/beep or /ding

578ef7eb6c6ed393024dff14eef07abbae9d9d5b

Cohee <18619528+Cohee1207@users.noreply.github.com>

2 files changed, +22 -4Showing whitespace changes
public/scripts/power-user.js+10 -3
@@ -380,12 +380,19 @@ const debug_functions = [];
380380
381const setHotswapsDebounced = debounce(favsToHotswap);381const setHotswapsDebounced = debounce(favsToHotswap);
382382
383export function playMessageSound() {383/**
384 if (!power_user.play_message_sound) {384 * Plays the message sound if enabled in power user settings.
385 * Passes through the `force` parameter to override settings.
386 * @param {object} [param] Arguments object.
387 * @param {boolean} [param.force] Whether to force play the sound.
388 * @returns {void}
389 */
390export function playMessageSound({ force } = {}) {
391 if (!power_user.play_message_sound && !force) {
385 return;392 return;
386 }393 }
387394
388 if (power_user.play_sound_unfocused && browser_has_focus) {395 if (power_user.play_sound_unfocused && browser_has_focus && !force) {
389 return;396 return;
390 }397 }
391398
public/scripts/slash-commands.js+12 -1
@@ -65,7 +65,7 @@ import { getRegexedString, regex_placement } from './extensions/regex/engine.js'
65import { findGroupMemberId, groups, is_group_generating, openGroupById, resetSelectedGroup, saveGroupChat, selected_group, getGroupMembers } from './group-chats.js';65import { findGroupMemberId, groups, is_group_generating, openGroupById, resetSelectedGroup, saveGroupChat, selected_group, getGroupMembers } from './group-chats.js';
66import { chat_completion_sources, oai_settings, promptManager, ZAI_ENDPOINT } from './openai.js';66import { chat_completion_sources, oai_settings, promptManager, ZAI_ENDPOINT } from './openai.js';
67import { user_avatar } from './personas.js';67import { user_avatar } from './personas.js';
68import { addEphemeralStoppingString, chat_styles, context_presets, flushEphemeralStoppingStrings, power_user } from './power-user.js';68import { addEphemeralStoppingString, chat_styles, context_presets, flushEphemeralStoppingStrings, playMessageSound, power_user } from './power-user.js';
69import { SERVER_INPUTS, textgen_types, textgenerationwebui_settings } from './textgen-settings.js';69import { SERVER_INPUTS, textgen_types, textgenerationwebui_settings } from './textgen-settings.js';
70import { decodeTextTokens, getAvailableTokenizers, getFriendlyTokenizerName, getTextTokens, getTokenCountAsync, selectTokenizer } from './tokenizers.js';70import { decodeTextTokens, getAvailableTokenizers, getFriendlyTokenizerName, getTextTokens, getTokenCountAsync, selectTokenizer } from './tokenizers.js';
71import { debounce, delay, equalsIgnoreCaseAndAccents, findChar, getCharIndex, isFalseBoolean, isTrueBoolean, onlyUnique, regexFromString, showFontAwesomePicker, stringToRange, trimToEndSentence, trimToStartSentence, waitUntilCondition } from './utils.js';71import { debounce, delay, equalsIgnoreCaseAndAccents, findChar, getCharIndex, isFalseBoolean, isTrueBoolean, onlyUnique, regexFromString, showFontAwesomePicker, stringToRange, trimToEndSentence, trimToStartSentence, waitUntilCondition } from './utils.js';
@@ -3145,6 +3145,17 @@ export function initDefaultSlashCommands() {
3145 `,3145 `,
3146 }));3146 }));
31473147
3148 SlashCommandParser.addCommandObject(SlashCommand.fromProps({
3149 name: 'beep',
3150 aliases: ['ding'],
3151 returns: t`an empty string`,
3152 callback: async () => {
3153 playMessageSound({ force: true });
3154 return '';
3155 },
3156 helpString: t`Plays the message received sound effect.`,
3157 }));
3158
3148 registerVariableCommands();3159 registerVariableCommands();
3149}3160}
31503161