Alias /note-pos command to match /inject
| @@ -76,15 +76,17 @@ function setNoteIntervalCommand(_, text) { | |||
| 76 | 76 | ||
| 77 | function setNotePositionCommand(_, text) { | 77 | function setNotePositionCommand(_, text) { |
| 78 | const validPositions = { | 78 | const validPositions = { |
| 79 | 'after': 0, | ||
| 79 | 'scenario': 0, | 80 | 'scenario': 0, |
| 80 | 'chat': 1, | 81 | 'chat': 1, |
| 81 | 'before_scenario': 2 | 82 | 'before_scenario': 2, |
| 83 | 'before': 2, | ||
| 82 | }; | 84 | }; |
| 83 | 85 | ||
| 84 | if (text) { | 86 | if (text) { |
| 85 | const position = validPositions[text?.trim()]; | 87 | const position = validPositions[text?.trim()?.toLowerCase()]; |
| 86 | 88 | ||
| 87 | if (typeof position == 'undefined') { | 89 | if (typeof position === 'undefined') { |
| 88 | toastr.error(t`Not a valid position`); | 90 | toastr.error(t`Not a valid position`); |
| 89 | return; | 91 | return; |
| 90 | } | 92 | } |
| @@ -94,22 +96,23 @@ function setNotePositionCommand(_, text) { | |||
| 94 | } | 96 | } |
| 95 | return Object.keys(validPositions).find(key => validPositions[key] == chat_metadata[metadata_keys.position]); | 97 | return Object.keys(validPositions).find(key => validPositions[key] == chat_metadata[metadata_keys.position]); |
| 96 | } | 98 | } |
| 99 | |||
| 97 | function setNoteRoleCommand(_, text) { | 100 | function setNoteRoleCommand(_, text) { |
| 98 | const validRoles = { | 101 | const validRoles = { |
| 99 | 'system': 0, | 102 | 'system': 0, |
| 100 | 'user': 1, | 103 | 'user': 1, |
| 101 | 'assistant': 2 | 104 | 'assistant': 2, |
| 102 | }; | 105 | }; |
| 103 | 106 | ||
| 104 | if (text) { | 107 | if (text) { |
| 105 | const role = validRoles[text?.trim()]; | 108 | const role = validRoles[text?.trim()?.toLowerCase()]; |
| 106 | 109 | ||
| 107 | if (typeof role == 'undefined') { | 110 | if (typeof role === 'undefined') { |
| 108 | toastr.error(t`Not a valid role`); | 111 | toastr.error(t`Not a valid role`); |
| 109 | return; | 112 | return; |
| 110 | } | 113 | } |
| 111 | 114 | ||
| 112 | $(`#extension_floating_role`).val(Math.abs(role)).trigger('input'); | 115 | $('#extension_floating_role').val(Math.abs(role)).trigger('input'); |
| 113 | toastr.info(t`Author's Note role updated`); | 116 | toastr.info(t`Author's Note role updated`); |
| 114 | } | 117 | } |
| 115 | return Object.keys(validRoles).find(key => validRoles[key] == chat_metadata[metadata_keys.role]); | 118 | return Object.keys(validRoles).find(key => validRoles[key] == chat_metadata[metadata_keys.role]); |
| @@ -491,7 +494,8 @@ export function initAuthorsNote() { | |||
| 491 | }); | 494 | }); |
| 492 | $('#option_toggle_AN').on('click', onANMenuItemClick); | 495 | $('#option_toggle_AN').on('click', onANMenuItemClick); |
| 493 | 496 | ||
| 494 | SlashCommandParser.addCommandObject(SlashCommand.fromProps({ name: 'note', | 497 | SlashCommandParser.addCommandObject(SlashCommand.fromProps({ |
| 498 | name: 'note', | ||
| 495 | callback: setNoteTextCommand, | 499 | callback: setNoteTextCommand, |
| 496 | returns: 'current author\'s note', | 500 | returns: 'current author\'s note', |
| 497 | unnamedArgumentList: [ | 501 | unnamedArgumentList: [ |
| @@ -505,8 +509,9 @@ export function initAuthorsNote() { | |||
| 505 | </div> | 509 | </div> |
| 506 | `, | 510 | `, |
| 507 | })); | 511 | })); |
| 508 | SlashCommandParser.addCommandObject(SlashCommand.fromProps({ name: 'depth', | 512 | SlashCommandParser.addCommandObject(SlashCommand.fromProps({ |
| 509 | aliases: ['note-depth'], | 513 | name: 'note-depth', |
| 514 | aliases: ['depth'], | ||
| 510 | callback: setNoteDepthCommand, | 515 | callback: setNoteDepthCommand, |
| 511 | returns: 'current author\'s note depth', | 516 | returns: 'current author\'s note depth', |
| 512 | unnamedArgumentList: [ | 517 | unnamedArgumentList: [ |
| @@ -520,8 +525,9 @@ export function initAuthorsNote() { | |||
| 520 | </div> | 525 | </div> |
| 521 | `, | 526 | `, |
| 522 | })); | 527 | })); |
| 523 | SlashCommandParser.addCommandObject(SlashCommand.fromProps({ name: 'freq', | 528 | SlashCommandParser.addCommandObject(SlashCommand.fromProps({ |
| 524 | aliases: ['note-freq'], | 529 | name: 'note-frequency', |
| 530 | aliases: ['freq', 'note-freq'], | ||
| 525 | callback: setNoteIntervalCommand, | 531 | callback: setNoteIntervalCommand, |
| 526 | returns: 'current author\'s note insertion frequency', | 532 | returns: 'current author\'s note insertion frequency', |
| 527 | namedArgumentList: [], | 533 | namedArgumentList: [], |
| @@ -536,14 +542,15 @@ export function initAuthorsNote() { | |||
| 536 | </div> | 542 | </div> |
| 537 | `, | 543 | `, |
| 538 | })); | 544 | })); |
| 539 | SlashCommandParser.addCommandObject(SlashCommand.fromProps({ name: 'pos', | 545 | SlashCommandParser.addCommandObject(SlashCommand.fromProps({ |
| 546 | name: 'note-position', | ||
| 540 | callback: setNotePositionCommand, | 547 | callback: setNotePositionCommand, |
| 541 | aliases: ['note-pos'], | 548 | aliases: ['pos', 'note-pos'], |
| 542 | returns: 'current author\'s note insertion position', | 549 | returns: 'current author\'s note insertion position', |
| 543 | namedArgumentList: [], | 550 | namedArgumentList: [], |
| 544 | unnamedArgumentList: [ | 551 | unnamedArgumentList: [ |
| 545 | new SlashCommandArgument( | 552 | new SlashCommandArgument( |
| 546 | 'position', [ARGUMENT_TYPE.STRING], false, false, null, ['chat', 'scenario','before_scenario'], | 553 | 'position', [ARGUMENT_TYPE.STRING], false, false, null, ['before', 'after', 'chat'], |
| 547 | ), | 554 | ), |
| 548 | ], | 555 | ], |
| 549 | helpString: ` | 556 | helpString: ` |
| @@ -552,7 +559,8 @@ export function initAuthorsNote() { | |||
| 552 | </div> | 559 | </div> |
| 553 | `, | 560 | `, |
| 554 | })); | 561 | })); |
| 555 | SlashCommandParser.addCommandObject(SlashCommand.fromProps({ name: 'note-role', | 562 | SlashCommandParser.addCommandObject(SlashCommand.fromProps({ |
| 563 | name: 'note-role', | ||
| 556 | callback: setNoteRoleCommand, | 564 | callback: setNoteRoleCommand, |
| 557 | returns: 'current author\'s note chat insertion role', | 565 | returns: 'current author\'s note chat insertion role', |
| 558 | namedArgumentList: [], | 566 | namedArgumentList: [], |