-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

4

1 回答 1

-1

好吧,我真的很困惑,所以让我们回去吧。

在这段代码中,我只是尝试从用户聊天中检索最后的消息并将它们转发到我的机器人:

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)

打印是正确的,但我的机器人聊天没有收到任何内容。我知道会有很多错误所以请耐心等待并抱歉。

于 2017-12-27T13:14:01.483 回答