问题:我需要将大约 400 个用户的消息发送到电报机器人。bot 听到消息中的特定标签,并将消息路由到由 bot 听到的标签定义的组频道或用户。当最终目的地回复时,机器人需要知道将该回复转发到哪里以实现双向通信(一种方式是用户在群聊中与整个部门通信,另一种方式是来自只回复用户的部门)
所以在这样的背景下,我决定使用 Telegraf 框架来构建机器人。我是 JS 和所有相关技术的新手,但它似乎是这项任务的最佳选择。我正在尝试使用 telegram.forwardMessage(); 方法,但我不确定如何填充该方法所需的参数。
电报文件显示
telegram.forwardMessage(chatId, fromChatId, messageId, [extra]) => Promise
但找不到任何实际使用该方法的例子
const Telegraf = require('telegraf'); // Module to use Telegraf API.
const {Extra, Markup} = Telegraf; // Extract Extra, Markups from Telegraf module.
const config = require('./config'); // Configuration file that holds telegraf_token API key.
const bot = new Telegraf(config.mon_telegraf_token) //this line extracts the variable where the api token is stored
bot.start((ctx) => ctx.reply('Welcome'))
bot.help((ctx) => ctx.reply('Send me message with the destination #TAG '))
bot.hears('hi', (ctx) => ctx.reply('Hey there')) //just playing around
bot.hears('#RH', (ctx) => ctx.telegram.forwardMessage()) //aditionally need to reply to the user a confirmation that the message sent correctly and can't send a new message in 5 minutes