koishi-plugin-bilibili-notify 3.0.0-alpha.13 → 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;
@@ -7,6 +7,9 @@ const jsx_runtime_1 = require("@satorijs/element/jsx-runtime");
7
7
  const koishi_1 = require("koishi");
8
8
  // 导入qrcode
9
9
  const qrcode_1 = __importDefault(require("qrcode"));
10
+ // 弹幕词云
11
+ // TODO:WorlCloud
12
+ // import { Segment } from "segmentit";
10
13
  var LiveType;
11
14
  (function (LiveType) {
12
15
  LiveType[LiveType["NotLiveBroadcast"] = 0] = "NotLiveBroadcast";
@@ -16,7 +19,7 @@ var LiveType;
16
19
  })(LiveType || (LiveType = {}));
17
20
  class ComRegister {
18
21
  // 必须服务
19
- static inject = ["ba", "gi", "database", "canvas", "bl", "sm"];
22
+ static inject = ["ba", "gi", "database", "bl", "sm"];
20
23
  // 定义数组:QQ相关bot
21
24
  qqRelatedBotList = [
22
25
  "qq",
@@ -692,8 +695,8 @@ class ComRegister {
692
695
  this.checkIfDynamicDetectIsNeeded();
693
696
  // 在控制台中显示订阅对象
694
697
  this.updateSubNotifier();
695
- // Test
696
- const testTarget = [
698
+ /* // Test
699
+ const testTarget: Target = [
697
700
  {
698
701
  channelIdArr: [
699
702
  {
@@ -707,8 +710,9 @@ class ComRegister {
707
710
  platform: "qqguild",
708
711
  },
709
712
  ];
713
+
710
714
  const buffer = await this.ctx.gi.generateWordCloudImg();
711
- this.sendMsg(testTarget, koishi_1.h.image(buffer, "image/png"));
715
+ this.sendMsg(testTarget, h.image(buffer, "image/png")); */
712
716
  }
713
717
  splitMultiPlatformStr(str) {
714
718
  return str
package/lib/database.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { Context } from "koishi";
2
- declare module 'koishi' {
1
+ import type { Context } from "koishi";
2
+ declare module "koishi" {
3
3
  interface Tables {
4
4
  bilibili: Bilibili;
5
5
  loginBili: LoginBili;
package/lib/database.js CHANGED
@@ -2,24 +2,24 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.name = void 0;
4
4
  exports.apply = apply;
5
- exports.name = 'Database';
5
+ exports.name = "Database";
6
6
  function apply(ctx) {
7
7
  // 新增Bilibili表
8
- ctx.model.extend('bilibili', {
9
- id: 'unsigned',
10
- uid: 'string',
11
- room_id: 'string',
12
- dynamic: 'unsigned',
13
- live: 'unsigned',
14
- target: 'string',
15
- platform: 'string',
16
- time: 'timestamp'
8
+ ctx.model.extend("bilibili", {
9
+ id: "unsigned",
10
+ uid: "string",
11
+ room_id: "string",
12
+ dynamic: "unsigned",
13
+ live: "unsigned",
14
+ target: "string",
15
+ platform: "string",
16
+ time: "timestamp",
17
17
  }, { autoInc: true });
18
18
  // 新增LoginBili表
19
- ctx.model.extend('loginBili', {
20
- id: 'unsigned',
21
- bili_cookies: 'text',
22
- bili_refresh_token: 'text',
23
- dynamic_group_id: 'string'
19
+ ctx.model.extend("loginBili", {
20
+ id: "unsigned",
21
+ bili_cookies: "text",
22
+ bili_refresh_token: "text",
23
+ dynamic_group_id: "string",
24
24
  });
25
25
  }
@@ -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/lib/index.js CHANGED
@@ -46,7 +46,7 @@ const Database = __importStar(require("./database"));
46
46
  const generateImg_1 = __importDefault(require("./generateImg"));
47
47
  const biliAPI_1 = __importDefault(require("./biliAPI"));
48
48
  const blive_1 = __importDefault(require("./blive"));
49
- exports.inject = ["puppeteer", "canvas", "database", "notifier"];
49
+ exports.inject = ["puppeteer", "database", "notifier"];
50
50
  exports.name = "bilibili-notify";
51
51
  let globalConfig;
52
52
  class ServerManager extends koishi_1.Service {
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.13",
4
+ "version": "3.0.0-alpha.15",
5
5
  "contributors": [
6
6
  "Akokko <admin@akokko.com>"
7
7
  ],
package/readme.md CHANGED
@@ -224,7 +224,9 @@
224
224
  - ver 3.0.0-alpha.10 修复:连续推送两次开播通知
225
225
  - ver 3.0.0-alpha.11 新增:直播结束后推送弹幕词云,直播推送上舰消息; 修复:直播推送都是同一张画面; 移除:直播推送弹幕消息
226
226
  - ver 3.0.0-alpha.12 修复:上一版本无法安装
227
- - ver 3.0.0-alpha.13 优化:将ESLint替换为Biome; 修复:增加弹幕词云功能产生的bug; 禁用:弹幕词云功能并不难正常运作,暂时将该功能禁用
227
+ - ver 3.0.0-alpha.13 优化:将ESLint替换为Biome; 修复:增加弹幕词云功能产生的bug; 禁用:弹幕词云功能并不能正常运作,暂时将该功能禁用
228
+ - ver 3.0.0-alpha.14 优化:移除不需要的服务
229
+ - ver 3.0.0-alpha.15 修复:启动插件提示发送群组消息失败、直播推送时间显示为负数(不用再特别设置系统时区为UTC+8)
228
230
 
229
231
  ## 交流群
230
232