Bugfix: World Info - NOT operator only considers first secondary key
Small fix to correct the behavior of the World Info NOT operator with a list of secondary keys to what was (hopefully) intended. Previously only the first secondary key was ever checked. Now each primary key should be checked against each secondary key with a single match invalidating the entry activation.
This commit is contained in:
parent
42c73c8658
commit
bca21ec9b6
|
@ -1526,6 +1526,9 @@ async function checkWorldInfo(chat, maxContext) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Array.isArray(entry.key) && entry.key.length) { //check for keywords existing
|
if (Array.isArray(entry.key) && entry.key.length) { //check for keywords existing
|
||||||
|
// If selectiveLogic isn't found, assume it's AND, only do this once per entry
|
||||||
|
const selectiveLogic = entry.selectiveLogic ?? 0;
|
||||||
|
let notFlag = true;
|
||||||
primary: for (let key of entry.key) {
|
primary: for (let key of entry.key) {
|
||||||
const substituted = substituteParams(key);
|
const substituted = substituteParams(key);
|
||||||
console.debug(`${entry.uid}: ${substituted}`)
|
console.debug(`${entry.uid}: ${substituted}`)
|
||||||
|
@ -1541,10 +1544,6 @@ async function checkWorldInfo(chat, maxContext) {
|
||||||
secondary: for (let keysecondary of entry.keysecondary) {
|
secondary: for (let keysecondary of entry.keysecondary) {
|
||||||
const secondarySubstituted = substituteParams(keysecondary);
|
const secondarySubstituted = substituteParams(keysecondary);
|
||||||
console.debug(`uid:${entry.uid}: filtering ${secondarySubstituted}`);
|
console.debug(`uid:${entry.uid}: filtering ${secondarySubstituted}`);
|
||||||
|
|
||||||
// If selectiveLogic isn't found, assume it's AND
|
|
||||||
const selectiveLogic = entry.selectiveLogic ?? 0;
|
|
||||||
|
|
||||||
//AND operator
|
//AND operator
|
||||||
if (selectiveLogic === 0) {
|
if (selectiveLogic === 0) {
|
||||||
console.debug('saw AND logic, checking..')
|
console.debug('saw AND logic, checking..')
|
||||||
|
@ -1559,11 +1558,8 @@ async function checkWorldInfo(chat, maxContext) {
|
||||||
console.debug(`uid ${entry.uid}: checking NOT logic for ${secondarySubstituted}`)
|
console.debug(`uid ${entry.uid}: checking NOT logic for ${secondarySubstituted}`)
|
||||||
if (secondarySubstituted && matchKeys(textToScan, secondarySubstituted.trim())) {
|
if (secondarySubstituted && matchKeys(textToScan, secondarySubstituted.trim())) {
|
||||||
console.debug(`uid ${entry.uid}: canceled; filtered out by ${secondarySubstituted}`)
|
console.debug(`uid ${entry.uid}: canceled; filtered out by ${secondarySubstituted}`)
|
||||||
|
notFlag = false;
|
||||||
break primary;
|
break primary;
|
||||||
} else {
|
|
||||||
console.debug(`${entry.uid}: activated; passed NOT filter`)
|
|
||||||
activatedNow.add(entry);
|
|
||||||
break secondary;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1575,6 +1571,11 @@ async function checkWorldInfo(chat, maxContext) {
|
||||||
}
|
}
|
||||||
} else { console.debug('no active entries for logic checks yet') }
|
} else { console.debug('no active entries for logic checks yet') }
|
||||||
}
|
}
|
||||||
|
//for a NOT all entries must be checked, a single match invalidates activation
|
||||||
|
if (selectiveLogic === 1 && notFlag) {
|
||||||
|
console.debug(`${entry.uid}: activated; passed NOT filter`)
|
||||||
|
activatedNow.add(entry);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue