I’m implementing a code to forward Telegram messages from one channel to another channel I can forward messages but I cannot find a way to update the Source messages when the destination message edited or deleted
Here is the code i already have this is working fine
client = TelegramClient('telegramfw', api_id, api_hash)
@client.on(events.NewMessage)
@client.on(events.MessageEdited)
async def handler(event):
chat = await event.get_chat()
chat_id = event.chat_id
print(chat_id)
if chat_id == -1001629488043:
if event.photo:
await client.send_file(-1001567215170, event.photo, caption=event.raw_text)
elif event.video:
await client.send_file(-1001567215170, event.video, caption=event.raw_text)
else:
msg = event.raw_text
print(msg)
msg_id_source = event.message.id
await client.send_message(-1001567215170, msg)
client.start()
client.run_until_disconnected()
Is there any way to do this im new to python and telethon it is grate help some one can help with
3
Answers
Found the solutions i dont know is this the correct way but it solve my problem
Need to keep message id's in a database and telethon have an option to get edited message
i used SQLite for DB that is inbuilt with python
here is the code i use
Let me know if any one need any help with this
i’m also want to know that how to add two decorate on a handler,please
but i don’t think it is a elegent way