Run eslint
| @@ -464,7 +464,7 @@ export function evaluateMacros(content, env) { | |||
| 464 | content = content.replace(/{{firstIncludedMessageId}}/gi, () => String(getFirstIncludedMessageId() ?? '')); | 464 | content = content.replace(/{{firstIncludedMessageId}}/gi, () => String(getFirstIncludedMessageId() ?? '')); |
| 465 | content = content.replace(/{{lastSwipeId}}/gi, () => String(getLastSwipeId() ?? '')); | 465 | content = content.replace(/{{lastSwipeId}}/gi, () => String(getLastSwipeId() ?? '')); |
| 466 | content = content.replace(/{{currentSwipeId}}/gi, () => String(getCurrentSwipeId() ?? '')); | 466 | content = content.replace(/{{currentSwipeId}}/gi, () => String(getCurrentSwipeId() ?? '')); |
| 467 | content = content.replace(/{{reverse\:(.+?)}}/gi, (_, str) => Array.from(str).reverse().join('')) | 467 | content = content.replace(/{{reverse\:(.+?)}}/gi, (_, str) => Array.from(str).reverse().join('')); |
| 468 | 468 | ||
| 469 | content = content.replace(/\{\{\/\/([\s\S]*?)\}\}/gm, ''); | 469 | content = content.replace(/\{\{\/\/([\s\S]*?)\}\}/gm, ''); |
| 470 | 470 | ||
| @@ -108,7 +108,7 @@ const METADATA_KEY = 'world_info'; | |||
| 108 | const DEFAULT_DEPTH = 4; | 108 | const DEFAULT_DEPTH = 4; |
| 109 | const DEFAULT_WEIGHT = 100; | 109 | const DEFAULT_WEIGHT = 100; |
| 110 | const MAX_SCAN_DEPTH = 1000; | 110 | const MAX_SCAN_DEPTH = 1000; |
| 111 | const KNOWN_DECORATORS = ['@@activate', '@@dont_activate'] | 111 | const KNOWN_DECORATORS = ['@@activate', '@@dont_activate']; |
| 112 | 112 | ||
| 113 | // Typedef area | 113 | // Typedef area |
| 114 | /** | 114 | /** |
| @@ -3538,53 +3538,53 @@ export async function getSortedEntries() { | |||
| 3538 | * @param {string} content The content to parse | 3538 | * @param {string} content The content to parse |
| 3539 | * @returns {[string[],string]} The decorators found in the content and the content without decorators | 3539 | * @returns {[string[],string]} The decorators found in the content and the content without decorators |
| 3540 | */ | 3540 | */ |
| 3541 | function parseDecorators(content){ | 3541 | function parseDecorators(content) { |
| 3542 | /** | 3542 | /** |
| 3543 | * Check if the decorator is known | 3543 | * Check if the decorator is known |
| 3544 | * @param {string} data string to check | 3544 | * @param {string} data string to check |
| 3545 | * @returns {boolean} true if the decorator is known | 3545 | * @returns {boolean} true if the decorator is known |
| 3546 | */ | 3546 | */ |
| 3547 | const isKnownDecorator = (data) => { | 3547 | const isKnownDecorator = (data) => { |
| 3548 | if(data.startsWith('@@@')){ | 3548 | if (data.startsWith('@@@')) { |
| 3549 | data = data.substring(1) | 3549 | data = data.substring(1); |
| 3550 | } | 3550 | } |
| 3551 | 3551 | ||
| 3552 | for(let i = 0; i<KNOWN_DECORATORS.length;i++){ | 3552 | for (let i = 0; i < KNOWN_DECORATORS.length; i++) { |
| 3553 | if(data.startsWith(KNOWN_DECORATORS[i])){ | 3553 | if (data.startsWith(KNOWN_DECORATORS[i])) { |
| 3554 | return true | 3554 | return true; |
| 3555 | } | 3555 | } |
| 3556 | } | 3556 | } |
| 3557 | return false | 3557 | return false; |
| 3558 | } | 3558 | }; |
| 3559 | 3559 | ||
| 3560 | if(content.startsWith('@@')){ | 3560 | if (content.startsWith('@@')) { |
| 3561 | let newContent = content; | 3561 | let newContent = content; |
| 3562 | const splited = content.split('\n'); | 3562 | const splited = content.split('\n'); |
| 3563 | let decorators = [] | 3563 | let decorators = []; |
| 3564 | let fallbacked = false; | 3564 | let fallbacked = false; |
| 3565 | 3565 | ||
| 3566 | for (let i = 0; i < splited.length; i++) { | 3566 | for (let i = 0; i < splited.length; i++) { |
| 3567 | if(splited[i].startsWith('@@')){ | 3567 | if (splited[i].startsWith('@@')) { |
| 3568 | if(splited[i].startsWith('@@@') && !fallbacked){ | 3568 | if (splited[i].startsWith('@@@') && !fallbacked) { |
| 3569 | continue | 3569 | continue; |
| 3570 | } | 3570 | } |
| 3571 | 3571 | ||
| 3572 | if(isKnownDecorator(splited[i])){ | 3572 | if (isKnownDecorator(splited[i])) { |
| 3573 | decorators.push(splited[i].startsWith('@@@') ? splited[i].substring(1) : splited[i]) | 3573 | decorators.push(splited[i].startsWith('@@@') ? splited[i].substring(1) : splited[i]); |
| 3574 | fallbacked = false | 3574 | fallbacked = false; |
| 3575 | } | 3575 | } |
| 3576 | else{ | 3576 | else { |
| 3577 | fallbacked = true | 3577 | fallbacked = true; |
| 3578 | } | 3578 | } |
| 3579 | } else { | 3579 | } else { |
| 3580 | newContent = splited.slice(i).join('\n'); | 3580 | newContent = splited.slice(i).join('\n'); |
| 3581 | break; | 3581 | break; |
| 3582 | } | 3582 | } |
| 3583 | } | 3583 | } |
| 3584 | return [decorators, newContent] | 3584 | return [decorators, newContent]; |
| 3585 | } | 3585 | } |
| 3586 | 3586 | ||
| 3587 | return [[], content] | 3587 | return [[], content]; |
| 3588 | 3588 | ||
| 3589 | } | 3589 | } |
| 3590 | 3590 | ||
| @@ -3714,17 +3714,17 @@ async function checkWorldInfo(chat, maxContext, isDryRun) { | |||
| 3714 | continue; | 3714 | continue; |
| 3715 | } | 3715 | } |
| 3716 | 3716 | ||
| 3717 | if(decorators.includes('@@activate')){ | 3717 | if (decorators.includes('@@activate')) { |
| 3718 | //activate in any case | 3718 | //activate in any case |
| 3719 | activatedNow.add(entry); | 3719 | activatedNow.add(entry); |
| 3720 | continue; | 3720 | continue; |
| 3721 | } | 3721 | } |
| 3722 | 3722 | ||
| 3723 | if(decorators.includes('@@dont_activate')){ | 3723 | if (decorators.includes('@@dont_activate')) { |
| 3724 | //deactivate in any case if @@activate is not present | 3724 | //deactivate in any case if @@activate is not present |
| 3725 | continue; | 3725 | continue; |
| 3726 | } | 3726 | } |
| 3727 | 3727 | ||
| 3728 | if (entry.constant || buffer.isExternallyActivated(entry) || isSticky) { | 3728 | if (entry.constant || buffer.isExternallyActivated(entry) || isSticky) { |
| 3729 | activatedNow.add(entry); | 3729 | activatedNow.add(entry); |
| 3730 | continue; | 3730 | continue; |
| @@ -31,12 +31,12 @@ const write = (image, data) => { | |||
| 31 | try { | 31 | try { |
| 32 | //change v2 format to v3 | 32 | //change v2 format to v3 |
| 33 | const v3Data = JSON.parse(data); | 33 | const v3Data = JSON.parse(data); |
| 34 | v3Data.spec = 'chara_card_v3' | 34 | v3Data.spec = 'chara_card_v3'; |
| 35 | v3Data.spec_version = '3.0' | 35 | v3Data.spec_version = '3.0'; |
| 36 | 36 | ||
| 37 | const base64EncodedData = Buffer.from(JSON.stringify(v3Data), 'utf8').toString('base64'); | 37 | const base64EncodedData = Buffer.from(JSON.stringify(v3Data), 'utf8').toString('base64'); |
| 38 | chunks.splice(-1, 0, PNGtext.encode('ccv3', base64EncodedData)); | 38 | chunks.splice(-1, 0, PNGtext.encode('ccv3', base64EncodedData)); |
| 39 | } catch (error) {} | 39 | } catch (error) { } |
| 40 | 40 | ||
| 41 | const newBuffer = Buffer.from(encode(chunks)); | 41 | const newBuffer = Buffer.from(encode(chunks)); |
| 42 | return newBuffer; | 42 | return newBuffer; |
| @@ -409,7 +409,7 @@ function charaFormatData(data, directories) { | |||
| 409 | //_.set(char, 'data.extensions.chat', data.ch_name + ' - ' + humanizedISO8601DateTime()); | 409 | //_.set(char, 'data.extensions.chat', data.ch_name + ' - ' + humanizedISO8601DateTime()); |
| 410 | 410 | ||
| 411 | // V3 fields | 411 | // V3 fields |
| 412 | _.set(char, 'data.group_only_greetings', data.group_only_greetings ?? []) | 412 | _.set(char, 'data.group_only_greetings', data.group_only_greetings ?? []); |
| 413 | 413 | ||
| 414 | if (data.world) { | 414 | if (data.world) { |
| 415 | try { | 415 | try { |