koishi-plugin-bilibili-notify 3.3.8 → 3.3.10

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.
Files changed (3) hide show
  1. package/lib/index.js +38 -16
  2. package/lib/index.mjs +38 -16
  3. 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)(koishi.h.Fragment, (0, koishi.h)(content))), 1);
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);
@@ -1540,7 +1547,7 @@ var ComRegister$1 = class {
1540
1547
  check();
1541
1548
  });
1542
1549
  }
1543
- async subUserInBili(mid) {
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
- for (const user of data) if (user.mid === mid) return {
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.toString() === mid) return {
1600
1614
  code: 0,
1601
1615
  message: "订阅对象已存在于分组中"
1602
1616
  };
@@ -1685,6 +1699,19 @@ var ComRegister$1 = class {
1685
1699
  this.preInitConfig(subs);
1686
1700
  for (const sub of Object.values(subs)) {
1687
1701
  this.logger.info(`加载订阅UID:${sub.uid}中...`);
1702
+ const subInfo = await this.subUserInBili(sub.uid);
1703
+ if (subInfo.code !== 0 && subInfo.code !== 22015) return subInfo;
1704
+ if (subInfo.code === 22015) this.logger.warn(`账号异常,无法进行订阅操作,请手动订阅 UID:${sub.uid} 备注:${sub.uname}`);
1705
+ this.subManager.set(sub.uid, {
1706
+ uname: sub.uname,
1707
+ roomId: sub.roomid,
1708
+ target: sub.target,
1709
+ live: sub.live,
1710
+ dynamic: sub.dynamic,
1711
+ customCardStyle: sub.customCardStyle,
1712
+ customLiveMsg: sub.customLiveMsg,
1713
+ customLiveSummary: sub.customLiveSummary
1714
+ });
1688
1715
  if (sub.live && !sub.roomid) {
1689
1716
  this.logger.info(`UID:${sub.uid} 请求了用户接口~`);
1690
1717
  const { code: userInfoCode, message: userInfoMsg, data: userInfoData } = await withRetry(async () => {
@@ -1716,18 +1743,6 @@ var ComRegister$1 = class {
1716
1743
  sub.roomid = userInfoData.live_room?.roomid;
1717
1744
  }
1718
1745
  if (sub.live && sub.roomid && this.config.liveDetectType === "WS") await this.liveDetectWithListener(sub);
1719
- const subInfo = await this.subUserInBili(sub.uid);
1720
- if (subInfo.code !== 0) return subInfo;
1721
- this.subManager.set(sub.uid, {
1722
- uname: sub.uname,
1723
- roomId: sub.roomid,
1724
- target: sub.target,
1725
- live: sub.live,
1726
- dynamic: sub.dynamic,
1727
- customCardStyle: sub.customCardStyle,
1728
- customLiveMsg: sub.customLiveMsg,
1729
- customLiveSummary: sub.customLiveSummary
1730
- });
1731
1746
  this.logger.info(`UID:${sub.uid} 订阅加载完毕!`);
1732
1747
  if (sub !== Object.values(subs).pop()) {
1733
1748
  const randomDelay = Math.floor(Math.random() * 3) + 1;
@@ -3840,7 +3855,14 @@ var BiliAPI$1 = class extends koishi.Service {
3840
3855
  "Content-Type": "application/json",
3841
3856
  "User-Agent": this.apiConfig.userAgent || "Mozilla/5.0 (X11; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/115.0",
3842
3857
  Origin: "https://www.bilibili.com",
3843
- Referer: "https://www.bilibili.com/"
3858
+ Referer: "https://www.bilibili.com/",
3859
+ priority: "u=1, i",
3860
+ "sec-ch-ua": "\"Not;A=Brand\";v=\"99\", \"Google Chrome\";v=\"139\", \"Chromium\";v=\"139\"",
3861
+ "sec-ch-ua-mobile": "?0",
3862
+ "sec-ch-ua-platform": "\"Linux\"",
3863
+ "sec-fetch-dest": "empty",
3864
+ "sec-fetch-mode": "cors",
3865
+ "sec-fetch-site": "same-site"
3844
3866
  }
3845
3867
  }));
3846
3868
  }
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(h.Fragment, h(content))), 1);
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);
@@ -1522,7 +1529,7 @@ var ComRegister$1 = class {
1522
1529
  check();
1523
1530
  });
1524
1531
  }
1525
- async subUserInBili(mid) {
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
- for (const user of data) if (user.mid === mid) return {
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.toString() === mid) return {
1582
1596
  code: 0,
1583
1597
  message: "订阅对象已存在于分组中"
1584
1598
  };
@@ -1667,6 +1681,19 @@ var ComRegister$1 = class {
1667
1681
  this.preInitConfig(subs);
1668
1682
  for (const sub of Object.values(subs)) {
1669
1683
  this.logger.info(`加载订阅UID:${sub.uid}中...`);
1684
+ const subInfo = await this.subUserInBili(sub.uid);
1685
+ if (subInfo.code !== 0 && subInfo.code !== 22015) return subInfo;
1686
+ if (subInfo.code === 22015) this.logger.warn(`账号异常,无法进行订阅操作,请手动订阅 UID:${sub.uid} 备注:${sub.uname}`);
1687
+ this.subManager.set(sub.uid, {
1688
+ uname: sub.uname,
1689
+ roomId: sub.roomid,
1690
+ target: sub.target,
1691
+ live: sub.live,
1692
+ dynamic: sub.dynamic,
1693
+ customCardStyle: sub.customCardStyle,
1694
+ customLiveMsg: sub.customLiveMsg,
1695
+ customLiveSummary: sub.customLiveSummary
1696
+ });
1670
1697
  if (sub.live && !sub.roomid) {
1671
1698
  this.logger.info(`UID:${sub.uid} 请求了用户接口~`);
1672
1699
  const { code: userInfoCode, message: userInfoMsg, data: userInfoData } = await withRetry(async () => {
@@ -1698,18 +1725,6 @@ var ComRegister$1 = class {
1698
1725
  sub.roomid = userInfoData.live_room?.roomid;
1699
1726
  }
1700
1727
  if (sub.live && sub.roomid && this.config.liveDetectType === "WS") await this.liveDetectWithListener(sub);
1701
- const subInfo = await this.subUserInBili(sub.uid);
1702
- if (subInfo.code !== 0) return subInfo;
1703
- this.subManager.set(sub.uid, {
1704
- uname: sub.uname,
1705
- roomId: sub.roomid,
1706
- target: sub.target,
1707
- live: sub.live,
1708
- dynamic: sub.dynamic,
1709
- customCardStyle: sub.customCardStyle,
1710
- customLiveMsg: sub.customLiveMsg,
1711
- customLiveSummary: sub.customLiveSummary
1712
- });
1713
1728
  this.logger.info(`UID:${sub.uid} 订阅加载完毕!`);
1714
1729
  if (sub !== Object.values(subs).pop()) {
1715
1730
  const randomDelay = Math.floor(Math.random() * 3) + 1;
@@ -3822,7 +3837,14 @@ var BiliAPI$1 = class extends Service {
3822
3837
  "Content-Type": "application/json",
3823
3838
  "User-Agent": this.apiConfig.userAgent || "Mozilla/5.0 (X11; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/115.0",
3824
3839
  Origin: "https://www.bilibili.com",
3825
- Referer: "https://www.bilibili.com/"
3840
+ Referer: "https://www.bilibili.com/",
3841
+ priority: "u=1, i",
3842
+ "sec-ch-ua": "\"Not;A=Brand\";v=\"99\", \"Google Chrome\";v=\"139\", \"Chromium\";v=\"139\"",
3843
+ "sec-ch-ua-mobile": "?0",
3844
+ "sec-ch-ua-platform": "\"Linux\"",
3845
+ "sec-fetch-dest": "empty",
3846
+ "sec-fetch-mode": "cors",
3847
+ "sec-fetch-site": "same-site"
3826
3848
  }
3827
3849
  }));
3828
3850
  }
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.3.8",
4
+ "version": "3.3.10",
5
5
  "main": "./lib/index.js",
6
6
  "typings": "lib/index.d.ts",
7
7
  "files": [