mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
fix scope for closure arguments
This commit is contained in:
@ -18,12 +18,13 @@ export class SlashCommandClosure {
|
|||||||
this.scope = new SlashCommandScope(parent);
|
this.scope = new SlashCommandScope(parent);
|
||||||
}
|
}
|
||||||
|
|
||||||
substituteParams(text) {
|
substituteParams(text, scope = null) {
|
||||||
|
scope = scope ?? this.scope;
|
||||||
text = substituteParams(text)
|
text = substituteParams(text)
|
||||||
.replace(/{{pipe}}/g, this.scope.pipe)
|
.replace(/{{pipe}}/g, scope.pipe)
|
||||||
.replace(/{{var::(\w+?)}}/g, (_, key)=>this.scope.getVariable(key))
|
.replace(/{{var::(\w+?)}}/g, (_, key)=>scope.getVariable(key))
|
||||||
;
|
;
|
||||||
for (const { key, value } of this.scope.macroList) {
|
for (const { key, value } of scope.macroList) {
|
||||||
text = text.replace(new RegExp(`{{${key}}}`), value);
|
text = text.replace(new RegExp(`{{${key}}}`), value);
|
||||||
}
|
}
|
||||||
return text;
|
return text;
|
||||||
@ -89,7 +90,7 @@ export class SlashCommandClosure {
|
|||||||
v = closure;
|
v = closure;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
v = this.substituteParams(v);
|
v = this.substituteParams(v, this.scope.parent);
|
||||||
}
|
}
|
||||||
// unescape value
|
// unescape value
|
||||||
if (typeof v == 'string') {
|
if (typeof v == 'string') {
|
||||||
|
Reference in New Issue
Block a user