Skip to content

Commit 0d5c651

Browse files
authored
Merge pull request chigwell#171 from antonskiter/fix/iter-participants-offset
fix(groups): correct get_participants pagination
2 parents 92d5887 + bf05bd0 commit 0d5c651

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

telegram_mcp/tools/groups.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -243,12 +243,13 @@ async def get_participants(
243243
cl = get_client(account)
244244
await ensure_connected(cl)
245245

246-
# Use iter_participants with offset to fetch only the needed slice,
247-
# avoiding O(N) fetching on later pages.
246+
# iter_participants takes no `offset`, and its `limit` is not honoured
247+
# for basic groups. Fetch through the page, then slice it out.
248248
offset = (page - 1) * page_size
249249
participants = []
250-
async for participant in cl.iter_participants(chat_id, limit=page_size, offset=offset):
250+
async for participant in cl.iter_participants(chat_id, limit=offset + page_size):
251251
participants.append(participant)
252+
participants = participants[offset : offset + page_size]
252253

253254
if not participants:
254255
return format_tool_result([])

0 commit comments

Comments
 (0)