簡體   English   中英

Telethon 嘗試將機器人添加到頻道或組

[英]Telethon trying to to add bot to channel or group

我正在嘗試將機器人添加到頻道,但每次嘗試我都會收到此錯誤消息:

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:啟用
  • GroupPrivacy:啟用

我已閱讀機器人無法加入頻道或群組,除非您是管理員才能將機器人添加為管理員。 如果是真的,為什么要在文檔上發帖,你可以通過邀請鏈接來做到這一點? 我無法加入群組或頻道...

用戶帳戶是可能的。 Telethon 確實支持 Telegram 機器人,但此 function 用於個人帳戶自動化。

我理解這種混淆,但您要使用的功能是用於個人自動帳戶,而不是用於實際的“機器人”帳戶。

在第一個文檔中也提到了: ImportChatInviteRequest Only users can use this method

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM