koishi-plugin-bilibili-videolink-analysis 1.1.12 → 1.1.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.js +15 -16
- package/package.json +1 -1
- package/readme.md +1 -0
package/lib/index.js
CHANGED
|
@@ -543,27 +543,23 @@ display: none !important;
|
|
|
543
543
|
// 分割文本
|
|
544
544
|
const textParts = fullText.split('${~~~}');
|
|
545
545
|
|
|
546
|
-
//
|
|
547
|
-
let messageContent = [];
|
|
548
|
-
|
|
549
|
-
// 将分割后的文本部分解析为消息元素,并添加到 messageContent
|
|
546
|
+
// 循环处理每个分割后的部分
|
|
550
547
|
for (const part of textParts) {
|
|
551
548
|
const trimmedPart = part.trim(); // 去除首尾空格
|
|
552
549
|
if (trimmedPart) { // 确保不是空字符串
|
|
553
550
|
// 使用 h.parse 解析文本为消息元素
|
|
554
551
|
const parsedElements = h.parse(trimmedPart);
|
|
555
|
-
messageContent.push(...parsedElements);
|
|
556
|
-
}
|
|
557
|
-
}
|
|
558
552
|
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
553
|
+
// 创建 message 元素
|
|
554
|
+
const messageElement = h('message', {
|
|
555
|
+
userId: session.userId,
|
|
556
|
+
nickname: session.author?.nickname || session.username,
|
|
557
|
+
}, parsedElements);
|
|
564
558
|
|
|
565
|
-
|
|
566
|
-
|
|
559
|
+
// 添加 message 元素到 responseElements
|
|
560
|
+
responseElements.push(messageElement);
|
|
561
|
+
}
|
|
562
|
+
}
|
|
567
563
|
}
|
|
568
564
|
|
|
569
565
|
// 视频/链接解析
|
|
@@ -577,7 +573,9 @@ display: none !important;
|
|
|
577
573
|
const { bvid, cid, video } = responseData.data;
|
|
578
574
|
const bilibiliUrl = `https://api.bilibili.com/x/player/playurl?fnval=80&cid=${cid}&bvid=${bvid}`;
|
|
579
575
|
const playData = await ctx.http.get(bilibiliUrl);
|
|
576
|
+
|
|
580
577
|
logInfo(bilibiliUrl);
|
|
578
|
+
|
|
581
579
|
if (playData.code === 0 && playData.data && playData.data.dash.duration) {
|
|
582
580
|
const videoDurationSeconds = playData.data.dash.duration;
|
|
583
581
|
const videoDurationMinutes = videoDurationSeconds / 60;
|
|
@@ -592,8 +590,8 @@ display: none !important;
|
|
|
592
590
|
}
|
|
593
591
|
|
|
594
592
|
const videoUrl = video.url;
|
|
595
|
-
logInfo(videoUrl);
|
|
596
593
|
|
|
594
|
+
logInfo(videoUrl);
|
|
597
595
|
if (videoUrl) {
|
|
598
596
|
if (options.link) {
|
|
599
597
|
responseElements.push(h.text(videoUrl));
|
|
@@ -654,12 +652,13 @@ display: none !important;
|
|
|
654
652
|
}
|
|
655
653
|
}
|
|
656
654
|
|
|
657
|
-
logInfo(
|
|
655
|
+
logInfo(`机器人已发送完整消息。`);
|
|
658
656
|
return;
|
|
659
657
|
}
|
|
660
658
|
|
|
661
659
|
|
|
662
660
|
|
|
661
|
+
|
|
663
662
|
// 提取最后一个URL
|
|
664
663
|
function extractLastUrl(text) {
|
|
665
664
|
const urlPattern = /https?:\/\/[^\s]+/g;
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "koishi-plugin-bilibili-videolink-analysis",
|
|
3
3
|
"description": "[<ruby>Bilibili视频解析<rp>(</rp><rt>点我查看食用方法</rt><rp>)</rp></ruby>](https://www.npmjs.com/package/koishi-plugin-bilibili-videolink-analysis)解析B站链接(支持小程序卡片)支持搜索点播功能!灵感来自完美的 [bili-parser](/market?keyword=bili-parser) !",
|
|
4
4
|
"license": "MIT",
|
|
5
|
-
"version": "1.1.
|
|
5
|
+
"version": "1.1.13",
|
|
6
6
|
"main": "lib/index.js",
|
|
7
7
|
"typings": "lib/index.d.ts",
|
|
8
8
|
"files": [
|