Answer the question
In order to leave comments, you need to log in
How to end wiretapping bot.on?
I have the following code, in which I implement a check for the correctness of the answer in the quiz:
let proverka = function() {
bot.on('message', msg => {
if (msg.text === правильный ответ) {
bot.sendMessage(msg.chat.id, 'Правильно')
}
})
}
proverka()
Answer the question
In order to leave comments, you need to log in
function proverka(msg) {
if (msg.text == "правильный ответ") {
bot.sendMessage(msg.chat.id, 'Правильно');
bot.removeListener("message", proverka);
};
};
bot.on('message', proverka);
// Дальше свои обработчики добавляй
https://nodejs.org/dist/latest-v16.x/docs/api/even...
The function given in .off must be the same as given in .on
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question