From 20e3e9297d2eb78b69bc56a8bf537a12010fc9fa Mon Sep 17 00:00:00 2001 From: bangonicdd <157843588+bangonicdd2@users.noreply.github.com> Date: Sat, 5 Apr 2025 04:59:46 +0900 Subject: [PATCH] fix: change cache timing after lua trigger --- src/ts/process/scripts.ts | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/ts/process/scripts.ts b/src/ts/process/scripts.ts index d571a415..ccc79f4f 100644 --- a/src/ts/process/scripts.ts +++ b/src/ts/process/scripts.ts @@ -102,11 +102,6 @@ export async function processScriptFull(char:character|groupChat|simpleCharacter let db = getDatabase() const originalData = data const scripts = (db.presetRegex ?? []).concat(char.customscript).concat(getModuleRegexScripts()) - const hash = generateScriptCacheKey(scripts, data, mode, chatID, cbsConditions) - const cached = getScriptCache(hash) - if(cached){ - return {data: cached, emoChanged: false} - } let emoChanged = false data = await runLuaEditTrigger(char, mode, data) @@ -138,6 +133,13 @@ export async function processScriptFull(char:character|groupChat|simpleCharacter } } } + + data = risuChatParser(data, { chatID: chatID, cbsConditions }) + const hash = generateScriptCacheKey(scripts, data, mode, chatID, cbsConditions) + const cached = getScriptCache(hash) + if(cached){ + return {data: cached, emoChanged: false} + } if(scripts.length === 0){ cacheScript(hash, data) @@ -146,6 +148,10 @@ export async function processScriptFull(char:character|groupChat|simpleCharacter function executeScript(pscript:pScript){ const script = pscript.script + if(script.in === '' && script.out !== ''){ + return + } + if(script.type === mode){ let outScript2 = script.out.replaceAll("$n", "\n")