Add `/regex-state` slash command to check regex script status (#5428) * feat: add /regex-state command to check script enabled status Adds a new slash command that returns 'on' or 'off' to indicate whether a regex script is currently enabled or disabled. * refactor: change /regex-state return values from 'on'/'off' to 'true'/'false' Updates the /regex-state slash command to return boolean string values ('true'/'false') instead of ('on'/'off') for better consistency with standard boolean conventions.

fb915b4321020e25cb8a80126e97c3693e3674c5

Wolfsblvt <wolfsblvt@gmail.com>

Signed
1 files changed, +31 -0Ignore whitespace
public/scripts/extensions/regex/index.js+31 -0
@@ -2069,6 +2069,37 @@ jQuery(async () => {
20692069 helpString: 'Runs a Regex extension script by name on the provided string. The script must be enabled.',
20702070 }));
20712071 SlashCommandParser.addCommandObject(SlashCommand.fromProps({
2072+ name: 'regex-state',
2073+ /** @param {object} _ @param {string} name */
2074+ callback: (_, name) => {
2075+ if (!name) {
2076+ toastr.warning('No regex script name provided.');
2077+ return '';
2078+ }
2079+
2080+ const scripts = getRegexScripts();
2081+ const script = scripts.find(s => equalsIgnoreCaseAndAccents(s.scriptName, name));
2082+
2083+ if (!script) {
2084+ toastr.warning(`Regex script "${name}" not found.`);
2085+ return '';
2086+ }
2087+
2088+ return script.disabled ? 'false' : 'true';
2089+ },
2090+ returns: 'true (for enabled) or false (for disabled)',
2091+ unnamedArgumentList: [
2092+ SlashCommandArgument.fromProps({
2093+ description: 'script name',
2094+ typeList: [ARGUMENT_TYPE.STRING],
2095+ isRequired: true,
2096+ enumProvider: localEnumProviders.regexScripts,
2097+ }),
2098+ ],
2099+ helpString: 'Returns the current state of a regex script.',
2100+ }));
2101+
2102+ SlashCommandParser.addCommandObject(SlashCommand.fromProps({
20722103 name: 'regex-toggle',
20732104 callback: toggleRegexCallback,
20742105 returns: 'The name of the script that was toggled',