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
+11 -9
View File
@@ -6,6 +6,7 @@ import {Environment} from "../common/environment";
import fs from "node:fs";
import {logError, replyToMessage, sendErrorPlaceholder} from "../util/utils";
import {bot} from "../index";
import {enqueueTelegramApiCall} from "../util/telegram-api-queue";
export class ExportDb extends Command {
@@ -23,20 +24,21 @@ export class ExportDb extends Command {
}
try {
const buffer = fs.readFileSync(fullPath);
await bot.sendDocument({
chat_id: Environment.CREATOR_ID,
document: new FileOptions(buffer, {filename: "database.db", contentType: "application/sql"}),
caption: "Бэкап базы данных",
});
await enqueueTelegramApiCall(
() => bot.sendDocument({
chat_id: Environment.CREATOR_ID,
document: new FileOptions(fs.createReadStream(fullPath), {filename: "database.db", contentType: "application/sql"}),
caption: Environment.databaseBackupCaption,
}),
{method: "sendDocument", chatId: Environment.CREATOR_ID, chatType: "private"}
);
if (msg.chat.id !== Environment.CREATOR_ID) {
await replyToMessage({message: msg, text: "Успешно отправлено в ЛС создателю!"});
await replyToMessage({message: msg, text: Environment.databaseBackupSentText});
}
} catch (e) {
logError(e);
await sendErrorPlaceholder(msg);
}
}
}
}