mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
Add command and profile for custom stop strings
This commit is contained in:
@ -4072,4 +4072,34 @@ $(document).ready(() => {
|
||||
],
|
||||
helpString: 'activates a movingUI preset by name',
|
||||
}));
|
||||
SlashCommandParser.addCommandObject(SlashCommand.fromProps({
|
||||
name: 'stop-strings',
|
||||
aliases: ['stopping-strings'],
|
||||
helpString: 'Sets a list of custom stopping strings. Gets the list if no value is provided.',
|
||||
returns: ARGUMENT_TYPE.LIST,
|
||||
unnamedArgumentList: [
|
||||
SlashCommandArgument.fromProps({
|
||||
description: 'list of strings',
|
||||
typeList: [ARGUMENT_TYPE.LIST],
|
||||
acceptsMultiple: false,
|
||||
isRequired: false,
|
||||
}),
|
||||
],
|
||||
callback: (_, value) => {
|
||||
if (String(value ?? '').trim()) {
|
||||
const parsedValue = ((x) => { try { return JSON.parse(x.toString()); } catch { return null; } })(value);
|
||||
if (!parsedValue || !Array.isArray(parsedValue)) {
|
||||
throw new Error('Invalid list format. The value must be a JSON-serialized array of strings.');
|
||||
}
|
||||
parsedValue.forEach((item, index) => {
|
||||
parsedValue[index] = String(item);
|
||||
});
|
||||
power_user.custom_stopping_strings = JSON.stringify(parsedValue);
|
||||
$('#custom_stopping_strings').val(power_user.custom_stopping_strings);
|
||||
saveSettingsDebounced();
|
||||
}
|
||||
|
||||
return power_user.custom_stopping_strings;
|
||||
},
|
||||
}));
|
||||
});
|
||||
|
Reference in New Issue
Block a user