koishi-plugin-bilibili-notify 3.0.0-alpha.14 → 3.0.0-alpha.15

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
@@ -67,7 +67,6 @@ declare class BiliAPI extends Service {
67
67
  disposeNotifier(): void;
68
68
  getRandomUserAgent(): string;
69
69
  createNewClient(): void;
70
- getTimeOfUTC8(): number;
71
70
  getCookies(): string;
72
71
  getCookiesForHeader(): Promise<string>;
73
72
  getLoginInfoIsLoaded(): boolean;
package/lib/biliAPI.js CHANGED
@@ -16,7 +16,6 @@ const axios_1 = __importDefault(require("axios"));
16
16
  const tough_cookie_1 = require("tough-cookie");
17
17
  const axios_cookiejar_support_1 = require("axios-cookiejar-support");
18
18
  const jsdom_1 = require("jsdom");
19
- const luxon_1 = require("luxon");
20
19
  const retry_1 = __importDefault(require("./utils/retry"));
21
20
  const mixinKeyEncTab = [
22
21
  46, 47, 18, 2, 53, 8, 23, 32, 15, 50, 10, 31, 58, 3, 45, 35, 27, 43, 5, 49,
@@ -297,9 +296,6 @@ class BiliAPI extends koishi_1.Service {
297
296
  },
298
297
  }));
299
298
  }
300
- getTimeOfUTC8() {
301
- return Math.floor(luxon_1.DateTime.now().setZone("UTC+8").toSeconds());
302
- }
303
299
  getCookies() {
304
300
  const cookies = JSON.stringify(this.jar.serializeSync().cookies);
305
301
  return cookies;
@@ -695,8 +695,8 @@ class ComRegister {
695
695
  this.checkIfDynamicDetectIsNeeded();
696
696
  // 在控制台中显示订阅对象
697
697
  this.updateSubNotifier();
698
- // Test
699
- const testTarget = [
698
+ /* // Test
699
+ const testTarget: Target = [
700
700
  {
701
701
  channelIdArr: [
702
702
  {
@@ -710,8 +710,9 @@ class ComRegister {
710
710
  platform: "qqguild",
711
711
  },
712
712
  ];
713
+
713
714
  const buffer = await this.ctx.gi.generateWordCloudImg();
714
- this.sendMsg(testTarget, koishi_1.h.image(buffer, "image/png"));
715
+ this.sendMsg(testTarget, h.image(buffer, "image/png")); */
715
716
  }
716
717
  splitMultiPlatformStr(str) {
717
718
  return str
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const koishi_1 = require("koishi");
4
+ const luxon_1 = require("luxon");
4
5
  const node_path_1 = require("node:path");
5
6
  const node_url_1 = require("node:url");
6
7
  // 动态类型
@@ -1487,22 +1488,39 @@ class GenerateImg extends koishi_1.Service {
1487
1488
  }
1488
1489
  async getTimeDifference(dateString) {
1489
1490
  // 将日期字符串转换为Date对象
1490
- const date = new Date(dateString);
1491
- // 获取Unix时间戳(以毫秒为单位)
1492
- const unixTime = date.getTime() / 1000;
1493
- // 获取当前Unix时间戳
1494
- const now = this.ctx.ba.getTimeOfUTC8();
1495
- // 计算时间差(以秒为单位)
1496
- const differenceInSeconds = Math.floor(now - unixTime);
1497
- // 获取yyyy:MM:dd HH:mm:ss
1498
- const days = Math.floor(differenceInSeconds / (24 * 60 * 60));
1499
- const hours = Math.floor((differenceInSeconds % (24 * 60 * 60)) / (60 * 60));
1500
- const minutes = Math.floor((differenceInSeconds % (60 * 60)) / 60);
1501
- const seconds = differenceInSeconds % 60;
1502
- // 返回格式化的字符串
1503
- return days
1504
- ? `${days}天${hours}小时${minutes.toString().padStart(2, "0")}分${seconds.toString().padStart(2, "0")}秒`
1505
- : `${hours}小时${minutes.toString().padStart(2, "0")}分${seconds.toString().padStart(2, "0")}秒`;
1491
+ const apiDateTime = luxon_1.DateTime.fromFormat(dateString, "yyyy-MM-dd HH:mm:ss", {
1492
+ zone: "UTC+8",
1493
+ });
1494
+ // 获取当前时间
1495
+ const currentDateTime = luxon_1.DateTime.now();
1496
+ // 计算时间差
1497
+ const diff = currentDateTime.diff(apiDateTime, [
1498
+ "years",
1499
+ "months",
1500
+ "days",
1501
+ "hours",
1502
+ "minutes",
1503
+ "seconds",
1504
+ ]);
1505
+ const { years, months, days, hours, minutes, seconds } = diff.toObject();
1506
+ // 按单位生成可读字符串(过滤零值)
1507
+ const parts = [];
1508
+ if (years !== 0)
1509
+ parts.push(`${Math.abs(years)}年`);
1510
+ if (months !== 0)
1511
+ parts.push(`${Math.abs(months)}个月`);
1512
+ if (days !== 0)
1513
+ parts.push(`${Math.abs(days)}天`);
1514
+ if (hours !== 0)
1515
+ parts.push(`${Math.abs(hours)}小时`);
1516
+ if (minutes !== 0)
1517
+ parts.push(`${Math.abs(minutes)}分`);
1518
+ if (seconds !== 0)
1519
+ parts.push(`${Math.abs(seconds)}秒`);
1520
+ // 处理负值
1521
+ const sign = diff.as("seconds") < 0 ? "" : "-";
1522
+ // 组合结果(如果无差值返回"0秒")
1523
+ return parts.length > 0 ? `${sign}${parts.join("")}` : "0秒";
1506
1524
  }
1507
1525
  unixTimestampToString(timestamp) {
1508
1526
  const date = new Date(timestamp * 1000);
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": "3.0.0-alpha.14",
4
+ "version": "3.0.0-alpha.15",
5
5
  "contributors": [
6
6
  "Akokko <admin@akokko.com>"
7
7
  ],
package/readme.md CHANGED
@@ -226,6 +226,7 @@
226
226
  - ver 3.0.0-alpha.12 修复:上一版本无法安装
227
227
  - ver 3.0.0-alpha.13 优化:将ESLint替换为Biome; 修复:增加弹幕词云功能产生的bug; 禁用:弹幕词云功能并不能正常运作,暂时将该功能禁用
228
228
  - ver 3.0.0-alpha.14 优化:移除不需要的服务
229
+ - ver 3.0.0-alpha.15 修复:启动插件提示发送群组消息失败、直播推送时间显示为负数(不用再特别设置系统时区为UTC+8)
229
230
 
230
231
  ## 交流群
231
232