mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2024-11-25 10:53:44 +03:00
Fix iter_messages was stopping too early in some channels
Closes #3949.
This commit is contained in:
parent
db29e9b7ef
commit
b6d8311a55
|
@ -204,7 +204,20 @@ class _MessagesIter(RequestIter):
|
||||||
message._finish_init(self.client, entities, self.entity)
|
message._finish_init(self.client, entities, self.entity)
|
||||||
self.buffer.append(message)
|
self.buffer.append(message)
|
||||||
|
|
||||||
if len(r.messages) < self.request.limit:
|
# Some channels are "buggy" and may return less messages than
|
||||||
|
# requested (apparently, the messages excluded are, for example,
|
||||||
|
# "not displayable due to local laws").
|
||||||
|
#
|
||||||
|
# This means it's not safe to rely on `len(r.messages) < req.limit` as
|
||||||
|
# the stop condition. Unfortunately more requests must be made.
|
||||||
|
#
|
||||||
|
# However we can still check if the highest ID is equal to or lower
|
||||||
|
# than the limit, in which case there won't be any more messages
|
||||||
|
# because the lowest message ID is 1.
|
||||||
|
#
|
||||||
|
# We also assume the API will always return, at least, one message if
|
||||||
|
# there is more to fetch.
|
||||||
|
if not r.messages or r.messages[0].id <= self.request.limit:
|
||||||
return True
|
return True
|
||||||
|
|
||||||
# Get the last message that's not empty (in some rare cases
|
# Get the last message that's not empty (in some rare cases
|
||||||
|
|
Loading…
Reference in New Issue
Block a user