koishi-plugin-bilibili-notify 1.2.0-rc.3 → 1.2.0-rc.5
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 +7 -0
- package/lib/comRegister.js +30 -27
- package/lib/generateImg.d.ts +0 -1
- package/lib/generateImg.js +1 -1
- package/lib/index.js +6 -3
- package/package.json +1 -1
- package/readme.md +2 -0
package/lib/comRegister.d.ts
CHANGED
|
@@ -12,6 +12,7 @@ declare class ComRegister {
|
|
|
12
12
|
uid: string;
|
|
13
13
|
roomId: string;
|
|
14
14
|
targetId: string;
|
|
15
|
+
platform: string;
|
|
15
16
|
live: boolean;
|
|
16
17
|
dynamic: boolean;
|
|
17
18
|
liveDispose: Function;
|
|
@@ -43,6 +44,12 @@ declare namespace ComRegister {
|
|
|
43
44
|
customLiveEnd: string;
|
|
44
45
|
dynamicLoopTime: number;
|
|
45
46
|
dynamicCheckNumber: number;
|
|
47
|
+
filter: {
|
|
48
|
+
enable: boolean;
|
|
49
|
+
regex: string;
|
|
50
|
+
keywords: Array<string>;
|
|
51
|
+
notify: boolean;
|
|
52
|
+
};
|
|
46
53
|
}
|
|
47
54
|
const Config: Schema<Config>;
|
|
48
55
|
}
|
package/lib/comRegister.js
CHANGED
|
@@ -440,6 +440,7 @@ class ComRegister {
|
|
|
440
440
|
uid: mid,
|
|
441
441
|
targetId,
|
|
442
442
|
roomId,
|
|
443
|
+
platform: session.event.platform,
|
|
443
444
|
live: liveMsg,
|
|
444
445
|
dynamic: dynamicMsg,
|
|
445
446
|
liveDispose: null,
|
|
@@ -454,16 +455,15 @@ class ComRegister {
|
|
|
454
455
|
catch (e) {
|
|
455
456
|
return 'bili sub指令 getMasterInfo() 网络请求失败,请重试';
|
|
456
457
|
}
|
|
457
|
-
this.logger.info(session.event.platform);
|
|
458
458
|
// 需要订阅直播
|
|
459
459
|
if (liveMsg) {
|
|
460
|
-
await session.execute(`bili live ${roomId} ${targetId.split(',').join(' ')}
|
|
460
|
+
await session.execute(`bili live ${roomId} ${targetId.split(',').join(' ')}`);
|
|
461
461
|
// 发送订阅消息通知
|
|
462
462
|
await session.send(`订阅${userData.info.uname}直播通知`);
|
|
463
463
|
}
|
|
464
464
|
// 需要订阅动态
|
|
465
465
|
if (dynamicMsg) {
|
|
466
|
-
await session.execute(`bili dynamic ${mid} ${targetId.split(',').join(' ')}
|
|
466
|
+
await session.execute(`bili dynamic ${mid} ${targetId.split(',').join(' ')}`);
|
|
467
467
|
// 发送订阅消息通知
|
|
468
468
|
await session.send(`订阅${userData.info.uname}动态通知`);
|
|
469
469
|
}
|
|
@@ -472,31 +472,28 @@ class ComRegister {
|
|
|
472
472
|
});
|
|
473
473
|
biliCom
|
|
474
474
|
.subcommand('.dynamic <uid:string> <...guildId:string>', '订阅用户动态推送', { hidden: true })
|
|
475
|
-
.option('bot', '-b <type:string>')
|
|
475
|
+
// .option('bot', '-b <type:string>')
|
|
476
476
|
.usage('订阅用户动态推送')
|
|
477
477
|
.example('bili dynamic 1194210119 订阅UID为1194210119的动态')
|
|
478
|
-
.action(async ({ session
|
|
478
|
+
.action(async ({ session }, uid, ...guildId) => {
|
|
479
479
|
this.logger.info('调用bili.dynamic指令');
|
|
480
|
-
this.logger.info('Platform:', options.bot);
|
|
481
480
|
// 如果uid为空则返回
|
|
482
481
|
if (!uid)
|
|
483
482
|
return `${uid}非法调用 dynamic 指令`; // 用户uid不能为空
|
|
484
483
|
if (!guildId)
|
|
485
484
|
return `${uid}非法调用 dynamic 指令`; // 目标群组或频道不能为空
|
|
486
|
-
if (!options.bot) {
|
|
487
|
-
this.logger.warn(`${uid}非法调用 dynamic 指令,未传入订阅平台`)
|
|
488
|
-
return `${uid}非法调用 dynamic
|
|
489
|
-
}
|
|
485
|
+
/* if (!options.bot) {
|
|
486
|
+
this.logger.warn(`${uid}非法调用 dynamic 指令,未传入订阅平台`)
|
|
487
|
+
return `${uid}非法调用 dynamic 指令`
|
|
488
|
+
} */
|
|
490
489
|
// 寻找对应订阅管理对象
|
|
491
490
|
const index = this.subManager.findIndex(sub => sub.uid === uid);
|
|
492
491
|
// 不存在则直接返回
|
|
493
|
-
if (index === -1)
|
|
494
|
-
|
|
495
|
-
return;
|
|
496
|
-
}
|
|
492
|
+
if (index === -1)
|
|
493
|
+
return '请勿直接调用该指令';
|
|
497
494
|
// 获取对应Bot
|
|
498
495
|
let bot;
|
|
499
|
-
switch (
|
|
496
|
+
switch (session.event.platform) {
|
|
500
497
|
case 'qq':
|
|
501
498
|
bot = this.qqBot;
|
|
502
499
|
break;
|
|
@@ -524,29 +521,27 @@ class ComRegister {
|
|
|
524
521
|
});
|
|
525
522
|
biliCom
|
|
526
523
|
.subcommand('.live <roomId:string> <...guildId:string>', '订阅主播开播通知', { hidden: true })
|
|
527
|
-
.option('bot', '-b <type:string>')
|
|
524
|
+
// .option('bot', '-b <type:string>')
|
|
528
525
|
.usage('订阅主播开播通知')
|
|
529
526
|
.example('bili live 26316137 订阅房间号为26316137的直播间')
|
|
530
|
-
.action(async ({
|
|
527
|
+
.action(async ({ session }, roomId, ...guildId) => {
|
|
531
528
|
this.logger.info('调用bili.live指令');
|
|
532
|
-
this.logger.info('Platform:', options.bot);
|
|
533
529
|
// 如果room_id为空则返回
|
|
534
530
|
if (!roomId)
|
|
535
531
|
return `${roomId}非法调用 dynamic 指令`; // 订阅主播房间号不能为空
|
|
536
532
|
if (!guildId)
|
|
537
533
|
return `${roomId}非法调用 dynamic 指令`; // 目标群组或频道不能为空
|
|
538
|
-
if (!options.bot) {
|
|
539
|
-
this.logger.warn(`${roomId}非法调用 dynamic 指令,未传入推送平台`)
|
|
540
|
-
return `${roomId}非法调用 dynamic
|
|
541
|
-
}
|
|
542
|
-
// 保存到订阅管理对象
|
|
543
|
-
const index = this.subManager.findIndex(sub => sub.roomId === roomId);
|
|
534
|
+
/* if (!options.bot) {
|
|
535
|
+
this.logger.warn(`${roomId}非法调用 dynamic 指令,未传入推送平台`)
|
|
536
|
+
return `${roomId}非法调用 dynamic 指令`
|
|
537
|
+
} */
|
|
544
538
|
// 要订阅的对象不在订阅管理对象中,直接返回
|
|
539
|
+
const index = this.subManager.findIndex(sub => sub.roomId === roomId);
|
|
545
540
|
if (index === -1)
|
|
546
541
|
return '请勿直接调用该指令';
|
|
547
542
|
// 获取对应Bot
|
|
548
543
|
let bot;
|
|
549
|
-
switch (
|
|
544
|
+
switch (session.event.platform) {
|
|
550
545
|
case 'qq':
|
|
551
546
|
bot = this.qqBot;
|
|
552
547
|
break;
|
|
@@ -678,7 +673,8 @@ class ComRegister {
|
|
|
678
673
|
if (e.message === '直播开播动态,不做处理')
|
|
679
674
|
break;
|
|
680
675
|
if (e.message === '出现关键词,屏蔽该动态') {
|
|
681
|
-
|
|
676
|
+
// 如果需要发送才发送
|
|
677
|
+
this.config.filter.notify && await this.sendMsg(guildId, bot, `UID:${uid} 发布了一条含有屏蔽关键字的动态`);
|
|
682
678
|
break;
|
|
683
679
|
}
|
|
684
680
|
}
|
|
@@ -1065,6 +1061,7 @@ class ComRegister {
|
|
|
1065
1061
|
uid: sub.uid,
|
|
1066
1062
|
roomId: sub.room_id,
|
|
1067
1063
|
targetId: sub.targetId,
|
|
1064
|
+
platform: sub.platform,
|
|
1068
1065
|
live: +sub.live === 1 ? true : false,
|
|
1069
1066
|
dynamic: +sub.dynamic === 1 ? true : false,
|
|
1070
1067
|
liveDispose: null,
|
|
@@ -1171,7 +1168,13 @@ class ComRegister {
|
|
|
1171
1168
|
customLiveStart: koishi_1.Schema.string().required(),
|
|
1172
1169
|
customLiveEnd: koishi_1.Schema.string().required(),
|
|
1173
1170
|
dynamicLoopTime: koishi_1.Schema.number().default(60),
|
|
1174
|
-
dynamicCheckNumber: koishi_1.Schema.number().required()
|
|
1171
|
+
dynamicCheckNumber: koishi_1.Schema.number().required(),
|
|
1172
|
+
filter: koishi_1.Schema.object({
|
|
1173
|
+
enable: koishi_1.Schema.boolean(),
|
|
1174
|
+
regex: koishi_1.Schema.string(),
|
|
1175
|
+
keywords: koishi_1.Schema.array(String),
|
|
1176
|
+
notify: koishi_1.Schema.boolean(),
|
|
1177
|
+
}),
|
|
1175
1178
|
});
|
|
1176
1179
|
})(ComRegister || (ComRegister = {}));
|
|
1177
1180
|
exports.default = ComRegister;
|
package/lib/generateImg.d.ts
CHANGED
package/lib/generateImg.js
CHANGED
|
@@ -1367,7 +1367,7 @@ class GenerateImg extends koishi_1.Service {
|
|
|
1367
1367
|
enable: koishi_1.Schema.boolean(),
|
|
1368
1368
|
regex: koishi_1.Schema.string(),
|
|
1369
1369
|
keywords: koishi_1.Schema.array(String),
|
|
1370
|
-
|
|
1370
|
+
notify: koishi_1.Schema.boolean(),
|
|
1371
1371
|
}),
|
|
1372
1372
|
removeBorder: koishi_1.Schema.boolean(),
|
|
1373
1373
|
cardColorStart: koishi_1.Schema.string(),
|
package/lib/index.js
CHANGED
|
@@ -114,7 +114,9 @@ exports.Config = koishi_1.Schema.object({
|
|
|
114
114
|
regex: koishi_1.Schema.string()
|
|
115
115
|
.description('正则表达式屏蔽'),
|
|
116
116
|
keywords: koishi_1.Schema.array(String)
|
|
117
|
-
.description('关键字屏蔽,一个关键字为一项')
|
|
117
|
+
.description('关键字屏蔽,一个关键字为一项'),
|
|
118
|
+
notify: koishi_1.Schema.boolean()
|
|
119
|
+
.description('动态被屏蔽是否发送提示')
|
|
118
120
|
}),
|
|
119
121
|
koishi_1.Schema.object({})
|
|
120
122
|
])
|
|
@@ -182,12 +184,13 @@ function apply(ctx, config) {
|
|
|
182
184
|
customLiveStart: config.customLiveStart,
|
|
183
185
|
customLiveEnd: config.customLiveEnd,
|
|
184
186
|
dynamicCheckNumber: config.dynamicCheckNumber,
|
|
185
|
-
dynamicLoopTime
|
|
187
|
+
dynamicLoopTime,
|
|
188
|
+
filter: config.filter
|
|
186
189
|
});
|
|
187
190
|
// 当用户输入“恶魔兔,启动!”时,执行 help 指令
|
|
188
191
|
ctx.middleware((session, next) => {
|
|
189
192
|
if (session.content === '恶魔兔,启动!') {
|
|
190
|
-
return session.
|
|
193
|
+
return session.send('启动不了一点');
|
|
191
194
|
}
|
|
192
195
|
else {
|
|
193
196
|
return next();
|
package/package.json
CHANGED
package/readme.md
CHANGED