koishi-plugin-bilibili-notify 3.0.4 → 3.0.5-alpha.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.
@@ -132,7 +132,7 @@ class ComRegister {
132
132
  }, async (err, buffer) => {
133
133
  if (err)
134
134
  return await session.send("二维码生成出错,请重新尝试");
135
- await session.send(koishi_1.h.image(buffer, "image/png"));
135
+ await session.send(koishi_1.h.image(buffer, "image/jpeg"));
136
136
  });
137
137
  // 检查之前是否存在登录定时器
138
138
  if (this.loginTimer)
@@ -253,6 +253,24 @@ class ComRegister {
253
253
  }
254
254
  return table;
255
255
  });
256
+ biliCom
257
+ .subcommand(".dyn <uid:string> [index:number]", "手动推送一条动态信息", {
258
+ hidden: true,
259
+ })
260
+ .usage("手动推送一条动态信息")
261
+ .example("bili dyn 233 1 手动推送UID为233用户空间的第一条动态信息")
262
+ .action(async ({ session }, uid, index) => {
263
+ // 获取index
264
+ const i = (index && index - 1) || 0;
265
+ // 获取动态
266
+ const content = await this.ctx.ba.getUserSpaceDynamic(uid);
267
+ // 获取动态内容
268
+ const item = content.data.items[i];
269
+ // 生成图片
270
+ const buffer = await this.ctx.gi.generateDynamicImg(item);
271
+ // 发送图片
272
+ await session.send(koishi_1.h.image(buffer, "image/jpeg"));
273
+ });
256
274
  }
257
275
  async init(config) {
258
276
  // 设置logger
@@ -509,7 +527,9 @@ class ComRegister {
509
527
  // 设置第一条动态的动态ID
510
528
  dynamicIdStr1st = content.data?.items[0]?.id_str || "0";
511
529
  // 设置时间线
512
- timeline = content.data?.items[0]?.modules.module_author.pub_ts || luxon_1.DateTime.now().toSeconds();
530
+ timeline =
531
+ content.data?.items[0]?.modules.module_author.pub_ts ||
532
+ luxon_1.DateTime.now().toSeconds();
513
533
  // 设置初始化为false
514
534
  detectSetup = false;
515
535
  // logger
@@ -629,7 +649,7 @@ class ComRegister {
629
649
  // logger
630
650
  this.logger.info("推送动态中...");
631
651
  // 发送推送卡片
632
- await this.sendMsg(sub.target, (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [koishi_1.h.image(buffer, "image/png"), dUrl] }));
652
+ await this.sendMsg(sub.target, (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [koishi_1.h.image(buffer, "image/jpeg"), dUrl] }));
633
653
  // 判断是否需要发送动态中的图片
634
654
  if (this.config.pushImgsInDynamic) {
635
655
  // 判断是否为图文动态,且存在draw
@@ -650,7 +670,8 @@ class ComRegister {
650
670
  // 更新本次请求第一条动态的动态ID
651
671
  dynamicIdStr1st = items[0].id_str;
652
672
  // 更新时间线
653
- timeline = items[0].modules.module_author.pub_ts || luxon_1.DateTime.now().toSeconds();
673
+ timeline =
674
+ items[0].modules.module_author.pub_ts || luxon_1.DateTime.now().toSeconds();
654
675
  };
655
676
  // 返回一个闭包函数
656
677
  return (0, utils_1.withLock)(handler);
@@ -695,7 +716,9 @@ class ComRegister {
695
716
  // logger
696
717
  this.logger.info(`获取到第一条动态ID:${dynamicIdStr1st}`);
697
718
  // 设置时间线
698
- timeline = content.data?.items[0]?.modules.module_author.pub_ts || luxon_1.DateTime.now().toSeconds();
719
+ timeline =
720
+ content.data?.items[0]?.modules.module_author.pub_ts ||
721
+ luxon_1.DateTime.now().toSeconds();
699
722
  // logger
700
723
  this.logger.info(`获取到时间线信息:${timeline}`);
701
724
  // 设置初始化为false
@@ -853,7 +876,7 @@ class ComRegister {
853
876
  // logger
854
877
  this.logger.info("推送动态中...");
855
878
  // 发送推送卡片
856
- await this.sendMsg(sub.target, (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [koishi_1.h.image(buffer, "image/png"), dUrl] }));
879
+ await this.sendMsg(sub.target, (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [koishi_1.h.image(buffer, "image/jpeg"), dUrl] }));
857
880
  // logger
858
881
  this.logger.info("动态推送完毕!");
859
882
  // 判断是否需要发送动态中的图片
@@ -882,7 +905,8 @@ class ComRegister {
882
905
  // logger
883
906
  this.logger.info(`更新本次请求第一条动态的动态ID:${dynamicIdStr1st}`);
884
907
  // 更新时间线
885
- timeline = items[0].modules.module_author.pub_ts || luxon_1.DateTime.now().toSeconds();
908
+ timeline =
909
+ items[0].modules.module_author.pub_ts || luxon_1.DateTime.now().toSeconds();
886
910
  // logger
887
911
  this.logger.info(`更新时间线:${timeline}`);
888
912
  };
@@ -971,7 +995,7 @@ class ComRegister {
971
995
  if (!buffer)
972
996
  return await this.sendPrivateMsgAndStopService();
973
997
  // 推送直播信息
974
- const msg = ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [koishi_1.h.image(buffer, "image/png"), liveNotifyMsg || ""] }));
998
+ const msg = ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [koishi_1.h.image(buffer, "image/jpeg"), liveNotifyMsg || ""] }));
975
999
  // 只有在开播时才艾特全体成员
976
1000
  return await this.sendMsg(target, msg, liveType === type_1.LiveType.StartBroadcasting);
977
1001
  };
@@ -15,7 +15,7 @@ declare class GenerateImg extends Service {
15
15
  cardBasePlateColor?: string;
16
16
  cardBasePlateBorder?: string;
17
17
  }): Promise<Buffer<ArrayBufferLike>>;
18
- generateDynamicImg(data: any, { cardColorStart, cardColorEnd, cardBasePlateColor, cardBasePlateBorder, }: {
18
+ generateDynamicImg(data: any, { cardColorStart, cardColorEnd, cardBasePlateColor, cardBasePlateBorder, }?: {
19
19
  cardColorStart?: string;
20
20
  cardColorEnd?: string;
21
21
  cardBasePlateColor?: string;
@@ -37,7 +37,7 @@ class GenerateImg extends koishi_1.Service {
37
37
  const elementHandle = await page.$("html");
38
38
  const boundingBox = await elementHandle.boundingBox();
39
39
  const buffer = await page.screenshot({
40
- type: "png",
40
+ type: "jpeg",
41
41
  clip: {
42
42
  x: boundingBox.x,
43
43
  y: boundingBox.y,
@@ -216,7 +216,7 @@ class GenerateImg extends koishi_1.Service {
216
216
  }
217
217
  async generateDynamicImg(
218
218
  // biome-ignore lint/suspicious/noExplicitAny: <explanation>
219
- data, { cardColorStart = this.giConfig.cardColorStart, cardColorEnd = this.giConfig.cardColorEnd, cardBasePlateColor = this.giConfig.cardBasePlateColor, cardBasePlateBorder = this.giConfig.cardBasePlateBorder, }) {
219
+ data, { cardColorStart = this.giConfig.cardColorStart, cardColorEnd = this.giConfig.cardColorEnd, cardBasePlateColor = this.giConfig.cardBasePlateColor, cardBasePlateBorder = this.giConfig.cardBasePlateBorder, } = {}) {
220
220
  // module_author
221
221
  const module_author = data.modules.module_author;
222
222
  const avatarUrl = module_author.face;
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.4",
4
+ "version": "3.0.5-alpha.1",
5
5
  "contributors": [
6
6
  "Akokko <admin@akokko.com>"
7
7
  ],
@@ -27,6 +27,7 @@
27
27
  "koishi": "^4.18.7"
28
28
  },
29
29
  "dependencies": {
30
+ "@napi-rs/canvas": "^0.1.69",
30
31
  "axios": "^1.7.9",
31
32
  "axios-cookiejar-support": "^5.0.5",
32
33
  "blive-message-listener": "^0.5.0",
package/readme.md CHANGED
@@ -64,6 +64,12 @@
64
64
 
65
65
  - 使用指令 `bili ll`
66
66
 
67
+ 推送指定UP主指定动态:
68
+
69
+ - 使用指令 `bili dyn <uid> [index]`
70
+
71
+ uid为必填参数,为要推送的UP主的UID,index为可选参数,为要推送的动态排序,不应超过15,不填默认第一条。例如要推送UID为 `233` 的UP主的第九条动态 `bili dyn 233 9`
72
+
67
73
  插件的启动、停止和重启
68
74
 
69
75
  - 使用指令 `sys`
@@ -221,6 +227,8 @@
221
227
  - ver 3.0.2 优化:动态监测,新增依赖服务 `cron`
222
228
  - ver 3.0.3 移除:配置项 `dynamicLoopTime` ,动态循环时间将不再可选,默认为两分钟
223
229
  - ver 3.0.4 优化:动态监测,增加时间判断,防止出现重复推送问题; 由于 `3.0.2` 动态监测定时器更换为cron定时任务,如果需要测试动态监测功能是否正常,可以通过控制台日志输出观察,打印 `动态监测初始化完毕!` 后,可进行测试
230
+ - ver 3.0.5-alpha.0 优化:推送卡片渲染,压缩图片; 新增:指令 `bili dyn` 可用于推送指定UP主指定动态
231
+ - ver 3.0.5-alpha.1 优化:推送卡片渲染,调整渲染图片格式为 `jpeg`
224
232
 
225
233
  ## 交流群
226
234