From 1179c9e21bab3269f373d2c79b26801dc708cdac Mon Sep 17 00:00:00 2001 From: Lonami Exo Date: Sun, 18 Feb 2018 12:17:02 +0100 Subject: [PATCH] Fix start not asking for password if needed --- telethon/telegram_client.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/telethon/telegram_client.py b/telethon/telegram_client.py index 9888b9e5..e81171d4 100644 --- a/telethon/telegram_client.py +++ b/telethon/telegram_client.py @@ -1,3 +1,4 @@ +import getpass import hashlib import io import itertools @@ -216,8 +217,8 @@ class TelegramClient(TelegramBareClient): def start(self, phone=lambda: input('Please enter your phone: '), - password=None, bot_token=None, - force_sms=False, code_callback=None, + password=lambda: getpass.getpass('Please enter your password: '), + bot_token=None, force_sms=False, code_callback=None, first_name='New User', last_name=''): """ Convenience method to interactively connect and sign in if required, @@ -331,6 +332,9 @@ class TelegramClient(TelegramBareClient): "Two-step verification is enabled for this account. " "Please provide the 'password' argument to 'start()'." ) + # TODO If callable given make it retry on invalid + if callable(password): + password = password() me = self.sign_in(phone=phone, password=password) # We won't reach here if any step failed (exit by exception)