koishi-plugin-bilibili-notify 3.2.8-alpha.0 → 3.2.8-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 CHANGED
@@ -92,9 +92,9 @@ const BAConfigSchema = koishi.Schema.object({
92
92
  })).description("订阅用户需要发送的平台和频道/群组信息(一个平台下可以推送多个频道/群组)"),
93
93
  liveMsg: koishi.Schema.intersect([koishi.Schema.object({ enable: koishi.Schema.boolean().default(false).description("是否开启个性化直播消息设置") }), koishi.Schema.union([koishi.Schema.object({
94
94
  enable: koishi.Schema.const(true).required(),
95
- customLiveStart: koishi.Schema.string().default("-name开播啦,当前粉丝数:-follower\\n-link").description("自定义开播提示语,-name代表UP昵称,-follower代表当前粉丝数,-link代表直播间链接(如果使用的是QQ官方机器人,请不要使用),\\n为换行。例如-name开播啦,会发送为xxxUP开播啦"),
96
- customLive: koishi.Schema.string().default("-name正在直播,目前已播-time,累计观看人数:-watched\\n-link").description("自定义直播中提示语,-name代表UP昵称,-time代表开播时长,-watched代表累计观看人数,-link代表直播间链接(如果使用的是QQ官方机器人,请不要使用),\\n为换行。例如-name正在直播,会发送为xxxUP正在直播xxx"),
97
- customLiveEnd: koishi.Schema.string().default("-name下播啦,本次直播了-time,粉丝数变化-follower_change").description("自定义下播提示语,-name代表UP昵称,-follower_change代表本场直播粉丝数变,-time代表开播时长,\\n为换行。例如-name下播啦,本次直播了-time,会发送为xxxUP下播啦,直播时长为xx小时xx分钟xx秒")
95
+ customLiveStart: koishi.Schema.string().description("自定义开播提示语,-name代表UP昵称,-follower代表当前粉丝数,-link代表直播间链接(如果使用的是QQ官方机器人,请不要使用),\\n为换行。例如-name开播啦,会发送为xxxUP开播啦"),
96
+ customLive: koishi.Schema.string().description("自定义直播中提示语,-name代表UP昵称,-time代表开播时长,-watched代表累计观看人数,-link代表直播间链接(如果使用的是QQ官方机器人,请不要使用),\\n为换行。例如-name正在直播,会发送为xxxUP正在直播xxx"),
97
+ customLiveEnd: koishi.Schema.string().description("自定义下播提示语,-name代表UP昵称,-follower_change代表本场直播粉丝数变,-time代表开播时长,\\n为换行。例如-name下播啦,本次直播了-time,会发送为xxxUP下播啦,直播时长为xx小时xx分钟xx秒")
98
98
  }), koishi.Schema.object({})])]),
99
99
  card: koishi.Schema.intersect([koishi.Schema.object({ enable: koishi.Schema.boolean().default(false).description("是否开启自定义卡片颜色") }), koishi.Schema.union([koishi.Schema.object({
100
100
  enable: koishi.Schema.const(true).required(),
@@ -640,6 +640,7 @@ var ComRegister = class {
640
640
  subManager = [];
641
641
  dynamicTimelineManager = /* @__PURE__ */ new Map();
642
642
  liveStatusManager = /* @__PURE__ */ new Map();
643
+ liveMsgManager = /* @__PURE__ */ new Map();
643
644
  pushArrMap = /* @__PURE__ */ new Map();
644
645
  loginDBData;
645
646
  privateBot;
@@ -829,29 +830,16 @@ var ComRegister = class {
829
830
  initManager() {
830
831
  for (const sub of this.subManager) {
831
832
  if (sub.dynamic) this.dynamicTimelineManager.set(sub.uid, Math.floor(luxon.DateTime.now().toSeconds()));
832
- if (sub.live) {
833
- const liveMsg = {
834
- customLiveStart: this.config.customLiveStart || "",
835
- customLive: this.config.customLive || "",
836
- customLiveEnd: this.config.customLiveEnd || ""
837
- };
838
- if (sub.liveMsg.enable) {
839
- liveMsg.customLiveStart = sub.liveMsg.customLiveStart || this.config.customLiveStart;
840
- liveMsg.customLive = sub.liveMsg.customLive || this.config.customLive;
841
- liveMsg.customLiveEnd = sub.liveMsg.customLiveEnd || this.config.customLiveEnd;
842
- }
843
- this.liveStatusManager.set(sub.uid, {
844
- roomId: sub.roomId,
845
- live: false,
846
- liveRoomInfo: void 0,
847
- masterInfo: void 0,
848
- watchedNum: "0",
849
- liveStartTime: "",
850
- liveStartTimeInit: false,
851
- push: 0,
852
- liveMsg
853
- });
854
- }
833
+ if (sub.live) this.liveStatusManager.set(sub.uid, {
834
+ roomId: sub.roomId,
835
+ live: false,
836
+ liveRoomInfo: void 0,
837
+ masterInfo: void 0,
838
+ watchedNum: "0",
839
+ liveStartTime: "",
840
+ liveStartTimeInit: false,
841
+ push: 0
842
+ });
855
843
  }
856
844
  }
857
845
  getBot(pf, selfId) {
@@ -897,8 +885,19 @@ var ComRegister = class {
897
885
  await this.sendPrivateMsg(`发送群组ID:${channelId}消息失败,请查看日志`);
898
886
  });
899
887
  }
900
- initPushRecord(subs) {
888
+ preInitConfig(subs) {
901
889
  for (const sub of subs) {
890
+ const liveMsg = {
891
+ customLiveStart: this.config.customLiveStart || "",
892
+ customLive: this.config.customLive || "",
893
+ customLiveEnd: this.config.customLiveEnd || ""
894
+ };
895
+ if (sub.liveMsg.enable) {
896
+ liveMsg.customLiveStart = sub.liveMsg.customLiveStart || this.config.customLiveStart;
897
+ liveMsg.customLive = sub.liveMsg.customLive || this.config.customLive;
898
+ liveMsg.customLiveEnd = sub.liveMsg.customLiveEnd || this.config.customLiveEnd;
899
+ }
900
+ this.liveMsgManager.set(sub.uid, liveMsg);
902
901
  const atAllArr = [];
903
902
  const dynamicArr = [];
904
903
  const liveArr = [];
@@ -1230,7 +1229,7 @@ var ComRegister = class {
1230
1229
  let liveRoomInfo;
1231
1230
  let masterInfo;
1232
1231
  let watchedNum;
1233
- const liveStatusObj = this.liveStatusManager.get(uid);
1232
+ const liveMsgObj = this.liveMsgManager.get(uid);
1234
1233
  const pushAtTimeFunc = async () => {
1235
1234
  if (!await useMasterAndLiveRoomInfo(LiveType.LiveBroadcast)) {
1236
1235
  await this.sendPrivateMsg("获取直播间信息失败,推送直播卡片失败!");
@@ -1244,7 +1243,7 @@ var ComRegister = class {
1244
1243
  }
1245
1244
  liveTime = liveRoomInfo.live_time;
1246
1245
  const watched = watchedNum || "暂未获取到";
1247
- const liveMsg = liveStatusObj?.liveMsg?.customLive.replace("-name", masterInfo.username).replace("-time", await this.ctx.gi.getTimeDifference(liveTime)).replace("-watched", watched).replace("\\n", "\n").replace("-link", `https://live.bilibili.com/${liveRoomInfo.short_id === 0 ? liveRoomInfo.room_id : liveRoomInfo.short_id}`);
1246
+ const liveMsg = liveMsgObj?.customLive.replace("-name", masterInfo.username).replace("-time", await this.ctx.gi.getTimeDifference(liveTime)).replace("-watched", watched).replace("\\n", "\n").replace("-link", `https://live.bilibili.com/${liveRoomInfo.short_id === 0 ? liveRoomInfo.room_id : liveRoomInfo.short_id}`);
1248
1247
  await this.sendLiveNotifyCard(LiveType.LiveBroadcast, watched, {
1249
1248
  liveRoomInfo,
1250
1249
  masterInfo,
@@ -1306,7 +1305,7 @@ var ComRegister = class {
1306
1305
  }
1307
1306
  liveTime = liveRoomInfo.live_time;
1308
1307
  const follower = masterInfo.liveOpenFollowerNum >= 1e4 ? `${(masterInfo.liveOpenFollowerNum / 1e4).toFixed(1)}万` : masterInfo.liveOpenFollowerNum.toString();
1309
- const liveStartMsg = liveStatusObj?.liveMsg?.customLiveStart.replace("-name", masterInfo.username).replace("-time", await this.ctx.gi.getTimeDifference(liveTime)).replace("-follower", follower).replace("\\n", "\n").replace("-link", `https://live.bilibili.com/${liveRoomInfo.short_id === 0 ? liveRoomInfo.room_id : liveRoomInfo.short_id}`);
1308
+ const liveStartMsg = liveMsgObj?.customLiveStart.replace("-name", masterInfo.username).replace("-time", await this.ctx.gi.getTimeDifference(liveTime)).replace("-follower", follower).replace("\\n", "\n").replace("-link", `https://live.bilibili.com/${liveRoomInfo.short_id === 0 ? liveRoomInfo.room_id : liveRoomInfo.short_id}`);
1310
1309
  await this.sendLiveNotifyCard(LiveType.StartBroadcasting, follower, {
1311
1310
  liveRoomInfo,
1312
1311
  masterInfo,
@@ -1326,7 +1325,7 @@ var ComRegister = class {
1326
1325
  if (liveFollowerChangeNum > 0) return liveFollowerChangeNum >= 1e4 ? `+${liveFollowerChangeNum.toFixed(1)}万` : `+${liveFollowerChangeNum}`;
1327
1326
  return liveFollowerChangeNum <= -1e4 ? `${liveFollowerChangeNum.toFixed(1)}万` : liveFollowerChangeNum.toString();
1328
1327
  })();
1329
- const liveEndMsg = liveStatusObj?.liveMsg?.customLiveEnd.replace("-name", masterInfo.username).replace("-time", await this.ctx.gi.getTimeDifference(liveTime)).replace("-follower_change", followerChange).replace("\\n", "\n");
1328
+ const liveEndMsg = liveMsgObj?.customLiveEnd.replace("-name", masterInfo.username).replace("-time", await this.ctx.gi.getTimeDifference(liveTime)).replace("-follower_change", followerChange).replace("\\n", "\n");
1330
1329
  await this.sendLiveNotifyCard(LiveType.StopBroadcast, followerChange, {
1331
1330
  liveRoomInfo,
1332
1331
  masterInfo,
@@ -1341,7 +1340,7 @@ var ComRegister = class {
1341
1340
  if (liveRoomInfo.live_status === 1) {
1342
1341
  liveTime = liveRoomInfo.live_time;
1343
1342
  const watched = watchedNum || "暂未获取到";
1344
- const liveMsg = liveStatusObj?.liveMsg?.customLive.replace("-name", masterInfo.username).replace("-time", await this.ctx.gi.getTimeDifference(liveTime)).replace("-watched", watched).replace("\\n", "\n").replace("-link", `https://live.bilibili.com/${liveRoomInfo.short_id === 0 ? liveRoomInfo.room_id : liveRoomInfo.short_id}`);
1343
+ const liveMsg = liveMsgObj?.customLive.replace("-name", masterInfo.username).replace("-time", await this.ctx.gi.getTimeDifference(liveTime)).replace("-watched", watched).replace("\\n", "\n").replace("-link", `https://live.bilibili.com/${liveRoomInfo.short_id === 0 ? liveRoomInfo.room_id : liveRoomInfo.short_id}`);
1345
1344
  if (this.config.restartPush) await this.sendLiveNotifyCard(LiveType.LiveBroadcast, watched, {
1346
1345
  liveRoomInfo,
1347
1346
  masterInfo,
@@ -1384,6 +1383,7 @@ var ComRegister = class {
1384
1383
  for (const item of Object.values(data$1)) {
1385
1384
  const uid = item.uid.toString();
1386
1385
  const liveStatus = this.liveStatusManager.get(uid);
1386
+ const liveMsgObj = this.liveMsgManager.get(uid);
1387
1387
  const sub = this.subManager.find((sub$1) => sub$1.uid === uid);
1388
1388
  if (item.live_status === 1) {
1389
1389
  liveStatus.live = true;
@@ -1392,7 +1392,7 @@ var ComRegister = class {
1392
1392
  liveStatus.liveStartTime = liveStatus.liveRoomInfo.live_time;
1393
1393
  liveStatus.liveStartTimeInit = true;
1394
1394
  }
1395
- const liveMsg = liveStatus.liveMsg?.customLive.replace("-name", liveStatus.masterInfo.username).replace("-time", await this.ctx.gi.getTimeDifference(liveStatus.liveStartTime)).replace("-watched", "API模式无法获取").replace("\\n", "\n").replace("-link", `https://live.bilibili.com/${liveStatus.liveRoomInfo.short_id === 0 ? liveStatus.liveRoomInfo.room_id : liveStatus.liveRoomInfo.short_id}`);
1395
+ const liveMsg = liveMsgObj?.customLive.replace("-name", liveStatus.masterInfo.username).replace("-time", await this.ctx.gi.getTimeDifference(liveStatus.liveStartTime)).replace("-watched", "API模式无法获取").replace("\\n", "\n").replace("-link", `https://live.bilibili.com/${liveStatus.liveRoomInfo.short_id === 0 ? liveStatus.liveRoomInfo.room_id : liveStatus.liveRoomInfo.short_id}`);
1396
1396
  await this.sendLiveNotifyCard(LiveType.LiveBroadcast, "API", {
1397
1397
  liveRoomInfo: liveStatus.liveRoomInfo,
1398
1398
  masterInfo: liveStatus.masterInfo,
@@ -1405,6 +1405,7 @@ var ComRegister = class {
1405
1405
  for (const item of Object.values(data$2)) {
1406
1406
  const uid = item.uid.toString();
1407
1407
  const liveStatus = this.liveStatusManager.get(uid);
1408
+ const liveMsgObj = this.liveMsgManager.get(uid);
1408
1409
  const sub = this.subManager.find((sub$1) => sub$1.uid === uid);
1409
1410
  if (!sub) return;
1410
1411
  switch (item.live_status) {
@@ -1424,7 +1425,7 @@ var ComRegister = class {
1424
1425
  if (liveFollowerChangeNum > 0) return liveFollowerChangeNum >= 1e4 ? `+${liveFollowerChangeNum.toFixed(1)}万` : `+${liveFollowerChangeNum}`;
1425
1426
  return liveFollowerChangeNum <= -1e4 ? `${liveFollowerChangeNum.toFixed(1)}万` : liveFollowerChangeNum.toString();
1426
1427
  })();
1427
- const liveEndMsg = liveStatus.liveMsg?.customLiveEnd.replace("-name", liveStatus.masterInfo.username).replace("-time", await this.ctx.gi.getTimeDifference(liveStatus.liveStartTime)).replace("-follower_change", followerChange).replace("\\n", "\n");
1428
+ const liveEndMsg = liveMsgObj?.customLiveEnd.replace("-name", liveStatus.masterInfo.username).replace("-time", await this.ctx.gi.getTimeDifference(liveStatus.liveStartTime)).replace("-follower_change", followerChange).replace("\\n", "\n");
1428
1429
  await this.sendLiveNotifyCard(LiveType.StopBroadcast, followerChange, {
1429
1430
  liveRoomInfo: liveStatus.liveRoomInfo,
1430
1431
  masterInfo: liveStatus.masterInfo,
@@ -1443,7 +1444,7 @@ var ComRegister = class {
1443
1444
  liveStatus.liveStartTime = liveStatus.liveRoomInfo.live_time;
1444
1445
  liveStatus.liveStartTimeInit = true;
1445
1446
  const follower = liveStatus.masterInfo.liveOpenFollowerNum >= 1e4 ? `${(liveStatus.masterInfo.liveOpenFollowerNum / 1e4).toFixed(1)}万` : liveStatus.masterInfo.liveOpenFollowerNum.toString();
1446
- const liveStartMsg = liveStatus.liveMsg?.customLiveStart.replace("-name", liveStatus.masterInfo.username).replace("-time", await this.ctx.gi.getTimeDifference(liveStatus.liveStartTime)).replace("-follower", follower).replace("\\n", "\n").replace("-link", `https://live.bilibili.com/${liveStatus.liveRoomInfo.short_id === 0 ? liveStatus.liveRoomInfo.room_id : liveStatus.liveRoomInfo.short_id}`);
1447
+ const liveStartMsg = liveMsgObj?.customLiveStart.replace("-name", liveStatus.masterInfo.username).replace("-time", await this.ctx.gi.getTimeDifference(liveStatus.liveStartTime)).replace("-follower", follower).replace("\\n", "\n").replace("-link", `https://live.bilibili.com/${liveStatus.liveRoomInfo.short_id === 0 ? liveStatus.liveRoomInfo.room_id : liveStatus.liveRoomInfo.short_id}`);
1447
1448
  await this.sendLiveNotifyCard(LiveType.StartBroadcasting, follower, {
1448
1449
  liveRoomInfo: liveStatus.liveRoomInfo,
1449
1450
  masterInfo: liveStatus.masterInfo,
@@ -1464,7 +1465,7 @@ var ComRegister = class {
1464
1465
  liveStatus.liveStartTime = liveStatus.liveRoomInfo.live_time;
1465
1466
  liveStatus.liveStartTimeInit = true;
1466
1467
  }
1467
- const liveMsg = liveStatus.liveMsg?.customLive.replace("-name", liveStatus.masterInfo.username).replace("-time", await this.ctx.gi.getTimeDifference(liveStatus.liveStartTime)).replace("-watched", "API模式无法获取").replace("\\n", "\n").replace("-link", `https://live.bilibili.com/${liveStatus.liveRoomInfo.short_id === 0 ? liveStatus.liveRoomInfo.room_id : liveStatus.liveRoomInfo.short_id}`);
1468
+ const liveMsg = liveMsgObj?.customLive.replace("-name", liveStatus.masterInfo.username).replace("-time", await this.ctx.gi.getTimeDifference(liveStatus.liveStartTime)).replace("-watched", "API模式无法获取").replace("\\n", "\n").replace("-link", `https://live.bilibili.com/${liveStatus.liveRoomInfo.short_id === 0 ? liveStatus.liveRoomInfo.room_id : liveStatus.liveRoomInfo.short_id}`);
1468
1469
  await this.sendLiveNotifyCard(LiveType.LiveBroadcast, "API", {
1469
1470
  liveRoomInfo: liveStatus.liveRoomInfo,
1470
1471
  masterInfo: liveStatus.masterInfo,
@@ -1637,7 +1638,7 @@ var ComRegister = class {
1637
1638
  return await subUserMatchPattern[subUserData.code]();
1638
1639
  }
1639
1640
  async loadSubFromConfig(subs) {
1640
- this.initPushRecord(subs);
1641
+ this.preInitConfig(subs);
1641
1642
  for (const sub of subs) {
1642
1643
  this.logger.info(`加载订阅UID:${sub.uid}中...`);
1643
1644
  const { code: userInfoCode, msg: userInfoMsg, data: userInfoData } = await withRetry(async () => {
package/lib/index.mjs CHANGED
@@ -94,9 +94,9 @@ const BAConfigSchema = Schema.object({
94
94
  })).description("订阅用户需要发送的平台和频道/群组信息(一个平台下可以推送多个频道/群组)"),
95
95
  liveMsg: Schema.intersect([Schema.object({ enable: Schema.boolean().default(false).description("是否开启个性化直播消息设置") }), Schema.union([Schema.object({
96
96
  enable: Schema.const(true).required(),
97
- customLiveStart: Schema.string().default("-name开播啦,当前粉丝数:-follower\\n-link").description("自定义开播提示语,-name代表UP昵称,-follower代表当前粉丝数,-link代表直播间链接(如果使用的是QQ官方机器人,请不要使用),\\n为换行。例如-name开播啦,会发送为xxxUP开播啦"),
98
- customLive: Schema.string().default("-name正在直播,目前已播-time,累计观看人数:-watched\\n-link").description("自定义直播中提示语,-name代表UP昵称,-time代表开播时长,-watched代表累计观看人数,-link代表直播间链接(如果使用的是QQ官方机器人,请不要使用),\\n为换行。例如-name正在直播,会发送为xxxUP正在直播xxx"),
99
- customLiveEnd: Schema.string().default("-name下播啦,本次直播了-time,粉丝数变化-follower_change").description("自定义下播提示语,-name代表UP昵称,-follower_change代表本场直播粉丝数变,-time代表开播时长,\\n为换行。例如-name下播啦,本次直播了-time,会发送为xxxUP下播啦,直播时长为xx小时xx分钟xx秒")
97
+ customLiveStart: Schema.string().description("自定义开播提示语,-name代表UP昵称,-follower代表当前粉丝数,-link代表直播间链接(如果使用的是QQ官方机器人,请不要使用),\\n为换行。例如-name开播啦,会发送为xxxUP开播啦"),
98
+ customLive: Schema.string().description("自定义直播中提示语,-name代表UP昵称,-time代表开播时长,-watched代表累计观看人数,-link代表直播间链接(如果使用的是QQ官方机器人,请不要使用),\\n为换行。例如-name正在直播,会发送为xxxUP正在直播xxx"),
99
+ customLiveEnd: Schema.string().description("自定义下播提示语,-name代表UP昵称,-follower_change代表本场直播粉丝数变,-time代表开播时长,\\n为换行。例如-name下播啦,本次直播了-time,会发送为xxxUP下播啦,直播时长为xx小时xx分钟xx秒")
100
100
  }), Schema.object({})])]),
101
101
  card: Schema.intersect([Schema.object({ enable: Schema.boolean().default(false).description("是否开启自定义卡片颜色") }), Schema.union([Schema.object({
102
102
  enable: Schema.const(true).required(),
@@ -642,6 +642,7 @@ var ComRegister = class {
642
642
  subManager = [];
643
643
  dynamicTimelineManager = /* @__PURE__ */ new Map();
644
644
  liveStatusManager = /* @__PURE__ */ new Map();
645
+ liveMsgManager = /* @__PURE__ */ new Map();
645
646
  pushArrMap = /* @__PURE__ */ new Map();
646
647
  loginDBData;
647
648
  privateBot;
@@ -831,29 +832,16 @@ var ComRegister = class {
831
832
  initManager() {
832
833
  for (const sub of this.subManager) {
833
834
  if (sub.dynamic) this.dynamicTimelineManager.set(sub.uid, Math.floor(DateTime.now().toSeconds()));
834
- if (sub.live) {
835
- const liveMsg = {
836
- customLiveStart: this.config.customLiveStart || "",
837
- customLive: this.config.customLive || "",
838
- customLiveEnd: this.config.customLiveEnd || ""
839
- };
840
- if (sub.liveMsg.enable) {
841
- liveMsg.customLiveStart = sub.liveMsg.customLiveStart || this.config.customLiveStart;
842
- liveMsg.customLive = sub.liveMsg.customLive || this.config.customLive;
843
- liveMsg.customLiveEnd = sub.liveMsg.customLiveEnd || this.config.customLiveEnd;
844
- }
845
- this.liveStatusManager.set(sub.uid, {
846
- roomId: sub.roomId,
847
- live: false,
848
- liveRoomInfo: void 0,
849
- masterInfo: void 0,
850
- watchedNum: "0",
851
- liveStartTime: "",
852
- liveStartTimeInit: false,
853
- push: 0,
854
- liveMsg
855
- });
856
- }
835
+ if (sub.live) this.liveStatusManager.set(sub.uid, {
836
+ roomId: sub.roomId,
837
+ live: false,
838
+ liveRoomInfo: void 0,
839
+ masterInfo: void 0,
840
+ watchedNum: "0",
841
+ liveStartTime: "",
842
+ liveStartTimeInit: false,
843
+ push: 0
844
+ });
857
845
  }
858
846
  }
859
847
  getBot(pf, selfId) {
@@ -899,8 +887,19 @@ var ComRegister = class {
899
887
  await this.sendPrivateMsg(`发送群组ID:${channelId}消息失败,请查看日志`);
900
888
  });
901
889
  }
902
- initPushRecord(subs) {
890
+ preInitConfig(subs) {
903
891
  for (const sub of subs) {
892
+ const liveMsg = {
893
+ customLiveStart: this.config.customLiveStart || "",
894
+ customLive: this.config.customLive || "",
895
+ customLiveEnd: this.config.customLiveEnd || ""
896
+ };
897
+ if (sub.liveMsg.enable) {
898
+ liveMsg.customLiveStart = sub.liveMsg.customLiveStart || this.config.customLiveStart;
899
+ liveMsg.customLive = sub.liveMsg.customLive || this.config.customLive;
900
+ liveMsg.customLiveEnd = sub.liveMsg.customLiveEnd || this.config.customLiveEnd;
901
+ }
902
+ this.liveMsgManager.set(sub.uid, liveMsg);
904
903
  const atAllArr = [];
905
904
  const dynamicArr = [];
906
905
  const liveArr = [];
@@ -1232,7 +1231,7 @@ var ComRegister = class {
1232
1231
  let liveRoomInfo;
1233
1232
  let masterInfo;
1234
1233
  let watchedNum;
1235
- const liveStatusObj = this.liveStatusManager.get(uid);
1234
+ const liveMsgObj = this.liveMsgManager.get(uid);
1236
1235
  const pushAtTimeFunc = async () => {
1237
1236
  if (!await useMasterAndLiveRoomInfo(LiveType.LiveBroadcast)) {
1238
1237
  await this.sendPrivateMsg("获取直播间信息失败,推送直播卡片失败!");
@@ -1246,7 +1245,7 @@ var ComRegister = class {
1246
1245
  }
1247
1246
  liveTime = liveRoomInfo.live_time;
1248
1247
  const watched = watchedNum || "暂未获取到";
1249
- const liveMsg = liveStatusObj?.liveMsg?.customLive.replace("-name", masterInfo.username).replace("-time", await this.ctx.gi.getTimeDifference(liveTime)).replace("-watched", watched).replace("\\n", "\n").replace("-link", `https://live.bilibili.com/${liveRoomInfo.short_id === 0 ? liveRoomInfo.room_id : liveRoomInfo.short_id}`);
1248
+ const liveMsg = liveMsgObj?.customLive.replace("-name", masterInfo.username).replace("-time", await this.ctx.gi.getTimeDifference(liveTime)).replace("-watched", watched).replace("\\n", "\n").replace("-link", `https://live.bilibili.com/${liveRoomInfo.short_id === 0 ? liveRoomInfo.room_id : liveRoomInfo.short_id}`);
1250
1249
  await this.sendLiveNotifyCard(LiveType.LiveBroadcast, watched, {
1251
1250
  liveRoomInfo,
1252
1251
  masterInfo,
@@ -1308,7 +1307,7 @@ var ComRegister = class {
1308
1307
  }
1309
1308
  liveTime = liveRoomInfo.live_time;
1310
1309
  const follower = masterInfo.liveOpenFollowerNum >= 1e4 ? `${(masterInfo.liveOpenFollowerNum / 1e4).toFixed(1)}万` : masterInfo.liveOpenFollowerNum.toString();
1311
- const liveStartMsg = liveStatusObj?.liveMsg?.customLiveStart.replace("-name", masterInfo.username).replace("-time", await this.ctx.gi.getTimeDifference(liveTime)).replace("-follower", follower).replace("\\n", "\n").replace("-link", `https://live.bilibili.com/${liveRoomInfo.short_id === 0 ? liveRoomInfo.room_id : liveRoomInfo.short_id}`);
1310
+ const liveStartMsg = liveMsgObj?.customLiveStart.replace("-name", masterInfo.username).replace("-time", await this.ctx.gi.getTimeDifference(liveTime)).replace("-follower", follower).replace("\\n", "\n").replace("-link", `https://live.bilibili.com/${liveRoomInfo.short_id === 0 ? liveRoomInfo.room_id : liveRoomInfo.short_id}`);
1312
1311
  await this.sendLiveNotifyCard(LiveType.StartBroadcasting, follower, {
1313
1312
  liveRoomInfo,
1314
1313
  masterInfo,
@@ -1328,7 +1327,7 @@ var ComRegister = class {
1328
1327
  if (liveFollowerChangeNum > 0) return liveFollowerChangeNum >= 1e4 ? `+${liveFollowerChangeNum.toFixed(1)}万` : `+${liveFollowerChangeNum}`;
1329
1328
  return liveFollowerChangeNum <= -1e4 ? `${liveFollowerChangeNum.toFixed(1)}万` : liveFollowerChangeNum.toString();
1330
1329
  })();
1331
- const liveEndMsg = liveStatusObj?.liveMsg?.customLiveEnd.replace("-name", masterInfo.username).replace("-time", await this.ctx.gi.getTimeDifference(liveTime)).replace("-follower_change", followerChange).replace("\\n", "\n");
1330
+ const liveEndMsg = liveMsgObj?.customLiveEnd.replace("-name", masterInfo.username).replace("-time", await this.ctx.gi.getTimeDifference(liveTime)).replace("-follower_change", followerChange).replace("\\n", "\n");
1332
1331
  await this.sendLiveNotifyCard(LiveType.StopBroadcast, followerChange, {
1333
1332
  liveRoomInfo,
1334
1333
  masterInfo,
@@ -1343,7 +1342,7 @@ var ComRegister = class {
1343
1342
  if (liveRoomInfo.live_status === 1) {
1344
1343
  liveTime = liveRoomInfo.live_time;
1345
1344
  const watched = watchedNum || "暂未获取到";
1346
- const liveMsg = liveStatusObj?.liveMsg?.customLive.replace("-name", masterInfo.username).replace("-time", await this.ctx.gi.getTimeDifference(liveTime)).replace("-watched", watched).replace("\\n", "\n").replace("-link", `https://live.bilibili.com/${liveRoomInfo.short_id === 0 ? liveRoomInfo.room_id : liveRoomInfo.short_id}`);
1345
+ const liveMsg = liveMsgObj?.customLive.replace("-name", masterInfo.username).replace("-time", await this.ctx.gi.getTimeDifference(liveTime)).replace("-watched", watched).replace("\\n", "\n").replace("-link", `https://live.bilibili.com/${liveRoomInfo.short_id === 0 ? liveRoomInfo.room_id : liveRoomInfo.short_id}`);
1347
1346
  if (this.config.restartPush) await this.sendLiveNotifyCard(LiveType.LiveBroadcast, watched, {
1348
1347
  liveRoomInfo,
1349
1348
  masterInfo,
@@ -1386,6 +1385,7 @@ var ComRegister = class {
1386
1385
  for (const item of Object.values(data$1)) {
1387
1386
  const uid = item.uid.toString();
1388
1387
  const liveStatus = this.liveStatusManager.get(uid);
1388
+ const liveMsgObj = this.liveMsgManager.get(uid);
1389
1389
  const sub = this.subManager.find((sub$1) => sub$1.uid === uid);
1390
1390
  if (item.live_status === 1) {
1391
1391
  liveStatus.live = true;
@@ -1394,7 +1394,7 @@ var ComRegister = class {
1394
1394
  liveStatus.liveStartTime = liveStatus.liveRoomInfo.live_time;
1395
1395
  liveStatus.liveStartTimeInit = true;
1396
1396
  }
1397
- const liveMsg = liveStatus.liveMsg?.customLive.replace("-name", liveStatus.masterInfo.username).replace("-time", await this.ctx.gi.getTimeDifference(liveStatus.liveStartTime)).replace("-watched", "API模式无法获取").replace("\\n", "\n").replace("-link", `https://live.bilibili.com/${liveStatus.liveRoomInfo.short_id === 0 ? liveStatus.liveRoomInfo.room_id : liveStatus.liveRoomInfo.short_id}`);
1397
+ const liveMsg = liveMsgObj?.customLive.replace("-name", liveStatus.masterInfo.username).replace("-time", await this.ctx.gi.getTimeDifference(liveStatus.liveStartTime)).replace("-watched", "API模式无法获取").replace("\\n", "\n").replace("-link", `https://live.bilibili.com/${liveStatus.liveRoomInfo.short_id === 0 ? liveStatus.liveRoomInfo.room_id : liveStatus.liveRoomInfo.short_id}`);
1398
1398
  await this.sendLiveNotifyCard(LiveType.LiveBroadcast, "API", {
1399
1399
  liveRoomInfo: liveStatus.liveRoomInfo,
1400
1400
  masterInfo: liveStatus.masterInfo,
@@ -1407,6 +1407,7 @@ var ComRegister = class {
1407
1407
  for (const item of Object.values(data$2)) {
1408
1408
  const uid = item.uid.toString();
1409
1409
  const liveStatus = this.liveStatusManager.get(uid);
1410
+ const liveMsgObj = this.liveMsgManager.get(uid);
1410
1411
  const sub = this.subManager.find((sub$1) => sub$1.uid === uid);
1411
1412
  if (!sub) return;
1412
1413
  switch (item.live_status) {
@@ -1426,7 +1427,7 @@ var ComRegister = class {
1426
1427
  if (liveFollowerChangeNum > 0) return liveFollowerChangeNum >= 1e4 ? `+${liveFollowerChangeNum.toFixed(1)}万` : `+${liveFollowerChangeNum}`;
1427
1428
  return liveFollowerChangeNum <= -1e4 ? `${liveFollowerChangeNum.toFixed(1)}万` : liveFollowerChangeNum.toString();
1428
1429
  })();
1429
- const liveEndMsg = liveStatus.liveMsg?.customLiveEnd.replace("-name", liveStatus.masterInfo.username).replace("-time", await this.ctx.gi.getTimeDifference(liveStatus.liveStartTime)).replace("-follower_change", followerChange).replace("\\n", "\n");
1430
+ const liveEndMsg = liveMsgObj?.customLiveEnd.replace("-name", liveStatus.masterInfo.username).replace("-time", await this.ctx.gi.getTimeDifference(liveStatus.liveStartTime)).replace("-follower_change", followerChange).replace("\\n", "\n");
1430
1431
  await this.sendLiveNotifyCard(LiveType.StopBroadcast, followerChange, {
1431
1432
  liveRoomInfo: liveStatus.liveRoomInfo,
1432
1433
  masterInfo: liveStatus.masterInfo,
@@ -1445,7 +1446,7 @@ var ComRegister = class {
1445
1446
  liveStatus.liveStartTime = liveStatus.liveRoomInfo.live_time;
1446
1447
  liveStatus.liveStartTimeInit = true;
1447
1448
  const follower = liveStatus.masterInfo.liveOpenFollowerNum >= 1e4 ? `${(liveStatus.masterInfo.liveOpenFollowerNum / 1e4).toFixed(1)}万` : liveStatus.masterInfo.liveOpenFollowerNum.toString();
1448
- const liveStartMsg = liveStatus.liveMsg?.customLiveStart.replace("-name", liveStatus.masterInfo.username).replace("-time", await this.ctx.gi.getTimeDifference(liveStatus.liveStartTime)).replace("-follower", follower).replace("\\n", "\n").replace("-link", `https://live.bilibili.com/${liveStatus.liveRoomInfo.short_id === 0 ? liveStatus.liveRoomInfo.room_id : liveStatus.liveRoomInfo.short_id}`);
1449
+ const liveStartMsg = liveMsgObj?.customLiveStart.replace("-name", liveStatus.masterInfo.username).replace("-time", await this.ctx.gi.getTimeDifference(liveStatus.liveStartTime)).replace("-follower", follower).replace("\\n", "\n").replace("-link", `https://live.bilibili.com/${liveStatus.liveRoomInfo.short_id === 0 ? liveStatus.liveRoomInfo.room_id : liveStatus.liveRoomInfo.short_id}`);
1449
1450
  await this.sendLiveNotifyCard(LiveType.StartBroadcasting, follower, {
1450
1451
  liveRoomInfo: liveStatus.liveRoomInfo,
1451
1452
  masterInfo: liveStatus.masterInfo,
@@ -1466,7 +1467,7 @@ var ComRegister = class {
1466
1467
  liveStatus.liveStartTime = liveStatus.liveRoomInfo.live_time;
1467
1468
  liveStatus.liveStartTimeInit = true;
1468
1469
  }
1469
- const liveMsg = liveStatus.liveMsg?.customLive.replace("-name", liveStatus.masterInfo.username).replace("-time", await this.ctx.gi.getTimeDifference(liveStatus.liveStartTime)).replace("-watched", "API模式无法获取").replace("\\n", "\n").replace("-link", `https://live.bilibili.com/${liveStatus.liveRoomInfo.short_id === 0 ? liveStatus.liveRoomInfo.room_id : liveStatus.liveRoomInfo.short_id}`);
1470
+ const liveMsg = liveMsgObj?.customLive.replace("-name", liveStatus.masterInfo.username).replace("-time", await this.ctx.gi.getTimeDifference(liveStatus.liveStartTime)).replace("-watched", "API模式无法获取").replace("\\n", "\n").replace("-link", `https://live.bilibili.com/${liveStatus.liveRoomInfo.short_id === 0 ? liveStatus.liveRoomInfo.room_id : liveStatus.liveRoomInfo.short_id}`);
1470
1471
  await this.sendLiveNotifyCard(LiveType.LiveBroadcast, "API", {
1471
1472
  liveRoomInfo: liveStatus.liveRoomInfo,
1472
1473
  masterInfo: liveStatus.masterInfo,
@@ -1639,7 +1640,7 @@ var ComRegister = class {
1639
1640
  return await subUserMatchPattern[subUserData.code]();
1640
1641
  }
1641
1642
  async loadSubFromConfig(subs) {
1642
- this.initPushRecord(subs);
1643
+ this.preInitConfig(subs);
1643
1644
  for (const sub of subs) {
1644
1645
  this.logger.info(`加载订阅UID:${sub.uid}中...`);
1645
1646
  const { code: userInfoCode, msg: userInfoMsg, data: userInfoData } = await withRetry(async () => {
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.2.8-alpha.0",
4
+ "version": "3.2.8-alpha.1",
5
5
  "contributors": [
6
6
  "Akokko <admin@akokko.com>"
7
7
  ],
package/readme.md CHANGED
@@ -296,6 +296,7 @@ uid为必填参数,为要推送的UP主的UID,index为可选参数,为要
296
296
  > - ver 3.2.7-alpha.0 优化:将选项 `userAgent` 更改为可选项,在 `cookies` 中添加 `bili_ticket` 降低风控概率;
297
297
  > - ver 3.2.7-alpha.1 修复:加载 `bili_ticket` 失败会导致插件加载失败;
298
298
  > - ver 3.2.8-alpha.0 修复:插件重启报错 `RangeError: Invalid time value` ; 新增:选项 `sub.liveMsg` ,可自定义每个UP个性化的直播推送语;
299
+ > - ver 3.2.8-alpha.1 修复:直播推送没有推送语;
299
300
 
300
301
  ## 交流群
301
302