From 9a6f4d35f22ed5d70697c0aa00e0d6c69da312bc Mon Sep 17 00:00:00 2001 From: Lonami Exo Date: Thu, 29 Nov 2018 14:19:56 +0100 Subject: [PATCH] Fix crash on get_messages(ids=InputMessageReplyTo) --- telethon/client/messages.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/telethon/client/messages.py b/telethon/client/messages.py index 02dcba67..f8d07f6c 100644 --- a/telethon/client/messages.py +++ b/telethon/client/messages.py @@ -103,6 +103,15 @@ class MessageMethods(UploadMethods, ButtonMethods, MessageParseMethods): will appear in its place, so that zipping the list of IDs with the messages can match one-to-one. + .. note:: + + At the time of writing, Telegram will **not** return + :tl:`MessageEmpty` for :tl:`InputMessageReplyTo` IDs that + failed (i.e. the message is not replying to any, or is + replying to a deleted message). This means that it is + **not** possible to match messages one-by-one, so be + careful if you use non-integers in this parameter. + reverse (`bool`, optional): If set to ``True``, the messages will be returned in reverse order (from oldest to newest, instead of the default newest @@ -359,7 +368,8 @@ class MessageMethods(UploadMethods, ButtonMethods, MessageParseMethods): msgs.append(x) msgs.total = total[0] if 'ids' in kwargs and not utils.is_list_like(kwargs['ids']): - return msgs[0] + # Check for empty list to handle InputMessageReplyTo + return msgs[0] if msgs else None return msgs