diff --git a/public/img/quill.png b/public/img/quill.png new file mode 100644 index 000000000..8edd69153 Binary files /dev/null and b/public/img/quill.png differ diff --git a/public/script.js b/public/script.js index 4ee1ba508..ef806ae94 100644 --- a/public/script.js +++ b/public/script.js @@ -264,6 +264,7 @@ let this_chid; let backgrounds = []; const default_avatar = "img/ai4.png"; export const system_avatar = "img/five.png"; +export const comment_avatar = "img/quill.png"; export let CLIENT_VERSION = 'SillyTavern:UNKNOWN:Cohee#1207'; // For Horde header let is_colab = false; let is_checked_colab = false; @@ -303,6 +304,7 @@ const system_message_types = { BOOKMARK_CREATED: "bookmark_created", BOOKMARK_BACK: "bookmark_back", NARRATOR: "narrator", + COMMENT: "comment", }; const extension_prompt_types = { diff --git a/public/scripts/slash-commands.js b/public/scripts/slash-commands.js index 5a8fce3ad..1991fe9a6 100644 --- a/public/scripts/slash-commands.js +++ b/public/scripts/slash-commands.js @@ -14,6 +14,7 @@ import { sendSystemMessage, setUserName, substituteParams, + comment_avatar, system_avatar, system_message_types } from "../script.js"; @@ -103,9 +104,11 @@ parser.addCommand('bg', setBackgroundCallback, ['background'], 'Uses character avatar if it exists in the characters list.`, true, true); parser.addCommand('sys', sendNarratorMessage, [], '(text) – sends message as a system narrator', false, true); parser.addCommand('sysname', setNarratorName, [], '(name) – sets a name for future system narrator messages in this chat (display only). Default: System. Leave empty to reset.', true, true); +parser.addCommand('comment', sendCommentMessage, [], '(text) – adds a note/comment message not part of the chat', false, true); const NARRATOR_NAME_KEY = 'narrator_name'; const NARRATOR_NAME_DEFAULT = 'System'; +const COMMENT_NAME_DEFAULT = 'Note'; function syncCallback() { $('#sync_name_button').trigger('click'); @@ -221,6 +224,31 @@ async function sendNarratorMessage(_, text) { saveChatConditional(); } +async function sendCommentMessage(_, text) { + if (!text) { + return; + } + + const message = { + name: COMMENT_NAME_DEFAULT, + is_user: false, + is_name: true, + is_system: true, + send_date: humanizedDateTime(), + mes: substituteParams(text.trim()), + force_avatar: comment_avatar, + extra: { + type: system_message_types.COMMENT, + gen_id: Date.now(), + }, + }; + + chat.push(message); + addOneMessage(message); + await eventSource.emit(event_types.MESSAGE_SENT, (chat.length - 1)); + saveChatConditional(); +} + function helpCommandCallback() { sendSystemMessage(system_message_types.HELP); }