【问题标题】:Telethon trying to to add bot to channel or groupTelethon 尝试将机器人添加到频道或组
【发布时间】:2022-01-15 13:10:16
【问题描述】:

我正在尝试将机器人添加到频道,但每次尝试我都会收到以下错误消息:

telethon.errors.rpcerrorlist.BotMethodInvalidError: The API access for bot users is restricted. The method you tried to invoke cannot be executed as a bot

我的代码基本上是来自documentation 和这个doc 的复制粘贴

和代码

from telethon.sync import TelegramClient, events, functions, types
from telethon.tl.types import PeerChat, PeerChannel


bot = TelegramClient('bot', api_id, api_hash).start(bot_token=token)

with bot:
    print(bot.get_me())
# I have this link https://telegram.me/joinchat/<HASH>
    result = bot(functions.messages.ImportChatInviteRequest(hash="<HASH>"))
    print(result)

我使用@botfather,我的配置是:

  • AllowGroups:启用
  • GroupPrivacy:启用

我已阅读机器人无法加入频道或群组,除非您是管理员才能将机器人添加为管理员。如果是真的,为什么要在文档上发帖,你可以通过邀请链接来做到这一点?我无法加入群组或频道...

【问题讨论】:

    标签: python telegram-bot telethon


    【解决方案1】:

    对于用户帐户是可能的。 Telethon 确实支持 Telegram 机器人,但此功能用于个人帐户自动化。

    我理解这种混淆,但您要使用的功能是用于个人自动帐户,而不是用于实际的“机器人”帐户。

    在第一个文档中也提到了它: 导入聊天邀请请求 只有用户可以使用此方法

    【讨论】:

    • 哇!完美的!我误解了概念。我明白了!
    猜你喜欢
    • 1970-01-01
    • 2021-04-08
    • 2019-01-18
    • 2021-11-11
    • 1970-01-01
    • 1970-01-01
    • 2023-03-30
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多