koishi-plugin-best-cave 2.3.13 → 2.3.14
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 +18 -1
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -435,7 +435,24 @@ async function processMessageElements(sourceElements, newId, session, config, lo
|
|
|
435
435
|
if (!node.message || !Array.isArray(node.message)) continue;
|
|
436
436
|
const userId = node.sender?.user_id;
|
|
437
437
|
const userName = node.sender?.nickname;
|
|
438
|
-
const
|
|
438
|
+
const elementsToProcess = node.message.map((segment) => {
|
|
439
|
+
const { type: type2, data } = segment;
|
|
440
|
+
const attrs = { ...data };
|
|
441
|
+
if (type2 === "text" && typeof data.text !== "undefined") {
|
|
442
|
+
attrs.content = data.text;
|
|
443
|
+
delete attrs.text;
|
|
444
|
+
}
|
|
445
|
+
if (type2 === "at" && typeof data.qq !== "undefined") {
|
|
446
|
+
attrs.id = data.qq;
|
|
447
|
+
delete attrs.qq;
|
|
448
|
+
}
|
|
449
|
+
if (["image", "video", "audio"].includes(type2) && typeof data.url !== "undefined") {
|
|
450
|
+
attrs.src = data.url;
|
|
451
|
+
delete attrs.url;
|
|
452
|
+
}
|
|
453
|
+
return (0, import_koishi.h)(type2, attrs);
|
|
454
|
+
});
|
|
455
|
+
const contentElements = await transform(elementsToProcess);
|
|
439
456
|
if (contentElements.length > 0) {
|
|
440
457
|
forwardNodes.push({ userId, userName, elements: contentElements });
|
|
441
458
|
}
|