koishi-plugin-bilibili-notify 3.7.0 → 3.7.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.
Files changed (3) hide show
  1. package/lib/index.cjs +452 -435
  2. package/lib/index.mjs +452 -435
  3. package/package.json +1 -1
package/lib/index.cjs CHANGED
@@ -46,12 +46,12 @@ require("koishi-plugin-puppeteer");
46
46
  let luxon = require("luxon");
47
47
  let node_url = require("node:url");
48
48
  let blive_message_listener = require("blive-message-listener");
49
- let cron = require("cron");
50
49
  require("@koishijs/plugin-help");
51
50
  let _node_rs_jieba = require("@node-rs/jieba");
52
51
  let _node_rs_jieba_dict = require("@node-rs/jieba/dict");
53
52
  let qrcode = require("qrcode");
54
53
  qrcode = __toESM(qrcode);
54
+ let cron = require("cron");
55
55
  let md5 = require("md5");
56
56
  md5 = __toESM(md5);
57
57
  let node_crypto = require("node:crypto");
@@ -1585,157 +1585,6 @@ var BilibiliNotifyDataServer = class extends _koishijs_plugin_console.DataServic
1585
1585
  }
1586
1586
  };
1587
1587
 
1588
- //#endregion
1589
- //#region src/core/dynamic.ts
1590
- var BilibiliNotifyDynamic = class extends koishi.Service {
1591
- static inject = [
1592
- "bilibili-notify-api",
1593
- "bilibili-notify-generate-img",
1594
- "bilibili-notify-push"
1595
- ];
1596
- dynamicJob;
1597
- dynamicTimelineManager;
1598
- constructor(ctx, config) {
1599
- super(ctx, "bilibili-notify-dynamic");
1600
- this.config = config;
1601
- }
1602
- start() {
1603
- this.dynamicTimelineManager = /* @__PURE__ */ new Map();
1604
- }
1605
- stop() {
1606
- if (this.dynamicJob) {
1607
- this.dynamicJob.stop();
1608
- this.logger.info("动态检测任务已停止");
1609
- }
1610
- }
1611
- startDynamicDetector() {
1612
- if (this.dynamicJob) {
1613
- this.logger.warn("动态检测任务已存在,跳过创建新的任务");
1614
- return;
1615
- }
1616
- this.dynamicJob = new cron.CronJob(this.config.dynamicCron, this.dynamicDetector());
1617
- this.dynamicJob.start();
1618
- this.logger.info("动态检测任务已启动");
1619
- }
1620
- dynamicDetector() {
1621
- const handler = async () => {
1622
- const currentPushDyn = {};
1623
- this.logger.debug(`开始获取动态信息`);
1624
- const content = await withRetry(async () => {
1625
- return await this.ctx["bilibili-notify-api"].getAllDynamic();
1626
- }, 1).catch((e) => {
1627
- this.logger.error(`获取动态失败:${e.message}`);
1628
- });
1629
- if (!content) return;
1630
- if (content.code !== 0) switch (content.code) {
1631
- case -101:
1632
- this.logger.error(`账号未登录,插件已停止工作,请先登录`);
1633
- await this.ctx["bilibili-notify-push"].sendPrivateMsg(`账号未登录,插件已停止工作,请先登录`);
1634
- await this.ctx["bilibili-notify"].disposePlugin();
1635
- break;
1636
- case -352:
1637
- this.logger.error("账号被风控,插件已停止工作,请使用 `bili cap` 指令解除风控");
1638
- await this.ctx["bilibili-notify-push"].sendPrivateMsg("账号被风控,插件已停止工作,请使用 `bili cap` 指令解除风控");
1639
- await this.ctx["bilibili-notify"].disposePlugin();
1640
- break;
1641
- default:
1642
- this.logger.error(`获取动态信息失败,错误码:${content.code},错误信息:${content.message}`);
1643
- await this.ctx["bilibili-notify-push"].sendPrivateMsg(`获取动态信息失败,错误码:${content.code}`);
1644
- await this.ctx["bilibili-notify"].disposePlugin();
1645
- break;
1646
- }
1647
- this.logger.debug("成功获取动态信息,开始处理");
1648
- const items = content.data.items;
1649
- for (const item of items) {
1650
- if (!item) continue;
1651
- const postTime = item.modules.module_author.pub_ts;
1652
- const uid = item.modules.module_author.mid.toString();
1653
- const name$2 = item.modules.module_author.name;
1654
- this.logger.debug(`获取动态信息:UP主=${name$2}, UID=${uid}, 发布时间=${luxon.DateTime.fromSeconds(postTime).toFormat("yyyy-MM-dd HH:mm:ss")}`);
1655
- if (this.dynamicTimelineManager.has(uid)) {
1656
- this.logger.debug("已订阅该UP主,检查动态时间线");
1657
- const timeline = this.dynamicTimelineManager.get(uid);
1658
- this.logger.debug(`上次推送时间线:${luxon.DateTime.fromSeconds(timeline).toFormat("yyyy-MM-dd HH:mm:ss")}`);
1659
- if (timeline < postTime) {
1660
- this.logger.debug("该动态需要推送");
1661
- const sub = this.ctx["bilibili-notify-push"].subManager.get(uid);
1662
- this.logger.debug("开始渲染推送卡片");
1663
- const buffer = await withRetry(async () => {
1664
- return await this.ctx["bilibili-notify-generate-img"].generateDynamicImg(item, sub.customCardStyle.enable ? sub.customCardStyle : void 0);
1665
- }, 1).catch(async (e) => {
1666
- if (e.message === "直播开播动态,不做处理") return;
1667
- if (e.message === "出现关键词,屏蔽该动态") {
1668
- if (this.config.filter.notify) await this.ctx["bilibili-notify-push"].broadcastToTargets(uid, (0, koishi.h)("message", `${name$2}发布了一条含有屏蔽关键字的动态`), PushType.Dynamic);
1669
- return;
1670
- }
1671
- if (e.message === "已屏蔽转发动态") {
1672
- if (this.config.filter.notify) await this.ctx["bilibili-notify-push"].broadcastToTargets(uid, (0, koishi.h)("message", `${name$2}转发了一条动态,已屏蔽`), PushType.Dynamic);
1673
- return;
1674
- }
1675
- if (e.message === "已屏蔽专栏动态") {
1676
- if (this.config.filter.notify) await this.ctx["bilibili-notify-push"].broadcastToTargets(uid, (0, koishi.h)("message", `${name$2}投稿了一条专栏,已屏蔽`), PushType.Dynamic);
1677
- return;
1678
- }
1679
- this.logger.error(`生成动态图片失败:${e.message}`);
1680
- await this.ctx["bilibili-notify-push"].sendPrivateMsgAndStopService();
1681
- });
1682
- if (!buffer) continue;
1683
- this.logger.debug("渲染推送卡片成功");
1684
- let dUrl = "";
1685
- if (this.config.dynamicUrl) {
1686
- this.logger.debug("生成动态链接");
1687
- if (item.type === "DYNAMIC_TYPE_AV") if (this.config.dynamicVideoUrlToBV) {
1688
- const bv = item.modules.module_dynamic.major.archive.jump_url.match(/BV[0-9A-Za-z]+/);
1689
- dUrl = bv ? bv[0] : "";
1690
- } else dUrl = `${name$2}发布了新视频:https:${item.modules.module_dynamic.major.archive.jump_url}`;
1691
- else dUrl = `${name$2}发布了一条动态:https://t.bilibili.com/${item.id_str}`;
1692
- this.logger.debug("生成动态链接成功");
1693
- }
1694
- this.logger.debug("推送动态");
1695
- await this.ctx["bilibili-notify-push"].broadcastToTargets(uid, (0, koishi.h)("message", [koishi.h.image(buffer, "image/jpeg"), koishi.h.text(dUrl)]), PushType.Dynamic);
1696
- if (this.config.pushImgsInDynamic) {
1697
- this.logger.debug("发送动态中的图片");
1698
- if (item.type === "DYNAMIC_TYPE_DRAW") {
1699
- const pics = item.modules?.module_dynamic?.major?.opus?.pics;
1700
- if (pics) {
1701
- const picsMsg = (0, koishi.h)("message", { forward: true }, pics.map((pic) => koishi.h.img(pic.url)));
1702
- await this.ctx["bilibili-notify-push"].broadcastToTargets(uid, picsMsg, PushType.Dynamic);
1703
- }
1704
- }
1705
- this.logger.debug("动态中的图片发送完毕");
1706
- }
1707
- if (!currentPushDyn[uid]) currentPushDyn[uid] = item;
1708
- this.logger.debug("动态推送完成");
1709
- }
1710
- }
1711
- }
1712
- this.logger.debug("动态信息处理完毕");
1713
- for (const uid in currentPushDyn) {
1714
- const postTime = currentPushDyn[uid].modules.module_author.pub_ts;
1715
- this.dynamicTimelineManager.set(uid, postTime);
1716
- this.logger.debug(`更新时间线:UP主=${uid}, 时间线=${luxon.DateTime.fromSeconds(postTime).toFormat("yyyy-MM-dd HH:mm:ss")}`);
1717
- }
1718
- this.logger.debug(`推送的动态数量:${Object.keys(currentPushDyn).length} 条`);
1719
- };
1720
- return withLock(handler);
1721
- }
1722
- };
1723
- (function(_BilibiliNotifyDynamic) {
1724
- _BilibiliNotifyDynamic.Config = koishi.Schema.object({
1725
- filter: koishi.Schema.object({
1726
- enable: koishi.Schema.boolean(),
1727
- notify: koishi.Schema.boolean(),
1728
- regex: koishi.Schema.string(),
1729
- keywords: koishi.Schema.array(String)
1730
- }),
1731
- dynamicUrl: koishi.Schema.boolean().required(),
1732
- dynamicCron: koishi.Schema.string().required(),
1733
- dynamicVideoUrlToBV: koishi.Schema.boolean().required(),
1734
- pushImgsInDynamic: koishi.Schema.boolean().required()
1735
- });
1736
- })(BilibiliNotifyDynamic || (BilibiliNotifyDynamic = {}));
1737
- var dynamic_default = BilibiliNotifyDynamic;
1738
-
1739
1588
  //#endregion
1740
1589
  //#region src/stop_words.ts
1741
1590
  const stopwords = new Set([
@@ -2832,17 +2681,10 @@ var BilibiliNotifyCore = class extends koishi.Service {
2832
2681
  await this.ctx["bilibili-notify-push"].sendPrivateMsg("加载订阅对象失败,插件初始化失败");
2833
2682
  return;
2834
2683
  }
2835
- this.initManagerAfterLoadSub();
2836
- this.checkIfDynamicDetectIsNeeded();
2684
+ this.ctx["bilibili-notify-dynamic"].startDynamicDetector(this.subManager);
2837
2685
  this.updateSubNotifier();
2838
2686
  this.logger.info("插件初始化完成");
2839
2687
  }
2840
- checkIfDynamicDetectIsNeeded() {
2841
- if (this.ctx["bilibili-notify-dynamic"].dynamicTimelineManager.size > 0) this.ctx["bilibili-notify-dynamic"].startDynamicDetector();
2842
- }
2843
- initManagerAfterLoadSub() {
2844
- for (const [uid, sub] of this.subManager) if (sub.dynamic) this.ctx["bilibili-notify-dynamic"].dynamicTimelineManager.set(uid, Math.floor(luxon.DateTime.now().toSeconds()));
2845
- }
2846
2688
  configSubsToSubscription(sub) {
2847
2689
  const subs = {};
2848
2690
  sub.forEach((s) => {
@@ -3151,109 +2993,451 @@ var BilibiliNotifyCore = class extends koishi.Service {
3151
2993
  var core_default = BilibiliNotifyCore;
3152
2994
 
3153
2995
  //#endregion
3154
- //#region src/api.ts
3155
- const mixinKeyEncTab = [
3156
- 46,
3157
- 47,
3158
- 18,
3159
- 2,
3160
- 53,
3161
- 8,
3162
- 23,
3163
- 32,
3164
- 15,
3165
- 50,
3166
- 10,
3167
- 31,
3168
- 58,
3169
- 3,
3170
- 45,
3171
- 35,
3172
- 27,
3173
- 43,
3174
- 5,
3175
- 49,
3176
- 33,
3177
- 9,
3178
- 42,
3179
- 19,
3180
- 29,
3181
- 28,
3182
- 14,
3183
- 39,
3184
- 12,
3185
- 38,
3186
- 41,
3187
- 13,
3188
- 37,
3189
- 48,
3190
- 7,
3191
- 16,
3192
- 24,
3193
- 55,
3194
- 40,
3195
- 61,
3196
- 26,
3197
- 17,
3198
- 0,
3199
- 1,
3200
- 60,
3201
- 51,
3202
- 30,
3203
- 4,
3204
- 22,
3205
- 25,
3206
- 54,
3207
- 21,
3208
- 56,
3209
- 59,
3210
- 6,
3211
- 63,
3212
- 57,
3213
- 62,
3214
- 11,
3215
- 36,
3216
- 20,
3217
- 34,
3218
- 44,
3219
- 52
3220
- ];
3221
- const bangumiTripData = {
3222
- code: 0,
3223
- data: { live_room: { roomid: 931774 } }
3224
- };
3225
- const GET_USER_SPACE_DYNAMIC_LIST = "https://api.bilibili.com/x/polymer/web-dynamic/v1/feed/space?platform=web&features=itemOpusStyle";
3226
- const GET_ALL_DYNAMIC_LIST = "https://api.bilibili.com/x/polymer/web-dynamic/v1/feed/all?platform=web&features=itemOpusStyle";
3227
- const HAS_NEW_DYNAMIC = "https://api.bilibili.com/x/polymer/web-dynamic/v1/feed/all/update";
3228
- const GET_COOKIES_INFO = "https://passport.bilibili.com/x/passport-login/web/cookie/info";
3229
- const GET_USER_INFO = "https://api.bilibili.com/x/space/wbi/acc/info";
3230
- const GET_MYSELF_INFO = "https://api.bilibili.com/x/member/web/account";
3231
- const GET_LOGIN_QRCODE = "https://passport.bilibili.com/x/passport-login/web/qrcode/generate";
3232
- const GET_LOGIN_STATUS = "https://passport.bilibili.com/x/passport-login/web/qrcode/poll";
3233
- const GET_LIVE_ROOM_INFO = "https://api.live.bilibili.com/room/v1/Room/get_info";
3234
- const GET_MASTER_INFO = "https://api.live.bilibili.com/live_user/v1/Master/info";
3235
- const GET_TIME_NOW = "https://api.bilibili.com/x/report/click/now";
3236
- const GET_SERVER_UTC_TIME = "https://interface.bilibili.com/serverdate.js";
3237
- const GET_USER_CARD_INFO = "https://api.bilibili.com/x/web-interface/card";
3238
- const GET_LATEST_UPDATED_UPS = "https://api.bilibili.com/x/polymer/web-dynamic/v1/portal";
3239
- const GET_ONLINE_GOLD_RANK = "https://api.live.bilibili.com//xlive/general-interface/v1/rank/getOnlineGoldRank";
3240
- const GET_USER_INFO_IN_LIVE = "https://api.live.bilibili.com/xlive/app-ucenter/v2/card/user";
3241
- const MODIFY_RELATION = "https://api.bilibili.com/x/relation/modify";
3242
- const CREATE_GROUP = "https://api.bilibili.com/x/relation/tag/create";
3243
- const MODIFY_GROUP_MEMBER = "https://api.bilibili.com/x/relation/tags/addUsers";
3244
- const GET_ALL_GROUP = "https://api.bilibili.com/x/relation/tags";
3245
- const COPY_USER_TO_GROUP = "https://api.bilibili.com/x/relation/tags/copyUsers";
3246
- const GET_RELATION_GROUP_DETAIL = "https://api.bilibili.com/x/relation/tag";
3247
- const GET_LIVE_ROOM_INFO_STREAM_KEY = "https://api.live.bilibili.com/xlive/web-room/v1/index/getDanmuInfo";
3248
- const GET_LIVE_ROOMS_INFO = "https://api.live.bilibili.com/room/v1/Room/get_status_info_by_uids";
3249
- var BilibiliNotifyAPI = class extends koishi.Service {
3250
- static inject = ["database", "notifier"];
3251
- jar;
3252
- client;
3253
- aiClient;
3254
- cacheable;
3255
- loginData;
3256
- loginNotifier;
2996
+ //#region src/core/dynamic.ts
2997
+ var BilibiliNotifyDynamic = class extends koishi.Service {
2998
+ static inject = [
2999
+ "bilibili-notify-api",
3000
+ "bilibili-notify-generate-img",
3001
+ "bilibili-notify-push"
3002
+ ];
3003
+ dynamicJob;
3004
+ dynamicSubManager;
3005
+ dynamicTimelineManager;
3006
+ constructor(ctx, config) {
3007
+ super(ctx, "bilibili-notify-dynamic");
3008
+ this.config = config;
3009
+ this.logger.level = config.logLevel;
3010
+ }
3011
+ start() {
3012
+ this.dynamicTimelineManager = /* @__PURE__ */ new Map();
3013
+ }
3014
+ stop() {
3015
+ if (this.dynamicJob) {
3016
+ this.dynamicJob.stop();
3017
+ this.logger.info("动态检测任务已停止");
3018
+ }
3019
+ }
3020
+ startDynamicDetector(subManager) {
3021
+ if (this.dynamicJob) {
3022
+ this.logger.warn("动态检测任务已存在,跳过创建新的任务");
3023
+ return;
3024
+ }
3025
+ if (subManager.size === 0) {
3026
+ this.logger.warn("没有订阅对象,跳过创建动态检测任务");
3027
+ return;
3028
+ }
3029
+ const dynamicSubManager = /* @__PURE__ */ new Map();
3030
+ for (const [uid, sub] of subManager) if (sub.dynamic) {
3031
+ this.dynamicTimelineManager.set(uid, Math.floor(luxon.DateTime.now().toSeconds()));
3032
+ dynamicSubManager.set(uid, sub);
3033
+ }
3034
+ this.dynamicSubManager = dynamicSubManager;
3035
+ this.dynamicJob = new cron.CronJob(this.config.dynamicCron, this.dynamicDetector());
3036
+ this.dynamicJob.start();
3037
+ this.logger.info("动态检测任务已启动");
3038
+ }
3039
+ dynamicDetector() {
3040
+ const handler = async () => {
3041
+ const currentPushDyn = {};
3042
+ this.logger.debug(`开始获取动态信息`);
3043
+ const content = await withRetry(async () => {
3044
+ return await this.ctx["bilibili-notify-api"].getAllDynamic();
3045
+ }, 1).catch((e) => {
3046
+ this.logger.error(`获取动态失败:${e.message}`);
3047
+ });
3048
+ if (!content) return;
3049
+ if (content.code !== 0) switch (content.code) {
3050
+ case -101:
3051
+ this.logger.error(`账号未登录,插件已停止工作,请先登录`);
3052
+ await this.ctx["bilibili-notify-push"].sendPrivateMsg(`账号未登录,插件已停止工作,请先登录`);
3053
+ await this.ctx["bilibili-notify"].disposePlugin();
3054
+ break;
3055
+ case -352:
3056
+ this.logger.error("账号被风控,插件已停止工作,请使用 `bili cap` 指令解除风控");
3057
+ await this.ctx["bilibili-notify-push"].sendPrivateMsg("账号被风控,插件已停止工作,请使用 `bili cap` 指令解除风控");
3058
+ await this.ctx["bilibili-notify"].disposePlugin();
3059
+ break;
3060
+ default:
3061
+ this.logger.error(`获取动态信息失败,错误码:${content.code},错误信息:${content.message}`);
3062
+ await this.ctx["bilibili-notify-push"].sendPrivateMsg(`获取动态信息失败,错误码:${content.code}`);
3063
+ await this.ctx["bilibili-notify"].disposePlugin();
3064
+ break;
3065
+ }
3066
+ this.logger.debug("成功获取动态信息,开始处理");
3067
+ const items = content.data.items;
3068
+ for (const item of items) {
3069
+ if (!item) continue;
3070
+ const postTime = item.modules.module_author.pub_ts;
3071
+ const uid = item.modules.module_author.mid.toString();
3072
+ const name$2 = item.modules.module_author.name;
3073
+ this.logger.debug(`获取动态信息:UP主=${name$2}, UID=${uid}, 发布时间=${luxon.DateTime.fromSeconds(postTime).toFormat("yyyy-MM-dd HH:mm:ss")}`);
3074
+ if (this.dynamicTimelineManager.has(uid)) {
3075
+ this.logger.debug("已订阅该UP主,检查动态时间线");
3076
+ const timeline = this.dynamicTimelineManager.get(uid);
3077
+ this.logger.debug(`上次推送时间线:${luxon.DateTime.fromSeconds(timeline).toFormat("yyyy-MM-dd HH:mm:ss")}`);
3078
+ if (timeline < postTime) {
3079
+ this.logger.debug("该动态需要推送");
3080
+ const sub = this.dynamicSubManager.get(uid);
3081
+ this.logger.debug("开始渲染推送卡片");
3082
+ const buffer = await withRetry(async () => {
3083
+ return await this.ctx["bilibili-notify-generate-img"].generateDynamicImg(item, sub.customCardStyle.enable ? sub.customCardStyle : void 0);
3084
+ }, 1).catch(async (e) => {
3085
+ if (e.message === "直播开播动态,不做处理") return;
3086
+ if (e.message === "出现关键词,屏蔽该动态") {
3087
+ if (this.config.filter.notify) await this.ctx["bilibili-notify-push"].broadcastToTargets(uid, (0, koishi.h)("message", `${name$2}发布了一条含有屏蔽关键字的动态`), PushType.Dynamic);
3088
+ return;
3089
+ }
3090
+ if (e.message === "已屏蔽转发动态") {
3091
+ if (this.config.filter.notify) await this.ctx["bilibili-notify-push"].broadcastToTargets(uid, (0, koishi.h)("message", `${name$2}转发了一条动态,已屏蔽`), PushType.Dynamic);
3092
+ return;
3093
+ }
3094
+ if (e.message === "已屏蔽专栏动态") {
3095
+ if (this.config.filter.notify) await this.ctx["bilibili-notify-push"].broadcastToTargets(uid, (0, koishi.h)("message", `${name$2}投稿了一条专栏,已屏蔽`), PushType.Dynamic);
3096
+ return;
3097
+ }
3098
+ this.logger.error(`生成动态图片失败:${e.message}`);
3099
+ await this.ctx["bilibili-notify-push"].sendPrivateMsgAndStopService();
3100
+ });
3101
+ if (!buffer) continue;
3102
+ this.logger.debug("渲染推送卡片成功");
3103
+ let dUrl = "";
3104
+ if (this.config.dynamicUrl) {
3105
+ this.logger.debug("生成动态链接");
3106
+ if (item.type === "DYNAMIC_TYPE_AV") if (this.config.dynamicVideoUrlToBV) {
3107
+ const bv = item.modules.module_dynamic.major.archive.jump_url.match(/BV[0-9A-Za-z]+/);
3108
+ dUrl = bv ? bv[0] : "";
3109
+ } else dUrl = `${name$2}发布了新视频:https:${item.modules.module_dynamic.major.archive.jump_url}`;
3110
+ else dUrl = `${name$2}发布了一条动态:https://t.bilibili.com/${item.id_str}`;
3111
+ this.logger.debug("生成动态链接成功");
3112
+ }
3113
+ this.logger.debug("推送动态");
3114
+ await this.ctx["bilibili-notify-push"].broadcastToTargets(uid, (0, koishi.h)("message", [koishi.h.image(buffer, "image/jpeg"), koishi.h.text(dUrl)]), PushType.Dynamic);
3115
+ if (this.config.pushImgsInDynamic) {
3116
+ this.logger.debug("发送动态中的图片");
3117
+ if (item.type === "DYNAMIC_TYPE_DRAW") {
3118
+ const pics = item.modules?.module_dynamic?.major?.opus?.pics;
3119
+ if (pics) {
3120
+ const picsMsg = (0, koishi.h)("message", { forward: true }, pics.map((pic) => koishi.h.img(pic.url)));
3121
+ await this.ctx["bilibili-notify-push"].broadcastToTargets(uid, picsMsg, PushType.Dynamic);
3122
+ }
3123
+ }
3124
+ this.logger.debug("动态中的图片发送完毕");
3125
+ }
3126
+ if (!currentPushDyn[uid]) currentPushDyn[uid] = item;
3127
+ this.logger.debug("动态推送完成");
3128
+ }
3129
+ }
3130
+ }
3131
+ this.logger.debug("动态信息处理完毕");
3132
+ for (const uid in currentPushDyn) {
3133
+ const postTime = currentPushDyn[uid].modules.module_author.pub_ts;
3134
+ this.dynamicTimelineManager.set(uid, postTime);
3135
+ this.logger.debug(`更新时间线:UP主=${uid}, 时间线=${luxon.DateTime.fromSeconds(postTime).toFormat("yyyy-MM-dd HH:mm:ss")}`);
3136
+ }
3137
+ this.logger.debug(`推送的动态数量:${Object.keys(currentPushDyn).length} 条`);
3138
+ };
3139
+ return withLock(handler);
3140
+ }
3141
+ };
3142
+ (function(_BilibiliNotifyDynamic) {
3143
+ _BilibiliNotifyDynamic.Config = koishi.Schema.object({
3144
+ logLevel: koishi.Schema.number().required(),
3145
+ filter: koishi.Schema.object({
3146
+ enable: koishi.Schema.boolean(),
3147
+ notify: koishi.Schema.boolean(),
3148
+ regex: koishi.Schema.string(),
3149
+ keywords: koishi.Schema.array(String)
3150
+ }),
3151
+ dynamicUrl: koishi.Schema.boolean().required(),
3152
+ dynamicCron: koishi.Schema.string().required(),
3153
+ dynamicVideoUrlToBV: koishi.Schema.boolean().required(),
3154
+ pushImgsInDynamic: koishi.Schema.boolean().required()
3155
+ });
3156
+ })(BilibiliNotifyDynamic || (BilibiliNotifyDynamic = {}));
3157
+ var dynamic_default = BilibiliNotifyDynamic;
3158
+
3159
+ //#endregion
3160
+ //#region src/core/push.ts
3161
+ var BilibiliNotifyPush = class extends koishi.Service {
3162
+ privateBot;
3163
+ rebootCount = 0;
3164
+ pushArrMapInitializing = false;
3165
+ pushArrMap;
3166
+ constructor(ctx, config) {
3167
+ super(ctx, "bilibili-notify-push");
3168
+ this.config = config;
3169
+ this.logger.level = config.logLevel;
3170
+ }
3171
+ start() {
3172
+ this.privateBot = this.ctx.bots.find((bot) => bot.platform === this.config.master.platform);
3173
+ if (!this.privateBot) this.ctx.notifier.create({ content: "未配置管理员账号,无法推送插件运行状态,请尽快配置" });
3174
+ }
3175
+ getBot(pf, selfId) {
3176
+ if (!selfId || selfId === "") return this.ctx.bots.find((bot) => bot.platform === pf);
3177
+ return this.ctx.bots.find((bot) => bot.platform === pf && bot.selfId === selfId);
3178
+ }
3179
+ async sendPrivateMsg(content) {
3180
+ if (this.config.master.enable) {
3181
+ if (this.privateBot?.status !== koishi.Universal.Status.ONLINE) {
3182
+ this.logger.warn(`${this.privateBot.platform} 机器人未初始化,暂时无法推送`);
3183
+ return;
3184
+ }
3185
+ if (this.config.master.masterAccountGuildId) await this.privateBot.sendPrivateMessage(this.config.master.masterAccount, content, this.config.master.masterAccountGuildId);
3186
+ else await this.privateBot.sendPrivateMessage(this.config.master.masterAccount, content);
3187
+ }
3188
+ }
3189
+ async sendPrivateMsgAndRebootService() {
3190
+ if (this.rebootCount >= 3) {
3191
+ this.logger.error("已重启插件3次,请检查机器人状态后使用 `bn start` 启动插件");
3192
+ await this.sendPrivateMsg("已重启插件3次,请检查机器人状态后使用 `bn start` 启动插件");
3193
+ await this.ctx["bilibili-notify"].disposePlugin();
3194
+ return;
3195
+ }
3196
+ this.rebootCount++;
3197
+ this.logger.info("插件出现未知错误,正在重启插件");
3198
+ if (await this.ctx["bilibili-notify"].restartPlugin()) this.logger.info("插件重启成功");
3199
+ else {
3200
+ this.logger.error("插件重启失败,请检查机器人状态后使用 `bn start` 启动插件");
3201
+ await this.sendPrivateMsg("插件重启失败,请检查机器人状态后使用 `bn start` 启动插件");
3202
+ await this.ctx["bilibili-notify"].disposePlugin();
3203
+ }
3204
+ }
3205
+ async sendPrivateMsgAndStopService() {
3206
+ await this.sendPrivateMsg("插件发生未知错误,请检查机器人状态后使用 `bn start` 启动插件");
3207
+ this.logger.error("插件发生未知错误,请检查机器人状态后使用 `bn start` 启动插件");
3208
+ await this.ctx["bilibili-notify"].disposePlugin();
3209
+ }
3210
+ async sendMessageWithRetry(bot, channelId, content) {
3211
+ withRetry(async () => await bot.sendMessage(channelId, content), 1).catch(async (e) => {
3212
+ if (e.message === "this._request is not a function") {
3213
+ this.ctx.setTimeout(async () => {
3214
+ await this.sendMessageWithRetry(bot, channelId, content);
3215
+ }, 2e3);
3216
+ return;
3217
+ }
3218
+ this.logger.error(`发送消息失败,群组ID: ${channelId},错误:${e.message}`);
3219
+ await this.sendPrivateMsg(`发送消息失败,群组ID: ${channelId}`);
3220
+ });
3221
+ }
3222
+ async pushMessage(targets, content) {
3223
+ const t = {};
3224
+ for (const target of targets) {
3225
+ const [platform, channleId] = target.split(":");
3226
+ if (!t[platform]) t[platform] = [channleId];
3227
+ else t[platform].push(channleId);
3228
+ }
3229
+ for (const platform of Object.keys(t)) {
3230
+ const bots = [];
3231
+ for (const bot of this.ctx.bots) if (bot.platform === platform) bots.push(bot);
3232
+ let num = 0;
3233
+ const sendMessageByBot = async (channelId, botIndex = 0, retry = 3e3) => {
3234
+ if (!bots[botIndex]) {
3235
+ this.logger.warn(`${platform} 没有配置对应机器人,无法推送`);
3236
+ return;
3237
+ }
3238
+ if (bots[botIndex].status !== koishi.Universal.Status.ONLINE) {
3239
+ if (retry >= 3e3 * 2 ** 5) {
3240
+ this.logger.error(`${platform} 机器人未初始化,已重试5次,放弃推送`);
3241
+ await this.sendPrivateMsg(`${platform} 机器人未初始化,已重试5次,放弃推送`);
3242
+ return;
3243
+ }
3244
+ this.logger.warn(`${platform} 机器人未初始化,${retry / 1e3} 秒后重试`);
3245
+ await this.ctx.sleep(retry);
3246
+ await sendMessageByBot(channelId, botIndex, retry * 2);
3247
+ return;
3248
+ }
3249
+ try {
3250
+ await bots[botIndex].sendMessage(channelId, content);
3251
+ num++;
3252
+ await this.ctx.sleep(500);
3253
+ } catch (e) {
3254
+ this.logger.error(`发送消息失败:${e}`);
3255
+ if (bots.length > 1) await sendMessageByBot(channelId, botIndex++);
3256
+ }
3257
+ };
3258
+ for (const channelId of t[platform]) await sendMessageByBot(channelId);
3259
+ this.logger.info(`成功推送 ${num} 条消息`);
3260
+ }
3261
+ }
3262
+ async broadcastToTargets(uid, content, type) {
3263
+ if (!this.pushArrMapInitializing) {
3264
+ this.logger.warn(`推送对象信息尚未初始化完毕,等待5秒钟后重试推送,推送对象: ${uid}, 推送类型: ${PushTypeMsg[type]}`);
3265
+ await this.ctx.sleep(5e3);
3266
+ return this.broadcastToTargets(uid, content, type);
3267
+ }
3268
+ const record = this.pushArrMap.get(uid);
3269
+ if (!record) return;
3270
+ if (!(type === PushType.StartBroadcasting && record.liveAtAllArr?.length > 0 || type === PushType.Dynamic && (record.dynamicArr?.length > 0 || record.dynamicAtAllArr?.length > 0) || (type === PushType.Live || type === PushType.StartBroadcasting) && record.liveArr?.length > 0 || type === PushType.LiveGuardBuy && record.liveGuardBuyArr?.length > 0 || type === PushType.Superchat && record.superchatArr?.length > 0 || type === PushType.WordCloudAndLiveSummary && (record.wordcloudArr?.length > 0 || record.liveSummaryArr?.length > 0))) return;
3271
+ this.logger.info(`推送对象: ${uid}, 推送类型: ${PushTypeMsg[type]}`);
3272
+ if (type === PushType.StartBroadcasting && record.liveAtAllArr?.length > 0) {
3273
+ this.logger.debug(`推送给 @全体,对象列表:${record.liveAtAllArr}`);
3274
+ const atAllArr = structuredClone(record.liveAtAllArr);
3275
+ await withRetry(() => this.pushMessage(atAllArr, koishi.h.at("all")), 1);
3276
+ }
3277
+ if (type === PushType.Dynamic && record.dynamicArr?.length > 0) {
3278
+ if (record.dynamicAtAllArr?.length > 0) {
3279
+ this.logger.debug(`推送动态给 @全体,对象列表:${record.dynamicAtAllArr}`);
3280
+ const dynamicAtAllArr = structuredClone(record.dynamicAtAllArr);
3281
+ await withRetry(() => this.pushMessage(dynamicAtAllArr, koishi.h.at("all")), 1);
3282
+ }
3283
+ this.logger.debug(`推送动态,对象列表:${record.dynamicArr}`);
3284
+ const dynamicArr = structuredClone(record.dynamicArr);
3285
+ await withRetry(() => this.pushMessage(dynamicArr, (0, koishi.h)("message", content)), 1);
3286
+ }
3287
+ if ((type === PushType.Live || type === PushType.StartBroadcasting) && record.liveArr?.length > 0) {
3288
+ this.logger.debug(`推送直播,对象列表:${record.liveArr}`);
3289
+ const liveArr = structuredClone(record.liveArr);
3290
+ await withRetry(() => this.pushMessage(liveArr, (0, koishi.h)("message", content)), 1);
3291
+ }
3292
+ if (type === PushType.LiveGuardBuy && record.liveGuardBuyArr?.length > 0) {
3293
+ this.logger.debug(`推送直播守护购买消息,对象列表:${record.liveGuardBuyArr}`);
3294
+ const liveGuardBuyArr = structuredClone(record.liveGuardBuyArr);
3295
+ await withRetry(() => this.pushMessage(liveGuardBuyArr, (0, koishi.h)("message", content)), 1);
3296
+ }
3297
+ if (type === PushType.Superchat && record.superchatArr?.length > 0) {
3298
+ this.logger.debug(`推送 SC 消息,对象列表:${record.superchatArr}`);
3299
+ const superchatArr = structuredClone(record.superchatArr);
3300
+ await withRetry(() => this.pushMessage(superchatArr, (0, koishi.h)("message", content)), 1);
3301
+ }
3302
+ if (type === PushType.WordCloudAndLiveSummary) {
3303
+ const wordcloudArr = structuredClone(record.wordcloudArr);
3304
+ const liveSummaryArr = structuredClone(record.liveSummaryArr);
3305
+ const wordcloudAndLiveSummaryArr = wordcloudArr.filter((item) => liveSummaryArr.includes(item));
3306
+ const wordcloudOnlyArr = wordcloudArr.filter((item) => !liveSummaryArr.includes(item));
3307
+ const liveSummaryOnlyArr = liveSummaryArr.filter((item) => !wordcloudArr.includes(item));
3308
+ if (wordcloudAndLiveSummaryArr.length > 0) {
3309
+ this.logger.debug(`推送词云和直播总结,对象列表:${wordcloudAndLiveSummaryArr}`);
3310
+ const msgs = content.filter(Boolean);
3311
+ if (msgs.length > 0) await withRetry(() => this.pushMessage(wordcloudAndLiveSummaryArr, (0, koishi.h)("message", msgs)), 1);
3312
+ }
3313
+ if (content[0] && wordcloudOnlyArr.length > 0) {
3314
+ this.logger.debug(`推送词云,对象列表:${wordcloudOnlyArr}`);
3315
+ await withRetry(() => this.pushMessage(wordcloudOnlyArr, (0, koishi.h)("message", content[0])), 1);
3316
+ }
3317
+ if (content[1] && liveSummaryOnlyArr.length > 0) {
3318
+ this.logger.debug(`推送直播总结,对象列表:${liveSummaryOnlyArr}`);
3319
+ await withRetry(() => this.pushMessage(liveSummaryOnlyArr, (0, koishi.h)("message", content[1])), 1);
3320
+ }
3321
+ }
3322
+ }
3323
+ };
3324
+ (function(_BilibiliNotifyPush) {
3325
+ _BilibiliNotifyPush.Config = koishi.Schema.object({
3326
+ logLevel: koishi.Schema.number().required(),
3327
+ master: koishi.Schema.object({
3328
+ enable: koishi.Schema.boolean(),
3329
+ platform: koishi.Schema.string(),
3330
+ masterAccount: koishi.Schema.string(),
3331
+ masterAccountGuildId: koishi.Schema.string()
3332
+ })
3333
+ });
3334
+ })(BilibiliNotifyPush || (BilibiliNotifyPush = {}));
3335
+ var push_default = BilibiliNotifyPush;
3336
+
3337
+ //#endregion
3338
+ //#region src/api.ts
3339
+ const mixinKeyEncTab = [
3340
+ 46,
3341
+ 47,
3342
+ 18,
3343
+ 2,
3344
+ 53,
3345
+ 8,
3346
+ 23,
3347
+ 32,
3348
+ 15,
3349
+ 50,
3350
+ 10,
3351
+ 31,
3352
+ 58,
3353
+ 3,
3354
+ 45,
3355
+ 35,
3356
+ 27,
3357
+ 43,
3358
+ 5,
3359
+ 49,
3360
+ 33,
3361
+ 9,
3362
+ 42,
3363
+ 19,
3364
+ 29,
3365
+ 28,
3366
+ 14,
3367
+ 39,
3368
+ 12,
3369
+ 38,
3370
+ 41,
3371
+ 13,
3372
+ 37,
3373
+ 48,
3374
+ 7,
3375
+ 16,
3376
+ 24,
3377
+ 55,
3378
+ 40,
3379
+ 61,
3380
+ 26,
3381
+ 17,
3382
+ 0,
3383
+ 1,
3384
+ 60,
3385
+ 51,
3386
+ 30,
3387
+ 4,
3388
+ 22,
3389
+ 25,
3390
+ 54,
3391
+ 21,
3392
+ 56,
3393
+ 59,
3394
+ 6,
3395
+ 63,
3396
+ 57,
3397
+ 62,
3398
+ 11,
3399
+ 36,
3400
+ 20,
3401
+ 34,
3402
+ 44,
3403
+ 52
3404
+ ];
3405
+ const bangumiTripData = {
3406
+ code: 0,
3407
+ data: { live_room: { roomid: 931774 } }
3408
+ };
3409
+ const GET_USER_SPACE_DYNAMIC_LIST = "https://api.bilibili.com/x/polymer/web-dynamic/v1/feed/space?platform=web&features=itemOpusStyle";
3410
+ const GET_ALL_DYNAMIC_LIST = "https://api.bilibili.com/x/polymer/web-dynamic/v1/feed/all?platform=web&features=itemOpusStyle";
3411
+ const HAS_NEW_DYNAMIC = "https://api.bilibili.com/x/polymer/web-dynamic/v1/feed/all/update";
3412
+ const GET_COOKIES_INFO = "https://passport.bilibili.com/x/passport-login/web/cookie/info";
3413
+ const GET_USER_INFO = "https://api.bilibili.com/x/space/wbi/acc/info";
3414
+ const GET_MYSELF_INFO = "https://api.bilibili.com/x/member/web/account";
3415
+ const GET_LOGIN_QRCODE = "https://passport.bilibili.com/x/passport-login/web/qrcode/generate";
3416
+ const GET_LOGIN_STATUS = "https://passport.bilibili.com/x/passport-login/web/qrcode/poll";
3417
+ const GET_LIVE_ROOM_INFO = "https://api.live.bilibili.com/room/v1/Room/get_info";
3418
+ const GET_MASTER_INFO = "https://api.live.bilibili.com/live_user/v1/Master/info";
3419
+ const GET_TIME_NOW = "https://api.bilibili.com/x/report/click/now";
3420
+ const GET_SERVER_UTC_TIME = "https://interface.bilibili.com/serverdate.js";
3421
+ const GET_USER_CARD_INFO = "https://api.bilibili.com/x/web-interface/card";
3422
+ const GET_LATEST_UPDATED_UPS = "https://api.bilibili.com/x/polymer/web-dynamic/v1/portal";
3423
+ const GET_ONLINE_GOLD_RANK = "https://api.live.bilibili.com//xlive/general-interface/v1/rank/getOnlineGoldRank";
3424
+ const GET_USER_INFO_IN_LIVE = "https://api.live.bilibili.com/xlive/app-ucenter/v2/card/user";
3425
+ const MODIFY_RELATION = "https://api.bilibili.com/x/relation/modify";
3426
+ const CREATE_GROUP = "https://api.bilibili.com/x/relation/tag/create";
3427
+ const MODIFY_GROUP_MEMBER = "https://api.bilibili.com/x/relation/tags/addUsers";
3428
+ const GET_ALL_GROUP = "https://api.bilibili.com/x/relation/tags";
3429
+ const COPY_USER_TO_GROUP = "https://api.bilibili.com/x/relation/tags/copyUsers";
3430
+ const GET_RELATION_GROUP_DETAIL = "https://api.bilibili.com/x/relation/tag";
3431
+ const GET_LIVE_ROOM_INFO_STREAM_KEY = "https://api.live.bilibili.com/xlive/web-room/v1/index/getDanmuInfo";
3432
+ const GET_LIVE_ROOMS_INFO = "https://api.live.bilibili.com/room/v1/Room/get_status_info_by_uids";
3433
+ var BilibiliNotifyAPI = class extends koishi.Service {
3434
+ static inject = ["database", "notifier"];
3435
+ jar;
3436
+ client;
3437
+ aiClient;
3438
+ cacheable;
3439
+ loginData;
3440
+ loginNotifier;
3257
3441
  refreshCookieTimer;
3258
3442
  loginInfoIsLoaded = false;
3259
3443
  wbiSign = {
@@ -3849,177 +4033,6 @@ function apply$1(ctx) {
3849
4033
  });
3850
4034
  }
3851
4035
 
3852
- //#endregion
3853
- //#region src/core/push.ts
3854
- var BilibiliNotifyPush = class extends koishi.Service {
3855
- privateBot;
3856
- rebootCount = 0;
3857
- pushArrMapInitializing = false;
3858
- pushArrMap;
3859
- constructor(ctx, config) {
3860
- super(ctx, "bilibili-notify-push");
3861
- this.privateBot = this.ctx.bots.find((bot) => bot.platform === config.master.platform);
3862
- if (!this.privateBot) this.ctx.notifier.create({ content: "未配置管理员账号,无法推送插件运行状态,请尽快配置" });
3863
- }
3864
- getBot(pf, selfId) {
3865
- if (!selfId || selfId === "") return this.ctx.bots.find((bot) => bot.platform === pf);
3866
- return this.ctx.bots.find((bot) => bot.platform === pf && bot.selfId === selfId);
3867
- }
3868
- async sendPrivateMsg(content) {
3869
- if (this.config.master.enable) {
3870
- if (this.privateBot?.status !== koishi.Universal.Status.ONLINE) {
3871
- this.logger.warn(`${this.privateBot.platform} 机器人未初始化,暂时无法推送`);
3872
- return;
3873
- }
3874
- if (this.config.master.masterAccountGuildId) await this.privateBot.sendPrivateMessage(this.config.master.masterAccount, content, this.config.master.masterAccountGuildId);
3875
- else await this.privateBot.sendPrivateMessage(this.config.master.masterAccount, content);
3876
- }
3877
- }
3878
- async sendPrivateMsgAndRebootService() {
3879
- if (this.rebootCount >= 3) {
3880
- this.logger.error("已重启插件3次,请检查机器人状态后使用 `bn start` 启动插件");
3881
- await this.sendPrivateMsg("已重启插件3次,请检查机器人状态后使用 `bn start` 启动插件");
3882
- await this.ctx["bilibili-notify"].disposePlugin();
3883
- return;
3884
- }
3885
- this.rebootCount++;
3886
- this.logger.info("插件出现未知错误,正在重启插件");
3887
- if (await this.ctx["bilibili-notify"].restartPlugin()) this.logger.info("插件重启成功");
3888
- else {
3889
- this.logger.error("插件重启失败,请检查机器人状态后使用 `bn start` 启动插件");
3890
- await this.sendPrivateMsg("插件重启失败,请检查机器人状态后使用 `bn start` 启动插件");
3891
- await this.ctx["bilibili-notify"].disposePlugin();
3892
- }
3893
- }
3894
- async sendPrivateMsgAndStopService() {
3895
- await this.sendPrivateMsg("插件发生未知错误,请检查机器人状态后使用 `bn start` 启动插件");
3896
- this.logger.error("插件发生未知错误,请检查机器人状态后使用 `bn start` 启动插件");
3897
- await this.ctx["bilibili-notify"].disposePlugin();
3898
- }
3899
- async sendMessageWithRetry(bot, channelId, content) {
3900
- withRetry(async () => await bot.sendMessage(channelId, content), 1).catch(async (e) => {
3901
- if (e.message === "this._request is not a function") {
3902
- this.ctx.setTimeout(async () => {
3903
- await this.sendMessageWithRetry(bot, channelId, content);
3904
- }, 2e3);
3905
- return;
3906
- }
3907
- this.logger.error(`发送消息失败,群组ID: ${channelId},错误:${e.message}`);
3908
- await this.sendPrivateMsg(`发送消息失败,群组ID: ${channelId}`);
3909
- });
3910
- }
3911
- async pushMessage(targets, content) {
3912
- const t = {};
3913
- for (const target of targets) {
3914
- const [platform, channleId] = target.split(":");
3915
- if (!t[platform]) t[platform] = [channleId];
3916
- else t[platform].push(channleId);
3917
- }
3918
- for (const platform of Object.keys(t)) {
3919
- const bots = [];
3920
- for (const bot of this.ctx.bots) if (bot.platform === platform) bots.push(bot);
3921
- let num = 0;
3922
- const sendMessageByBot = async (channelId, botIndex = 0, retry = 3e3) => {
3923
- if (!bots[botIndex]) {
3924
- this.logger.warn(`${platform} 没有配置对应机器人,无法推送`);
3925
- return;
3926
- }
3927
- if (bots[botIndex].status !== koishi.Universal.Status.ONLINE) {
3928
- if (retry >= 3e3 * 2 ** 5) {
3929
- this.logger.error(`${platform} 机器人未初始化,已重试5次,放弃推送`);
3930
- await this.sendPrivateMsg(`${platform} 机器人未初始化,已重试5次,放弃推送`);
3931
- return;
3932
- }
3933
- this.logger.warn(`${platform} 机器人未初始化,${retry / 1e3} 秒后重试`);
3934
- await this.ctx.sleep(retry);
3935
- await sendMessageByBot(channelId, botIndex, retry * 2);
3936
- return;
3937
- }
3938
- try {
3939
- await bots[botIndex].sendMessage(channelId, content);
3940
- num++;
3941
- await this.ctx.sleep(500);
3942
- } catch (e) {
3943
- this.logger.error(`发送消息失败:${e}`);
3944
- if (bots.length > 1) await sendMessageByBot(channelId, botIndex++);
3945
- }
3946
- };
3947
- for (const channelId of t[platform]) await sendMessageByBot(channelId);
3948
- this.logger.info(`成功推送 ${num} 条消息`);
3949
- }
3950
- }
3951
- async broadcastToTargets(uid, content, type) {
3952
- if (!this.pushArrMapInitializing) {
3953
- this.logger.warn(`推送对象信息尚未初始化完毕,等待5秒钟后重试推送,推送对象: ${uid}, 推送类型: ${PushTypeMsg[type]}`);
3954
- await this.ctx.sleep(5e3);
3955
- return this.broadcastToTargets(uid, content, type);
3956
- }
3957
- const record = this.pushArrMap.get(uid);
3958
- if (!record) return;
3959
- if (!(type === PushType.StartBroadcasting && record.liveAtAllArr?.length > 0 || type === PushType.Dynamic && (record.dynamicArr?.length > 0 || record.dynamicAtAllArr?.length > 0) || (type === PushType.Live || type === PushType.StartBroadcasting) && record.liveArr?.length > 0 || type === PushType.LiveGuardBuy && record.liveGuardBuyArr?.length > 0 || type === PushType.Superchat && record.superchatArr?.length > 0 || type === PushType.WordCloudAndLiveSummary && (record.wordcloudArr?.length > 0 || record.liveSummaryArr?.length > 0))) return;
3960
- this.logger.info(`推送对象: ${uid}, 推送类型: ${PushTypeMsg[type]}`);
3961
- if (type === PushType.StartBroadcasting && record.liveAtAllArr?.length > 0) {
3962
- this.logger.debug(`推送给 @全体,对象列表:${record.liveAtAllArr}`);
3963
- const atAllArr = structuredClone(record.liveAtAllArr);
3964
- await withRetry(() => this.pushMessage(atAllArr, koishi.h.at("all")), 1);
3965
- }
3966
- if (type === PushType.Dynamic && record.dynamicArr?.length > 0) {
3967
- if (record.dynamicAtAllArr?.length > 0) {
3968
- this.logger.debug(`推送动态给 @全体,对象列表:${record.dynamicAtAllArr}`);
3969
- const dynamicAtAllArr = structuredClone(record.dynamicAtAllArr);
3970
- await withRetry(() => this.pushMessage(dynamicAtAllArr, koishi.h.at("all")), 1);
3971
- }
3972
- this.logger.debug(`推送动态,对象列表:${record.dynamicArr}`);
3973
- const dynamicArr = structuredClone(record.dynamicArr);
3974
- await withRetry(() => this.pushMessage(dynamicArr, (0, koishi.h)("message", content)), 1);
3975
- }
3976
- if ((type === PushType.Live || type === PushType.StartBroadcasting) && record.liveArr?.length > 0) {
3977
- this.logger.debug(`推送直播,对象列表:${record.liveArr}`);
3978
- const liveArr = structuredClone(record.liveArr);
3979
- await withRetry(() => this.pushMessage(liveArr, (0, koishi.h)("message", content)), 1);
3980
- }
3981
- if (type === PushType.LiveGuardBuy && record.liveGuardBuyArr?.length > 0) {
3982
- this.logger.debug(`推送直播守护购买消息,对象列表:${record.liveGuardBuyArr}`);
3983
- const liveGuardBuyArr = structuredClone(record.liveGuardBuyArr);
3984
- await withRetry(() => this.pushMessage(liveGuardBuyArr, (0, koishi.h)("message", content)), 1);
3985
- }
3986
- if (type === PushType.Superchat && record.superchatArr?.length > 0) {
3987
- this.logger.debug(`推送 SC 消息,对象列表:${record.superchatArr}`);
3988
- const superchatArr = structuredClone(record.superchatArr);
3989
- await withRetry(() => this.pushMessage(superchatArr, (0, koishi.h)("message", content)), 1);
3990
- }
3991
- if (type === PushType.WordCloudAndLiveSummary) {
3992
- const wordcloudArr = structuredClone(record.wordcloudArr);
3993
- const liveSummaryArr = structuredClone(record.liveSummaryArr);
3994
- const wordcloudAndLiveSummaryArr = wordcloudArr.filter((item) => liveSummaryArr.includes(item));
3995
- const wordcloudOnlyArr = wordcloudArr.filter((item) => !liveSummaryArr.includes(item));
3996
- const liveSummaryOnlyArr = liveSummaryArr.filter((item) => !wordcloudArr.includes(item));
3997
- if (wordcloudAndLiveSummaryArr.length > 0) {
3998
- this.logger.debug(`推送词云和直播总结,对象列表:${wordcloudAndLiveSummaryArr}`);
3999
- const msgs = content.filter(Boolean);
4000
- if (msgs.length > 0) await withRetry(() => this.pushMessage(wordcloudAndLiveSummaryArr, (0, koishi.h)("message", msgs)), 1);
4001
- }
4002
- if (content[0] && wordcloudOnlyArr.length > 0) {
4003
- this.logger.debug(`推送词云,对象列表:${wordcloudOnlyArr}`);
4004
- await withRetry(() => this.pushMessage(wordcloudOnlyArr, (0, koishi.h)("message", content[0])), 1);
4005
- }
4006
- if (content[1] && liveSummaryOnlyArr.length > 0) {
4007
- this.logger.debug(`推送直播总结,对象列表:${liveSummaryOnlyArr}`);
4008
- await withRetry(() => this.pushMessage(liveSummaryOnlyArr, (0, koishi.h)("message", content[1])), 1);
4009
- }
4010
- }
4011
- }
4012
- };
4013
- (function(_BilibiliNotifyPush) {
4014
- _BilibiliNotifyPush.Config = koishi.Schema.object({ master: koishi.Schema.object({
4015
- enable: koishi.Schema.boolean(),
4016
- platform: koishi.Schema.string(),
4017
- masterAccount: koishi.Schema.string(),
4018
- masterAccountGuildId: koishi.Schema.string()
4019
- }) });
4020
- })(BilibiliNotifyPush || (BilibiliNotifyPush = {}));
4021
- var push_default = BilibiliNotifyPush;
4022
-
4023
4036
  //#endregion
4024
4037
  //#region src/index.ts
4025
4038
  const inject = [
@@ -4103,8 +4116,12 @@ var ServerManager = class extends koishi.Service {
4103
4116
  font: globalConfig.font,
4104
4117
  followerDisplay: globalConfig.followerDisplay
4105
4118
  });
4106
- const ps = this.ctx.plugin(push_default, { master: globalConfig.master });
4119
+ const ps = this.ctx.plugin(push_default, {
4120
+ logLevel: globalConfig.logLevel,
4121
+ master: globalConfig.master
4122
+ });
4107
4123
  const dy = this.ctx.plugin(dynamic_default, {
4124
+ logLevel: globalConfig.logLevel,
4108
4125
  filter: globalConfig.filter,
4109
4126
  dynamicUrl: globalConfig.dynamicUrl,
4110
4127
  dynamicCron: globalConfig.dynamicCron,