From 233daafd962df13292347e3484dcb8185a9edbea Mon Sep 17 00:00:00 2001 From: Lonami Exo Date: Thu, 1 Oct 2020 13:18:54 +0200 Subject: [PATCH] Fix global search would fail if last message had no peer --- telethon/client/messages.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/telethon/client/messages.py b/telethon/client/messages.py index 32014136..c30c686b 100644 --- a/telethon/client/messages.py +++ b/telethon/client/messages.py @@ -240,7 +240,11 @@ class _MessagesIter(RequestIter): self.request.offset_date = last_message.date if isinstance(self.request, functions.messages.SearchGlobalRequest): - self.request.offset_peer = last_message.input_chat + if last_message.input_chat: + self.request.offset_peer = last_message.input_chat + else: + self.request.offset_peer = types.InputPeerEmpty() + self.request.offset_rate = getattr(response, 'next_rate', None)