koishi-plugin-bilibili-videolink-analysis 1.1.22 → 1.1.24

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 (2) hide show
  1. package/lib/index.js +49 -33
  2. package/package.json +1 -1
package/lib/index.js CHANGED
@@ -69,7 +69,7 @@ exports.Config = Schema.intersect([
69
69
 
70
70
  Schema.object({
71
71
  enablebilianalysis: Schema.boolean().default(true).description("开启解析功能<br>`关闭后,解析功能将关闭`"),
72
- }).description('解析功能开关'),
72
+ }).description('视频解析 - 功能开关'),
73
73
  Schema.union([
74
74
  Schema.object({
75
75
  enablebilianalysis: Schema.const(false).required(),
@@ -90,16 +90,28 @@ exports.Config = Schema.intersect([
90
90
  Schema.const('5').description('返回视频,仅在日志记录视频直链'),
91
91
  ]).role('radio').default('2').description("是否返回` 视频/视频直链 `"),
92
92
  BVnumberParsing: Schema.boolean().default(true).description("是否允许根据`独立的BV、AV号`解析视频 `开启后,可以通过视频的BV、AV号解析视频。` <br> [触发说明见README](https://www.npmjs.com/package/koishi-plugin-bilibili-videolink-analysis)"),
93
- Maximumduration: Schema.number().default(25).description("允许解析的视频最大时长(分钟)`超过这个时长 就不会发视频`").min(1),
93
+ MinimumTimeInterval: Schema.number().default(180).description("若干`秒`内 不再处理相同链接 `防止多bot互相触发 导致的刷屏/性能浪费`").min(1),
94
+ }),
95
+
96
+ Schema.object({
97
+ enablebilianalysis: Schema.const(true),
98
+ Minimumduration: Schema.number().default(0).description("允许解析的视频最小时长(分钟)`低于这个时长 就不会发视频内容`").min(0),
99
+ Minimumduration_tip: Schema.union([
100
+ Schema.const('return').description('不返回文字提示'),
101
+ Schema.object({
102
+ tipcontent: Schema.string().default('视频太短啦!不看不看~').description("文字提示内容"),
103
+ tipanalysis: Schema.boolean().default(true).description("是否进行图文解析(不会返回视频链接)"),
104
+ }).description('返回文字提示'),
105
+ ]).description("对`过短视频`的文字提示内容").default({}),
106
+ Maximumduration: Schema.number().default(25).description("允许解析的视频最大时长(分钟)`超过这个时长 就不会发视频内容`").min(1),
94
107
  Maximumduration_tip: Schema.union([
95
108
  Schema.const('return').description('不返回文字提示'),
96
109
  Schema.object({
97
110
  tipcontent: Schema.string().default('视频太长啦!内容还是去B站看吧~').description("文字提示内容"),
98
- tipanalysis: Schema.boolean().default(false).description("是否进行图文解析(不会返回视频链接)"),
111
+ tipanalysis: Schema.boolean().default(true).description("是否进行图文解析(不会返回视频链接)"),
99
112
  }).description('返回文字提示'),
100
113
  ]).description("对`过长视频`的文字提示内容").default({}),
101
- MinimumTimeInterval: Schema.number().default(180).description("若干`秒`内 不再处理相同链接 `防止多bot互相触发 导致的刷屏/性能浪费`").min(1),
102
- }),
114
+ }).description("视频解析 - 内容限制"),
103
115
 
104
116
  Schema.object({
105
117
  parseLimit: Schema.number().default(3).description("单对话多链接解析上限").hidden(),
@@ -129,6 +141,7 @@ exports.Config = Schema.intersect([
129
141
  Schema.object({
130
142
  pageclose: Schema.boolean().default(true).description("自动`page.close()`<br>非开发者请勿改动").experimental(),
131
143
  loggerinfo: Schema.boolean().default(false).description("日志调试输出 `日常使用无需开启`<br>非开发者请勿改动").experimental(),
144
+ loggerinfofulljson: Schema.boolean().default(false).description("打印完整的机器人发送的json输出").experimental(),
132
145
  }).description("开发者选项"),
133
146
  ]);
134
147
 
@@ -519,7 +532,35 @@ display: none !important;
519
532
  const videoDurationSeconds = playData.data.dash.duration;
520
533
  const videoDurationMinutes = videoDurationSeconds / 60;
521
534
 
522
- if (videoDurationMinutes > config.Maximumduration) {
535
+ // 检查视频是否太短
536
+ if (videoDurationMinutes < config.Minimumduration) {
537
+ isShortVideo = true;
538
+
539
+ // 根据 Minimumduration_tip 的值决定行为
540
+ if (config.Minimumduration_tip === 'return') {
541
+ // 不返回文字提示,直接返回
542
+ return;
543
+ } else if (typeof config.Minimumduration_tip === 'object') {
544
+ // 返回文字提示
545
+ if (config.Minimumduration_tip.tipcontent) {
546
+ if (config.Minimumduration_tip.tipanalysis) {
547
+ videoElements.push(h.text(config.Minimumduration_tip.tipcontent));
548
+ } else {
549
+ await session.send(config.Minimumduration_tip.tipcontent);
550
+ }
551
+ }
552
+
553
+ // 决定是否进行图文解析
554
+ shouldPerformTextParsing = config.Minimumduration_tip.tipanalysis === true;
555
+
556
+ // 如果不进行图文解析,清空已准备的文本元素
557
+ if (!shouldPerformTextParsing) {
558
+ textElements = [];
559
+ }
560
+ }
561
+ }
562
+ // 检查视频是否太长
563
+ else if (videoDurationMinutes > config.Maximumduration) {
523
564
  isLongVideo = true;
524
565
 
525
566
  // 根据 Maximumduration_tip 的值决定行为
@@ -646,35 +687,10 @@ display: none !important;
646
687
  children: allElements
647
688
  });
648
689
 
649
- // 创建一个用于日志的深拷贝对象,避免修改原始对象
650
- const logObject = JSON.parse(JSON.stringify(figureContent));
651
-
652
- // 递归处理对象,截断长字符串
653
- function truncateLongStrings(obj, maxLength = 150) {
654
- if (!obj) return obj;
655
-
656
- if (typeof obj === 'string' && obj.length > maxLength) {
657
- return obj.substring(0, maxLength) + '... [截断剩余' + (obj.length - maxLength) + '字符]';
658
- }
659
-
660
- if (Array.isArray(obj)) {
661
- return obj.map(item => truncateLongStrings(item, maxLength));
662
- }
663
-
664
- if (typeof obj === 'object') {
665
- const newObj = {};
666
- for (const key in obj) {
667
- newObj[key] = truncateLongStrings(obj[key], maxLength);
668
- }
669
- return newObj;
670
- }
671
-
672
- return obj;
690
+ if (config.loggerinfofulljson) {
691
+ logInfo(JSON.stringify(figureContent, null, 2));
673
692
  }
674
693
 
675
- // 截断长字符串后再打印
676
- logInfo(JSON.stringify(truncateLongStrings(logObject), null, 2));
677
-
678
694
  // 发送合并转发消息
679
695
  await session.send(figureContent);
680
696
  } else {
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.22",
5
+ "version": "1.1.24",
6
6
  "main": "lib/index.js",
7
7
  "typings": "lib/index.d.ts",
8
8
  "files": [