mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
add icon= and showLabel= to /qr-create and /qr-update
This commit is contained in:
@@ -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} 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 {string} label label for the new quick reply (text on the button)
|
||||||
* @param {object} [props]
|
* @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.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 {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
|
* @param {boolean} [props.isHidden] whether to hide or show the button
|
||||||
@@ -198,6 +200,8 @@ export class QuickReplyApi {
|
|||||||
* @returns {QuickReply} the new quick reply
|
* @returns {QuickReply} the new quick reply
|
||||||
*/
|
*/
|
||||||
createQuickReply(setName, label, {
|
createQuickReply(setName, label, {
|
||||||
|
icon,
|
||||||
|
showLabel,
|
||||||
message,
|
message,
|
||||||
title,
|
title,
|
||||||
isHidden,
|
isHidden,
|
||||||
@@ -214,6 +218,8 @@ export class QuickReplyApi {
|
|||||||
}
|
}
|
||||||
const qr = set.addQuickReply();
|
const qr = set.addQuickReply();
|
||||||
qr.label = label ?? '';
|
qr.label = label ?? '';
|
||||||
|
qr.icon = icon ?? '';
|
||||||
|
qr.showLabel = showLabel ?? false;
|
||||||
qr.message = message ?? '';
|
qr.message = message ?? '';
|
||||||
qr.title = title ?? '';
|
qr.title = title ?? '';
|
||||||
qr.isHidden = isHidden ?? false;
|
qr.isHidden = isHidden ?? false;
|
||||||
@@ -233,6 +239,8 @@ export class QuickReplyApi {
|
|||||||
* @param {string} setName name of the existing quick reply set
|
* @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 {string|number} label label of the existing quick reply (text on the button) or its numeric ID
|
||||||
* @param {object} [props]
|
* @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.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.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
|
* @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
|
* @returns {QuickReply} the altered quick reply
|
||||||
*/
|
*/
|
||||||
updateQuickReply(setName, label, {
|
updateQuickReply(setName, label, {
|
||||||
|
icon,
|
||||||
|
showLabel,
|
||||||
newLabel,
|
newLabel,
|
||||||
message,
|
message,
|
||||||
title,
|
title,
|
||||||
@@ -261,6 +271,8 @@ export class QuickReplyApi {
|
|||||||
if (!qr) {
|
if (!qr) {
|
||||||
throw new Error(`No quick reply with label "${label}" in set "${setName}" found.`);
|
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.updateLabel(newLabel ?? qr.label);
|
||||||
qr.updateMessage(message ?? qr.message);
|
qr.updateMessage(message ?? qr.message);
|
||||||
qr.updateTitle(title ?? qr.title);
|
qr.updateTitle(title ?? qr.title);
|
||||||
|
@@ -247,6 +247,18 @@ export class SlashCommandHandler {
|
|||||||
isRequired: false,
|
isRequired: false,
|
||||||
enumProvider: localEnumProviders.qrEntries,
|
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('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('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'),
|
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.set ?? '',
|
||||||
args.label ?? '',
|
args.label ?? '',
|
||||||
{
|
{
|
||||||
|
icon: args.icon,
|
||||||
|
showLabel: args.showlabel === undefined ? undefined : isTrueBoolean(args.showlabel),
|
||||||
message: message ?? '',
|
message: message ?? '',
|
||||||
title: args.title,
|
title: args.title,
|
||||||
isHidden: isTrueBoolean(args.hidden),
|
isHidden: isTrueBoolean(args.hidden),
|
||||||
@@ -856,6 +870,8 @@ export class SlashCommandHandler {
|
|||||||
args.set ?? '',
|
args.set ?? '',
|
||||||
args.id !== undefined ? Number(args.id) : (args.label ?? ''),
|
args.id !== undefined ? Number(args.id) : (args.label ?? ''),
|
||||||
{
|
{
|
||||||
|
icon: args.icon,
|
||||||
|
showLabel: args.showlabel === undefined ? undefined : isTrueBoolean(args.showlabel),
|
||||||
newLabel: args.newlabel,
|
newLabel: args.newlabel,
|
||||||
message: (message ?? '').trim().length > 0 ? message : undefined,
|
message: (message ?? '').trim().length > 0 ? message : undefined,
|
||||||
title: args.title,
|
title: args.title,
|
||||||
|
Reference in New Issue
Block a user