Easy method

Lonami 2018-06-25 09:27:26 +02:00
parent 0a8a6a2817
commit 5332a57838

@ -1,20 +1,5 @@
Note that [`ForwardMessageRequest`](https://lonamiwebs.github.io/Telethon/methods/messages/forward_message.html) (note it's *Message*, singular) will **not** work if channels are involved. This is because channel (and megagroups) IDs are not unique, so you also need to know who the sender is (a parameter this request doesn't have). The following code will forward several `messages` to `chat`. The messages that will be forwarded are currently in `original_chat`. You can also use a single message, or just their IDs.
Either way, you are encouraged to use [`ForwardMessagesRequest`](https://lonamiwebs.github.io/Telethon/methods/messages/forward_messages.html) (note it's _Message**s**_, plural) **always**, since it is more powerful, as follows:
```python ```python
from telethon.tl.functions.messages import ForwardMessagesRequest client.forward_messages(chat, messages, original_chat)
# note the s ^ ```
messages = foo() # retrieve a few messages (or even one, in a list)
from_entity = bar()
to_entity = baz()
client(ForwardMessagesRequest(
from_peer=from_entity, # who sent these messages or what channel sent in?
id=[msg.id for msg in messages], # which are the messages?
to_peer=to_entity # who or what channel are we forwarding them to?
))
```
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.