尝试使用telethon加入频道时出现值错误

2024-09-27 23:27:09 发布

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

我有一个代码,我需要加入一个给定的通道,但得到以下错误

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 JoinChannelRequest)

我的代码:

group_input = InputChannel(group.id, group.access_hash)
client(JoinChannelRequest(group_input))

这里我使用inputChannel,因为我查看了joinChannelRequest,它要求输入“TypeInputChannel” 它是[InputChannelEmpty,InputChannel,InputChannelFromMessage]的联合体

我试过的另一件事:

1-

client(JoinChannelRequest(group.id))

2-

client(JoinChannelRequest(group))

3-

group_input = InputPeerChannel(group.id, group.access_hash)
client(JoinChannelRequest(group_input))

Tags: the代码clientidforinputaccess错误
1条回答
网友
1楼 · 发布于 2024-09-27 23:27:09

最简单的方法是检索公共频道的用户名
假设频道的用户名为@The_Channel
获取实体
entity = client.get_entity("t.me/The_Channel") #omit @
然后调用此函数
client(JoinChannelRequest(entity))

相关问题 更多 >

    热门问题