commands: localize generic bot commands

This commit is contained in:
2026-05-10 22:53:32 +03:00
parent 3d14e3c0d5
commit 94d695e008
33 changed files with 341 additions and 299 deletions
+7 -6
View File
@@ -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 {
}
});
}
}
}