From 40bc1c3466902aa226dcf748adf73a317a999c1c Mon Sep 17 00:00:00 2001 From: Lonami Date: Fri, 9 Jun 2017 15:40:10 +0200 Subject: [PATCH] Created Forwarding messages (markdown) --- Forwarding-messages.md | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 Forwarding-messages.md diff --git a/Forwarding-messages.md b/Forwarding-messages.md new file mode 100644 index 0000000..8f947bb --- /dev/null +++ b/Forwarding-messages.md @@ -0,0 +1,21 @@ +For some reason, [`ForwardMessageRequest`](https://lonamiwebs.github.io/Telethon/methods/messages/forward_message.html) (note it's *Message*, singular) does **not** seem to work. + +You should use [`ForwardMessagesRequest`](https://lonamiwebs.github.io/Telethon/methods/messages/forward_messages.html) (note it's _Message**s**_, plural) as follows: + +```python +from telethon.utils import generate_random_long +from telethon.helpers import get_input_peer + +messages = foo() # Logic to retrieve a few messages. +from_entity = bar() # Who has the original messages. +to_entity = baz() # Who you want to forward them to. + +client.invoke(ForwardMessagesRequest( + from_peer=get_input_peer(from_entity), + id=[msg.id for msg in messages], + random_id=[generate_random_long() for _ in range(len(messages))], + to_peer=get_input_peer(to_entity) +)) +``` + +The named arguments are there for clarity, although they're not needed because they appear in order. You can obviously just wrap a single message on the list too, if that's all you have. \ No newline at end of file