From 27ab509caf305b80e207e795655a1286a685ea94 Mon Sep 17 00:00:00 2001 From: Cohee Date: Wed, 5 Jul 2023 01:06:24 +0300 Subject: [PATCH] Split help command into pages --- public/script.js | 56 +++++++++++++++++++++++++++----- public/scripts/slash-commands.js | 22 +++++++++++-- 2 files changed, 68 insertions(+), 10 deletions(-) diff --git a/public/script.js b/public/script.js index 2a727eb32..ff21505ee 100644 --- a/public/script.js +++ b/public/script.js @@ -318,6 +318,9 @@ const system_message_types = { BOOKMARK_BACK: "bookmark_back", NARRATOR: "narrator", COMMENT: "comment", + SLASH_COMMANDS: "slash_commands", + FORMATTING: "formatting", + HOTKEYS: "hotkeys", }; const extension_prompt_types = { @@ -333,12 +336,31 @@ const system_messages = { is_system: true, is_name: true, mes: [ - `Hi there! The following chat formatting commands are supported: + `Hello there! Please select the help topic you would like to learn more about: - Hotkeys/Keybinds: +
Still got questions left? The Official SillyTavern Documentation Website has much more information!` + ] + }, + slash_commands: { + name: systemUserName, + force_avatar: system_avatar, + is_user: false, + is_system: true, + is_name: true, + mes: '', + }, + hotkeys: { + name: systemUserName, + force_avatar: system_avatar, + is_user: false, + is_system: true, + is_name: true, + mes: [ + `Hotkeys/Keybinds: ` + ] + }, + formatting: { + name: systemUserName, + force_avatar: system_avatar, + is_user: false, + is_system: true, + is_name: true, + mes: [ + `Text formatting commands: + ` ] }, @@ -1525,9 +1566,8 @@ function sendSystemMessage(type, text, extra = {}) { newMessage.mes = text; } - if (type == system_message_types.HELP) { - newMessage.mes += getSlashCommandsHelp(); - newMessage.mes += `
Still got questions left? The Official SillyTavern Documentation Website has much more information!`; + if (type == system_message_types.SLASH_COMMANDS) { + newMessage.mes = getSlashCommandsHelp(); } if (!newMessage.extra) { diff --git a/public/scripts/slash-commands.js b/public/scripts/slash-commands.js index b29cb3239..fd3d2123a 100644 --- a/public/scripts/slash-commands.js +++ b/public/scripts/slash-commands.js @@ -319,10 +319,28 @@ async function sendCommentMessage(_, text) { saveChatConditional(); } -function helpCommandCallback() { - sendSystemMessage(system_message_types.HELP); +function helpCommandCallback(_, type) { + switch (type?.trim()) { + case 'slash': + case '1': + sendSystemMessage(system_message_types.SLASH_COMMANDS); + break; + case 'format': + case '2': + sendSystemMessage(system_message_types.FORMATTING); + break; + case 'hotkeys': + case '3': + sendSystemMessage(system_message_types.HOTKEYS); + break; + default: + sendSystemMessage(system_message_types.HELP); + break; + } } +window['displayHelp'] = (page) => helpCommandCallback(null, page); + function setBackgroundCallback(_, bg) { if (!bg) { return;