koishi-plugin-bilibili-notify 3.3.11-alpha.3 → 3.3.11
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 -9
- package/lib/index.mjs +23 -9
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -710,6 +710,7 @@ var ComRegister = class {
|
|
|
710
710
|
for (const uname of Object.keys(subs)) subs[uname].uname = uname;
|
|
711
711
|
}
|
|
712
712
|
async initAsyncPart(subs) {
|
|
713
|
+
this.ctx["bilibili-notify-live"].clearListeners();
|
|
713
714
|
this.logger.info("获取到订阅信息,开始加载订阅...");
|
|
714
715
|
const groupInfoResult = await this.getGroupInfo();
|
|
715
716
|
if (groupInfoResult.code !== 0) {
|
|
@@ -1237,10 +1238,7 @@ var ComRegister = class {
|
|
|
1237
1238
|
let liveStatus = false;
|
|
1238
1239
|
let liveRoomInfo;
|
|
1239
1240
|
let masterInfo;
|
|
1240
|
-
const liveData = {
|
|
1241
|
-
watchedNum: "0",
|
|
1242
|
-
likedNum: "0"
|
|
1243
|
-
};
|
|
1241
|
+
const liveData = { likedNum: "0" };
|
|
1244
1242
|
const liveMsgObj = this.liveMsgManager.get(sub.uid);
|
|
1245
1243
|
const sendDanmakuWordCloudAndLiveSummary = async (customLiveSummary) => {
|
|
1246
1244
|
this.logger.info("开始制作弹幕词云");
|
|
@@ -1283,8 +1281,9 @@ var ComRegister = class {
|
|
|
1283
1281
|
}
|
|
1284
1282
|
liveTime = liveRoomInfo.live_time;
|
|
1285
1283
|
const watched = liveData.watchedNum || "暂未获取到";
|
|
1284
|
+
liveData.watchedNum = watched;
|
|
1286
1285
|
const liveMsg = liveMsgObj.customLive.replace("-name", masterInfo.username).replace("-time", await this.ctx["bilibili-notify-generate-img"].getTimeDifference(liveTime)).replace("-watched", watched).replaceAll("\\n", "\n").replace("-link", `https://live.bilibili.com/${liveRoomInfo.short_id === 0 ? liveRoomInfo.room_id : liveRoomInfo.short_id}`);
|
|
1287
|
-
await this.sendLiveNotifyCard(LiveType.LiveBroadcast,
|
|
1286
|
+
await this.sendLiveNotifyCard(LiveType.LiveBroadcast, liveData, {
|
|
1288
1287
|
liveRoomInfo,
|
|
1289
1288
|
masterInfo,
|
|
1290
1289
|
cardStyle: sub.customCardStyle
|
|
@@ -1339,7 +1338,9 @@ var ComRegister = class {
|
|
|
1339
1338
|
liveData.watchedNum = body.text_small;
|
|
1340
1339
|
},
|
|
1341
1340
|
onLikedChange: ({ body }) => {
|
|
1341
|
+
console.log(body.count);
|
|
1342
1342
|
liveData.likedNum = body.count.toString();
|
|
1343
|
+
console.log(liveData.likedNum);
|
|
1343
1344
|
},
|
|
1344
1345
|
onGuardBuy: ({ body }) => {
|
|
1345
1346
|
const content = (0, koishi.h)("message", [koishi.h.text(`【${masterInfo.username}的直播间】${body.user.uname}加入了大航海(${body.gift_name})`)]);
|
|
@@ -1366,8 +1367,9 @@ var ComRegister = class {
|
|
|
1366
1367
|
liveTime = liveRoomInfo?.live_time || luxon.DateTime.now().toFormat("yyyy-MM-dd HH:mm:ss");
|
|
1367
1368
|
const diffTime = await this.ctx["bilibili-notify-generate-img"].getTimeDifference(liveTime);
|
|
1368
1369
|
const followerNum = masterInfo.liveOpenFollowerNum >= 1e4 ? `${(masterInfo.liveOpenFollowerNum / 1e4).toFixed(1)}万` : masterInfo.liveOpenFollowerNum.toString();
|
|
1370
|
+
liveData.fansNum = followerNum;
|
|
1369
1371
|
const liveStartMsg = liveMsgObj.customLiveStart.replace("-name", masterInfo.username).replace("-time", diffTime).replace("-follower", followerNum).replaceAll("\\n", "\n").replace("-link", `https://live.bilibili.com/${liveRoomInfo.short_id === 0 ? liveRoomInfo.room_id : liveRoomInfo.short_id}`);
|
|
1370
|
-
await this.sendLiveNotifyCard(LiveType.StartBroadcasting,
|
|
1372
|
+
await this.sendLiveNotifyCard(LiveType.StartBroadcasting, liveData, {
|
|
1371
1373
|
liveRoomInfo,
|
|
1372
1374
|
masterInfo,
|
|
1373
1375
|
cardStyle: sub.customCardStyle
|
|
@@ -1402,8 +1404,9 @@ var ComRegister = class {
|
|
|
1402
1404
|
if (liveFollowerChangeNum > 0) return liveFollowerChangeNum >= 1e4 ? `+${(liveFollowerChangeNum / 1e4).toFixed(1)}万` : `+${liveFollowerChangeNum}`;
|
|
1403
1405
|
return liveFollowerChangeNum <= -1e4 ? `${(liveFollowerChangeNum / 1e4).toFixed(1)}万` : liveFollowerChangeNum.toString();
|
|
1404
1406
|
})();
|
|
1407
|
+
liveData.fansChanged = followerChange;
|
|
1405
1408
|
const liveEndMsg = liveMsgObj.customLiveEnd.replace("-name", masterInfo.username).replace("-time", diffTime).replace("-follower_change", followerChange).replaceAll("\\n", "\n");
|
|
1406
|
-
await this.sendLiveNotifyCard(LiveType.StopBroadcast,
|
|
1409
|
+
await this.sendLiveNotifyCard(LiveType.StopBroadcast, liveData, {
|
|
1407
1410
|
liveRoomInfo,
|
|
1408
1411
|
masterInfo,
|
|
1409
1412
|
cardStyle: sub.customCardStyle
|
|
@@ -1422,8 +1425,9 @@ var ComRegister = class {
|
|
|
1422
1425
|
if (liveRoomInfo.live_status === 1) {
|
|
1423
1426
|
liveTime = liveRoomInfo.live_time;
|
|
1424
1427
|
const watched = liveData.watchedNum || "暂未获取到";
|
|
1428
|
+
liveData.watchedNum = watched;
|
|
1425
1429
|
const liveMsg = liveMsgObj.customLive.replace("-name", masterInfo.username).replace("-time", await this.ctx["bilibili-notify-generate-img"].getTimeDifference(liveTime)).replace("-watched", watched).replaceAll("\\n", "\n").replace("-link", `https://live.bilibili.com/${liveRoomInfo.short_id === 0 ? liveRoomInfo.room_id : liveRoomInfo.short_id}`);
|
|
1426
|
-
if (this.config.restartPush) this.sendLiveNotifyCard(LiveType.LiveBroadcast,
|
|
1430
|
+
if (this.config.restartPush) this.sendLiveNotifyCard(LiveType.LiveBroadcast, liveData, {
|
|
1427
1431
|
liveRoomInfo,
|
|
1428
1432
|
masterInfo,
|
|
1429
1433
|
cardStyle: sub.customCardStyle
|
|
@@ -4161,9 +4165,13 @@ var BLive = class extends koishi.Service {
|
|
|
4161
4165
|
super(ctx, "bilibili-notify-live");
|
|
4162
4166
|
}
|
|
4163
4167
|
stop() {
|
|
4164
|
-
|
|
4168
|
+
this.clearListeners();
|
|
4165
4169
|
}
|
|
4166
4170
|
async startLiveRoomListener(roomId, handler) {
|
|
4171
|
+
if (this.listenerRecord[roomId]) {
|
|
4172
|
+
this.logger.warn(`[${roomId}]直播间连接已存在,无法重复创建!`);
|
|
4173
|
+
return;
|
|
4174
|
+
}
|
|
4167
4175
|
const cookiesStr = await this.ctx["bilibili-notify-api"].getCookiesForHeader();
|
|
4168
4176
|
const mySelfInfo = await this.ctx["bilibili-notify-api"].getMyselfInfo();
|
|
4169
4177
|
this.listenerRecord[roomId] = (0, blive_message_listener.startListen)(Number.parseInt(roomId), handler, { ws: {
|
|
@@ -4182,6 +4190,12 @@ var BLive = class extends koishi.Service {
|
|
|
4182
4190
|
}
|
|
4183
4191
|
this.logger.warn(`${roomId}直播间连接未成功关闭`);
|
|
4184
4192
|
}
|
|
4193
|
+
clearListeners() {
|
|
4194
|
+
for (const key of Object.keys(this.listenerRecord)) {
|
|
4195
|
+
this.closeListener(key);
|
|
4196
|
+
delete this.listenerRecord[key];
|
|
4197
|
+
}
|
|
4198
|
+
}
|
|
4185
4199
|
};
|
|
4186
4200
|
var bili_live_default = BLive;
|
|
4187
4201
|
|
package/lib/index.mjs
CHANGED
|
@@ -692,6 +692,7 @@ var ComRegister = class {
|
|
|
692
692
|
for (const uname of Object.keys(subs)) subs[uname].uname = uname;
|
|
693
693
|
}
|
|
694
694
|
async initAsyncPart(subs) {
|
|
695
|
+
this.ctx["bilibili-notify-live"].clearListeners();
|
|
695
696
|
this.logger.info("获取到订阅信息,开始加载订阅...");
|
|
696
697
|
const groupInfoResult = await this.getGroupInfo();
|
|
697
698
|
if (groupInfoResult.code !== 0) {
|
|
@@ -1219,10 +1220,7 @@ var ComRegister = class {
|
|
|
1219
1220
|
let liveStatus = false;
|
|
1220
1221
|
let liveRoomInfo;
|
|
1221
1222
|
let masterInfo;
|
|
1222
|
-
const liveData = {
|
|
1223
|
-
watchedNum: "0",
|
|
1224
|
-
likedNum: "0"
|
|
1225
|
-
};
|
|
1223
|
+
const liveData = { likedNum: "0" };
|
|
1226
1224
|
const liveMsgObj = this.liveMsgManager.get(sub.uid);
|
|
1227
1225
|
const sendDanmakuWordCloudAndLiveSummary = async (customLiveSummary) => {
|
|
1228
1226
|
this.logger.info("开始制作弹幕词云");
|
|
@@ -1265,8 +1263,9 @@ var ComRegister = class {
|
|
|
1265
1263
|
}
|
|
1266
1264
|
liveTime = liveRoomInfo.live_time;
|
|
1267
1265
|
const watched = liveData.watchedNum || "暂未获取到";
|
|
1266
|
+
liveData.watchedNum = watched;
|
|
1268
1267
|
const liveMsg = liveMsgObj.customLive.replace("-name", masterInfo.username).replace("-time", await this.ctx["bilibili-notify-generate-img"].getTimeDifference(liveTime)).replace("-watched", watched).replaceAll("\\n", "\n").replace("-link", `https://live.bilibili.com/${liveRoomInfo.short_id === 0 ? liveRoomInfo.room_id : liveRoomInfo.short_id}`);
|
|
1269
|
-
await this.sendLiveNotifyCard(LiveType.LiveBroadcast,
|
|
1268
|
+
await this.sendLiveNotifyCard(LiveType.LiveBroadcast, liveData, {
|
|
1270
1269
|
liveRoomInfo,
|
|
1271
1270
|
masterInfo,
|
|
1272
1271
|
cardStyle: sub.customCardStyle
|
|
@@ -1321,7 +1320,9 @@ var ComRegister = class {
|
|
|
1321
1320
|
liveData.watchedNum = body.text_small;
|
|
1322
1321
|
},
|
|
1323
1322
|
onLikedChange: ({ body }) => {
|
|
1323
|
+
console.log(body.count);
|
|
1324
1324
|
liveData.likedNum = body.count.toString();
|
|
1325
|
+
console.log(liveData.likedNum);
|
|
1325
1326
|
},
|
|
1326
1327
|
onGuardBuy: ({ body }) => {
|
|
1327
1328
|
const content = h("message", [h.text(`【${masterInfo.username}的直播间】${body.user.uname}加入了大航海(${body.gift_name})`)]);
|
|
@@ -1348,8 +1349,9 @@ var ComRegister = class {
|
|
|
1348
1349
|
liveTime = liveRoomInfo?.live_time || DateTime.now().toFormat("yyyy-MM-dd HH:mm:ss");
|
|
1349
1350
|
const diffTime = await this.ctx["bilibili-notify-generate-img"].getTimeDifference(liveTime);
|
|
1350
1351
|
const followerNum = masterInfo.liveOpenFollowerNum >= 1e4 ? `${(masterInfo.liveOpenFollowerNum / 1e4).toFixed(1)}万` : masterInfo.liveOpenFollowerNum.toString();
|
|
1352
|
+
liveData.fansNum = followerNum;
|
|
1351
1353
|
const liveStartMsg = liveMsgObj.customLiveStart.replace("-name", masterInfo.username).replace("-time", diffTime).replace("-follower", followerNum).replaceAll("\\n", "\n").replace("-link", `https://live.bilibili.com/${liveRoomInfo.short_id === 0 ? liveRoomInfo.room_id : liveRoomInfo.short_id}`);
|
|
1352
|
-
await this.sendLiveNotifyCard(LiveType.StartBroadcasting,
|
|
1354
|
+
await this.sendLiveNotifyCard(LiveType.StartBroadcasting, liveData, {
|
|
1353
1355
|
liveRoomInfo,
|
|
1354
1356
|
masterInfo,
|
|
1355
1357
|
cardStyle: sub.customCardStyle
|
|
@@ -1384,8 +1386,9 @@ var ComRegister = class {
|
|
|
1384
1386
|
if (liveFollowerChangeNum > 0) return liveFollowerChangeNum >= 1e4 ? `+${(liveFollowerChangeNum / 1e4).toFixed(1)}万` : `+${liveFollowerChangeNum}`;
|
|
1385
1387
|
return liveFollowerChangeNum <= -1e4 ? `${(liveFollowerChangeNum / 1e4).toFixed(1)}万` : liveFollowerChangeNum.toString();
|
|
1386
1388
|
})();
|
|
1389
|
+
liveData.fansChanged = followerChange;
|
|
1387
1390
|
const liveEndMsg = liveMsgObj.customLiveEnd.replace("-name", masterInfo.username).replace("-time", diffTime).replace("-follower_change", followerChange).replaceAll("\\n", "\n");
|
|
1388
|
-
await this.sendLiveNotifyCard(LiveType.StopBroadcast,
|
|
1391
|
+
await this.sendLiveNotifyCard(LiveType.StopBroadcast, liveData, {
|
|
1389
1392
|
liveRoomInfo,
|
|
1390
1393
|
masterInfo,
|
|
1391
1394
|
cardStyle: sub.customCardStyle
|
|
@@ -1404,8 +1407,9 @@ var ComRegister = class {
|
|
|
1404
1407
|
if (liveRoomInfo.live_status === 1) {
|
|
1405
1408
|
liveTime = liveRoomInfo.live_time;
|
|
1406
1409
|
const watched = liveData.watchedNum || "暂未获取到";
|
|
1410
|
+
liveData.watchedNum = watched;
|
|
1407
1411
|
const liveMsg = liveMsgObj.customLive.replace("-name", masterInfo.username).replace("-time", await this.ctx["bilibili-notify-generate-img"].getTimeDifference(liveTime)).replace("-watched", watched).replaceAll("\\n", "\n").replace("-link", `https://live.bilibili.com/${liveRoomInfo.short_id === 0 ? liveRoomInfo.room_id : liveRoomInfo.short_id}`);
|
|
1408
|
-
if (this.config.restartPush) this.sendLiveNotifyCard(LiveType.LiveBroadcast,
|
|
1412
|
+
if (this.config.restartPush) this.sendLiveNotifyCard(LiveType.LiveBroadcast, liveData, {
|
|
1409
1413
|
liveRoomInfo,
|
|
1410
1414
|
masterInfo,
|
|
1411
1415
|
cardStyle: sub.customCardStyle
|
|
@@ -4143,9 +4147,13 @@ var BLive = class extends Service {
|
|
|
4143
4147
|
super(ctx, "bilibili-notify-live");
|
|
4144
4148
|
}
|
|
4145
4149
|
stop() {
|
|
4146
|
-
|
|
4150
|
+
this.clearListeners();
|
|
4147
4151
|
}
|
|
4148
4152
|
async startLiveRoomListener(roomId, handler) {
|
|
4153
|
+
if (this.listenerRecord[roomId]) {
|
|
4154
|
+
this.logger.warn(`[${roomId}]直播间连接已存在,无法重复创建!`);
|
|
4155
|
+
return;
|
|
4156
|
+
}
|
|
4149
4157
|
const cookiesStr = await this.ctx["bilibili-notify-api"].getCookiesForHeader();
|
|
4150
4158
|
const mySelfInfo = await this.ctx["bilibili-notify-api"].getMyselfInfo();
|
|
4151
4159
|
this.listenerRecord[roomId] = startListen(Number.parseInt(roomId), handler, { ws: {
|
|
@@ -4164,6 +4172,12 @@ var BLive = class extends Service {
|
|
|
4164
4172
|
}
|
|
4165
4173
|
this.logger.warn(`${roomId}直播间连接未成功关闭`);
|
|
4166
4174
|
}
|
|
4175
|
+
clearListeners() {
|
|
4176
|
+
for (const key of Object.keys(this.listenerRecord)) {
|
|
4177
|
+
this.closeListener(key);
|
|
4178
|
+
delete this.listenerRecord[key];
|
|
4179
|
+
}
|
|
4180
|
+
}
|
|
4167
4181
|
};
|
|
4168
4182
|
var bili_live_default = BLive;
|
|
4169
4183
|
|