koishi-plugin-best-cave 2.3.6 → 2.3.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/index.js +3 -26
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -423,21 +423,9 @@ async function processMessageElements(sourceElements, newId, session) {
|
|
|
423
423
|
result.push({ type: "text", content: el.attrs.content.trim() });
|
|
424
424
|
} else if (type === "at" && el.attrs.id) {
|
|
425
425
|
result.push({ type: "at", content: el.attrs.id });
|
|
426
|
-
} else if (type === "forward") {
|
|
427
|
-
const
|
|
428
|
-
|
|
429
|
-
for (const rawMessage of el.attrs.content) {
|
|
430
|
-
if (rawMessage && rawMessage.message) {
|
|
431
|
-
childrenToProcess.push(...import_koishi.h.normalize(rawMessage.message));
|
|
432
|
-
}
|
|
433
|
-
}
|
|
434
|
-
}
|
|
435
|
-
if (childrenToProcess.length > 0) {
|
|
436
|
-
const transformedChildren = await transform(childrenToProcess);
|
|
437
|
-
if (transformedChildren.length > 0) {
|
|
438
|
-
result.push({ type: "forward", content: JSON.stringify(transformedChildren) });
|
|
439
|
-
}
|
|
440
|
-
}
|
|
426
|
+
} else if (type === "forward" && el.children?.length) {
|
|
427
|
+
const transformedChildren = await transform(el.children);
|
|
428
|
+
result.push({ type: "forward", content: JSON.stringify(transformedChildren) });
|
|
441
429
|
} else if (["image", "video", "audio", "file"].includes(type) && el.attrs.src) {
|
|
442
430
|
let fileIdentifier = el.attrs.src;
|
|
443
431
|
if (fileIdentifier.startsWith("http")) {
|
|
@@ -465,7 +453,6 @@ async function handleFileUploads(ctx, config, fileManager, logger2, reviewManage
|
|
|
465
453
|
const imageHashesToStore = [];
|
|
466
454
|
const allExistingImageHashes = hashManager ? await ctx.database.get("cave_hash", { type: { $ne: "simhash" } }) : [];
|
|
467
455
|
const existingGlobalHashes = allExistingImageHashes.filter((h4) => h4.type === "phash_g");
|
|
468
|
-
const existingQuadrantHashes = allExistingImageHashes.filter((h4) => h4.type.startsWith("phash_q"));
|
|
469
456
|
for (const media of mediaToToSave) {
|
|
470
457
|
const buffer = Buffer.from(await ctx.http.get(media.sourceUrl, { responseType: "arraybuffer", timeout: 3e4 }));
|
|
471
458
|
downloadedMedia.push({ fileName: media.fileName, buffer });
|
|
@@ -480,16 +467,6 @@ async function handleFileUploads(ctx, config, fileManager, logger2, reviewManage
|
|
|
480
467
|
return;
|
|
481
468
|
}
|
|
482
469
|
}
|
|
483
|
-
const notifiedPartialCaves = /* @__PURE__ */ new Set();
|
|
484
|
-
for (const newSubHash of Object.values(quadrantHashes)) {
|
|
485
|
-
for (const existing of existingQuadrantHashes) {
|
|
486
|
-
if (notifiedPartialCaves.has(existing.cave)) continue;
|
|
487
|
-
if (newSubHash === existing.hash) {
|
|
488
|
-
await session.send(`图片与回声洞(${existing.cave})局部相同`);
|
|
489
|
-
notifiedPartialCaves.add(existing.cave);
|
|
490
|
-
}
|
|
491
|
-
}
|
|
492
|
-
}
|
|
493
470
|
imageHashesToStore.push({ hash: globalHash, type: "phash_g" });
|
|
494
471
|
imageHashesToStore.push({ hash: quadrantHashes.q1, type: "phash_q1" });
|
|
495
472
|
imageHashesToStore.push({ hash: quadrantHashes.q2, type: "phash_q2" });
|