koishi-plugin-best-cave 2.4.6 → 2.4.7
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 +17 -5
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -297,10 +297,22 @@ async function buildCaveMessage(cave, config, fileManager, logger2, platform, pr
|
|
|
297
297
|
const forwardNodes = Array.isArray(el.content) ? el.content : [];
|
|
298
298
|
const messageNodes = await Promise.all(forwardNodes.map(async (node) => {
|
|
299
299
|
const author = (0, import_koishi.h)("author", { id: node.userId, name: node.userName });
|
|
300
|
-
const
|
|
301
|
-
|
|
300
|
+
const contentElements = await transformToH(node.elements);
|
|
301
|
+
const unwrappedContent = [];
|
|
302
|
+
const nestedMessageNodes = [];
|
|
303
|
+
for (const contentEl of contentElements) {
|
|
304
|
+
if (contentEl.type === "message" && contentEl.attrs.forward) {
|
|
305
|
+
nestedMessageNodes.push(...contentEl.children);
|
|
306
|
+
} else {
|
|
307
|
+
unwrappedContent.push(contentEl);
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
const resultNodes = [];
|
|
311
|
+
if (unwrappedContent.length > 0) resultNodes.push((0, import_koishi.h)("message", {}, [author, ...unwrappedContent]));
|
|
312
|
+
resultNodes.push(...nestedMessageNodes);
|
|
313
|
+
return resultNodes;
|
|
302
314
|
}));
|
|
303
|
-
return (0, import_koishi.h)("message", { forward: true }, messageNodes);
|
|
315
|
+
return (0, import_koishi.h)("message", { forward: true }, messageNodes.flat());
|
|
304
316
|
} catch (error) {
|
|
305
317
|
logger2.warn(`解析回声洞(${cave.id})合并转发内容失败:`, error);
|
|
306
318
|
return import_koishi.h.text("[合并转发]");
|
|
@@ -321,7 +333,7 @@ async function buildCaveMessage(cave, config, fileManager, logger2, platform, pr
|
|
|
321
333
|
}
|
|
322
334
|
}
|
|
323
335
|
return null;
|
|
324
|
-
})).then((hElements) => hElements.filter(Boolean));
|
|
336
|
+
})).then((hElements) => hElements.flat().filter(Boolean));
|
|
325
337
|
}
|
|
326
338
|
__name(transformToH, "transformToH");
|
|
327
339
|
const caveHElements = await transformToH(cave.elements);
|
|
@@ -1108,7 +1120,7 @@ function apply(ctx, config) {
|
|
|
1108
1120
|
if (hashManager && textHashesToStore.length > 0) await ctx.database.upsert("cave_hash", textHashesToStore.map((h4) => ({ ...h4, cave: newCave.id })));
|
|
1109
1121
|
if (initialStatus === "pending") reviewManager.sendForPend(newCave);
|
|
1110
1122
|
}
|
|
1111
|
-
return
|
|
1123
|
+
return needsReview ? `提交成功,序号为(${newCave.id})` : `添加成功,序号为(${newCave.id})`;
|
|
1112
1124
|
} catch (error) {
|
|
1113
1125
|
logger.error("添加回声洞失败:", error);
|
|
1114
1126
|
return "添加失败,请稍后再试";
|