from telethon import TelegramClient, events import pathlib # Remember to use your own values from my.telegram.org! api_id = 12345 api_hash = '0123456789abcdef0123456789abcdef' # Replace the checkin bot and text with yourown checkin_at_bot_id = '@checkin_bot' checkin_text = '/checkin' # where to save the login session session_name = pathlib.Path.home() / '.tg-auto-checkin' client = TelegramClient(str(session_name), api_id, api_hash) # handle reply message from checkin_bot @client.on(events.NewMessage(chats=checkin_at_bot_id)) async def handler(event): print(event.message.text) await client.disconnect() async def main(): # Getting information about yourself # me = await client.get_me() # "me" is a user object. You can pretty-print # any Telegram object with the "stringify" method: # print(me.stringify()) await client.send_message(checkin_at_bot_id, checkin_text) # disconnet after handle the reply message from checkin_bot await client.run_until_disconnected() if __name__ == '__main__': with client: client.loop.run_until_complete(main())