koishi-plugin-bilibili-notify 3.3.8-alpha.2 → 3.3.9
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 +27 -6
- package/lib/index.mjs +27 -6
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -375,6 +375,7 @@ var ComRegister$1 = class {
|
|
|
375
375
|
_jieba = __node_rs_jieba.Jieba.withDict(__node_rs_jieba_dict.dict);
|
|
376
376
|
stopwords;
|
|
377
377
|
reciveSubTimes = 0;
|
|
378
|
+
groupInfo = null;
|
|
378
379
|
constructor(ctx, config) {
|
|
379
380
|
this.ctx = ctx;
|
|
380
381
|
this.init(config);
|
|
@@ -695,6 +696,12 @@ var ComRegister$1 = class {
|
|
|
695
696
|
}
|
|
696
697
|
async initAsyncPart(subs) {
|
|
697
698
|
this.logger.info("获取到订阅信息,开始加载订阅...");
|
|
699
|
+
const groupInfoResult = await this.getGroupInfo();
|
|
700
|
+
if (groupInfoResult.code !== 0) {
|
|
701
|
+
this.logger.error("获取分组信息失败,插件初始化失败!");
|
|
702
|
+
return;
|
|
703
|
+
}
|
|
704
|
+
this.groupInfo = groupInfoResult.data;
|
|
698
705
|
const { code, message } = await this.loadSubFromConfig(subs);
|
|
699
706
|
if (code !== 0) {
|
|
700
707
|
this.logger.error(message);
|
|
@@ -936,7 +943,7 @@ var ComRegister$1 = class {
|
|
|
936
943
|
if (type === PushType.LiveGuardBuy && record.liveGuardBuyArr?.length > 0) {
|
|
937
944
|
this.logger.info("推送直播守护购买:", record.liveGuardBuyArr);
|
|
938
945
|
const liveGuardBuyArr = structuredClone(record.liveGuardBuyArr);
|
|
939
|
-
await withRetry(() => this.pushMessage(liveGuardBuyArr, (0, koishi.h)(
|
|
946
|
+
await withRetry(() => this.pushMessage(liveGuardBuyArr, (0, koishi.h)("message", content)), 1);
|
|
940
947
|
}
|
|
941
948
|
if (type === PushType.WordCloudAndLiveSummary) {
|
|
942
949
|
const wordcloudArr = structuredClone(record.wordcloudArr);
|
|
@@ -1373,7 +1380,7 @@ var ComRegister$1 = class {
|
|
|
1373
1380
|
liveTime = liveRoomInfo.live_time;
|
|
1374
1381
|
const watched = watchedNum || "暂未获取到";
|
|
1375
1382
|
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}`);
|
|
1376
|
-
if (this.config.restartPush)
|
|
1383
|
+
if (this.config.restartPush) this.sendLiveNotifyCard(LiveType.LiveBroadcast, watched, {
|
|
1377
1384
|
liveRoomInfo,
|
|
1378
1385
|
masterInfo,
|
|
1379
1386
|
cardStyle: sub.customCardStyle
|
|
@@ -1540,7 +1547,7 @@ var ComRegister$1 = class {
|
|
|
1540
1547
|
check();
|
|
1541
1548
|
});
|
|
1542
1549
|
}
|
|
1543
|
-
async
|
|
1550
|
+
async getGroupInfo() {
|
|
1544
1551
|
const checkGroupIsReady = async () => {
|
|
1545
1552
|
const allGroupData = await this.ctx["bilibili-notify-api"].getAllGroup();
|
|
1546
1553
|
let existFlag = false;
|
|
@@ -1596,7 +1603,14 @@ var ComRegister$1 = class {
|
|
|
1596
1603
|
code,
|
|
1597
1604
|
message
|
|
1598
1605
|
};
|
|
1599
|
-
|
|
1606
|
+
return {
|
|
1607
|
+
code: 0,
|
|
1608
|
+
message: "获取分组明细成功",
|
|
1609
|
+
data
|
|
1610
|
+
};
|
|
1611
|
+
}
|
|
1612
|
+
async subUserInBili(mid) {
|
|
1613
|
+
for (const user of this.groupInfo) if (user.mid === mid) return {
|
|
1600
1614
|
code: 0,
|
|
1601
1615
|
message: "订阅对象已存在于分组中"
|
|
1602
1616
|
};
|
|
@@ -3839,8 +3853,15 @@ var BiliAPI$1 = class extends koishi.Service {
|
|
|
3839
3853
|
headers: {
|
|
3840
3854
|
"Content-Type": "application/json",
|
|
3841
3855
|
"User-Agent": this.apiConfig.userAgent || "Mozilla/5.0 (X11; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/115.0",
|
|
3842
|
-
Origin: "https://
|
|
3843
|
-
Referer: "https://
|
|
3856
|
+
Origin: "https://space.bilibili.com",
|
|
3857
|
+
Referer: "https://space.bilibili.com/",
|
|
3858
|
+
priority: "u=1, i",
|
|
3859
|
+
"sec-ch-ua": "\"Not;A=Brand\";v=\"99\", \"Google Chrome\";v=\"139\", \"Chromium\";v=\"139\"",
|
|
3860
|
+
"sec-ch-ua-mobile": "?0",
|
|
3861
|
+
"sec-ch-ua-platform": "\"Linux\"",
|
|
3862
|
+
"sec-fetch-dest": "empty",
|
|
3863
|
+
"sec-fetch-mode": "cors",
|
|
3864
|
+
"sec-fetch-site": "same-site"
|
|
3844
3865
|
}
|
|
3845
3866
|
}));
|
|
3846
3867
|
}
|
package/lib/index.mjs
CHANGED
|
@@ -357,6 +357,7 @@ var ComRegister$1 = class {
|
|
|
357
357
|
_jieba = Jieba.withDict(dict);
|
|
358
358
|
stopwords;
|
|
359
359
|
reciveSubTimes = 0;
|
|
360
|
+
groupInfo = null;
|
|
360
361
|
constructor(ctx, config) {
|
|
361
362
|
this.ctx = ctx;
|
|
362
363
|
this.init(config);
|
|
@@ -677,6 +678,12 @@ var ComRegister$1 = class {
|
|
|
677
678
|
}
|
|
678
679
|
async initAsyncPart(subs) {
|
|
679
680
|
this.logger.info("获取到订阅信息,开始加载订阅...");
|
|
681
|
+
const groupInfoResult = await this.getGroupInfo();
|
|
682
|
+
if (groupInfoResult.code !== 0) {
|
|
683
|
+
this.logger.error("获取分组信息失败,插件初始化失败!");
|
|
684
|
+
return;
|
|
685
|
+
}
|
|
686
|
+
this.groupInfo = groupInfoResult.data;
|
|
680
687
|
const { code, message } = await this.loadSubFromConfig(subs);
|
|
681
688
|
if (code !== 0) {
|
|
682
689
|
this.logger.error(message);
|
|
@@ -918,7 +925,7 @@ var ComRegister$1 = class {
|
|
|
918
925
|
if (type === PushType.LiveGuardBuy && record.liveGuardBuyArr?.length > 0) {
|
|
919
926
|
this.logger.info("推送直播守护购买:", record.liveGuardBuyArr);
|
|
920
927
|
const liveGuardBuyArr = structuredClone(record.liveGuardBuyArr);
|
|
921
|
-
await withRetry(() => this.pushMessage(liveGuardBuyArr, h(
|
|
928
|
+
await withRetry(() => this.pushMessage(liveGuardBuyArr, h("message", content)), 1);
|
|
922
929
|
}
|
|
923
930
|
if (type === PushType.WordCloudAndLiveSummary) {
|
|
924
931
|
const wordcloudArr = structuredClone(record.wordcloudArr);
|
|
@@ -1355,7 +1362,7 @@ var ComRegister$1 = class {
|
|
|
1355
1362
|
liveTime = liveRoomInfo.live_time;
|
|
1356
1363
|
const watched = watchedNum || "暂未获取到";
|
|
1357
1364
|
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}`);
|
|
1358
|
-
if (this.config.restartPush)
|
|
1365
|
+
if (this.config.restartPush) this.sendLiveNotifyCard(LiveType.LiveBroadcast, watched, {
|
|
1359
1366
|
liveRoomInfo,
|
|
1360
1367
|
masterInfo,
|
|
1361
1368
|
cardStyle: sub.customCardStyle
|
|
@@ -1522,7 +1529,7 @@ var ComRegister$1 = class {
|
|
|
1522
1529
|
check();
|
|
1523
1530
|
});
|
|
1524
1531
|
}
|
|
1525
|
-
async
|
|
1532
|
+
async getGroupInfo() {
|
|
1526
1533
|
const checkGroupIsReady = async () => {
|
|
1527
1534
|
const allGroupData = await this.ctx["bilibili-notify-api"].getAllGroup();
|
|
1528
1535
|
let existFlag = false;
|
|
@@ -1578,7 +1585,14 @@ var ComRegister$1 = class {
|
|
|
1578
1585
|
code,
|
|
1579
1586
|
message
|
|
1580
1587
|
};
|
|
1581
|
-
|
|
1588
|
+
return {
|
|
1589
|
+
code: 0,
|
|
1590
|
+
message: "获取分组明细成功",
|
|
1591
|
+
data
|
|
1592
|
+
};
|
|
1593
|
+
}
|
|
1594
|
+
async subUserInBili(mid) {
|
|
1595
|
+
for (const user of this.groupInfo) if (user.mid === mid) return {
|
|
1582
1596
|
code: 0,
|
|
1583
1597
|
message: "订阅对象已存在于分组中"
|
|
1584
1598
|
};
|
|
@@ -3821,8 +3835,15 @@ var BiliAPI$1 = class extends Service {
|
|
|
3821
3835
|
headers: {
|
|
3822
3836
|
"Content-Type": "application/json",
|
|
3823
3837
|
"User-Agent": this.apiConfig.userAgent || "Mozilla/5.0 (X11; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/115.0",
|
|
3824
|
-
Origin: "https://
|
|
3825
|
-
Referer: "https://
|
|
3838
|
+
Origin: "https://space.bilibili.com",
|
|
3839
|
+
Referer: "https://space.bilibili.com/",
|
|
3840
|
+
priority: "u=1, i",
|
|
3841
|
+
"sec-ch-ua": "\"Not;A=Brand\";v=\"99\", \"Google Chrome\";v=\"139\", \"Chromium\";v=\"139\"",
|
|
3842
|
+
"sec-ch-ua-mobile": "?0",
|
|
3843
|
+
"sec-ch-ua-platform": "\"Linux\"",
|
|
3844
|
+
"sec-fetch-dest": "empty",
|
|
3845
|
+
"sec-fetch-mode": "cors",
|
|
3846
|
+
"sec-fetch-site": "same-site"
|
|
3826
3847
|
}
|
|
3827
3848
|
}));
|
|
3828
3849
|
}
|