koishi-plugin-bilibili-notify 3.3.11-alpha.0 → 3.3.11-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 +22 -16
- package/lib/index.mjs +22 -16
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -693,10 +693,16 @@ var ComRegister$1 = class {
|
|
|
693
693
|
return;
|
|
694
694
|
}
|
|
695
695
|
if (this.reciveSubTimes >= 1) await this.ctx["bilibili-notify"].restartPlugin();
|
|
696
|
-
else
|
|
696
|
+
else {
|
|
697
|
+
this.processUname(subs);
|
|
698
|
+
await this.initAsyncPart(subs);
|
|
699
|
+
}
|
|
697
700
|
this.reciveSubTimes++;
|
|
698
701
|
});
|
|
699
702
|
}
|
|
703
|
+
processUname(subs) {
|
|
704
|
+
for (const uname of Object.keys(subs)) subs[uname].uname = uname;
|
|
705
|
+
}
|
|
700
706
|
async initAsyncPart(subs) {
|
|
701
707
|
this.logger.info("获取到订阅信息,开始加载订阅...");
|
|
702
708
|
const groupInfoResult = await this.getGroupInfo();
|
|
@@ -1223,7 +1229,7 @@ var ComRegister$1 = class {
|
|
|
1223
1229
|
const danmakuWeightRecord = {};
|
|
1224
1230
|
const danmakuMakerRecord = {};
|
|
1225
1231
|
let liveStatus = false;
|
|
1226
|
-
|
|
1232
|
+
let liveRoomInfo;
|
|
1227
1233
|
let masterInfo;
|
|
1228
1234
|
let watchedNum;
|
|
1229
1235
|
const liveMsgObj = this.liveMsgManager.get(sub.uid);
|
|
@@ -1285,24 +1291,18 @@ var ComRegister$1 = class {
|
|
|
1285
1291
|
};
|
|
1286
1292
|
const useLiveRoomInfo = async (liveType) => {
|
|
1287
1293
|
let flag = true;
|
|
1288
|
-
const
|
|
1294
|
+
const data = await this.getLiveRoomInfo(sub.roomid).catch(() => {
|
|
1289
1295
|
flag = false;
|
|
1290
|
-
return null;
|
|
1291
1296
|
});
|
|
1292
|
-
if (!flag || !
|
|
1297
|
+
if (!flag || !data || !data.uid) {
|
|
1293
1298
|
flag = false;
|
|
1294
1299
|
return flag;
|
|
1295
1300
|
}
|
|
1296
|
-
|
|
1297
|
-
liveRoomInfo
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
liveRoomInfo.online_max = 0;
|
|
1302
|
-
}
|
|
1303
|
-
liveRoomInfo.live_status = liveRoomInfoData.live_status;
|
|
1304
|
-
liveRoomInfo.online = liveRoomInfoData.online;
|
|
1305
|
-
if (liveRoomInfo.online > liveRoomInfo.online_max) liveRoomInfo.online_max = liveRoomInfo.online;
|
|
1301
|
+
liveRoomInfo = {
|
|
1302
|
+
...liveRoomInfo,
|
|
1303
|
+
...data
|
|
1304
|
+
};
|
|
1305
|
+
if (liveType === LiveType.StartBroadcasting || liveType === LiveType.FirstLiveBroadcast) liveRoomInfo.online_max = 0;
|
|
1306
1306
|
};
|
|
1307
1307
|
const LIVE_EVENT_COOLDOWN = 10 * 1e3;
|
|
1308
1308
|
let lastLiveStart = 0;
|
|
@@ -1329,6 +1329,9 @@ var ComRegister$1 = class {
|
|
|
1329
1329
|
onWatchedChange: ({ body }) => {
|
|
1330
1330
|
watchedNum = body.text_small;
|
|
1331
1331
|
},
|
|
1332
|
+
onAttentionChange: ({ body }) => {
|
|
1333
|
+
if (liveRoomInfo?.online_max && liveRoomInfo.online_max < body.attention) liveRoomInfo.online_max = body.attention;
|
|
1334
|
+
},
|
|
1332
1335
|
onGuardBuy: ({ body }) => {
|
|
1333
1336
|
const content = (0, koishi.h)("message", [koishi.h.text(`【${masterInfo.username}的直播间】${body.user.uname}加入了大航海(${body.gift_name})`)]);
|
|
1334
1337
|
this.broadcastToTargets(sub.uid, content, PushType.LiveGuardBuy);
|
|
@@ -1899,6 +1902,9 @@ var GenerateImg$1 = class extends koishi.Service {
|
|
|
1899
1902
|
super(ctx, "bilibili-notify-generate-img");
|
|
1900
1903
|
this.giConfig = config;
|
|
1901
1904
|
}
|
|
1905
|
+
numberToStr(num) {
|
|
1906
|
+
return num > 1e4 ? `${(num / 1e4).toFixed(1)}万` : num.toString();
|
|
1907
|
+
}
|
|
1902
1908
|
async imgHandler(html) {
|
|
1903
1909
|
const htmlPath = `file://${__dirname.replaceAll("\\", "/")}/page/0.html`;
|
|
1904
1910
|
const page = await this.ctx.puppeteer.page();
|
|
@@ -2049,7 +2055,7 @@ var GenerateImg$1 = class extends koishi.Service {
|
|
|
2049
2055
|
</div>
|
|
2050
2056
|
${this.giConfig.hideDesc ? "" : `<p class="card-text">${data.description ? data.description : "这个主播很懒,什么简介都没写"}</p>`}
|
|
2051
2057
|
<p class="card-link">
|
|
2052
|
-
<span>${liveStatus === 3 ?
|
|
2058
|
+
<span>${liveStatus === 3 ? `本场直播最高人气:${this.numberToStr(data.online_max)}` : `人气:${this.numberToStr(data.online)}`}</span>
|
|
2053
2059
|
<span>分区名称:${data.area_name}</span>
|
|
2054
2060
|
</p>
|
|
2055
2061
|
<p class="card-link">
|
package/lib/index.mjs
CHANGED
|
@@ -675,10 +675,16 @@ var ComRegister$1 = class {
|
|
|
675
675
|
return;
|
|
676
676
|
}
|
|
677
677
|
if (this.reciveSubTimes >= 1) await this.ctx["bilibili-notify"].restartPlugin();
|
|
678
|
-
else
|
|
678
|
+
else {
|
|
679
|
+
this.processUname(subs);
|
|
680
|
+
await this.initAsyncPart(subs);
|
|
681
|
+
}
|
|
679
682
|
this.reciveSubTimes++;
|
|
680
683
|
});
|
|
681
684
|
}
|
|
685
|
+
processUname(subs) {
|
|
686
|
+
for (const uname of Object.keys(subs)) subs[uname].uname = uname;
|
|
687
|
+
}
|
|
682
688
|
async initAsyncPart(subs) {
|
|
683
689
|
this.logger.info("获取到订阅信息,开始加载订阅...");
|
|
684
690
|
const groupInfoResult = await this.getGroupInfo();
|
|
@@ -1205,7 +1211,7 @@ var ComRegister$1 = class {
|
|
|
1205
1211
|
const danmakuWeightRecord = {};
|
|
1206
1212
|
const danmakuMakerRecord = {};
|
|
1207
1213
|
let liveStatus = false;
|
|
1208
|
-
|
|
1214
|
+
let liveRoomInfo;
|
|
1209
1215
|
let masterInfo;
|
|
1210
1216
|
let watchedNum;
|
|
1211
1217
|
const liveMsgObj = this.liveMsgManager.get(sub.uid);
|
|
@@ -1267,24 +1273,18 @@ var ComRegister$1 = class {
|
|
|
1267
1273
|
};
|
|
1268
1274
|
const useLiveRoomInfo = async (liveType) => {
|
|
1269
1275
|
let flag = true;
|
|
1270
|
-
const
|
|
1276
|
+
const data = await this.getLiveRoomInfo(sub.roomid).catch(() => {
|
|
1271
1277
|
flag = false;
|
|
1272
|
-
return null;
|
|
1273
1278
|
});
|
|
1274
|
-
if (!flag || !
|
|
1279
|
+
if (!flag || !data || !data.uid) {
|
|
1275
1280
|
flag = false;
|
|
1276
1281
|
return flag;
|
|
1277
1282
|
}
|
|
1278
|
-
|
|
1279
|
-
liveRoomInfo
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
liveRoomInfo.online_max = 0;
|
|
1284
|
-
}
|
|
1285
|
-
liveRoomInfo.live_status = liveRoomInfoData.live_status;
|
|
1286
|
-
liveRoomInfo.online = liveRoomInfoData.online;
|
|
1287
|
-
if (liveRoomInfo.online > liveRoomInfo.online_max) liveRoomInfo.online_max = liveRoomInfo.online;
|
|
1283
|
+
liveRoomInfo = {
|
|
1284
|
+
...liveRoomInfo,
|
|
1285
|
+
...data
|
|
1286
|
+
};
|
|
1287
|
+
if (liveType === LiveType.StartBroadcasting || liveType === LiveType.FirstLiveBroadcast) liveRoomInfo.online_max = 0;
|
|
1288
1288
|
};
|
|
1289
1289
|
const LIVE_EVENT_COOLDOWN = 10 * 1e3;
|
|
1290
1290
|
let lastLiveStart = 0;
|
|
@@ -1311,6 +1311,9 @@ var ComRegister$1 = class {
|
|
|
1311
1311
|
onWatchedChange: ({ body }) => {
|
|
1312
1312
|
watchedNum = body.text_small;
|
|
1313
1313
|
},
|
|
1314
|
+
onAttentionChange: ({ body }) => {
|
|
1315
|
+
if (liveRoomInfo?.online_max && liveRoomInfo.online_max < body.attention) liveRoomInfo.online_max = body.attention;
|
|
1316
|
+
},
|
|
1314
1317
|
onGuardBuy: ({ body }) => {
|
|
1315
1318
|
const content = h("message", [h.text(`【${masterInfo.username}的直播间】${body.user.uname}加入了大航海(${body.gift_name})`)]);
|
|
1316
1319
|
this.broadcastToTargets(sub.uid, content, PushType.LiveGuardBuy);
|
|
@@ -1881,6 +1884,9 @@ var GenerateImg$1 = class extends Service {
|
|
|
1881
1884
|
super(ctx, "bilibili-notify-generate-img");
|
|
1882
1885
|
this.giConfig = config;
|
|
1883
1886
|
}
|
|
1887
|
+
numberToStr(num) {
|
|
1888
|
+
return num > 1e4 ? `${(num / 1e4).toFixed(1)}万` : num.toString();
|
|
1889
|
+
}
|
|
1884
1890
|
async imgHandler(html) {
|
|
1885
1891
|
const htmlPath = `file://${__dirname.replaceAll("\\", "/")}/page/0.html`;
|
|
1886
1892
|
const page = await this.ctx.puppeteer.page();
|
|
@@ -2031,7 +2037,7 @@ var GenerateImg$1 = class extends Service {
|
|
|
2031
2037
|
</div>
|
|
2032
2038
|
${this.giConfig.hideDesc ? "" : `<p class="card-text">${data.description ? data.description : "这个主播很懒,什么简介都没写"}</p>`}
|
|
2033
2039
|
<p class="card-link">
|
|
2034
|
-
<span>${liveStatus === 3 ?
|
|
2040
|
+
<span>${liveStatus === 3 ? `本场直播最高人气:${this.numberToStr(data.online_max)}` : `人气:${this.numberToStr(data.online)}`}</span>
|
|
2035
2041
|
<span>分区名称:${data.area_name}</span>
|
|
2036
2042
|
</p>
|
|
2037
2043
|
<p class="card-link">
|