koishi-plugin-bilibili-videolink-analysis 1.1.15 → 1.1.17

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 +87 -65
  2. package/package.json +1 -1
package/lib/index.js CHANGED
@@ -54,53 +54,73 @@ exports.usage = `
54
54
  exports.Config = Schema.intersect([
55
55
  Schema.object({
56
56
  demand: Schema.boolean().default(true).description("开启点播指令功能<br>`其实点播登录不登录 都搜不准,登录只是写着玩的`"),
57
- timeout: Schema.number().role('slider').min(1).max(300).step(1).default(60).description('指定播放视频的输入时限。`单位 秒`'),
58
- point: Schema.tuple([Number, Number]).description('序号标注位置。分别表示`距离顶部 距离左侧`的百分比').default([50, 50]),
59
- enable: Schema.boolean().description('是否开启自动解析`选择对应视频 会自动解析视频内容`').default(true),
60
57
  }).description('点播设置(需要puppeteer服务)'),
58
+ Schema.union([
59
+ Schema.object({
60
+ demand: Schema.const(false).required(),
61
+ }),
62
+ Schema.object({
63
+ demand: Schema.const(true),
64
+ timeout: Schema.number().role('slider').min(1).max(300).step(1).default(60).description('指定播放视频的输入时限。`单位 秒`'),
65
+ point: Schema.tuple([Number, Number]).description('序号标注位置。分别表示`距离顶部 距离左侧`的百分比').default([50, 50]),
66
+ enable: Schema.boolean().description('是否开启自动解析`选择对应视频 会自动解析视频内容`').default(true),
67
+ }),
68
+ ]),
61
69
 
62
70
  Schema.object({
63
- waitTip_Switch: Schema.union([
64
- Schema.const().description('不返回文字提示'),
65
- Schema.string().description('返回文字提示(请在右侧填写文字内容)'),
66
- ]).description("是否返回等待提示。开启后,会发送`等待提示语`"),
67
- linktextParsing: Schema.boolean().default(true).description("是否返回 视频图文数据 `开启后,才发送视频数据的图文解析。`"),
68
- VideoParsing_ToLink: Schema.union([
69
- Schema.const('1').description('不返回视频/视频直链'),
70
- Schema.const('2').description('仅返回视频'),
71
- Schema.const('3').description('仅返回视频直链'),
72
- Schema.const('4').description('返回视频和视频直链'),
73
- Schema.const('5').description('返回视频,仅在日志记录视频直链'),
74
- ]).role('radio').default('2').description("是否返回` 视频/视频直链 `"),
75
- BVnumberParsing: Schema.boolean().default(true).description("是否允许根据`独立的BV、AV号`解析视频 `开启后,可以通过视频的BV、AV号解析视频。` <br> [触发说明见README](https://www.npmjs.com/package/koishi-plugin-bilibili-videolink-analysis)"),
76
- Maximumduration: Schema.number().default(25).description("允许解析的视频最大时长(分钟)`超过这个时长 就不会发视频`").min(1),
77
- Maximumduration_tip: Schema.union([
78
- Schema.const('不返回文字提示').description('不返回文字提示'),
79
- Schema.string().description('返回文字提示(请在右侧填写文字内容)').default('视频太长啦!还是去B站看吧~'),
80
- ]).description("对过长视频的文字提示内容").default('视频太长啦!还是去B站看吧~'),
81
- MinimumTimeInterval: Schema.number().default(180).description("若干`秒`内 不再处理相同链接 `防止多bot互相触发 导致的刷屏/性能浪费`").min(1),
82
- }).description("基础设置"),
71
+ enablebilianalysis: Schema.boolean().default(true).description("开启解析功能<br>`关闭后,解析功能将关闭`"),
72
+ }).description('解析功能开关'),
73
+ Schema.union([
74
+ Schema.object({
75
+ enablebilianalysis: Schema.const(false).required(),
76
+ }),
77
+ Schema.intersect([
78
+ Schema.object({
79
+ enablebilianalysis: Schema.const(true),
80
+ waitTip_Switch: Schema.union([
81
+ Schema.const().description('不返回文字提示'),
82
+ Schema.string().description('返回文字提示(请在右侧填写文字内容)'),
83
+ ]).description("是否返回等待提示。开启后,会发送`等待提示语`"),
84
+ linktextParsing: Schema.boolean().default(true).description("是否返回 视频图文数据 `开启后,才发送视频数据的图文解析。`"),
85
+ VideoParsing_ToLink: Schema.union([
86
+ Schema.const('1').description('不返回视频/视频直链'),
87
+ Schema.const('2').description('仅返回视频'),
88
+ Schema.const('3').description('仅返回视频直链'),
89
+ Schema.const('4').description('返回视频和视频直链'),
90
+ Schema.const('5').description('返回视频,仅在日志记录视频直链'),
91
+ ]).role('radio').default('2').description("是否返回` 视频/视频直链 `"),
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),
94
+ Maximumduration_tip: Schema.union([
95
+ Schema.const('不返回文字提示').description('不返回文字提示'),
96
+ Schema.string().description('返回文字提示(请在右侧填写文字内容)').default('视频太长啦!还是去B站看吧~'),
97
+ ]).description("对过长视频的文字提示内容").default('视频太长啦!还是去B站看吧~'),
98
+ MinimumTimeInterval: Schema.number().default(180).description("若干`秒`内 不再处理相同链接 `防止多bot互相触发 导致的刷屏/性能浪费`").min(1),
99
+ }),
100
+
101
+ Schema.object({
102
+ parseLimit: Schema.number().default(3).description("单对话多链接解析上限").hidden(),
103
+ useNumeral: Schema.boolean().default(true).description("使用格式化数字").hidden(),
104
+ showError: Schema.boolean().default(false).description("当链接不正确时提醒发送者").hidden(),
105
+ bVideoIDPreference: Schema.union([
106
+ Schema.const("bv").description("BV 号"),
107
+ Schema.const("av").description("AV 号"),
108
+ ]).default("bv").description("ID 偏好").hidden(),
109
+
110
+ bVideo_area: Schema.string().role('textarea', { rows: [8, 16] }).description("图文解析的返回格式<br>注意变量格式,以及变量名称。<br>比如 `${标题}` 不可以变成`${标题123}`,你可以直接删掉但是不能修改变量名称哦<br>当然变量也不能无中生有,下面的默认值内容 就是所有变量了,你仅可以删去变量 或者修改变量之外的格式。<br>· 特殊变量`${~~~}`表示分割线,会把上下内容分为两个信息单独发送。")
111
+ .default("${标题} --- ${UP主}\n${简介}\n点赞:${点赞} --- 投币:${投币}\n收藏:${收藏} --- 转发:${转发}\n观看:${观看} --- 弹幕:${弹幕}\n${~~~}\n${封面}"),
112
+ bVideoShowLink: Schema.boolean().default(false).description("在末尾显示视频的链接地址 `开启可能会导致其他bot循环解析`"),
113
+ bVideoShowIntroductionTofixed: Schema.number().default(50).description("视频的`简介`最大的字符长度<br>超出部分会使用 `...` 代替"),
114
+ }).description("链接的图文解析设置"),
115
+
116
+ Schema.object({
117
+ isfigure: Schema.boolean().default(false).description("是否开启合并转发 `仅支持 onebot 适配器` 其他平台开启 无效").experimental(),
118
+ middleware: Schema.boolean().default(false).description("前置中间件模式"),
119
+ userAgent: Schema.string().description("所有 API 请求所用的 User-Agent").default("Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36"),
120
+ }).description("调试设置"),
121
+ ]),
122
+ ]),
83
123
 
84
- Schema.object({
85
- parseLimit: Schema.number().default(3).description("单对话多链接解析上限").hidden(),
86
- useNumeral: Schema.boolean().default(true).description("使用格式化数字").hidden(),
87
- showError: Schema.boolean().default(false).description("当链接不正确时提醒发送者").hidden(),
88
- bVideoIDPreference: Schema.union([
89
- Schema.const("bv").description("BV 号"),
90
- Schema.const("av").description("AV 号"),
91
- ]).default("bv").description("ID 偏好").hidden(),
92
-
93
- bVideo_area: Schema.string().role('textarea', { rows: [8, 16] }).description("图文解析的返回格式<br>注意变量格式,以及变量名称。<br>比如 `${标题}` 不可以变成`${标题123}`,你可以直接删掉但是不能修改变量名称哦<br>当然变量也不能无中生有,下面的默认值内容 就是所有变量了,你仅可以删去变量 或者修改变量之外的格式。<br>· 特殊变量`${~~~}`表示分割线,会把上下内容分为两个信息单独发送。")
94
- .default("${标题} --- ${UP主}\n---\n${封面}\n---\n${简介}\n---\n${点赞} --- ${投币}\n${收藏} --- ${转发}\n${观看} --- ${弹幕}"),
95
- bVideoShowLink: Schema.boolean().default(false).description("在末尾显示视频的链接地址 `开启可能会导致其他bot循环解析`"),
96
- bVideoShowIntroductionTofixed: Schema.number().default(50).description("视频的`简介`最大的字符长度<br>超出部分会使用 `...` 代替"),
97
- }).description("链接的图文解析设置"),
98
-
99
- Schema.object({
100
- isfigure: Schema.boolean().default(false).description("是否开启合并转发 `仅支持 onebot 适配器` 其他平台开启 无效").experimental(),
101
- middleware: Schema.boolean().default(false).description("前置中间件模式"),
102
- userAgent: Schema.string().description("所有 API 请求所用的 User-Agent").default("Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36"),
103
- }).description("调试设置"),
104
124
 
105
125
  Schema.object({
106
126
  pageclose: Schema.boolean().default(true).description("自动`page.close()`<br>非开发者请勿改动").experimental(),
@@ -120,24 +140,26 @@ function apply(ctx, config) {
120
140
  }
121
141
  }
122
142
 
123
- ctx.middleware(async (session, next) => {
124
- let sessioncontent = session.content;
125
- // 如果允许解析 BV 号,则进行解析
126
- if (config.BVnumberParsing) {
127
- const bvUrls = convertBVToUrl(sessioncontent);
128
- if (bvUrls.length > 0) {
129
- sessioncontent += '\n' + bvUrls.join('\n');
143
+ if (config.enablebilianalysis) {
144
+ ctx.middleware(async (session, next) => {
145
+ let sessioncontent = session.content;
146
+ // 如果允许解析 BV 号,则进行解析
147
+ if (config.BVnumberParsing) {
148
+ const bvUrls = convertBVToUrl(sessioncontent);
149
+ if (bvUrls.length > 0) {
150
+ sessioncontent += '\n' + bvUrls.join('\n');
151
+ }
130
152
  }
131
- }
132
- const links = await isProcessLinks(sessioncontent); // 判断是否需要解析
133
- if (links) {
134
- const ret = await extractLinks(session, config, ctx, links); // 提取链接
135
- if (ret && !isLinkProcessedRecently(ret, lastProcessedUrls, config, logger)) {
136
- await processVideoFromLink(session, config, ctx, lastProcessedUrls, logger, ret); // 解析视频并返回
153
+ const links = await isProcessLinks(sessioncontent); // 判断是否需要解析
154
+ if (links) {
155
+ const ret = await extractLinks(session, config, ctx, links); // 提取链接
156
+ if (ret && !isLinkProcessedRecently(ret, lastProcessedUrls, config, logger)) {
157
+ await processVideoFromLink(session, config, ctx, lastProcessedUrls, logger, ret); // 解析视频并返回
158
+ }
137
159
  }
138
- }
139
- return next();
140
- }, config.middleware);
160
+ return next();
161
+ }, config.middleware);
162
+ }
141
163
 
142
164
  if (config.demand) {
143
165
  ctx.command('B站点播/退出登录', '退出B站账号')
@@ -704,12 +726,12 @@ display: none !important;
704
726
  '${UP主}': info["data"]["owner"]["name"],
705
727
  '${封面}': `<img src="${info["data"]["pic"]}"/>`,
706
728
  '${简介}': description, // 使用处理后的简介
707
- '${点赞}': `点赞:${(0, numeral)(info["data"]["stat"]["like"], this.config)}`,
708
- '${投币}': `投币:${(0, numeral)(info["data"]["stat"]["coin"], this.config)}`,
709
- '${收藏}': `收藏:${(0, numeral)(info["data"]["stat"]["favorite"], this.config)}`,
710
- '${转发}': `转发:${(0, numeral)(info["data"]["stat"]["share"], this.config)}`,
711
- '${观看}': `观看:${(0, numeral)(info["data"]["stat"]["view"], this.config)}`,
712
- '${弹幕}': `弹幕:${(0, numeral)(info["data"]["stat"]["danmaku"], this.config)}`,
729
+ '${点赞}': `${(0, numeral)(info["data"]["stat"]["like"], this.config)}`,
730
+ '${投币}': `${(0, numeral)(info["data"]["stat"]["coin"], this.config)}`,
731
+ '${收藏}': `${(0, numeral)(info["data"]["stat"]["favorite"], this.config)}`,
732
+ '${转发}': `${(0, numeral)(info["data"]["stat"]["share"], this.config)}`,
733
+ '${观看}': `${(0, numeral)(info["data"]["stat"]["view"], this.config)}`,
734
+ '${弹幕}': `${(0, numeral)(info["data"]["stat"]["danmaku"], this.config)}`,
713
735
  };
714
736
 
715
737
  // 根据配置项中的格式替换占位符
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.15",
5
+ "version": "1.1.17",
6
6
  "main": "lib/index.js",
7
7
  "typings": "lib/index.d.ts",
8
8
  "files": [