Команды для просмотра и удаления архива чата
- /archive: последние 10 сообщений архива с кнопками 🗑 (удалить) и «⬅️ Раньше» / «⏭ К последним» - /archive_del 120-130 135: удалить пачку по номерам, с диапазонами - Служебные команды боту больше не записываются в архив (/ask остаётся — в нём сам вопрос) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -21,7 +21,15 @@ export const createChatHistoryService = ({ messageRepository, historyLimit }: Ch
|
||||
|
||||
const stats = (chatId: number) => ({ ...messageRepository.statsByChat(chatId), limit: historyLimit });
|
||||
|
||||
return { record, latest, latestByUser, find, stats };
|
||||
/** Страница архива для просмотра: сообщения до `beforeMessageId` (не включая); без него — самые последние. */
|
||||
const page = (chatId: number, limit: number, beforeMessageId = Number.MAX_SAFE_INTEGER): ChatMessage[] =>
|
||||
messageRepository.pageBefore(chatId, beforeMessageId, limit);
|
||||
|
||||
/** Удаляет из архива диапазоны номеров сообщений; возвращает, сколько удалено всего. */
|
||||
const remove = (chatId: number, ranges: { from: number; to: number }[]): number =>
|
||||
ranges.reduce((sum, { from, to }) => sum + messageRepository.deleteRange(chatId, from, to), 0);
|
||||
|
||||
return { record, latest, latestByUser, find, stats, page, remove };
|
||||
};
|
||||
|
||||
export type ChatHistoryService = ReturnType<typeof createChatHistoryService>;
|
||||
|
||||
Reference in New Issue
Block a user