fix delete archive scope

This commit is contained in:
yunogasai
2026-09-25 15:21:02 +02:00
parent 08108f5e1f
commit 11efe48ee2

View File

@@ -129,6 +129,16 @@ export const createArchiveHandlers = (chatHistoryService: ChatHistoryService) =>
return;
}
// В личке первое число — ID чата. Если такого чата в архиве нет, скорее всего, ID просто забыли указать.
const known = chatHistoryService.chats();
if (!known.some((chat) => chat.chatId === chatId)) {
const titles = await Promise.all(known.map(async (chat) => `${await chatTitle(ctx, chat.chatId)}: ${chat.chatId}`));
await ctx.reply(`В архиве нет чата ${chatId}. ${usage}\n\nЧаты с архивом:\n${titles.join("\n")}`);
return;
}
if (rest.length === 1 && rest[0]!.toLowerCase() === "all") {
const { count } = chatHistoryService.stats(chatId);
@@ -151,7 +161,13 @@ export const createArchiveHandlers = (chatHistoryService: ChatHistoryService) =>
const removed = chatHistoryService.remove(chatId, ranges);
await ctx.reply(`Удалил из архива ${removed} сообщений. Посмотреть, что осталось: /archive`);
const title = await chatTitle(ctx, chatId);
await ctx.reply(
removed > 0
? `Удалил из архива «${title}» сообщений: ${removed}. Посмотреть, что осталось: /archive`
: `В архиве «${title}» нет сообщений с такими номерами — возможно, они уже удалены. Свежие номера: /archive`,
);
});
composer.callbackQuery("arch:list", async (ctx) => {