Fix get_dialogs could fail when count % chunk_size = 0

Closes #3971.
This commit is contained in:
Lonami Exo 2022-11-09 16:12:17 +01:00
parent fb43f638ff
commit 2c85ffea12

View File

@ -91,8 +91,9 @@ class _DialogsIter(RequestIter):
cd.entity, 'migrated_to', None) is None:
self.buffer.append(cd)
if len(r.dialogs) < self.request.limit\
if not self.buffer or len(r.dialogs) < self.request.limit\
or not isinstance(r, types.messages.DialogsSlice):
# Buffer being empty means all returned dialogs were skipped (due to offsets).
# Less than we requested means we reached the end, or
# we didn't get a DialogsSlice which means we got all.
return True