From 403c7bd00a52fd716a35b71f7389684245e76ed8 Mon Sep 17 00:00:00 2001 From: Tanuj Date: Thu, 26 Oct 2017 17:03:24 +0100 Subject: [PATCH] Make pylint happier on print_updates example (#387) --- telethon_examples/print_updates.py | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/telethon_examples/print_updates.py b/telethon_examples/print_updates.py index c90302e4..ab7ba1d4 100755 --- a/telethon_examples/print_updates.py +++ b/telethon_examples/print_updates.py @@ -1,21 +1,22 @@ #!/usr/bin/env python3 # A simple script to print all updates received -from telethon import TelegramClient from getpass import getpass from os import environ # 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) +from telethon import TelegramClient +from telethon.errors import SessionPasswordNeededError def main(): - session_name = environ.get('TG_SESSION','session') + session_name = environ.get('TG_SESSION', 'session') user_phone = environ['TG_PHONE'] client = TelegramClient(session_name, - int(environ['TG_API_ID']), - environ['TG_API_HASH'], - proxy=None, - update_workers=4) + int(environ['TG_API_ID']), + environ['TG_API_HASH'], + proxy=None, + update_workers=4) print('INFO: Connecting to Telegram Servers...', end='', flush=True) client.connect() @@ -30,15 +31,15 @@ def main(): try: code_ok = client.sign_in(user_phone, code) except SessionPasswordNeededError: - pw = getpass('Two step verification enabled. Please enter your password: ') - code_ok = client.sign_in(password=pw) + password = getpass('Two step verification enabled. Please enter your password: ') + code_ok = client.sign_in(password=password) print('INFO: Client initialized succesfully!') client.add_update_handler(update_handler) input('Press Enter to stop this!\n') def update_handler(update): - print(update) + print(update) print('Press Enter to stop this!') if __name__ == '__main__':