koishi-plugin-bilibili-notify 3.3.7 → 3.3.8-alpha.0

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 +23 -31
  2. package/lib/index.mjs +23 -31
  3. package/package.json +1 -1
package/lib/index.js CHANGED
@@ -337,11 +337,10 @@ const stopwords = new Set([
337
337
  "之前",
338
338
  "某天"
339
339
  ]);
340
- var stop_words_default = stopwords;
341
340
 
342
341
  //#endregion
343
342
  //#region src/command_register.ts
344
- var ComRegister = class {
343
+ var ComRegister$1 = class {
345
344
  static inject = [
346
345
  "bilibili-notify",
347
346
  "bilibili-notify-api",
@@ -711,11 +710,11 @@ var ComRegister = class {
711
710
  }
712
711
  mergeStopWords(stopWordsStr) {
713
712
  if (!stopWordsStr || stopWordsStr.trim() === "") {
714
- this.stopwords = new Set(stop_words_default);
713
+ this.stopwords = new Set(stopwords);
715
714
  return;
716
715
  }
717
716
  const additionalStopWords = stopWordsStr.split(",").map((word) => word.trim()).filter((word) => word !== "");
718
- this.stopwords = new Set([...stop_words_default, ...additionalStopWords]);
717
+ this.stopwords = new Set([...stopwords, ...additionalStopWords]);
719
718
  }
720
719
  initManagerAfterLoadSub() {
721
720
  for (const [uid, sub] of this.subManager) {
@@ -1170,9 +1169,11 @@ var ComRegister = class {
1170
1169
  async useLiveRoomInfo(roomId) {
1171
1170
  const data = await withRetry(async () => await this.ctx["bilibili-notify-api"].getLiveRoomInfo(roomId)).then((content) => content.data).catch((e) => {
1172
1171
  this.logger.error(`liveDetect getLiveRoomInfo 发生了错误,错误为:${e.message}`);
1173
- return false;
1174
1172
  });
1175
- if (!data) return await this.sendPrivateMsgAndStopService();
1173
+ if (!data) {
1174
+ await this.sendPrivateMsgAndStopService();
1175
+ return;
1176
+ }
1176
1177
  return data;
1177
1178
  }
1178
1179
  async sendLiveNotifyCard(liveType, followerDisplay, liveInfo, uid, liveNotifyMsg) {
@@ -1261,7 +1262,7 @@ var ComRegister = class {
1261
1262
  flag = false;
1262
1263
  return flag;
1263
1264
  }
1264
- masterInfo = await this.useMasterInfo(liveRoomInfo.uid, masterInfo, liveType).catch(() => {
1265
+ masterInfo = await this.useMasterInfo(liveRoomInfo.uid.toString(), masterInfo, liveType).catch(() => {
1265
1266
  flag = false;
1266
1267
  return null;
1267
1268
  });
@@ -1298,10 +1299,6 @@ var ComRegister = class {
1298
1299
  const now = Date.now();
1299
1300
  if (now - lastLiveStart < LIVE_EVENT_COOLDOWN) {
1300
1301
  this.logger.warn(`[${sub.roomid}] 开播事件冷却期内被忽略`);
1301
- if (!liveTime) {
1302
- await useMasterAndLiveRoomInfo(LiveType.StartBroadcasting);
1303
- liveTime = liveRoomInfo?.live_time || Date.now();
1304
- }
1305
1302
  return;
1306
1303
  }
1307
1304
  lastLiveStart = now;
@@ -1315,7 +1312,7 @@ var ComRegister = class {
1315
1312
  await this.sendPrivateMsg("获取直播间信息失败,推送直播开播卡片失败!");
1316
1313
  return await this.sendPrivateMsgAndStopService();
1317
1314
  }
1318
- liveTime = liveRoomInfo?.live_time || Date.now();
1315
+ liveTime = liveRoomInfo?.live_time || luxon.DateTime.now().toFormat("yyyy-MM-dd HH:mm:ss");
1319
1316
  const diffTime = await this.ctx["bilibili-notify-generate-img"].getTimeDifference(liveTime);
1320
1317
  const follower = masterInfo.liveOpenFollowerNum >= 1e4 ? `${(masterInfo.liveOpenFollowerNum / 1e4).toFixed(1)}万` : masterInfo.liveOpenFollowerNum.toString();
1321
1318
  const liveStartMsg = liveMsgObj.customLiveStart.replace("-name", masterInfo.username).replace("-time", diffTime).replace("-follower", follower).replaceAll("\\n", "\n").replace("-link", `https://live.bilibili.com/${liveRoomInfo.short_id === 0 ? liveRoomInfo.room_id : liveRoomInfo.short_id}`);
@@ -1335,7 +1332,7 @@ var ComRegister = class {
1335
1332
  this.logger.warn(`[${sub.roomid}] 下播事件冷却期内被忽略`);
1336
1333
  if (!liveTime) {
1337
1334
  await useMasterAndLiveRoomInfo(LiveType.StopBroadcast);
1338
- liveTime = liveRoomInfo?.live_time || Date.now();
1335
+ liveTime = liveRoomInfo?.live_time || luxon.DateTime.now().toFormat("yyyy-MM-dd HH:mm:ss");
1339
1336
  }
1340
1337
  return;
1341
1338
  }
@@ -1345,11 +1342,7 @@ var ComRegister = class {
1345
1342
  return;
1346
1343
  }
1347
1344
  liveStatus = false;
1348
- if (!await useMasterAndLiveRoomInfo(LiveType.StopBroadcast)) {
1349
- await this.sendPrivateMsg("获取直播间信息失败,推送直播下播卡片失败!");
1350
- return await this.sendPrivateMsgAndStopService();
1351
- }
1352
- liveTime = liveTime || liveRoomInfo?.live_time || Date.now();
1345
+ liveTime = liveRoomInfo?.live_time || luxon.DateTime.now().toFormat("yyyy-MM-dd HH:mm:ss");
1353
1346
  const diffTime = await this.ctx["bilibili-notify-generate-img"].getTimeDifference(liveTime);
1354
1347
  const followerChange = (() => {
1355
1348
  const liveFollowerChangeNum = masterInfo.liveFollowerChange;
@@ -1811,8 +1804,8 @@ var ComRegister = class {
1811
1804
  }),
1812
1805
  dynamicDebugMode: koishi.Schema.boolean().required()
1813
1806
  });
1814
- })(ComRegister || (ComRegister = {}));
1815
- var command_register_default = ComRegister;
1807
+ })(ComRegister$1 || (ComRegister$1 = {}));
1808
+ var ComRegister = ComRegister$1;
1816
1809
 
1817
1810
  //#endregion
1818
1811
  //#region src/database.ts
@@ -1848,7 +1841,7 @@ const DYNAMIC_TYPE_COURSES_SEASON = "DYNAMIC_TYPE_COURSES_SEASON";
1848
1841
  const DYNAMIC_TYPE_LIVE_RCMD = "DYNAMIC_TYPE_LIVE_RCMD";
1849
1842
  const DYNAMIC_TYPE_UGC_SEASON = "DYNAMIC_TYPE_UGC_SEASON";
1850
1843
  const ADDITIONAL_TYPE_RESERVE = "ADDITIONAL_TYPE_RESERVE";
1851
- var GenerateImg = class extends koishi.Service {
1844
+ var GenerateImg$1 = class extends koishi.Service {
1852
1845
  static inject = ["puppeteer"];
1853
1846
  giConfig;
1854
1847
  constructor(ctx, config) {
@@ -3312,8 +3305,8 @@ var GenerateImg = class extends koishi.Service {
3312
3305
  hideDesc: koishi.Schema.boolean(),
3313
3306
  followerDisplay: koishi.Schema.boolean()
3314
3307
  });
3315
- })(GenerateImg || (GenerateImg = {}));
3316
- var generate_img_default = GenerateImg;
3308
+ })(GenerateImg$1 || (GenerateImg$1 = {}));
3309
+ var GenerateImg = GenerateImg$1;
3317
3310
 
3318
3311
  //#endregion
3319
3312
  //#region src/bili_api.ts
@@ -3408,7 +3401,7 @@ const COPY_USER_TO_GROUP = "https://api.bilibili.com/x/relation/tags/copyUsers";
3408
3401
  const GET_RELATION_GROUP_DETAIL = "https://api.bilibili.com/x/relation/tag";
3409
3402
  const GET_LIVE_ROOM_INFO_STREAM_KEY = "https://api.live.bilibili.com/xlive/web-room/v1/index/getDanmuInfo";
3410
3403
  const GET_LIVE_ROOMS_INFO = "https://api.live.bilibili.com/room/v1/Room/get_status_info_by_uids";
3411
- var BiliAPI = class extends koishi.Service {
3404
+ var BiliAPI$1 = class extends koishi.Service {
3412
3405
  static inject = ["database", "notifier"];
3413
3406
  jar;
3414
3407
  client;
@@ -4083,8 +4076,8 @@ var BiliAPI = class extends koishi.Service {
4083
4076
  userAgent: koishi.Schema.string(),
4084
4077
  key: koishi.Schema.string().pattern(/^[0-9a-f]{32}$/).required()
4085
4078
  });
4086
- })(BiliAPI || (BiliAPI = {}));
4087
- var bili_api_default = BiliAPI;
4079
+ })(BiliAPI$1 || (BiliAPI$1 = {}));
4080
+ var BiliAPI = BiliAPI$1;
4088
4081
 
4089
4082
  //#endregion
4090
4083
  //#region src/bili_live.ts
@@ -4117,7 +4110,6 @@ var BLive = class extends koishi.Service {
4117
4110
  this.logger.warn(`${roomId}直播间连接未成功关闭`);
4118
4111
  }
4119
4112
  };
4120
- var bili_live_default = BLive;
4121
4113
 
4122
4114
  //#endregion
4123
4115
  //#region src/index.ts
@@ -4159,11 +4151,11 @@ var ServerManager = class extends koishi.Service {
4159
4151
  registerPlugin = () => {
4160
4152
  if (this.servers.length !== 0) return false;
4161
4153
  try {
4162
- const ba = this.ctx.plugin(bili_api_default, {
4154
+ const ba = this.ctx.plugin(BiliAPI, {
4163
4155
  userAgent: globalConfig.userAgent,
4164
4156
  key: globalConfig.key
4165
4157
  });
4166
- const gi = this.ctx.plugin(generate_img_default, {
4158
+ const gi = this.ctx.plugin(GenerateImg, {
4167
4159
  filter: globalConfig.filter,
4168
4160
  removeBorder: globalConfig.removeBorder,
4169
4161
  cardColorStart: globalConfig.cardColorStart,
@@ -4175,7 +4167,7 @@ var ServerManager = class extends koishi.Service {
4175
4167
  font: globalConfig.font,
4176
4168
  followerDisplay: globalConfig.followerDisplay
4177
4169
  });
4178
- const cr = this.ctx.plugin(command_register_default, {
4170
+ const cr = this.ctx.plugin(ComRegister, {
4179
4171
  advancedSub: globalConfig.advancedSub,
4180
4172
  subs: globalConfig.subs,
4181
4173
  master: globalConfig.master,
@@ -4194,7 +4186,7 @@ var ServerManager = class extends koishi.Service {
4194
4186
  filter: globalConfig.filter,
4195
4187
  dynamicDebugMode: globalConfig.dynamicDebugMode
4196
4188
  });
4197
- const bl = this.ctx.plugin(bili_live_default);
4189
+ const bl = this.ctx.plugin(BLive);
4198
4190
  this.servers.push(ba);
4199
4191
  this.servers.push(bl);
4200
4192
  this.servers.push(gi);
package/lib/index.mjs CHANGED
@@ -319,11 +319,10 @@ const stopwords = new Set([
319
319
  "之前",
320
320
  "某天"
321
321
  ]);
322
- var stop_words_default = stopwords;
323
322
 
324
323
  //#endregion
325
324
  //#region src/command_register.ts
326
- var ComRegister = class {
325
+ var ComRegister$1 = class {
327
326
  static inject = [
328
327
  "bilibili-notify",
329
328
  "bilibili-notify-api",
@@ -693,11 +692,11 @@ var ComRegister = class {
693
692
  }
694
693
  mergeStopWords(stopWordsStr) {
695
694
  if (!stopWordsStr || stopWordsStr.trim() === "") {
696
- this.stopwords = new Set(stop_words_default);
695
+ this.stopwords = new Set(stopwords);
697
696
  return;
698
697
  }
699
698
  const additionalStopWords = stopWordsStr.split(",").map((word) => word.trim()).filter((word) => word !== "");
700
- this.stopwords = new Set([...stop_words_default, ...additionalStopWords]);
699
+ this.stopwords = new Set([...stopwords, ...additionalStopWords]);
701
700
  }
702
701
  initManagerAfterLoadSub() {
703
702
  for (const [uid, sub] of this.subManager) {
@@ -1152,9 +1151,11 @@ var ComRegister = class {
1152
1151
  async useLiveRoomInfo(roomId) {
1153
1152
  const data = await withRetry(async () => await this.ctx["bilibili-notify-api"].getLiveRoomInfo(roomId)).then((content) => content.data).catch((e) => {
1154
1153
  this.logger.error(`liveDetect getLiveRoomInfo 发生了错误,错误为:${e.message}`);
1155
- return false;
1156
1154
  });
1157
- if (!data) return await this.sendPrivateMsgAndStopService();
1155
+ if (!data) {
1156
+ await this.sendPrivateMsgAndStopService();
1157
+ return;
1158
+ }
1158
1159
  return data;
1159
1160
  }
1160
1161
  async sendLiveNotifyCard(liveType, followerDisplay, liveInfo, uid, liveNotifyMsg) {
@@ -1243,7 +1244,7 @@ var ComRegister = class {
1243
1244
  flag = false;
1244
1245
  return flag;
1245
1246
  }
1246
- masterInfo = await this.useMasterInfo(liveRoomInfo.uid, masterInfo, liveType).catch(() => {
1247
+ masterInfo = await this.useMasterInfo(liveRoomInfo.uid.toString(), masterInfo, liveType).catch(() => {
1247
1248
  flag = false;
1248
1249
  return null;
1249
1250
  });
@@ -1280,10 +1281,6 @@ var ComRegister = class {
1280
1281
  const now = Date.now();
1281
1282
  if (now - lastLiveStart < LIVE_EVENT_COOLDOWN) {
1282
1283
  this.logger.warn(`[${sub.roomid}] 开播事件冷却期内被忽略`);
1283
- if (!liveTime) {
1284
- await useMasterAndLiveRoomInfo(LiveType.StartBroadcasting);
1285
- liveTime = liveRoomInfo?.live_time || Date.now();
1286
- }
1287
1284
  return;
1288
1285
  }
1289
1286
  lastLiveStart = now;
@@ -1297,7 +1294,7 @@ var ComRegister = class {
1297
1294
  await this.sendPrivateMsg("获取直播间信息失败,推送直播开播卡片失败!");
1298
1295
  return await this.sendPrivateMsgAndStopService();
1299
1296
  }
1300
- liveTime = liveRoomInfo?.live_time || Date.now();
1297
+ liveTime = liveRoomInfo?.live_time || DateTime.now().toFormat("yyyy-MM-dd HH:mm:ss");
1301
1298
  const diffTime = await this.ctx["bilibili-notify-generate-img"].getTimeDifference(liveTime);
1302
1299
  const follower = masterInfo.liveOpenFollowerNum >= 1e4 ? `${(masterInfo.liveOpenFollowerNum / 1e4).toFixed(1)}万` : masterInfo.liveOpenFollowerNum.toString();
1303
1300
  const liveStartMsg = liveMsgObj.customLiveStart.replace("-name", masterInfo.username).replace("-time", diffTime).replace("-follower", follower).replaceAll("\\n", "\n").replace("-link", `https://live.bilibili.com/${liveRoomInfo.short_id === 0 ? liveRoomInfo.room_id : liveRoomInfo.short_id}`);
@@ -1317,7 +1314,7 @@ var ComRegister = class {
1317
1314
  this.logger.warn(`[${sub.roomid}] 下播事件冷却期内被忽略`);
1318
1315
  if (!liveTime) {
1319
1316
  await useMasterAndLiveRoomInfo(LiveType.StopBroadcast);
1320
- liveTime = liveRoomInfo?.live_time || Date.now();
1317
+ liveTime = liveRoomInfo?.live_time || DateTime.now().toFormat("yyyy-MM-dd HH:mm:ss");
1321
1318
  }
1322
1319
  return;
1323
1320
  }
@@ -1327,11 +1324,7 @@ var ComRegister = class {
1327
1324
  return;
1328
1325
  }
1329
1326
  liveStatus = false;
1330
- if (!await useMasterAndLiveRoomInfo(LiveType.StopBroadcast)) {
1331
- await this.sendPrivateMsg("获取直播间信息失败,推送直播下播卡片失败!");
1332
- return await this.sendPrivateMsgAndStopService();
1333
- }
1334
- liveTime = liveTime || liveRoomInfo?.live_time || Date.now();
1327
+ liveTime = liveRoomInfo?.live_time || DateTime.now().toFormat("yyyy-MM-dd HH:mm:ss");
1335
1328
  const diffTime = await this.ctx["bilibili-notify-generate-img"].getTimeDifference(liveTime);
1336
1329
  const followerChange = (() => {
1337
1330
  const liveFollowerChangeNum = masterInfo.liveFollowerChange;
@@ -1793,8 +1786,8 @@ var ComRegister = class {
1793
1786
  }),
1794
1787
  dynamicDebugMode: Schema.boolean().required()
1795
1788
  });
1796
- })(ComRegister || (ComRegister = {}));
1797
- var command_register_default = ComRegister;
1789
+ })(ComRegister$1 || (ComRegister$1 = {}));
1790
+ var ComRegister = ComRegister$1;
1798
1791
 
1799
1792
  //#endregion
1800
1793
  //#region src/database.ts
@@ -1830,7 +1823,7 @@ const DYNAMIC_TYPE_COURSES_SEASON = "DYNAMIC_TYPE_COURSES_SEASON";
1830
1823
  const DYNAMIC_TYPE_LIVE_RCMD = "DYNAMIC_TYPE_LIVE_RCMD";
1831
1824
  const DYNAMIC_TYPE_UGC_SEASON = "DYNAMIC_TYPE_UGC_SEASON";
1832
1825
  const ADDITIONAL_TYPE_RESERVE = "ADDITIONAL_TYPE_RESERVE";
1833
- var GenerateImg = class extends Service {
1826
+ var GenerateImg$1 = class extends Service {
1834
1827
  static inject = ["puppeteer"];
1835
1828
  giConfig;
1836
1829
  constructor(ctx, config) {
@@ -3294,8 +3287,8 @@ var GenerateImg = class extends Service {
3294
3287
  hideDesc: Schema.boolean(),
3295
3288
  followerDisplay: Schema.boolean()
3296
3289
  });
3297
- })(GenerateImg || (GenerateImg = {}));
3298
- var generate_img_default = GenerateImg;
3290
+ })(GenerateImg$1 || (GenerateImg$1 = {}));
3291
+ var GenerateImg = GenerateImg$1;
3299
3292
 
3300
3293
  //#endregion
3301
3294
  //#region src/bili_api.ts
@@ -3390,7 +3383,7 @@ const COPY_USER_TO_GROUP = "https://api.bilibili.com/x/relation/tags/copyUsers";
3390
3383
  const GET_RELATION_GROUP_DETAIL = "https://api.bilibili.com/x/relation/tag";
3391
3384
  const GET_LIVE_ROOM_INFO_STREAM_KEY = "https://api.live.bilibili.com/xlive/web-room/v1/index/getDanmuInfo";
3392
3385
  const GET_LIVE_ROOMS_INFO = "https://api.live.bilibili.com/room/v1/Room/get_status_info_by_uids";
3393
- var BiliAPI = class extends Service {
3386
+ var BiliAPI$1 = class extends Service {
3394
3387
  static inject = ["database", "notifier"];
3395
3388
  jar;
3396
3389
  client;
@@ -4065,8 +4058,8 @@ var BiliAPI = class extends Service {
4065
4058
  userAgent: Schema.string(),
4066
4059
  key: Schema.string().pattern(/^[0-9a-f]{32}$/).required()
4067
4060
  });
4068
- })(BiliAPI || (BiliAPI = {}));
4069
- var bili_api_default = BiliAPI;
4061
+ })(BiliAPI$1 || (BiliAPI$1 = {}));
4062
+ var BiliAPI = BiliAPI$1;
4070
4063
 
4071
4064
  //#endregion
4072
4065
  //#region src/bili_live.ts
@@ -4099,7 +4092,6 @@ var BLive = class extends Service {
4099
4092
  this.logger.warn(`${roomId}直播间连接未成功关闭`);
4100
4093
  }
4101
4094
  };
4102
- var bili_live_default = BLive;
4103
4095
 
4104
4096
  //#endregion
4105
4097
  //#region src/index.ts
@@ -4141,11 +4133,11 @@ var ServerManager = class extends Service {
4141
4133
  registerPlugin = () => {
4142
4134
  if (this.servers.length !== 0) return false;
4143
4135
  try {
4144
- const ba = this.ctx.plugin(bili_api_default, {
4136
+ const ba = this.ctx.plugin(BiliAPI, {
4145
4137
  userAgent: globalConfig.userAgent,
4146
4138
  key: globalConfig.key
4147
4139
  });
4148
- const gi = this.ctx.plugin(generate_img_default, {
4140
+ const gi = this.ctx.plugin(GenerateImg, {
4149
4141
  filter: globalConfig.filter,
4150
4142
  removeBorder: globalConfig.removeBorder,
4151
4143
  cardColorStart: globalConfig.cardColorStart,
@@ -4157,7 +4149,7 @@ var ServerManager = class extends Service {
4157
4149
  font: globalConfig.font,
4158
4150
  followerDisplay: globalConfig.followerDisplay
4159
4151
  });
4160
- const cr = this.ctx.plugin(command_register_default, {
4152
+ const cr = this.ctx.plugin(ComRegister, {
4161
4153
  advancedSub: globalConfig.advancedSub,
4162
4154
  subs: globalConfig.subs,
4163
4155
  master: globalConfig.master,
@@ -4176,7 +4168,7 @@ var ServerManager = class extends Service {
4176
4168
  filter: globalConfig.filter,
4177
4169
  dynamicDebugMode: globalConfig.dynamicDebugMode
4178
4170
  });
4179
- const bl = this.ctx.plugin(bili_live_default);
4171
+ const bl = this.ctx.plugin(BLive);
4180
4172
  this.servers.push(ba);
4181
4173
  this.servers.push(bl);
4182
4174
  this.servers.push(gi);
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.7",
4
+ "version": "3.3.8-alpha.0",
5
5
  "main": "./lib/index.js",
6
6
  "typings": "lib/index.d.ts",
7
7
  "files": [