问题描述
我希望有人可以将我的机器人添加到他的频道。为此,我想将频道的 webhook (chat.id) 保存在数据库中。
我的代码:
async with bot.conversation(chat.id) as conv:
await conv.send_message("Which channel you want add? (invite link of the channel):")
resp = await conv.get_response()
hookName = resp.message
hook = await bot.get_entity(hookName)
print(hook)
print(hook.chat_id)
print(hook.user_id)
当我使用邀请链接时,我在 get_entity 行收到此错误:
telethon.errors.rpcerrorlist.BotMethodInvalidError: The API access for bot users is restricted. The method you tried to invoke cannot be executed as a bot (caused by CheckChatInviteRequest)
ValueError: No user has "channelname" as username
我想知道为什么当我对频道名称进行硬编码而不是作为响应时它会起作用...
如果用户只需输入聊天名称或频道名称或邀请链接,我就可以从中获取 ID,那就太好了。
有没有办法做到这一点?
谢谢:)
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)