mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
Somewhat usable system message narrator
This commit is contained in:
@ -1,6 +1,8 @@
|
||||
import {
|
||||
addOneMessage,
|
||||
chat,
|
||||
chat_metadata,
|
||||
saveChatConditional,
|
||||
sendSystemMessage,
|
||||
system_avatar,
|
||||
system_message_types
|
||||
@ -79,15 +81,25 @@ const getSlashCommandsHelp = parser.getHelpString.bind(parser);
|
||||
|
||||
parser.addCommand('help', helpCommandCallback, ['?'], ' – displays this help message', true, true);
|
||||
parser.addCommand('bg', setBackgroundCallback, ['background'], '<span class="monospace">(filename)</span> – sets a background according to filename, partial names allowed, will set the first one alphebetically if multiple files begin with the provided argument string', false, true);
|
||||
parser.addCommand('sys', sendNarratorMessage, [], ' - sends message as a narrator character', false, true);
|
||||
parser.addCommand('sys', sendNarratorMessage, [], ' – sends message as a system narrator', false, true);
|
||||
parser.addCommand('sysname', setNarratorName, [], '<span class="monospace">(name)</span> – sets a name for future system narrator messages in this chat (display only). Default: System. Leave empty to reset.', true, true);
|
||||
|
||||
const NARRATOR_NAME_KEY = 'narrator_name';
|
||||
const NARRATOR_NAME_DEFAULT = 'System';
|
||||
|
||||
function setNarratorName(_, text) {
|
||||
chat_metadata[NARRATOR_NAME_KEY] = text || NARRATOR_NAME_DEFAULT;
|
||||
saveChatConditional();
|
||||
}
|
||||
|
||||
function sendNarratorMessage(_, text) {
|
||||
if (!text) {
|
||||
return;
|
||||
}
|
||||
|
||||
const name = chat_metadata[NARRATOR_NAME_KEY] || NARRATOR_NAME_DEFAULT;
|
||||
const message = {
|
||||
name: 'Narrator',
|
||||
name: name,
|
||||
is_user: false,
|
||||
is_name: false,
|
||||
is_system: false,
|
||||
|
Reference in New Issue
Block a user