koishi-plugin-bilibili-notify 1.0.1 → 1.0.3

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();
@@ -101,12 +101,20 @@ class ComRegister {
101
101
  console.log(session);
102
102
  })
103
103
 
104
+ // ctx.command('test')
105
+ // .subcommand('.dynamic <uid:string>')
106
+ // .usage('测试动态监测')
107
+ // .example('test dynamic uid')
108
+ // .action(({ session }, uid) => {
109
+ // ctx.setInterval(this.test_dynamicDetect(ctx, session, uid), 30000)
110
+ // })
111
+
104
112
  ctx.command('test')
105
- .subcommand('.dynamic <uid:string>')
106
- .usage('测试动态监测')
107
- .example('test dynamic uid')
108
- .action(({ session }, uid) => {
109
- ctx.setInterval(this.test_dynamicDetect(ctx, session, uid), 30000)
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;
@@ -19,6 +19,7 @@ declare namespace GenerateImg {
19
19
  interface Config {
20
20
  cardColorStart: string;
21
21
  cardColorEnd: string;
22
+ font: string;
22
23
  }
23
24
  const Config: Schema<Config>;
24
25
  }
@@ -56,7 +56,7 @@ class GenerateImg extends koishi_1.Service {
56
56
  *{
57
57
  margin: 0;
58
58
  padding: 0;
59
- font-family: 'HYZhengYuan', Courier;
59
+ font-family: "${this.config.font}", "Microsoft YaHei", "Source Han Sans", "Noto Sans CJK", sans-serif;
60
60
  }
61
61
 
62
62
  html {
@@ -474,7 +474,7 @@ class GenerateImg extends koishi_1.Service {
474
474
  * {
475
475
  margin: 0;
476
476
  padding: 0;
477
- font-family: 'HYZhengYuan', Courier;
477
+ font-family: "${this.config.font}", "Microsoft YaHei", "Source Han Sans", "Noto Sans CJK", sans-serif;
478
478
  }
479
479
 
480
480
  html {
@@ -899,7 +899,7 @@ class GenerateImg extends koishi_1.Service {
899
899
  // 获取Unix时间戳(以毫秒为单位)
900
900
  const unixTime = date.getTime();
901
901
  // 获取当前Unix时间戳
902
- const now = Date.now();
902
+ const now = this.ctx.biliAPI.getUTCPlus8Time();
903
903
  // 计算时间差(以秒为单位)
904
904
  const differenceInSeconds = Math.floor((now - unixTime) / 1000);
905
905
  // 获取yyyy:MM:dd HH:mm:ss
@@ -932,7 +932,8 @@ class GenerateImg extends koishi_1.Service {
932
932
  cardColorEnd: koishi_1.Schema.string()
933
933
  .pattern(/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/)
934
934
  .default('#F9CCDF')
935
- .description('推送卡片的结束渐变背景色,请填入16进制颜色代码,参考网站:https://colorate.azurewebsites.net/')
935
+ .description('推送卡片的结束渐变背景色,请填入16进制颜色代码,参考网站:https://colorate.azurewebsites.net/'),
936
+ font: koishi_1.Schema.string()
936
937
  });
937
938
  })(GenerateImg || (GenerateImg = {}));
938
939
  exports.default = GenerateImg;
package/lib/index.d.ts CHANGED
@@ -7,6 +7,7 @@ export interface Config {
7
7
  dynamicLoopTime: '1分钟' | '2分钟' | '3分钟' | '5分钟';
8
8
  cardColorStart: string;
9
9
  cardColorEnd: string;
10
+ font: string;
10
11
  key: string;
11
12
  }
12
13
  export declare const Config: Schema<Config>;
package/lib/index.js CHANGED
@@ -64,6 +64,8 @@ exports.Config = koishi_1.Schema.object({
64
64
  .pattern(/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/)
65
65
  .default('#F9CCDF')
66
66
  .description('推送卡片的结束渐变背景色,请填入16进制颜色代码,参考网站:https://colorate.azurewebsites.net/'),
67
+ font: koishi_1.Schema.string()
68
+ .description('推送卡片的字体样式,如果你想用你自己的字体可以在此填写,例如:Microsoft YaHei'),
67
69
  key: koishi_1.Schema.string()
68
70
  .pattern(/^[0-9a-f]{32}$/)
69
71
  .role('secret')
@@ -78,7 +80,7 @@ function apply(ctx, config) {
78
80
  ctx.plugin(Database);
79
81
  // Regist server
80
82
  ctx.plugin(wbi_1.default, { key: config.key });
81
- ctx.plugin(generateImg_1.default, { cardColorStart: config.cardColorStart, cardColorEnd: config.cardColorEnd });
83
+ ctx.plugin(generateImg_1.default, { cardColorStart: config.cardColorStart, cardColorEnd: config.cardColorEnd, font: config.font });
82
84
  ctx.plugin(biliAPI_1.default);
83
85
  // load plugin
84
86
  // ctx.plugin(Authority)
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.3",
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,8 @@
79
79
  ## 更新日志
80
80
 
81
81
  ver 1.0.1 修复了一些bug,提供用户自己选择动态检测时间的选项
82
+ ver 1.0.2 修复时间bug和字体乱码问题
83
+ ver 1.0.3 修复了一些bug,提供用户自己选择推送卡片字体样式的选项
82
84
 
83
85
  ## 感谢
84
86