fix delete archive scope
This commit is contained in:
@@ -129,6 +129,16 @@ export const createArchiveHandlers = (chatHistoryService: ChatHistoryService) =>
|
|||||||
return;
|
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") {
|
if (rest.length === 1 && rest[0]!.toLowerCase() === "all") {
|
||||||
const { count } = chatHistoryService.stats(chatId);
|
const { count } = chatHistoryService.stats(chatId);
|
||||||
|
|
||||||
@@ -151,7 +161,13 @@ export const createArchiveHandlers = (chatHistoryService: ChatHistoryService) =>
|
|||||||
|
|
||||||
const removed = chatHistoryService.remove(chatId, ranges);
|
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) => {
|
composer.callbackQuery("arch:list", async (ctx) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user