mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-02-09 16:49:01 +01:00
parent
2379fd5970
commit
4e67cc1bc4
@ -2497,16 +2497,19 @@ async function askCharacter(args, text) {
|
|||||||
const prevChId = this_chid;
|
const prevChId = this_chid;
|
||||||
|
|
||||||
// Find the character
|
// Find the character
|
||||||
const chId = characters.findIndex((e) => e.name === name);
|
const chId = characters.findIndex((e) => e.name === name || e.avatar === name);
|
||||||
if (!characters[chId] || chId === -1) {
|
if (!characters[chId] || chId === -1) {
|
||||||
toastr.error('Character not found.');
|
toastr.error('Character not found.');
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Sending a message implicitly saves the chat, so this needs to be done before changing the character
|
||||||
|
// Otherwise, a corruption will occur
|
||||||
|
await sendMessageAsUser(mesText, '');
|
||||||
|
|
||||||
// Override character and send a user message
|
// Override character and send a user message
|
||||||
setCharacterId(String(chId));
|
setCharacterId(String(chId));
|
||||||
|
|
||||||
// TODO: Maybe look up by filename instead of name
|
|
||||||
const character = characters[chId];
|
const character = characters[chId];
|
||||||
let force_avatar, original_avatar;
|
let force_avatar, original_avatar;
|
||||||
|
|
||||||
@ -2521,8 +2524,6 @@ async function askCharacter(args, text) {
|
|||||||
|
|
||||||
setCharacterName(character.name);
|
setCharacterName(character.name);
|
||||||
|
|
||||||
await sendMessageAsUser(mesText, '');
|
|
||||||
|
|
||||||
const restoreCharacter = () => {
|
const restoreCharacter = () => {
|
||||||
setCharacterId(prevChId);
|
setCharacterId(prevChId);
|
||||||
setCharacterName(characters[prevChId].name);
|
setCharacterName(characters[prevChId].name);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user