koishi-plugin-bilibili-notify 3.2.1-alpha.1 → 3.2.1-alpha.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 +2 -2
- package/lib/biliAPI.js +100 -56
- package/lib/blive.js +7 -5
- package/lib/comRegister.js +133 -143
- package/lib/database.js +6 -2
- package/lib/generateImg.js +33 -31
- package/lib/index.js +131 -91
- package/lib/type/index.js +7 -4
- package/lib/utils/index.js +8 -3
- package/package.json +1 -1
- package/readme.md +3 -1
package/lib/biliAPI.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { type Awaitable, type Context, Schema, Service } from "koishi";
|
|
2
|
-
import CacheableLookup from "cacheable-lookup";
|
|
3
2
|
import { type AxiosInstance } from "axios";
|
|
4
3
|
import { CookieJar } from "tough-cookie";
|
|
5
4
|
import type { Notifier } from "@koishijs/plugin-notifier";
|
|
@@ -12,7 +11,7 @@ declare class BiliAPI extends Service {
|
|
|
12
11
|
static inject: string[];
|
|
13
12
|
jar: CookieJar;
|
|
14
13
|
client: AxiosInstance;
|
|
15
|
-
cacheable:
|
|
14
|
+
cacheable: any;
|
|
16
15
|
apiConfig: BiliAPI.Config;
|
|
17
16
|
loginData: any;
|
|
18
17
|
loginNotifier: Notifier;
|
|
@@ -21,6 +20,7 @@ declare class BiliAPI extends Service {
|
|
|
21
20
|
constructor(ctx: Context, config: BiliAPI.Config);
|
|
22
21
|
protected start(): void | Promise<void>;
|
|
23
22
|
protected stop(): Awaitable<void>;
|
|
23
|
+
init(): Promise<void>;
|
|
24
24
|
getMixinKey: (orig: string) => string;
|
|
25
25
|
encWbi(params: {
|
|
26
26
|
[key: string]: string | number | object;
|
package/lib/biliAPI.js
CHANGED
|
@@ -1,20 +1,57 @@
|
|
|
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
|
+
});
|
|
1
18
|
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
19
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
20
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
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;
|
|
5
22
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
23
|
};
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
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
|
+
})();
|
|
41
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
42
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
43
|
+
};
|
|
44
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
45
|
+
const koishi_1 = require("koishi");
|
|
46
|
+
const md5_1 = __importDefault(require("md5"));
|
|
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"));
|
|
50
|
+
const axios_1 = __importDefault(require("axios"));
|
|
51
|
+
const tough_cookie_1 = require("tough-cookie");
|
|
52
|
+
const axios_cookiejar_support_1 = require("axios-cookiejar-support");
|
|
53
|
+
const jsdom_1 = require("jsdom");
|
|
54
|
+
const utils_1 = require("./utils");
|
|
18
55
|
const mixinKeyEncTab = [
|
|
19
56
|
46, 47, 18, 2, 53, 8, 23, 32, 15, 50, 10, 31, 58, 3, 45, 35, 27, 43, 5, 49,
|
|
20
57
|
33, 9, 42, 19, 29, 28, 14, 39, 12, 38, 41, 13, 37, 48, 7, 16, 24, 55, 40, 61,
|
|
@@ -47,10 +84,11 @@ const GET_RELATION_GROUP_DETAIL = "https://api.bilibili.com/x/relation/tag";
|
|
|
47
84
|
// 直播
|
|
48
85
|
const GET_LIVE_ROOM_INFO_STREAM_KEY = "https://api.live.bilibili.com/xlive/web-room/v1/index/getDanmuInfo";
|
|
49
86
|
const GET_LIVE_ROOMS_INFO = "https://api.live.bilibili.com/room/v1/Room/get_status_info_by_uids";
|
|
50
|
-
class BiliAPI extends Service {
|
|
87
|
+
class BiliAPI extends koishi_1.Service {
|
|
51
88
|
static inject = ["database", "notifier"];
|
|
52
89
|
jar;
|
|
53
90
|
client;
|
|
91
|
+
// biome-ignore lint/suspicious/noExplicitAny: <explanation>
|
|
54
92
|
cacheable;
|
|
55
93
|
apiConfig;
|
|
56
94
|
// biome-ignore lint/suspicious/noExplicitAny: <explanation>
|
|
@@ -63,6 +101,8 @@ class BiliAPI extends Service {
|
|
|
63
101
|
this.apiConfig = config;
|
|
64
102
|
}
|
|
65
103
|
start() {
|
|
104
|
+
// init
|
|
105
|
+
this.init();
|
|
66
106
|
// 创建新的http客户端(axios)
|
|
67
107
|
this.createNewClient();
|
|
68
108
|
// 从数据库加载cookies
|
|
@@ -70,8 +110,17 @@ class BiliAPI extends Service {
|
|
|
70
110
|
}
|
|
71
111
|
stop() {
|
|
72
112
|
// 将DNS缓存卸载
|
|
73
|
-
this.cacheable.uninstall(
|
|
74
|
-
this.cacheable.uninstall(
|
|
113
|
+
this.cacheable.uninstall(node_http_1.default.globalAgent);
|
|
114
|
+
this.cacheable.uninstall(node_https_1.default.globalAgent);
|
|
115
|
+
}
|
|
116
|
+
async init() {
|
|
117
|
+
// 导入纯ESM模块Cacheable
|
|
118
|
+
const { default: CacheableLookup } = await Promise.resolve().then(() => __importStar(require("cacheable-lookup")));
|
|
119
|
+
// 创建Cacheable
|
|
120
|
+
this.cacheable = new CacheableLookup();
|
|
121
|
+
// 安装到http和https
|
|
122
|
+
this.cacheable.install(node_http_1.default.globalAgent);
|
|
123
|
+
this.cacheable.install(node_https_1.default.globalAgent);
|
|
75
124
|
}
|
|
76
125
|
// WBI签名
|
|
77
126
|
// 对 imgKey 和 subKey 进行字符顺序打乱编码
|
|
@@ -94,7 +143,7 @@ class BiliAPI extends Service {
|
|
|
94
143
|
return `${encodeURIComponent(key)}=${encodeURIComponent(value)}`;
|
|
95
144
|
})
|
|
96
145
|
.join("&");
|
|
97
|
-
const wbi_sign =
|
|
146
|
+
const wbi_sign = (0, md5_1.default)(query + mixin_key); // 计算 w_rid
|
|
98
147
|
return `${query}&w_rid=${wbi_sign}`;
|
|
99
148
|
}
|
|
100
149
|
async getWbi(params) {
|
|
@@ -105,8 +154,8 @@ class BiliAPI extends Service {
|
|
|
105
154
|
return query;
|
|
106
155
|
}
|
|
107
156
|
encrypt(text) {
|
|
108
|
-
const iv =
|
|
109
|
-
const cipher =
|
|
157
|
+
const iv = node_crypto_1.default.randomBytes(16);
|
|
158
|
+
const cipher = node_crypto_1.default.createCipheriv("aes-256-cbc", Buffer.from(this.apiConfig.key), iv);
|
|
110
159
|
const encrypted = Buffer.concat([cipher.update(text), cipher.final()]);
|
|
111
160
|
return `${iv.toString("hex")}:${encrypted.toString("hex")}`;
|
|
112
161
|
}
|
|
@@ -114,7 +163,7 @@ class BiliAPI extends Service {
|
|
|
114
163
|
const textParts = text.split(":");
|
|
115
164
|
const iv = Buffer.from(textParts.shift(), "hex");
|
|
116
165
|
const encryptedText = Buffer.from(textParts.join(":"), "hex");
|
|
117
|
-
const decipher =
|
|
166
|
+
const decipher = node_crypto_1.default.createDecipheriv("aes-256-cbc", Buffer.from(this.apiConfig.key), iv);
|
|
118
167
|
const decrypted = Buffer.concat([
|
|
119
168
|
decipher.update(encryptedText),
|
|
120
169
|
decipher.final(),
|
|
@@ -290,15 +339,10 @@ class BiliAPI extends Service {
|
|
|
290
339
|
return userAgents[index];
|
|
291
340
|
}
|
|
292
341
|
createNewClient() {
|
|
293
|
-
// 创建DNS缓存
|
|
294
|
-
this.cacheable = new CacheableLookup();
|
|
295
|
-
// 安装到http和https
|
|
296
|
-
this.cacheable.install(http.globalAgent);
|
|
297
|
-
this.cacheable.install(https.globalAgent);
|
|
298
342
|
// 创建cookieJar
|
|
299
|
-
this.jar = new CookieJar();
|
|
343
|
+
this.jar = new tough_cookie_1.CookieJar();
|
|
300
344
|
// 包装cookieJar
|
|
301
|
-
this.client = wrapper(
|
|
345
|
+
this.client = (0, axios_cookiejar_support_1.wrapper)(axios_1.default.create({
|
|
302
346
|
jar: this.jar,
|
|
303
347
|
headers: {
|
|
304
348
|
"Content-Type": "application/json",
|
|
@@ -414,7 +458,7 @@ class BiliAPI extends Service {
|
|
|
414
458
|
sameSite = cookieData.sameSite;
|
|
415
459
|
}
|
|
416
460
|
// 创建一个完整的 Cookie 实例
|
|
417
|
-
const cookie = new Cookie({
|
|
461
|
+
const cookie = new tough_cookie_1.Cookie({
|
|
418
462
|
key: cookieData.key,
|
|
419
463
|
value: cookieData.value,
|
|
420
464
|
expires: new Date(cookieData.expires),
|
|
@@ -427,7 +471,7 @@ class BiliAPI extends Service {
|
|
|
427
471
|
this.jar.setCookieSync(cookie, `http${cookie.secure ? "s" : ""}://${cookie.domain}${cookie.path}`, {});
|
|
428
472
|
}
|
|
429
473
|
// 对于某些 IP 地址,需要在 Cookie 中提供任意非空的 buvid3 字段
|
|
430
|
-
const buvid3Cookie = new Cookie({
|
|
474
|
+
const buvid3Cookie = new tough_cookie_1.Cookie({
|
|
431
475
|
key: "buvid3",
|
|
432
476
|
value: "some_non_empty_value", // 设置任意非空值
|
|
433
477
|
expires, // 设置过期时间
|
|
@@ -500,7 +544,7 @@ class BiliAPI extends Service {
|
|
|
500
544
|
// 如果请求失败,有可能是404,直接刷新cookie
|
|
501
545
|
}
|
|
502
546
|
// 定义Key
|
|
503
|
-
const publicKey = await
|
|
547
|
+
const publicKey = await node_crypto_1.default.subtle.importKey("jwk", {
|
|
504
548
|
kty: "RSA",
|
|
505
549
|
n: "y4HdjgJHBlbaBN04VERG4qNBIFHP6a3GozCl75AihQloSWCXC5HDNgyinEnhaQ_4-gaMud_GF50elYXLlCToR9se9Z8z433U3KjM-3Yx7ptKkmQNAMggQwAVKgq3zYAoidNEWuxpkY_mAitTSRLnsJW-NCTa0bqBFF6Wm1MxgfE",
|
|
506
550
|
e: "AQAB",
|
|
@@ -508,7 +552,7 @@ class BiliAPI extends Service {
|
|
|
508
552
|
// 定义获取CorrespondPath方法
|
|
509
553
|
async function getCorrespondPath(timestamp) {
|
|
510
554
|
const data = new TextEncoder().encode(`refresh_${timestamp}`);
|
|
511
|
-
const encrypted = new Uint8Array(await
|
|
555
|
+
const encrypted = new Uint8Array(await node_crypto_1.default.subtle.encrypt({ name: "RSA-OAEP" }, publicKey, data));
|
|
512
556
|
return encrypted.reduce((str, c) => str + c.toString(16).padStart(2, "0"), "");
|
|
513
557
|
}
|
|
514
558
|
// 获取CorrespondPath
|
|
@@ -517,7 +561,7 @@ class BiliAPI extends Service {
|
|
|
517
561
|
// 获取refresh_csrf
|
|
518
562
|
const { data: refreshCsrfHtml } = await this.client.get(`https://www.bilibili.com/correspond/1/${correspondPath}`);
|
|
519
563
|
// 创建一个虚拟的DOM元素
|
|
520
|
-
const { document } = new JSDOM(refreshCsrfHtml).window;
|
|
564
|
+
const { document } = new jsdom_1.JSDOM(refreshCsrfHtml).window;
|
|
521
565
|
// 提取标签name为1-name的内容
|
|
522
566
|
const targetElement = document.getElementById("1-name");
|
|
523
567
|
const refresh_csrf = targetElement ? targetElement.textContent : null;
|
|
@@ -585,7 +629,7 @@ class BiliAPI extends Service {
|
|
|
585
629
|
}
|
|
586
630
|
}
|
|
587
631
|
__decorate([
|
|
588
|
-
Retry({
|
|
632
|
+
(0, utils_1.Retry)({
|
|
589
633
|
attempts: 3,
|
|
590
634
|
onFailure(error, attempts) {
|
|
591
635
|
this.logger.error(`getTheUserWhoIsLiveStreaming() 第${attempts}次失败: ${error.message}`);
|
|
@@ -593,7 +637,7 @@ __decorate([
|
|
|
593
637
|
})
|
|
594
638
|
], BiliAPI.prototype, "getTheUserWhoIsLiveStreaming", null);
|
|
595
639
|
__decorate([
|
|
596
|
-
Retry({
|
|
640
|
+
(0, utils_1.Retry)({
|
|
597
641
|
attempts: 3,
|
|
598
642
|
onFailure(error, attempts) {
|
|
599
643
|
this.logger.error(`getLiveRoomInfoStreamKey() 第${attempts}次失败: ${error.message}`);
|
|
@@ -601,7 +645,7 @@ __decorate([
|
|
|
601
645
|
})
|
|
602
646
|
], BiliAPI.prototype, "getLiveRoomInfoStreamKey", null);
|
|
603
647
|
__decorate([
|
|
604
|
-
Retry({
|
|
648
|
+
(0, utils_1.Retry)({
|
|
605
649
|
attempts: 3,
|
|
606
650
|
onFailure(error, attempts) {
|
|
607
651
|
this.logger.error(`getLiveRoomInfoByUids() 第${attempts}次失败: ${error.message}`);
|
|
@@ -609,7 +653,7 @@ __decorate([
|
|
|
609
653
|
})
|
|
610
654
|
], BiliAPI.prototype, "getLiveRoomInfoByUids", null);
|
|
611
655
|
__decorate([
|
|
612
|
-
Retry({
|
|
656
|
+
(0, utils_1.Retry)({
|
|
613
657
|
attempts: 3,
|
|
614
658
|
onFailure(error, attempts) {
|
|
615
659
|
this.logger.error(`getServerUTCTime() 第${attempts}次失败: ${error.message}`);
|
|
@@ -617,7 +661,7 @@ __decorate([
|
|
|
617
661
|
})
|
|
618
662
|
], BiliAPI.prototype, "getServerUTCTime", null);
|
|
619
663
|
__decorate([
|
|
620
|
-
Retry({
|
|
664
|
+
(0, utils_1.Retry)({
|
|
621
665
|
attempts: 3,
|
|
622
666
|
onFailure(error, attempts) {
|
|
623
667
|
this.logger.error(`getTimeNow() 第${attempts}次失败: ${error.message}`);
|
|
@@ -625,7 +669,7 @@ __decorate([
|
|
|
625
669
|
})
|
|
626
670
|
], BiliAPI.prototype, "getTimeNow", null);
|
|
627
671
|
__decorate([
|
|
628
|
-
Retry({
|
|
672
|
+
(0, utils_1.Retry)({
|
|
629
673
|
attempts: 3,
|
|
630
674
|
onFailure(error, attempts) {
|
|
631
675
|
this.logger.error(`getAllGroup() 第${attempts}次失败: ${error.message}`);
|
|
@@ -633,7 +677,7 @@ __decorate([
|
|
|
633
677
|
})
|
|
634
678
|
], BiliAPI.prototype, "getAllGroup", null);
|
|
635
679
|
__decorate([
|
|
636
|
-
Retry({
|
|
680
|
+
(0, utils_1.Retry)({
|
|
637
681
|
attempts: 3,
|
|
638
682
|
onFailure(error, attempts) {
|
|
639
683
|
this.logger.error(`removeUserFromGroup() 第${attempts}次失败: ${error.message}`);
|
|
@@ -641,7 +685,7 @@ __decorate([
|
|
|
641
685
|
})
|
|
642
686
|
], BiliAPI.prototype, "removeUserFromGroup", null);
|
|
643
687
|
__decorate([
|
|
644
|
-
Retry({
|
|
688
|
+
(0, utils_1.Retry)({
|
|
645
689
|
attempts: 3,
|
|
646
690
|
onFailure(error, attempts) {
|
|
647
691
|
this.logger.error(`copyUserToGroup() 第${attempts}次失败: ${error.message}`);
|
|
@@ -649,7 +693,7 @@ __decorate([
|
|
|
649
693
|
})
|
|
650
694
|
], BiliAPI.prototype, "copyUserToGroup", null);
|
|
651
695
|
__decorate([
|
|
652
|
-
Retry({
|
|
696
|
+
(0, utils_1.Retry)({
|
|
653
697
|
attempts: 3,
|
|
654
698
|
onFailure(error, attempts) {
|
|
655
699
|
this.logger.error(`getUserSpaceDynamic() 第${attempts}次失败: ${error.message}`);
|
|
@@ -657,7 +701,7 @@ __decorate([
|
|
|
657
701
|
})
|
|
658
702
|
], BiliAPI.prototype, "getUserSpaceDynamic", null);
|
|
659
703
|
__decorate([
|
|
660
|
-
Retry({
|
|
704
|
+
(0, utils_1.Retry)({
|
|
661
705
|
attempts: 3,
|
|
662
706
|
onFailure(error, attempts) {
|
|
663
707
|
this.logger.error(`createGroup() 第${attempts}次失败: ${error.message}`);
|
|
@@ -665,7 +709,7 @@ __decorate([
|
|
|
665
709
|
})
|
|
666
710
|
], BiliAPI.prototype, "createGroup", null);
|
|
667
711
|
__decorate([
|
|
668
|
-
Retry({
|
|
712
|
+
(0, utils_1.Retry)({
|
|
669
713
|
attempts: 3,
|
|
670
714
|
onFailure(error, attempts) {
|
|
671
715
|
this.logger.error(`getAllDynamic() 第${attempts}次失败: ${error.message}`);
|
|
@@ -673,7 +717,7 @@ __decorate([
|
|
|
673
717
|
})
|
|
674
718
|
], BiliAPI.prototype, "getAllDynamic", null);
|
|
675
719
|
__decorate([
|
|
676
|
-
Retry({
|
|
720
|
+
(0, utils_1.Retry)({
|
|
677
721
|
attempts: 3,
|
|
678
722
|
onFailure(error, attempts) {
|
|
679
723
|
this.logger.error(`hasNewDynamic() 第${attempts}次失败: ${error.message}`);
|
|
@@ -681,7 +725,7 @@ __decorate([
|
|
|
681
725
|
})
|
|
682
726
|
], BiliAPI.prototype, "hasNewDynamic", null);
|
|
683
727
|
__decorate([
|
|
684
|
-
Retry({
|
|
728
|
+
(0, utils_1.Retry)({
|
|
685
729
|
attempts: 3,
|
|
686
730
|
onFailure(error, attempts) {
|
|
687
731
|
this.logger.error(`follow() 第${attempts}次失败: ${error.message}`);
|
|
@@ -689,7 +733,7 @@ __decorate([
|
|
|
689
733
|
})
|
|
690
734
|
], BiliAPI.prototype, "follow", null);
|
|
691
735
|
__decorate([
|
|
692
|
-
Retry({
|
|
736
|
+
(0, utils_1.Retry)({
|
|
693
737
|
attempts: 3,
|
|
694
738
|
onFailure(error, attempts) {
|
|
695
739
|
this.logger.error(`getRelationGroupDetail() 第${attempts}次失败: ${error.message}`);
|
|
@@ -697,7 +741,7 @@ __decorate([
|
|
|
697
741
|
})
|
|
698
742
|
], BiliAPI.prototype, "getRelationGroupDetail", null);
|
|
699
743
|
__decorate([
|
|
700
|
-
Retry({
|
|
744
|
+
(0, utils_1.Retry)({
|
|
701
745
|
attempts: 3,
|
|
702
746
|
onFailure(error, attempts) {
|
|
703
747
|
this.logger.error(`getCookieInfo() 第${attempts}次失败: ${error.message}`);
|
|
@@ -705,7 +749,7 @@ __decorate([
|
|
|
705
749
|
})
|
|
706
750
|
], BiliAPI.prototype, "getCookieInfo", null);
|
|
707
751
|
__decorate([
|
|
708
|
-
Retry({
|
|
752
|
+
(0, utils_1.Retry)({
|
|
709
753
|
attempts: 3,
|
|
710
754
|
onFailure(error, attempts) {
|
|
711
755
|
this.logger.error(`getUserInfo() 第${attempts}次失败: ${error.message}`);
|
|
@@ -713,7 +757,7 @@ __decorate([
|
|
|
713
757
|
})
|
|
714
758
|
], BiliAPI.prototype, "getUserInfo", null);
|
|
715
759
|
__decorate([
|
|
716
|
-
Retry({
|
|
760
|
+
(0, utils_1.Retry)({
|
|
717
761
|
attempts: 3,
|
|
718
762
|
onFailure(error, attempts) {
|
|
719
763
|
this.logger.error(`getWbiKeys() 第${attempts}次失败: ${error.message}`);
|
|
@@ -721,7 +765,7 @@ __decorate([
|
|
|
721
765
|
})
|
|
722
766
|
], BiliAPI.prototype, "getWbiKeys", null);
|
|
723
767
|
__decorate([
|
|
724
|
-
Retry({
|
|
768
|
+
(0, utils_1.Retry)({
|
|
725
769
|
attempts: 3,
|
|
726
770
|
onFailure(error, attempts) {
|
|
727
771
|
this.logger.error(`getMyselfInfo() 第${attempts}次失败: ${error.message}`);
|
|
@@ -729,7 +773,7 @@ __decorate([
|
|
|
729
773
|
})
|
|
730
774
|
], BiliAPI.prototype, "getMyselfInfo", null);
|
|
731
775
|
__decorate([
|
|
732
|
-
Retry({
|
|
776
|
+
(0, utils_1.Retry)({
|
|
733
777
|
attempts: 3,
|
|
734
778
|
onFailure(error, attempts) {
|
|
735
779
|
this.logger.error(`getLoginQRCode() 第${attempts}次失败: ${error.message}`);
|
|
@@ -737,7 +781,7 @@ __decorate([
|
|
|
737
781
|
})
|
|
738
782
|
], BiliAPI.prototype, "getLoginQRCode", null);
|
|
739
783
|
__decorate([
|
|
740
|
-
Retry({
|
|
784
|
+
(0, utils_1.Retry)({
|
|
741
785
|
attempts: 3,
|
|
742
786
|
onFailure(error, attempts) {
|
|
743
787
|
this.logger.error(`getLoginStatus() 第${attempts}次失败: ${error.message}`);
|
|
@@ -745,7 +789,7 @@ __decorate([
|
|
|
745
789
|
})
|
|
746
790
|
], BiliAPI.prototype, "getLoginStatus", null);
|
|
747
791
|
__decorate([
|
|
748
|
-
Retry({
|
|
792
|
+
(0, utils_1.Retry)({
|
|
749
793
|
attempts: 3,
|
|
750
794
|
onFailure(error, attempts) {
|
|
751
795
|
this.logger.error(`getLiveRoomInfo() 第${attempts}次失败: ${error.message}`);
|
|
@@ -753,7 +797,7 @@ __decorate([
|
|
|
753
797
|
})
|
|
754
798
|
], BiliAPI.prototype, "getLiveRoomInfo", null);
|
|
755
799
|
__decorate([
|
|
756
|
-
Retry({
|
|
800
|
+
(0, utils_1.Retry)({
|
|
757
801
|
attempts: 3,
|
|
758
802
|
onFailure(error, attempts) {
|
|
759
803
|
this.logger.error(`getMasterInfo() 第${attempts}次失败: ${error.message}`);
|
|
@@ -761,11 +805,11 @@ __decorate([
|
|
|
761
805
|
})
|
|
762
806
|
], BiliAPI.prototype, "getMasterInfo", null);
|
|
763
807
|
(function (BiliAPI) {
|
|
764
|
-
BiliAPI.Config = Schema.object({
|
|
765
|
-
userAgent: Schema.string(),
|
|
766
|
-
key: Schema.string()
|
|
808
|
+
BiliAPI.Config = koishi_1.Schema.object({
|
|
809
|
+
userAgent: koishi_1.Schema.string(),
|
|
810
|
+
key: koishi_1.Schema.string()
|
|
767
811
|
.pattern(/^[0-9a-f]{32}$/)
|
|
768
812
|
.required(),
|
|
769
813
|
});
|
|
770
814
|
})(BiliAPI || (BiliAPI = {}));
|
|
771
|
-
|
|
815
|
+
exports.default = BiliAPI;
|
package/lib/blive.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const koishi_1 = require("koishi");
|
|
4
|
+
const blive_message_listener_1 = require("blive-message-listener");
|
|
5
|
+
class BLive extends koishi_1.Service {
|
|
4
6
|
// 必要服务
|
|
5
7
|
static inject = ["ba"];
|
|
6
8
|
// 定义类属性
|
|
@@ -22,7 +24,7 @@ class BLive extends Service {
|
|
|
22
24
|
// 获取自身信息
|
|
23
25
|
const mySelfInfo = await this.ctx.ba.getMyselfInfo();
|
|
24
26
|
// 创建实例并保存到Record中
|
|
25
|
-
this.listenerRecord[roomId] = startListen(Number.parseInt(roomId), handler, {
|
|
27
|
+
this.listenerRecord[roomId] = (0, blive_message_listener_1.startListen)(Number.parseInt(roomId), handler, {
|
|
26
28
|
ws: {
|
|
27
29
|
headers: {
|
|
28
30
|
Cookie: cookiesStr,
|
|
@@ -53,4 +55,4 @@ class BLive extends Service {
|
|
|
53
55
|
this.logger.warn(`${roomId}直播间弹幕监听未成功关闭`);
|
|
54
56
|
}
|
|
55
57
|
}
|
|
56
|
-
|
|
58
|
+
exports.default = BLive;
|