-
Notifications
You must be signed in to change notification settings - Fork 269
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error in edit-markup.js #197
Comments
can you show the code ? |
this is the code const TeleBot = require('telebot');
const bot = new TeleBot('TELEGRAM_BOT_TOKEN');
var lastMessage;
bot.on('/start', msg => {
const markup = updateKeyboard('apples');
return bot.sendMessage(
msg.from.id, 'This is a editMessageReplyMarkup example. So, apples or oranges?', {markup}
).then(re => {
// Start updating message
lastMessage = [msg.from.id, re.result.message_id];
});
});
// On button callback
bot.on('callbackQuery', msg => {
// Send confirm
bot.answerCallbackQuery(msg.id);
if (!lastMessage) return bot.sendMessage(msg.from.id, 'Type /start');
const data = msg.data;
const [chatId, messageId] = lastMessage;
const replyMarkup = updateKeyboard(data);
// Edit message markup
return bot.editMessageReplyMarkup({chatId, messageId}, {replyMarkup});
});
bot.start();
// Returns keyboard markup
function updateKeyboard(fruit) {
let apples = 'apples';
let oranges = 'oranges';
if (fruit == 'apples') {
apples = `==> ${ apples } <==`;
} else {
oranges = `==> ${ oranges } <==`;
}
return bot.inlineKeyboard([
[
bot.inlineButton(apples, {callback: 'apples'}),
bot.inlineButton(oranges, {callback: 'oranges'})
]
]);
} and this is the link of the example |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
when i used the edit-markup.js in the examples it gives me :
[bot.error.event] TypeError: Cannot read property 'message_id' of undefined
at D:\xyz\test.js:47:47
at processTicksAndRejections (internal/process/task_queues.js:93:5)
at async Promise.all (index 0)
The text was updated successfully, but these errors were encountered: