koishi-plugin-bilibili-notify 1.2.0-alpha.3 → 1.2.0-alpha.4

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
@@ -28,6 +28,7 @@ declare class BiliAPI extends Service {
28
28
  getMasterInfo(mid: string): Promise<any>;
29
29
  disposeNotifier(): void;
30
30
  createNewClient(): void;
31
+ getTimeOfUTC8(): number;
31
32
  getCookies(): string;
32
33
  getLoginInfoFromDB(): Promise<{
33
34
  cookies: any;
package/lib/biliAPI.js CHANGED
@@ -8,6 +8,7 @@ const axios_1 = __importDefault(require("axios"));
8
8
  const tough_cookie_1 = require("tough-cookie");
9
9
  const axios_cookiejar_support_1 = require("axios-cookiejar-support");
10
10
  const jsdom_1 = require("jsdom");
11
+ const luxon_1 = require("luxon");
11
12
  // const GET_DYNAMIC_LIST = 'https://api.bilibili.com/x/polymer/web-dynamic/v1/feed/all'
12
13
  const GET_USER_SPACE_DYNAMIC_LIST = 'https://api.bilibili.com/x/polymer/web-dynamic/v1/feed/space';
13
14
  const GET_COOKIES_INFO = 'https://passport.bilibili.com/x/passport-login/web/cookie/info';
@@ -193,6 +194,9 @@ class BiliAPI extends koishi_1.Service {
193
194
  }
194
195
  }));
195
196
  }
197
+ getTimeOfUTC8() {
198
+ return Math.floor(luxon_1.DateTime.now().setZone('UTC+8').toSeconds());
199
+ }
196
200
  getCookies() {
197
201
  let cookies;
198
202
  cookies = JSON.stringify(this.jar.serializeSync().cookies);
@@ -588,7 +588,7 @@ class ComRegister {
588
588
  // 第一次订阅判断
589
589
  if (firstSubscription) {
590
590
  // 设置第一次的时间点
591
- timePoint = await ctx.biliAPI.getServerUTCTime();
591
+ timePoint = ctx.biliAPI.getTimeOfUTC8();
592
592
  // 设置第一次为false
593
593
  firstSubscription = false;
594
594
  return;
@@ -7,7 +7,7 @@ declare module 'koishi' {
7
7
  }
8
8
  declare class GenerateImg extends Service {
9
9
  static inject: string[];
10
- config: GenerateImg.Config;
10
+ giConfig: GenerateImg.Config;
11
11
  constructor(ctx: Context, config: GenerateImg.Config);
12
12
  protected start(): void | Promise<void>;
13
13
  generateLiveImg(data: any, userData: any, liveStatus: number): Promise<{
@@ -38,10 +38,10 @@ const ADDITIONAL_TYPE_UGC = 'ADDITIONAL_TYPE_UGC' */
38
38
  const ADDITIONAL_TYPE_RESERVE = 'ADDITIONAL_TYPE_RESERVE';
39
39
  class GenerateImg extends koishi_1.Service {
40
40
  static inject = ['puppeteer', 'biliAPI'];
41
- config;
41
+ giConfig;
42
42
  constructor(ctx, config) {
43
43
  super(ctx, 'gimg');
44
- this.config = config;
44
+ this.giConfig = config;
45
45
  }
46
46
  start() {
47
47
  // this.logger.info('GenerateImg已被注册到Context中');
@@ -65,7 +65,7 @@ class GenerateImg extends koishi_1.Service {
65
65
  * {
66
66
  margin: 0;
67
67
  padding: 0;
68
- font-family: "${this.config.font}", "Custom Font", "Microsoft YaHei", "Source Han Sans", "Noto Sans CJK", sans-serif;
68
+ font-family: "${this.giConfig.font}", "Custom Font", "Microsoft YaHei", "Source Han Sans", "Noto Sans CJK", sans-serif;
69
69
  }
70
70
 
71
71
  html {
@@ -76,7 +76,7 @@ class GenerateImg extends koishi_1.Service {
76
76
  .background {
77
77
  width: 770px;
78
78
  height: auto;
79
- background: linear-gradient(to right bottom, ${this.config.cardColorStart}, ${this.config.cardColorEnd});
79
+ background: linear-gradient(to right bottom, ${this.giConfig.cardColorStart}, ${this.giConfig.cardColorEnd});
80
80
  overflow: hidden;
81
81
  }
82
82
 
@@ -91,7 +91,7 @@ class GenerateImg extends koishi_1.Service {
91
91
  }
92
92
 
93
93
  .base-plate {
94
- ${this.config.removeBorder ? `
94
+ ${this.giConfig.removeBorder ? `
95
95
  width: 740px;
96
96
  ` : `
97
97
  width: 704px;
@@ -186,7 +186,7 @@ class GenerateImg extends koishi_1.Service {
186
186
  </html>
187
187
  `;
188
188
  // 判断渲染方式
189
- if (this.config.renderType) { // 为1则为真,进入page模式
189
+ if (this.giConfig.renderType) { // 为1则为真,进入page模式
190
190
  const htmlPath = 'file://' + __dirname.replaceAll('\\', '/') + '/page/0.html';
191
191
  const page = await this.ctx.puppeteer.page();
192
192
  await page.goto(htmlPath);
@@ -251,14 +251,14 @@ class GenerateImg extends koishi_1.Service {
251
251
  }
252
252
  }, '');
253
253
  // 关键字和正则屏蔽
254
- if (this.config.filter.enable) { // 开启关键字和正则屏蔽
255
- if (this.config.filter.regex) { // 正则屏蔽
256
- const reg = new RegExp(this.config.filter.regex);
254
+ if (this.giConfig.filter.enable) { // 开启关键字和正则屏蔽
255
+ if (this.giConfig.filter.regex) { // 正则屏蔽
256
+ const reg = new RegExp(this.giConfig.filter.regex);
257
257
  if (reg.test(richText))
258
258
  throw new Error('出现关键词,屏蔽该动态');
259
259
  }
260
- if (this.config.filter.keywords.length !== 0 &&
261
- this.config.filter.keywords
260
+ if (this.giConfig.filter.keywords.length !== 0 &&
261
+ this.giConfig.filter.keywords
262
262
  .some(keyword => richText.includes(keyword))) {
263
263
  throw new Error('出现关键词,屏蔽该动态');
264
264
  }
@@ -517,7 +517,7 @@ class GenerateImg extends koishi_1.Service {
517
517
  const fontURL = (0, url_1.pathToFileURL)((0, path_1.resolve)(__dirname, 'font/HYZhengYuan-75W.ttf'));
518
518
  // 判断是否开启大字体模式
519
519
  let style;
520
- if (this.config.enableLargeFont) {
520
+ if (this.giConfig.enableLargeFont) {
521
521
  style = `
522
522
  @font-face {
523
523
  font-family: "Custom Font";
@@ -528,7 +528,7 @@ class GenerateImg extends koishi_1.Service {
528
528
  margin: 0;
529
529
  padding: 0;
530
530
  box-sizing: border-box;
531
- font-family: "${this.config.font}", "Custom Font", "Microsoft YaHei", "Source Han Sans", "Noto Sans CJK", sans-serif;
531
+ font-family: "${this.giConfig.font}", "Custom Font", "Microsoft YaHei", "Source Han Sans", "Noto Sans CJK", sans-serif;
532
532
  }
533
533
 
534
534
  html {
@@ -539,7 +539,7 @@ class GenerateImg extends koishi_1.Service {
539
539
  .background {
540
540
  width: 770px;
541
541
  height: auto;
542
- background: linear-gradient(to right bottom, ${this.config.cardColorStart}, ${this.config.cardColorEnd});
542
+ background: linear-gradient(to right bottom, ${this.giConfig.cardColorStart}, ${this.giConfig.cardColorEnd});
543
543
  overflow: hidden;
544
544
  }
545
545
 
@@ -554,7 +554,7 @@ class GenerateImg extends koishi_1.Service {
554
554
  }
555
555
 
556
556
  .base-plate {
557
- ${this.config.removeBorder ? `
557
+ ${this.giConfig.removeBorder ? `
558
558
  width: 740px;
559
559
  ` : `
560
560
  width: 704px;
@@ -858,7 +858,7 @@ class GenerateImg extends koishi_1.Service {
858
858
  * {
859
859
  margin: 0;
860
860
  padding: 0;
861
- font-family: "${this.config.font}", "Custom Font", "Microsoft YaHei", "Source Han Sans", "Noto Sans CJK", sans-serif;
861
+ font-family: "${this.giConfig.font}", "Custom Font", "Microsoft YaHei", "Source Han Sans", "Noto Sans CJK", sans-serif;
862
862
  }
863
863
 
864
864
  html {
@@ -869,7 +869,7 @@ class GenerateImg extends koishi_1.Service {
869
869
  .background {
870
870
  width: 770px;
871
871
  height: auto;
872
- background: linear-gradient(to right bottom, ${this.config.cardColorStart}, ${this.config.cardColorEnd});
872
+ background: linear-gradient(to right bottom, ${this.giConfig.cardColorStart}, ${this.giConfig.cardColorEnd});
873
873
  overflow: hidden;
874
874
  }
875
875
 
@@ -1258,7 +1258,7 @@ class GenerateImg extends koishi_1.Service {
1258
1258
  </html>
1259
1259
  `;
1260
1260
  // 判断渲染方式
1261
- if (this.config.renderType) { // 为1则为真,进入page模式
1261
+ if (this.giConfig.renderType) { // 为1则为真,进入page模式
1262
1262
  const htmlPath = 'file://' + __dirname.replaceAll('\\', '/') + '/page/0.html';
1263
1263
  const page = await this.ctx.puppeteer.page();
1264
1264
  await page.goto(htmlPath);
@@ -1314,7 +1314,7 @@ class GenerateImg extends koishi_1.Service {
1314
1314
  // 获取Unix时间戳(以毫秒为单位)
1315
1315
  const unixTime = date.getTime() / 1000;
1316
1316
  // 获取当前Unix时间戳
1317
- const now = await this.ctx.biliAPI.getServerUTCTime();
1317
+ const now = this.ctx.biliAPI.getTimeOfUTC8();
1318
1318
  // 计算时间差(以秒为单位)
1319
1319
  const differenceInSeconds = Math.floor(now - unixTime);
1320
1320
  // 获取yyyy:MM:dd HH:mm:ss
package/lib/wbi.d.ts CHANGED
@@ -5,7 +5,7 @@ declare module 'koishi' {
5
5
  }
6
6
  }
7
7
  declare class Wbi extends Service {
8
- config: Wbi.Config;
8
+ wbiConfig: Wbi.Config;
9
9
  mixinKeyEncTab: number[];
10
10
  constructor(ctx: Context, config: Wbi.Config);
11
11
  protected start(): void | Promise<void>;
package/lib/wbi.js CHANGED
@@ -7,7 +7,7 @@ const koishi_1 = require("koishi");
7
7
  const md5_1 = __importDefault(require("md5"));
8
8
  const crypto_1 = __importDefault(require("crypto"));
9
9
  class Wbi extends koishi_1.Service {
10
- config;
10
+ wbiConfig;
11
11
  mixinKeyEncTab = [
12
12
  46, 47, 18, 2, 53, 8, 23, 32, 15, 50, 10, 31, 58, 3, 45, 35, 27, 43, 5, 49,
13
13
  33, 9, 42, 19, 29, 28, 14, 39, 12, 38, 41, 13, 37, 48, 7, 16, 24, 55, 40,
@@ -16,7 +16,7 @@ class Wbi extends koishi_1.Service {
16
16
  ];
17
17
  constructor(ctx, config) {
18
18
  super(ctx, 'wbi');
19
- this.config = config;
19
+ this.wbiConfig = config;
20
20
  }
21
21
  start() {
22
22
  // this.logger.info('wbi已被注册到Context中')
@@ -62,7 +62,7 @@ class Wbi extends koishi_1.Service {
62
62
  }
63
63
  encrypt(text, secretKey) {
64
64
  const iv = crypto_1.default.randomBytes(16);
65
- const cipher = crypto_1.default.createCipheriv('aes-256-cbc', Buffer.from(this.config.key), iv);
65
+ const cipher = crypto_1.default.createCipheriv('aes-256-cbc', Buffer.from(this.wbiConfig.key), iv);
66
66
  const encrypted = Buffer.concat([cipher.update(text), cipher.final()]);
67
67
  return iv.toString('hex') + ':' + encrypted.toString('hex');
68
68
  }
@@ -70,7 +70,7 @@ class Wbi extends koishi_1.Service {
70
70
  let textParts = text.split(':');
71
71
  let iv = Buffer.from(textParts.shift(), 'hex');
72
72
  let encryptedText = Buffer.from(textParts.join(':'), 'hex');
73
- let decipher = crypto_1.default.createDecipheriv('aes-256-cbc', Buffer.from(this.config.key), iv);
73
+ let decipher = crypto_1.default.createDecipheriv('aes-256-cbc', Buffer.from(this.wbiConfig.key), iv);
74
74
  let decrypted = Buffer.concat([decipher.update(encryptedText), decipher.final()]);
75
75
  return decrypted.toString();
76
76
  }
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.2.0-alpha.3",
4
+ "version": "1.2.0-alpha.4",
5
5
  "contributors": [
6
6
  "Akokko <admin@akokko.com>"
7
7
  ],
@@ -24,21 +24,23 @@
24
24
  "bilibili"
25
25
  ],
26
26
  "peerDependencies": {
27
- "koishi": "^4.16.8"
27
+ "koishi": "^4.17.1"
28
28
  },
29
29
  "dependencies": {
30
30
  "axios": "^1.6.7",
31
31
  "axios-cookiejar-support": "^5.0.0",
32
32
  "jsdom": "^24.0.0",
33
+ "luxon": "^3.4.4",
33
34
  "md5": "^2.3.0",
34
35
  "qrcode": "^1.5.3",
35
36
  "tough-cookie": "^4.1.3"
36
37
  },
37
38
  "devDependencies": {
39
+ "@types/luxon": "^3",
38
40
  "@types/md5": "^2",
39
41
  "@types/qrcode": "^1",
40
42
  "@types/tough-cookie": "^4",
41
- "koishi-plugin-puppeteer": "^3.7.3"
43
+ "koishi-plugin-puppeteer": "^3.8.2"
42
44
  },
43
45
  "koishi": {
44
46
  "service": {
package/readme.md CHANGED
@@ -104,6 +104,7 @@
104
104
  - ver 1.2.0-alpha.1 对推送进行了改进:在开启直播开播艾特全体成员的情况下,发送图片后才会艾特全体成员
105
105
  - ver 1.2.0-alpha.2 支持QQ群多群推送(实验性),修复了一些bug
106
106
  - ver 1.2.0-alpha.3 修复了指定QQ群订阅时的一个bug
107
+ - ver 1.2.0-alpha.4 对时间获取进行了优化,能够适应不同环境下的时间获取,修复了一些bug
107
108
 
108
109
  ## 感谢
109
110