From 6b65af891e2f77040dfc9a387c7e00774a6b1c3f Mon Sep 17 00:00:00 2001 From: SillyLossy Date: Wed, 19 Apr 2023 13:59:40 +0300 Subject: [PATCH] Fix stopping strings for ooba and kobold --- public/script.js | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/public/script.js b/public/script.js index bb4a13020..ed0be4cf7 100644 --- a/public/script.js +++ b/public/script.js @@ -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; }