koishi-plugin-bilibili-videolink-analysis 1.1.9 → 1.1.11

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 +32 -13
  2. package/package.json +1 -1
  3. package/readme.md +6 -0
package/lib/index.js CHANGED
@@ -72,7 +72,7 @@ exports.Config = Schema.intersect([
72
72
  Schema.const('4').description('返回视频和视频直链'),
73
73
  Schema.const('5').description('返回视频,仅在日志记录视频直链'),
74
74
  ]).role('radio').default('2').description("是否返回` 视频/视频直链 `"),
75
- BVnumberParsing: Schema.boolean().default(true).description("是否允许根据`独立的BV号`解析视频 `开启后,可以通过视频的BV号解析视频。` <br> [触发说明见README](https://www.npmjs.com/package/koishi-plugin-bilibili-videolink-analysis)"),
75
+ BVnumberParsing: Schema.boolean().default(true).description("是否允许根据`独立的BV、AV号`解析视频 `开启后,可以通过视频的BV、AV号解析视频。` <br> [触发说明见README](https://www.npmjs.com/package/koishi-plugin-bilibili-videolink-analysis)"),
76
76
  Maximumduration: Schema.number().default(25).description("允许解析的视频最大时长(分钟)`超过这个时长 就不会发视频`").min(1),
77
77
  Maximumduration_tip: Schema.union([
78
78
  Schema.const('不返回文字提示').description('不返回文字提示'),
@@ -89,7 +89,8 @@ exports.Config = Schema.intersect([
89
89
  Schema.const("bv").description("BV 号"),
90
90
  Schema.const("av").description("AV 号"),
91
91
  ]).default("bv").description("ID 偏好").hidden(),
92
- bVideo_area: Schema.string().role('textarea', { rows: [8, 16] }).description("图文解析的返回格式<br>注意变量格式,以及变量名称<br>比如 `${标题}` 不可以变成`${标题123}`,你可以直接删掉但是不能修改变量名称哦<br>当然变量也不能无中生有,下面的默认值内容 就是所有变量了,你仅可以删去变量 或者修改变量之外的格式。")
92
+
93
+ bVideo_area: Schema.string().role('textarea', { rows: [8, 16] }).description("图文解析的返回格式<br>注意变量格式,以及变量名称。<br>比如 `${标题}` 不可以变成`${标题123}`,你可以直接删掉但是不能修改变量名称哦<br>当然变量也不能无中生有,下面的默认值内容 就是所有变量了,你仅可以删去变量 或者修改变量之外的格式。<br>· 特殊变量`${~~~}`表示分割线,会把上下内容分为两个信息单独发送。")
93
94
  .default("${标题} --- ${UP主}\n---\n${封面}\n---\n${简介}\n---\n${点赞} --- ${投币}\n${收藏} --- ${转发}\n${观看} --- ${弹幕}"),
94
95
  bVideoShowLink: Schema.boolean().default(false).description("在末尾显示视频的链接地址 `开启可能会导致其他bot循环解析`"),
95
96
  bVideoShowIntroductionTofixed: Schema.number().default(50).description("视频的`简介`最大的字符长度<br>超出部分会使用 `...` 代替"),
@@ -515,22 +516,32 @@ display: none !important;
515
516
  async function processVideoFromLink(session, config, ctx, lastProcessedUrls, logger, ret, options = { video: true }) {
516
517
  const lastretUrl = extractLastUrl(ret);
517
518
 
518
- let mediaData = '';
519
-
520
519
  if (config.waitTip_Switch) {
521
520
  // 等候的提示文字
522
521
  await session.send(config.waitTip_Switch);
523
522
  }
524
523
 
524
+ let textParts = []; // 用于存储分割后的文本部分
525
525
  if (config.linktextParsing) {
526
+ let fullText;
526
527
  if (config.bVideoShowLink) {
527
- await session.send(ret); // 发送完整信息
528
+ fullText = ret; // 发送完整信息
528
529
  } else {
529
530
  // 去掉最后一个链接
530
- const retWithoutLastLink = ret.replace(lastretUrl, '');
531
- await session.send(retWithoutLastLink);
531
+ fullText = ret.replace(lastretUrl, '');
532
+ }
533
+
534
+ // 分割文本
535
+ textParts = fullText.split('${~~~}');
536
+ }
537
+ // 发送分割后的文本部分
538
+ for (const part of textParts) {
539
+ const trimmedPart = part.trim(); // 去除首尾空格
540
+ if (trimmedPart) { // 确保不是空字符串
541
+ await session.send(trimmedPart);
532
542
  }
533
543
  }
544
+
534
545
  if (config.VideoParsing_ToLink) {
535
546
  const fullAPIurl = `https://api.xingzhige.com/API/b_parse/?url=${encodeURIComponent(lastretUrl)}`;
536
547
 
@@ -604,15 +615,14 @@ display: none !important;
604
615
  }
605
616
  }
606
617
 
607
-
608
618
  if (config.loggerinfo) {
609
- //logger.info(`视频信息内容:\n ${JSON.stringify(mediaData)}`);
610
619
  logger.info(`机器人发送完整消息为:\n ${ret}`);
611
620
  }
612
621
  return;
613
622
  }
614
623
 
615
624
 
625
+
616
626
  // 提取最后一个URL
617
627
  function extractLastUrl(text) {
618
628
  const urlPattern = /https?:\/\/[^\s]+/g;
@@ -620,15 +630,24 @@ display: none !important;
620
630
  return urls ? urls.pop() : null;
621
631
  }
622
632
 
623
- // 检测BV号并转换为URL
633
+ // 检测BV / AV 号并转换为URL
624
634
  function convertBVToUrl(text) {
625
635
  const bvPattern = /(?:^|\s)(BV\w{10})(?:\s|$)/g;
626
- const bvMatches = [];
636
+ const avPattern = /(?:^|\s)(av\d+)(?:\s|$)/g; // 新增 AV 号的正则表达式
637
+ const matches = [];
627
638
  let match;
639
+
640
+ // 查找 BV 号
628
641
  while ((match = bvPattern.exec(text)) !== null) {
629
- bvMatches.push(match[1]);
642
+ matches.push(`https://www.bilibili.com/video/${match[1]}`);
630
643
  }
631
- return bvMatches.length ? bvMatches.map(bv => `https://www.bilibili.com/video/${bv}`) : [];
644
+
645
+ // 查找 AV 号
646
+ while ((match = avPattern.exec(text)) !== null) {
647
+ matches.push(`https://www.bilibili.com/video/${match[1]}`);
648
+ }
649
+
650
+ return matches;
632
651
  }
633
652
 
634
653
  // 记录上次处理链接的时间
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.9",
5
+ "version": "1.1.11",
6
6
  "main": "lib/index.js",
7
7
  "typings": "lib/index.d.ts",
8
8
  "files": [
package/readme.md CHANGED
@@ -178,6 +178,12 @@ https://www.bilibili.com/video/BV1ii421Q7oj
178
178
  <details>
179
179
  <summary>点击此处 可查看更新日志</summary>
180
180
 
181
+ - **1.1.11**
182
+ - 又想写了(指readme)
183
+ - 新增解析格式的的变量分割线
184
+ - 期间还写了什么,忘了
185
+ - 支持独立的AV号
186
+
181
187
  - **1.0.0**
182
188
  - 不想写了
183
189