koishi-plugin-bilibili-notify 3.2.3 → 3.2.4-alpha.0

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.
@@ -92,6 +92,7 @@ declare namespace ComRegister {
92
92
  customLive: string;
93
93
  customLiveEnd: string;
94
94
  dynamicUrl: boolean;
95
+ dynamicVideoUrlToBV: boolean;
95
96
  filter: {
96
97
  enable: boolean;
97
98
  notify: boolean;
@@ -673,7 +673,17 @@ class ComRegister {
673
673
  // 判断是否需要发送URL
674
674
  if (this.config.dynamicUrl) {
675
675
  if (item.type === "DYNAMIC_TYPE_AV") {
676
- dUrl = `${name}发布了新视频:https:${item.modules.module_dynamic.major.archive.jump_url}`;
676
+ // 判断是否开启url to bv
677
+ if (this.config.dynamicVideoUrlToBV) {
678
+ // 截取bv号
679
+ const bv = item.modules.module_dynamic.major.archive.jump_url.match(/BV[0-9A-Za-z]+/);
680
+ // 获取bv号
681
+ dUrl = bv ? bv[0] : "";
682
+ }
683
+ else {
684
+ // 生成视频链接
685
+ dUrl = `${name}发布了新视频:https:${item.modules.module_dynamic.major.archive.jump_url}`;
686
+ }
677
687
  }
678
688
  else {
679
689
  // 生成动态链接
@@ -692,11 +702,10 @@ class ComRegister {
692
702
  const pics = item.modules?.module_dynamic?.major?.opus?.pics;
693
703
  // 判断pics是否存在
694
704
  if (pics) {
695
- for (const pic of pics) {
696
- await this.broadcastToTargets(sub.target, (0, jsx_runtime_1.jsx)("img", { src: pic.url, alt: "\u52A8\u6001\u56FE\u7247" }), type_1.PushType.Dynamic);
697
- // 随机睡眠1-3秒
698
- await this.ctx.sleep(Math.floor(Math.random() * 2000) + 1000);
699
- }
705
+ // 组合消息
706
+ const picsMsg = ((0, jsx_runtime_1.jsx)("message", { forward: true, children: pics.map((pic) => ((0, jsx_runtime_1.jsx)("img", { src: pic.url, alt: "\u52A8\u6001\u56FE\u7247" }, pic.url))) }));
707
+ // 发送消息
708
+ await this.broadcastToTargets(sub.target, picsMsg, type_1.PushType.Dynamic);
700
709
  }
701
710
  }
702
711
  }
@@ -860,7 +869,17 @@ class ComRegister {
860
869
  this.logger.info("需要发送动态链接,开始生成链接...");
861
870
  // 判断动态类型
862
871
  if (item.type === "DYNAMIC_TYPE_AV") {
863
- dUrl = `${name}发布了新视频:https:${item.modules.module_dynamic.major.archive.jump_url}`;
872
+ // 判断是否开启url to bv
873
+ if (this.config.dynamicVideoUrlToBV) {
874
+ // 截取bv号
875
+ const bv = item.modules.module_dynamic.major.archive.jump_url.match(/BV[0-9A-Za-z]+/);
876
+ // 获取bv号
877
+ dUrl = bv ? bv[0] : "";
878
+ }
879
+ else {
880
+ // 生成视频链接
881
+ dUrl = `${name}发布了新视频:https:${item.modules.module_dynamic.major.archive.jump_url}`;
882
+ }
864
883
  }
865
884
  else {
866
885
  // 生成动态链接
@@ -883,11 +902,10 @@ class ComRegister {
883
902
  const pics = item.modules?.module_dynamic?.major?.opus?.pics;
884
903
  // 判断pics是否存在
885
904
  if (pics) {
886
- for (const pic of pics) {
887
- await this.broadcastToTargets(sub.target, (0, jsx_runtime_1.jsx)("img", { src: pic.url, alt: "\u52A8\u6001\u56FE\u7247" }), type_1.PushType.Dynamic);
888
- // 随机睡眠1-3秒
889
- await this.ctx.sleep(Math.floor(Math.random() * 2000) + 1000);
890
- }
905
+ // 组合消息
906
+ const picsMsg = ((0, jsx_runtime_1.jsx)("message", { forward: true, children: pics.map((pic) => ((0, jsx_runtime_1.jsx)("img", { src: pic.url, alt: "\u52A8\u6001\u56FE\u7247" }, pic.url))) }));
907
+ // 发送消息
908
+ await this.broadcastToTargets(sub.target, picsMsg, type_1.PushType.Dynamic);
891
909
  }
892
910
  }
893
911
  // logger
@@ -1858,6 +1876,7 @@ class ComRegister {
1858
1876
  customLive: koishi_1.Schema.string(),
1859
1877
  customLiveEnd: koishi_1.Schema.string().required(),
1860
1878
  dynamicUrl: koishi_1.Schema.boolean().required(),
1879
+ dynamicVideoUrlToBV: koishi_1.Schema.boolean().required(),
1861
1880
  filter: koishi_1.Schema.object({
1862
1881
  enable: koishi_1.Schema.boolean(),
1863
1882
  notify: koishi_1.Schema.boolean(),
package/lib/index.d.ts CHANGED
@@ -42,6 +42,7 @@ export interface Config {
42
42
  }>;
43
43
  dynamic: {};
44
44
  dynamicUrl: boolean;
45
+ dynamicVideoUrlToBV: boolean;
45
46
  pushImgsInDynamic: boolean;
46
47
  live: {};
47
48
  liveDetectType: "WS" | "API";
package/lib/index.js CHANGED
@@ -134,6 +134,7 @@ class ServerManager extends koishi_1.Service {
134
134
  customLive: globalConfig.customLive,
135
135
  customLiveEnd: globalConfig.customLiveEnd,
136
136
  dynamicUrl: globalConfig.dynamicUrl,
137
+ dynamicVideoUrlToBV: globalConfig.dynamicVideoUrlToBV,
137
138
  filter: globalConfig.filter,
138
139
  dynamicDebugMode: globalConfig.dynamicDebugMode,
139
140
  });
@@ -314,6 +315,9 @@ exports.Config = koishi_1.Schema.object({
314
315
  dynamicUrl: koishi_1.Schema.boolean()
315
316
  .default(false)
316
317
  .description("发送动态时是否同时发送链接。注意:如果使用的是QQ官方机器人不能开启此项!"),
318
+ dynamicVideoUrlToBV: koishi_1.Schema.boolean()
319
+ .default(false)
320
+ .description("如果推送的动态是视频动态,且开启了发送链接选项,开启此选项则会将链接转换为BV号以便其他用途"),
317
321
  pushImgsInDynamic: koishi_1.Schema.boolean()
318
322
  .default(false)
319
323
  .description("是否推送动态中的图片,默认不开启。开启后会单独推送动态中的图片,该功能容易导致QQ风控"),
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "koishi-plugin-bilibili-notify",
3
3
  "description": "Koishi bilibili notify plugin",
4
- "version": "3.2.3",
4
+ "version": "3.2.4-alpha.0",
5
5
  "contributors": [
6
6
  "Akokko <admin@akokko.com>"
7
7
  ],
package/readme.md CHANGED
@@ -268,6 +268,7 @@ uid为必填参数,为要推送的UP主的UID,index为可选参数,为要
268
268
  - ver 3.2.1 优化:移除不必要成员变量、创建自动上传npm `github actions`,添加相关开发依赖;
269
269
  - ver 3.2.2 调整:修改 `github actions`;
270
270
  - ver 3.2.3 优化:移除不必要的代码;
271
+ - ver 3.2.4-alpha.0 优化:选项 `pushImagesInDynamic` 发送多图会以转发消息的格式发送; 新增:选项 `dynamicVideoUrlToBV` 开启后将链接转换为bv号以用作特殊用途;
271
272
 
272
273
  ## 交流群
273
274