如何使用setMessageReaction(node-telegram-bot-api)?

问题描述 投票:0回答:1

收到错误电子电报:

400 Bad Request: message to react not found

我正在使用 node-telegram-bot API 并尝试通过

setMessageReaction
方法设置对通道中消息的反应:

bot.setMessageReaction method('@channel_name', message_id, [
{type: 'emoji', emoji: '👍' },
])

但是我收到以下错误:

ETELEGRAM: 400 Bad Request: message to react not found

如果消息id正确,可能是什么原因?

bots telegram node-telegram-bot-api
1个回答
0
投票

您的机器人需要拥有必要的权限才能在目标聊天中添加反应。

const TelegramBot = require('node-telegram-bot-api');

const token = 'YOUR_BOT_TOKEN';
const bot = new TelegramBot(token, { polling: true });

const chatId = 123456789;
const messageId = 123; 

const reaction = [{ type: 'emoji', emoji: '👍' }]; 

bot.setMessageReaction(chatId, messageId, reaction)
  .then(() => {
    console.log('Reaction added successfully!');
  })
  .catch(error => {
    console.error('Error adding reaction:', error);
  });
© www.soinside.com 2019 - 2024. All rights reserved.