From 44e2ef6c798dccbae075a2f7f99ee657b9642a2f Mon Sep 17 00:00:00 2001 From: Lonami Exo Date: Fri, 23 Oct 2020 11:02:30 +0200 Subject: [PATCH] Don't error when failing to extract response messages --- telethon/client/messageparse.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/telethon/client/messageparse.py b/telethon/client/messageparse.py index 3a0fc268..664bd5b2 100644 --- a/telethon/client/messageparse.py +++ b/telethon/client/messageparse.py @@ -193,7 +193,13 @@ class MessageParseMethods: mapping = sched_to_message opposite = id_to_message # scheduled may be treated as normal, though - random_id = request if isinstance(request, (int, list)) else request.random_id + random_id = request if isinstance(request, (int, list)) else getattr(request, 'random_id', None) + if random_id is None: + # Can happen when pinning a message does not actually produce a service message. + self._log[__name__].warning( + 'No random_id in %s to map to, returning None message for %s', request, result) + return None + if not utils.is_list_like(random_id): msg = mapping.get(random_to_id.get(random_id)) if not msg: