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.
Files changed (2) hide show
  1. package/lib/index.js +3 -26
  2. 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 childrenToProcess = [...el.children || []];
428
- if (Array.isArray(el.attrs.content)) {
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" });
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "koishi-plugin-best-cave",
3
3
  "description": "功能强大、高度可定制的回声洞。支持丰富的媒体类型、内容查重、人工审核、用户昵称、数据迁移以及本地/S3 双重文件存储后端。",
4
- "version": "2.3.6",
4
+ "version": "2.3.8",
5
5
  "contributors": [
6
6
  "Yis_Rime <yis_rime@outlook.com>"
7
7
  ],