Make pylint happier on print_updates example (#387)

This commit is contained in:
Tanuj 2017-10-26 17:03:24 +01:00 committed by Lonami
parent e6ac61c1b9
commit 403c7bd00a

View File

@ -1,12 +1,13 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
# A simple script to print all updates received # A simple script to print all updates received
from telethon import TelegramClient
from getpass import getpass from getpass import getpass
from os import environ from os import environ
# environ is used to get API information from environment variables # environ is used to get API information from environment variables
# You could also use a config file, pass them as arguments, # You could also use a config file, pass them as arguments,
# or even hardcode them (not recommended) # or even hardcode them (not recommended)
from telethon import TelegramClient
from telethon.errors import SessionPasswordNeededError
def main(): def main():
session_name = environ.get('TG_SESSION', 'session') session_name = environ.get('TG_SESSION', 'session')
@ -30,8 +31,8 @@ def main():
try: try:
code_ok = client.sign_in(user_phone, code) code_ok = client.sign_in(user_phone, code)
except SessionPasswordNeededError: except SessionPasswordNeededError:
pw = getpass('Two step verification enabled. Please enter your password: ') password = getpass('Two step verification enabled. Please enter your password: ')
code_ok = client.sign_in(password=pw) code_ok = client.sign_in(password=password)
print('INFO: Client initialized succesfully!') print('INFO: Client initialized succesfully!')
client.add_update_handler(update_handler) client.add_update_handler(update_handler)