Run eslint

3fb83e47ecc616b4557d737a9ac77197898ee7cd

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

4 files changed, +29 -29Ignore whitespace
public/scripts/macros.js+1 -1
@@ -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(''));
468468
469 content = content.replace(/\{\{\/\/([\s\S]*?)\}\}/gm, '');469 content = content.replace(/\{\{\/\/([\s\S]*?)\}\}/gm, '');
470470
public/scripts/world-info.js+24 -24
@@ -108,7 +108,7 @@ const METADATA_KEY = 'world_info';
108const DEFAULT_DEPTH = 4;108const DEFAULT_DEPTH = 4;
109const DEFAULT_WEIGHT = 100;109const DEFAULT_WEIGHT = 100;
110const MAX_SCAN_DEPTH = 1000;110const MAX_SCAN_DEPTH = 1000;
111const KNOWN_DECORATORS = ['@@activate', '@@dont_activate']111const KNOWN_DECORATORS = ['@@activate', '@@dont_activate'];
112112
113// Typedef area113// Typedef area
114/**114/**
@@ -3538,53 +3538,53 @@ export async function getSortedEntries() {
3538 * @param {string} content The content to parse3538 * @param {string} content The content to parse
3539 * @returns {[string[],string]} The decorators found in the content and the content without decorators3539 * @returns {[string[],string]} The decorators found in the content and the content without decorators
3540*/3540*/
3541function parseDecorators(content){3541function parseDecorators(content) {
3542 /**3542 /**
3543 * Check if the decorator is known3543 * Check if the decorator is known
3544 * @param {string} data string to check3544 * @param {string} data string to check
3545 * @returns {boolean} true if the decorator is known3545 * @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 }
35513551
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 true3554 return true;
3555 }3555 }
3556 }3556 }
3557 return false3557 return false;
3558 }3558 };
35593559
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;
35653565
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 continue3569 continue;
3570 }3570 }
35713571
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 = false3574 fallbacked = false;
3575 }3575 }
3576 else{3576 else {
3577 fallbacked = true3577 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 }
35863586
3587 return [[], content]3587 return [[], content];
35883588
3589}3589}
35903590
@@ -3714,17 +3714,17 @@ async function checkWorldInfo(chat, maxContext, isDryRun) {
3714 continue;3714 continue;
3715 }3715 }
37163716
3717 if(decorators.includes('@@activate')){3717 if (decorators.includes('@@activate')) {
3718 //activate in any case3718 //activate in any case
3719 activatedNow.add(entry);3719 activatedNow.add(entry);
3720 continue;3720 continue;
3721 }3721 }
37223722
3723 if(decorators.includes('@@dont_activate')){3723 if (decorators.includes('@@dont_activate')) {
3724 //deactivate in any case if @@activate is not present3724 //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;
src/character-card-parser.js+3 -3
@@ -31,12 +31,12 @@ const write = (image, data) => {
31 try {31 try {
32 //change v2 format to v332 //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';
3636
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) { }
4040
41 const newBuffer = Buffer.from(encode(chunks));41 const newBuffer = Buffer.from(encode(chunks));
42 return newBuffer;42 return newBuffer;
src/endpoints/characters.js+1 -1
@@ -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());
410410
411 // V3 fields411 // V3 fields
412 _.set(char, 'data.group_only_greetings', data.group_only_greetings ?? [])412 _.set(char, 'data.group_only_greetings', data.group_only_greetings ?? []);
413413
414 if (data.world) {414 if (data.world) {
415 try {415 try {