I've developed a telegram bot using Node.js and node-telegram-bot-api module that sends a message and an inline keyboard to the users, what I'm trying is to achieve that after the user clicks the button, the inline keyboard must disappear. I'm using editMessageReplyMarkup
but it gives the mentioned errors
Reference: Method editMessageReplyMarkup removes inline keybord
Part of code:
bot.on('callback_query', function onCallbackQuery(example) {
const action = example.data
const msg_id = example.message.from.id
const chat_id = example.from.id
//console.log(example.from.id)
if (action == 'FM') {
bot.editMessageReplyMarkup({
reply_markup: {
inline_keyboard: [
[
],
]
}
}, {
chat_id: chat_id,
message_id: msg_id
});
}
});
Error:
Unhandled rejection Error: ETELEGRAM: 400 Bad Request: message to edit not found
I've tried the following solution as well but it doesn't work
Reference: How hide or delete inline button after click?
bot.on('callback_query', function onCallbackQuery(example) {
const action = example.data
const msg_id = example.message.from.id
const chat_id = example.from.id
console.log(example.from.id)
if (action == 'FM') {
console.log(action)
console.log("FM")
console.log(msg_id)
// console.log(example.message.message_id)
bot.editMessageReplyMarkup({
chat_id: chat_id,
message_id: msg_id,
reply_markup: JSON.stringify({
keyboard: []
})
}
);
}
});
Error:
Unhandled rejection Error: ETELEGRAM: 400 Bad Request: message identifier is not specified
CodePudding user response:
You're referring to wrong msg_id. It should be
const msg_id = example.message.message_id
bot.editMessageReplyMarkup({
reply_markup: {
inline_keyboard: [
[
],
]
}
}, {
chat_id: chat_id,
message_id: msg_id
});
execute console.log(example)
to get a clear idea of the response