mirror of
https://github.com/abocn/TelegramBot.git
synced 2025-03-10 12:49:57 +00:00
Put help in another file to avoid confusion
This commit is contained in:
parent
835b56f311
commit
177a3c5540
67
commands/help.js
Normal file
67
commands/help.js
Normal file
@ -0,0 +1,67 @@
|
|||||||
|
const { getStrings } = require('../plugins/checklang.js');
|
||||||
|
const { isOnSpamWatch } = require('../plugins/lib-spamwatch/spamwatch.js');
|
||||||
|
const spamwatchMiddleware = require('../plugins/lib-spamwatch/Middleware.js')(isOnSpamWatch);
|
||||||
|
|
||||||
|
async function sendHelpMessage(ctx, isEditing) {
|
||||||
|
const Strings = getStrings(ctx.from.language_code);
|
||||||
|
const options = {
|
||||||
|
parse_mode: 'Markdown',
|
||||||
|
reply_markup: {
|
||||||
|
inline_keyboard: [
|
||||||
|
[{ text: Strings.mainCommands, callback_data: '1' }, { text: Strings.usefulCommands, callback_data: '2' }],
|
||||||
|
[{ text: Strings.interactiveEmojis, callback_data: '3' }, { text: Strings.funnyCommands, callback_data: '4' }]
|
||||||
|
]
|
||||||
|
}
|
||||||
|
};
|
||||||
|
const helpText = Strings.lynxHelp;
|
||||||
|
if (isEditing) {
|
||||||
|
await ctx.editMessageText(helpText, options);
|
||||||
|
} else {
|
||||||
|
await ctx.reply(helpText, options);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = (bot) => {
|
||||||
|
bot.help(spamwatchMiddleware, async (ctx) => {
|
||||||
|
await sendHelpMessage(ctx);
|
||||||
|
});
|
||||||
|
|
||||||
|
bot.on('callback_query', async (ctx) => {
|
||||||
|
const callbackData = ctx.callbackQuery.data;
|
||||||
|
const Strings = getStrings(ctx.from.language_code);
|
||||||
|
const options = {
|
||||||
|
parse_mode: 'Markdown',
|
||||||
|
reply_markup: JSON.stringify({
|
||||||
|
inline_keyboard: [
|
||||||
|
[{ text: Strings.goBack, callback_data: '5' }],
|
||||||
|
]
|
||||||
|
})
|
||||||
|
};
|
||||||
|
|
||||||
|
switch (callbackData) {
|
||||||
|
case '1':
|
||||||
|
await ctx.answerCbQuery();
|
||||||
|
await ctx.editMessageText(Strings.mainCommandsDesc, options);
|
||||||
|
break;
|
||||||
|
case '2':
|
||||||
|
await ctx.answerCbQuery();
|
||||||
|
await ctx.editMessageText(Strings.usefulCommandsDesc, options);
|
||||||
|
break;
|
||||||
|
case '3':
|
||||||
|
await ctx.answerCbQuery();
|
||||||
|
await ctx.editMessageText(Strings.interactiveEmojisDesc, options);
|
||||||
|
break;
|
||||||
|
case '4':
|
||||||
|
await ctx.answerCbQuery();
|
||||||
|
await ctx.editMessageText(Strings.funnyCommandsDesc, options);
|
||||||
|
break;
|
||||||
|
case '5':
|
||||||
|
await ctx.answerCbQuery();
|
||||||
|
await sendHelpMessage(ctx, true);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
await ctx.answerCbQuery(Strings.invalidOption);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
@ -3,25 +3,6 @@ const { getStrings } = require('../plugins/checklang.js');
|
|||||||
const { isOnSpamWatch } = require('../plugins/lib-spamwatch/spamwatch.js');
|
const { isOnSpamWatch } = require('../plugins/lib-spamwatch/spamwatch.js');
|
||||||
const spamwatchMiddleware = require('../plugins/lib-spamwatch/Middleware.js')(isOnSpamWatch);
|
const spamwatchMiddleware = require('../plugins/lib-spamwatch/Middleware.js')(isOnSpamWatch);
|
||||||
|
|
||||||
async function sendHelpMessage(ctx, isEditing) {
|
|
||||||
const Strings = getStrings(ctx.from.language_code);
|
|
||||||
const options = {
|
|
||||||
parse_mode: 'Markdown',
|
|
||||||
reply_markup: {
|
|
||||||
inline_keyboard: [
|
|
||||||
[{ text: Strings.mainCommands, callback_data: '1' }, { text: Strings.usefulCommands, callback_data: '2' }],
|
|
||||||
[{ text: Strings.interactiveEmojis, callback_data: '3' }, { text: Strings.funnyCommands, callback_data: '4' }]
|
|
||||||
]
|
|
||||||
}
|
|
||||||
};
|
|
||||||
const helpText = Strings.lynxHelp;
|
|
||||||
if (isEditing) {
|
|
||||||
await ctx.editMessageText(helpText, options);
|
|
||||||
} else {
|
|
||||||
await ctx.reply(helpText, options);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = (bot) => {
|
module.exports = (bot) => {
|
||||||
bot.start(spamwatchMiddleware, async (ctx) => {
|
bot.start(spamwatchMiddleware, async (ctx) => {
|
||||||
const Strings = getStrings(ctx.from.language_code);
|
const Strings = getStrings(ctx.from.language_code);
|
||||||
@ -34,49 +15,6 @@ module.exports = (bot) => {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
bot.help(spamwatchMiddleware, async (ctx) => {
|
|
||||||
await sendHelpMessage(ctx);
|
|
||||||
});
|
|
||||||
|
|
||||||
bot.on('callback_query', async (ctx) => {
|
|
||||||
const callbackData = ctx.callbackQuery.data;
|
|
||||||
const Strings = getStrings(ctx.from.language_code);
|
|
||||||
const options = {
|
|
||||||
parse_mode: 'Markdown',
|
|
||||||
reply_markup: JSON.stringify({
|
|
||||||
inline_keyboard: [
|
|
||||||
[{ text: Strings.goBack, callback_data: '5' }],
|
|
||||||
]
|
|
||||||
})
|
|
||||||
};
|
|
||||||
|
|
||||||
switch (callbackData) {
|
|
||||||
case '1':
|
|
||||||
await ctx.answerCbQuery();
|
|
||||||
await ctx.editMessageText(Strings.mainCommandsDesc, options);
|
|
||||||
break;
|
|
||||||
case '2':
|
|
||||||
await ctx.answerCbQuery();
|
|
||||||
await ctx.editMessageText(Strings.usefulCommandsDesc, options);
|
|
||||||
break;
|
|
||||||
case '3':
|
|
||||||
await ctx.answerCbQuery();
|
|
||||||
await ctx.editMessageText(Strings.interactiveEmojisDesc, options);
|
|
||||||
break;
|
|
||||||
case '4':
|
|
||||||
await ctx.answerCbQuery();
|
|
||||||
await ctx.editMessageText(Strings.funnyCommandsDesc, options);
|
|
||||||
break;
|
|
||||||
case '5':
|
|
||||||
await ctx.answerCbQuery();
|
|
||||||
await sendHelpMessage(ctx, true);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
await ctx.answerCbQuery(Strings.invalidOption);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
bot.command('privacy', spamwatchMiddleware, async (ctx) => {
|
bot.command('privacy', spamwatchMiddleware, async (ctx) => {
|
||||||
const Strings = getStrings(ctx.from.language_code);
|
const Strings = getStrings(ctx.from.language_code);
|
||||||
ctx.reply(
|
ctx.reply(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user