为电报组分配特定的聊天ID

发布于 2025-02-11 06:22:21 字数 526 浏览 2 评论 0原文

尝试分配一个聊天ID以使我的脚本或bot仅在特定聊天组上发送消息,目前在我的测试中,我只能使用bot消息框与我的bot进行交互,一旦我发送消息,我的机器人将回复我的聊天,我可以知道我需要修改脚本以使我分配特定的聊天ID,以便我只能在特定组上与机器人进行通信吗?

我的脚本

function sendText(chatid,text,replymarkup){
var data = {
    method: "post",
    payload: {
      method: "sendMessage",
      chat_id: String (chatid),
      text: text,
      parse_mode: "HTML",
      reply_markup: JSON.stringify(replymarkup)
    }
  };
  UrlFetchApp.fetch('https://api.telegram.org/bot' + BotToken + '/', data);
}

Trying to assign an chat ID to make my script or bot send a message on specific chat group only, currently on my testing I can interact with my bot using bot message box only, once I send a message my bot will reply to my chat, May I know what I need to modify with my script for me to assign specific chat id so I can communicate with my bot on specific group only?

My script

function sendText(chatid,text,replymarkup){
var data = {
    method: "post",
    payload: {
      method: "sendMessage",
      chat_id: String (chatid),
      text: text,
      parse_mode: "HTML",
      reply_markup: JSON.stringify(replymarkup)
    }
  };
  UrlFetchApp.fetch('https://api.telegram.org/bot' + BotToken + '/', data);
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文