Last active
March 19, 2024 09:35
-
-
Save crazygit/1fbacfba604f9c7b2a616033ca5b81a1 to your computer and use it in GitHub Desktop.
Revisions
-
crazygit revised this gist
Aug 24, 2022 . 1 changed file with 2 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -4,6 +4,8 @@ # 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' -
crazygit created this gist
Aug 24, 2022 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,33 @@ from telethon import TelegramClient, events import pathlib # Remember to use your own values from my.telegram.org! api_id = 12345 api_hash = '0123456789abcdef0123456789abcdef' 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())