mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-03-02 10:57:45 +01:00
Add comments to STscript
This commit is contained in:
parent
101693ba99
commit
5e8999cc43
@ -51,6 +51,11 @@ export {
|
||||
};
|
||||
|
||||
class SlashCommandParser {
|
||||
static COMMENT_KEYWORDS = ['#', '/'];
|
||||
static RESERVED_KEYWORDS = [
|
||||
...this.COMMENT_KEYWORDS,
|
||||
];
|
||||
|
||||
constructor() {
|
||||
this.commands = {};
|
||||
this.helpStrings = {};
|
||||
@ -59,6 +64,11 @@ class SlashCommandParser {
|
||||
addCommand(command, callback, aliases, helpString = '', interruptsGeneration = false, purgeFromMessage = true) {
|
||||
const fnObj = { callback, helpString, interruptsGeneration, purgeFromMessage };
|
||||
|
||||
if ([command, ...aliases].some(x => SlashCommandParser.RESERVED_KEYWORDS.includes(x))) {
|
||||
console.error('ERROR: Reserved slash command keyword used!');
|
||||
return;
|
||||
}
|
||||
|
||||
if ([command, ...aliases].some(x => Object.hasOwn(this.commands, x))) {
|
||||
console.trace('WARN: Duplicate slash command registered!');
|
||||
}
|
||||
@ -1735,6 +1745,11 @@ async function executeSlashCommands(text, unescape = false) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Skip comment commands. They don't run macros or interrupt pipes.
|
||||
if (SlashCommandParser.COMMENT_KEYWORDS.includes(result.command)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (result.value && typeof result.value === 'string') {
|
||||
result.value = substituteParams(result.value.trim());
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user