koishi-plugin-bilibili-notify 3.2.1-alpha.10 → 3.2.1-alpha.11
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 +5 -3
- package/lib/biliAPI.js +58 -52
- package/lib/blive.js +5 -7
- package/lib/comRegister.js +116 -121
- package/lib/database.js +2 -6
- package/lib/generateImg.js +31 -33
- package/lib/index.js +91 -131
- package/lib/type/index.js +4 -7
- package/lib/utils/index.js +3 -8
- package/package.json +12 -8
- package/readme.md +1 -0
package/lib/biliAPI.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { type Context, Schema, Service } from "koishi";
|
|
1
|
+
import { type Awaitable, type Context, Schema, Service } from "koishi";
|
|
2
|
+
import CacheableLookup from "cacheable-lookup";
|
|
2
3
|
import { type AxiosInstance } from "axios";
|
|
3
4
|
import { CookieJar } from "tough-cookie";
|
|
4
5
|
import type { Notifier } from "@koishijs/plugin-notifier";
|
|
@@ -11,7 +12,7 @@ declare class BiliAPI extends Service {
|
|
|
11
12
|
static inject: string[];
|
|
12
13
|
jar: CookieJar;
|
|
13
14
|
client: AxiosInstance;
|
|
14
|
-
cacheable:
|
|
15
|
+
cacheable: CacheableLookup;
|
|
15
16
|
apiConfig: BiliAPI.Config;
|
|
16
17
|
loginData: any;
|
|
17
18
|
loginNotifier: Notifier;
|
|
@@ -19,6 +20,7 @@ declare class BiliAPI extends Service {
|
|
|
19
20
|
loginInfoIsLoaded: boolean;
|
|
20
21
|
constructor(ctx: Context, config: BiliAPI.Config);
|
|
21
22
|
protected start(): void | Promise<void>;
|
|
23
|
+
protected stop(): Awaitable<void>;
|
|
22
24
|
getMixinKey: (orig: string) => string;
|
|
23
25
|
encWbi(params: {
|
|
24
26
|
[key: string]: string | number | object;
|
|
@@ -63,7 +65,7 @@ declare class BiliAPI extends Service {
|
|
|
63
65
|
cookies: any;
|
|
64
66
|
refresh_token: string;
|
|
65
67
|
}>;
|
|
66
|
-
getCSRF():
|
|
68
|
+
getCSRF(): string;
|
|
67
69
|
loadCookiesFromDatabase(): Promise<void>;
|
|
68
70
|
enableRefreshCookiesDetect(): void;
|
|
69
71
|
checkIfTokenNeedRefresh(refreshToken: string, csrf: string, times?: number): Promise<void>;
|
package/lib/biliAPI.js
CHANGED
|
@@ -1,22 +1,20 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
2
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
3
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
4
|
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
5
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
6
|
};
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
const utils_1 = require("./utils");
|
|
7
|
+
import { Schema, Service } from "koishi";
|
|
8
|
+
import md5 from "md5";
|
|
9
|
+
import crypto from "node:crypto";
|
|
10
|
+
import http from "node:http";
|
|
11
|
+
import https from "node:https";
|
|
12
|
+
import CacheableLookup from "cacheable-lookup";
|
|
13
|
+
import axios from "axios";
|
|
14
|
+
import { CookieJar, Cookie } from "tough-cookie";
|
|
15
|
+
import { wrapper } from "axios-cookiejar-support";
|
|
16
|
+
import { JSDOM } from "jsdom";
|
|
17
|
+
import { Retry } from "./utils";
|
|
20
18
|
const mixinKeyEncTab = [
|
|
21
19
|
46, 47, 18, 2, 53, 8, 23, 32, 15, 50, 10, 31, 58, 3, 45, 35, 27, 43, 5, 49,
|
|
22
20
|
33, 9, 42, 19, 29, 28, 14, 39, 12, 38, 41, 13, 37, 48, 7, 16, 24, 55, 40, 61,
|
|
@@ -49,11 +47,10 @@ const GET_RELATION_GROUP_DETAIL = "https://api.bilibili.com/x/relation/tag";
|
|
|
49
47
|
// 直播
|
|
50
48
|
const GET_LIVE_ROOM_INFO_STREAM_KEY = "https://api.live.bilibili.com/xlive/web-room/v1/index/getDanmuInfo";
|
|
51
49
|
const GET_LIVE_ROOMS_INFO = "https://api.live.bilibili.com/room/v1/Room/get_status_info_by_uids";
|
|
52
|
-
class BiliAPI extends
|
|
50
|
+
class BiliAPI extends Service {
|
|
53
51
|
static inject = ["database", "notifier"];
|
|
54
52
|
jar;
|
|
55
53
|
client;
|
|
56
|
-
// biome-ignore lint/suspicious/noExplicitAny: <explanation>
|
|
57
54
|
cacheable;
|
|
58
55
|
apiConfig;
|
|
59
56
|
// biome-ignore lint/suspicious/noExplicitAny: <explanation>
|
|
@@ -71,6 +68,10 @@ class BiliAPI extends koishi_1.Service {
|
|
|
71
68
|
// 从数据库加载cookies
|
|
72
69
|
this.loadCookiesFromDatabase();
|
|
73
70
|
}
|
|
71
|
+
stop() {
|
|
72
|
+
this.cacheable.uninstall(http.globalAgent);
|
|
73
|
+
this.cacheable.uninstall(https.globalAgent);
|
|
74
|
+
}
|
|
74
75
|
// WBI签名
|
|
75
76
|
// 对 imgKey 和 subKey 进行字符顺序打乱编码
|
|
76
77
|
getMixinKey = (orig) => mixinKeyEncTab
|
|
@@ -92,7 +93,7 @@ class BiliAPI extends koishi_1.Service {
|
|
|
92
93
|
return `${encodeURIComponent(key)}=${encodeURIComponent(value)}`;
|
|
93
94
|
})
|
|
94
95
|
.join("&");
|
|
95
|
-
const wbi_sign = (
|
|
96
|
+
const wbi_sign = md5(query + mixin_key); // 计算 w_rid
|
|
96
97
|
return `${query}&w_rid=${wbi_sign}`;
|
|
97
98
|
}
|
|
98
99
|
async getWbi(params) {
|
|
@@ -103,8 +104,8 @@ class BiliAPI extends koishi_1.Service {
|
|
|
103
104
|
return query;
|
|
104
105
|
}
|
|
105
106
|
encrypt(text) {
|
|
106
|
-
const iv =
|
|
107
|
-
const cipher =
|
|
107
|
+
const iv = crypto.randomBytes(16);
|
|
108
|
+
const cipher = crypto.createCipheriv("aes-256-cbc", Buffer.from(this.apiConfig.key), iv);
|
|
108
109
|
const encrypted = Buffer.concat([cipher.update(text), cipher.final()]);
|
|
109
110
|
return `${iv.toString("hex")}:${encrypted.toString("hex")}`;
|
|
110
111
|
}
|
|
@@ -112,7 +113,7 @@ class BiliAPI extends koishi_1.Service {
|
|
|
112
113
|
const textParts = text.split(":");
|
|
113
114
|
const iv = Buffer.from(textParts.shift(), "hex");
|
|
114
115
|
const encryptedText = Buffer.from(textParts.join(":"), "hex");
|
|
115
|
-
const decipher =
|
|
116
|
+
const decipher = crypto.createDecipheriv("aes-256-cbc", Buffer.from(this.apiConfig.key), iv);
|
|
116
117
|
const decrypted = Buffer.concat([
|
|
117
118
|
decipher.update(encryptedText),
|
|
118
119
|
decipher.final(),
|
|
@@ -288,10 +289,15 @@ class BiliAPI extends koishi_1.Service {
|
|
|
288
289
|
return userAgents[index];
|
|
289
290
|
}
|
|
290
291
|
createNewClient() {
|
|
292
|
+
// 创建DNS缓存
|
|
293
|
+
this.cacheable = new CacheableLookup();
|
|
294
|
+
// 安装到http和https
|
|
295
|
+
this.cacheable.install(http.globalAgent);
|
|
296
|
+
this.cacheable.install(https.globalAgent);
|
|
291
297
|
// 创建cookieJar
|
|
292
|
-
this.jar = new
|
|
298
|
+
this.jar = new CookieJar();
|
|
293
299
|
// 包装cookieJar
|
|
294
|
-
this.client =
|
|
300
|
+
this.client = wrapper(axios.create({
|
|
295
301
|
jar: this.jar,
|
|
296
302
|
headers: {
|
|
297
303
|
"Content-Type": "application/json",
|
|
@@ -407,7 +413,7 @@ class BiliAPI extends koishi_1.Service {
|
|
|
407
413
|
sameSite = cookieData.sameSite;
|
|
408
414
|
}
|
|
409
415
|
// 创建一个完整的 Cookie 实例
|
|
410
|
-
const cookie = new
|
|
416
|
+
const cookie = new Cookie({
|
|
411
417
|
key: cookieData.key,
|
|
412
418
|
value: cookieData.value,
|
|
413
419
|
expires: new Date(cookieData.expires),
|
|
@@ -420,7 +426,7 @@ class BiliAPI extends koishi_1.Service {
|
|
|
420
426
|
this.jar.setCookieSync(cookie, `http${cookie.secure ? "s" : ""}://${cookie.domain}${cookie.path}`, {});
|
|
421
427
|
}
|
|
422
428
|
// 对于某些 IP 地址,需要在 Cookie 中提供任意非空的 buvid3 字段
|
|
423
|
-
const buvid3Cookie = new
|
|
429
|
+
const buvid3Cookie = new Cookie({
|
|
424
430
|
key: "buvid3",
|
|
425
431
|
value: "some_non_empty_value", // 设置任意非空值
|
|
426
432
|
expires, // 设置过期时间
|
|
@@ -493,7 +499,7 @@ class BiliAPI extends koishi_1.Service {
|
|
|
493
499
|
// 如果请求失败,有可能是404,直接刷新cookie
|
|
494
500
|
}
|
|
495
501
|
// 定义Key
|
|
496
|
-
const publicKey = await
|
|
502
|
+
const publicKey = await crypto.subtle.importKey("jwk", {
|
|
497
503
|
kty: "RSA",
|
|
498
504
|
n: "y4HdjgJHBlbaBN04VERG4qNBIFHP6a3GozCl75AihQloSWCXC5HDNgyinEnhaQ_4-gaMud_GF50elYXLlCToR9se9Z8z433U3KjM-3Yx7ptKkmQNAMggQwAVKgq3zYAoidNEWuxpkY_mAitTSRLnsJW-NCTa0bqBFF6Wm1MxgfE",
|
|
499
505
|
e: "AQAB",
|
|
@@ -501,7 +507,7 @@ class BiliAPI extends koishi_1.Service {
|
|
|
501
507
|
// 定义获取CorrespondPath方法
|
|
502
508
|
async function getCorrespondPath(timestamp) {
|
|
503
509
|
const data = new TextEncoder().encode(`refresh_${timestamp}`);
|
|
504
|
-
const encrypted = new Uint8Array(await
|
|
510
|
+
const encrypted = new Uint8Array(await crypto.subtle.encrypt({ name: "RSA-OAEP" }, publicKey, data));
|
|
505
511
|
return encrypted.reduce((str, c) => str + c.toString(16).padStart(2, "0"), "");
|
|
506
512
|
}
|
|
507
513
|
// 获取CorrespondPath
|
|
@@ -510,7 +516,7 @@ class BiliAPI extends koishi_1.Service {
|
|
|
510
516
|
// 获取refresh_csrf
|
|
511
517
|
const { data: refreshCsrfHtml } = await this.client.get(`https://www.bilibili.com/correspond/1/${correspondPath}`);
|
|
512
518
|
// 创建一个虚拟的DOM元素
|
|
513
|
-
const { document } = new
|
|
519
|
+
const { document } = new JSDOM(refreshCsrfHtml).window;
|
|
514
520
|
// 提取标签name为1-name的内容
|
|
515
521
|
const targetElement = document.getElementById("1-name");
|
|
516
522
|
const refresh_csrf = targetElement ? targetElement.textContent : null;
|
|
@@ -578,7 +584,7 @@ class BiliAPI extends koishi_1.Service {
|
|
|
578
584
|
}
|
|
579
585
|
}
|
|
580
586
|
__decorate([
|
|
581
|
-
|
|
587
|
+
Retry({
|
|
582
588
|
attempts: 3,
|
|
583
589
|
onFailure(error, attempts) {
|
|
584
590
|
this.logger.error(`getTheUserWhoIsLiveStreaming() 第${attempts}次失败: ${error.message}`);
|
|
@@ -586,7 +592,7 @@ __decorate([
|
|
|
586
592
|
})
|
|
587
593
|
], BiliAPI.prototype, "getTheUserWhoIsLiveStreaming", null);
|
|
588
594
|
__decorate([
|
|
589
|
-
|
|
595
|
+
Retry({
|
|
590
596
|
attempts: 3,
|
|
591
597
|
onFailure(error, attempts) {
|
|
592
598
|
this.logger.error(`getLiveRoomInfoStreamKey() 第${attempts}次失败: ${error.message}`);
|
|
@@ -594,7 +600,7 @@ __decorate([
|
|
|
594
600
|
})
|
|
595
601
|
], BiliAPI.prototype, "getLiveRoomInfoStreamKey", null);
|
|
596
602
|
__decorate([
|
|
597
|
-
|
|
603
|
+
Retry({
|
|
598
604
|
attempts: 3,
|
|
599
605
|
onFailure(error, attempts) {
|
|
600
606
|
this.logger.error(`getLiveRoomInfoByUids() 第${attempts}次失败: ${error.message}`);
|
|
@@ -602,7 +608,7 @@ __decorate([
|
|
|
602
608
|
})
|
|
603
609
|
], BiliAPI.prototype, "getLiveRoomInfoByUids", null);
|
|
604
610
|
__decorate([
|
|
605
|
-
|
|
611
|
+
Retry({
|
|
606
612
|
attempts: 3,
|
|
607
613
|
onFailure(error, attempts) {
|
|
608
614
|
this.logger.error(`getServerUTCTime() 第${attempts}次失败: ${error.message}`);
|
|
@@ -610,7 +616,7 @@ __decorate([
|
|
|
610
616
|
})
|
|
611
617
|
], BiliAPI.prototype, "getServerUTCTime", null);
|
|
612
618
|
__decorate([
|
|
613
|
-
|
|
619
|
+
Retry({
|
|
614
620
|
attempts: 3,
|
|
615
621
|
onFailure(error, attempts) {
|
|
616
622
|
this.logger.error(`getTimeNow() 第${attempts}次失败: ${error.message}`);
|
|
@@ -618,7 +624,7 @@ __decorate([
|
|
|
618
624
|
})
|
|
619
625
|
], BiliAPI.prototype, "getTimeNow", null);
|
|
620
626
|
__decorate([
|
|
621
|
-
|
|
627
|
+
Retry({
|
|
622
628
|
attempts: 3,
|
|
623
629
|
onFailure(error, attempts) {
|
|
624
630
|
this.logger.error(`getAllGroup() 第${attempts}次失败: ${error.message}`);
|
|
@@ -626,7 +632,7 @@ __decorate([
|
|
|
626
632
|
})
|
|
627
633
|
], BiliAPI.prototype, "getAllGroup", null);
|
|
628
634
|
__decorate([
|
|
629
|
-
|
|
635
|
+
Retry({
|
|
630
636
|
attempts: 3,
|
|
631
637
|
onFailure(error, attempts) {
|
|
632
638
|
this.logger.error(`removeUserFromGroup() 第${attempts}次失败: ${error.message}`);
|
|
@@ -634,7 +640,7 @@ __decorate([
|
|
|
634
640
|
})
|
|
635
641
|
], BiliAPI.prototype, "removeUserFromGroup", null);
|
|
636
642
|
__decorate([
|
|
637
|
-
|
|
643
|
+
Retry({
|
|
638
644
|
attempts: 3,
|
|
639
645
|
onFailure(error, attempts) {
|
|
640
646
|
this.logger.error(`copyUserToGroup() 第${attempts}次失败: ${error.message}`);
|
|
@@ -642,7 +648,7 @@ __decorate([
|
|
|
642
648
|
})
|
|
643
649
|
], BiliAPI.prototype, "copyUserToGroup", null);
|
|
644
650
|
__decorate([
|
|
645
|
-
|
|
651
|
+
Retry({
|
|
646
652
|
attempts: 3,
|
|
647
653
|
onFailure(error, attempts) {
|
|
648
654
|
this.logger.error(`getUserSpaceDynamic() 第${attempts}次失败: ${error.message}`);
|
|
@@ -650,7 +656,7 @@ __decorate([
|
|
|
650
656
|
})
|
|
651
657
|
], BiliAPI.prototype, "getUserSpaceDynamic", null);
|
|
652
658
|
__decorate([
|
|
653
|
-
|
|
659
|
+
Retry({
|
|
654
660
|
attempts: 3,
|
|
655
661
|
onFailure(error, attempts) {
|
|
656
662
|
this.logger.error(`createGroup() 第${attempts}次失败: ${error.message}`);
|
|
@@ -658,7 +664,7 @@ __decorate([
|
|
|
658
664
|
})
|
|
659
665
|
], BiliAPI.prototype, "createGroup", null);
|
|
660
666
|
__decorate([
|
|
661
|
-
|
|
667
|
+
Retry({
|
|
662
668
|
attempts: 3,
|
|
663
669
|
onFailure(error, attempts) {
|
|
664
670
|
this.logger.error(`getAllDynamic() 第${attempts}次失败: ${error.message}`);
|
|
@@ -666,7 +672,7 @@ __decorate([
|
|
|
666
672
|
})
|
|
667
673
|
], BiliAPI.prototype, "getAllDynamic", null);
|
|
668
674
|
__decorate([
|
|
669
|
-
|
|
675
|
+
Retry({
|
|
670
676
|
attempts: 3,
|
|
671
677
|
onFailure(error, attempts) {
|
|
672
678
|
this.logger.error(`hasNewDynamic() 第${attempts}次失败: ${error.message}`);
|
|
@@ -674,7 +680,7 @@ __decorate([
|
|
|
674
680
|
})
|
|
675
681
|
], BiliAPI.prototype, "hasNewDynamic", null);
|
|
676
682
|
__decorate([
|
|
677
|
-
|
|
683
|
+
Retry({
|
|
678
684
|
attempts: 3,
|
|
679
685
|
onFailure(error, attempts) {
|
|
680
686
|
this.logger.error(`follow() 第${attempts}次失败: ${error.message}`);
|
|
@@ -682,7 +688,7 @@ __decorate([
|
|
|
682
688
|
})
|
|
683
689
|
], BiliAPI.prototype, "follow", null);
|
|
684
690
|
__decorate([
|
|
685
|
-
|
|
691
|
+
Retry({
|
|
686
692
|
attempts: 3,
|
|
687
693
|
onFailure(error, attempts) {
|
|
688
694
|
this.logger.error(`getRelationGroupDetail() 第${attempts}次失败: ${error.message}`);
|
|
@@ -690,7 +696,7 @@ __decorate([
|
|
|
690
696
|
})
|
|
691
697
|
], BiliAPI.prototype, "getRelationGroupDetail", null);
|
|
692
698
|
__decorate([
|
|
693
|
-
|
|
699
|
+
Retry({
|
|
694
700
|
attempts: 3,
|
|
695
701
|
onFailure(error, attempts) {
|
|
696
702
|
this.logger.error(`getCookieInfo() 第${attempts}次失败: ${error.message}`);
|
|
@@ -698,7 +704,7 @@ __decorate([
|
|
|
698
704
|
})
|
|
699
705
|
], BiliAPI.prototype, "getCookieInfo", null);
|
|
700
706
|
__decorate([
|
|
701
|
-
|
|
707
|
+
Retry({
|
|
702
708
|
attempts: 3,
|
|
703
709
|
onFailure(error, attempts) {
|
|
704
710
|
this.logger.error(`getUserInfo() 第${attempts}次失败: ${error.message}`);
|
|
@@ -706,7 +712,7 @@ __decorate([
|
|
|
706
712
|
})
|
|
707
713
|
], BiliAPI.prototype, "getUserInfo", null);
|
|
708
714
|
__decorate([
|
|
709
|
-
|
|
715
|
+
Retry({
|
|
710
716
|
attempts: 3,
|
|
711
717
|
onFailure(error, attempts) {
|
|
712
718
|
this.logger.error(`getWbiKeys() 第${attempts}次失败: ${error.message}`);
|
|
@@ -714,7 +720,7 @@ __decorate([
|
|
|
714
720
|
})
|
|
715
721
|
], BiliAPI.prototype, "getWbiKeys", null);
|
|
716
722
|
__decorate([
|
|
717
|
-
|
|
723
|
+
Retry({
|
|
718
724
|
attempts: 3,
|
|
719
725
|
onFailure(error, attempts) {
|
|
720
726
|
this.logger.error(`getMyselfInfo() 第${attempts}次失败: ${error.message}`);
|
|
@@ -722,7 +728,7 @@ __decorate([
|
|
|
722
728
|
})
|
|
723
729
|
], BiliAPI.prototype, "getMyselfInfo", null);
|
|
724
730
|
__decorate([
|
|
725
|
-
|
|
731
|
+
Retry({
|
|
726
732
|
attempts: 3,
|
|
727
733
|
onFailure(error, attempts) {
|
|
728
734
|
this.logger.error(`getLoginQRCode() 第${attempts}次失败: ${error.message}`);
|
|
@@ -730,7 +736,7 @@ __decorate([
|
|
|
730
736
|
})
|
|
731
737
|
], BiliAPI.prototype, "getLoginQRCode", null);
|
|
732
738
|
__decorate([
|
|
733
|
-
|
|
739
|
+
Retry({
|
|
734
740
|
attempts: 3,
|
|
735
741
|
onFailure(error, attempts) {
|
|
736
742
|
this.logger.error(`getLoginStatus() 第${attempts}次失败: ${error.message}`);
|
|
@@ -738,7 +744,7 @@ __decorate([
|
|
|
738
744
|
})
|
|
739
745
|
], BiliAPI.prototype, "getLoginStatus", null);
|
|
740
746
|
__decorate([
|
|
741
|
-
|
|
747
|
+
Retry({
|
|
742
748
|
attempts: 3,
|
|
743
749
|
onFailure(error, attempts) {
|
|
744
750
|
this.logger.error(`getLiveRoomInfo() 第${attempts}次失败: ${error.message}`);
|
|
@@ -746,7 +752,7 @@ __decorate([
|
|
|
746
752
|
})
|
|
747
753
|
], BiliAPI.prototype, "getLiveRoomInfo", null);
|
|
748
754
|
__decorate([
|
|
749
|
-
|
|
755
|
+
Retry({
|
|
750
756
|
attempts: 3,
|
|
751
757
|
onFailure(error, attempts) {
|
|
752
758
|
this.logger.error(`getMasterInfo() 第${attempts}次失败: ${error.message}`);
|
|
@@ -754,11 +760,11 @@ __decorate([
|
|
|
754
760
|
})
|
|
755
761
|
], BiliAPI.prototype, "getMasterInfo", null);
|
|
756
762
|
(function (BiliAPI) {
|
|
757
|
-
BiliAPI.Config =
|
|
758
|
-
userAgent:
|
|
759
|
-
key:
|
|
763
|
+
BiliAPI.Config = Schema.object({
|
|
764
|
+
userAgent: Schema.string(),
|
|
765
|
+
key: Schema.string()
|
|
760
766
|
.pattern(/^[0-9a-f]{32}$/)
|
|
761
767
|
.required(),
|
|
762
768
|
});
|
|
763
769
|
})(BiliAPI || (BiliAPI = {}));
|
|
764
|
-
|
|
770
|
+
export default BiliAPI;
|
package/lib/blive.js
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const blive_message_listener_1 = require("@akokko/blive-message-listener");
|
|
5
|
-
class BLive extends koishi_1.Service {
|
|
1
|
+
import { Service } from "koishi";
|
|
2
|
+
import { startListen, } from "@akokko/blive-message-listener";
|
|
3
|
+
class BLive extends Service {
|
|
6
4
|
// 必要服务
|
|
7
5
|
static inject = ["ba"];
|
|
8
6
|
// 定义类属性
|
|
@@ -24,7 +22,7 @@ class BLive extends koishi_1.Service {
|
|
|
24
22
|
// 获取自身信息
|
|
25
23
|
const mySelfInfo = await this.ctx.ba.getMyselfInfo();
|
|
26
24
|
// 创建实例并保存到Record中
|
|
27
|
-
this.listenerRecord[roomId] =
|
|
25
|
+
this.listenerRecord[roomId] = startListen(Number.parseInt(roomId), handler, {
|
|
28
26
|
ws: {
|
|
29
27
|
headers: {
|
|
30
28
|
Cookie: cookiesStr,
|
|
@@ -55,4 +53,4 @@ class BLive extends koishi_1.Service {
|
|
|
55
53
|
this.logger.warn(`${roomId}直播间弹幕监听未成功关闭`);
|
|
56
54
|
}
|
|
57
55
|
}
|
|
58
|
-
|
|
56
|
+
export default BLive;
|