Created Forwarding messages (markdown)

Lonami 2017-06-09 15:40:10 +02:00
parent b9380c745b
commit 40bc1c3466

21
Forwarding-messages.md Normal file

@ -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.