From 88718d89bc9ae9d896383c43661b3eeea3b9c4b6 Mon Sep 17 00:00:00 2001 From: LenAnderson Date: Fri, 5 Jul 2024 19:14:00 -0400 Subject: [PATCH] add /qr-arg for {{arg::...}} fallbacks --- .../quick-reply/src/SlashCommandHandler.js | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/public/scripts/extensions/quick-reply/src/SlashCommandHandler.js b/public/scripts/extensions/quick-reply/src/SlashCommandHandler.js index 015ccf2ba..fe3bcf0e3 100644 --- a/public/scripts/extensions/quick-reply/src/SlashCommandHandler.js +++ b/public/scripts/extensions/quick-reply/src/SlashCommandHandler.js @@ -526,6 +526,34 @@ export class SlashCommandHandler { `, })); + + SlashCommandParser.addCommandObject(SlashCommand.fromProps({ name: 'qr-arg', + callback: ({ _scope }, [key, value]) => { + _scope.setMacro(`arg::${key}`, value, false); + return ''; + }, + unnamedArgumentList: [ + SlashCommandArgument.fromProps({ description: 'argument name', + typeList: ARGUMENT_TYPE.STRING, + isRequired: true, + }), + SlashCommandArgument.fromProps({ description: 'argument value', + typeList: [ARGUMENT_TYPE.STRING, ARGUMENT_TYPE.NUMBER, ARGUMENT_TYPE.BOOLEAN, ARGUMENT_TYPE.LIST, ARGUMENT_TYPE.DICTIONARY], + isRequired: true, + }), + ], + splitUnnamedArgument: true, + splitUnnamedArgumentCount: 2, + helpString: ` +
+ Set a fallback value for a Quick Reply argument. +
+
+ Example: +
/qr-arg x foo |\n/echo {{arg::x}}
+
+ `, + })); }