-
Notifications
You must be signed in to change notification settings - Fork 143
Open
Description
User Story
As a user managing large Telegram groups,
I want paginated access to group participants
so that I can reliably retrieve complete membership lists without data loss.
Background
The current get_participants() implementation in main.py uses Telethon's default limit, risking incomplete data retrieval in groups with >200 members. This violates data completeness requirements and prevents analysis of large communities. The function currently:
- Calls
client.get_participants()without pagination parameters - Returns results as immediate list
- Lacks control over batch sizes
Key risks:
- Telegram API limits (400 users per request default)
- Memory issues with large participant lists
- Timeouts in massive groups
Acceptance Criteria
- Modify
main.py'sget_participants()tool implementation - Add
page(1-indexed) andpage_size(default 200) parameters - Implement pagination using Telethon's
limitandoffsetparameters - Convert to async generator using
client.iter_participants() - Add safety limit (max 1000 participants/page)
- Preserve current text output format with pagination metadata
Validation:
- Test with group containing 1500 participants - verify 8 pages (7x200 + 1x100)
- Confirm no duplicate IDs across consecutive pages
- Verify error handling for invalid page numbers
- Check memory usage stays under 50MB for 1000-user batches
Implementation Note:
Leverage Telethon's async for participant in client.iter_participants() with limit and offset for efficient pagination while maintaining session state.