From 88e7f0da654661e659e871ff99201fe477a01c4e Mon Sep 17 00:00:00 2001 From: Lonami Exo Date: Sun, 24 May 2020 18:35:06 +0200 Subject: [PATCH] Fix return value when fwding msgs if some are missing It was supposed to return None for the spots were it failed to fwd a message, but instead only those that were present were returned, because we were iterating over the wrong object (dict and not list). --- telethon/client/messageparse.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/telethon/client/messageparse.py b/telethon/client/messageparse.py index 1815f305..bb7c3a3b 100644 --- a/telethon/client/messageparse.py +++ b/telethon/client/messageparse.py @@ -211,13 +211,18 @@ class MessageParseMethods: # deleted or `WORKER_BUSY_TOO_LONG_RETRY` if there are issues at # Telegram), in which case we get some "missing" message mappings. # Log them with the hope that we can better work around them. + # + # This also happens when trying to forward messages that can't + # be forwarded because they don't exist (0, service, deleted) + # among others which could be (like deleted or existing). self._log[__name__].warning( 'Request %s had missing message mappings %s', request, result) return [ - mapping.get(random_to_id.get(rnd)) - or opposite.get(random_to_id.get(rnd)) - for rnd in random_to_id + (mapping.get(random_to_id[rnd]) or opposite.get(random_to_id[rnd])) + if rnd in random_to_id + else None + for rnd in random_id ] # endregion