bot.onText(/(.+)$/, function (msg, match) {
const opts = {
reply_markup: {
inline_keyboard: [
[
{
text: 'Edit Text',
callback_data: 'edit'
}
]
]
}
};
bot.sendMessage(msg.from.id, 'Original Text', opts);
});
bot.on("callback_query", function(callbackQuery) {
// 'callbackQuery' is of type CallbackQuery
console.log(callbackQuery);
});
我一直在寻找这个问题的答案,尝试了call_back上的所有可用资源。如 Telegram bot inline keyboard via Node.JS Telegram inline keyboard and keyboard How can create menu for telegram bot in bot father?
答案 0 :(得分:0)
这样尝试怎么样?
bot.on('callback_query', function onCallbackQuery(callbackQuery) {
const action = callbackQuery.data;
const msg = callbackQuery.message;
// do your stuff
if (action === 'adress') {
// do something if callback data is "adress", you can have multiple if statements for various cases
}
});
这就是我如何运作,希望它有所帮助!