commands: localize generic bot commands
This commit is contained in:
@@ -3,16 +3,17 @@ import {chatCommandToString, delay, logError, sendMessage} from "../util/utils";
|
||||
import {Command} from "../base/command";
|
||||
import {commands} from "../index";
|
||||
import {TelegramError} from "typescript-telegram-bot-api/dist/errors";
|
||||
import {Environment} from "../common/environment";
|
||||
|
||||
export class Help extends Command {
|
||||
command = ["h", "help"];
|
||||
|
||||
title = "/help";
|
||||
description = "Show list of commands";
|
||||
title = Environment.commandTitles.help;
|
||||
description = Environment.commandDescriptions.help;
|
||||
|
||||
async execute(msg: Message) {
|
||||
if (!msg.from) return;
|
||||
let text = "Commands:\n\n";
|
||||
let text = Environment.commandsHeaderText;
|
||||
|
||||
commands.forEach(c => {
|
||||
text += `${chatCommandToString(c)}\n`;
|
||||
@@ -21,7 +22,7 @@ export class Help extends Command {
|
||||
await sendMessage({chat_id: msg.from.id, text: text})
|
||||
.then(async () => {
|
||||
if (msg.chat.type !== "private") {
|
||||
await sendMessage({message: msg, text: "Отправил команды в ЛС 😎"}).catch(logError);
|
||||
await sendMessage({message: msg, text: Environment.sentCommandsInDmText}).catch(logError);
|
||||
}
|
||||
})
|
||||
.catch(async (e) => {
|
||||
@@ -29,7 +30,7 @@ export class Help extends Command {
|
||||
if (e.response?.error_code === 403) {
|
||||
await sendMessage({
|
||||
message: msg,
|
||||
text: "Не смог отправить команды в ЛС ☹️\nТогда отправлю сюда"
|
||||
text: Environment.couldNotSendCommandsInDmText
|
||||
}).catch(logError);
|
||||
|
||||
await delay(1000);
|
||||
@@ -38,4 +39,4 @@ export class Help extends Command {
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user