Fix legacy {{authorsNote}}

bc660b8b9113ad0bf295cdf578d95e81a810f4e7

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

1 files changed, +18 -1Showing whitespace changes
public/scripts/authors-note.js+18 -1
@@ -20,6 +20,8 @@ import { ARGUMENT_TYPE, SlashCommandArgument } from './slash-commands/SlashComma
20export { MODULE_NAME as NOTE_MODULE_NAME };20export { MODULE_NAME as NOTE_MODULE_NAME };
21import { t } from './i18n.js';21import { t } from './i18n.js';
22import { macros, MacroCategory } from './macros/macro-system.js';22import { macros, MacroCategory } from './macros/macro-system.js';
23import { MacrosParser } from './macros.js';
24import { power_user } from './power-user.js';
2325
24const MODULE_NAME = '2_floating_prompt'; // <= Deliberate, for sorting lower than memory26const MODULE_NAME = '2_floating_prompt'; // <= Deliberate, for sorting lower than memory
2527
@@ -585,6 +587,7 @@ export function initAuthorsNote() {
585}587}
586588
587function registerAuthorsNoteMacros() {589function registerAuthorsNoteMacros() {
590 if (power_user.experimental_macro_engine) {
588 macros.register('authorsNote', {591 macros.register('authorsNote', {
589 category: MacroCategory.PROMPTS,592 category: MacroCategory.PROMPTS,
590 description: t`The contents of the Author's Note`,593 description: t`The contents of the Author's Note`,
@@ -600,5 +603,19 @@ function registerAuthorsNoteMacros() {
600 description: t`The contents of the Default Author's Note`,603 description: t`The contents of the Default Author's Note`,
601 handler: () => extension_settings.note.default ?? '',604 handler: () => extension_settings.note.default ?? '',
602 });605 });
606 } else {
607 // TODO: Remove this when the experimental macro engine is replacing the old macro engine
608 MacrosParser.registerMacro('authorsNote',
609 () => chat_metadata[metadata_keys.prompt] ?? '',
610 t`The contents of the Author's Note`,
611 );
612 MacrosParser.registerMacro('charAuthorsNote',
613 () => this_chid !== undefined ? (extension_settings.note.chara.find((e) => e.name === getCharaFilename())?.prompt ?? '') : '',
614 t`The contents of the Character Author's Note`,
615 );
616 MacrosParser.registerMacro('defaultAuthorsNote',
617 () => extension_settings.note.default ?? '',
618 t`The contents of the Default Author's Note`,
619 );
620 }
603}621}
604