mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2024-11-30 05:13:45 +03:00
Fix start not asking for password if needed
This commit is contained in:
parent
33fd6895d3
commit
1179c9e21b
|
@ -1,3 +1,4 @@
|
||||||
|
import getpass
|
||||||
import hashlib
|
import hashlib
|
||||||
import io
|
import io
|
||||||
import itertools
|
import itertools
|
||||||
|
@ -216,8 +217,8 @@ class TelegramClient(TelegramBareClient):
|
||||||
|
|
||||||
def start(self,
|
def start(self,
|
||||||
phone=lambda: input('Please enter your phone: '),
|
phone=lambda: input('Please enter your phone: '),
|
||||||
password=None, bot_token=None,
|
password=lambda: getpass.getpass('Please enter your password: '),
|
||||||
force_sms=False, code_callback=None,
|
bot_token=None, force_sms=False, code_callback=None,
|
||||||
first_name='New User', last_name=''):
|
first_name='New User', last_name=''):
|
||||||
"""
|
"""
|
||||||
Convenience method to interactively connect and sign in if required,
|
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. "
|
"Two-step verification is enabled for this account. "
|
||||||
"Please provide the 'password' argument to 'start()'."
|
"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)
|
me = self.sign_in(phone=phone, password=password)
|
||||||
|
|
||||||
# We won't reach here if any step failed (exit by exception)
|
# We won't reach here if any step failed (exit by exception)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user