Add {{groupNotMuted}}

This commit is contained in:
Cohee 2024-12-05 22:57:02 +02:00
parent f5f60e269e
commit 3502bfcaa0
2 changed files with 9 additions and 4 deletions

View File

@ -2607,15 +2607,18 @@ export function substituteParams(content, _name1, _name2, _original, _group, _re
};
}
const getGroupValue = () => {
const getGroupValue = (includeMuted) => {
if (typeof _group === 'string') {
return _group;
}
if (selected_group) {
const members = groups.find(x => x.id === selected_group)?.members;
/** @type {string[]} */
const disabledMembers = groups.find(x => x.id === selected_group)?.disabled_members ?? [];
const isMuted = x => includeMuted ? true : !disabledMembers.includes(x);
const names = Array.isArray(members)
? members.map(m => characters.find(c => c.avatar === m)?.name).filter(Boolean).join(', ')
? members.filter(isMuted).map(m => characters.find(c => c.avatar === m)?.name).filter(Boolean).join(', ')
: '';
return names;
} else {
@ -2639,7 +2642,8 @@ export function substituteParams(content, _name1, _name2, _original, _group, _re
// Must be substituted last so that they're replaced inside {{description}}
environment.user = _name1 ?? name1;
environment.char = _name2 ?? name2;
environment.group = environment.charIfNotGroup = getGroupValue();
environment.group = environment.charIfNotGroup = getGroupValue(true);
environment.groupNotMuted = getGroupValue(false);
environment.model = getGeneratingModel();
if (additionalMacro && typeof additionalMacro === 'object') {

View File

@ -21,7 +21,8 @@
<li><tt>&lcub;&lcub;user&rcub;&rcub;</tt> <span data-i18n="help_macros_15">your current Persona username</span></li>
<li><tt>&lcub;&lcub;char&rcub;&rcub;</tt> <span data-i18n="help_macros_16">the Character's name</span></li>
<li><tt>&lcub;&lcub;char_version&rcub;&rcub;</tt> <span data-i18n="help_macros_17">the Character's version number</span></li>
<li><tt>&lcub;&lcub;group&rcub;&rcub;</tt> <span data-i18n="help_macros_18">a comma-separated list of group member names or the character name in solo chats. Alias: &lcub;&lcub;charIfNotGroup&rcub;&rcub;</span></li>
<li><tt>&lcub;&lcub;group&rcub;&rcub;</tt> <span data-i18n="help_macros_18">a comma-separated list of group member names (including muted) or the character name in solo chats. Alias: &lcub;&lcub;charIfNotGroup&rcub;&rcub;</span></li>
<li><tt>&lcub;&lcub;groupNotMuted&rcub;&rcub;</tt> <span data-i18n="help_groupNotMuted">the same as &lcub;&lcub;group&rcub;&rcub;, but excludes muted members</span></li>
<li><tt>&lcub;&lcub;model&rcub;&rcub;</tt> <span data-i18n="help_macros_19">a text generation model name for the currently selected API. </span><b data-i18n="Can be inaccurate!">Can be inaccurate!</b></li>
<li><tt>&lcub;&lcub;lastMessage&rcub;&rcub;</tt> <span data-i18n="help_macros_20">the text of the latest chat message.</span></li>
<li><tt>&lcub;&lcub;lastUserMessage&rcub;&rcub;</tt> <span data-i18n="help_macros_lastUser">the text of the latest user chat message.</span></li>