Is there a way to delete/hide/remove the inline buttons after user clicks it? Below is the code I use to send the message with inline buttons:
bot.sendMessage(msg.chat.id, 'Yes or no?', {
reply_markup: {
inline_keyboard: [[
{
text: `Yes`,
callback_data: '1'
},
{
text: 'No',
callback_data: '0'
}
]]
}
})
If I do an attempt to call editMessageReplyMarkup with an empty reply_markup - it just won't let me do so, return a 400 status code and error saying message can't be edited. Telegram docs say:
Please note, that it is currently only possible to edit messages without reply_markup or with inline keyboards.
So I'm not entirely sure how to achieve my goal. Any thoughts?
Just add:
bot.on('callback_query', (msg) => {
bot.sendMessage(_.id, `Selected '${msg.data}'`);
bot.deleteMessage(_.id, msg.message.message_id);
});`
@ecdeveloper any way to do this. I want to edit entire message (inline keyboard and text message).
How @Telegram botFather do this. upon click of buttons it change goback and forward etc.
@ivomarsan Deleting a message and then sending a new message is not a good idea.
@AliN11 How Can I do?
Here is what I done for this. I have done it using the editMessage API with a reply_markup given below
getTelegramReplyMarkup() {
var opts = {
reply_markup: {
inline_keyboard: []
}
}
return opts;
}
function editMessageText(text_message, chatId, msgId, reply_markup) {
console.log("chatId", chatId);
console.log("msgId", msgId);
var markup = {
chat_id: chatId,
message_id: parseInt(msgId),
reply_markup: reply_markup
}
console.log("reply_markup", JSON.stringify(markup));
telegramBot.editMessageText(text_message, markup).then(function (response) {
console.log("editMessageText response", response);
}).catch(function (err) {
console.log("editMessageText err", err);
})
}
here is how I have called the above functions
editMessageText(STRINGS.TASK_CANCELED_BY + " @" + callbackQuery.from.username, callbackQuery.message.chat.id, callbackQuery.message.message_id, utils.getTelegramConfirmedMarkup())
Here is what I done for this. I have done it using the editMessage API with a reply_markup given below
getTelegramReplyMarkup() { var opts = { reply_markup: { inline_keyboard: [] } } return opts; }```
function editMessageText(text_message, chatId, msgId, reply_markup) {console.log("chatId", chatId); console.log("msgId", msgId); var markup = { chat_id: chatId, message_id: parseInt(msgId), reply_markup: reply_markup } console.log("reply_markup", JSON.stringify(markup)); telegramBot.editMessageText(text_message, markup).then(function (response) { console.log("editMessageText response", response); }).catch(function (err) { console.log("editMessageText err", err); })}
```
here is how I have called the above functions
editMessageText(STRINGS.TASK_CANCELED_BY + " @" + callbackQuery.from.username, callbackQuery.message.chat.id, callbackQuery.message.message_id, utils.getTelegramConfirmedMarkup())
Can you give a concrete example?
Can you show me how to use editMessageReplyMarkup?
Most helpful comment
Can you show me how to use editMessageReplyMarkup?