Telethon试图将机器人添加到频道或群组中



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

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

我的代码基本上是文档和这个文档的副本

和代码

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:enable
  • GroupPrivacy:已启用

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

这对于用户帐户来说是可能的。Telethon确实支持Telegram机器人程序,但此功能旨在实现个人账户自动化。

我理解这种困惑,但你想使用的功能是用于个人自动账户,而不是用于实际的";bot";账户

在第一份文件中也提到:ImportChatInviteRequest只有用户才能使用此方法

最新更新