首页 > 解决方案 > 如何使用 Telethon 从频道 ID 获取参与者

问题描述

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

channel - InputChannel - 如果库可以找到其输入版本(例如,用户名、Peer、User 或 Channel 对象等),任何类似实体的东西都可以工作

我的代码:

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:无效的通道对象。确保传递正确的类型,例如确保请求是为通道设计的,或者寻找更适合的不同类型(由 GetParticipantsRequest 引起)

该组是私人的,所以它没有用户名,但我还是得到了 GROUP_ID 和 GROUP_HASH,我怎样才能得到所有成员的列表?

谢谢

标签: pythonapitelegramtelethon

解决方案


推荐阅读