From acfde7132b20e0d857b2e0886982461a0d8f7da4 Mon Sep 17 00:00:00 2001 From: Lonami Exo Date: Wed, 8 Feb 2023 17:35:49 +0100 Subject: [PATCH] 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). --- telethon/client/messages.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/telethon/client/messages.py b/telethon/client/messages.py index 16a2b3d7..d7729a80 100644 --- a/telethon/client/messages.py +++ b/telethon/client/messages.py @@ -1018,7 +1018,7 @@ class MessageMethods: if isinstance(chunk[0], int): chat = from_peer 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] req = functions.messages.ForwardMessagesRequest(