在电报上发送消息:"Forbidden: bot is not a member of the supergroup chat" 或 "Forbidden: bot is not a member of the channel chat"

Send a message on telegram: "Forbidden: bot is not a member of the supergroup chat" or "Forbidden: bot is not a member of the channel chat"

我正在尝试通过电报聊天发送消息。 我希望电报设置只能由官方 UI 完成,因为我希望它可能由最终用户完成。

这是我做的电报设置:

以下是频道管理员的设置:

在一天结束时,chat/group 的设置在电报 UI 中如下:

我进行了以下 http 调用:

GET https://api.telegram.org/botXXXXXXTOKENXXXXXXX/sendMessage?chat_id=@TestChannelChat&text=coucou

这给了我以下答案:

{
  "ok": false,
  "error_code": 403,
  "description": "Forbidden: bot is not a member of the supergroup chat"
}

我还做了以下(绕过实际聊天,直接在频道中发布消息):

GET https://api.telegram.org/botXXXXXXTOKENXXXXXXX/sendMessage?chat_id=@TestChannel&text=coucou

这给了我以下答案:

{
  "ok": false,
  "error_code": 403,
  "description": "Forbidden: bot is not a member of the channel chat"
}

一个简单的问题,作为一个 bot 也意味着广播消息,我缺少它的哪一部分设置?

您在使用 Telegram 机器人方面走在正确的轨道上。不过先了解一下chat_id.

chat_id 是聊天的聊天 用户名id。您只能为 Public chats/groups 设置用户名。在您的情况下,您有一个私人群组,并且没有用户名。您传递 @TestChannelChatchat_id 值不属于您的聊天。您必须传递聊天的 id 或设置 public 用户名并传递它。

如果您不知道如何查看聊天的 id,请阅读此处: