Estoy haciendo un mensaje con un teclado en línea simple. El resultado esperado sería que cuando hago clic en el botón cambia junto con el texto del mensaje.
Sin embargo, el botón no cambia y me sale este error:
TelegramError: ETELEGRAM: 400 Bad Request: message is not modified: specified new message content and reply markup are exactly the same as a current content and reply markup of the messageEstoy usando el paquete node-telegram-bot-api.
El código que tiene que cambiar mi teclado es:
let info_message = { text: "some info boi", keyboard: { reply_markup: { inline_keyboard: [ [{ text: 'Start', callback_data: '!/start' }] ] } } } client.on("callback_query", async (cb) => { if (cb.data === "!/info") { const msg = cb.message; const opts = { chat_id: msg.chat.id, message_id: msg.message_id, }; await client.editMessageReplyMarkup(info_message.keyboard, opts); await client.editMessageText(info_message.text, opts); } })Descubrí el error.
El método editMessageReplyMarkup() requiere el parámetro replyMarkup , un objeto serializado JSON para un teclado en línea.
Mi error fue que di todo el answer_markup mientras que me pidieron que diera solo el inline_keyboard. El código ahora se ve así:
client.on("callback_query", async (cb) => { if (cb.data === "!/info") { const msg = cb.message; const opts = { chat_id: msg.chat.id, message_id: msg.message_id, }; await client.editMessageReplyMarkup(info_message.keyboard.reply_markup, opts); // I gave info_message.keyboard.reply_markup as input, instead of info_message.keyboard await client.editMessageText(info_message.text, opts); } })