koishi-plugin-bilibili-notify 3.2.4 → 3.2.5-alpha.0

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
@@ -1,4 +1,4 @@
1
- import { type Context, Schema, Service } from "koishi";
1
+ import { type Awaitable, type Context, Schema, Service } from "koishi";
2
2
  import { type AxiosInstance } from "axios";
3
3
  import { CookieJar } from "tough-cookie";
4
4
  import type { Notifier } from "@koishijs/plugin-notifier";
@@ -12,12 +12,14 @@ declare class BiliAPI extends Service {
12
12
  jar: CookieJar;
13
13
  client: AxiosInstance;
14
14
  apiConfig: BiliAPI.Config;
15
+ cacheable: any;
15
16
  loginData: any;
16
17
  loginNotifier: Notifier;
17
18
  refreshCookieTimer: () => void;
18
19
  loginInfoIsLoaded: boolean;
19
20
  constructor(ctx: Context, config: BiliAPI.Config);
20
- protected start(): void | Promise<void>;
21
+ protected start(): Promise<void>;
22
+ protected stop(): Awaitable<void>;
21
23
  getMixinKey: (orig: string) => string;
22
24
  encWbi(params: {
23
25
  [key: string]: string | number | object;
package/lib/biliAPI.js CHANGED
@@ -1,10 +1,43 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
2
18
  var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
19
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
20
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
21
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
22
  return c > 3 && r && Object.defineProperty(target, key, r), r;
7
23
  };
24
+ var __importStar = (this && this.__importStar) || (function () {
25
+ var ownKeys = function(o) {
26
+ ownKeys = Object.getOwnPropertyNames || function (o) {
27
+ var ar = [];
28
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
29
+ return ar;
30
+ };
31
+ return ownKeys(o);
32
+ };
33
+ return function (mod) {
34
+ if (mod && mod.__esModule) return mod;
35
+ var result = {};
36
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
37
+ __setModuleDefault(result, mod);
38
+ return result;
39
+ };
40
+ })();
8
41
  var __importDefault = (this && this.__importDefault) || function (mod) {
9
42
  return (mod && mod.__esModule) ? mod : { "default": mod };
10
43
  };
@@ -12,6 +45,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
12
45
  const koishi_1 = require("koishi");
13
46
  const md5_1 = __importDefault(require("md5"));
14
47
  const node_crypto_1 = __importDefault(require("node:crypto"));
48
+ const node_http_1 = __importDefault(require("node:http"));
49
+ const node_https_1 = __importDefault(require("node:https"));
15
50
  const axios_1 = __importDefault(require("axios"));
16
51
  const tough_cookie_1 = require("tough-cookie");
17
52
  const axios_cookiejar_support_1 = require("axios-cookiejar-support");
@@ -55,6 +90,8 @@ class BiliAPI extends koishi_1.Service {
55
90
  client;
56
91
  apiConfig;
57
92
  // biome-ignore lint/suspicious/noExplicitAny: <explanation>
93
+ cacheable;
94
+ // biome-ignore lint/suspicious/noExplicitAny: <explanation>
58
95
  loginData;
59
96
  loginNotifier;
60
97
  refreshCookieTimer;
@@ -63,12 +100,24 @@ class BiliAPI extends koishi_1.Service {
63
100
  super(ctx, "ba");
64
101
  this.apiConfig = config;
65
102
  }
66
- start() {
103
+ async start() {
104
+ // 导入dns缓存
105
+ const CacheableLookup = (await Promise.resolve().then(() => __importStar(require("cacheable-lookup")))).default;
106
+ // 注册dns缓存
107
+ this.cacheable = new CacheableLookup();
108
+ // 安装缓存
109
+ this.cacheable.install(node_http_1.default.globalAgent);
110
+ this.cacheable.install(node_https_1.default.globalAgent);
67
111
  // 创建新的http客户端(axios)
68
112
  this.createNewClient();
69
113
  // 从数据库加载cookies
70
114
  this.loadCookiesFromDatabase();
71
115
  }
116
+ stop() {
117
+ // 卸载dns缓存
118
+ this.cacheable.uninstall(node_http_1.default.globalAgent);
119
+ this.cacheable.uninstall(node_https_1.default.globalAgent);
120
+ }
72
121
  // WBI签名
73
122
  // 对 imgKey 和 subKey 进行字符顺序打乱编码
74
123
  getMixinKey = (orig) => mixinKeyEncTab
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.2.4",
4
+ "version": "3.2.5-alpha.0",
5
5
  "contributors": [
6
6
  "Akokko <admin@akokko.com>"
7
7
  ],
@@ -31,15 +31,16 @@
31
31
  "bilibili"
32
32
  ],
33
33
  "peerDependencies": {
34
- "koishi": "^4.18.7"
34
+ "koishi": "^4.18.8"
35
35
  },
36
36
  "dependencies": {
37
37
  "@akokko/blive-message-listener": "^0.5.1",
38
- "axios": "^1.7.9",
38
+ "axios": "^1.9.0",
39
39
  "axios-cookiejar-support": "^5.0.5",
40
- "cron": "^4.3.0",
40
+ "cacheable-lookup": "^7.0.0",
41
+ "cron": "^4.3.1",
41
42
  "jsdom": "^24.1.3",
42
- "luxon": "^3.5.0",
43
+ "luxon": "^3.6.1",
43
44
  "md5": "^2.3.0",
44
45
  "qrcode": "^1.5.4",
45
46
  "tough-cookie": "^4.1.4"
@@ -47,22 +48,23 @@
47
48
  "devDependencies": {
48
49
  "@biomejs/biome": "1.9.4",
49
50
  "@koishijs/cache": "^2.1.0",
50
- "@koishijs/client": "^5.30.7",
51
+ "@koishijs/client": "^5.30.8",
51
52
  "@koishijs/plugin-help": "^2.4.5",
52
53
  "@koishijs/plugin-hmr": "^1.2.9",
53
54
  "@koishijs/plugin-notifier": "^1.2.1",
54
55
  "@koishijs/scripts": "^4.6.1",
55
- "@types/luxon": "^3.4.2",
56
+ "@types/jsdom": "^21.1.7",
57
+ "@types/luxon": "^3.6.2",
56
58
  "@types/md5": "^2.3.5",
57
59
  "@types/qrcode": "^1.5.5",
58
60
  "@types/tough-cookie": "^4.0.5",
59
61
  "esbuild": "^0.25.5",
60
62
  "esbuild-register": "^3.6.0",
61
- "globals": "^15.14.0",
63
+ "globals": "^15.15.0",
62
64
  "koishi": "^4.18.8",
63
65
  "koishi-plugin-puppeteer": "^3.9.0",
64
66
  "tsx": "^4.19.4",
65
- "typescript": "^5.8.3",
67
+ "typescript": "^5.9.0-dev.20250603",
66
68
  "yakumo": "^1.0.0",
67
69
  "yakumo-esbuild": "^1.0.0",
68
70
  "yakumo-tsc": "^1.0.0",
package/readme.md CHANGED
@@ -16,8 +16,8 @@
16
16
  - [License](#License)
17
17
 
18
18
  ## 重新订阅
19
-
20
- 由于版本 `2.0.0-alpha.7` 重构了订阅功能,从 `2.0.0-alpha.7` 以前版本升级到以后版本的需重新订阅
19
+ > [!important]
20
+ >由于版本 `2.0.0-alpha.7` 重构了订阅功能,从 `2.0.0-alpha.7` 以前版本升级到以后版本的需重新订阅
21
21
 
22
22
  ## 功能
23
23
 
@@ -270,6 +270,7 @@ uid为必填参数,为要推送的UP主的UID,index为可选参数,为要
270
270
  - ver 3.2.3 优化:移除不必要的代码;
271
271
  - ver 3.2.4-alpha.0 优化:选项 `pushImgsInDynamic` 发送多图会以转发消息的格式发送; 新增:选项 `dynamicVideoUrlToBV` 开启后将链接转换为bv号以用作特殊用途;
272
272
  - ver 3.2.4 修复:第一次使用插件时,使用登录指令报错; 插件配置页新增和删除提示信息;
273
+ - ver 3.2.5 优化:新增 `DNS` 缓存,以减少DNS错误;
273
274
 
274
275
  ## 交流群
275
276