diff --git a/public/script.js b/public/script.js index fca41f91d..c9e76f522 100644 --- a/public/script.js +++ b/public/script.js @@ -236,7 +236,7 @@ let characters = []; let this_chid; let backgrounds = []; const default_avatar = "img/ai4.png"; -const system_avatar = "img/five.png"; +export const system_avatar = "img/five.png"; export let CLIENT_VERSION = 'SillyTavern:UNKNOWN:Cohee#1207'; // For Horde header let is_colab = false; let is_checked_colab = false; diff --git a/public/scripts/slash-commands.js b/public/scripts/slash-commands.js index 6ee7600ea..5f5f2e62b 100644 --- a/public/scripts/slash-commands.js +++ b/public/scripts/slash-commands.js @@ -1,7 +1,11 @@ import { + addOneMessage, + chat, sendSystemMessage, + system_avatar, system_message_types } from "../script.js"; +import { humanizedDateTime } from "./RossAscends-mods.js"; export { executeSlashCommands, registerSlashCommand, @@ -75,6 +79,28 @@ const getSlashCommandsHelp = parser.getHelpString.bind(parser); parser.addCommand('help', helpCommandCallback, ['?'], ' – displays this help message', true, true); parser.addCommand('bg', setBackgroundCallback, ['background'], '(filename) – 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); + +function sendNarratorMessage(_, text) { + if (!text) { + return; + } + + const message = { + extra: {}, + name: 'Narrator', + is_user: false, + is_name: false, + is_system: false, + send_date: humanizedDateTime(), + mes: text.trim(), + force_avatar: system_avatar, + type + }; + + chat.push(message); + addOneMessage(message); +} function helpCommandCallback() { sendSystemMessage(system_message_types.HELP);