fix: back on help (#43)

* fix: back on help

* Fix back on help

Closes #43.
Co-authored-by: Giovani Finazzi <53719063+GiovaniFZ@users.noreply.github.com>

---------

Co-authored-by: Luquinhas <lucmsilva651@gmail.com>
This commit is contained in:
Giovani Finazzi 2025-04-20 12:16:56 -03:00 committed by GitHub
parent 39d327bb99
commit 3f5814f6e4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -8,24 +8,35 @@ async function sendHelpMessage(ctx, isEditing) {
const helpText = Strings.botHelp const helpText = Strings.botHelp
.replace(/{botName}/g, botInfo.first_name) .replace(/{botName}/g, botInfo.first_name)
.replace(/{sourceLink}/g, process.env.botSource); .replace(/{sourceLink}/g, process.env.botSource);
const options = { function getMessageId(ctx) {
parse_mode: 'Markdown', return ctx.message?.message_id || ctx.callbackQuery?.message?.message_id;
disable_web_page_preview: true, };
reply_to_message_id: ctx.message.message_id, const createOptions = (ctx, includeReplyTo = false) => {
reply_markup: { const options = {
inline_keyboard: [ parse_mode: 'Markdown',
[{ text: Strings.mainCommands, callback_data: 'helpMain' }, { text: Strings.usefulCommands, callback_data: 'helpUseful' }], disable_web_page_preview: true,
[{ text: Strings.interactiveEmojis, callback_data: 'helpInteractive' }, { text: Strings.funnyCommands, callback_data: 'helpFunny' }], reply_markup: {
[{ text: Strings.lastFm.helpEntry, callback_data: 'helpLast' }, { text: Strings.animalCommands, callback_data: 'helpAnimals' }], inline_keyboard: [
[{ text: Strings.ytDownload.helpEntry, callback_data: 'helpYouTube' }, { text: Strings.ponyApi.helpEntry, callback_data: 'helpMLP' }] [{ 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) { if (isEditing) {
await ctx.editMessageText(helpText, options); await ctx.editMessageText(helpText, createOptions(ctx));
} else { } else {
await ctx.reply(helpText, options); await ctx.reply(helpText, createOptions(ctx, true));
} };
} }
module.exports = (bot) => { module.exports = (bot) => {
@ -36,7 +47,6 @@ module.exports = (bot) => {
bot.command("about", spamwatchMiddleware, async (ctx) => { bot.command("about", spamwatchMiddleware, async (ctx) => {
const Strings = getStrings(ctx.from.language_code); const Strings = getStrings(ctx.from.language_code);
const aboutMsg = Strings.botAbout.replace(/{sourceLink}/g, `${process.env.botSource}`); const aboutMsg = Strings.botAbout.replace(/{sourceLink}/g, `${process.env.botSource}`);
ctx.reply(aboutMsg, { ctx.reply(aboutMsg, {
parse_mode: 'Markdown', parse_mode: 'Markdown',
disable_web_page_preview: true, disable_web_page_preview: true,