koishi-plugin-bilibili-notify 1.0.7-alpha.0 → 1.0.9-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/biliAPI.js +9 -1
- package/lib/comRegister.d.ts +2 -0
- package/lib/comRegister.js +110 -91
- package/lib/generateImg.d.ts +1 -0
- package/lib/generateImg.js +29 -20
- package/lib/index.d.ts +6 -1
- package/lib/index.js +25 -8
- package/package.json +1 -1
- package/readme.md +2 -0
package/lib/biliAPI.js
CHANGED
|
@@ -138,7 +138,15 @@ class BiliAPI extends koishi_1.Service {
|
|
|
138
138
|
disposeNotifier() { this.loginNotifier && this.loginNotifier.dispose(); }
|
|
139
139
|
createNewClient() {
|
|
140
140
|
this.jar = new tough_cookie_1.CookieJar();
|
|
141
|
-
this.client = (0, axios_cookiejar_support_1.wrapper)(axios_1.default.create({
|
|
141
|
+
this.client = (0, axios_cookiejar_support_1.wrapper)(axios_1.default.create({
|
|
142
|
+
jar: this.jar,
|
|
143
|
+
headers: {
|
|
144
|
+
'Content-Type': 'application/json; charset=utf-8',
|
|
145
|
+
'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36',
|
|
146
|
+
'Origin': 'https://www.bilibili.com',
|
|
147
|
+
'Referer': 'https://www.bilibili.com/'
|
|
148
|
+
}
|
|
149
|
+
}));
|
|
142
150
|
}
|
|
143
151
|
getCookies() {
|
|
144
152
|
let cookies;
|
package/lib/comRegister.d.ts
CHANGED
|
@@ -23,12 +23,14 @@ declare class ComRegister {
|
|
|
23
23
|
liveDetect(ctx: Context, bot: Bot<Context>, guildId: string, roomId: string): () => Promise<void>;
|
|
24
24
|
subShow(): string;
|
|
25
25
|
checkIfNeedSub(comNeed: boolean, subType: string, session: Session, data?: any): Promise<boolean>;
|
|
26
|
+
updateSubNotifier(ctx: Context): void;
|
|
26
27
|
getSubFromDatabase(ctx: Context): Promise<string[]>;
|
|
27
28
|
unsubSingle(ctx: Context, id: string, type: number): string;
|
|
28
29
|
checkIfIsLogin(ctx: Context): Promise<boolean>;
|
|
29
30
|
}
|
|
30
31
|
declare namespace ComRegister {
|
|
31
32
|
interface Config {
|
|
33
|
+
unlockSubLimits: boolean;
|
|
32
34
|
pushTime: number;
|
|
33
35
|
liveLoopTime: number;
|
|
34
36
|
dynamicLoopTime: number;
|
package/lib/comRegister.js
CHANGED
|
@@ -3,6 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const jsx_runtime_1 = require("@satorijs/element/jsx-runtime");
|
|
6
7
|
const koishi_1 = require("koishi");
|
|
7
8
|
// 导入qrcode
|
|
8
9
|
const qrcode_1 = __importDefault(require("qrcode"));
|
|
@@ -32,14 +33,15 @@ class ComRegister {
|
|
|
32
33
|
this.qqguildBot = ctx.bots[ctx.bots.findIndex(bot => bot.platform === 'qqguild')];
|
|
33
34
|
// 从数据库获取订阅
|
|
34
35
|
this.getSubFromDatabase(ctx);
|
|
35
|
-
/* ctx.command('test', { hidden: true, permissions: ['authority:5'] })
|
|
36
|
-
|
|
36
|
+
/* const testCom = ctx.command('test', { hidden: true, permissions: ['authority:5'] })
|
|
37
|
+
|
|
38
|
+
testCom.subcommand('.cookies')
|
|
37
39
|
.usage('测试指令,用于测试从数据库读取cookies')
|
|
38
40
|
.action(async () => {
|
|
39
41
|
await ctx.biliAPI.loadCookiesFromDatabase()
|
|
40
42
|
})
|
|
41
43
|
|
|
42
|
-
|
|
44
|
+
testCom
|
|
43
45
|
.subcommand('.my')
|
|
44
46
|
.usage('测试指令,用于测试获取自己信息')
|
|
45
47
|
.example('test.my')
|
|
@@ -48,7 +50,7 @@ class ComRegister {
|
|
|
48
50
|
console.log(content);
|
|
49
51
|
})
|
|
50
52
|
|
|
51
|
-
|
|
53
|
+
testCom
|
|
52
54
|
.subcommand('.user <mid:string>')
|
|
53
55
|
.usage('测试指令,用于测试获取用户信息')
|
|
54
56
|
.example('test.user 用户UID')
|
|
@@ -57,7 +59,7 @@ class ComRegister {
|
|
|
57
59
|
console.log(content);
|
|
58
60
|
})
|
|
59
61
|
|
|
60
|
-
|
|
62
|
+
testCom
|
|
61
63
|
.subcommand('.time')
|
|
62
64
|
.usage('测试时间接口')
|
|
63
65
|
.example('test.time')
|
|
@@ -65,7 +67,7 @@ class ComRegister {
|
|
|
65
67
|
session.send(await ctx.biliAPI.getTimeNow())
|
|
66
68
|
})
|
|
67
69
|
|
|
68
|
-
|
|
70
|
+
testCom
|
|
69
71
|
.subcommand('.exist')
|
|
70
72
|
.usage('测试写法')
|
|
71
73
|
.example('test.exist')
|
|
@@ -74,7 +76,7 @@ class ComRegister {
|
|
|
74
76
|
console.log(num && `Hello World`);
|
|
75
77
|
})
|
|
76
78
|
|
|
77
|
-
|
|
79
|
+
testCom
|
|
78
80
|
.subcommand('.gimg <uid:string> <index:number>')
|
|
79
81
|
.usage('测试图片生成')
|
|
80
82
|
.example('test.gimg')
|
|
@@ -89,7 +91,7 @@ class ComRegister {
|
|
|
89
91
|
await session.send(h.image(buffer, 'image/png'))
|
|
90
92
|
})
|
|
91
93
|
|
|
92
|
-
|
|
94
|
+
testCom
|
|
93
95
|
.subcommand('.group')
|
|
94
96
|
.usage('查看session groupId')
|
|
95
97
|
.example('test group')
|
|
@@ -97,7 +99,7 @@ class ComRegister {
|
|
|
97
99
|
console.log(session.event.channel);
|
|
98
100
|
})
|
|
99
101
|
|
|
100
|
-
|
|
102
|
+
testCom
|
|
101
103
|
.subcommand('.session')
|
|
102
104
|
.usage('查看seesion')
|
|
103
105
|
.example('test session')
|
|
@@ -105,15 +107,15 @@ class ComRegister {
|
|
|
105
107
|
console.log(session);
|
|
106
108
|
})
|
|
107
109
|
|
|
108
|
-
|
|
110
|
+
testCom
|
|
109
111
|
.subcommand('.utc')
|
|
110
112
|
.usage('获取当前UTC+8 Unix时间戳')
|
|
111
113
|
.example('test utc')
|
|
112
114
|
.action(async ({ session }) => {
|
|
113
115
|
session.send((await ctx.biliAPI.getServerUTCTime()).toString())
|
|
114
116
|
}) */
|
|
115
|
-
ctx.command('bili', 'bili-notify插件相关指令', { permissions: ['authority:3'] })
|
|
116
|
-
|
|
117
|
+
const biliCom = ctx.command('bili', 'bili-notify插件相关指令', { permissions: ['authority:3'] });
|
|
118
|
+
biliCom.subcommand('.login', '登录B站之后才可以进行之后的操作')
|
|
117
119
|
.usage('使用二维码登录,登录B站之后才可以进行之后的操作')
|
|
118
120
|
.example('bili login')
|
|
119
121
|
.action(async ({ session }) => {
|
|
@@ -188,7 +190,7 @@ class ComRegister {
|
|
|
188
190
|
}
|
|
189
191
|
}, 1000);
|
|
190
192
|
});
|
|
191
|
-
|
|
193
|
+
biliCom
|
|
192
194
|
.subcommand('.unsub <uid:string>', '取消订阅UP主动态、直播或全部')
|
|
193
195
|
.usage('取消订阅,加-l为取消直播订阅,加-d为取消动态订阅,什么都不加则为全部取消')
|
|
194
196
|
.option('live', '-l')
|
|
@@ -199,6 +201,9 @@ class ComRegister {
|
|
|
199
201
|
// 若用户UID为空则直接返回
|
|
200
202
|
if (!uid)
|
|
201
203
|
return '用户UID不能为空';
|
|
204
|
+
// -d -l两个选项不能同时存在
|
|
205
|
+
if (options.dynamic && options.live)
|
|
206
|
+
return '需要取消订阅该UP主请直接使用指令bili unsub 用户UID';
|
|
202
207
|
// 定义是否存在
|
|
203
208
|
let exist;
|
|
204
209
|
await Promise.all(this.subManager.map(async (sub, i) => {
|
|
@@ -221,11 +226,13 @@ class ComRegister {
|
|
|
221
226
|
// 从数据库中删除订阅
|
|
222
227
|
await ctx.database.remove('bilibili', { uid: this.subManager[i].uid });
|
|
223
228
|
// 将该订阅对象从订阅管理对象中移除
|
|
224
|
-
this.subManager
|
|
229
|
+
this.subManager.splice(i, 1);
|
|
225
230
|
// id--
|
|
226
231
|
this.num--;
|
|
227
232
|
// 发送成功通知
|
|
228
233
|
session.send('已取消订阅该用户');
|
|
234
|
+
// 更新控制台提示
|
|
235
|
+
this.updateSubNotifier(ctx);
|
|
229
236
|
// 将存在flag设置为true
|
|
230
237
|
exist = true;
|
|
231
238
|
}
|
|
@@ -233,7 +240,7 @@ class ComRegister {
|
|
|
233
240
|
// 未订阅该用户,无需取消订阅
|
|
234
241
|
!exist && session.send('未订阅该用户,无需取消订阅');
|
|
235
242
|
});
|
|
236
|
-
|
|
243
|
+
biliCom
|
|
237
244
|
.subcommand('.show', '展示订阅对象')
|
|
238
245
|
.usage('展示订阅对象')
|
|
239
246
|
.example('bili show')
|
|
@@ -241,7 +248,7 @@ class ComRegister {
|
|
|
241
248
|
const subTable = this.subShow();
|
|
242
249
|
return subTable;
|
|
243
250
|
});
|
|
244
|
-
|
|
251
|
+
biliCom
|
|
245
252
|
.subcommand('.sub <mid:string> [guildId:string]', '订阅用户动态和直播通知')
|
|
246
253
|
.option('live', '-l')
|
|
247
254
|
.option('dynamic', '-d')
|
|
@@ -255,7 +262,7 @@ class ComRegister {
|
|
|
255
262
|
return '请使用指令bili login登录后再进行订阅操作';
|
|
256
263
|
}
|
|
257
264
|
// 如果订阅人数超过三个则直接返回
|
|
258
|
-
if (this.num >= 3)
|
|
265
|
+
if (!config.unlockSubLimits && this.num >= 3)
|
|
259
266
|
return '目前最多只能订阅三个人';
|
|
260
267
|
// 检查必选参数是否有值
|
|
261
268
|
if (!mid)
|
|
@@ -380,16 +387,9 @@ class ComRegister {
|
|
|
380
387
|
await bot.sendMessage(sub.targetId, `订阅${userData.info.uname}动态通知`);
|
|
381
388
|
}
|
|
382
389
|
// 新增订阅展示到控制台
|
|
383
|
-
|
|
384
|
-
const subTable = this.subShow();
|
|
385
|
-
// 判断之前是否存在Notifier
|
|
386
|
-
this.subNotifier && this.subNotifier.dispose();
|
|
387
|
-
this.subNotifier = ctx.notifier.create({
|
|
388
|
-
type: 'primary',
|
|
389
|
-
content: subTable
|
|
390
|
-
});
|
|
390
|
+
this.updateSubNotifier(ctx);
|
|
391
391
|
});
|
|
392
|
-
|
|
392
|
+
biliCom
|
|
393
393
|
.subcommand('.dynamic <uid:string> <guildId:string>', '订阅用户动态推送', { hidden: true })
|
|
394
394
|
.option('bot', '-b <type:string>')
|
|
395
395
|
.usage('订阅用户动态推送')
|
|
@@ -426,7 +426,7 @@ class ComRegister {
|
|
|
426
426
|
// 将销毁函数保存到订阅管理对象
|
|
427
427
|
this.subManager[index].dynamicDispose = dispose;
|
|
428
428
|
});
|
|
429
|
-
|
|
429
|
+
biliCom
|
|
430
430
|
.subcommand('.live <roomId:string> <guildId:string>', '订阅主播开播通知', { hidden: true })
|
|
431
431
|
.option('bot', '-b <type:string>')
|
|
432
432
|
.usage('订阅主播开播通知')
|
|
@@ -461,7 +461,7 @@ class ComRegister {
|
|
|
461
461
|
// 保存销毁函数
|
|
462
462
|
this.subManager[index].liveDispose = dispose;
|
|
463
463
|
});
|
|
464
|
-
|
|
464
|
+
biliCom
|
|
465
465
|
.subcommand('.status <roomId:string>', '查询主播当前直播状态', { hidden: true })
|
|
466
466
|
.usage('查询主播当前直播状态')
|
|
467
467
|
.example('bili status 732')
|
|
@@ -509,7 +509,7 @@ class ComRegister {
|
|
|
509
509
|
let firstSubscription = true;
|
|
510
510
|
let timePoint;
|
|
511
511
|
// Test code
|
|
512
|
-
let timer = 0
|
|
512
|
+
// let timer = 0
|
|
513
513
|
return async () => {
|
|
514
514
|
// Test code
|
|
515
515
|
/* this.logger.info('timer:' + timer++)
|
|
@@ -797,6 +797,20 @@ class ComRegister {
|
|
|
797
797
|
}
|
|
798
798
|
}
|
|
799
799
|
}
|
|
800
|
+
updateSubNotifier(ctx) {
|
|
801
|
+
// 更新控制台提示
|
|
802
|
+
this.subNotifier && this.subNotifier.dispose();
|
|
803
|
+
// 获取subTable
|
|
804
|
+
let subTableArray = this.subShow().split('\n');
|
|
805
|
+
subTableArray.splice(subTableArray.length - 1, 1);
|
|
806
|
+
// 定义Table
|
|
807
|
+
let table = (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: (0, jsx_runtime_1.jsx)("ul", { children: subTableArray.map(str => ((0, jsx_runtime_1.jsx)("li", { children: str }))) }) });
|
|
808
|
+
/* subTableArray.forEach(str => {
|
|
809
|
+
table +=
|
|
810
|
+
}) */
|
|
811
|
+
// 设置更新后的提示
|
|
812
|
+
this.subNotifier = ctx.notifier.create(table);
|
|
813
|
+
}
|
|
800
814
|
async getSubFromDatabase(ctx) {
|
|
801
815
|
// 如果未登录,则直接返回
|
|
802
816
|
if (!(await this.checkIfIsLogin(ctx)))
|
|
@@ -810,10 +824,10 @@ class ComRegister {
|
|
|
810
824
|
this.num = subData.length;
|
|
811
825
|
// 如果订阅数量超过三个则被非法修改数据库
|
|
812
826
|
// 在控制台提示重新订阅
|
|
813
|
-
if (this.num > 3) {
|
|
827
|
+
if (!this.config.unlockSubLimits && this.num > 3) {
|
|
814
828
|
ctx.notifier.create({
|
|
815
829
|
type: 'danger',
|
|
816
|
-
content: '
|
|
830
|
+
content: '您未解锁订阅限制,且订阅数大于3人,请您手动删除bilibili表中多余的数据后,重启本插件'
|
|
817
831
|
});
|
|
818
832
|
return;
|
|
819
833
|
}
|
|
@@ -821,6 +835,13 @@ class ComRegister {
|
|
|
821
835
|
let bot;
|
|
822
836
|
// 循环遍历
|
|
823
837
|
for (const sub of subData) {
|
|
838
|
+
// 判断是否存在没有任何订阅的数据
|
|
839
|
+
if (!sub.dynamic && !sub.live) { // 存在未订阅任何项目的数据
|
|
840
|
+
// 删除该条数据
|
|
841
|
+
ctx.database.remove('bilibili', { id: sub.id });
|
|
842
|
+
// 跳过下面的步骤
|
|
843
|
+
continue;
|
|
844
|
+
}
|
|
824
845
|
// 拿到对应bot
|
|
825
846
|
switch (sub.platform) {
|
|
826
847
|
case 'qq': bot = this.qqBot;
|
|
@@ -899,73 +920,70 @@ class ComRegister {
|
|
|
899
920
|
this.subManager.push(subManagerItem);
|
|
900
921
|
}
|
|
901
922
|
// 在控制台中显示订阅对象
|
|
902
|
-
|
|
903
|
-
// 如果已经存在Notifier则清除原先的Notifier
|
|
904
|
-
this.subNotifier && this.subNotifier.dispose();
|
|
905
|
-
// 创建Notifier
|
|
906
|
-
this.subNotifier = ctx.notifier.create({
|
|
907
|
-
type: 'primary',
|
|
908
|
-
content: subTable
|
|
909
|
-
});
|
|
923
|
+
this.updateSubNotifier(ctx);
|
|
910
924
|
}
|
|
911
925
|
unsubSingle(ctx, id /* UID或RoomId */, type /* 0取消Live订阅,1取消Dynamic订阅 */) {
|
|
912
926
|
let index;
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
927
|
+
const checkIfNoSubExist = (index) => {
|
|
928
|
+
if (!this.subManager[index].dynamic && !this.subManager[index].live) {
|
|
929
|
+
// 获取要删除行的id
|
|
930
|
+
const id = this.subManager[index].id;
|
|
931
|
+
// 从管理对象中移除
|
|
932
|
+
this.subManager.splice(index, 1);
|
|
933
|
+
// 从数据库中删除
|
|
934
|
+
ctx.database.remove('bilibili', [id]);
|
|
935
|
+
// num--
|
|
936
|
+
this.num--;
|
|
937
|
+
return '已取消订阅该用户';
|
|
938
|
+
}
|
|
939
|
+
return null;
|
|
940
|
+
};
|
|
941
|
+
try {
|
|
942
|
+
switch (type) {
|
|
943
|
+
case 0: { // 取消Live订阅
|
|
944
|
+
index = this.subManager.findIndex(sub => sub.roomId === id);
|
|
945
|
+
if (index === -1)
|
|
946
|
+
return '未订阅该用户,无需取消订阅';
|
|
947
|
+
// 取消订阅
|
|
948
|
+
this.subManager[index].live && this.subManager[index].liveDispose();
|
|
949
|
+
this.subManager[index].liveDispose = null;
|
|
950
|
+
this.subManager[index].live = false;
|
|
951
|
+
// 如果没有对这个UP的任何订阅,则移除
|
|
952
|
+
const info = checkIfNoSubExist(index);
|
|
953
|
+
if (info)
|
|
954
|
+
return info;
|
|
955
|
+
// 更新数据库
|
|
956
|
+
ctx.database.upsert('bilibili', [{
|
|
957
|
+
id: +`${this.subManager[index].id}`,
|
|
958
|
+
live: 0
|
|
959
|
+
}]);
|
|
960
|
+
return '已取消订阅Live';
|
|
931
961
|
}
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
const id = this.subManager[index].id;
|
|
951
|
-
// 从管理对象中移除
|
|
952
|
-
this.subManager = this.subManager.splice(index, index);
|
|
953
|
-
// 从数据库中删除
|
|
954
|
-
ctx.database.remove('bilibili', [id]);
|
|
955
|
-
// num--
|
|
956
|
-
this.num--;
|
|
957
|
-
return '已取消订阅该用户';
|
|
962
|
+
case 1: { // 取消Dynamic订阅
|
|
963
|
+
index = this.subManager.findIndex(sub => sub.uid === id);
|
|
964
|
+
if (index === -1)
|
|
965
|
+
return '未订阅该用户,无需取消订阅';
|
|
966
|
+
// 取消订阅
|
|
967
|
+
this.subManager[index].dynamic && this.subManager[index].dynamicDispose();
|
|
968
|
+
this.subManager[index].dynamicDispose = null;
|
|
969
|
+
this.subManager[index].dynamic = false;
|
|
970
|
+
// 如果没有对这个UP的任何订阅,则移除
|
|
971
|
+
const info = checkIfNoSubExist(index);
|
|
972
|
+
if (info)
|
|
973
|
+
return info;
|
|
974
|
+
// 更新数据库
|
|
975
|
+
ctx.database.upsert('bilibili', [{
|
|
976
|
+
id: +`${this.subManager[index].id}`,
|
|
977
|
+
dynamic: 0
|
|
978
|
+
}]);
|
|
979
|
+
return '已取消订阅Dynamic';
|
|
958
980
|
}
|
|
959
|
-
this.subManager[index].dynamicDispose = null;
|
|
960
|
-
this.subManager[index].dynamic = false;
|
|
961
|
-
// 更新数据库
|
|
962
|
-
ctx.database.upsert('bilibili', [{
|
|
963
|
-
id: +`${this.subManager[index].id}`,
|
|
964
|
-
dynamic: 0
|
|
965
|
-
}]);
|
|
966
|
-
return '已取消订阅Dynamic';
|
|
967
981
|
}
|
|
968
982
|
}
|
|
983
|
+
finally {
|
|
984
|
+
// 执行完该方法后,保证执行一次updateSubNotifier()
|
|
985
|
+
this.updateSubNotifier(ctx);
|
|
986
|
+
}
|
|
969
987
|
}
|
|
970
988
|
async checkIfIsLogin(ctx) {
|
|
971
989
|
if ((await ctx.database.get('loginBili', 1)).length !== 0) { // 数据库中有数据
|
|
@@ -979,6 +997,7 @@ class ComRegister {
|
|
|
979
997
|
}
|
|
980
998
|
(function (ComRegister) {
|
|
981
999
|
ComRegister.Config = koishi_1.Schema.object({
|
|
1000
|
+
unlockSubLimits: koishi_1.Schema.boolean().required(),
|
|
982
1001
|
pushTime: koishi_1.Schema.number().required(),
|
|
983
1002
|
liveLoopTime: koishi_1.Schema.number().default(10),
|
|
984
1003
|
dynamicLoopTime: koishi_1.Schema.number().default(60),
|
package/lib/generateImg.d.ts
CHANGED
package/lib/generateImg.js
CHANGED
|
@@ -91,9 +91,13 @@ class GenerateImg extends koishi_1.Service {
|
|
|
91
91
|
}
|
|
92
92
|
|
|
93
93
|
.base-plate {
|
|
94
|
+
${this.config.removeBorder ? `
|
|
95
|
+
width: 740px;
|
|
96
|
+
` : `
|
|
94
97
|
width: 704px;
|
|
95
|
-
height: auto;
|
|
96
98
|
margin: 20px auto;
|
|
99
|
+
`}
|
|
100
|
+
height: auto;
|
|
97
101
|
border-radius: 10px;
|
|
98
102
|
background-color: #fff;
|
|
99
103
|
}
|
|
@@ -513,6 +517,7 @@ class GenerateImg extends koishi_1.Service {
|
|
|
513
517
|
* {
|
|
514
518
|
margin: 0;
|
|
515
519
|
padding: 0;
|
|
520
|
+
box-sizing: border-box;
|
|
516
521
|
font-family: "${this.config.font}", "Custom Font", "Microsoft YaHei", "Source Han Sans", "Noto Sans CJK", sans-serif;
|
|
517
522
|
}
|
|
518
523
|
|
|
@@ -539,9 +544,13 @@ class GenerateImg extends koishi_1.Service {
|
|
|
539
544
|
}
|
|
540
545
|
|
|
541
546
|
.base-plate {
|
|
547
|
+
${this.config.removeBorder ? `
|
|
548
|
+
width: 740px;
|
|
549
|
+
` : `
|
|
542
550
|
width: 704px;
|
|
543
|
-
height: auto;
|
|
544
551
|
margin: 20px auto;
|
|
552
|
+
`}
|
|
553
|
+
height: auto;
|
|
545
554
|
border-radius: 10px;
|
|
546
555
|
background-color: #fff;
|
|
547
556
|
}
|
|
@@ -552,10 +561,9 @@ class GenerateImg extends koishi_1.Service {
|
|
|
552
561
|
}
|
|
553
562
|
|
|
554
563
|
.card .anchor-avatar {
|
|
555
|
-
|
|
556
|
-
max-width: 50px;
|
|
564
|
+
max-width: 70px;
|
|
557
565
|
/* 设置最大宽度为容器宽度的100% */
|
|
558
|
-
max-height:
|
|
566
|
+
max-height: 70px;
|
|
559
567
|
/* 设置最大高度为容器高度的90% */
|
|
560
568
|
margin-right: 20px;
|
|
561
569
|
border-radius: 10px;
|
|
@@ -575,15 +583,15 @@ class GenerateImg extends koishi_1.Service {
|
|
|
575
583
|
display: flex;
|
|
576
584
|
flex-direction: column;
|
|
577
585
|
justify-content: space-between;
|
|
578
|
-
height:
|
|
586
|
+
height: 70px;
|
|
579
587
|
}
|
|
580
588
|
|
|
581
589
|
.card .up-info .up-name {
|
|
582
|
-
font-size:
|
|
590
|
+
font-size: 27px;
|
|
583
591
|
}
|
|
584
592
|
|
|
585
593
|
.card .pub-time {
|
|
586
|
-
font-size:
|
|
594
|
+
font-size: 20px;
|
|
587
595
|
color: grey;
|
|
588
596
|
}
|
|
589
597
|
|
|
@@ -593,12 +601,9 @@ class GenerateImg extends koishi_1.Service {
|
|
|
593
601
|
|
|
594
602
|
.card .dress-up {
|
|
595
603
|
position: relative;
|
|
596
|
-
max-width: 110px;
|
|
597
|
-
max-height: 34px;
|
|
598
604
|
/* background-image: url('${dynamicCardUrl}');
|
|
599
605
|
background-size: cover; */
|
|
600
|
-
font-size:
|
|
601
|
-
line-height: 33px;
|
|
606
|
+
font-size: 17px;
|
|
602
607
|
}
|
|
603
608
|
|
|
604
609
|
.card .dress-up img {
|
|
@@ -609,20 +614,23 @@ class GenerateImg extends koishi_1.Service {
|
|
|
609
614
|
.card .dress-up span {
|
|
610
615
|
position: absolute;
|
|
611
616
|
color: ${dynamicCardColor};
|
|
612
|
-
right:
|
|
613
|
-
top:
|
|
617
|
+
right: 67px;
|
|
618
|
+
top: 24px;
|
|
614
619
|
}
|
|
615
620
|
|
|
616
621
|
.card .card-topic {
|
|
617
622
|
display: flex;
|
|
618
623
|
align-items: center;
|
|
619
624
|
margin-top: 10px;
|
|
625
|
+
font-size: 20px;
|
|
620
626
|
color: #008AC5;
|
|
621
627
|
gap: 3px;
|
|
622
628
|
}
|
|
623
629
|
|
|
624
630
|
.card .card-details {
|
|
631
|
+
margin-top: 5px;
|
|
625
632
|
margin-bottom: 15px;
|
|
633
|
+
font-size: 22px;
|
|
626
634
|
width: 90%;
|
|
627
635
|
}
|
|
628
636
|
|
|
@@ -749,8 +757,8 @@ class GenerateImg extends koishi_1.Service {
|
|
|
749
757
|
}
|
|
750
758
|
|
|
751
759
|
.card .card-forward {
|
|
752
|
-
margin: 0 -15px 0 -
|
|
753
|
-
padding: 12px 15px 14px
|
|
760
|
+
margin: 0 -15px 0 -105px;
|
|
761
|
+
padding: 12px 15px 14px 105px;
|
|
754
762
|
background-color: #F6F7F8;
|
|
755
763
|
}
|
|
756
764
|
|
|
@@ -758,18 +766,18 @@ class GenerateImg extends koishi_1.Service {
|
|
|
758
766
|
display: flex;
|
|
759
767
|
align-items: center;
|
|
760
768
|
gap: 5px;
|
|
761
|
-
height:
|
|
769
|
+
height: 35px;
|
|
762
770
|
}
|
|
763
771
|
|
|
764
772
|
.forward-userinfo img {
|
|
765
|
-
width:
|
|
766
|
-
height:
|
|
773
|
+
width: 25px;
|
|
774
|
+
height: 25px;
|
|
767
775
|
border-radius: 50%;
|
|
768
776
|
}
|
|
769
777
|
|
|
770
778
|
.forward-userinfo span {
|
|
771
779
|
color: #61666D;
|
|
772
|
-
font-size:
|
|
780
|
+
font-size: 20px;
|
|
773
781
|
}
|
|
774
782
|
|
|
775
783
|
.card .card-reserve {
|
|
@@ -986,6 +994,7 @@ class GenerateImg extends koishi_1.Service {
|
|
|
986
994
|
(function (GenerateImg) {
|
|
987
995
|
GenerateImg.Config = koishi_1.Schema.object({
|
|
988
996
|
renderType: koishi_1.Schema.number(),
|
|
997
|
+
removeBorder: koishi_1.Schema.boolean(),
|
|
989
998
|
cardColorStart: koishi_1.Schema.string(),
|
|
990
999
|
cardColorEnd: koishi_1.Schema.string(),
|
|
991
1000
|
font: koishi_1.Schema.string()
|
package/lib/index.d.ts
CHANGED
|
@@ -2,14 +2,19 @@ import { Context, Schema } from 'koishi';
|
|
|
2
2
|
export declare const inject: string[];
|
|
3
3
|
export declare const name = "bilibili-notify";
|
|
4
4
|
export interface Config {
|
|
5
|
+
require: {};
|
|
6
|
+
key: string;
|
|
7
|
+
basicSettings: {};
|
|
8
|
+
unlockSubLimits: boolean;
|
|
5
9
|
pushTime: number;
|
|
6
10
|
dynamicCheckNumber: number;
|
|
7
11
|
dynamicLoopTime: '1分钟' | '2分钟' | '3分钟' | '5分钟';
|
|
8
12
|
renderType: 'render' | 'page';
|
|
13
|
+
style: {};
|
|
14
|
+
removeBorder: boolean;
|
|
9
15
|
cardColorStart: string;
|
|
10
16
|
cardColorEnd: string;
|
|
11
17
|
font: string;
|
|
12
|
-
key: string;
|
|
13
18
|
}
|
|
14
19
|
export declare const Config: Schema<Config>;
|
|
15
20
|
export declare function apply(ctx: Context, config: Config): void;
|
package/lib/index.js
CHANGED
|
@@ -39,6 +39,16 @@ const biliAPI_1 = __importDefault(require("./biliAPI"));
|
|
|
39
39
|
exports.inject = ['puppeteer', 'database', 'notifier'];
|
|
40
40
|
exports.name = 'bilibili-notify';
|
|
41
41
|
exports.Config = koishi_1.Schema.object({
|
|
42
|
+
require: koishi_1.Schema.object({}).description('必填设置'),
|
|
43
|
+
key: koishi_1.Schema.string()
|
|
44
|
+
.pattern(/^[0-9a-f]{32}$/)
|
|
45
|
+
.role('secret')
|
|
46
|
+
.required()
|
|
47
|
+
.description('请输入一个32位小写字母的十六进制密钥(例如:9b8db7ae562b9864efefe06289cc5530),使用此密钥将你的B站登录信息存储在数据库中,请一定保存好此密钥。如果你忘记了此密钥,必须重新登录。你可以自行生成,或到这个网站生成:https://www.sexauth.com/'),
|
|
48
|
+
basicSettings: koishi_1.Schema.object({}).description('基本设置'),
|
|
49
|
+
unlockSubLimits: koishi_1.Schema.boolean()
|
|
50
|
+
.default(false)
|
|
51
|
+
.description('解锁3个订阅限制,默认只允许订阅3位UP主。订阅过多用户可能有导致IP暂时被封禁的风险'),
|
|
42
52
|
pushTime: koishi_1.Schema.number()
|
|
43
53
|
.min(0)
|
|
44
54
|
.max(12)
|
|
@@ -60,6 +70,10 @@ exports.Config = koishi_1.Schema.object({
|
|
|
60
70
|
.role('')
|
|
61
71
|
.default('render')
|
|
62
72
|
.description('渲染类型,默认为render模式,渲染速度更快,但会出现乱码问题,若出现乱码问题,请切换到page模式。若使用自定义字体,建议选择render模式'),
|
|
73
|
+
style: koishi_1.Schema.object({}).description('美化设置'),
|
|
74
|
+
removeBorder: koishi_1.Schema.boolean()
|
|
75
|
+
.default(false)
|
|
76
|
+
.description('移除推送卡片边框'),
|
|
63
77
|
cardColorStart: koishi_1.Schema.string()
|
|
64
78
|
.pattern(/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/)
|
|
65
79
|
.default('#F38AB5')
|
|
@@ -69,17 +83,20 @@ exports.Config = koishi_1.Schema.object({
|
|
|
69
83
|
.default('#F9CCDF')
|
|
70
84
|
.description('推送卡片的结束渐变背景色,请填入16进制颜色代码,参考网站:https://colorate.azurewebsites.net/'),
|
|
71
85
|
font: koishi_1.Schema.string()
|
|
72
|
-
.description('推送卡片的字体样式,如果你想用你自己的字体可以在此填写,例如:Microsoft YaHei')
|
|
73
|
-
key: koishi_1.Schema.string()
|
|
74
|
-
.pattern(/^[0-9a-f]{32}$/)
|
|
75
|
-
.role('secret')
|
|
76
|
-
.required()
|
|
77
|
-
.description('请输入一个32位小写字母的十六进制密钥(例如:9b8db7ae562b9864efefe06289cc5530),使用此密钥将你的B站登录信息存储在数据库中,请一定保存好此密钥。如果你忘记了此密钥,必须重新登录。你可以自行生成,或到这个网站生成:https://www.sexauth.com/')
|
|
86
|
+
.description('推送卡片的字体样式,如果你想用你自己的字体可以在此填写,例如:Microsoft YaHei')
|
|
78
87
|
});
|
|
79
88
|
function apply(ctx, config) {
|
|
89
|
+
// 设置提示
|
|
80
90
|
ctx.notifier.create({
|
|
81
91
|
content: '请记得使用Auth插件创建超级管理员账号,没有权限将无法使用该插件提供的指令。'
|
|
82
92
|
});
|
|
93
|
+
if (config.unlockSubLimits) { // 用户允许订阅超过三个用户
|
|
94
|
+
// 设置警告
|
|
95
|
+
ctx.notifier.create({
|
|
96
|
+
type: 'danger',
|
|
97
|
+
content: '过多的订阅可能会导致IP暂时被封禁!'
|
|
98
|
+
});
|
|
99
|
+
}
|
|
83
100
|
// load config
|
|
84
101
|
// 转换为具体时间
|
|
85
102
|
let dynamicLoopTime;
|
|
@@ -111,11 +128,11 @@ function apply(ctx, config) {
|
|
|
111
128
|
ctx.plugin(Database);
|
|
112
129
|
// Regist server
|
|
113
130
|
ctx.plugin(wbi_1.default, { key: config.key });
|
|
114
|
-
ctx.plugin(generateImg_1.default, { renderType, cardColorStart: config.cardColorStart, cardColorEnd: config.cardColorEnd, font: config.font });
|
|
131
|
+
ctx.plugin(generateImg_1.default, { renderType, removeBorder: config.removeBorder, cardColorStart: config.cardColorStart, cardColorEnd: config.cardColorEnd, font: config.font });
|
|
115
132
|
ctx.plugin(biliAPI_1.default);
|
|
116
133
|
// load plugin
|
|
117
134
|
// ctx.plugin(Authority)
|
|
118
|
-
ctx.plugin(comRegister_1.default, { pushTime: config.pushTime, dynamicCheckNumber: config.dynamicCheckNumber, dynamicLoopTime });
|
|
135
|
+
ctx.plugin(comRegister_1.default, { unlockSubLimits: config.unlockSubLimits, pushTime: config.pushTime, dynamicCheckNumber: config.dynamicCheckNumber, dynamicLoopTime });
|
|
119
136
|
// 当用户输入“恶魔兔,启动!”时,执行 help 指令
|
|
120
137
|
ctx.middleware((session, next) => {
|
|
121
138
|
if (session.content === '恶魔兔,启动!') {
|
package/package.json
CHANGED
package/readme.md
CHANGED
|
@@ -83,6 +83,8 @@
|
|
|
83
83
|
- ver 1.0.5 修复了用户非法篡改数据库内容可能导致程序异常运行的bug,修复了UP主开播动态推送空白卡片的bug
|
|
84
84
|
- ver 1.0.6 修复了转发动态转发信息出现undefined的bug,修复了再次登录订阅显示错误的bug,优化了动态推送的逻辑
|
|
85
85
|
- ver 1.0.7 修复了在已登录情况下,再次登录会导致重复订阅和提示用户未订阅任何UP主的提示(实际上已订阅)的bug,新增了订阅对象在控制台的显示,优化了bili show指令的逻辑
|
|
86
|
+
- ver 1.0.8 修复了取消订阅的bug
|
|
87
|
+
- ver 1.0.9 更新请求客户端header信息。优化了动态推送卡片的页面布局,增加了字体大小。提供用户开放订阅数量限制的选项,提供用户移除推送卡片边框的选项。在控制台页面增加订阅信息提示
|
|
86
88
|
|
|
87
89
|
## 感谢
|
|
88
90
|
|