-
-
Save sofa-dm/2f5fed4c7c1b9c01f5f3074b75e186f3 to your computer and use it in GitHub Desktop.
Revisions
-
aliforever created this gist
Aug 17, 2019 .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 @@ # After running the script in logging in to your account, send "forward_unseen:mister_x:10" to your saved messages, # the bot will then forward 10 last messages of the first user with name mister_x to your saved messages. # This way you can check what people have sent you without them knowing you did. from telethon import TelegramClient, events, sync from telethon.tl.types import PeerUser api_id = # Your Telegram API id here api_hash = # Your Telegram API hash here client = TelegramClient("Session_Name", api_id, api_hash) client.start() @client.on(events.NewMessage) async def my_event_handler(event): if "forward_unseen:" in event.raw_text: command = event.raw_text.split(":") name = command[1] count = command[2] for dialog in await client.iter_dialogs(): if dialog.title == name: user = client.get_entity(PeerUser(dialog.id)) i = 1 for chat in client.iter_messages(user): await client.forward_messages(client.get_me(), chat, user) if i >= count: break i += 1 break client.run_until_disconnected()