Make .start() more friendly by asking phone if not given

Ping #530
This commit is contained in:
Lonami Exo
2018-01-13 11:54:41 +01:00
parent ef3ea11e38
commit 77301378f8
3 changed files with 13 additions and 4 deletions

View File

@@ -231,7 +231,15 @@ class TelegramClient(TelegramBareClient):
'function that returns the code you received by Telegram.'
)
if (phone and bot_token) or (not phone and not bot_token):
if not phone and not bot_token:
value = input('Please enter your phone/bot token: ')
phone = utils.parse_phone(phone)
if not phone:
bot_token = value
print("Note: input doesn't look like a phone, "
"using as bot token")
if phone and bot_token:
raise ValueError(
'You must provide either a phone number or a bot token, '
'not both (or neither).'