-1

I would like to forward every updates from channels to my bot. Is it Possible with ForwardMessagesRequest ? I tried to use this Telethon example to build my personal code:

https://github.com/LonamiWebs/Telethon/wiki/Forwarding-messages

But i wasn't able to do it. And i don't know if it's possible to use that part of code inside a callback function. Someone can help me? Thank you

etnic90
  • 1
  • 1
  • 2

1 Answers1

-1

Ok, i'm really confused so let's go back.

In this code I just try to retrieve last messages from an user chat and forward them to my bot:

def callback(update):

source_chat_id = "here i put the user id"
source_hash = "here i put his access_hash"

source_chat = InputPeerUser(source_chat_id, source_hash)
total_count, messages, senders = client.get_message_history(
                source_chat, limit=10)

for msg in reversed(messages):
    print ("msg:", msg.id, msg)

msg = messages[0]    
print ("msg id:", msg.id)

dest_chat = "here i tried to put the number of my bot ID"   

result = client.invoke(ForwardMessagesRequest(from_peer=source_chat, id=[msg.id], random_id=[generate_random_long()], to_peer=dest_chat))


client.add_update_handler(callback)

The print was correct but i didn't receive anything to my bot chat. I know that there will be a lot of errors so please be patient and sorry.

etnic90
  • 1
  • 1
  • 2