from telethon import TelegramClient with open('data/tg_api_id.txt') as f: api_id = f.read().strip() with open('data/tg_app_api_hash.txt') as f: api_hash = f.read().strip() with TelegramClient('data/session.session', api_id, api_hash) as client: client.loop.run_until_complete(client.send_message('me', 'Hello, myself!'))