Advertisement
disk6969

iter_call_participants

Dec 1st, 2023 (edited)
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.70 KB | None | 0 0
  1. from telethon.tl.functions.phone import GetGroupParticipantsRequest
  2. from telethon.tl.functions.channels import GetFullChannelRequest
  3. from telethon.utils import get_peer_id
  4.  
  5. async def iter_call_participants(chat_id):
  6.   call = (
  7.     await client(GetFullChannelRequest(chat_id))
  8.   ).full_chat.call
  9.   offset = ""
  10.   while True:
  11.     r = await client(
  12.       GetGroupParticipantsRequest(
  13.         call=call,
  14.         ids=[],
  15.         sources=[],
  16.         offset=offset,
  17.         limit=20,
  18.       )
  19.     )
  20.     if not r.next_offset: break
  21.     offset = r.next_offset
  22.     entities = {u.id: u for u in r.users + r.chats}
  23.     for p in r.participants:
  24.       p.entity = entities.get(get_peer_id(p.peer))
  25.       yield p
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement