Run eslint

This commit is contained in:
Cohee
2024-07-14 14:07:23 +03:00
parent fe0b29f606
commit 3fb83e47ec
4 changed files with 29 additions and 29 deletions

View File

@ -464,7 +464,7 @@ export function evaluateMacros(content, env) {
content = content.replace(/{{firstIncludedMessageId}}/gi, () => String(getFirstIncludedMessageId() ?? '')); content = content.replace(/{{firstIncludedMessageId}}/gi, () => String(getFirstIncludedMessageId() ?? ''));
content = content.replace(/{{lastSwipeId}}/gi, () => String(getLastSwipeId() ?? '')); content = content.replace(/{{lastSwipeId}}/gi, () => String(getLastSwipeId() ?? ''));
content = content.replace(/{{currentSwipeId}}/gi, () => String(getCurrentSwipeId() ?? '')); content = content.replace(/{{currentSwipeId}}/gi, () => String(getCurrentSwipeId() ?? ''));
content = content.replace(/{{reverse\:(.+?)}}/gi, (_, str) => Array.from(str).reverse().join('')) content = content.replace(/{{reverse\:(.+?)}}/gi, (_, str) => Array.from(str).reverse().join(''));
content = content.replace(/\{\{\/\/([\s\S]*?)\}\}/gm, ''); content = content.replace(/\{\{\/\/([\s\S]*?)\}\}/gm, '');

View File

@ -108,7 +108,7 @@ const METADATA_KEY = 'world_info';
const DEFAULT_DEPTH = 4; const DEFAULT_DEPTH = 4;
const DEFAULT_WEIGHT = 100; const DEFAULT_WEIGHT = 100;
const MAX_SCAN_DEPTH = 1000; const MAX_SCAN_DEPTH = 1000;
const KNOWN_DECORATORS = ['@@activate', '@@dont_activate'] const KNOWN_DECORATORS = ['@@activate', '@@dont_activate'];
// Typedef area // Typedef area
/** /**
@ -3546,45 +3546,45 @@ function parseDecorators(content){
*/ */
const isKnownDecorator = (data) => { const isKnownDecorator = (data) => {
if (data.startsWith('@@@')) { if (data.startsWith('@@@')) {
data = data.substring(1) data = data.substring(1);
} }
for (let i = 0; i < KNOWN_DECORATORS.length; i++) { for (let i = 0; i < KNOWN_DECORATORS.length; i++) {
if (data.startsWith(KNOWN_DECORATORS[i])) { if (data.startsWith(KNOWN_DECORATORS[i])) {
return true return true;
} }
} }
return false return false;
} };
if (content.startsWith('@@')) { if (content.startsWith('@@')) {
let newContent = content; let newContent = content;
const splited = content.split('\n'); const splited = content.split('\n');
let decorators = [] let decorators = [];
let fallbacked = false; let fallbacked = false;
for (let i = 0; i < splited.length; i++) { for (let i = 0; i < splited.length; i++) {
if (splited[i].startsWith('@@')) { if (splited[i].startsWith('@@')) {
if (splited[i].startsWith('@@@') && !fallbacked) { if (splited[i].startsWith('@@@') && !fallbacked) {
continue continue;
} }
if (isKnownDecorator(splited[i])) { if (isKnownDecorator(splited[i])) {
decorators.push(splited[i].startsWith('@@@') ? splited[i].substring(1) : splited[i]) decorators.push(splited[i].startsWith('@@@') ? splited[i].substring(1) : splited[i]);
fallbacked = false fallbacked = false;
} }
else { else {
fallbacked = true fallbacked = true;
} }
} else { } else {
newContent = splited.slice(i).join('\n'); newContent = splited.slice(i).join('\n');
break; break;
} }
} }
return [decorators, newContent] return [decorators, newContent];
} }
return [[], content] return [[], content];
} }

View File

@ -31,8 +31,8 @@ const write = (image, data) => {
try { try {
//change v2 format to v3 //change v2 format to v3
const v3Data = JSON.parse(data); const v3Data = JSON.parse(data);
v3Data.spec = 'chara_card_v3' v3Data.spec = 'chara_card_v3';
v3Data.spec_version = '3.0' v3Data.spec_version = '3.0';
const base64EncodedData = Buffer.from(JSON.stringify(v3Data), 'utf8').toString('base64'); const base64EncodedData = Buffer.from(JSON.stringify(v3Data), 'utf8').toString('base64');
chunks.splice(-1, 0, PNGtext.encode('ccv3', base64EncodedData)); chunks.splice(-1, 0, PNGtext.encode('ccv3', base64EncodedData));

View File

@ -409,7 +409,7 @@ function charaFormatData(data, directories) {
//_.set(char, 'data.extensions.chat', data.ch_name + ' - ' + humanizedISO8601DateTime()); //_.set(char, 'data.extensions.chat', data.ch_name + ' - ' + humanizedISO8601DateTime());
// V3 fields // V3 fields
_.set(char, 'data.group_only_greetings', data.group_only_greetings ?? []) _.set(char, 'data.group_only_greetings', data.group_only_greetings ?? []);
if (data.world) { if (data.world) {
try { try {