From 10a23012f3cefa676db1429d3e78db4081d69750 Mon Sep 17 00:00:00 2001 From: Wolfsblvt Date: Tue, 10 Sep 2024 18:46:38 +0200 Subject: [PATCH 1/5] Fix /sendas not needed to enforce avatar - Fixes #2820 --- public/scripts/slash-commands.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/public/scripts/slash-commands.js b/public/scripts/slash-commands.js index aa494c366..f018e5f9b 100644 --- a/public/scripts/slash-commands.js +++ b/public/scripts/slash-commands.js @@ -3129,7 +3129,10 @@ export async function sendMessageAs(args, text) { const character = characters.find(x => x.avatar === name) ?? characters.find(x => x.name === name); let force_avatar, original_avatar; - if (character && character.avatar !== 'none') { + if (characters[this_chid] === character) { + // If the targeted character is the currently selected one in a solo chat, we don't need to force any avatars + } + else if (character && character.avatar !== 'none') { force_avatar = getThumbnailUrl('avatar', character.avatar); original_avatar = character.avatar; } From 9e73e2598eb06e213cd78c8134b61dd7a0f602b6 Mon Sep 17 00:00:00 2001 From: Wolfsblvt Date: Tue, 10 Sep 2024 19:15:49 +0200 Subject: [PATCH 2/5] Small fix group chats not using default avatars --- public/scripts/slash-commands.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/scripts/slash-commands.js b/public/scripts/slash-commands.js index f018e5f9b..90bd90a6d 100644 --- a/public/scripts/slash-commands.js +++ b/public/scripts/slash-commands.js @@ -3129,7 +3129,7 @@ export async function sendMessageAs(args, text) { const character = characters.find(x => x.avatar === name) ?? characters.find(x => x.name === name); let force_avatar, original_avatar; - if (characters[this_chid] === character) { + if (this_chid !== undefined && characters[this_chid] === character) { // If the targeted character is the currently selected one in a solo chat, we don't need to force any avatars } else if (character && character.avatar !== 'none') { From a989ccf318c8e40693f9337956a418ae756ac8a1 Mon Sep 17 00:00:00 2001 From: Wolfsblvt Date: Tue, 10 Sep 2024 19:44:27 +0200 Subject: [PATCH 3/5] Don't force avatar on neutral assistant chat --- public/scripts/slash-commands.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/public/scripts/slash-commands.js b/public/scripts/slash-commands.js index 90bd90a6d..0eda2cb4e 100644 --- a/public/scripts/slash-commands.js +++ b/public/scripts/slash-commands.js @@ -24,6 +24,7 @@ import { main_api, name1, name2, + neutralCharacterName, reloadCurrentChat, removeMacros, renameCharacter, @@ -3129,7 +3130,10 @@ export async function sendMessageAs(args, text) { const character = characters.find(x => x.avatar === name) ?? characters.find(x => x.name === name); let force_avatar, original_avatar; - if (this_chid !== undefined && characters[this_chid] === character) { + const chatCharacter = this_chid !== null ? characters[this_chid] : null; + const isNeutralCharacter = !chatCharacter && name2 === neutralCharacterName; + + if (chatCharacter === character || isNeutralCharacter) { // If the targeted character is the currently selected one in a solo chat, we don't need to force any avatars } else if (character && character.avatar !== 'none') { From d21b24666aecb6ac8449d400d5ab45f9d84604b1 Mon Sep 17 00:00:00 2001 From: Wolfsblvt Date: Tue, 10 Sep 2024 20:02:26 +0200 Subject: [PATCH 4/5] fix neutral avatar again --- public/scripts/slash-commands.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/scripts/slash-commands.js b/public/scripts/slash-commands.js index 0eda2cb4e..f7a99729a 100644 --- a/public/scripts/slash-commands.js +++ b/public/scripts/slash-commands.js @@ -3131,7 +3131,7 @@ export async function sendMessageAs(args, text) { let force_avatar, original_avatar; const chatCharacter = this_chid !== null ? characters[this_chid] : null; - const isNeutralCharacter = !chatCharacter && name2 === neutralCharacterName; + const isNeutralCharacter = !chatCharacter && name2 === neutralCharacterName && name === neutralCharacterName; if (chatCharacter === character || isNeutralCharacter) { // If the targeted character is the currently selected one in a solo chat, we don't need to force any avatars From aed4a8e36da678e9dc4a48a710e895b42018e435 Mon Sep 17 00:00:00 2001 From: Cohee <18619528+Cohee1207@users.noreply.github.com> Date: Tue, 10 Sep 2024 22:37:53 +0300 Subject: [PATCH 5/5] It was very close. --- public/scripts/slash-commands.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/scripts/slash-commands.js b/public/scripts/slash-commands.js index f7a99729a..9650263f9 100644 --- a/public/scripts/slash-commands.js +++ b/public/scripts/slash-commands.js @@ -3130,7 +3130,7 @@ export async function sendMessageAs(args, text) { const character = characters.find(x => x.avatar === name) ?? characters.find(x => x.name === name); let force_avatar, original_avatar; - const chatCharacter = this_chid !== null ? characters[this_chid] : null; + const chatCharacter = this_chid !== undefined ? characters[this_chid] : null; const isNeutralCharacter = !chatCharacter && name2 === neutralCharacterName && name === neutralCharacterName; if (chatCharacter === character || isNeutralCharacter) {