skip to Main Content

I want to get admins of Telegram groups, I try with this code but I get empty response, my code

client.connect()
if not client.is_user_authorized():
    client.send_code_request(phone)
    client.sign_in(phone, input('Enter the code: '))
result = client(functions.channels.GetParticipantsRequest(
    channel='mychannel',
    filter=types.ChannelParticipantsAdmins(),
    offset=42,
    limit=100,
    hash=0
))
print(result.stringify())

this is my response I’ve got

ChannelParticipants(
        count=1,
        participants=[
        ],
        users=[
        ]
)

3

Answers


  1. Try passing the value 1 to the offset argument

    Login or Signup to reply.
  2. As per the client reference, you can use client.iter_participants to iterate over the participants of a group. Furthermore, you can use the filter parameter to narrow down the results. The documentation also includes this example:

    # Filter by admins
    from telethon.tl.types import ChannelParticipantsAdmins
    async for user in client.iter_participants(chat, filter=ChannelParticipantsAdmins):
        print(user.first_name)
    
    Login or Signup to reply.
  3. I know your question is for long time ago, but still maybe someone had same question.
    Answer:
    your code is correct and return all admins of channel. and it have only 1 admin (showen by ‘count=1’ in your result).
    but you set ‘offset’ parameter to 42, but it has only 1 admin. so it show empty result.
    if your channel had let say 50 admins (indexing 0-49), by setting ‘offset’ to 42 it shows you from index 42 to 49.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search