koishi-plugin-bilibili-notify 3.3.11 → 3.3.12-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.
- package/lib/index.js +23 -19
- package/lib/index.mjs +23 -19
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -1245,25 +1245,29 @@ var ComRegister = class {
|
|
|
1245
1245
|
this.logger.info("正在获取前90热词");
|
|
1246
1246
|
const words = Object.entries(danmakuWeightRecord);
|
|
1247
1247
|
const danmaker = Object.entries(danmakuMakerRecord);
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
const
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1248
|
+
const img = await (async () => {
|
|
1249
|
+
if (words.length < 50) {
|
|
1250
|
+
this.logger.info("热词不足50个,本次弹幕词云放弃");
|
|
1251
|
+
return;
|
|
1252
|
+
}
|
|
1253
|
+
const top90Words = words.sort((a, b) => b[1] - a[1]).slice(0, 90);
|
|
1254
|
+
this.logger.info("弹幕词云前90词及权重:");
|
|
1255
|
+
this.logger.info(top90Words);
|
|
1256
|
+
this.logger.info("正在准备生成弹幕词云");
|
|
1257
|
+
const buffer = await this.ctx["bilibili-notify-generate-img"].generateWordCloudImg(top90Words, masterInfo.username);
|
|
1258
|
+
return koishi.h.image(buffer, "image/jpeg");
|
|
1259
|
+
})();
|
|
1260
|
+
const summary = (() => {
|
|
1261
|
+
if (danmaker.length < 5) {
|
|
1262
|
+
this.logger.info("发言人数不足5位,本次弹幕词云放弃");
|
|
1263
|
+
return;
|
|
1264
|
+
}
|
|
1265
|
+
this.logger.info("开始构建弹幕发送排行榜消息");
|
|
1266
|
+
const danmakuMakerCount = Object.keys(danmakuMakerRecord).length;
|
|
1267
|
+
const danmakuCount = Object.values(danmakuMakerRecord).reduce((sum, val) => sum + val, 0);
|
|
1268
|
+
const top5DanmakuMaker = Object.entries(danmakuMakerRecord).sort((a, b) => b[1] - a[1]).slice(0, 5);
|
|
1269
|
+
return customLiveSummary.replace("-dmc", `${danmakuMakerCount}`).replace("-mdn", `${masterInfo.medalName}`).replace("-dca", `${danmakuCount}`).replace("-un1", `${top5DanmakuMaker[0][0]}`).replace("-dc1", `${top5DanmakuMaker[0][1]}`).replace("-un2", `${top5DanmakuMaker[1][0]}`).replace("-dc2", `${top5DanmakuMaker[1][1]}`).replace("-un3", `${top5DanmakuMaker[2][0]}`).replace("-dc3", `${top5DanmakuMaker[2][1]}`).replace("-un4", `${top5DanmakuMaker[3][0]}`).replace("-dc4", `${top5DanmakuMaker[3][1]}`).replace("-un5", `${top5DanmakuMaker[4][0]}`).replace("-dc5", `${top5DanmakuMaker[4][1]}`).replaceAll("\\n", "\n");
|
|
1270
|
+
})();
|
|
1267
1271
|
await this.broadcastToTargets(sub.uid, [img, summary], PushType.WordCloudAndLiveSummary);
|
|
1268
1272
|
Object.keys(danmakuWeightRecord).forEach((key) => delete danmakuWeightRecord[key]);
|
|
1269
1273
|
Object.keys(danmakuMakerRecord).forEach((key) => delete danmakuMakerRecord[key]);
|
package/lib/index.mjs
CHANGED
|
@@ -1227,25 +1227,29 @@ var ComRegister = class {
|
|
|
1227
1227
|
this.logger.info("正在获取前90热词");
|
|
1228
1228
|
const words = Object.entries(danmakuWeightRecord);
|
|
1229
1229
|
const danmaker = Object.entries(danmakuMakerRecord);
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
const
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1230
|
+
const img = await (async () => {
|
|
1231
|
+
if (words.length < 50) {
|
|
1232
|
+
this.logger.info("热词不足50个,本次弹幕词云放弃");
|
|
1233
|
+
return;
|
|
1234
|
+
}
|
|
1235
|
+
const top90Words = words.sort((a, b) => b[1] - a[1]).slice(0, 90);
|
|
1236
|
+
this.logger.info("弹幕词云前90词及权重:");
|
|
1237
|
+
this.logger.info(top90Words);
|
|
1238
|
+
this.logger.info("正在准备生成弹幕词云");
|
|
1239
|
+
const buffer = await this.ctx["bilibili-notify-generate-img"].generateWordCloudImg(top90Words, masterInfo.username);
|
|
1240
|
+
return h.image(buffer, "image/jpeg");
|
|
1241
|
+
})();
|
|
1242
|
+
const summary = (() => {
|
|
1243
|
+
if (danmaker.length < 5) {
|
|
1244
|
+
this.logger.info("发言人数不足5位,本次弹幕词云放弃");
|
|
1245
|
+
return;
|
|
1246
|
+
}
|
|
1247
|
+
this.logger.info("开始构建弹幕发送排行榜消息");
|
|
1248
|
+
const danmakuMakerCount = Object.keys(danmakuMakerRecord).length;
|
|
1249
|
+
const danmakuCount = Object.values(danmakuMakerRecord).reduce((sum, val) => sum + val, 0);
|
|
1250
|
+
const top5DanmakuMaker = Object.entries(danmakuMakerRecord).sort((a, b) => b[1] - a[1]).slice(0, 5);
|
|
1251
|
+
return customLiveSummary.replace("-dmc", `${danmakuMakerCount}`).replace("-mdn", `${masterInfo.medalName}`).replace("-dca", `${danmakuCount}`).replace("-un1", `${top5DanmakuMaker[0][0]}`).replace("-dc1", `${top5DanmakuMaker[0][1]}`).replace("-un2", `${top5DanmakuMaker[1][0]}`).replace("-dc2", `${top5DanmakuMaker[1][1]}`).replace("-un3", `${top5DanmakuMaker[2][0]}`).replace("-dc3", `${top5DanmakuMaker[2][1]}`).replace("-un4", `${top5DanmakuMaker[3][0]}`).replace("-dc4", `${top5DanmakuMaker[3][1]}`).replace("-un5", `${top5DanmakuMaker[4][0]}`).replace("-dc5", `${top5DanmakuMaker[4][1]}`).replaceAll("\\n", "\n");
|
|
1252
|
+
})();
|
|
1249
1253
|
await this.broadcastToTargets(sub.uid, [img, summary], PushType.WordCloudAndLiveSummary);
|
|
1250
1254
|
Object.keys(danmakuWeightRecord).forEach((key) => delete danmakuWeightRecord[key]);
|
|
1251
1255
|
Object.keys(danmakuMakerRecord).forEach((key) => delete danmakuMakerRecord[key]);
|