From 857912e1f215e222b0c196cefd045ce61f960d18 Mon Sep 17 00:00:00 2001 From: Wx-2025 <351320169@qq.com> Date: Thu, 10 Jul 2025 23:42:18 +0800 Subject: [PATCH] Update events.js --- core/events.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/core/events.js b/core/events.js index cfcf6d3..6c8eee4 100644 --- a/core/events.js +++ b/core/events.js @@ -1,5 +1,3 @@ - - import { getContext, extension_settings } from "/scripts/extensions.js"; import { characters, saveChatConditional, reloadCurrentChat } from "/script.js"; import { extensionName } from "../utils/settings.js"; @@ -11,7 +9,7 @@ const pendingWriteData = { summary: null, targetLorebook: null, chatIdentifier: null, - sourceAiMessageTimestamp: null, + sourceAiMessageTimestamp: null, }; export async function onMessageReceived(data) { @@ -30,6 +28,12 @@ export async function onMessageReceived(data) { return; } + if (chat.length < 2 || !chat[chat.length - 2].is_user) { + console.log("[Amily2号] 检测到消息并非AI对用户的直接回复(可能是角色问候语或连续AI消息),已跳过优化任务。"); + return; + } + // ============================================================= + if (pendingWriteData.summary) { await writeSummaryToLorebook(pendingWriteData); }