commands: localize generic bot commands
This commit is contained in:
+14
-4
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user