Python Telethon获得组中的所有管理员

2024-10-05 10:05:39 发布

您现在位置:Python中文网/ 问答频道 /正文

我想得到电报组的管理员,我试着用这个代码,但我得到了空的响应,我的代码

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

Tags: 代码clientsendifisrequest管理员connect
2条回答

尝试将值1传递给偏移量参数

根据client reference,您可以使用^{}迭代组的参与者。此外,您可以使用filter参数来缩小结果范围。文档还包括以下示例:

# Filter by admins
from telethon.tl.types import ChannelParticipantsAdmins
async for user in client.iter_participants(chat, filter=ChannelParticipantsAdmins):
    print(user.first_name)

相关问题 更多 >

    热门问题