Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions telegram_mcp/tools/groups.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,12 +243,13 @@ async def get_participants(
cl = get_client(account)
await ensure_connected(cl)

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

if not participants:
return format_tool_result([])
Expand Down
Loading