koishi-plugin-bilibili-notify 3.1.1-alpha.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 -0
- package/lib/comRegister.js +81 -70
- package/lib/type/index.d.ts +3 -2
- package/package.json +1 -1
- package/readme.md +1 -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;
|
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
|
-
}
|
|
496
|
-
}
|
|
497
|
-
|
|
498
|
-
await pushTypePatternMatching[type]();
|
|
455
|
+
}
|
|
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;
|
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
|
@@ -234,6 +234,7 @@ uid为必填参数,为要推送的UP主的UID,index为可选参数,为要
|
|
|
234
234
|
- ver 3.1.0-alpha.1 修复:无法发送 `@全体成员` 消息,将消息发送模式改回
|
|
235
235
|
- ver 3.1.0 修复:订阅某位UP主直播和动态后,某些群聊只开启推送直播也会推送动态
|
|
236
236
|
- ver 3.1.1-alpha.0 修复:稿件重投后,会将之前日期的动态一起推送; 优化:加强动态debug输出; 移除:不必要选项 `live.liveDetectMode`
|
|
237
|
+
- ver 3.1.2-alpha.0 重构:对消息发送模块进行小型重构,多群多平台推送将不再支持艾特全体成员,仅单平台单群聊支持; 移除:群聊 `all` 选项
|
|
237
238
|
|
|
238
239
|
## 交流群
|
|
239
240
|
|