2016-09-04 12:07:18 +03:00
|
|
|
import tl_generator
|
|
|
|
from tl.telegram_client import TelegramClient
|
|
|
|
from utils.helpers import load_settings
|
2016-08-26 13:58:53 +03:00
|
|
|
|
2016-09-03 11:54:58 +03:00
|
|
|
|
2016-08-26 13:58:53 +03:00
|
|
|
if __name__ == '__main__':
|
2016-09-04 12:07:18 +03:00
|
|
|
if not tl_generator.tlobjects_exist():
|
|
|
|
print('Please run `python3 tl_generator.py` first!')
|
2016-08-28 14:43:00 +03:00
|
|
|
|
2016-09-04 12:07:18 +03:00
|
|
|
else:
|
|
|
|
settings = load_settings()
|
|
|
|
client = TelegramClient(session_user_id=settings.get('session_name', 'anonymous'),
|
2016-09-06 19:54:49 +03:00
|
|
|
layer=55,
|
2016-09-04 12:07:18 +03:00
|
|
|
api_id=settings['api_id'],
|
|
|
|
api_hash=settings['api_hash'])
|
|
|
|
|
|
|
|
client.connect()
|
2016-09-06 19:54:49 +03:00
|
|
|
input('You should now be connected. Press enter when you are ready to continue.')
|
2016-09-04 12:07:18 +03:00
|
|
|
if not client.is_user_authorized():
|
2016-09-06 19:54:49 +03:00
|
|
|
client.send_code_request(str(settings['user_phone']))
|
2016-09-05 19:35:12 +03:00
|
|
|
|
2016-09-04 12:07:18 +03:00
|
|
|
code = input('Enter the code you just received: ')
|
2016-09-06 19:54:49 +03:00
|
|
|
client.make_auth(settings['user_phone'], code)
|
|
|
|
|
|
|
|
else:
|
|
|
|
client.get_dialogs()
|