koishi-plugin-best-cave 2.3.12 → 2.3.13

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.d.ts CHANGED
@@ -7,7 +7,7 @@ export declare const usage = "\n<div style=\"border-radius: 10px; border: 1px so
7
7
  * @description 存储在数据库中的单个消息元素。
8
8
  */
9
9
  export interface StoredElement {
10
- type: 'text' | 'image' | 'video' | 'audio' | 'file' | 'at' | 'forward';
10
+ type: 'text' | 'image' | 'video' | 'audio' | 'file' | 'at' | 'forward' | 'reply';
11
11
  content?: string;
12
12
  file?: string;
13
13
  }
package/lib/index.js CHANGED
@@ -297,6 +297,7 @@ async function buildCaveMessage(cave, config, fileManager, logger2) {
297
297
  return Promise.all(elements.map(async (el) => {
298
298
  if (el.type === "text") return import_koishi.h.text(el.content);
299
299
  if (el.type === "at") return (0, import_koishi.h)("at", { id: el.content });
300
+ if (el.type === "reply") return (0, import_koishi.h)("reply", { id: el.content });
300
301
  if (el.type === "forward") {
301
302
  try {
302
303
  const forwardNodes = JSON.parse(el.content || "[]");
@@ -414,7 +415,7 @@ async function processMessageElements(sourceElements, newId, session, config, lo
414
415
  let mediaIndex = 0;
415
416
  async function transform(elements) {
416
417
  const result = [];
417
- const typeMap = { "img": "image", "image": "image", "video": "video", "audio": "audio", "file": "file", "text": "text", "at": "at", "forward": "forward" };
418
+ const typeMap = { "img": "image", "image": "image", "video": "video", "audio": "audio", "file": "file", "text": "text", "at": "at", "forward": "forward", "reply": "reply" };
418
419
  const defaultExtMap = { "image": ".jpg", "video": ".mp4", "audio": ".mp3", "file": ".dat" };
419
420
  for (const el of elements) {
420
421
  const type = typeMap[el.type];
@@ -426,16 +427,22 @@ async function processMessageElements(sourceElements, newId, session, config, lo
426
427
  result.push({ type: "text", content: el.attrs.content.trim() });
427
428
  } else if (type === "at" && el.attrs.id) {
428
429
  result.push({ type: "at", content: el.attrs.id });
430
+ } else if (type === "reply" && el.attrs.id) {
431
+ result.push({ type: "reply", content: el.attrs.id });
429
432
  } else if (type === "forward" && Array.isArray(el.attrs.content)) {
430
433
  const forwardNodes = [];
431
434
  for (const node of el.attrs.content) {
432
- if (!node.message) continue;
435
+ if (!node.message || !Array.isArray(node.message)) continue;
433
436
  const userId = node.sender?.user_id;
434
437
  const userName = node.sender?.nickname;
435
438
  const contentElements = await transform(import_koishi.h.normalize(node.message));
436
- forwardNodes.push({ userId, userName, elements: contentElements });
439
+ if (contentElements.length > 0) {
440
+ forwardNodes.push({ userId, userName, elements: contentElements });
441
+ }
442
+ }
443
+ if (forwardNodes.length > 0) {
444
+ result.push({ type: "forward", content: JSON.stringify(forwardNodes) });
437
445
  }
438
- result.push({ type: "forward", content: JSON.stringify(forwardNodes) });
439
446
  } else if (["image", "video", "audio", "file"].includes(type) && el.attrs.src) {
440
447
  let fileIdentifier = el.attrs.src;
441
448
  if (fileIdentifier.startsWith("http")) {
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.12",
4
+ "version": "2.3.13",
5
5
  "contributors": [
6
6
  "Yis_Rime <yis_rime@outlook.com>"
7
7
  ],