Javascript Telegraf框架。如何使用电报将消息转发到给定的组、聊天室或频道。forwardMessage();?

Javascript Telegraf框架。如何使用电报将消息转发到给定的组、聊天室或频道。forwardMessage();?,javascript,telegram,telegram-bot,node-telegram-bot-api,Javascript,Telegram,Telegram Bot,Node Telegram Bot Api,问题是:我需要从大约400个用户那里获取消息到一个电报机器人。bot侦听消息中的特定标记,并将消息路由到由bot侦听的标记定义的组通道或用户。当最终目的地回复时,bot需要知道将该回复转发到何处以实现双向通信(一种方式是用户在groupchat中向整个部门发送回复,另一种方式是从只向用户发送回复的部门发送回复) 因此,在这种背景下,我决定使用Telegraf框架来构建机器人。我不熟悉JS和所有相关技术,但它似乎是完成这项任务的最佳选择。我正试图使用电报。转发消息();方法,但我不确定如何确切地填

问题是:我需要从大约400个用户那里获取消息到一个电报机器人。bot侦听消息中的特定标记,并将消息路由到由bot侦听的标记定义的组通道或用户。当最终目的地回复时,bot需要知道将该回复转发到何处以实现双向通信(一种方式是用户在groupchat中向整个部门发送回复,另一种方式是从只向用户发送回复的部门发送回复)

因此,在这种背景下,我决定使用Telegraf框架来构建机器人。我不熟悉JS和所有相关技术,但它似乎是完成这项任务的最佳选择。我正试图使用电报。转发消息();方法,但我不确定如何确切地填充该方法所需的参数

telegraf文档显示

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

例如

ctx.telegram.forwardMessage(whereToSendId, fromWhereToSendId, whatIdToSend).then(function(){
console.log("mesage forwaded")
});
在您的情况下,
fromWhereToSend
将是
ctx.message.chat.id
whatIdToSend
将是
ctx.message.message\u id


文档非常清晰,您可以查看官方电报文档了解更多信息

我对这一点不熟悉,英语不是我的母语。我不太了解这些文件。让我试试这个解决方案,谢谢你的友好回复。我想我不理解telegraf的概念。如果我的机器人收到消息。我如何访问它?如果我可以访问该消息,我可以轮询每个ID以转发回复等。我说得对吗?消息对象是
ctx.message
。bot.hears(“whatever”,(ctx)=>{let mesage_id=ctx.message.message_id;let chat_id=ctx.message.chat.id;let sender_id=ctx.message.from.id;}这是我不理解的。谢谢你,现在我可以构建我的解决方案了