python - Python Telethon 获取组的所有管理员
问题描述
我想获得电报组的管理员,我尝试使用此代码,但我得到空响应,我的代码
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
参数来缩小结果范围。该文档还包括此示例:
# Filter by admins
from telethon.tl.types import ChannelParticipantsAdmins
async for user in client.iter_participants(chat, filter=ChannelParticipantsAdmins):
print(user.first_name)
推荐阅读
- python - 将 postgres 表导出到 yaml 文件
- python - SQLite 和 Python 的问题
- c# - C# 调用字典
基于从另一个字典返回的值 - python - Instabot 信号仅在主线程中有效
- json - 如何使用 JMeter 中的 JSON 提取器提取 JSON 响应中的嵌套元素
- python - python请求的HTTPS连接错误
- python - 模型返回错误 - ValueError:logits 和标签必须具有相同的形状 ((None, 18) vs (None, 1))
- javascript - 如何使用 jQuery 设置 php 值的颜色?
- c# - 使 REST API 仅响应已知客户端
- pre-commit.com - 预提交无法在 docker 容器中运行