fix scope macros

This commit is contained in:
LenAnderson 2024-04-16 16:45:13 -04:00
parent 001b22bec0
commit 19e997ccbe
1 changed files with 3 additions and 2 deletions

View File

@ -1,4 +1,5 @@
import { substituteParams } from '../../script.js'; import { substituteParams } from '../../script.js';
import { escapeRegex } from '../utils.js';
import { SlashCommandClosureExecutor } from './SlashCommandClosureExecutor.js'; import { SlashCommandClosureExecutor } from './SlashCommandClosureExecutor.js';
import { SlashCommandClosureResult } from './SlashCommandClosureResult.js'; import { SlashCommandClosureResult } from './SlashCommandClosureResult.js';
import { SlashCommandExecutor } from './SlashCommandExecutor.js'; import { SlashCommandExecutor } from './SlashCommandExecutor.js';
@ -22,10 +23,10 @@ export class SlashCommandClosure {
scope = scope ?? this.scope; scope = scope ?? this.scope;
text = substituteParams(text) text = substituteParams(text)
.replace(/{{pipe}}/g, scope.pipe) .replace(/{{pipe}}/g, scope.pipe)
.replace(/{{var::(\w+?)}}/g, (_, key)=>scope.getVariable(key)) .replace(/{{var::([^\s]+?)}}/g, (_, key)=>scope.getVariable(key))
; ;
for (const { key, value } of scope.macroList) { for (const { key, value } of scope.macroList) {
text = text.replace(new RegExp(`{{${key}}}`), value); text = text.replace(new RegExp(`{{${escapeRegex(key)}}}`), value);
} }
return text; return text;
} }