koishi-plugin-bilibili-notify 2.0.0-alpha.15 → 2.0.0-alpha.16
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 +11 -1
- package/lib/comRegister.js +37 -19
- package/lib/index.d.ts +9 -1
- package/lib/index.js +13 -5
- package/package.json +1 -1
- package/readme.md +1 -0
package/lib/comRegister.d.ts
CHANGED
|
@@ -3,6 +3,8 @@ import { Notifier } from "@koishijs/plugin-notifier";
|
|
|
3
3
|
import { LoginBili } from "./database";
|
|
4
4
|
type ChannelIdArr = Array<{
|
|
5
5
|
channelId: string;
|
|
6
|
+
dynamic: boolean;
|
|
7
|
+
live: boolean;
|
|
6
8
|
atAll: boolean;
|
|
7
9
|
}>;
|
|
8
10
|
type TargetItem = {
|
|
@@ -69,7 +71,15 @@ declare namespace ComRegister {
|
|
|
69
71
|
uid: string;
|
|
70
72
|
dynamic: boolean;
|
|
71
73
|
live: boolean;
|
|
72
|
-
target:
|
|
74
|
+
target: Array<{
|
|
75
|
+
channelIdArr: Array<{
|
|
76
|
+
channelId: string;
|
|
77
|
+
dynamic: boolean;
|
|
78
|
+
live: boolean;
|
|
79
|
+
atAll: boolean;
|
|
80
|
+
}>;
|
|
81
|
+
platform: string;
|
|
82
|
+
}>;
|
|
73
83
|
}>;
|
|
74
84
|
master: {
|
|
75
85
|
enable: boolean;
|
package/lib/comRegister.js
CHANGED
|
@@ -276,6 +276,8 @@ class ComRegister {
|
|
|
276
276
|
groupId.forEach(group => {
|
|
277
277
|
channelIdArr.push({
|
|
278
278
|
channelId: group,
|
|
279
|
+
dynamic: true,
|
|
280
|
+
live: true,
|
|
279
281
|
atAll: options.atAll
|
|
280
282
|
});
|
|
281
283
|
});
|
|
@@ -335,7 +337,7 @@ class ComRegister {
|
|
|
335
337
|
// 判断targetArr是否为空
|
|
336
338
|
if (target.length === 0) {
|
|
337
339
|
// 为空则默认为当前环境
|
|
338
|
-
target = [{ channelIdArr: [{ channelId: session.event.channel.id, atAll: options.atAll }], platform: session.event.platform }];
|
|
340
|
+
target = [{ channelIdArr: [{ channelId: session.event.channel.id, dynamic: true, live: true, atAll: options.atAll }], platform: session.event.platform }];
|
|
339
341
|
// 没有满足条件的群组或频道
|
|
340
342
|
await session.send('没有满足条件的群组或频道,默认订阅到当前聊天环境');
|
|
341
343
|
}
|
|
@@ -346,7 +348,7 @@ class ComRegister {
|
|
|
346
348
|
}
|
|
347
349
|
else {
|
|
348
350
|
// 未填写群号或频道号,默认为当前环境
|
|
349
|
-
target = [{ channelIdArr: [{ channelId: session.event.channel.id, atAll: options.atAll }], platform: session.event.platform }];
|
|
351
|
+
target = [{ channelIdArr: [{ channelId: session.event.channel.id, dynamic: true, live: true, atAll: options.atAll }], platform: session.event.platform }];
|
|
350
352
|
// 发送提示消息
|
|
351
353
|
await session.send('没有填写群号或频道号,默认订阅到当前聊天环境');
|
|
352
354
|
}
|
|
@@ -354,7 +356,7 @@ class ComRegister {
|
|
|
354
356
|
}
|
|
355
357
|
else {
|
|
356
358
|
// 用户直接订阅,将当前环境赋值给target
|
|
357
|
-
target = [{ channelIdArr: [{ channelId: session.event.channel.id, atAll: options.atAll }], platform: session.event.platform }];
|
|
359
|
+
target = [{ channelIdArr: [{ channelId: session.event.channel.id, dynamic: true, live: true, atAll: options.atAll }], platform: session.event.platform }];
|
|
358
360
|
}
|
|
359
361
|
}
|
|
360
362
|
// 定义外围变量
|
|
@@ -587,7 +589,7 @@ class ComRegister {
|
|
|
587
589
|
const channelIdArr = idStr.split(',').map(id => {
|
|
588
590
|
const atAll = /@$/.test(id); // 使用正则表达式检查 id 是否以 @ 结尾
|
|
589
591
|
const channelId = atAll ? id.slice(0, -1) : id; // 去除末尾的 @
|
|
590
|
-
return { channelId, atAll };
|
|
592
|
+
return { channelId, dynamic: true, live: true, atAll };
|
|
591
593
|
});
|
|
592
594
|
return { channelIdArr, platform };
|
|
593
595
|
});
|
|
@@ -658,22 +660,33 @@ class ComRegister {
|
|
|
658
660
|
if (target.channelIdArr[0].channelId === 'all') {
|
|
659
661
|
// 获取所有guild
|
|
660
662
|
for (const guild of (await bot.getGuildList()).data) {
|
|
661
|
-
sendArr.push({
|
|
663
|
+
sendArr.push({
|
|
664
|
+
channelId: guild.id,
|
|
665
|
+
dynamic: target.channelIdArr[0].dynamic,
|
|
666
|
+
live: target.channelIdArr[0].live,
|
|
667
|
+
atAll: target.channelIdArr[0].atAll
|
|
668
|
+
});
|
|
662
669
|
}
|
|
663
670
|
}
|
|
664
671
|
else {
|
|
665
672
|
sendArr = target.channelIdArr;
|
|
666
673
|
}
|
|
667
|
-
//
|
|
674
|
+
// 判断是否是直播推送,如果是则需要进一步判断是否需要艾特群体成员
|
|
668
675
|
if (live) {
|
|
669
|
-
//
|
|
676
|
+
// 直播开播推送,判断是否需要艾特全体成员
|
|
670
677
|
for (const channel of sendArr) {
|
|
671
|
-
|
|
678
|
+
// 判断是否需要推送直播消息
|
|
679
|
+
if (channel.live) {
|
|
680
|
+
await this.sendMsgFunc(bot, channel.channelId, (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [content, channel.atAll && (0, jsx_runtime_1.jsx)("at", { type: "all" })] }));
|
|
681
|
+
}
|
|
672
682
|
}
|
|
673
683
|
}
|
|
674
684
|
else {
|
|
675
685
|
for (const channel of sendArr) {
|
|
676
|
-
|
|
686
|
+
// 判断是否需要推送动态消息和直播消息
|
|
687
|
+
if (channel.dynamic || channel.live) {
|
|
688
|
+
await this.sendMsgFunc(bot, channel.channelId, content);
|
|
689
|
+
}
|
|
677
690
|
}
|
|
678
691
|
}
|
|
679
692
|
}
|
|
@@ -1405,8 +1418,6 @@ class ComRegister {
|
|
|
1405
1418
|
}
|
|
1406
1419
|
async loadSubFromConfig(ctx, subs) {
|
|
1407
1420
|
for (const sub of subs) {
|
|
1408
|
-
// 整理target
|
|
1409
|
-
const target = this.splitMultiPlatformStr(sub.target);
|
|
1410
1421
|
// 定义Data
|
|
1411
1422
|
let data;
|
|
1412
1423
|
// 定义直播销毁函数
|
|
@@ -1445,7 +1456,7 @@ class ComRegister {
|
|
|
1445
1456
|
if (sub.live) {
|
|
1446
1457
|
// 订阅直播
|
|
1447
1458
|
liveDispose = ctx.setInterval(() => {
|
|
1448
|
-
this.liveDetect(ctx, data.live_room.room_id, target);
|
|
1459
|
+
this.liveDetect(ctx, data.live_room.room_id, sub.target);
|
|
1449
1460
|
}, this.config.liveLoopTime * 1000);
|
|
1450
1461
|
}
|
|
1451
1462
|
}
|
|
@@ -1459,7 +1470,7 @@ class ComRegister {
|
|
|
1459
1470
|
id: +sub.uid,
|
|
1460
1471
|
uid: sub.uid,
|
|
1461
1472
|
roomId: sub.live ? data.live_room.roomid : '',
|
|
1462
|
-
target,
|
|
1473
|
+
target: sub.target,
|
|
1463
1474
|
platform: '',
|
|
1464
1475
|
live: sub.live,
|
|
1465
1476
|
dynamic: sub.dynamic,
|
|
@@ -1736,12 +1747,19 @@ class ComRegister {
|
|
|
1736
1747
|
(function (ComRegister) {
|
|
1737
1748
|
ComRegister.Config = koishi_1.Schema.object({
|
|
1738
1749
|
sub: koishi_1.Schema.array(koishi_1.Schema.object({
|
|
1739
|
-
uid: koishi_1.Schema.string(),
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
1750
|
+
uid: koishi_1.Schema.string().description('订阅用户UID'),
|
|
1751
|
+
dynamic: koishi_1.Schema.boolean().description('是否订阅用户动态'),
|
|
1752
|
+
live: koishi_1.Schema.boolean().description('是否订阅用户直播'),
|
|
1753
|
+
target: koishi_1.Schema.array(koishi_1.Schema.object({
|
|
1754
|
+
channelIdArr: koishi_1.Schema.array(koishi_1.Schema.object({
|
|
1755
|
+
channelId: koishi_1.Schema.string().description('频道/群组号'),
|
|
1756
|
+
dynamic: koishi_1.Schema.boolean().description('该频道/群组是否推送动态信息'),
|
|
1757
|
+
live: koishi_1.Schema.boolean().description('该频道/群组是否推送直播通知'),
|
|
1758
|
+
atAll: koishi_1.Schema.boolean().description('推送开播通知时是否艾特全体成员')
|
|
1759
|
+
})).description('频道/群组信息'),
|
|
1760
|
+
platform: koishi_1.Schema.string().description('推送平台')
|
|
1761
|
+
})).description('订阅用户需要发送的频道/群组信息')
|
|
1762
|
+
})).role('table').description('手动输入订阅信息,方便自定义订阅内容,这里的订阅内容不会存入数据库。uid: 订阅用户UID,dynamic: 是否需要订阅动态,live: 是否需要订阅直播'),
|
|
1745
1763
|
master: koishi_1.Schema.object({
|
|
1746
1764
|
enable: koishi_1.Schema.boolean(),
|
|
1747
1765
|
platform: koishi_1.Schema.string(),
|
package/lib/index.d.ts
CHANGED
|
@@ -20,7 +20,15 @@ export interface Config {
|
|
|
20
20
|
uid: string;
|
|
21
21
|
dynamic: boolean;
|
|
22
22
|
live: boolean;
|
|
23
|
-
target:
|
|
23
|
+
target: Array<{
|
|
24
|
+
channelIdArr: Array<{
|
|
25
|
+
channelId: string;
|
|
26
|
+
dynamic: boolean;
|
|
27
|
+
live: boolean;
|
|
28
|
+
atAll: boolean;
|
|
29
|
+
}>;
|
|
30
|
+
platform: string;
|
|
31
|
+
}>;
|
|
24
32
|
}>;
|
|
25
33
|
dynamic: {};
|
|
26
34
|
dynamicUrl: boolean;
|
package/lib/index.js
CHANGED
|
@@ -95,11 +95,19 @@ exports.Config = koishi_1.Schema.object({
|
|
|
95
95
|
.description('设置请求头User-Agen,请求出现-352时可以尝试修改,UA获取方法可参考:https://blog.csdn.net/qq_44503987/article/details/104929111'),
|
|
96
96
|
subTitle: koishi_1.Schema.object({}).description('手动订阅'),
|
|
97
97
|
sub: koishi_1.Schema.array(koishi_1.Schema.object({
|
|
98
|
-
uid: koishi_1.Schema.string(),
|
|
99
|
-
dynamic: koishi_1.Schema.boolean(),
|
|
100
|
-
live: koishi_1.Schema.boolean(),
|
|
101
|
-
target: koishi_1.Schema.
|
|
102
|
-
|
|
98
|
+
uid: koishi_1.Schema.string().description('订阅用户UID'),
|
|
99
|
+
dynamic: koishi_1.Schema.boolean().description('是否订阅用户动态'),
|
|
100
|
+
live: koishi_1.Schema.boolean().description('是否订阅用户直播'),
|
|
101
|
+
target: koishi_1.Schema.array(koishi_1.Schema.object({
|
|
102
|
+
channelIdArr: koishi_1.Schema.array(koishi_1.Schema.object({
|
|
103
|
+
channelId: koishi_1.Schema.string().description('频道/群组号'),
|
|
104
|
+
dynamic: koishi_1.Schema.boolean().description('该频道/群组是否推送动态信息'),
|
|
105
|
+
live: koishi_1.Schema.boolean().description('该频道/群组是否推送直播通知'),
|
|
106
|
+
atAll: koishi_1.Schema.boolean().description('推送开播通知时是否艾特全体成员')
|
|
107
|
+
})).description('频道/群组信息'),
|
|
108
|
+
platform: koishi_1.Schema.string().description('推送平台')
|
|
109
|
+
})).description('订阅用户需要发送的频道/群组信息')
|
|
110
|
+
})).role('table').description('手动输入订阅信息,方便自定义订阅内容,这里的订阅内容不会存入数据库。uid: 订阅用户UID,dynamic: 是否需要订阅动态,live: 是否需要订阅直播'),
|
|
103
111
|
dynamic: koishi_1.Schema.object({}).description('动态推送设置'),
|
|
104
112
|
dynamicUrl: koishi_1.Schema.boolean()
|
|
105
113
|
.default(false)
|
package/package.json
CHANGED
package/readme.md
CHANGED