I've this code
var TelegramBot = require('node-telegram-bot-api');
moment = require('moment');
_ = require("underscore");
var bot = new TelegramBot("xxxxxxxxxxxxxxx", { polling: true });
bot.onText(/\/assenti/, function (msg) {
bot.sendMessage(msg.chat.id, "Scegli il giorno", {
reply_markup: {
inline_keyboard: [[{
text: "Oggi",
callback_data: "0",
}, {
text: "Domani",
callback_data: "1",
}]],
},
});
bot.on("callback_query", function (callbackQuery) {
// 'callbackQuery' is of type CallbackQuery
console.log(callbackQuery);
bot.editMessageText(t, { chat_id: callbackQuery.message.chat.id, message_id: callbackQuery.message.message_id });
})
});
});
the problem is that when I call the command /assenti the second ot third time etc... the reply occours 2, 3 ... times
can you help me?
thanks
lenny
You are calling bot.on() everytime the regexp callback (the onText() callback) is invoked! This means that each and every single time, you are adding a new listener for "callback_query"! Your logic is flawed!
@GochoMugo so tell us a logic that is not flawed!!!
not only say that "it`s flawed",then if we knew that we never asked it!
thanks