Fix char A/N in groups

This commit is contained in:
Cohee
2023-06-18 18:33:57 +03:00
parent 040c4a8894
commit 976248b665
3 changed files with 19 additions and 6 deletions

View File

@ -811,6 +811,7 @@ async function printCharacters() {
favsToHotswap();
await delay(300);
updateVisibleDivs('#rm_print_characters_block', true);
displayOverrideWarnings();
}
@ -5765,7 +5766,9 @@ function updateVisibleDivs(containerSelector, resizecontainer) {
}
function displayOverrideWarnings() {
if (!this_chid) {
if (!this_chid || !selected_group) {
$('.prompt_overridden').hide();
$('.jailbreak_overridden').hide();
return;
}

View File

@ -177,11 +177,14 @@ function loadSettings() {
$('#extension_floating_depth').val(chat_metadata[metadata_keys.depth]);
$(`input[name="extension_floating_position"][value="${chat_metadata[metadata_keys.position]}"]`).prop('checked', true);
if (extension_settings.note.chara) {
if (extension_settings.note.chara && getContext().characterId) {
const charaNote = extension_settings.note.chara.find((e) => e.name === getCharaFilename());
$('#extension_floating_chara').val(charaNote ? charaNote.prompt : '');
$('#extension_use_floating_chara').prop('checked', charaNote ? charaNote.useChara : false);
} else {
$('#extension_floating_chara').val('');
$('#extension_use_floating_chara').prop('checked', false);
}
$('#extension_floating_default').val(extension_settings.note.default);
@ -216,7 +219,7 @@ async function moduleWorker() {
const shouldAddPrompt = messagesTillInsertion == 0;
let prompt = shouldAddPrompt ? $('#extension_floating_prompt').val() : '';
if (shouldAddPrompt && extension_settings.note.chara) {
if (shouldAddPrompt && extension_settings.note.chara && getContext().characterId) {
const charaNote = extension_settings.note.chara.find((e) => e.name === getCharaFilename());
// Only replace with the chara note if the user checked the box
@ -263,11 +266,16 @@ function onANMenuItemClick() {
}
function onChatChanged() {
const context = getContext();
// Disable the chara note if in a group
$('#extension_floating_chara').prop('disabled', context.groupId ? true : false);
const tokenCounter1 = chat_metadata[metadata_keys.prompt] ? getTokenCount(chat_metadata[metadata_keys.prompt]) : 0;
$('#extension_floating_prompt_token_counter').text(tokenCounter1);
let tokenCounter2;
if (extension_settings.note.chara) {
if (extension_settings.note.chara && context.characterId) {
const charaNote = extension_settings.note.chara.find((e) => e.name === getCharaFilename());
if (charaNote) {
@ -338,13 +346,13 @@ setTimeout(function () {
<div class="inline-drawer-icon fa-solid fa-circle-chevron-down down"></div>
</div>
<div class="inline-drawer-content">
<small>Will be automatically added as the author's note for this character.</small>
<small>Will be automatically added as the author's note for this character. Will be used in groups, but can't be modified when a group chat is open.</small>
<textarea id="extension_floating_chara" class="text_pole" rows="8" maxlength="10000"
placeholder="Example:\n[Scenario: wacky adventures; Genre: romantic comedy; Style: verbose, creative]"></textarea>
<div class="extension_token_counter">Tokens: <span id="extension_floating_chara_token_counter">0</small></div>
<label for="extension_use_floating_chara">
<label class="checkbox_label" for="extension_use_floating_chara">
<input id="extension_use_floating_chara" type="checkbox" />
<span data-i18n="Use character author's note">Use character author's note</span>
</label>
@ -402,4 +410,5 @@ setTimeout(function () {
registerSlashCommand('freq', setNoteIntervalCommand, ['interval'], "<span class='monospace'>(number)</span> sets an author's note insertion frequency", true, true);
registerSlashCommand('pos', setNotePositionCommand, ['position'], "(<span class='monospace'>chat</span> or <span class='monospace'>scenario</span>) sets an author's note position", true, true);
eventSource.on(event_types.CHAT_CHANGED, onChatChanged);
window['AuthorNote_generateInterceptor'] = moduleWorker;
}, 1);

View File

@ -3,6 +3,7 @@
"loading_order": 1,
"requires": [],
"optional": [],
"generate_interceptor": "AuthorNote_generateInterceptor",
"js": "index.js",
"css": "style.css",
"author": "Cohee#1207",