Merge pull request #2823 from SillyTavern/fix-sendas-forced-avatar

Fix `/sendas` to not always enforce avatar, if not needed in solo chats
This commit is contained in:
Cohee 2024-09-10 22:38:44 +03:00 committed by GitHub
commit c4cc33cad9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -24,6 +24,7 @@ import {
main_api,
name1,
name2,
neutralCharacterName,
reloadCurrentChat,
removeMacros,
renameCharacter,
@ -3129,7 +3130,13 @@ 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') {
const chatCharacter = this_chid !== undefined ? characters[this_chid] : null;
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
}
else if (character && character.avatar !== 'none') {
force_avatar = getThumbnailUrl('avatar', character.avatar);
original_avatar = character.avatar;
}