Regex: fix multiple script bug

Multiple scripts were not running due to improper variable assingment.
For efficiency's sake, do not do a string comparison before returning
and instead do another variable assignment in the parent function.

Doing this reduces the length of regex hooks in the parent calls,
but also removes the need for unnecessary O(n) complexity of comparing
two string variables.

If there are errors, it would be advisable to add string comparison
and revert back to the old logic in parent function calls.

Signed-off-by: kingbri <bdashore3@proton.me>
This commit is contained in:
kingbri
2023-07-06 22:21:04 -04:00
parent f93fb78bc7
commit 82624ff55b
3 changed files with 13 additions and 34 deletions

View File

@@ -226,10 +226,7 @@ async function sendMessageAs(_, text) {
const name = parts.shift().trim();
let mesText = parts.join('\n').trim();
const regexResult = getRegexedString(mesText, regex_placement.SENDAS, { characterOverride: name });
if (regexResult) {
mesText = regexResult;
}
mesText = getRegexedString(mesText, regex_placement.SENDAS, { characterOverride: name });
// Messages that do nothing but set bias will be hidden from the context
const bias = extractMessageBias(mesText);
@@ -273,10 +270,7 @@ async function sendNarratorMessage(_, text) {
return;
}
const regexResult = getRegexedString(text, regex_placement.SYSTEM);
if (regexResult) {
text = regexResult;
}
text = getRegexedString(text, regex_placement.SYSTEM);
const name = chat_metadata[NARRATOR_NAME_KEY] || NARRATOR_NAME_DEFAULT;
// Messages that do nothing but set bias will be hidden from the context