koishi-plugin-bilibili-notify 3.0.0-beta.0 → 3.0.0-beta.1

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.
@@ -76,6 +76,7 @@ declare namespace ComRegister {
76
76
  liveDetectMode: "API" | "WS";
77
77
  restartPush: boolean;
78
78
  pushTime: number;
79
+ pushImgsInDynamic: boolean;
79
80
  liveLoopTime: number;
80
81
  customLiveStart: string;
81
82
  customLive: string;
@@ -604,12 +604,14 @@ class ComRegister {
604
604
  }
605
605
  if (e.message === "已屏蔽转发动态") {
606
606
  if (this.config.filter.notify) {
607
- await this.sendMsg(sub.target, `${upName}发布了一条转发动态,已屏蔽`);
607
+ await this.sendMsg(sub.target, `${upName}转发了一条动态,已屏蔽`);
608
608
  }
609
609
  return;
610
610
  }
611
611
  // 未知错误
612
612
  this.logger.error(`dynamicDetect generateDynamicImg() 推送卡片发送失败,原因:${e.message}`);
613
+ // 发送私聊消息并重启服务
614
+ await this.sendPrivateMsgAndStopService();
613
615
  });
614
616
  // 判断是否执行成功,未执行成功直接返回
615
617
  if (!buffer)
@@ -622,6 +624,19 @@ class ComRegister {
622
624
  this.logger.info("推送动态中...");
623
625
  // 发送推送卡片
624
626
  await this.sendMsg(sub.target, (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [koishi_1.h.image(buffer, "image/png"), dUrl] }));
627
+ // 判断是否需要发送动态中的图片
628
+ if (this.config.pushImgsInDynamic) {
629
+ // 判断是否为图文动态,且存在draw
630
+ if (items[num].type === "DYNAMIC_TYPE_DRAW" &&
631
+ items[num].modules.module_dynamic.major?.draw) {
632
+ for (const img of items[num].modules.module_dynamic.major.draw
633
+ .items) {
634
+ await this.sendMsg(sub.target, (0, jsx_runtime_1.jsx)("img", { src: img.src, alt: "\u52A8\u6001\u56FE\u7247" }));
635
+ }
636
+ }
637
+ }
638
+ // logger
639
+ this.logger.info("动态推送完毕!");
625
640
  }
626
641
  }
627
642
  }
@@ -783,18 +798,38 @@ class ComRegister {
783
798
  }
784
799
  // 未知错误
785
800
  this.logger.error(`dynamicDetect generateDynamicImg() 推送卡片发送失败,原因:${e.message}`);
801
+ // 发送私聊消息并重启服务
802
+ await this.sendPrivateMsgAndStopService();
786
803
  });
787
- // 发送私聊消息并重启服务
804
+ // 屏蔽动态直接返回
788
805
  if (!buffer)
789
- return await this.sendPrivateMsgAndStopService();
806
+ return;
790
807
  // 判断是否需要发送URL
791
808
  const dUrl = this.config.dynamicUrl
792
809
  ? `${upName}发布了一条动态:https://t.bilibili.com/${dynamicId}`
793
810
  : "";
794
- // 如果pic存在,则直接返回pic
811
+ // logger
795
812
  this.logger.info("推送动态中...");
796
- // pic不存在,说明使用的是page模式
813
+ // 推送动态卡片
797
814
  await this.sendMsg(sub.target, (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [koishi_1.h.image(buffer, "image/png"), dUrl] }));
815
+ // 判断是否需要发送动态中的图片
816
+ if (this.config.pushImgsInDynamic) {
817
+ // 判断是否为图文动态,且存在draw
818
+ if (items[num].type === "DYNAMIC_TYPE_DRAW" &&
819
+ items[num].modules.module_dynamic.major?.draw) {
820
+ // logger
821
+ this.logger.info("推送动态图片中...");
822
+ // 循环遍历图片
823
+ for (const img of items[num].modules.module_dynamic.major.draw
824
+ .items) {
825
+ await this.sendMsg(sub.target, (0, jsx_runtime_1.jsx)("img", { src: img.src, alt: "\u52A8\u6001\u56FE\u7247" }));
826
+ }
827
+ // logger
828
+ this.logger.info("推送动态图片完毕!");
829
+ }
830
+ }
831
+ // logger
832
+ this.logger.info("动态推送完毕!");
798
833
  }
799
834
  }
800
835
  }
@@ -971,7 +1006,7 @@ class ComRegister {
971
1006
  },
972
1007
  onGuardBuy: ({ body }) => {
973
1008
  // 定义消息
974
- const content = `${body.user.uname}加入了大航海(${body.gift_name})`;
1009
+ const content = `[${masterInfo.username}的直播间]「${body.user.uname}」加入了大航海(${body.gift_name})`;
975
1010
  // 直接发送消息
976
1011
  channelIdArrLen > 0 && this.sendMsg(liveGuardBuyPushTargetArr, content);
977
1012
  },
@@ -1356,6 +1391,7 @@ class ComRegister {
1356
1391
  ]).required(),
1357
1392
  restartPush: koishi_1.Schema.boolean().required(),
1358
1393
  pushTime: koishi_1.Schema.number().required(),
1394
+ pushImgsInDynamic: koishi_1.Schema.boolean().required(),
1359
1395
  liveLoopTime: koishi_1.Schema.number().default(10),
1360
1396
  customLiveStart: koishi_1.Schema.string().required(),
1361
1397
  customLive: koishi_1.Schema.string(),
package/lib/index.d.ts CHANGED
@@ -50,6 +50,7 @@ export interface Config {
50
50
  dynamic: {};
51
51
  dynamicUrl: boolean;
52
52
  dynamicLoopTime: "1分钟" | "2分钟" | "3分钟" | "5分钟" | "10分钟" | "20分钟";
53
+ pushImgsInDynamic: boolean;
53
54
  live: {};
54
55
  liveDetectMode: "API" | "WS";
55
56
  restartPush: boolean;
package/lib/index.js CHANGED
@@ -145,6 +145,7 @@ class ServerManager extends koishi_1.Service {
145
145
  liveDetectMode: globalConfig.liveDetectMode,
146
146
  restartPush: globalConfig.restartPush,
147
147
  pushTime: globalConfig.pushTime,
148
+ pushImgsInDynamic: globalConfig.pushImgsInDynamic,
148
149
  customLiveStart: globalConfig.customLiveStart,
149
150
  customLive: globalConfig.customLive,
150
151
  customLiveEnd: globalConfig.customLiveEnd,
@@ -320,6 +321,9 @@ exports.Config = koishi_1.Schema.object({
320
321
  .role("")
321
322
  .default("2分钟")
322
323
  .description("设定多久检测一次动态。若需动态的时效性,可以设置为1分钟。若订阅的UP主经常在短时间内连着发多条动态应该将该值提高,否则会出现动态漏推送和晚推送的问题,默认值为2分钟"),
324
+ pushImgsInDynamic: koishi_1.Schema.boolean()
325
+ .default(false)
326
+ .description("是否推送动态中的图片,默认不开启。开启后会单独推送动态中的图片"),
323
327
  live: koishi_1.Schema.object({}).description("直播推送设置"),
324
328
  liveDetectMode: koishi_1.Schema.union([
325
329
  koishi_1.Schema.const("WS").description("WebSocket模式:连接到对应的直播间,可推送弹幕消息,开播下播响应最快,但对订阅数有限制"),
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.0.0-beta.0",
4
+ "version": "3.0.0-beta.1",
5
5
  "contributors": [
6
6
  "Akokko <admin@akokko.com>"
7
7
  ],
package/readme.md CHANGED
@@ -210,6 +210,7 @@
210
210
  - ver 3.0.0-alpha.24 新增:配置项,`cardBasePlateColor` 和 `cardBasePlateBorder`,分别设置卡片底板颜色和底板边框宽度; 优化:部分代码结构
211
211
  - ver 3.0.0-alpha.25 修复:输入指令 `bili ll` 时报错 `TypeError: Cannot read properties of null (reading 'items')`,当某个订阅只订阅动态时无法成功订阅且后续订阅都无法加载; 优化:部分代码结构
212
212
  - ver 3.0.0-beta.0 移除:配置项 `renderType`,推送卡片渲染模式 `render`,现默认为 `page` 渲染模式; 优化:部分代码结构
213
+ - ver 3.0.0-beta.1 修复:使用动态屏蔽时,同时开启动态debug模式,当检测到屏蔽动态时会直接报错关闭插件; 新增:配置项 `pushImgsInDynamic` 是否推送动态中的图片,默认不开启。开启后会单独推送动态中的图片,上舰信息直播间提示
213
214
 
214
215
  ## 交流群
215
216