Created
September 18, 2020 03:54
-
-
Save xuewei4d/222346de1a05320676830c72bf3a387c to your computer and use it in GitHub Desktop.
telegram app which just forwards messages
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 characters
from telethon.sync import TelegramClient, events | |
api_id= '' | |
api_hash = '' | |
mvp_usernames = ['abcd'] | |
source_channel_id = 9999 # # set source channel id here | |
dest_channel_id = 9999 # set dest channel id here | |
with TelegramClient('name', api_id, api_hash) as client: | |
@client.on(events.NewMessage(chats=source_channel_id)) | |
async def handler(event): | |
sender = await event.get_sender() | |
if sender.username in mvp_usernames and event.raw_text.strip() != '': | |
await client.send_message(dest_channel_id, '{}: {}'.format(sender.first_name, event.raw_text)) | |
client.run_until_disconnected() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment