Slash command to send a "neutral" message

This commit is contained in:
SillyLossy
2023-05-17 11:03:28 +03:00
parent 072d8edf52
commit a3e584a6e3
2 changed files with 27 additions and 1 deletions

View File

@ -236,7 +236,7 @@ let characters = [];
let this_chid; let this_chid;
let backgrounds = []; let backgrounds = [];
const default_avatar = "img/ai4.png"; 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 export let CLIENT_VERSION = 'SillyTavern:UNKNOWN:Cohee#1207'; // For Horde header
let is_colab = false; let is_colab = false;
let is_checked_colab = false; let is_checked_colab = false;

View File

@ -1,7 +1,11 @@
import { import {
addOneMessage,
chat,
sendSystemMessage, sendSystemMessage,
system_avatar,
system_message_types system_message_types
} from "../script.js"; } from "../script.js";
import { humanizedDateTime } from "./RossAscends-mods.js";
export { export {
executeSlashCommands, executeSlashCommands,
registerSlashCommand, registerSlashCommand,
@ -75,6 +79,28 @@ const getSlashCommandsHelp = parser.getHelpString.bind(parser);
parser.addCommand('help', helpCommandCallback, ['?'], ' displays this help message', true, true); 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('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);
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() { function helpCommandCallback() {
sendSystemMessage(system_message_types.HELP); sendSystemMessage(system_message_types.HELP);