Prevent double insert of chat lore

This commit is contained in:
Cohee 2023-10-16 23:13:32 +03:00
parent 6a1b230c7e
commit eaadb1c5c2
1 changed files with 10 additions and 0 deletions

View File

@ -1281,6 +1281,11 @@ async function getCharacterLore() {
continue; continue;
} }
if (chat_metadata[METADATA_KEY] === worldName) {
console.debug(`Character ${name}'s world ${worldName} is already activated in chat lore! Skipping...`);
continue;
}
const data = await loadWorldInfoData(worldName); const data = await loadWorldInfoData(worldName);
const newEntries = data ? Object.keys(data.entries).map((x) => data.entries[x]) : []; const newEntries = data ? Object.keys(data.entries).map((x) => data.entries[x]) : [];
entries = entries.concat(newEntries); entries = entries.concat(newEntries);
@ -1314,6 +1319,11 @@ async function getChatLore() {
return []; return [];
} }
if (selected_world_info.includes(chatWorld)) {
console.debug(`Chat world ${chatWorld} is already activated in global world info! Skipping...`);
return [];
}
const data = await loadWorldInfoData(chatWorld); const data = await loadWorldInfoData(chatWorld);
const entries = data ? Object.keys(data.entries).map((x) => data.entries[x]) : []; const entries = data ? Object.keys(data.entries).map((x) => data.entries[x]) : [];