add icon= and showLabel= to /qr-create and /qr-update
This commit is contained in:
parent
10b9fdd06d
commit
5478b69253
|
@ -186,6 +186,8 @@ export class QuickReplyApi {
|
|||
* @param {string} setName name of the quick reply set to insert the new quick reply into
|
||||
* @param {string} label label for the new quick reply (text on the button)
|
||||
* @param {object} [props]
|
||||
* @param {string} [props.icon] the icon to show on the QR button
|
||||
* @param {boolean} [props.showLabel] whether to show the label even when an icon is assigned
|
||||
* @param {string} [props.message] the message to be sent or slash command to be executed by the new quick reply
|
||||
* @param {string} [props.title] the title / tooltip to be shown on the quick reply button
|
||||
* @param {boolean} [props.isHidden] whether to hide or show the button
|
||||
|
@ -198,6 +200,8 @@ export class QuickReplyApi {
|
|||
* @returns {QuickReply} the new quick reply
|
||||
*/
|
||||
createQuickReply(setName, label, {
|
||||
icon,
|
||||
showLabel,
|
||||
message,
|
||||
title,
|
||||
isHidden,
|
||||
|
@ -214,6 +218,8 @@ export class QuickReplyApi {
|
|||
}
|
||||
const qr = set.addQuickReply();
|
||||
qr.label = label ?? '';
|
||||
qr.icon = icon ?? '';
|
||||
qr.showLabel = showLabel ?? false;
|
||||
qr.message = message ?? '';
|
||||
qr.title = title ?? '';
|
||||
qr.isHidden = isHidden ?? false;
|
||||
|
@ -233,6 +239,8 @@ export class QuickReplyApi {
|
|||
* @param {string} setName name of the existing quick reply set
|
||||
* @param {string|number} label label of the existing quick reply (text on the button) or its numeric ID
|
||||
* @param {object} [props]
|
||||
* @param {string} [props.icon] the icon to show on the QR button
|
||||
* @param {boolean} [props.showLabel] whether to show the label even when an icon is assigned
|
||||
* @param {string} [props.newLabel] new label for quick reply (text on the button)
|
||||
* @param {string} [props.message] the message to be sent or slash command to be executed by the quick reply
|
||||
* @param {string} [props.title] the title / tooltip to be shown on the quick reply button
|
||||
|
@ -246,6 +254,8 @@ export class QuickReplyApi {
|
|||
* @returns {QuickReply} the altered quick reply
|
||||
*/
|
||||
updateQuickReply(setName, label, {
|
||||
icon,
|
||||
showLabel,
|
||||
newLabel,
|
||||
message,
|
||||
title,
|
||||
|
@ -261,6 +271,8 @@ export class QuickReplyApi {
|
|||
if (!qr) {
|
||||
throw new Error(`No quick reply with label "${label}" in set "${setName}" found.`);
|
||||
}
|
||||
qr.updateIcon(icon ?? qr.icon);
|
||||
qr.updateShowLabel(showLabel ?? qr.showLabel);
|
||||
qr.updateLabel(newLabel ?? qr.label);
|
||||
qr.updateMessage(message ?? qr.message);
|
||||
qr.updateTitle(title ?? qr.title);
|
||||
|
|
|
@ -247,6 +247,18 @@ export class SlashCommandHandler {
|
|||
isRequired: false,
|
||||
enumProvider: localEnumProviders.qrEntries,
|
||||
}),
|
||||
SlashCommandNamedArgument.fromProps({
|
||||
name: 'icon',
|
||||
description: 'icon to show on the button, e.g., icon=fa-pencil',
|
||||
typeList: [ARGUMENT_TYPE.STRING],
|
||||
isRequired: false,
|
||||
}),
|
||||
SlashCommandNamedArgument.fromProps({
|
||||
name: 'showlabel',
|
||||
description: 'whether to show the label even when an icon is assigned, e.g., icon=fa-pencil showlabel=true',
|
||||
typeList: [ARGUMENT_TYPE.BOOLEAN],
|
||||
isRequired: false,
|
||||
}),
|
||||
new SlashCommandNamedArgument('hidden', 'whether the button should be hidden, e.g., hidden=true', [ARGUMENT_TYPE.BOOLEAN], false, false, 'false'),
|
||||
new SlashCommandNamedArgument('startup', 'auto execute on app startup, e.g., startup=true', [ARGUMENT_TYPE.BOOLEAN], false, false, 'false'),
|
||||
new SlashCommandNamedArgument('user', 'auto execute on user message, e.g., user=true', [ARGUMENT_TYPE.BOOLEAN], false, false, 'false'),
|
||||
|
@ -828,6 +840,8 @@ export class SlashCommandHandler {
|
|||
args.set ?? '',
|
||||
args.label ?? '',
|
||||
{
|
||||
icon: args.icon,
|
||||
showLabel: args.showlabel === undefined ? undefined : isTrueBoolean(args.showlabel),
|
||||
message: message ?? '',
|
||||
title: args.title,
|
||||
isHidden: isTrueBoolean(args.hidden),
|
||||
|
@ -856,6 +870,8 @@ export class SlashCommandHandler {
|
|||
args.set ?? '',
|
||||
args.id !== undefined ? Number(args.id) : (args.label ?? ''),
|
||||
{
|
||||
icon: args.icon,
|
||||
showLabel: args.showlabel === undefined ? undefined : isTrueBoolean(args.showlabel),
|
||||
newLabel: args.newlabel,
|
||||
message: (message ?? '').trim().length > 0 ? message : undefined,
|
||||
title: args.title,
|
||||
|
|
Loading…
Reference in New Issue