Support Message without client as inputs to forward_messages

Raw API does not monkey-patch the client on the returned messages,
so the get_input_chat call would return None, causing the forward
to fail. Instead, manually resolve the chat using the message's
peer_id.

The resolve call can also be avoided if from_peer is passed (which
may mismatch with where the messages actually belong, but that's not
really a concern).
This commit is contained in:
Lonami Exo 2023-02-08 17:35:49 +01:00
parent 610b8c34dd
commit acfde7132b

View File

@ -1018,7 +1018,7 @@ class MessageMethods:
if isinstance(chunk[0], int): if isinstance(chunk[0], int):
chat = from_peer chat = from_peer
else: else:
chat = await chunk[0].get_input_chat() chat = from_peer or await self.get_input_entity(chunk[0].peer_id)
chunk = [m.id for m in chunk] chunk = [m.id for m in chunk]
req = functions.messages.ForwardMessagesRequest( req = functions.messages.ForwardMessagesRequest(