koishi-plugin-bilibili-notify 3.1.0 → 3.1.2-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.
- package/lib/comRegister.d.ts +1 -1
- package/lib/comRegister.js +232 -204
- package/lib/index.d.ts +0 -1
- package/lib/index.js +0 -10
- package/lib/type/index.d.ts +3 -2
- package/package.json +1 -1
- package/readme.md +2 -0
package/lib/comRegister.d.ts
CHANGED
|
@@ -24,6 +24,7 @@ declare class ComRegister {
|
|
|
24
24
|
sendPrivateMsgAndRebootService(): Promise<void>;
|
|
25
25
|
sendPrivateMsgAndStopService(): Promise<void>;
|
|
26
26
|
sendMessageWithRetry(bot: Bot<Context>, channelId: string, content: any): Promise<void>;
|
|
27
|
+
getGroupsThatMeetCriteria(targets: Target, type: PushType): string[];
|
|
27
28
|
broadcastToTargets(targets: Target, content: any, type: PushType): Promise<void>;
|
|
28
29
|
dynamicDetect(): (...args: any[]) => void;
|
|
29
30
|
debug_dynamicDetect(): (...args: any[]) => void;
|
|
@@ -73,7 +74,6 @@ declare namespace ComRegister {
|
|
|
73
74
|
masterAccount: string;
|
|
74
75
|
masterAccountGuildId: string;
|
|
75
76
|
};
|
|
76
|
-
liveDetectMode: "API" | "WS";
|
|
77
77
|
restartPush: boolean;
|
|
78
78
|
pushTime: number;
|
|
79
79
|
pushImgsInDynamic: boolean;
|
package/lib/comRegister.js
CHANGED
|
@@ -422,82 +422,93 @@ class ComRegister {
|
|
|
422
422
|
await this.sendPrivateMsg(`发送群组ID:${channelId}消息失败,请查看日志`);
|
|
423
423
|
});
|
|
424
424
|
}
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
for (const guild of (await bot.getGuildList()).data) {
|
|
436
|
-
channelArr.push({
|
|
437
|
-
channelId: guild.id,
|
|
438
|
-
dynamic: target.channelArr[0].dynamic,
|
|
439
|
-
live: target.channelArr[0].live,
|
|
440
|
-
liveGuardBuy: target.channelArr[0].liveGuardBuy,
|
|
441
|
-
atAll: target.channelArr[0].atAll,
|
|
442
|
-
});
|
|
425
|
+
getGroupsThatMeetCriteria(targets, type) {
|
|
426
|
+
// 定义数组
|
|
427
|
+
const pushArr = [];
|
|
428
|
+
// 判断类型
|
|
429
|
+
if (type === type_1.PushType.Live || type === type_1.PushType.StartBroadcasting) {
|
|
430
|
+
for (const target of targets) {
|
|
431
|
+
for (const channel of target.channelArr) {
|
|
432
|
+
if (channel.live) {
|
|
433
|
+
pushArr.push(`${target.platform}:${channel.channelId}`);
|
|
434
|
+
}
|
|
443
435
|
}
|
|
444
436
|
}
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
// 判断是否需要推送动态消息
|
|
453
|
-
if (channel.live) {
|
|
454
|
-
await this.sendMessageWithRetry(bot, channel.channelId, content);
|
|
455
|
-
}
|
|
456
|
-
// 延迟发送
|
|
457
|
-
await this.ctx.sleep(500);
|
|
458
|
-
}
|
|
459
|
-
},
|
|
460
|
-
[type_1.PushType.Dynamic]: async () => {
|
|
461
|
-
for (const channel of channelArr) {
|
|
462
|
-
// 判断是否需要推送动态消息
|
|
463
|
-
if (channel.live) {
|
|
464
|
-
await this.sendMessageWithRetry(bot, channel.channelId, content);
|
|
465
|
-
}
|
|
466
|
-
// 延迟发送
|
|
467
|
-
await this.ctx.sleep(500);
|
|
468
|
-
}
|
|
469
|
-
},
|
|
470
|
-
[type_1.PushType.StartBroadcasting]: async () => {
|
|
471
|
-
// 直播开播推送,判断是否需要艾特全体成员
|
|
472
|
-
for (const channel of channelArr) {
|
|
473
|
-
// 判断是否需要推送直播消息
|
|
474
|
-
if (channel.live) {
|
|
475
|
-
await this.sendMessageWithRetry(bot, channel.channelId, content);
|
|
476
|
-
}
|
|
477
|
-
// 判断是否需要艾特全体成员
|
|
478
|
-
if (channel.atAll) {
|
|
479
|
-
await this.sendMessageWithRetry(bot, channel.channelId, (0, jsx_runtime_1.jsx)("at", { type: "all" }));
|
|
480
|
-
}
|
|
481
|
-
// 延迟发送
|
|
482
|
-
await this.ctx.sleep(500);
|
|
437
|
+
return pushArr;
|
|
438
|
+
}
|
|
439
|
+
if (type === type_1.PushType.Dynamic) {
|
|
440
|
+
for (const target of targets) {
|
|
441
|
+
for (const channel of target.channelArr) {
|
|
442
|
+
if (channel.dynamic) {
|
|
443
|
+
pushArr.push(`${target.platform}:${channel.channelId}`);
|
|
483
444
|
}
|
|
484
|
-
}
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
await this.ctx.sleep(500);
|
|
445
|
+
}
|
|
446
|
+
}
|
|
447
|
+
return pushArr;
|
|
448
|
+
}
|
|
449
|
+
if (type === type_1.PushType.LiveGuardBuy) {
|
|
450
|
+
for (const target of targets) {
|
|
451
|
+
for (const channel of target.channelArr) {
|
|
452
|
+
if (channel.liveGuardBuy) {
|
|
453
|
+
pushArr.push(`${target.platform}:${channel.channelId}`);
|
|
494
454
|
}
|
|
495
455
|
}
|
|
496
|
-
}
|
|
497
|
-
|
|
498
|
-
await pushTypePatternMatching[type]();
|
|
456
|
+
}
|
|
457
|
+
return pushArr;
|
|
499
458
|
}
|
|
500
459
|
}
|
|
460
|
+
// biome-ignore lint/suspicious/noExplicitAny: <explanation>
|
|
461
|
+
async broadcastToTargets(targets, content, type) {
|
|
462
|
+
// 不止一个目标平台或一个目标频道
|
|
463
|
+
if (targets.length !== 1 || targets[0].channelArr.length !== 1) {
|
|
464
|
+
// 直接使用broadcast
|
|
465
|
+
const pushArr = this.getGroupsThatMeetCriteria(targets, type);
|
|
466
|
+
// logger
|
|
467
|
+
this.logger.info(`推送消息到 ${pushArr.length} 个目标频道,目标频道为:${pushArr.join(", ")}`);
|
|
468
|
+
// 推送消息
|
|
469
|
+
await (0, utils_1.withRetry)(async () => {
|
|
470
|
+
await this.ctx.broadcast(pushArr, content);
|
|
471
|
+
}, 1);
|
|
472
|
+
// 结束
|
|
473
|
+
return;
|
|
474
|
+
}
|
|
475
|
+
// 获取目标
|
|
476
|
+
const targetChannel = targets[0].channelArr[0];
|
|
477
|
+
// 获取机器人实例
|
|
478
|
+
const bot = this.getBot(targets[0].platform);
|
|
479
|
+
// 模式匹配
|
|
480
|
+
const pushTypePatternMatching = {
|
|
481
|
+
[type_1.PushType.Live]: async () => {
|
|
482
|
+
if (targetChannel.live) {
|
|
483
|
+
// 直接推送
|
|
484
|
+
await this.sendMessageWithRetry(bot, targetChannel.channelId, content);
|
|
485
|
+
}
|
|
486
|
+
},
|
|
487
|
+
[type_1.PushType.Dynamic]: async () => {
|
|
488
|
+
if (targetChannel.dynamic) {
|
|
489
|
+
await this.sendMessageWithRetry(bot, targetChannel.channelId, content);
|
|
490
|
+
}
|
|
491
|
+
},
|
|
492
|
+
[type_1.PushType.StartBroadcasting]: async () => {
|
|
493
|
+
// 判断是否需要推送直播消息
|
|
494
|
+
if (targetChannel.live) {
|
|
495
|
+
await this.sendMessageWithRetry(bot, targetChannel.channelId, content);
|
|
496
|
+
}
|
|
497
|
+
// 判断是否需要艾特全体成员
|
|
498
|
+
if (targetChannel.atAll) {
|
|
499
|
+
await this.sendMessageWithRetry(bot, targetChannel.channelId, (0, jsx_runtime_1.jsx)("at", { type: "all" }));
|
|
500
|
+
}
|
|
501
|
+
},
|
|
502
|
+
[type_1.PushType.LiveGuardBuy]: async () => {
|
|
503
|
+
// 判断是否需要推送直播消息
|
|
504
|
+
if (targetChannel.liveGuardBuy) {
|
|
505
|
+
await this.sendMessageWithRetry(bot, targetChannel.channelId, content);
|
|
506
|
+
}
|
|
507
|
+
},
|
|
508
|
+
};
|
|
509
|
+
// 推送
|
|
510
|
+
await pushTypePatternMatching[type]();
|
|
511
|
+
}
|
|
501
512
|
dynamicDetect() {
|
|
502
513
|
// 检测初始化变量
|
|
503
514
|
let detectSetup = true;
|
|
@@ -604,67 +615,71 @@ class ComRegister {
|
|
|
604
615
|
// 动态ID如果一致则结束循环
|
|
605
616
|
if (dynamicId === dynamicIdStr1st)
|
|
606
617
|
break;
|
|
607
|
-
//
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
618
|
+
// 获取动态发布时间
|
|
619
|
+
const postTime = item.modules.module_author.pub_ts;
|
|
620
|
+
// timeline已超过或与当前动态时间戳相同,则后面的动态不需要推送
|
|
621
|
+
if (postTime <= timeline)
|
|
622
|
+
break;
|
|
623
|
+
// 从动态数据中取出UP主名称、UID
|
|
624
|
+
const upUID = item.modules.module_author.mid.toString();
|
|
625
|
+
const upName = item.modules.module_author.name;
|
|
626
|
+
// 寻找关注的UP主的动态
|
|
627
|
+
for (const sub of this.subManager) {
|
|
628
|
+
// 判断是否是订阅的UP主
|
|
629
|
+
if (sub.dynamic && sub.uid === upUID) {
|
|
630
|
+
// 推送该条动态
|
|
631
|
+
const buffer = await (0, utils_1.withRetry)(async () => {
|
|
632
|
+
// 渲染图片
|
|
633
|
+
return await this.ctx.gi.generateDynamicImg(item, sub.card);
|
|
634
|
+
}, 1).catch(async (e) => {
|
|
635
|
+
// 直播开播动态,不做处理
|
|
636
|
+
if (e.message === "直播开播动态,不做处理")
|
|
637
|
+
return;
|
|
638
|
+
if (e.message === "出现关键词,屏蔽该动态") {
|
|
639
|
+
// 如果需要发送才发送
|
|
640
|
+
if (this.config.filter.notify) {
|
|
641
|
+
await this.broadcastToTargets(sub.target, `${upName}发布了一条含有屏蔽关键字的动态`, type_1.PushType.Dynamic);
|
|
631
642
|
}
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
643
|
+
return;
|
|
644
|
+
}
|
|
645
|
+
if (e.message === "已屏蔽转发动态") {
|
|
646
|
+
if (this.config.filter.notify) {
|
|
647
|
+
await this.broadcastToTargets(sub.target, `${upName}转发了一条动态,已屏蔽`, type_1.PushType.Dynamic);
|
|
637
648
|
}
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
//
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
649
|
+
return;
|
|
650
|
+
}
|
|
651
|
+
// 未知错误
|
|
652
|
+
this.logger.error(`dynamicDetect generateDynamicImg() 推送卡片发送失败,原因:${e.message}`);
|
|
653
|
+
// 发送私聊消息并重启服务
|
|
654
|
+
await this.sendPrivateMsgAndStopService();
|
|
655
|
+
});
|
|
656
|
+
// 判断是否执行成功,未执行成功直接返回
|
|
657
|
+
if (!buffer)
|
|
658
|
+
continue;
|
|
659
|
+
// 定义动态链接
|
|
660
|
+
let dUrl = "";
|
|
661
|
+
// 判断是否需要发送URL
|
|
662
|
+
if (this.config.dynamicUrl) {
|
|
663
|
+
// 生成动态链接
|
|
664
|
+
dUrl = `${upName}发布了一条动态:https://t.bilibili.com/${dynamicId}`;
|
|
665
|
+
}
|
|
666
|
+
// logger
|
|
667
|
+
this.logger.info("推送动态中...");
|
|
668
|
+
// 发送推送卡片
|
|
669
|
+
await this.broadcastToTargets(sub.target, (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [koishi_1.h.image(buffer, "image/jpeg"), dUrl] }), type_1.PushType.Dynamic);
|
|
670
|
+
// 判断是否需要发送动态中的图片
|
|
671
|
+
if (this.config.pushImgsInDynamic) {
|
|
672
|
+
// 判断是否为图文动态,且存在draw
|
|
673
|
+
if (item.type === "DYNAMIC_TYPE_DRAW" &&
|
|
674
|
+
item.modules.module_dynamic.major?.draw) {
|
|
675
|
+
for (const img of item.modules.module_dynamic.major.draw
|
|
676
|
+
.items) {
|
|
677
|
+
await this.broadcastToTargets(sub.target, (0, jsx_runtime_1.jsx)("img", { src: img.src, alt: "\u52A8\u6001\u56FE\u7247" }), type_1.PushType.Dynamic);
|
|
663
678
|
}
|
|
664
679
|
}
|
|
665
|
-
// logger
|
|
666
|
-
this.logger.info("动态推送完毕!");
|
|
667
680
|
}
|
|
681
|
+
// logger
|
|
682
|
+
this.logger.info("动态推送完毕!");
|
|
668
683
|
}
|
|
669
684
|
}
|
|
670
685
|
}
|
|
@@ -812,93 +827,104 @@ class ComRegister {
|
|
|
812
827
|
this.logger.info("动态ID与上一次获取第一条一致,结束循环");
|
|
813
828
|
break;
|
|
814
829
|
}
|
|
830
|
+
// 获取动态发布时间
|
|
831
|
+
const postTime = item.modules.module_author.pub_ts;
|
|
832
|
+
// logger
|
|
833
|
+
this.logger.info(`当前动态时间线:${postTime}`);
|
|
815
834
|
// logger
|
|
816
|
-
this.logger.info(`当前动态时间线:${item.modules.module_author.pub_ts}`);
|
|
817
835
|
this.logger.info(`上一次获取到第一条动态时间线:${timeline}`);
|
|
818
|
-
//
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
const upName = item.modules.module_author.name;
|
|
836
|
+
// logger
|
|
837
|
+
this.logger.info(`当前动态发布时间:${luxon_1.DateTime.fromSeconds(postTime).toFormat("yyyy-MM-dd HH:mm:ss")}`);
|
|
838
|
+
// logger
|
|
839
|
+
this.logger.info(`上一次获取到第一条动态发布时间:${luxon_1.DateTime.fromSeconds(timeline).toFormat("yyyy-MM-dd HH:mm:ss")}`);
|
|
840
|
+
// timeline已超过或与当前动态时间戳相同,则后面的动态不需要推送
|
|
841
|
+
if (postTime <= timeline) {
|
|
825
842
|
// logger
|
|
826
|
-
this.logger.info(
|
|
827
|
-
//
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
843
|
+
this.logger.info("当前动态时间戳已小于等于上一次获取到第一条动态时间线,更晚发布的动态无需监测");
|
|
844
|
+
// 结束本次监测
|
|
845
|
+
break;
|
|
846
|
+
}
|
|
847
|
+
// logger
|
|
848
|
+
this.logger.info("动态时间线大于上一次获取到第一条动态时间线,开始判断是否是订阅的UP主...");
|
|
849
|
+
// 从动态数据中取出UP主名称、UID
|
|
850
|
+
const upUID = item.modules.module_author.mid.toString();
|
|
851
|
+
const upName = item.modules.module_author.name;
|
|
852
|
+
// logger
|
|
853
|
+
this.logger.info(`当前动态UP主UID:${upUID},UP主名称:${upName}`);
|
|
854
|
+
// 寻找关注的UP主的动态
|
|
855
|
+
for (const sub of this.subManager) {
|
|
856
|
+
// 判断是否是订阅的UP主
|
|
857
|
+
if (sub.dynamic && sub.uid === upUID) {
|
|
858
|
+
// logger:订阅该UP主,推送该动态
|
|
859
|
+
this.logger.info("订阅该UP主,开始推送该动态...");
|
|
860
|
+
// logger
|
|
861
|
+
this.logger.info("开始生成推送卡片...");
|
|
862
|
+
// 推送该条动态
|
|
863
|
+
const buffer = await (0, utils_1.withRetry)(async () => {
|
|
864
|
+
// 渲染图片
|
|
865
|
+
return await this.ctx.gi.generateDynamicImg(item, sub.card);
|
|
866
|
+
}, 1).catch(async (e) => {
|
|
867
|
+
// 直播开播动态,不做处理
|
|
868
|
+
if (e.message === "直播开播动态,不做处理")
|
|
869
|
+
return;
|
|
870
|
+
if (e.message === "出现关键词,屏蔽该动态") {
|
|
871
|
+
// 如果需要发送才发送
|
|
872
|
+
if (this.config.filter.notify) {
|
|
873
|
+
await this.broadcastToTargets(sub.target, `${upName}发布了一条含有屏蔽关键字的动态`, type_1.PushType.Dynamic);
|
|
855
874
|
}
|
|
856
|
-
|
|
857
|
-
this.logger.error(`dynamicDetect generateDynamicImg() 推送卡片发送失败,原因:${e.message}`);
|
|
858
|
-
// 发送私聊消息并重启服务
|
|
859
|
-
await this.sendPrivateMsgAndStopService();
|
|
860
|
-
});
|
|
861
|
-
// 判断是否执行成功,未执行成功直接返回
|
|
862
|
-
if (!buffer) {
|
|
863
|
-
// logger
|
|
864
|
-
this.logger.info("推送卡片生成失败,或该动态为屏蔽动态,跳过该动态!");
|
|
865
|
-
// 结束循环
|
|
866
|
-
continue;
|
|
875
|
+
return;
|
|
867
876
|
}
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
this.logger.info("生成动态链接中...");
|
|
874
|
-
// 生成动态链接
|
|
875
|
-
dUrl = `${upName}发布了一条动态:https://t.bilibili.com/${dynamicId}`;
|
|
877
|
+
if (e.message === "已屏蔽转发动态") {
|
|
878
|
+
if (this.config.filter.notify) {
|
|
879
|
+
await this.broadcastToTargets(sub.target, `${upName}转发了一条动态,已屏蔽`, type_1.PushType.Dynamic);
|
|
880
|
+
}
|
|
881
|
+
return;
|
|
876
882
|
}
|
|
883
|
+
// 未知错误
|
|
884
|
+
this.logger.error(`dynamicDetect generateDynamicImg() 推送卡片发送失败,原因:${e.message}`);
|
|
885
|
+
// 发送私聊消息并重启服务
|
|
886
|
+
await this.sendPrivateMsgAndStopService();
|
|
887
|
+
});
|
|
888
|
+
// 判断是否执行成功,未执行成功直接返回
|
|
889
|
+
if (!buffer) {
|
|
877
890
|
// logger
|
|
878
|
-
this.logger.info("
|
|
879
|
-
//
|
|
880
|
-
|
|
891
|
+
this.logger.info("推送卡片生成失败,或该动态为屏蔽动态,跳过该动态!");
|
|
892
|
+
// 结束循环
|
|
893
|
+
continue;
|
|
894
|
+
}
|
|
895
|
+
// 定义动态链接
|
|
896
|
+
let dUrl = "";
|
|
897
|
+
// 判断是否需要发送URL
|
|
898
|
+
if (this.config.dynamicUrl) {
|
|
899
|
+
// logger
|
|
900
|
+
this.logger.info("生成动态链接中...");
|
|
901
|
+
// 生成动态链接
|
|
902
|
+
dUrl = `${upName}发布了一条动态:https://t.bilibili.com/${dynamicId}`;
|
|
903
|
+
}
|
|
904
|
+
// logger
|
|
905
|
+
this.logger.info("推送动态中...");
|
|
906
|
+
// 发送推送卡片
|
|
907
|
+
await this.broadcastToTargets(sub.target, (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [koishi_1.h.image(buffer, "image/jpeg"), dUrl] }), type_1.PushType.Dynamic);
|
|
908
|
+
// 判断是否需要发送动态中的图片
|
|
909
|
+
if (this.config.pushImgsInDynamic) {
|
|
881
910
|
// logger
|
|
882
|
-
this.logger.info("
|
|
883
|
-
//
|
|
884
|
-
if (
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
item.modules.module_dynamic.major?.draw) {
|
|
890
|
-
for (const img of item.modules.module_dynamic.major.draw
|
|
891
|
-
.items) {
|
|
892
|
-
await this.broadcastToTargets(sub.target, (0, jsx_runtime_1.jsx)("img", { src: img.src, alt: "\u52A8\u6001\u56FE\u7247" }), type_1.PushType.Dynamic);
|
|
893
|
-
}
|
|
911
|
+
this.logger.info("开始推送动态中的图片...");
|
|
912
|
+
// 判断是否为图文动态,且存在draw
|
|
913
|
+
if (item.type === "DYNAMIC_TYPE_DRAW" &&
|
|
914
|
+
item.modules.module_dynamic.major?.draw) {
|
|
915
|
+
for (const img of item.modules.module_dynamic.major.draw
|
|
916
|
+
.items) {
|
|
917
|
+
await this.broadcastToTargets(sub.target, (0, jsx_runtime_1.jsx)("img", { src: img.src, alt: "\u52A8\u6001\u56FE\u7247" }), type_1.PushType.Dynamic);
|
|
894
918
|
}
|
|
895
|
-
// logger
|
|
896
|
-
this.logger.info("图片推送完毕!");
|
|
897
919
|
}
|
|
898
920
|
// logger
|
|
899
|
-
this.logger.info("
|
|
921
|
+
this.logger.info("图片推送完毕!");
|
|
900
922
|
}
|
|
923
|
+
// logger
|
|
924
|
+
this.logger.info("动态推送完毕!");
|
|
901
925
|
}
|
|
926
|
+
// logger
|
|
927
|
+
this.logger.info("不是关注的UP主,跳过该动态");
|
|
902
928
|
}
|
|
903
929
|
}
|
|
904
930
|
// 更新本次请求第一条动态的动态ID
|
|
@@ -910,6 +936,10 @@ class ComRegister {
|
|
|
910
936
|
items[0].modules.module_author.pub_ts || luxon_1.DateTime.now().toSeconds();
|
|
911
937
|
// logger
|
|
912
938
|
this.logger.info(`更新时间线:${timeline}`);
|
|
939
|
+
// logger
|
|
940
|
+
this.logger.info(`时间线格式化:${luxon_1.DateTime.fromSeconds(timeline).toFormat("yyyy-MM-dd HH:mm:ss")}`);
|
|
941
|
+
// logger
|
|
942
|
+
this.logger.info("动态监测完成,等待下一次检测...");
|
|
913
943
|
};
|
|
914
944
|
// 返回一个闭包函数
|
|
915
945
|
return (0, utils_1.withLock)(handler);
|
|
@@ -998,7 +1028,9 @@ class ComRegister {
|
|
|
998
1028
|
// 推送直播信息
|
|
999
1029
|
const msg = ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [koishi_1.h.image(buffer, "image/jpeg"), liveNotifyMsg || ""] }));
|
|
1000
1030
|
// 只有在开播时才艾特全体成员
|
|
1001
|
-
return await this.broadcastToTargets(target, msg, liveType === type_1.LiveType.StartBroadcasting
|
|
1031
|
+
return await this.broadcastToTargets(target, msg, liveType === type_1.LiveType.StartBroadcasting
|
|
1032
|
+
? type_1.PushType.StartBroadcasting
|
|
1033
|
+
: type_1.PushType.Live);
|
|
1002
1034
|
};
|
|
1003
1035
|
// 找到频道/群组对应的
|
|
1004
1036
|
const liveGuardBuyPushTargetArr = target.map((channel) => {
|
|
@@ -1552,10 +1584,6 @@ class ComRegister {
|
|
|
1552
1584
|
masterAccount: koishi_1.Schema.string(),
|
|
1553
1585
|
masterAccountGuildId: koishi_1.Schema.string(),
|
|
1554
1586
|
}),
|
|
1555
|
-
liveDetectMode: koishi_1.Schema.union([
|
|
1556
|
-
koishi_1.Schema.const("API"),
|
|
1557
|
-
koishi_1.Schema.const("WS"),
|
|
1558
|
-
]).required(),
|
|
1559
1587
|
restartPush: koishi_1.Schema.boolean().required(),
|
|
1560
1588
|
pushTime: koishi_1.Schema.number().required(),
|
|
1561
1589
|
pushImgsInDynamic: koishi_1.Schema.boolean().required(),
|
package/lib/index.d.ts
CHANGED
package/lib/index.js
CHANGED
|
@@ -127,7 +127,6 @@ class ServerManager extends koishi_1.Service {
|
|
|
127
127
|
subLoadTimeout: globalConfig.subLoadTimeout,
|
|
128
128
|
sub: globalConfig.sub,
|
|
129
129
|
master: globalConfig.master,
|
|
130
|
-
liveDetectMode: globalConfig.liveDetectMode,
|
|
131
130
|
restartPush: globalConfig.restartPush,
|
|
132
131
|
pushTime: globalConfig.pushTime,
|
|
133
132
|
pushImgsInDynamic: globalConfig.pushImgsInDynamic,
|
|
@@ -325,15 +324,6 @@ exports.Config = koishi_1.Schema.object({
|
|
|
325
324
|
.default(false)
|
|
326
325
|
.description("是否推送动态中的图片,默认不开启。开启后会单独推送动态中的图片"),
|
|
327
326
|
live: koishi_1.Schema.object({}).description("直播推送设置"),
|
|
328
|
-
liveDetectMode: koishi_1.Schema.union([
|
|
329
|
-
koishi_1.Schema.const("WS").description("WebSocket模式:连接到对应的直播间,可推送弹幕消息,开播下播响应最快,但对订阅数有限制"),
|
|
330
|
-
koishi_1.Schema.const("API")
|
|
331
|
-
.description("API模式:请求对应直播间API,无法获取弹幕消息,开播下播响应慢,理论可无限订阅")
|
|
332
|
-
.deprecated(),
|
|
333
|
-
])
|
|
334
|
-
.role("radio")
|
|
335
|
-
.description("直播检测模式")
|
|
336
|
-
.default("WS"),
|
|
337
327
|
restartPush: koishi_1.Schema.boolean()
|
|
338
328
|
.default(true)
|
|
339
329
|
.description("插件重启后,如果订阅的主播正在直播,是否进行一次推送,默认开启"),
|
package/lib/type/index.d.ts
CHANGED
|
@@ -5,13 +5,14 @@ export declare enum LiveType {
|
|
|
5
5
|
StopBroadcast = 3,
|
|
6
6
|
FirstLiveBroadcast = 4
|
|
7
7
|
}
|
|
8
|
-
export type
|
|
8
|
+
export type Channel = {
|
|
9
9
|
channelId: string;
|
|
10
10
|
dynamic: boolean;
|
|
11
11
|
live: boolean;
|
|
12
12
|
liveGuardBuy: boolean;
|
|
13
13
|
atAll: boolean;
|
|
14
|
-
}
|
|
14
|
+
};
|
|
15
|
+
export type ChannelArr = Array<Channel>;
|
|
15
16
|
export type TargetItem = {
|
|
16
17
|
channelArr: ChannelArr;
|
|
17
18
|
platform: string;
|
package/package.json
CHANGED
package/readme.md
CHANGED
|
@@ -233,6 +233,8 @@ uid为必填参数,为要推送的UP主的UID,index为可选参数,为要
|
|
|
233
233
|
- ver 3.1.0-alpha.0 修复:新插件在第一次订阅时提示 `订阅失败,错误信息:该分组已经存在`; 移除:消息重发功能; 重构:将消息发送模式改为 `broadcast`
|
|
234
234
|
- ver 3.1.0-alpha.1 修复:无法发送 `@全体成员` 消息,将消息发送模式改回
|
|
235
235
|
- ver 3.1.0 修复:订阅某位UP主直播和动态后,某些群聊只开启推送直播也会推送动态
|
|
236
|
+
- ver 3.1.1-alpha.0 修复:稿件重投后,会将之前日期的动态一起推送; 优化:加强动态debug输出; 移除:不必要选项 `live.liveDetectMode`
|
|
237
|
+
- ver 3.1.2-alpha.0 重构:对消息发送模块进行小型重构,多群多平台推送将不再支持艾特全体成员,仅单平台单群聊支持; 移除:群聊 `all` 选项
|
|
236
238
|
|
|
237
239
|
## 交流群
|
|
238
240
|
|