Python Telethon get all admins of group

Viewed 2427

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=[
        ]
)
2 Answers

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)

Try passing the value 1 to the offset argument

Related