koishi-plugin-bilibili-notify 1.0.1 → 1.0.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.d.ts CHANGED
@@ -23,6 +23,7 @@ declare class BiliAPI extends Service {
23
23
  getLoginStatus(qrcodeKey: string): Promise<any>;
24
24
  getLiveRoomInfo(roomId: string): Promise<any>;
25
25
  getMasterInfo(mid: string): Promise<any>;
26
+ getUTCPlus8Time(): number;
26
27
  disposeNotifier(): void;
27
28
  createNewClient(): void;
28
29
  getCookies(): string;
package/lib/biliAPI.js CHANGED
@@ -118,6 +118,12 @@ class BiliAPI extends koishi_1.Service {
118
118
  throw new Error('网络异常,本次请求失败!');
119
119
  }
120
120
  }
121
+ getUTCPlus8Time() {
122
+ // 获取当前时间的UTC+8时间对象
123
+ const currentTimeInUtc8 = new Date().toLocaleString('en-US', { timeZone: 'Asia/Shanghai' });
124
+ // 将时间转换为Unix时间戳(单位:秒)
125
+ return Math.floor(new Date(currentTimeInUtc8).getTime() / 1000);
126
+ }
121
127
  disposeNotifier() { this.loginNotifier && this.loginNotifier.dispose(); }
122
128
  createNewClient() {
123
129
  this.jar = new tough_cookie_1.CookieJar();
@@ -107,6 +107,14 @@ class ComRegister {
107
107
  .example('test dynamic uid')
108
108
  .action(({ session }, uid) => {
109
109
  ctx.setInterval(this.test_dynamicDetect(ctx, session, uid), 30000)
110
+ })
111
+
112
+ ctx.command('test')
113
+ .subcommand('.utc')
114
+ .usage('获取当前UTC+8 Unix时间戳')
115
+ .example('test utc')
116
+ .action(() => {
117
+ console.log(ctx.biliAPI.getUTCPlus8Time());
110
118
  }) */
111
119
  ctx.command('bili', 'bili-notify插件相关指令', { permissions: ['authority:3'] })
112
120
  .subcommand('.login', '登录B站之后才可以进行之后的操作')
@@ -489,7 +497,7 @@ class ComRegister {
489
497
  let liveTime = (new Date(data.live_time).getTime()) / 1000;
490
498
  const string = await ctx.gimg.generateLiveImg(data, userData, data.live_status !== 1 ?
491
499
  LiveType.NotLiveBroadcast :
492
- liveTime < Date.now() ? LiveType.LiveBroadcast : LiveType.StartBroadcasting);
500
+ LiveType.LiveBroadcast);
493
501
  session.send(string);
494
502
  });
495
503
  }
@@ -507,7 +515,7 @@ class ComRegister {
507
515
  // 第一次订阅判断
508
516
  if (firstSubscription) {
509
517
  // 设置第一次的时间点
510
- timePoint = Math.floor(Date.now() / 1000);
518
+ timePoint = ctx.biliAPI.getUTCPlus8Time();
511
519
  // 设置第一次为false
512
520
  firstSubscription = false;
513
521
  return;
@@ -56,7 +56,6 @@ class GenerateImg extends koishi_1.Service {
56
56
  *{
57
57
  margin: 0;
58
58
  padding: 0;
59
- font-family: 'HYZhengYuan', Courier;
60
59
  }
61
60
 
62
61
  html {
@@ -474,7 +473,6 @@ class GenerateImg extends koishi_1.Service {
474
473
  * {
475
474
  margin: 0;
476
475
  padding: 0;
477
- font-family: 'HYZhengYuan', Courier;
478
476
  }
479
477
 
480
478
  html {
@@ -899,7 +897,7 @@ class GenerateImg extends koishi_1.Service {
899
897
  // 获取Unix时间戳(以毫秒为单位)
900
898
  const unixTime = date.getTime();
901
899
  // 获取当前Unix时间戳
902
- const now = Date.now();
900
+ const now = this.ctx.biliAPI.getUTCPlus8Time();
903
901
  // 计算时间差(以秒为单位)
904
902
  const differenceInSeconds = Math.floor((now - unixTime) / 1000);
905
903
  // 获取yyyy:MM:dd HH:mm:ss
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.1",
4
+ "version": "1.0.2",
5
5
  "contributors": [
6
6
  "Akokko <admin@akokko.com>"
7
7
  ],
package/readme.md CHANGED
@@ -1,17 +1,17 @@
1
- <div align="center">
1
+ <center>
2
2
  # Bilibili-Botify
3
- </div>
4
-
3
+ </center>
5
4
 
6
5
  基于 [koishi](../../../../koishijs/koishi) 框架的B站推送插件
7
6
 
8
7
  ---
9
8
 
10
- - **koishi-plugin-bilibili-notify** [![npm](https://img.shields.io/npm/v/koishi-plugin-bilibili-notify?style=flat-square)](https://www.npmjs.com/package/koishi-plugin-bilibili-notify)
9
+ - koishi-plugin-bilibili-notify [![npm](https://img.shields.io/npm/v/koishi-plugin-bilibili-notify?style=flat-square)](https://www.npmjs.com/package/koishi-plugin-bilibili-notify)
11
10
  - [功能](#功能)
12
11
  - [安装](#安装)
13
12
  - [使用方法](#使用方法)
14
13
  - [注意事项](#注意事项)
14
+ - [更新日志](#更新日志)
15
15
  - [感谢](#感谢)
16
16
  - [License](#License)
17
17
 
@@ -79,6 +79,7 @@
79
79
  ## 更新日志
80
80
 
81
81
  ver 1.0.1 修复了一些bug,提供用户自己选择动态检测时间的选项
82
+ ver 1.0.2 修复时间bug和字体乱码问题
82
83
 
83
84
  ## 感谢
84
85