Add {{newline}} and {{pipe}} macros

This commit is contained in:
Cohee 2023-11-23 22:56:52 +02:00
parent 86819b6f4f
commit 3594c4aac7
3 changed files with 9 additions and 1 deletions

View File

@ -2010,6 +2010,7 @@ function substituteParams(content, _name1, _name2, _original, _group, _replaceCh
}
content = replaceVariableMacros(content);
content = content.replace(/{{newline}}/gi, "\n");
content = content.replace(/{{input}}/gi, String($('#send_textarea').val()));
if (_replaceCharacterCard) {

View File

@ -1014,7 +1014,12 @@ async function executeSlashCommands(text) {
}
console.debug('Slash command executing:', result);
const unnamedArg = result.value || pipeResult;
let unnamedArg = result.value || pipeResult;
if (typeof unnamedArg === 'string' && /{{pipe}}/i.test(unnamedArg)) {
unnamedArg = unnamedArg.replace(/{{pipe}}/i, pipeResult);
}
pipeResult = await result.command.callback(result.args, unnamedArg);
if (result.command.interruptsGeneration) {

View File

@ -2,6 +2,8 @@
System-wide Replacement Macros (in order of evaluation):
</div>
<ul>
<li><tt>&lcub;&lcub;pipe&rcub;&rcub;</tt> only for slash command batching. Replaced with the returned result of the previous command.</li>
<li><tt>&lcub;&lcub;newline&rcub;&rcub;</tt> just inserts a newline.</li>
<li><tt>&lcub;&lcub;original&rcub;&rcub;</tt> global prompts defined in API settings. Only valid in Advanced Definitions prompt overrides.</li>
<li><tt>&lcub;&lcub;input&rcub;&rcub;</tt> the user input</li>
<li><tt>&lcub;&lcub;charPrompt&rcub;&rcub;</tt> the Character's Main Prompt override</li>