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
+13 -9
View File
@@ -5,10 +5,11 @@ import {Message} from "typescript-telegram-bot-api";
import {bot, botUser} from "../index";
import {fullName, logError, oldSendMessage, oldReplyToMessage} from "../util/utils";
import {Environment} from "../common/environment";
import {enqueueTelegramApiCall} from "../util/telegram-api-queue";
export class Ban extends Command {
title = "/ban [reply]";
description = "ban user from chat";
title = Environment.commandTitles.ban;
description = Environment.commandDescriptions.ban;
requirements = Requirements.Build(
Requirement.BOT_ADMIN,
@@ -25,26 +26,29 @@ export class Ban extends Command {
const userId = user.id;
if (userId === botUser.id) {
await oldReplyToMessage(msg, "Используй /leave").catch(logError);
await oldReplyToMessage(msg, Environment.useLeaveCommandText).catch(logError);
return;
}
if (userId === Environment.CREATOR_ID) {
await oldReplyToMessage(msg, "Бот не будет банить своего создателя.").catch(logError);
await oldReplyToMessage(msg, Environment.botWillNotBanCreatorText).catch(logError);
return;
}
if (msg.from.id !== Environment.CREATOR_ID && Environment.ADMIN_IDS.has(userId)) {
await oldReplyToMessage(msg, "Бот не будет банить своих администраторов.").catch(logError);
await oldReplyToMessage(msg, Environment.botWillNotBanAdminsText).catch(logError);
return;
}
bot.banChatMember({chat_id: msg.chat.id, user_id: userId})
enqueueTelegramApiCall(
() => bot.banChatMember({chat_id: msg.chat.id, user_id: userId}),
{method: "banChatMember", chatId: msg.chat.id, chatType: msg.chat.type}
)
.then(async () => {
await oldSendMessage(msg, `${fullName(user)} забанен 🚫`).catch(logError);
await oldSendMessage(msg, Environment.getUserBannedText(fullName(user))).catch(logError);
})
.catch(async () => {
await oldSendMessage(msg, `Не смог забанить ${fullName(user)} ☹️`).catch(logError);
await oldSendMessage(msg, Environment.getUserBanFailedText(fullName(user))).catch(logError);
});
}
}
}