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.
Files changed (3) hide show
  1. package/lib/index.js +15 -16
  2. package/package.json +1 -1
  3. 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
- // 创建 message 元素的内容数组
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
- // 创建 message 元素
560
- const messageElement = h('message', {
561
- userId: session.userId,
562
- nickname: session.author?.nickname || session.username,
563
- }, messageContent);
553
+ // 创建 message 元素
554
+ const messageElement = h('message', {
555
+ userId: session.userId,
556
+ nickname: session.author?.nickname || session.username,
557
+ }, parsedElements);
564
558
 
565
- // 添加 message 元素到 responseElements
566
- responseElements.push(messageElement);
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.12",
5
+ "version": "1.1.13",
6
6
  "main": "lib/index.js",
7
7
  "typings": "lib/index.d.ts",
8
8
  "files": [
package/readme.md CHANGED
@@ -181,6 +181,7 @@ https://www.bilibili.com/video/BV1ii421Q7oj
181
181
  - **1.1.12**
182
182
  - 支持合并转发
183
183
  - 支持独立的AV号
184
+ - 修复合并转发与`${~~~}`不兼容的问题
184
185
 
185
186
  - **1.1.11**
186
187
  - 又想写了(指readme)