Simplify message owner checks a bit

This commit is contained in:
Grzegorz Gidel
2023-05-03 02:56:09 +02:00
parent 71d2472d36
commit a5ae9cc7fb
2 changed files with 9 additions and 9 deletions

View File

@ -1860,7 +1860,7 @@ async function Generate(type, { automatic_trigger, force_name2, resolve, reject,
arrMes = arrMes.reverse();
arrMes.forEach(function (item, i, arr) {//For added anchors and others
if (i === arrMes.length - 1 && $.trim(item).substr(0, (name1 + ":").length) != name1 + ":") {
if (i === arrMes.length - 1 && !item.trim().startsWith(name1 + ":")) {
if (textareaText == "") {
item = item.substr(0, item.length - 1);
}
@ -1873,21 +1873,21 @@ async function Generate(type, { automatic_trigger, force_name2, resolve, reject,
item += "[" + personalityAndAnchor + ']\n';
}
}
if (i === arrMes.length - 1 && coreChat.length > bottomAnchorThreshold && $.trim(item).substr(0, (name1 + ":").length) == name1 + ":" && !is_pygmalion) {//For add anchor in end
if (i === arrMes.length - 1 && coreChat.length > bottomAnchorThreshold && item.trim().startsWith(name1 + ":") && !is_pygmalion) {//For add anchor in end
item = item.substr(0, item.length - 1);
//chatString+=postAnchor+"\n";//"[Writing style: very long messages]\n";
item = item + anchorBottom + "\n";
}
if (is_pygmalion) {
if (i === arrMes.length - 1 && $.trim(item).substr(0, (name1 + ":").length) == name1 + ":") {//for add name2 when user sent
if (i === arrMes.length - 1 && item.trim().startsWith(name1 + ":")) {//for add name2 when user sent
item = item + name2 + ":";
}
if (i === arrMes.length - 1 && $.trim(item).substr(0, (name1 + ":").length) != name1 + ":") {//for add name2 when continue
if (i === arrMes.length - 1 && !item.trim().startsWith(name1 + ":")) {//for add name2 when continue
if (textareaText == "") {
item = item + '\n' + name2 + ":";
}
}
if ($.trim(item).indexOf(name1) === 0) {
if (item.trim().startsWith(name1)) {
item = item.replace(name1 + ':', 'You:');
}
}
@ -2363,7 +2363,7 @@ function shouldContinueMultigen(getMessage) {
function extractNameFromMessage(getMessage, force_name2, isImpersonate) {
const nameToTrim = isImpersonate ? name1 : name2;
let this_mes_is_name = true;
if (getMessage.indexOf(nameToTrim + ":") === 0) {
if (getMessage.startsWith(nameToTrim + ":")) {
getMessage = getMessage.replace(nameToTrim + ':', '');
getMessage = getMessage.trimStart();
} else {