Deprecate old /sendas syntax.

"name" arg is now required, but defaults to {{char}} for compatibility
This commit is contained in:
Cohee 2024-04-28 03:53:17 +03:00
parent 49074effce
commit e08a21ebe7

View File

@ -20,6 +20,7 @@ import {
is_send_press,
main_api,
name1,
name2,
reloadCurrentChat,
removeMacros,
retriggerFirstMessageOnEmptyChat,
@ -1404,14 +1405,12 @@ export async function sendMessageAs(args, text) {
return;
}
} else {
const parts = text.split('\n');
if (parts.length <= 1) {
toastr.warning('Both character name and message are required. Separate them with a new line.');
return;
const namelessWarningKey = 'sendAsNamelessWarningShown';
if (localStorage.getItem(namelessWarningKey) !== 'true') {
toastr.warning('To avoid confusion, please use /sendas name="Character Name"', 'Name defaulted to {{char}}', { timeOut: 10000 });
localStorage.setItem(namelessWarningKey, 'true');
}
name = parts.shift().trim();
mesText = parts.join('\n').trim();
name = name2;
}
// Requires a regex check after the slash command is pushed to output