如何使用Telethon从通道id获取参与者

2024-10-04 11:27:14 发布

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

我正在尝试将GetParticipantsRequest()与第一个参数一起用作文档:

channel - InputChannel - Anything entity-like will work if the library can find its Input version (e.g., usernames, Peer, User or Channel objects, etc.)

我的代码:

newInputChannel = InputChannel(channelId, channelHash)


all_participants = await client(functions.channels.GetParticipantsRequest(
        newInputChannel,
        filter=types.ChannelParticipantsRecent(),
        offset=42,
        limit=100,
        hash=0
)) 

但我得到了一个错误:

telethon.errors.rpcerrorlist.ChannelInvalidError: Invalid channel object. Make sure to pass the right types, for instance making sure that the request is designed for channels or otherwise look for a different one more suited (caused by GetParticipantsRequest)

该组是私有的,因此它没有用户名,但我无论如何都会获取组ID和组哈希,如何获取所有成员的列表

多谢各位


Tags: orthe文档for参数channelliketypes