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
+14 -4
View File
@@ -1,13 +1,15 @@
import {Command} from "../base/command";
import {Message} from "typescript-telegram-bot-api";
import {logError, oldReplyToMessage, randomValue} from "../util/utils";
import {prepareTelegramMarkdownV2} from "../util/markdown-v2-renderer";
import {Environment} from "../common/environment";
export class Choice extends Command {
command = "choice";
argsMode = "required" as const;
title = "/choice a, b, ..., c";
description = "Выбор случайного значения";
title = Environment.commandTitles.choice;
description = Environment.commandDescriptions.choice;
async execute(msg: Message, match?: RegExpExecArray): Promise<void> {
console.log("match", match);
@@ -33,7 +35,15 @@ export class Choice extends Command {
}
const random = randomValue(out);
if (!random) {
await oldReplyToMessage(msg, Environment.noChoicesText).catch(logError);
return;
}
await oldReplyToMessage(msg, `Выбрал *${random}*`, "Markdown").catch(logError);
await oldReplyToMessage(
msg,
Environment.getChoiceText(prepareTelegramMarkdownV2(random, {mode: "final"})),
"MarkdownV2"
).catch(logError);
}
}
}