Javascript 如何制作;“后退”;按钮输入';节点电报机器人api';?
我有一个机器人,我需要创建“返回”按钮的主菜单。 我尝试使用“bot.onText(//Back/,(msg)),但它不起作用 任务是在一开始我有两个按钮。此外,每个按钮都有分支。我需要在此分支中创建一个“后退”按钮以返回到主bot菜单 我的代码:Javascript 如何制作;“后退”;按钮输入';节点电报机器人api';?,javascript,node.js,node-telegram-bot-api,Javascript,Node.js,Node Telegram Bot Api,我有一个机器人,我需要创建“返回”按钮的主菜单。 我尝试使用“bot.onText(//Back/,(msg)),但它不起作用 任务是在一开始我有两个按钮。此外,每个按钮都有分支。我需要在此分支中创建一个“后退”按钮以返回到主bot菜单 我的代码: require('dotenv').config(); const TelegramBot = require('node-telegram-bot-api'); const bot = new TelegramBot(process.env.API
require('dotenv').config();
const TelegramBot = require('node-telegram-bot-api');
const bot = new TelegramBot(process.env.API_TOKEN, { polling: true });
const text_amazon = [
'My text',
'My text',
'My text',
'My text',
'My text',
'My text',
'Back'
];
const text_crypto = [
'My text',
'My text',
'My text',
'My text',
'My text',
'My text',
'Back'
];
bot.onText(/\/start/, (msg) => {
chatId = msg.chat.id;
bot.sendMessage(chatId, 'Hello, ' + msg.from.first_name, {
reply_markup: {
resize_keyboard: true,
// one_time_keyboard: true,
keyboard: [[text_amazon[0], text_crypto[0]]],
},
});
});
bot.on('message', (event) => console.log(event.text.toString()))
bot.on('message', (msg) => {
// var amazon = text_amazon[0];
if (msg.text.toString().includes(text_amazon[0])) {
bot.sendMessage(msg.chat.id, 'Text', {
reply_markup: {
resize_keyboard: true,
keyboard: [
[text_amazon[1], text_amazon[2], text_amazon[3]],
[text_amazon[4], text_amazon[5]],
[text_amazon[6]]
],
},
});
}
if (msg.text.toString().includes(text_crypto[0])) {
bot.sendMessage(msg.chat.id, 'Text', {
reply_markup: {
resize_keyboard: true,
keyboard: [
[text_crypto[1], text_crypto[2], text_crypto[3]],
[text_crypto[4], text_crypto[5]],
[text_crypto[6]]
],
},
});
}
});