mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
add double pipe a pipe breaker
This commit is contained in:
@ -144,7 +144,9 @@ export class SlashCommandClosure {
|
|||||||
|
|
||||||
// substitute unnamed argument
|
// substitute unnamed argument
|
||||||
if (executor.value === undefined) {
|
if (executor.value === undefined) {
|
||||||
value = this.scope.pipe;
|
if (executor.injectPipe) {
|
||||||
|
value = this.scope.pipe;
|
||||||
|
}
|
||||||
} else if (executor.value instanceof SlashCommandClosure) {
|
} else if (executor.value instanceof SlashCommandClosure) {
|
||||||
/**@type {SlashCommandClosure}*/
|
/**@type {SlashCommandClosure}*/
|
||||||
const closure = executor.value;
|
const closure = executor.value;
|
||||||
|
@ -4,6 +4,7 @@ import { SlashCommand } from './SlashCommand.js';
|
|||||||
import { SlashCommandClosure } from './SlashCommandClosure.js';
|
import { SlashCommandClosure } from './SlashCommandClosure.js';
|
||||||
|
|
||||||
export class SlashCommandExecutor {
|
export class SlashCommandExecutor {
|
||||||
|
/**@type {Boolean}*/ injectPipe = true;
|
||||||
/**@type {Number}*/ start;
|
/**@type {Number}*/ start;
|
||||||
/**@type {Number}*/ end;
|
/**@type {Number}*/ end;
|
||||||
/**@type {String}*/ name = '';
|
/**@type {String}*/ name = '';
|
||||||
|
@ -213,6 +213,7 @@ export class SlashCommandParser {
|
|||||||
return this.char == ':' && this.ahead[0] == '}' && this.behind.slice(-1) != '\\';
|
return this.char == ':' && this.ahead[0] == '}' && this.behind.slice(-1) != '\\';
|
||||||
}
|
}
|
||||||
parseClosure() {
|
parseClosure() {
|
||||||
|
let injectPipe = true;
|
||||||
this.take(2); // discard opening {:
|
this.take(2); // discard opening {:
|
||||||
let closure = new SlashCommandClosure(this.scope);
|
let closure = new SlashCommandClosure(this.scope);
|
||||||
this.scope = closure.scope;
|
this.scope = closure.scope;
|
||||||
@ -224,11 +225,23 @@ export class SlashCommandParser {
|
|||||||
}
|
}
|
||||||
while (!this.testClosureEnd()) {
|
while (!this.testClosureEnd()) {
|
||||||
if (this.testCommand()) {
|
if (this.testCommand()) {
|
||||||
closure.executorList.push(this.parseCommand());
|
const cmd = this.parseCommand();
|
||||||
|
cmd.injectPipe = injectPipe;
|
||||||
|
closure.executorList.push(cmd);
|
||||||
|
injectPipe = true;
|
||||||
} else {
|
} else {
|
||||||
while (!this.testCommandEnd()) this.take(1); // discard plain text and comments
|
while (!this.testCommandEnd()) this.take(); // discard plain text and comments
|
||||||
}
|
}
|
||||||
while (/\s|\|/.test(this.char)) this.take(); // discard whitespace and pipe (command separator)
|
this.discardWhitespace();
|
||||||
|
// first pipe marks end of command
|
||||||
|
if (this.char == '|') {
|
||||||
|
this.take(); // discard first pipe
|
||||||
|
// second pipe indicates no pipe injection for the next command
|
||||||
|
if (this.char == '|') {
|
||||||
|
injectPipe = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
while (/\s|\|/.test(this.char)) this.take(); // discard whitespace and further pipes (command separator)
|
||||||
}
|
}
|
||||||
this.take(2); // discard closing :}
|
this.take(2); // discard closing :}
|
||||||
if (this.char == '(' && this.ahead[0] == ')') {
|
if (this.char == '(' && this.ahead[0] == ')') {
|
||||||
|
Reference in New Issue
Block a user