Answer the question
In order to leave comments, you need to log in
Callback_data/callback_query not working in node-telegram-bot-api?
Some of the most basic questions here, I'll post the rest a little later:
const TelegramApi = require('node-telegram-bot-api');
const { addNewUser, checkUser, clearUser, User, update } = require('./schems/userSchema');
const { addPost, clearPost, sendStartPost } = require('./schems/postSchema');
const { send, day7} = require('./send/send')
require('dotenv').config('')
const token = process.env.TOKEN;
const bot = new TelegramApi(token, { polling: true });
const keyboardOption ={
reply_markup: {
inline_keyboard:
[
[
{ text: "Да", callback_data: '1' },
{ text: "Нет", callback_data: '0' }
]
]
}
}
bot.onText(/\/d7/, (msg,prop)=>{
bot.sendMessage(msg.id.chat, ' some text', keyboardOption)
})
bot.on("message", async (msg, prop) => {
const id = {
userId: msg.from.id,
userName: msg.from.first_name,
dateNow: new Date().getDate(),
status: 'day0'
}
if (msg.text == '/start') {
addNewUser(id);
const messageArr = await sendStartPost();
messageArr.forEach((text) => {
bot.sendMessage(msg.from.id, text.post, { parse_mode: 'Markdown', disable_web_page_preview: true });
})
}
if (msg.text == '/update') {
update();
}
if (msg.text == "/add") // поиск
{
addPost();
}
if (msg.text == "/find") // Добавление в базу
{
checkUser('day1');
}
if (msg.text == "/clean") // Удаление из базы
{
clearPost();
clearUser();
bot.sendMessage(msg.from.id, "База обнулена")
}
console.log('msg did not handle');
})
bot.on('callback_query', msg => {
console.log(msg);
})
Answer the question
In order to leave comments, you need to log in
Perhaps someone will be useful. The issue was resolved in an unexpected way.
You need to update the node-telegram-bot-api package .
I automatically installed version ^0.18.
To install the current one, go to the package website, see the version, and then write it in package.json opposite the installed package
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question