koishi-plugin-bilibili-notify 1.0.0-rc.0 → 1.0.0-rc.2
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 +5 -2
- package/lib/comRegister.js +39 -28
- package/lib/index.d.ts +1 -0
- package/lib/index.js +5 -5
- package/package.json +1 -7
package/lib/biliAPI.js
CHANGED
|
@@ -222,10 +222,13 @@ class BiliAPI extends koishi_1.Service {
|
|
|
222
222
|
throw new Error('refresh_csrf 错误或 refresh_token 与 cookie 不匹配');
|
|
223
223
|
}
|
|
224
224
|
}
|
|
225
|
-
// 更新refresh_token
|
|
225
|
+
// 更新 新的cookies和refresh_token
|
|
226
|
+
const encryptedCookies = this.ctx.wbi.encrypt(this.ctx.biliAPI.getCookies());
|
|
227
|
+
const encryptedRefreshToken = this.ctx.wbi.encrypt(refreshData.data.refresh_token);
|
|
226
228
|
await this.ctx.database.upsert('loginBili', [{
|
|
227
229
|
id: 1,
|
|
228
|
-
|
|
230
|
+
bili_cookies: encryptedCookies,
|
|
231
|
+
bili_refresh_token: encryptedRefreshToken
|
|
229
232
|
}]);
|
|
230
233
|
// Get new csrf from cookies
|
|
231
234
|
let newCsrf;
|
package/lib/comRegister.js
CHANGED
|
@@ -29,76 +29,85 @@ class ComRegister {
|
|
|
29
29
|
this.qqBot = ctx.bots[ctx.bots.findIndex(bot => bot.platform === 'qq')];
|
|
30
30
|
// 拿到QQ频道机器人
|
|
31
31
|
this.qqguildBot = ctx.bots[ctx.bots.findIndex(bot => bot.platform === 'qqguild')];
|
|
32
|
+
// 从数据库获取订阅
|
|
32
33
|
this.getSubFromDatabase(ctx);
|
|
33
|
-
ctx.command('test', { hidden: true, permissions: ['authority:5'] })
|
|
34
|
+
/* ctx.command('test', { hidden: true, permissions: ['authority:5'] })
|
|
34
35
|
.subcommand('.cookies')
|
|
35
36
|
.usage('测试指令,用于测试从数据库读取cookies')
|
|
36
37
|
.action(async () => {
|
|
37
|
-
|
|
38
|
-
|
|
38
|
+
await ctx.biliAPI.loadCookiesFromDatabase()
|
|
39
|
+
})
|
|
40
|
+
|
|
39
41
|
ctx.command('test')
|
|
40
42
|
.subcommand('.my')
|
|
41
43
|
.usage('测试指令,用于测试获取自己信息')
|
|
42
44
|
.example('test.my')
|
|
43
45
|
.action(async () => {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
46
|
+
const content = await ctx.biliAPI.getMyselfInfo()
|
|
47
|
+
console.log(content);
|
|
48
|
+
})
|
|
49
|
+
|
|
47
50
|
ctx.command('test')
|
|
48
51
|
.subcommand('.user <mid:string>')
|
|
49
52
|
.usage('测试指令,用于测试获取用户信息')
|
|
50
53
|
.example('test.user 用户UID')
|
|
51
54
|
.action(async (_, mid) => {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
+
const content = await ctx.biliAPI.getUserInfo(mid)
|
|
56
|
+
console.log(content);
|
|
57
|
+
})
|
|
58
|
+
|
|
55
59
|
ctx.command('test')
|
|
56
60
|
.subcommand('.time')
|
|
57
61
|
.usage('测试时间接口')
|
|
58
62
|
.example('test.time')
|
|
59
63
|
.action(async () => {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
64
|
+
const content = await ctx.biliAPI.getTimeNow()
|
|
65
|
+
console.log(content);
|
|
66
|
+
})
|
|
67
|
+
|
|
63
68
|
ctx.command('test')
|
|
64
69
|
.subcommand('.exist')
|
|
65
70
|
.usage('测试写法')
|
|
66
71
|
.example('test.exist')
|
|
67
72
|
.action(async () => {
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
73
|
+
let num = 1;
|
|
74
|
+
console.log(num && `Hello World`);
|
|
75
|
+
})
|
|
76
|
+
|
|
71
77
|
ctx.command('test')
|
|
72
78
|
.subcommand('.gimg <uid:string> <index:number>')
|
|
73
79
|
.usage('测试图片生成')
|
|
74
80
|
.example('test.gimg')
|
|
75
81
|
.action(async (_, uid, index) => {
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
82
|
+
// 获取用户空间动态数据
|
|
83
|
+
const { data } = await ctx.biliAPI.getUserSpaceDynamic(uid)
|
|
84
|
+
const [pic] = await ctx.gimg.generateDynamicImg(data.items[index])
|
|
85
|
+
return pic
|
|
86
|
+
})
|
|
87
|
+
|
|
81
88
|
ctx.command('test')
|
|
82
89
|
.subcommand('.group')
|
|
83
90
|
.usage('查看session groupId')
|
|
84
91
|
.example('test group')
|
|
85
92
|
.action(({ session }) => {
|
|
86
|
-
|
|
87
|
-
|
|
93
|
+
console.log(session.event.channel);
|
|
94
|
+
})
|
|
95
|
+
|
|
88
96
|
ctx.command('test')
|
|
89
97
|
.subcommand('.session')
|
|
90
98
|
.usage('查看seesion')
|
|
91
99
|
.example('test session')
|
|
92
100
|
.action(({ session }) => {
|
|
93
|
-
|
|
94
|
-
|
|
101
|
+
console.log(session);
|
|
102
|
+
})
|
|
103
|
+
|
|
95
104
|
ctx.command('test')
|
|
96
105
|
.subcommand('.dynamic <uid:string>')
|
|
97
106
|
.usage('测试动态监测')
|
|
98
107
|
.example('test dynamic uid')
|
|
99
108
|
.action(({ session }, uid) => {
|
|
100
|
-
|
|
101
|
-
|
|
109
|
+
ctx.setInterval(this.test_dynamicDetect(ctx, session, uid), 30000)
|
|
110
|
+
}) */
|
|
102
111
|
ctx.command('bili', 'bili-notify插件相关指令', { permissions: ['authority:3'] })
|
|
103
112
|
.subcommand('.login', '登录B站之后才可以进行之后的操作')
|
|
104
113
|
.usage('使用二维码登录,登录B站之后才可以进行之后的操作')
|
|
@@ -154,7 +163,7 @@ class ComRegister {
|
|
|
154
163
|
return await session.send('二维码已失效,请重新登录!');
|
|
155
164
|
}
|
|
156
165
|
if (loginContent.data.code === 0) { // 登录成功
|
|
157
|
-
const encryptedCookies = ctx.wbi.encrypt(
|
|
166
|
+
const encryptedCookies = ctx.wbi.encrypt(ctx.biliAPI.getCookies());
|
|
158
167
|
const encryptedRefreshToken = ctx.wbi.encrypt(loginContent.data.refresh_token);
|
|
159
168
|
await ctx.database.upsert('loginBili', [{
|
|
160
169
|
id: 1,
|
|
@@ -615,6 +624,8 @@ class ComRegister {
|
|
|
615
624
|
uData = userData;
|
|
616
625
|
// 判断直播状态
|
|
617
626
|
if (data.live_status === 1) { // 当前正在直播
|
|
627
|
+
// 设置开播时间
|
|
628
|
+
liveTime = data.live_time;
|
|
618
629
|
// 推送直播信息
|
|
619
630
|
await bot.sendMessage(guildId, await ctx
|
|
620
631
|
.gimg
|
|
@@ -663,7 +674,7 @@ class ComRegister {
|
|
|
663
674
|
if (this.config.pushTime > 0) {
|
|
664
675
|
timer++;
|
|
665
676
|
// 开始记录时间
|
|
666
|
-
if (timer >= (
|
|
677
|
+
if (timer >= (6 * 60 * this.config.pushTime)) { // 到时间推送直播消息
|
|
667
678
|
// 到时间重新计时
|
|
668
679
|
timer = 0;
|
|
669
680
|
// 发送状态信息
|
package/lib/index.d.ts
CHANGED
package/lib/index.js
CHANGED
|
@@ -26,7 +26,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
26
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.apply = exports.Config = exports.name = void 0;
|
|
29
|
+
exports.apply = exports.Config = exports.name = exports.inject = void 0;
|
|
30
30
|
const koishi_1 = require("koishi");
|
|
31
31
|
// import crypto
|
|
32
32
|
// import crypto from 'crypto'
|
|
@@ -38,15 +38,15 @@ const Database = __importStar(require("./database"));
|
|
|
38
38
|
const wbi_1 = __importDefault(require("./wbi"));
|
|
39
39
|
const generateImg_1 = __importDefault(require("./generateImg"));
|
|
40
40
|
const biliAPI_1 = __importDefault(require("./biliAPI"));
|
|
41
|
+
exports.inject = ['puppeteer', 'database'];
|
|
41
42
|
exports.name = 'bilibili-notify';
|
|
42
43
|
exports.Config = koishi_1.Schema.object({
|
|
43
44
|
pushTime: koishi_1.Schema.number()
|
|
44
45
|
.min(0)
|
|
45
|
-
.max(
|
|
46
|
-
.step(
|
|
47
|
-
.role('slider')
|
|
46
|
+
.max(12)
|
|
47
|
+
.step(0.5)
|
|
48
48
|
.default(1)
|
|
49
|
-
.description('
|
|
49
|
+
.description('设定隔多长时间推送一次直播状态,单位为小时,默认为一小时'),
|
|
50
50
|
cardColorStart: koishi_1.Schema.string()
|
|
51
51
|
.pattern(/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/)
|
|
52
52
|
.default('#F38AB5')
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "koishi-plugin-bilibili-notify",
|
|
3
3
|
"description": "Koishi bilibili notify plugin",
|
|
4
|
-
"version": "1.0.0-rc.
|
|
4
|
+
"version": "1.0.0-rc.2",
|
|
5
5
|
"contributors": [
|
|
6
6
|
"Akokko <admin@akokko.com>"
|
|
7
7
|
],
|
|
@@ -36,12 +36,6 @@
|
|
|
36
36
|
"devDependencies": {
|
|
37
37
|
"koishi-plugin-puppeteer": "^3.7.3"
|
|
38
38
|
},
|
|
39
|
-
"service": {
|
|
40
|
-
"required": [
|
|
41
|
-
"puppeteer",
|
|
42
|
-
"database"
|
|
43
|
-
]
|
|
44
|
-
},
|
|
45
39
|
"koishi": {
|
|
46
40
|
"preview": true,
|
|
47
41
|
"service": {
|