From a376ba27404838ce653b88db76c825798d96aaeb Mon Sep 17 00:00:00 2001 From: GiovaniFZ Date: Sun, 20 Apr 2025 11:34:29 -0300 Subject: [PATCH 1/2] fix: back on help --- src/commands/help.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/commands/help.js b/src/commands/help.js index 163af25..a9b7612 100644 --- a/src/commands/help.js +++ b/src/commands/help.js @@ -11,7 +11,6 @@ async function sendHelpMessage(ctx, isEditing) { const options = { parse_mode: 'Markdown', disable_web_page_preview: true, - reply_to_message_id: ctx.message.message_id, reply_markup: { inline_keyboard: [ [{ text: Strings.mainCommands, callback_data: 'helpMain' }, { text: Strings.usefulCommands, callback_data: 'helpUseful' }], -- 2.47.2 From a8967b2d1ca63951e98fcce0e73e7546f1c84a92 Mon Sep 17 00:00:00 2001 From: Luquinhas Date: Sun, 20 Apr 2025 12:15:56 -0300 Subject: [PATCH 2/2] Fix back on help Closes #43. Co-authored-by: Giovani Finazzi <53719063+GiovaniFZ@users.noreply.github.com> --- src/commands/help.js | 41 ++++++++++++++++++++++++++--------------- 1 file changed, 26 insertions(+), 15 deletions(-) diff --git a/src/commands/help.js b/src/commands/help.js index a9b7612..3d76629 100644 --- a/src/commands/help.js +++ b/src/commands/help.js @@ -8,23 +8,35 @@ async function sendHelpMessage(ctx, isEditing) { const helpText = Strings.botHelp .replace(/{botName}/g, botInfo.first_name) .replace(/{sourceLink}/g, process.env.botSource); - const options = { - parse_mode: 'Markdown', - disable_web_page_preview: true, - reply_markup: { - inline_keyboard: [ - [{ text: Strings.mainCommands, callback_data: 'helpMain' }, { text: Strings.usefulCommands, callback_data: 'helpUseful' }], - [{ text: Strings.interactiveEmojis, callback_data: 'helpInteractive' }, { text: Strings.funnyCommands, callback_data: 'helpFunny' }], - [{ text: Strings.lastFm.helpEntry, callback_data: 'helpLast' }, { text: Strings.animalCommands, callback_data: 'helpAnimals' }], - [{ text: Strings.ytDownload.helpEntry, callback_data: 'helpYouTube' }, { text: Strings.ponyApi.helpEntry, callback_data: 'helpMLP' }] - ] - } + function getMessageId(ctx) { + return ctx.message?.message_id || ctx.callbackQuery?.message?.message_id; + }; + const createOptions = (ctx, includeReplyTo = false) => { + const options = { + parse_mode: 'Markdown', + disable_web_page_preview: true, + reply_markup: { + inline_keyboard: [ + [{ text: Strings.mainCommands, callback_data: 'helpMain' }, { text: Strings.usefulCommands, callback_data: 'helpUseful' }], + [{ text: Strings.interactiveEmojis, callback_data: 'helpInteractive' }, { text: Strings.funnyCommands, callback_data: 'helpFunny' }], + [{ text: Strings.lastFm.helpEntry, callback_data: 'helpLast' }, { text: Strings.animalCommands, callback_data: 'helpAnimals' }], + [{ text: Strings.ytDownload.helpEntry, callback_data: 'helpYouTube' }, { text: Strings.ponyApi.helpEntry, callback_data: 'helpMLP' }] + ] + } + }; + if (includeReplyTo) { + const messageId = getMessageId(ctx); + if (messageId) { + options.reply_to_message_id = messageId; + }; + }; + return options; }; if (isEditing) { - await ctx.editMessageText(helpText, options); + await ctx.editMessageText(helpText, createOptions(ctx)); } else { - await ctx.reply(helpText, options); - } + await ctx.reply(helpText, createOptions(ctx, true)); + }; } module.exports = (bot) => { @@ -35,7 +47,6 @@ module.exports = (bot) => { bot.command("about", spamwatchMiddleware, async (ctx) => { const Strings = getStrings(ctx.from.language_code); const aboutMsg = Strings.botAbout.replace(/{sourceLink}/g, `${process.env.botSource}`); - ctx.reply(aboutMsg, { parse_mode: 'Markdown', disable_web_page_preview: true, -- 2.47.2