koishi-plugin-bilibili-notify 3.2.5-alpha.9 → 3.2.6-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.
Binary file
Binary file
package/lib/index.d.mts CHANGED
@@ -45,6 +45,7 @@ interface Config {
45
45
  }>;
46
46
  dynamic: {};
47
47
  dynamicUrl: boolean;
48
+ dynamicCron: string;
48
49
  dynamicVideoUrlToBV: boolean;
49
50
  pushImgsInDynamic: boolean;
50
51
  live: {};
package/lib/index.d.ts CHANGED
@@ -45,6 +45,7 @@ interface Config {
45
45
  }>;
46
46
  dynamic: {};
47
47
  dynamicUrl: boolean;
48
+ dynamicCron: string;
48
49
  dynamicVideoUrlToBV: boolean;
49
50
  pushImgsInDynamic: boolean;
50
51
  live: {};
package/lib/index.js CHANGED
@@ -443,7 +443,7 @@ var require_lib$3 = __commonJS$1({ "node_modules/@koishijs/plugin-help/lib/index
443
443
  //#endregion
444
444
  //#region src/utils/index.ts
445
445
  function Retry(options = { attempts: 3 }) {
446
- return (target, propertyKey, descriptor) => {
446
+ return (_target, _propertyKey, descriptor) => {
447
447
  const originalMethod = descriptor.value;
448
448
  descriptor.value = async function(...args) {
449
449
  let lastError;
@@ -552,7 +552,7 @@ var ComRegister = class {
552
552
  subManager = [];
553
553
  dynamicTimelineManager = /* @__PURE__ */ new Map();
554
554
  liveStatusManager = /* @__PURE__ */ new Map();
555
- pushRecord = {};
555
+ pushArrMap = /* @__PURE__ */ new Map();
556
556
  loginDBData;
557
557
  privateBot;
558
558
  dynamicJob;
@@ -588,7 +588,7 @@ var ComRegister = class {
588
588
  let content;
589
589
  try {
590
590
  content = await ctx.ba.getLoginQRCode();
591
- } catch (e$1) {
591
+ } catch (_$2) {
592
592
  return "bili login getLoginQRCode() 本次网络请求失败";
593
593
  }
594
594
  if (content.code !== 0) return await session.send("出问题咯,请联系管理员解决");
@@ -797,7 +797,6 @@ var ComRegister = class {
797
797
  });
798
798
  }
799
799
  initPushRecord(subs) {
800
- const pushRecord = {};
801
800
  for (const sub of subs) {
802
801
  const atAllArr = [];
803
802
  const dynamicArr = [];
@@ -809,16 +808,15 @@ var ComRegister = class {
809
808
  if (channel.live) liveArr.push(`${platform.platform}:${channel.channelId}`);
810
809
  if (channel.liveGuardBuy) liveGuardBuyArr.push(`${platform.platform}:${channel.channelId}`);
811
810
  }
812
- pushRecord[sub.uid] = {
811
+ this.pushArrMap.set(sub.uid, {
813
812
  atAllArr,
814
813
  dynamicArr,
815
814
  liveArr,
816
815
  liveGuardBuyArr
817
- };
816
+ });
818
817
  }
819
- this.pushRecord = pushRecord;
820
818
  this.logger.info("初始化推送群组/频道信息:");
821
- this.logger.info(this.pushRecord);
819
+ this.logger.info(this.pushArrMap);
822
820
  }
823
821
  checkAllBotsAreReady() {
824
822
  return !this.ctx.bots.some((bot) => bot.status !== koishi.Universal.Status.ONLINE);
@@ -832,33 +830,37 @@ var ComRegister = class {
832
830
  return;
833
831
  }
834
832
  this.logger.info(`本次推送对象:${uid},推送类型:${PushTypeMsg[type]}`);
835
- const record = this.pushRecord[uid];
833
+ const record = this.pushArrMap.get(uid);
836
834
  this.logger.info("本次推送目标:");
837
835
  if (type === PushType.StartBroadcasting && record.atAllArr?.length >= 1) {
838
836
  this.logger.info(record.atAllArr);
837
+ const atAllArr = structuredClone(record.atAllArr);
839
838
  const success = await withRetry(async () => {
840
- return await this.ctx.broadcast(record.atAllArr, /* @__PURE__ */ (0, __satorijs_element_jsx_runtime.jsxs)("message", { children: [/* @__PURE__ */ (0, __satorijs_element_jsx_runtime.jsx)("at", { type: "all" }), /* @__PURE__ */ (0, __satorijs_element_jsx_runtime.jsx)("message", { children: content })] }));
839
+ return await this.ctx.broadcast(atAllArr, /* @__PURE__ */ (0, __satorijs_element_jsx_runtime.jsx)("message", { children: /* @__PURE__ */ (0, __satorijs_element_jsx_runtime.jsx)("at", { type: "all" }) }));
841
840
  }, 1);
842
841
  this.logger.info(`成功推送全体成员消息群组/频道:${success}`);
843
842
  }
844
843
  if (type === PushType.Dynamic && record.dynamicArr?.length >= 1) {
845
844
  this.logger.info(record.dynamicArr);
845
+ const dynamicArr = structuredClone(record.dynamicArr);
846
846
  const success = await withRetry(async () => {
847
- return await this.ctx.broadcast(record.dynamicArr, /* @__PURE__ */ (0, __satorijs_element_jsx_runtime.jsx)("message", { children: content }));
847
+ return await this.ctx.broadcast(dynamicArr, /* @__PURE__ */ (0, __satorijs_element_jsx_runtime.jsx)("message", { children: content }));
848
848
  }, 1);
849
849
  this.logger.info(`成功推送动态消息群组/频道:${success}`);
850
850
  }
851
851
  if ((type === PushType.Live || type === PushType.StartBroadcasting) && record.liveArr?.length >= 1) {
852
852
  this.logger.info(record.liveArr);
853
+ const liveArr = structuredClone(record.liveArr);
853
854
  const success = await withRetry(async () => {
854
- return await this.ctx.broadcast(record.liveArr, /* @__PURE__ */ (0, __satorijs_element_jsx_runtime.jsx)("message", { children: content }));
855
+ return await this.ctx.broadcast(liveArr, /* @__PURE__ */ (0, __satorijs_element_jsx_runtime.jsx)("message", { children: content }));
855
856
  }, 1);
856
857
  this.logger.info(`成功推送直播消息群组/频道:${success}`);
857
858
  }
858
859
  if (type === PushType.LiveGuardBuy && record.liveGuardBuyArr?.length >= 1) {
859
860
  this.logger.info(record.liveGuardBuyArr);
861
+ const liveGuardBuyArr = structuredClone(record.liveGuardBuyArr);
860
862
  const success = await withRetry(async () => {
861
- return await this.ctx.broadcast(record.liveGuardBuyArr, /* @__PURE__ */ (0, __satorijs_element_jsx_runtime.jsx)("message", { children: content }));
863
+ return await this.ctx.broadcast(liveGuardBuyArr, /* @__PURE__ */ (0, __satorijs_element_jsx_runtime.jsx)("message", { children: content }));
862
864
  }, 1);
863
865
  this.logger.info(`成功推送上舰消息群组/频道:${success}`);
864
866
  }
@@ -912,15 +914,15 @@ var ComRegister = class {
912
914
  }, 1).catch(async (e$1) => {
913
915
  if (e$1.message === "直播开播动态,不做处理") return;
914
916
  if (e$1.message === "出现关键词,屏蔽该动态") {
915
- if (this.config.filter.notify) await this.broadcastToTargets(sub.uid, `${name$3}发布了一条含有屏蔽关键字的动态`, PushType.Dynamic);
917
+ if (this.config.filter.notify) await this.broadcastToTargets(sub.uid, /* @__PURE__ */ (0, __satorijs_element_jsx_runtime.jsxs)("message", { children: [name$3, "发布了一条含有屏蔽关键字的动态"] }), PushType.Dynamic);
916
918
  return;
917
919
  }
918
920
  if (e$1.message === "已屏蔽转发动态") {
919
- if (this.config.filter.notify) await this.broadcastToTargets(sub.uid, `${name$3}转发了一条动态,已屏蔽`, PushType.Dynamic);
921
+ if (this.config.filter.notify) await this.broadcastToTargets(sub.uid, /* @__PURE__ */ (0, __satorijs_element_jsx_runtime.jsxs)("message", { children: [name$3, "转发了一条动态,已屏蔽"] }), PushType.Dynamic);
920
922
  return;
921
923
  }
922
924
  if (e$1.message === "已屏蔽专栏动态") {
923
- if (this.config.filter.notify) await this.broadcastToTargets(sub.uid, `${name$3}投稿了一条专栏,已屏蔽`, PushType.Dynamic);
925
+ if (this.config.filter.notify) await this.broadcastToTargets(sub.uid, /* @__PURE__ */ (0, __satorijs_element_jsx_runtime.jsxs)("message", { children: [name$3, "投稿了一条专栏,已屏蔽"] }), PushType.Dynamic);
924
926
  return;
925
927
  }
926
928
  this.logger.error(`dynamicDetect generateDynamicImg() 推送卡片发送失败,原因:${e$1.message}`);
@@ -934,7 +936,7 @@ var ComRegister = class {
934
936
  } else dUrl = `${name$3}发布了新视频:https:${item.modules.module_dynamic.major.archive.jump_url}`;
935
937
  else dUrl = `${name$3}发布了一条动态:https://t.bilibili.com/${item.id_str}`;
936
938
  this.logger.info("推送动态中...");
937
- await this.broadcastToTargets(sub.uid, /* @__PURE__ */ (0, __satorijs_element_jsx_runtime.jsxs)(__satorijs_element_jsx_runtime.Fragment, { children: [koishi.h.image(buffer, "image/jpeg"), dUrl] }), PushType.Dynamic);
939
+ await this.broadcastToTargets(sub.uid, /* @__PURE__ */ (0, __satorijs_element_jsx_runtime.jsxs)("message", { children: [koishi.h.image(buffer, "image/jpeg"), dUrl] }), PushType.Dynamic);
938
940
  if (this.config.pushImgsInDynamic) {
939
941
  if (item.type === "DYNAMIC_TYPE_DRAW") {
940
942
  const pics = item.modules?.module_dynamic?.major?.opus?.pics;
@@ -1017,15 +1019,15 @@ var ComRegister = class {
1017
1019
  }, 1).catch(async (e$1) => {
1018
1020
  if (e$1.message === "直播开播动态,不做处理") return;
1019
1021
  if (e$1.message === "出现关键词,屏蔽该动态") {
1020
- if (this.config.filter.notify) await this.broadcastToTargets(sub.uid, `${name$3}发布了一条含有屏蔽关键字的动态`, PushType.Dynamic);
1022
+ if (this.config.filter.notify) await this.broadcastToTargets(sub.uid, /* @__PURE__ */ (0, __satorijs_element_jsx_runtime.jsxs)("message", { children: [name$3, "发布了一条含有屏蔽关键字的动态"] }), PushType.Dynamic);
1021
1023
  return;
1022
1024
  }
1023
1025
  if (e$1.message === "已屏蔽转发动态") {
1024
- if (this.config.filter.notify) await this.broadcastToTargets(sub.uid, `${name$3}转发了一条动态,已屏蔽`, PushType.Dynamic);
1026
+ if (this.config.filter.notify) await this.broadcastToTargets(sub.uid, /* @__PURE__ */ (0, __satorijs_element_jsx_runtime.jsxs)("message", { children: [name$3, "转发了一条动态,已屏蔽"] }), PushType.Dynamic);
1025
1027
  return;
1026
1028
  }
1027
1029
  if (e$1.message === "已屏蔽专栏动态") {
1028
- if (this.config.filter.notify) await this.broadcastToTargets(sub.uid, `${name$3}投稿了一条专栏,已屏蔽`, PushType.Dynamic);
1030
+ if (this.config.filter.notify) await this.broadcastToTargets(sub.uid, /* @__PURE__ */ (0, __satorijs_element_jsx_runtime.jsxs)("message", { children: [name$3, "投稿了一条专栏,已屏蔽"] }), PushType.Dynamic);
1029
1031
  return;
1030
1032
  }
1031
1033
  this.logger.error(`dynamicDetect generateDynamicImg() 推送卡片发送失败,原因:${e$1.message}`);
@@ -1044,7 +1046,7 @@ var ComRegister = class {
1044
1046
  this.logger.info("动态链接生成成功!");
1045
1047
  }
1046
1048
  this.logger.info("推送动态中...");
1047
- await this.broadcastToTargets(sub.uid, /* @__PURE__ */ (0, __satorijs_element_jsx_runtime.jsxs)(__satorijs_element_jsx_runtime.Fragment, { children: [koishi.h.image(buffer, "image/jpeg"), dUrl] }), PushType.Dynamic);
1049
+ await this.broadcastToTargets(sub.uid, /* @__PURE__ */ (0, __satorijs_element_jsx_runtime.jsxs)("message", { children: [koishi.h.image(buffer, "image/jpeg"), dUrl] }), PushType.Dynamic);
1048
1050
  if (this.config.pushImgsInDynamic) {
1049
1051
  this.logger.info("需要发送动态中的图片,开始发送...");
1050
1052
  if (item.type === "DYNAMIC_TYPE_DRAW") {
@@ -1116,7 +1118,7 @@ var ComRegister = class {
1116
1118
  this.logger.error(`liveDetect generateLiveImg() 推送卡片生成失败,原因:${e$1.message}`);
1117
1119
  });
1118
1120
  if (!buffer) return await this.sendPrivateMsgAndStopService();
1119
- const msg = /* @__PURE__ */ (0, __satorijs_element_jsx_runtime.jsxs)(__satorijs_element_jsx_runtime.Fragment, { children: [koishi.h.image(buffer, "image/jpeg"), liveNotifyMsg || ""] });
1121
+ const msg = /* @__PURE__ */ (0, __satorijs_element_jsx_runtime.jsxs)("message", { children: [koishi.h.image(buffer, "image/jpeg"), liveNotifyMsg || ""] });
1120
1122
  return await this.broadcastToTargets(uid, msg, liveType === LiveType.StartBroadcasting ? PushType.StartBroadcasting : PushType.Live);
1121
1123
  }
1122
1124
  async liveDetectWithListener(roomId, uid, cardStyle) {
@@ -1181,7 +1183,15 @@ var ComRegister = class {
1181
1183
  watchedNum = body.text_small;
1182
1184
  },
1183
1185
  onGuardBuy: ({ body }) => {
1184
- const content = `[${masterInfo.username}的直播间]「${body.user.uname}」加入了大航海(${body.gift_name})`;
1186
+ const content = /* @__PURE__ */ (0, __satorijs_element_jsx_runtime.jsxs)("message", { children: [
1187
+ "【",
1188
+ masterInfo.username,
1189
+ "的直播间】",
1190
+ body.user.uname,
1191
+ "加入了大航海(",
1192
+ body.gift_name,
1193
+ ")"
1194
+ ] });
1185
1195
  this.broadcastToTargets(uid, content, PushType.LiveGuardBuy);
1186
1196
  },
1187
1197
  onLiveStart: async () => {
@@ -1469,37 +1479,37 @@ var ComRegister = class {
1469
1479
  msg: "账号被封停,无法进行订阅操作"
1470
1480
  };
1471
1481
  },
1472
- [22002]: () => {
1482
+ 22002: () => {
1473
1483
  return {
1474
1484
  code: subUserData.code,
1475
1485
  msg: "因对方隐私设置,无法进行订阅操作"
1476
1486
  };
1477
1487
  },
1478
- [22003]: () => {
1488
+ 22003: () => {
1479
1489
  return {
1480
1490
  code: subUserData.code,
1481
1491
  msg: "你已将对方拉黑,无法进行订阅操作"
1482
1492
  };
1483
1493
  },
1484
- [22013]: () => {
1494
+ 22013: () => {
1485
1495
  return {
1486
1496
  code: subUserData.code,
1487
1497
  msg: "账号已注销,无法进行订阅操作"
1488
1498
  };
1489
1499
  },
1490
- [40061]: () => {
1500
+ 40061: () => {
1491
1501
  return {
1492
1502
  code: subUserData.code,
1493
1503
  msg: "账号不存在,请检查uid输入是否正确或用户是否存在"
1494
1504
  };
1495
1505
  },
1496
- [22001]: () => {
1506
+ 22001: () => {
1497
1507
  return {
1498
1508
  code: 0,
1499
1509
  msg: "订阅对象为自己,无需添加到分组"
1500
1510
  };
1501
1511
  },
1502
- [22014]: async () => {
1512
+ 22014: async () => {
1503
1513
  const copyUserToGroupData = await this.ctx.ba.copyUserToGroup(mid, this.loginDBData.dynamic_group_id);
1504
1514
  if (copyUserToGroupData.code !== 0) return {
1505
1515
  code: copyUserToGroupData.code,
@@ -1510,7 +1520,7 @@ var ComRegister = class {
1510
1520
  msg: "订阅对象添加成功"
1511
1521
  };
1512
1522
  },
1513
- [0]: async () => {
1523
+ 0: async () => {
1514
1524
  const copyUserToGroupData = await this.ctx.ba.copyUserToGroup(mid, this.loginDBData.dynamic_group_id);
1515
1525
  if (copyUserToGroupData.code !== 0) return {
1516
1526
  code: copyUserToGroupData.code,
@@ -1584,7 +1594,7 @@ var ComRegister = class {
1584
1594
  }
1585
1595
  }
1586
1596
  enableDynamicDetect() {
1587
- this.dynamicJob = new cron.CronJob("*/2 * * * *", this.config.dynamicDebugMode ? this.debug_dynamicDetect() : this.dynamicDetect());
1597
+ this.dynamicJob = new cron.CronJob(this.config.dynamicCron, this.config.dynamicDebugMode ? this.debug_dynamicDetect() : this.dynamicDetect());
1588
1598
  this.logger.info("动态监测已开启");
1589
1599
  this.dynamicJob.start();
1590
1600
  }
@@ -1640,6 +1650,7 @@ var ComRegister = class {
1640
1650
  customLive: koishi.Schema.string(),
1641
1651
  customLiveEnd: koishi.Schema.string().required(),
1642
1652
  dynamicUrl: koishi.Schema.boolean().required(),
1653
+ dynamicCron: koishi.Schema.string().required(),
1643
1654
  dynamicVideoUrlToBV: koishi.Schema.boolean().required(),
1644
1655
  filter: koishi.Schema.object({
1645
1656
  enable: koishi.Schema.boolean(),
@@ -58056,7 +58067,7 @@ var require_helpers$1 = __commonJS$1({ "node_modules/socks/build/common/helpers.
58056
58067
  }
58057
58068
  function ipv4ToInt32(ip) {
58058
58069
  const address = new ip_address_1$1.Address4(ip);
58059
- return address.toArray().reduce((acc, part) => (acc << 8) + part, 0);
58070
+ return address.toArray().reduce((acc, part) => (acc << 8) + part, 0) >>> 0;
58060
58071
  }
58061
58072
  exports.ipv4ToInt32 = ipv4ToInt32;
58062
58073
  function int32ToIpv4(int32) {
@@ -80276,6 +80287,7 @@ var require_once = __commonJS$1({ "node_modules/once/once.js"(exports, module) {
80276
80287
  var require_end_of_stream = __commonJS$1({ "node_modules/end-of-stream/index.js"(exports, module) {
80277
80288
  var once$1 = require_once();
80278
80289
  var noop$5 = function() {};
80290
+ var qnt = global.Bare ? queueMicrotask : process.nextTick.bind(process);
80279
80291
  var isRequest$1 = function(stream$3) {
80280
80292
  return stream$3.setHeader && typeof stream$3.abort === "function";
80281
80293
  };
@@ -80309,7 +80321,7 @@ var require_end_of_stream = __commonJS$1({ "node_modules/end-of-stream/index.js"
80309
80321
  callback.call(stream$3, err);
80310
80322
  };
80311
80323
  var onclose = function() {
80312
- process.nextTick(onclosenexttick);
80324
+ qnt(onclosenexttick);
80313
80325
  };
80314
80326
  var onclosenexttick = function() {
80315
80327
  if (cancelled) return;
@@ -80361,7 +80373,7 @@ var require_pump = __commonJS$1({ "node_modules/pump/index.js"(exports, module)
80361
80373
  fs$7 = require("fs");
80362
80374
  } catch (e$1) {}
80363
80375
  var noop$4 = function() {};
80364
- var ancient = /^v?\.0/.test(process.version);
80376
+ var ancient = typeof process === "undefined" ? false : /^v?\.0/.test(process.version);
80365
80377
  var isFn = function(fn) {
80366
80378
  return typeof fn === "function";
80367
80379
  };
@@ -83943,7 +83955,7 @@ var require_tar_fs = __commonJS$1({ "node_modules/tar-fs/index.js"(exports) {
83943
83955
  const pump = require_pump();
83944
83956
  const fs$3 = require("fs");
83945
83957
  const path$4 = require("path");
83946
- const win32$1 = (global.Bare?.platform || process.platform) === "win32";
83958
+ const win32$1 = (global.Bare ? global.Bare.platform : process.platform) === "win32";
83947
83959
  exports.pack = function pack(cwd, opts) {
83948
83960
  if (!cwd) cwd = ".";
83949
83961
  if (!opts) opts = {};
@@ -84029,10 +84041,10 @@ var require_tar_fs = __commonJS$1({ "node_modules/tar-fs/index.js"(exports) {
84029
84041
  return list.length ? list[list.length - 1] : null;
84030
84042
  }
84031
84043
  function processGetuid() {
84032
- return process.getuid ? process.getuid() : -1;
84044
+ return !global.Bare && process.getuid ? process.getuid() : -1;
84033
84045
  }
84034
84046
  function processUmask() {
84035
- return process.umask ? process.umask() : 0;
84047
+ return !global.Bare && process.umask ? process.umask() : 0;
84036
84048
  }
84037
84049
  exports.extract = function extract(cwd, opts) {
84038
84050
  if (!cwd) cwd = ".";
@@ -94636,7 +94648,7 @@ var BiliAPI = class extends koishi.Service {
94636
94648
  cookies,
94637
94649
  refresh_token: decryptedRefreshToken
94638
94650
  };
94639
- } catch (e$1) {
94651
+ } catch (_$2) {
94640
94652
  this.loginNotifier = this.ctx.notifier.create({
94641
94653
  type: "warning",
94642
94654
  content: "数据库被篡改,请重新登录"
@@ -94725,7 +94737,7 @@ var BiliAPI = class extends koishi.Service {
94725
94737
  try {
94726
94738
  const { data: data$1 } = await this.getCookieInfo(refreshToken);
94727
94739
  if (!data$1.refresh) return;
94728
- } catch (e$1) {
94740
+ } catch (_$2) {
94729
94741
  if (times$1 >= 1) this.ctx.setTimeout(() => {
94730
94742
  this.checkIfTokenNeedRefresh(refreshToken, csrf, times$1 - 1);
94731
94743
  }, 3e3);
@@ -95031,6 +95043,7 @@ var ServerManager = class extends koishi.Service {
95031
95043
  customLive: globalConfig.customLive,
95032
95044
  customLiveEnd: globalConfig.customLiveEnd,
95033
95045
  dynamicUrl: globalConfig.dynamicUrl,
95046
+ dynamicCron: globalConfig.dynamicCron,
95034
95047
  dynamicVideoUrlToBV: globalConfig.dynamicVideoUrlToBV,
95035
95048
  filter: globalConfig.filter,
95036
95049
  dynamicDebugMode: globalConfig.dynamicDebugMode
@@ -95128,6 +95141,7 @@ const Config = koishi.Schema.object({
95128
95141
  }).collapse()).collapse().description("输入订阅信息,自定义订阅内容; uid: 订阅用户UID,dynamic: 是否需要订阅动态,live: 是否需要订阅直播"),
95129
95142
  dynamic: koishi.Schema.object({}).description("动态推送设置"),
95130
95143
  dynamicUrl: koishi.Schema.boolean().default(false).description("发送动态时是否同时发送链接。注意:如果使用的是QQ官方机器人不能开启此项!"),
95144
+ dynamicCron: koishi.Schema.string().default("*/2 * * * *").description("动态监测时间,请填入cron表达式,请勿填入过短时间"),
95131
95145
  dynamicVideoUrlToBV: koishi.Schema.boolean().default(false).description("如果推送的动态是视频动态,且开启了发送链接选项,开启此选项则会将链接转换为BV号以便其他用途"),
95132
95146
  pushImgsInDynamic: koishi.Schema.boolean().default(false).description("是否推送动态中的图片,默认不开启。开启后会单独推送动态中的图片,该功能容易导致QQ风控"),
95133
95147
  live: koishi.Schema.object({}).description("直播推送设置"),