fix(groups): correct get_participants pagination - #171
Merged
Conversation
antonskiter
force-pushed
the
fix/iter-participants-offset
branch
2 times, most recently
from
July 28, 2026 10:58
38c3762 to
1438a11
Compare
Two independent defects made every page beyond the first wrong: 1. TelegramClient.iter_participants takes no `offset` kwarg — its signature is (entity, limit=None, *, search, filter, aggressive) — so passing offset= raised TypeError for page > 1. 2. `limit` does not bound basic groups. _ParticipantsIter._init buffers the whole participant list and returns True, and RequestIter.__anext__ then sets `left` to the buffer length, discarding the requested limit. A page of a basic group therefore ran past page_size. Skip to the start of the requested page and stop once it is full. `limit` is still passed so channels, where it is honoured, do not over-fetch. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
antonskiter
force-pushed
the
fix/iter-participants-offset
branch
from
July 28, 2026 11:01
1438a11 to
db87ad2
Compare
chigwell
approved these changes
Jul 28, 2026
KiaroSama
pushed a commit
to KiaroSama/telegram-mcp
that referenced
this pull request
Aug 25, 2026
…s-offset fix(groups): correct get_participants pagination
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #170.
get_participantspagination has two independent defects; this fixes both intelegram_mcp/tools/groups.py.1.
iter_participantshas nooffsetparameter. Telethon's signature is(entity, limit=None, *, search, filter, aggressive)— nooffset, in the v1 source or the 1.44.0 docs, and the project requirestelethon>=1.44.0. Sinceoffsetis passed unconditionally, every call raisesTypeError.2.
limitdoes not bound basic groups. Intelethon/requestiter.py:For
_EntityType.CHAT,_ParticipantsIter._initbuffers the whole participant list and returnsTrue, soleftis overwritten with the buffer length and the requestedlimitis discarded. Channels are unaffected — there_initreturns falsy. Solimitalone cannot bound a page.Fix. Skip to the start of the requested page and stop once it is full, relying on neither
offsetnorlimit.limitis still passed so channels do not over-fetch.Verification. Against a live account on telethon 1.44.0:
page_size=2— pages 1/2/3 each return 2 non-overlapping participants in list order, page 4 returns emptypage_size=3— pages 1 and 2 each return 3, disjointBefore the fix the same calls returned a formatted
TypeError; with only defect 1 fixed,page=1, page_size=1on the basic group returned all 6 participants.No behaviour change for
page=1, page_size=200(the defaults) beyond it no longer erroring.