Python Telethon 获取组的所有管理员

编程入门 行业动态 更新时间:2024-10-21 15:54:50
本文介绍了Python Telethon 获取组的所有管理员的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时送ChatGPT账号..

我想获得 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屋!

更多推荐

[db:关键词]

本文发布于:2023-05-01 07:11:25,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1405910.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:管理员   Python   Telethon

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!