Fix legacy {{authorsNote}}

bc660b8b9113ad0bf295cdf578d95e81a810f4e7

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

1 files changed, +33 -16Ignore whitespace
public/scripts/authors-note.js+33 -16
@@ -20,6 +20,8 @@ import { ARGUMENT_TYPE, SlashCommandArgument } from './slash-commands/SlashComma
2020export { MODULE_NAME as NOTE_MODULE_NAME };
2121import { t } from './i18n.js';
2222import { macros, MacroCategory } from './macros/macro-system.js';
23+import { MacrosParser } from './macros.js';
24+import { power_user } from './power-user.js';
2325
2426const MODULE_NAME = '2_floating_prompt'; // <= Deliberate, for sorting lower than memory
2527
@@ -585,20 +587,35 @@ export function initAuthorsNote() {
585587}
586588
587589function registerAuthorsNoteMacros() {
588- macros.register('authorsNote', {
590+ if (power_user.experimental_macro_engine) {
589- category: MacroCategory.PROMPTS,
591+ macros.register('authorsNote', {
590- description: t`The contents of the Author's Note`,
592+ category: MacroCategory.PROMPTS,
591- handler: () => chat_metadata[metadata_keys.prompt] ?? '',
593+ description: t`The contents of the Author's Note`,
592- });
594+ handler: () => chat_metadata[metadata_keys.prompt] ?? '',
593- macros.register('charAuthorsNote', {
595+ });
594- category: MacroCategory.CHARACTER,
596+ macros.register('charAuthorsNote', {
595- description: t`The contents of the Character Author's Note`,
597+ category: MacroCategory.CHARACTER,
596- handler: () => this_chid !== undefined ? (extension_settings.note.chara.find((e) => e.name === getCharaFilename())?.prompt ?? '') : '',
598+ description: t`The contents of the Character Author's Note`,
597- });
599+ handler: () => this_chid !== undefined ? (extension_settings.note.chara.find((e) => e.name === getCharaFilename())?.prompt ?? '') : '',
598- macros.register('defaultAuthorsNote', {
600+ });
599- category: MacroCategory.PROMPTS,
601+ macros.register('defaultAuthorsNote', {
600- description: t`The contents of the Default Author's Note`,
602+ category: MacroCategory.PROMPTS,
601- handler: () => extension_settings.note.default ?? '',
603+ description: t`The contents of the Default Author's Note`,
602- });
604+ handler: () => extension_settings.note.default ?? '',
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+ }
603621}
604-