diff --git a/inline-menu.js b/inline-menu.js index c44e42a..e148d08 100644 --- a/inline-menu.js +++ b/inline-menu.js @@ -254,7 +254,7 @@ class TelegrafInlineMenu { // Looks like message is to old to be deleted return } - throw error + console.error('deleteMessage on question button failed', error) }) ]) } diff --git a/test/question.js b/test/question.js index 8c47f63..d7234b9 100644 --- a/test/question.js +++ b/test/question.js @@ -197,3 +197,30 @@ test('multiple question setFuncs do not interfere', async t => { text: 'less meat' }}) }) + +test('question button works on old menu', async t => { + t.plan(3) + const menu = new TelegrafInlineMenu('yaay') + menu.question('Question', 'c', { + questionText: 'what do you want?', + setFunc: t.fail + }) + + const bot = new Telegraf() + bot.use(menu.init({actionCode: 'a:b'})) + + bot.context.editMessageText = t.fail + bot.context.deleteMessage = () => { + // Method is triggered but fails as the message is to old + t.pass() + return Promise.reject(new Error('Bad Request: message can\'t be deleted')) + } + bot.context.reply = (text, extra) => { + t.is(text, 'what do you want?') + t.deepEqual(extra.reply_markup, { + force_reply: true + }) + } + + await bot.handleUpdate({callback_query: {data: 'a:b:c'}}) +})