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