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