koishi-plugin-bilibili-notify 1.0.0-rc.0 → 1.0.0-rc.1

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 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
- bili_refresh_token: refreshData.data.refresh_token
230
+ bili_cookies: encryptedCookies,
231
+ bili_refresh_token: encryptedRefreshToken
229
232
  }]);
230
233
  // Get new csrf from cookies
231
234
  let newCsrf;
@@ -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
- await ctx.biliAPI.loadCookiesFromDatabase();
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
- const content = await ctx.biliAPI.getMyselfInfo();
45
- console.log(content);
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
- const content = await ctx.biliAPI.getUserInfo(mid);
53
- console.log(content);
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
- const content = await ctx.biliAPI.getTimeNow();
61
- console.log(content);
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
- let num = 1;
69
- console.log(num && `Hello World`);
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
- const { data } = await ctx.biliAPI.getUserSpaceDynamic(uid);
78
- const [pic] = await ctx.gimg.generateDynamicImg(data.items[index]);
79
- return pic;
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
- console.log(session.event.channel);
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
- console.log(session);
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
- ctx.setInterval(this.test_dynamicDetect(ctx, session, uid), 30000);
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(await ctx.biliAPI.getCookies());
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 >= (12 * 30 * this.config.pushTime)) { // 到时间推送直播消息
677
+ if (timer >= (6 * 60 * this.config.pushTime)) { // 到时间推送直播消息
667
678
  // 到时间重新计时
668
679
  timer = 0;
669
680
  // 发送状态信息
package/lib/index.js CHANGED
@@ -42,11 +42,10 @@ exports.name = 'bilibili-notify';
42
42
  exports.Config = koishi_1.Schema.object({
43
43
  pushTime: koishi_1.Schema.number()
44
44
  .min(0)
45
- .max(24)
46
- .step(1)
47
- .role('slider')
45
+ .max(12)
46
+ .step(0.5)
48
47
  .default(1)
49
- .description('设定隔多长时间推送一次直播状态,单位为半小时,默认为半小时'),
48
+ .description('设定隔多长时间推送一次直播状态,单位为小时,默认为一小时'),
50
49
  cardColorStart: koishi_1.Schema.string()
51
50
  .pattern(/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/)
52
51
  .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.0",
4
+ "version": "1.0.0-rc.1",
5
5
  "contributors": [
6
6
  "Akokko <admin@akokko.com>"
7
7
  ],