add optional named arguments to /run command

This commit is contained in:
LenAnderson
2023-12-27 12:28:15 +00:00
parent 678a702d6e
commit 03b80900d6
4 changed files with 24 additions and 14 deletions

View File

@ -85,9 +85,7 @@ export class QuickReply {
this.showEditor();
return;
}
if (this.message?.length > 0 && this.onExecute) {
this.onExecute(this);
}
this.execute();
});
const lbl = document.createElement('div'); {
this.domLabel = lbl;
@ -370,7 +368,7 @@ export class QuickReply {
document.querySelector('#shadow_popup').classList.add('qr--hide');
}
try {
executePromise = this.onExecute();
executePromise = this.execute();
await executePromise;
} catch (ex) {
executeErrors.textContent = ex.message;
@ -461,6 +459,16 @@ export class QuickReply {
}
async execute(args = {}) {
if (this.message?.length > 0 && this.onExecute) {
const message = this.message.replace(/\{\{arg::([^}]+)\}\}/g, (_, key) => {
return args[key] ?? '';
});
this.onExecute(this, message);
}
}
toJSON() {