koishi-plugin-bilibili-notify 3.2.9-alpha.3 → 3.2.9-rc.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.
package/lib/index.d.mts CHANGED
@@ -34,6 +34,7 @@ interface BAConfig {
34
34
  pushImgsInDynamic: boolean;
35
35
  live: {};
36
36
  liveDetectType: "WS" | "API";
37
+ wordcloud: boolean;
37
38
  restartPush: boolean;
38
39
  pushTime: number;
39
40
  customLiveStart: string;
package/lib/index.d.ts CHANGED
@@ -34,6 +34,7 @@ interface BAConfig {
34
34
  pushImgsInDynamic: boolean;
35
35
  live: {};
36
36
  liveDetectType: "WS" | "API";
37
+ wordcloud: boolean;
37
38
  restartPush: boolean;
38
39
  pushTime: number;
39
40
  customLiveStart: string;
package/lib/index.js CHANGED
@@ -112,6 +112,7 @@ const BAConfigSchema = koishi.Schema.object({
112
112
  pushImgsInDynamic: koishi.Schema.boolean().default(false).description("是否推送动态中的图片,默认不开启。开启后会单独推送动态中的图片,该功能容易导致QQ风控"),
113
113
  live: koishi.Schema.object({}).description("直播推送设置"),
114
114
  liveDetectType: koishi.Schema.union([koishi.Schema.const("WS").description("使用WebSocket连接到B站消息服务器进行直播检测,推荐使用"), koishi.Schema.const("API").description("通过轮询API发送请求监测直播状态,此模式理论可无限订阅,但容易产生其他问题,功能没有WS模式全面").experimental()]).role("radio").default("WS").description("直播检测方式,WS为连接到B站消息服务器,API为通过轮询发送请求监测,默认使用WS检测"),
115
+ wordcloud: koishi.Schema.boolean().default(false).description("直播结束后,是否生成本场直播弹幕词云"),
115
116
  restartPush: koishi.Schema.boolean().default(true).description("插件重启后,如果订阅的主播正在直播,是否进行一次推送,默认开启"),
116
117
  pushTime: koishi.Schema.number().min(0).max(12).step(.5).default(1).description("设定间隔多长时间推送一次直播状态,单位为小时,默认为一小时"),
117
118
  customLiveStart: koishi.Schema.string().default("-name开播啦,当前粉丝数:-follower\\n-link").description("自定义开播提示语,-name代表UP昵称,-follower代表当前粉丝数,-link代表直播间链接(如果使用的是QQ官方机器人,请不要使用),\\n为换行。例如-name开播啦,会发送为xxxUP开播啦"),
@@ -847,7 +848,147 @@ var ComRegister = class {
847
848
  ["b8n5c", 70],
848
849
  ["v3x7w", 163],
849
850
  ["t6c4a", 49],
850
- ["z9u2j", 146]
851
+ ["z9u2j", 146],
852
+ ["k1q8z", 102],
853
+ ["v7n2a", 31],
854
+ ["b4x9p", 176],
855
+ ["w2m5s", 61],
856
+ ["t8j3u", 150],
857
+ ["z5c7l", 84],
858
+ ["h2r8y", 196],
859
+ ["n9d1q", 44],
860
+ ["p6s3e", 123],
861
+ ["f8g2b", 17],
862
+ ["m1v7k", 109],
863
+ ["x4a9w", 72],
864
+ ["c7t2z", 180],
865
+ ["u5b8n", 38],
866
+ ["e1y3h", 134],
867
+ ["j8l6p", 56],
868
+ ["s2q9d", 191],
869
+ ["g7m4x", 25],
870
+ ["a5w8c", 113],
871
+ ["l9h2v", 68],
872
+ ["y1k7t", 159],
873
+ ["d8z3u", 45],
874
+ ["q2e6j", 177],
875
+ ["r7p1s", 80],
876
+ ["b5n9f", 126],
877
+ ["v1x4m", 32],
878
+ ["t7c8w", 198],
879
+ ["z4u2h", 54],
880
+ ["h9y5j", 143],
881
+ ["n2l7s", 19],
882
+ ["p8d1g", 104],
883
+ ["f5b3a", 67],
884
+ ["m2v9x", 171],
885
+ ["x8a4c", 40],
886
+ ["c1t7u", 187],
887
+ ["u4b2e", 28],
888
+ ["e9y6k", 135],
889
+ ["j2l8q", 60],
890
+ ["s7g1m", 119],
891
+ ["g4w5t", 76],
892
+ ["a9z2h", 164],
893
+ ["l1h7p", 35],
894
+ ["y8k3n", 185],
895
+ ["d2u9f", 22],
896
+ ["q7e4v", 110],
897
+ ["r5p8x", 69],
898
+ ["b1n6c", 152],
899
+ ["v8x2w", 48],
900
+ ["t4c7a", 142],
901
+ ["z7u1j", 99],
902
+ ["k2q5z", 174],
903
+ ["v9n8a", 37],
904
+ ["b6x3p", 189],
905
+ ["w1m7s", 24],
906
+ ["t5j2u", 115],
907
+ ["z1c8l", 63],
908
+ ["h6r4y", 155],
909
+ ["n3d9q", 50],
910
+ ["p7s2e", 137],
911
+ ["f9g1b", 81],
912
+ ["m4v6k", 170],
913
+ ["x1a8w", 42],
914
+ ["c8t3z", 194],
915
+ ["u2b7n", 26],
916
+ ["e5y9h", 130],
917
+ ["j9l1p", 58],
918
+ ["s4q6d", 182],
919
+ ["g1m8x", 33],
920
+ ["a8w5c", 108],
921
+ ["l3h9v", 75],
922
+ ["y2k4t", 161],
923
+ ["d9z1u", 46],
924
+ ["q5e8j", 149],
925
+ ["r2p7s", 20],
926
+ ["b9n3f", 122],
927
+ ["v4x6m", 65],
928
+ ["t1c9w", 179],
929
+ ["z8u5h", 30],
930
+ ["h3y2j", 136],
931
+ ["n5l8s", 52],
932
+ ["p1d4g", 167],
933
+ ["f6b9a", 95],
934
+ ["m3v2x", 156],
935
+ ["x9a5c", 43],
936
+ ["c2t8u", 192],
937
+ ["u7b1e", 16],
938
+ ["e4y6k", 129],
939
+ ["j5l3q", 78],
940
+ ["s1g9m", 118],
941
+ ["g8w2t", 71],
942
+ ["a3z7h", 173],
943
+ ["l6h1p", 36],
944
+ ["y9k5n", 184],
945
+ ["d1u8f", 15],
946
+ ["q8e3v", 111],
947
+ ["r4p6x", 64],
948
+ ["b2n7c", 151],
949
+ ["v5x1w", 47],
950
+ ["t8c4a", 140],
951
+ ["z3u9j", 98],
952
+ ["k7q2z", 176],
953
+ ["v1n5a", 55],
954
+ ["b8x6p", 195],
955
+ ["w3m1s", 14],
956
+ ["t6j9u", 116],
957
+ ["z2c5l", 61],
958
+ ["h7r3y", 153],
959
+ ["n4d8q", 51],
960
+ ["p2s7e", 139],
961
+ ["f7g5b", 82],
962
+ ["m9v1k", 169],
963
+ ["x5a3w", 38],
964
+ ["c9t6z", 197],
965
+ ["u3b8n", 17],
966
+ ["e6y2h", 131],
967
+ ["j7l5p", 59],
968
+ ["s3q8d", 181],
969
+ ["g2m4x", 34],
970
+ ["a6w9c", 107],
971
+ ["l8h2v", 74],
972
+ ["y4k7t", 162],
973
+ ["d6z5u", 49],
974
+ ["q3e1j", 148],
975
+ ["r9p2s", 21],
976
+ ["b4n8f", 121],
977
+ ["v7x5m", 68],
978
+ ["t2c1w", 178],
979
+ ["z5u3h", 31],
980
+ ["h8y6j", 133],
981
+ ["n1l4s", 57],
982
+ ["p5d7g", 166],
983
+ ["f3b2a", 96],
984
+ ["m6v8x", 158],
985
+ ["x2a9c", 45],
986
+ ["c5t1u", 191],
987
+ ["u8b4e", 19],
988
+ ["e3y7k", 128],
989
+ ["j6l2q", 79],
990
+ ["s9g5m", 114],
991
+ ["g5w3t", 73]
851
992
  ];
852
993
  await session.send(/* @__PURE__ */ (0, __satorijs_element_jsx_runtime.jsx)("message", { children: koishi.h.image(await this.ctx.gi.generateWordCloudImg(words, "词云测试"), "image/jpg") }));
853
994
  });
@@ -1294,8 +1435,14 @@ var ComRegister = class {
1294
1435
  let watchedNum;
1295
1436
  const liveMsgObj = this.liveMsgManager.get(uid);
1296
1437
  const sendDanmakuWordCloud = async () => {
1297
- const top50Words = Object.entries(danmakuWeightRecord).sort((a$1, b$2) => b$2[1] - a$1[1]).slice(0, 50);
1298
- const buffer = await this.ctx.gi.generateWordCloudImg(top50Words, masterInfo.username);
1438
+ this.logger.info("开始制作弹幕词云");
1439
+ this.logger.info("正在获取前150热词");
1440
+ const top150Words = Object.entries(danmakuWeightRecord).sort((a$1, b$2) => b$2[1] - a$1[1]).slice(0, 150);
1441
+ this.logger.info("弹幕词云前150词及权重:");
1442
+ this.logger.info(top150Words);
1443
+ this.logger.info("正在准备生成弹幕词云");
1444
+ const buffer = await this.ctx.gi.generateWordCloudImg(top150Words, masterInfo.username);
1445
+ this.logger.info("弹幕词云生成完成,正在准备发送词云图片");
1299
1446
  await this.broadcastToTargets(uid, koishi.h.image(buffer, "image/jpeg"), PushType.Live);
1300
1447
  };
1301
1448
  const pushAtTimeFunc = async () => {
@@ -1379,7 +1526,7 @@ var ComRegister = class {
1379
1526
  masterInfo,
1380
1527
  cardStyle
1381
1528
  }, uid, liveStartMsg);
1382
- if (!pushAtTimeTimer) pushAtTimeTimer = this.ctx.setInterval(pushAtTimeFunc, this.config.pushTime * 1e3 * 60 * 60);
1529
+ if (this.config.pushTime !== 0 && !pushAtTimeTimer) pushAtTimeTimer = this.ctx.setInterval(pushAtTimeFunc, this.config.pushTime * 1e3 * 60 * 60);
1383
1530
  },
1384
1531
  onLiveEnd: async () => {
1385
1532
  liveStatus = false;
@@ -1401,10 +1548,7 @@ var ComRegister = class {
1401
1548
  }, uid, liveEndMsg);
1402
1549
  pushAtTimeTimer();
1403
1550
  pushAtTimeTimer = null;
1404
- const words = Object.entries(danmakuWeightRecord);
1405
- const buffer = await this.ctx.gi.generateWordCloudImg(words, masterInfo.username);
1406
- await this.broadcastToTargets(uid, koishi.h.image(buffer, "image/jpeg"), PushType.Live);
1407
- await sendDanmakuWordCloud();
1551
+ if (this.config.wordcloud) await sendDanmakuWordCloud();
1408
1552
  }
1409
1553
  };
1410
1554
  await this.ctx.bl.startLiveRoomListener(roomId, handler);
@@ -1418,7 +1562,7 @@ var ComRegister = class {
1418
1562
  masterInfo,
1419
1563
  cardStyle
1420
1564
  }, uid, liveMsg);
1421
- if (!pushAtTimeTimer) pushAtTimeTimer = this.ctx.setInterval(pushAtTimeFunc, this.config.pushTime * 1e3 * 60 * 60);
1565
+ if (this.config.pushTime !== 0 && !pushAtTimeTimer) pushAtTimeTimer = this.ctx.setInterval(pushAtTimeFunc, this.config.pushTime * 1e3 * 60 * 60);
1422
1566
  liveStatus = true;
1423
1567
  }
1424
1568
  }
@@ -1824,6 +1968,7 @@ var ComRegister = class {
1824
1968
  masterAccountGuildId: koishi.Schema.string()
1825
1969
  }),
1826
1970
  liveDetectType: koishi.Schema.string(),
1971
+ wordcloud: koishi.Schema.boolean(),
1827
1972
  restartPush: koishi.Schema.boolean().required(),
1828
1973
  pushTime: koishi.Schema.number().required(),
1829
1974
  pushImgsInDynamic: koishi.Schema.boolean().required(),
@@ -50298,9 +50443,9 @@ var require_websocket_server = __commonJS$1({ "node_modules/ws/lib/websocket-ser
50298
50443
  abortHandshakeOrEmitwsClientError(this, req$1, socket, 400, message$1);
50299
50444
  return;
50300
50445
  }
50301
- if (version !== 8 && version !== 13) {
50446
+ if (version !== 13 && version !== 8) {
50302
50447
  const message$1 = "Missing or invalid Sec-WebSocket-Version header";
50303
- abortHandshakeOrEmitwsClientError(this, req$1, socket, 400, message$1);
50448
+ abortHandshakeOrEmitwsClientError(this, req$1, socket, 400, message$1, { "Sec-WebSocket-Version": "13, 8" });
50304
50449
  return;
50305
50450
  }
50306
50451
  if (!this.shouldHandle(req$1)) {
@@ -50469,14 +50614,15 @@ var require_websocket_server = __commonJS$1({ "node_modules/ws/lib/websocket-ser
50469
50614
  * @param {Duplex} socket The socket of the upgrade request
50470
50615
  * @param {Number} code The HTTP response status code
50471
50616
  * @param {String} message The HTTP response body
50617
+ * @param {Object} [headers] The HTTP response headers
50472
50618
  * @private
50473
50619
  */
50474
- function abortHandshakeOrEmitwsClientError(server, req$1, socket, code, message$1) {
50620
+ function abortHandshakeOrEmitwsClientError(server, req$1, socket, code, message$1, headers$2) {
50475
50621
  if (server.listenerCount("wsClientError")) {
50476
50622
  const err = new Error(message$1);
50477
50623
  Error.captureStackTrace(err, abortHandshakeOrEmitwsClientError);
50478
50624
  server.emit("wsClientError", err, socket, req$1);
50479
- } else abortHandshake(socket, code, message$1);
50625
+ } else abortHandshake(socket, code, message$1, headers$2);
50480
50626
  }
50481
50627
  } });
50482
50628
 
@@ -94482,19 +94628,19 @@ var GenerateImg = class extends koishi.Service {
94482
94628
  const minWeight = Math.min(...words.map(w => w[1]));
94483
94629
 
94484
94630
  // 设置最大字体大小、最小字体大小(以像素为单位)
94485
- const maxFontSize = 60;
94631
+ const maxFontSize = 80;
94486
94632
  const minFontSize = 14;
94487
94633
 
94488
94634
  // 用映射函数代替 weightFactor
94489
94635
  function getWeightFactor(size) {
94490
94636
  if (maxWeight === minWeight) return maxFontSize; // 防止除0
94491
94637
  const ratio = (size - minWeight) / (maxWeight - minWeight);
94492
- return minFontSize + (maxFontSize - minFontSize) * ratio;
94638
+ return minFontSize + (maxFontSize - minFontSize) * Math.pow(ratio, 0.85);
94493
94639
  }
94494
94640
 
94495
94641
  WordCloud(canvas, {
94496
94642
  list: words,
94497
- gridSize: Math.round(8 * (cssWidth / 1024)), // 自动适配大小
94643
+ gridSize: Math.max(4, Math.round(5 * (cssWidth / 1024))),
94498
94644
  weightFactor: getWeightFactor,
94499
94645
  fontFamily: 'Quicksand, sans-serif',
94500
94646
  color: () => {
@@ -95411,6 +95557,7 @@ var ServerManager = class extends koishi.Service {
95411
95557
  const cr = this.ctx.plugin(comRegister_default, {
95412
95558
  sub: globalConfig.sub,
95413
95559
  master: globalConfig.master,
95560
+ wordcloud: globalConfig.wordcloud,
95414
95561
  liveDetectType: globalConfig.liveDetectType,
95415
95562
  restartPush: globalConfig.restartPush,
95416
95563
  pushTime: globalConfig.pushTime,
package/lib/index.mjs CHANGED
@@ -114,6 +114,7 @@ const BAConfigSchema = Schema.object({
114
114
  pushImgsInDynamic: Schema.boolean().default(false).description("是否推送动态中的图片,默认不开启。开启后会单独推送动态中的图片,该功能容易导致QQ风控"),
115
115
  live: Schema.object({}).description("直播推送设置"),
116
116
  liveDetectType: Schema.union([Schema.const("WS").description("使用WebSocket连接到B站消息服务器进行直播检测,推荐使用"), Schema.const("API").description("通过轮询API发送请求监测直播状态,此模式理论可无限订阅,但容易产生其他问题,功能没有WS模式全面").experimental()]).role("radio").default("WS").description("直播检测方式,WS为连接到B站消息服务器,API为通过轮询发送请求监测,默认使用WS检测"),
117
+ wordcloud: Schema.boolean().default(false).description("直播结束后,是否生成本场直播弹幕词云"),
117
118
  restartPush: Schema.boolean().default(true).description("插件重启后,如果订阅的主播正在直播,是否进行一次推送,默认开启"),
118
119
  pushTime: Schema.number().min(0).max(12).step(.5).default(1).description("设定间隔多长时间推送一次直播状态,单位为小时,默认为一小时"),
119
120
  customLiveStart: Schema.string().default("-name开播啦,当前粉丝数:-follower\\n-link").description("自定义开播提示语,-name代表UP昵称,-follower代表当前粉丝数,-link代表直播间链接(如果使用的是QQ官方机器人,请不要使用),\\n为换行。例如-name开播啦,会发送为xxxUP开播啦"),
@@ -849,7 +850,147 @@ var ComRegister = class {
849
850
  ["b8n5c", 70],
850
851
  ["v3x7w", 163],
851
852
  ["t6c4a", 49],
852
- ["z9u2j", 146]
853
+ ["z9u2j", 146],
854
+ ["k1q8z", 102],
855
+ ["v7n2a", 31],
856
+ ["b4x9p", 176],
857
+ ["w2m5s", 61],
858
+ ["t8j3u", 150],
859
+ ["z5c7l", 84],
860
+ ["h2r8y", 196],
861
+ ["n9d1q", 44],
862
+ ["p6s3e", 123],
863
+ ["f8g2b", 17],
864
+ ["m1v7k", 109],
865
+ ["x4a9w", 72],
866
+ ["c7t2z", 180],
867
+ ["u5b8n", 38],
868
+ ["e1y3h", 134],
869
+ ["j8l6p", 56],
870
+ ["s2q9d", 191],
871
+ ["g7m4x", 25],
872
+ ["a5w8c", 113],
873
+ ["l9h2v", 68],
874
+ ["y1k7t", 159],
875
+ ["d8z3u", 45],
876
+ ["q2e6j", 177],
877
+ ["r7p1s", 80],
878
+ ["b5n9f", 126],
879
+ ["v1x4m", 32],
880
+ ["t7c8w", 198],
881
+ ["z4u2h", 54],
882
+ ["h9y5j", 143],
883
+ ["n2l7s", 19],
884
+ ["p8d1g", 104],
885
+ ["f5b3a", 67],
886
+ ["m2v9x", 171],
887
+ ["x8a4c", 40],
888
+ ["c1t7u", 187],
889
+ ["u4b2e", 28],
890
+ ["e9y6k", 135],
891
+ ["j2l8q", 60],
892
+ ["s7g1m", 119],
893
+ ["g4w5t", 76],
894
+ ["a9z2h", 164],
895
+ ["l1h7p", 35],
896
+ ["y8k3n", 185],
897
+ ["d2u9f", 22],
898
+ ["q7e4v", 110],
899
+ ["r5p8x", 69],
900
+ ["b1n6c", 152],
901
+ ["v8x2w", 48],
902
+ ["t4c7a", 142],
903
+ ["z7u1j", 99],
904
+ ["k2q5z", 174],
905
+ ["v9n8a", 37],
906
+ ["b6x3p", 189],
907
+ ["w1m7s", 24],
908
+ ["t5j2u", 115],
909
+ ["z1c8l", 63],
910
+ ["h6r4y", 155],
911
+ ["n3d9q", 50],
912
+ ["p7s2e", 137],
913
+ ["f9g1b", 81],
914
+ ["m4v6k", 170],
915
+ ["x1a8w", 42],
916
+ ["c8t3z", 194],
917
+ ["u2b7n", 26],
918
+ ["e5y9h", 130],
919
+ ["j9l1p", 58],
920
+ ["s4q6d", 182],
921
+ ["g1m8x", 33],
922
+ ["a8w5c", 108],
923
+ ["l3h9v", 75],
924
+ ["y2k4t", 161],
925
+ ["d9z1u", 46],
926
+ ["q5e8j", 149],
927
+ ["r2p7s", 20],
928
+ ["b9n3f", 122],
929
+ ["v4x6m", 65],
930
+ ["t1c9w", 179],
931
+ ["z8u5h", 30],
932
+ ["h3y2j", 136],
933
+ ["n5l8s", 52],
934
+ ["p1d4g", 167],
935
+ ["f6b9a", 95],
936
+ ["m3v2x", 156],
937
+ ["x9a5c", 43],
938
+ ["c2t8u", 192],
939
+ ["u7b1e", 16],
940
+ ["e4y6k", 129],
941
+ ["j5l3q", 78],
942
+ ["s1g9m", 118],
943
+ ["g8w2t", 71],
944
+ ["a3z7h", 173],
945
+ ["l6h1p", 36],
946
+ ["y9k5n", 184],
947
+ ["d1u8f", 15],
948
+ ["q8e3v", 111],
949
+ ["r4p6x", 64],
950
+ ["b2n7c", 151],
951
+ ["v5x1w", 47],
952
+ ["t8c4a", 140],
953
+ ["z3u9j", 98],
954
+ ["k7q2z", 176],
955
+ ["v1n5a", 55],
956
+ ["b8x6p", 195],
957
+ ["w3m1s", 14],
958
+ ["t6j9u", 116],
959
+ ["z2c5l", 61],
960
+ ["h7r3y", 153],
961
+ ["n4d8q", 51],
962
+ ["p2s7e", 139],
963
+ ["f7g5b", 82],
964
+ ["m9v1k", 169],
965
+ ["x5a3w", 38],
966
+ ["c9t6z", 197],
967
+ ["u3b8n", 17],
968
+ ["e6y2h", 131],
969
+ ["j7l5p", 59],
970
+ ["s3q8d", 181],
971
+ ["g2m4x", 34],
972
+ ["a6w9c", 107],
973
+ ["l8h2v", 74],
974
+ ["y4k7t", 162],
975
+ ["d6z5u", 49],
976
+ ["q3e1j", 148],
977
+ ["r9p2s", 21],
978
+ ["b4n8f", 121],
979
+ ["v7x5m", 68],
980
+ ["t2c1w", 178],
981
+ ["z5u3h", 31],
982
+ ["h8y6j", 133],
983
+ ["n1l4s", 57],
984
+ ["p5d7g", 166],
985
+ ["f3b2a", 96],
986
+ ["m6v8x", 158],
987
+ ["x2a9c", 45],
988
+ ["c5t1u", 191],
989
+ ["u8b4e", 19],
990
+ ["e3y7k", 128],
991
+ ["j6l2q", 79],
992
+ ["s9g5m", 114],
993
+ ["g5w3t", 73]
853
994
  ];
854
995
  await session.send(/* @__PURE__ */ jsx("message", { children: h.image(await this.ctx.gi.generateWordCloudImg(words, "词云测试"), "image/jpg") }));
855
996
  });
@@ -1296,8 +1437,14 @@ var ComRegister = class {
1296
1437
  let watchedNum;
1297
1438
  const liveMsgObj = this.liveMsgManager.get(uid);
1298
1439
  const sendDanmakuWordCloud = async () => {
1299
- const top50Words = Object.entries(danmakuWeightRecord).sort((a$1, b$2) => b$2[1] - a$1[1]).slice(0, 50);
1300
- const buffer = await this.ctx.gi.generateWordCloudImg(top50Words, masterInfo.username);
1440
+ this.logger.info("开始制作弹幕词云");
1441
+ this.logger.info("正在获取前150热词");
1442
+ const top150Words = Object.entries(danmakuWeightRecord).sort((a$1, b$2) => b$2[1] - a$1[1]).slice(0, 150);
1443
+ this.logger.info("弹幕词云前150词及权重:");
1444
+ this.logger.info(top150Words);
1445
+ this.logger.info("正在准备生成弹幕词云");
1446
+ const buffer = await this.ctx.gi.generateWordCloudImg(top150Words, masterInfo.username);
1447
+ this.logger.info("弹幕词云生成完成,正在准备发送词云图片");
1301
1448
  await this.broadcastToTargets(uid, h.image(buffer, "image/jpeg"), PushType.Live);
1302
1449
  };
1303
1450
  const pushAtTimeFunc = async () => {
@@ -1381,7 +1528,7 @@ var ComRegister = class {
1381
1528
  masterInfo,
1382
1529
  cardStyle
1383
1530
  }, uid, liveStartMsg);
1384
- if (!pushAtTimeTimer) pushAtTimeTimer = this.ctx.setInterval(pushAtTimeFunc, this.config.pushTime * 1e3 * 60 * 60);
1531
+ if (this.config.pushTime !== 0 && !pushAtTimeTimer) pushAtTimeTimer = this.ctx.setInterval(pushAtTimeFunc, this.config.pushTime * 1e3 * 60 * 60);
1385
1532
  },
1386
1533
  onLiveEnd: async () => {
1387
1534
  liveStatus = false;
@@ -1403,10 +1550,7 @@ var ComRegister = class {
1403
1550
  }, uid, liveEndMsg);
1404
1551
  pushAtTimeTimer();
1405
1552
  pushAtTimeTimer = null;
1406
- const words = Object.entries(danmakuWeightRecord);
1407
- const buffer = await this.ctx.gi.generateWordCloudImg(words, masterInfo.username);
1408
- await this.broadcastToTargets(uid, h.image(buffer, "image/jpeg"), PushType.Live);
1409
- await sendDanmakuWordCloud();
1553
+ if (this.config.wordcloud) await sendDanmakuWordCloud();
1410
1554
  }
1411
1555
  };
1412
1556
  await this.ctx.bl.startLiveRoomListener(roomId, handler);
@@ -1420,7 +1564,7 @@ var ComRegister = class {
1420
1564
  masterInfo,
1421
1565
  cardStyle
1422
1566
  }, uid, liveMsg);
1423
- if (!pushAtTimeTimer) pushAtTimeTimer = this.ctx.setInterval(pushAtTimeFunc, this.config.pushTime * 1e3 * 60 * 60);
1567
+ if (this.config.pushTime !== 0 && !pushAtTimeTimer) pushAtTimeTimer = this.ctx.setInterval(pushAtTimeFunc, this.config.pushTime * 1e3 * 60 * 60);
1424
1568
  liveStatus = true;
1425
1569
  }
1426
1570
  }
@@ -1826,6 +1970,7 @@ var ComRegister = class {
1826
1970
  masterAccountGuildId: Schema.string()
1827
1971
  }),
1828
1972
  liveDetectType: Schema.string(),
1973
+ wordcloud: Schema.boolean(),
1829
1974
  restartPush: Schema.boolean().required(),
1830
1975
  pushTime: Schema.number().required(),
1831
1976
  pushImgsInDynamic: Schema.boolean().required(),
@@ -50300,9 +50445,9 @@ var require_websocket_server = __commonJS$1({ "node_modules/ws/lib/websocket-ser
50300
50445
  abortHandshakeOrEmitwsClientError(this, req$1, socket, 400, message$1);
50301
50446
  return;
50302
50447
  }
50303
- if (version !== 8 && version !== 13) {
50448
+ if (version !== 13 && version !== 8) {
50304
50449
  const message$1 = "Missing or invalid Sec-WebSocket-Version header";
50305
- abortHandshakeOrEmitwsClientError(this, req$1, socket, 400, message$1);
50450
+ abortHandshakeOrEmitwsClientError(this, req$1, socket, 400, message$1, { "Sec-WebSocket-Version": "13, 8" });
50306
50451
  return;
50307
50452
  }
50308
50453
  if (!this.shouldHandle(req$1)) {
@@ -50471,14 +50616,15 @@ var require_websocket_server = __commonJS$1({ "node_modules/ws/lib/websocket-ser
50471
50616
  * @param {Duplex} socket The socket of the upgrade request
50472
50617
  * @param {Number} code The HTTP response status code
50473
50618
  * @param {String} message The HTTP response body
50619
+ * @param {Object} [headers] The HTTP response headers
50474
50620
  * @private
50475
50621
  */
50476
- function abortHandshakeOrEmitwsClientError(server, req$1, socket, code, message$1) {
50622
+ function abortHandshakeOrEmitwsClientError(server, req$1, socket, code, message$1, headers$2) {
50477
50623
  if (server.listenerCount("wsClientError")) {
50478
50624
  const err = new Error(message$1);
50479
50625
  Error.captureStackTrace(err, abortHandshakeOrEmitwsClientError);
50480
50626
  server.emit("wsClientError", err, socket, req$1);
50481
- } else abortHandshake(socket, code, message$1);
50627
+ } else abortHandshake(socket, code, message$1, headers$2);
50482
50628
  }
50483
50629
  } });
50484
50630
 
@@ -94484,19 +94630,19 @@ var GenerateImg = class extends Service {
94484
94630
  const minWeight = Math.min(...words.map(w => w[1]));
94485
94631
 
94486
94632
  // 设置最大字体大小、最小字体大小(以像素为单位)
94487
- const maxFontSize = 60;
94633
+ const maxFontSize = 80;
94488
94634
  const minFontSize = 14;
94489
94635
 
94490
94636
  // 用映射函数代替 weightFactor
94491
94637
  function getWeightFactor(size) {
94492
94638
  if (maxWeight === minWeight) return maxFontSize; // 防止除0
94493
94639
  const ratio = (size - minWeight) / (maxWeight - minWeight);
94494
- return minFontSize + (maxFontSize - minFontSize) * ratio;
94640
+ return minFontSize + (maxFontSize - minFontSize) * Math.pow(ratio, 0.85);
94495
94641
  }
94496
94642
 
94497
94643
  WordCloud(canvas, {
94498
94644
  list: words,
94499
- gridSize: Math.round(8 * (cssWidth / 1024)), // 自动适配大小
94645
+ gridSize: Math.max(4, Math.round(5 * (cssWidth / 1024))),
94500
94646
  weightFactor: getWeightFactor,
94501
94647
  fontFamily: 'Quicksand, sans-serif',
94502
94648
  color: () => {
@@ -95413,6 +95559,7 @@ var ServerManager = class extends Service {
95413
95559
  const cr = this.ctx.plugin(comRegister_default, {
95414
95560
  sub: globalConfig.sub,
95415
95561
  master: globalConfig.master,
95562
+ wordcloud: globalConfig.wordcloud,
95416
95563
  liveDetectType: globalConfig.liveDetectType,
95417
95564
  restartPush: globalConfig.restartPush,
95418
95565
  pushTime: globalConfig.pushTime,
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.9-alpha.3",
4
+ "version": "3.2.9-rc.0",
5
5
  "contributors": [
6
6
  "Akokko <admin@akokko.com>"
7
7
  ],
package/readme.md CHANGED
@@ -304,7 +304,8 @@ uid为必填参数,为要推送的UP主的UID,index为可选参数,为要
304
304
  > - ver 3.2.9-alpha.1 修复:弹幕词云显示问题,弹幕过多导致插件爆炸; 不建议更新,目前仅做测试用!
305
305
  > - ver 3.2.9-alpha.2 修复:`AxiosError: Request failed with status code 404 xxx at async BiliAPI.checkIfTokenNeedRefresh`、潜在cookie相关bug、弹幕词云bug `Error: 生成图片失败!错误: TimeoutError: Navigation timeout of 30000 ms exceeded`
306
306
  > - ver 3.2.9-alpha.3 修复:词云生成空白
307
-
307
+ > - ver 3.2.9-alpha.4 修复:弹幕词云bug `Error: 生成图片失败!错误: TimeoutError: Navigation timeout of 30000 ms exceeded`
308
+ > - ver 3.2.9-rc.0 优化:弹幕词云生成效果、选项 `pushTime` 设置为0时可关闭该功能; 新增:选项 `wordcloud` 可选择在直播结束后是否生成弹幕词云
308
309
 
309
310
  ## 交流群
310
311