Fix help #45

Merged
lucmsilva651 merged 3 commits from fix_help into main 2025-04-20 15:18:41 +00:00

View file

@ -8,10 +8,13 @@ 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);
function getMessageId(ctx) {
return ctx.message?.message_id || ctx.callbackQuery?.message?.message_id;
};
const createOptions = (ctx, includeReplyTo = false) => {
const options = { const options = {
parse_mode: 'Markdown', parse_mode: 'Markdown',
disable_web_page_preview: true, disable_web_page_preview: true,
reply_to_message_id: ctx.message.message_id,
reply_markup: { reply_markup: {
inline_keyboard: [ inline_keyboard: [
[{ text: Strings.mainCommands, callback_data: 'helpMain' }, { text: Strings.usefulCommands, callback_data: 'helpUseful' }], [{ text: Strings.mainCommands, callback_data: 'helpMain' }, { text: Strings.usefulCommands, callback_data: 'helpUseful' }],
@ -21,11 +24,19 @@ async function sendHelpMessage(ctx, isEditing) {
] ]
} }
}; };
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,