Python Telethon 获取组的所有管理员 [英] Python Telethon get all admins of group

查看:133
本文介绍了Python Telethon 获取组的所有管理员的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想获得 Telegram 群组的管理员,我尝试使用此代码,但得到空响应,我的代码

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())

这是我收到的回复

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

推荐答案

根据 客户端参考,你可以使用client.iter_participants 以遍历组的参与者.此外,您可以使用 filter 参数来缩小结果范围.该文档还包括此示例:

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)

这篇关于Python Telethon 获取组的所有管理员的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆