koishi-plugin-bilibili-notify 1.2.0-rc.4 → 1.2.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/biliAPI.js +7 -0
- package/lib/comRegister.d.ts +7 -0
- package/lib/comRegister.js +21 -14
- package/lib/font/HYZhengYuan-75W.ttf +0 -0
- package/lib/generateImg.d.ts +2 -1
- package/lib/generateImg.js +6 -2
- package/lib/index.d.ts +1 -0
- package/lib/index.js +16 -10
- package/package.json +1 -1
- package/readme.md +4 -1
package/lib/biliAPI.js
CHANGED
|
@@ -9,6 +9,8 @@ const tough_cookie_1 = require("tough-cookie");
|
|
|
9
9
|
const axios_cookiejar_support_1 = require("axios-cookiejar-support");
|
|
10
10
|
const jsdom_1 = require("jsdom");
|
|
11
11
|
const luxon_1 = require("luxon");
|
|
12
|
+
// 在getUserInfo中检测到番剧出差的UID时,要传回的数据:
|
|
13
|
+
const bangumiTripData = { "code": 0, "data": { "live_room": { "roomid": 931774 } } };
|
|
12
14
|
// const GET_DYNAMIC_LIST = 'https://api.bilibili.com/x/polymer/web-dynamic/v1/feed/all'
|
|
13
15
|
const GET_USER_SPACE_DYNAMIC_LIST = 'https://api.bilibili.com/x/polymer/web-dynamic/v1/feed/space';
|
|
14
16
|
const GET_COOKIES_INFO = 'https://passport.bilibili.com/x/passport-login/web/cookie/info';
|
|
@@ -127,6 +129,11 @@ class BiliAPI extends koishi_1.Service {
|
|
|
127
129
|
}
|
|
128
130
|
}
|
|
129
131
|
async getUserInfo(mid) {
|
|
132
|
+
//如果为番剧出差的UID,则不从远程接口拉取数据,直接传回一段精简过的有效数据
|
|
133
|
+
if (mid === "11783021") {
|
|
134
|
+
console.log("检测到番剧出差UID,跳过远程用户接口访问");
|
|
135
|
+
return bangumiTripData;
|
|
136
|
+
}
|
|
130
137
|
try {
|
|
131
138
|
const wbi = await this.ctx.wbi.getWbi({ mid });
|
|
132
139
|
const { data } = await this.client.get(`${GET_USER_INFO}?${wbi}`);
|
package/lib/comRegister.d.ts
CHANGED
|
@@ -42,8 +42,15 @@ declare namespace ComRegister {
|
|
|
42
42
|
liveLoopTime: number;
|
|
43
43
|
customLiveStart: string;
|
|
44
44
|
customLiveEnd: string;
|
|
45
|
+
dynamicUrl: boolean;
|
|
45
46
|
dynamicLoopTime: number;
|
|
46
47
|
dynamicCheckNumber: number;
|
|
48
|
+
filter: {
|
|
49
|
+
enable: boolean;
|
|
50
|
+
notify: boolean;
|
|
51
|
+
regex: string;
|
|
52
|
+
keywords: Array<string>;
|
|
53
|
+
};
|
|
47
54
|
}
|
|
48
55
|
const Config: Schema<Config>;
|
|
49
56
|
}
|
package/lib/comRegister.js
CHANGED
|
@@ -472,7 +472,6 @@ class ComRegister {
|
|
|
472
472
|
});
|
|
473
473
|
biliCom
|
|
474
474
|
.subcommand('.dynamic <uid:string> <...guildId:string>', '订阅用户动态推送', { hidden: true })
|
|
475
|
-
// .option('bot', '-b <type:string>')
|
|
476
475
|
.usage('订阅用户动态推送')
|
|
477
476
|
.example('bili dynamic 1194210119 订阅UID为1194210119的动态')
|
|
478
477
|
.action(async ({ session }, uid, ...guildId) => {
|
|
@@ -482,10 +481,6 @@ class ComRegister {
|
|
|
482
481
|
return `${uid}非法调用 dynamic 指令`; // 用户uid不能为空
|
|
483
482
|
if (!guildId)
|
|
484
483
|
return `${uid}非法调用 dynamic 指令`; // 目标群组或频道不能为空
|
|
485
|
-
/* if (!options.bot) {
|
|
486
|
-
this.logger.warn(`${uid}非法调用 dynamic 指令,未传入订阅平台`)
|
|
487
|
-
return `${uid}非法调用 dynamic 指令`
|
|
488
|
-
} */
|
|
489
484
|
// 寻找对应订阅管理对象
|
|
490
485
|
const index = this.subManager.findIndex(sub => sub.uid === uid);
|
|
491
486
|
// 不存在则直接返回
|
|
@@ -521,7 +516,6 @@ class ComRegister {
|
|
|
521
516
|
});
|
|
522
517
|
biliCom
|
|
523
518
|
.subcommand('.live <roomId:string> <...guildId:string>', '订阅主播开播通知', { hidden: true })
|
|
524
|
-
// .option('bot', '-b <type:string>')
|
|
525
519
|
.usage('订阅主播开播通知')
|
|
526
520
|
.example('bili live 26316137 订阅房间号为26316137的直播间')
|
|
527
521
|
.action(async ({ session }, roomId, ...guildId) => {
|
|
@@ -531,10 +525,6 @@ class ComRegister {
|
|
|
531
525
|
return `${roomId}非法调用 dynamic 指令`; // 订阅主播房间号不能为空
|
|
532
526
|
if (!guildId)
|
|
533
527
|
return `${roomId}非法调用 dynamic 指令`; // 目标群组或频道不能为空
|
|
534
|
-
/* if (!options.bot) {
|
|
535
|
-
this.logger.warn(`${roomId}非法调用 dynamic 指令,未传入推送平台`)
|
|
536
|
-
return `${roomId}非法调用 dynamic 指令`
|
|
537
|
-
} */
|
|
538
528
|
// 要订阅的对象不在订阅管理对象中,直接返回
|
|
539
529
|
const index = this.subManager.findIndex(sub => sub.roomId === roomId);
|
|
540
530
|
if (index === -1)
|
|
@@ -661,6 +651,11 @@ class ComRegister {
|
|
|
661
651
|
// 定义变量
|
|
662
652
|
let pic;
|
|
663
653
|
let buffer;
|
|
654
|
+
// 从动态数据中取出UP主名称和动态ID
|
|
655
|
+
const upName = content.data.items[num].modules.module_author.name;
|
|
656
|
+
const dynamicId = content.data.items[num].id_str;
|
|
657
|
+
// 判断是否需要发送URL
|
|
658
|
+
const dUrl = this.config.dynamicUrl ? `${upName}发布了一条动态:https://t.bilibili.com/${dynamicId}` : '';
|
|
664
659
|
// 获取动态推送图片
|
|
665
660
|
try {
|
|
666
661
|
// 渲染图片
|
|
@@ -673,18 +668,23 @@ class ComRegister {
|
|
|
673
668
|
if (e.message === '直播开播动态,不做处理')
|
|
674
669
|
break;
|
|
675
670
|
if (e.message === '出现关键词,屏蔽该动态') {
|
|
676
|
-
|
|
671
|
+
// 如果需要发送才发送
|
|
672
|
+
this.config.filter.notify && await this.sendMsg(guildId, bot, `${upName}发布了一条含有屏蔽关键字的动态`);
|
|
673
|
+
break;
|
|
674
|
+
}
|
|
675
|
+
if (e.message === '已屏蔽转发动态') {
|
|
676
|
+
this.config.filter.notify && await this.sendMsg(guildId, bot, `${upName}发布了一条转发动态,已屏蔽`);
|
|
677
677
|
break;
|
|
678
678
|
}
|
|
679
679
|
}
|
|
680
680
|
// 如果pic存在,则直接返回pic
|
|
681
681
|
if (pic) {
|
|
682
682
|
// pic存在,使用的是render模式
|
|
683
|
-
await this.sendMsg(guildId, bot, pic);
|
|
683
|
+
await this.sendMsg(guildId, bot, pic + ' ' + dUrl);
|
|
684
684
|
}
|
|
685
685
|
else {
|
|
686
686
|
// pic不存在,说明使用的是page模式
|
|
687
|
-
await this.sendMsg(guildId, bot, koishi_1.h.image(buffer, 'image/png'));
|
|
687
|
+
await this.sendMsg(guildId, bot, koishi_1.h.image(buffer, 'image/png' + ' ' + dUrl));
|
|
688
688
|
}
|
|
689
689
|
// 如果成功,那么跳出循环
|
|
690
690
|
break;
|
|
@@ -1166,8 +1166,15 @@ class ComRegister {
|
|
|
1166
1166
|
liveLoopTime: koishi_1.Schema.number().default(10),
|
|
1167
1167
|
customLiveStart: koishi_1.Schema.string().required(),
|
|
1168
1168
|
customLiveEnd: koishi_1.Schema.string().required(),
|
|
1169
|
+
dynamicUrl: koishi_1.Schema.boolean().required(),
|
|
1169
1170
|
dynamicLoopTime: koishi_1.Schema.number().default(60),
|
|
1170
|
-
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
|
+
notify: koishi_1.Schema.boolean(),
|
|
1175
|
+
regex: koishi_1.Schema.string(),
|
|
1176
|
+
keywords: koishi_1.Schema.array(String),
|
|
1177
|
+
}),
|
|
1171
1178
|
});
|
|
1172
1179
|
})(ComRegister || (ComRegister = {}));
|
|
1173
1180
|
exports.default = ComRegister;
|
|
Binary file
|
package/lib/generateImg.d.ts
CHANGED
|
@@ -35,9 +35,10 @@ declare namespace GenerateImg {
|
|
|
35
35
|
renderType: number;
|
|
36
36
|
filter: {
|
|
37
37
|
enable: boolean;
|
|
38
|
+
notify: boolean;
|
|
38
39
|
regex: string;
|
|
39
40
|
keywords: Array<string>;
|
|
40
|
-
|
|
41
|
+
forward: boolean;
|
|
41
42
|
};
|
|
42
43
|
removeBorder: boolean;
|
|
43
44
|
cardColorStart: string;
|
package/lib/generateImg.js
CHANGED
|
@@ -262,7 +262,7 @@ class GenerateImg extends koishi_1.Service {
|
|
|
262
262
|
}
|
|
263
263
|
}, '');
|
|
264
264
|
// 关键字和正则屏蔽
|
|
265
|
-
if (this.giConfig.filter.enable) { //
|
|
265
|
+
if (this.giConfig.filter.enable) { // 开启动态屏蔽功能
|
|
266
266
|
if (this.giConfig.filter.regex) { // 正则屏蔽
|
|
267
267
|
const reg = new RegExp(this.giConfig.filter.regex);
|
|
268
268
|
if (reg.test(richText))
|
|
@@ -317,6 +317,9 @@ class GenerateImg extends koishi_1.Service {
|
|
|
317
317
|
basicDynamic();
|
|
318
318
|
// 转发动态
|
|
319
319
|
if (dynamicMajorData.type === DYNAMIC_TYPE_FORWARD) {
|
|
320
|
+
//转发动态屏蔽
|
|
321
|
+
if (this.giConfig.filter.enable && this.giConfig.filter.forward)
|
|
322
|
+
throw new Error('已屏蔽转发动态');
|
|
320
323
|
// User info
|
|
321
324
|
const forward_module_author = dynamicMajorData.orig.modules.module_author;
|
|
322
325
|
const forwardUserAvatarUrl = forward_module_author.face;
|
|
@@ -1365,9 +1368,10 @@ class GenerateImg extends koishi_1.Service {
|
|
|
1365
1368
|
renderType: koishi_1.Schema.number(),
|
|
1366
1369
|
filter: koishi_1.Schema.object({
|
|
1367
1370
|
enable: koishi_1.Schema.boolean(),
|
|
1371
|
+
notify: koishi_1.Schema.boolean(),
|
|
1368
1372
|
regex: koishi_1.Schema.string(),
|
|
1369
1373
|
keywords: koishi_1.Schema.array(String),
|
|
1370
|
-
|
|
1374
|
+
forward: koishi_1.Schema.boolean()
|
|
1371
1375
|
}),
|
|
1372
1376
|
removeBorder: koishi_1.Schema.boolean(),
|
|
1373
1377
|
cardColorStart: koishi_1.Schema.string(),
|
package/lib/index.d.ts
CHANGED
package/lib/index.js
CHANGED
|
@@ -55,6 +55,9 @@ exports.Config = koishi_1.Schema.object({
|
|
|
55
55
|
.default('render')
|
|
56
56
|
.description('渲染类型,默认为render模式,渲染速度更快,但会出现乱码问题,若出现乱码问题,请切换到page模式。若使用自定义字体,建议选择render模式'),
|
|
57
57
|
dynamic: koishi_1.Schema.object({}).description('动态推送设置'),
|
|
58
|
+
dynamicUrl: koishi_1.Schema.boolean()
|
|
59
|
+
.default(false)
|
|
60
|
+
.description('发送动态时是否同时发送链接。注意:如果使用的是QQ官方机器人不能开启此项!'),
|
|
58
61
|
dynamicCheckNumber: koishi_1.Schema.number()
|
|
59
62
|
.min(2)
|
|
60
63
|
.max(10)
|
|
@@ -78,11 +81,9 @@ exports.Config = koishi_1.Schema.object({
|
|
|
78
81
|
.description('设定隔多长时间推送一次直播状态,单位为小时,默认为一小时'),
|
|
79
82
|
customLiveStart: koishi_1.Schema.string()
|
|
80
83
|
.default('-name开播啦')
|
|
81
|
-
.experimental()
|
|
82
84
|
.description('自定义开播提示语,-name代表UP昵称。例如-name开播啦,会发送为xxxUP开播啦'),
|
|
83
85
|
customLiveEnd: koishi_1.Schema.string()
|
|
84
86
|
.default('-name下播啦,本次直播了-time')
|
|
85
|
-
.experimental()
|
|
86
87
|
.description('自定义下播提示语,-name代表UP昵称,-time代表开播时长。例如-name下播啦,本次直播了-time,会发送为xxxUP下播啦,直播时长为xx小时xx分钟xx秒'),
|
|
87
88
|
style: koishi_1.Schema.object({}).description('美化设置'),
|
|
88
89
|
removeBorder: koishi_1.Schema.boolean()
|
|
@@ -105,16 +106,21 @@ exports.Config = koishi_1.Schema.object({
|
|
|
105
106
|
koishi_1.Schema.object({
|
|
106
107
|
enable: koishi_1.Schema.boolean()
|
|
107
108
|
.default(false)
|
|
108
|
-
.description('
|
|
109
|
-
.experimental()
|
|
109
|
+
.description('是否开启动态屏蔽功能')
|
|
110
110
|
}).description('屏蔽设置'),
|
|
111
111
|
koishi_1.Schema.union([
|
|
112
112
|
koishi_1.Schema.object({
|
|
113
113
|
enable: koishi_1.Schema.const(true).required().experimental(),
|
|
114
|
+
notify: koishi_1.Schema.boolean()
|
|
115
|
+
.default(false)
|
|
116
|
+
.description('动态被屏蔽是否发送提示'),
|
|
114
117
|
regex: koishi_1.Schema.string()
|
|
115
118
|
.description('正则表达式屏蔽'),
|
|
116
119
|
keywords: koishi_1.Schema.array(String)
|
|
117
|
-
.description('关键字屏蔽,一个关键字为一项')
|
|
120
|
+
.description('关键字屏蔽,一个关键字为一项'),
|
|
121
|
+
forward: koishi_1.Schema.boolean()
|
|
122
|
+
.default(false)
|
|
123
|
+
.description("是否屏蔽转发动态"),
|
|
118
124
|
}),
|
|
119
125
|
koishi_1.Schema.object({})
|
|
120
126
|
])
|
|
@@ -163,6 +169,7 @@ function apply(ctx, config) {
|
|
|
163
169
|
ctx.plugin(Database);
|
|
164
170
|
// Regist server
|
|
165
171
|
ctx.plugin(wbi_1.default, { key: config.key });
|
|
172
|
+
ctx.plugin(biliAPI_1.default);
|
|
166
173
|
ctx.plugin(generateImg_1.default, {
|
|
167
174
|
renderType,
|
|
168
175
|
filter: config.filter,
|
|
@@ -172,9 +179,6 @@ function apply(ctx, config) {
|
|
|
172
179
|
enableLargeFont: config.enableLargeFont,
|
|
173
180
|
font: config.font
|
|
174
181
|
});
|
|
175
|
-
ctx.plugin(biliAPI_1.default);
|
|
176
|
-
// load plugin
|
|
177
|
-
// ctx.plugin(Authority)
|
|
178
182
|
ctx.plugin(comRegister_1.default, {
|
|
179
183
|
unlockSubLimits: config.unlockSubLimits,
|
|
180
184
|
liveStartAtAll: config.liveStartAtAll,
|
|
@@ -182,12 +186,14 @@ function apply(ctx, config) {
|
|
|
182
186
|
customLiveStart: config.customLiveStart,
|
|
183
187
|
customLiveEnd: config.customLiveEnd,
|
|
184
188
|
dynamicCheckNumber: config.dynamicCheckNumber,
|
|
185
|
-
dynamicLoopTime
|
|
189
|
+
dynamicLoopTime,
|
|
190
|
+
dynamicUrl: config.dynamicUrl,
|
|
191
|
+
filter: config.filter
|
|
186
192
|
});
|
|
187
193
|
// 当用户输入“恶魔兔,启动!”时,执行 help 指令
|
|
188
194
|
ctx.middleware((session, next) => {
|
|
189
195
|
if (session.content === '恶魔兔,启动!') {
|
|
190
|
-
return session.
|
|
196
|
+
return session.send('启动不了一点');
|
|
191
197
|
}
|
|
192
198
|
else {
|
|
193
199
|
return next();
|
package/package.json
CHANGED
package/readme.md
CHANGED
|
@@ -110,7 +110,10 @@
|
|
|
110
110
|
- ver 1.2.0-rc.0 现已支持自定义开播和下播提示语(实验性)
|
|
111
111
|
- ver 1.2.0-rc.1 现已支持Telegram平台(实验性)
|
|
112
112
|
- ver 1.2.0-rc.2 添加更多日志输出
|
|
113
|
-
- ver 1.2.0-rc.3 针对Telegram的
|
|
113
|
+
- ver 1.2.0-rc.3 针对Telegram的bug测试版本
|
|
114
|
+
- ver 1.2.0-rc.4 修复了订阅指令的一个bug
|
|
115
|
+
- ver 1.2.0-rc.5 屏蔽动态设置新增是否发送动态被屏蔽消息的选项
|
|
116
|
+
- ver 1.2.0 添加屏蔽转发动态功能,添加发送动态卡片时附带文本信息和动态链接功能,支持订阅哔哩哔哩番剧出差
|
|
114
117
|
|
|
115
118
|
## 交流群
|
|
116
119
|
801338523 使用问题或bug都可以在群里提出
|