在机器人菜单中,我有一个在线聊天选项。如果用户单击此按钮,bot 会将此用户状态保存为chatMode
. 这种情况就像用户的状态是chatMode
他的每条消息都应该转发给我,当我回复这条消息时,我的答案应该发送给这个用户——所有这些通信都应该通过我的机器人进行。这种情况就像服务机器人@LivegramBot。您能否提供有关如何实现此结果的详细答案?
另外,有没有办法对这些用户进行分组,因为如果有更多用户,我的对话将在我的机器人这边混在一起?
这就是我正在尝试的:
if (user.state === 'chatMode') {
bot.forwardMessage(xx4775xxx, msg.from.id, msg.message_id);
} else if (user.telegramId === xx4775xxx) {
if (msg.reply_to_message) {
bot.sendMessage(msg.reply_to_message.chat.id, msg.text)
}
}
但这里if (msg.reply_to_message)
的部分再次发送给自己。