Fix stopping strings for ooba and kobold

This commit is contained in:
SillyLossy
2023-04-19 13:59:40 +03:00
parent b9ce9024a0
commit 6b65af891e

View File

@@ -1021,11 +1021,11 @@ function substituteParams(content, _name1, _name2) {
return content;
}
function getStoppingStrings(isImpersonate, wrapInQuotes) {
const charString = `\n${name2}: `;
const userString = is_pygmalion ? `\nYou: ` : `\n${name1}: `;
function getStoppingStrings(isImpersonate, addSpace) {
const charString = `\n${name2}:`;
const userString = is_pygmalion ? `\nYou:` : `\n${name1}:`;
const result = isImpersonate ? charString : userString;
return wrapInQuotes ? `"${result}"` : result;
return addSpace ? `${result} ` : result;
}
function getSlashCommand(message, type) {
@@ -2193,6 +2193,17 @@ function cleanUpMessage(getMessage, isImpersonate) {
getMessage = getMessage.trim();
}
const stoppingString = getStoppingStrings(isImpersonate, false);
if (stoppingString.length) {
for (let j = stoppingString.length - 1; j > 0; j--) {
if (getMessage.slice(-j) === stoppingString.slice(0, j)) {
getMessage = getMessage.slice(0, -j);
break;
}
}
}
return getMessage;
}