mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2025-12-04 16:53:55 +03:00
parent
5f69650e38
commit
c1f3f924d9
|
|
@ -167,7 +167,7 @@ class _MessagesIter(RequestIter):
|
||||||
|
|
||||||
# When going in reverse we need an offset of `-limit`, but we
|
# When going in reverse we need an offset of `-limit`, but we
|
||||||
# also want to respect what the user passed, so add them together.
|
# also want to respect what the user passed, so add them together.
|
||||||
if self.reverse:
|
if self.reverse and hasattr(self.request, 'add_offset'):
|
||||||
self.request.add_offset -= _MAX_CHUNK_SIZE
|
self.request.add_offset -= _MAX_CHUNK_SIZE
|
||||||
|
|
||||||
self.add_offset = add_offset
|
self.add_offset = add_offset
|
||||||
|
|
@ -176,10 +176,11 @@ class _MessagesIter(RequestIter):
|
||||||
self.last_id = 0 if self.reverse else float('inf')
|
self.last_id = 0 if self.reverse else float('inf')
|
||||||
|
|
||||||
async def _load_next_chunk(self):
|
async def _load_next_chunk(self):
|
||||||
self.request.limit = min(self.left, _MAX_CHUNK_SIZE)
|
if hasattr(self.request, 'limit'):
|
||||||
if self.reverse and self.request.limit != _MAX_CHUNK_SIZE:
|
self.request.limit = min(self.left, _MAX_CHUNK_SIZE)
|
||||||
# Remember that we need -limit when going in reverse
|
if self.reverse and self.request.limit != _MAX_CHUNK_SIZE:
|
||||||
self.request.add_offset = self.add_offset - self.request.limit
|
# Remember that we need -limit when going in reverse
|
||||||
|
self.request.add_offset = self.add_offset - self.request.limit
|
||||||
|
|
||||||
r = await self.client(self.request)
|
r = await self.client(self.request)
|
||||||
self.total = getattr(r, 'count', len(r.messages))
|
self.total = getattr(r, 'count', len(r.messages))
|
||||||
|
|
@ -205,7 +206,7 @@ class _MessagesIter(RequestIter):
|
||||||
self.buffer.append(message)
|
self.buffer.append(message)
|
||||||
|
|
||||||
# Not a slice (using offset would return the same, with e.g. SearchGlobal).
|
# Not a slice (using offset would return the same, with e.g. SearchGlobal).
|
||||||
if isinstance(r, types.messages.Messages):
|
if isinstance(r, types.messages.Messages) or not hasattr(self.request, 'limit'):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
# Some channels are "buggy" and may return less messages than
|
# Some channels are "buggy" and may return less messages than
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user