koishi-plugin-bilibili-notify 3.2.1-alpha.8 → 3.2.1
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 +1 -1
- package/lib/biliAPI.js +51 -46
- package/lib/blive.js +20 -23
- package/lib/comRegister.js +125 -120
- package/lib/database.js +6 -2
- package/lib/font/HYZhengYuan-75W.ttf +0 -0
- package/lib/generateImg.js +33 -31
- package/lib/index.js +131 -91
- package/lib/type/index.d.ts +19 -0
- package/lib/type/index.js +7 -4
- package/lib/utils/index.js +8 -3
- package/package.json +34 -9
- package/readme.md +5 -4
package/lib/biliAPI.d.ts
CHANGED
|
@@ -62,7 +62,7 @@ declare class BiliAPI extends Service {
|
|
|
62
62
|
cookies: any;
|
|
63
63
|
refresh_token: string;
|
|
64
64
|
}>;
|
|
65
|
-
getCSRF():
|
|
65
|
+
getCSRF(): any;
|
|
66
66
|
loadCookiesFromDatabase(): Promise<void>;
|
|
67
67
|
enableRefreshCookiesDetect(): void;
|
|
68
68
|
checkIfTokenNeedRefresh(refreshToken: string, csrf: string, times?: number): Promise<void>;
|
package/lib/biliAPI.js
CHANGED
|
@@ -1,17 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
3
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
4
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
5
|
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
6
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
7
|
};
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
8
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
9
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
const koishi_1 = require("koishi");
|
|
13
|
+
const md5_1 = __importDefault(require("md5"));
|
|
14
|
+
const node_crypto_1 = __importDefault(require("node:crypto"));
|
|
15
|
+
const axios_1 = __importDefault(require("axios"));
|
|
16
|
+
const tough_cookie_1 = require("tough-cookie");
|
|
17
|
+
const axios_cookiejar_support_1 = require("axios-cookiejar-support");
|
|
18
|
+
const jsdom_1 = require("jsdom");
|
|
19
|
+
const utils_1 = require("./utils");
|
|
15
20
|
const mixinKeyEncTab = [
|
|
16
21
|
46, 47, 18, 2, 53, 8, 23, 32, 15, 50, 10, 31, 58, 3, 45, 35, 27, 43, 5, 49,
|
|
17
22
|
33, 9, 42, 19, 29, 28, 14, 39, 12, 38, 41, 13, 37, 48, 7, 16, 24, 55, 40, 61,
|
|
@@ -44,7 +49,7 @@ const GET_RELATION_GROUP_DETAIL = "https://api.bilibili.com/x/relation/tag";
|
|
|
44
49
|
// 直播
|
|
45
50
|
const GET_LIVE_ROOM_INFO_STREAM_KEY = "https://api.live.bilibili.com/xlive/web-room/v1/index/getDanmuInfo";
|
|
46
51
|
const GET_LIVE_ROOMS_INFO = "https://api.live.bilibili.com/room/v1/Room/get_status_info_by_uids";
|
|
47
|
-
class BiliAPI extends Service {
|
|
52
|
+
class BiliAPI extends koishi_1.Service {
|
|
48
53
|
static inject = ["database", "notifier"];
|
|
49
54
|
jar;
|
|
50
55
|
client;
|
|
@@ -85,7 +90,7 @@ class BiliAPI extends Service {
|
|
|
85
90
|
return `${encodeURIComponent(key)}=${encodeURIComponent(value)}`;
|
|
86
91
|
})
|
|
87
92
|
.join("&");
|
|
88
|
-
const wbi_sign =
|
|
93
|
+
const wbi_sign = (0, md5_1.default)(query + mixin_key); // 计算 w_rid
|
|
89
94
|
return `${query}&w_rid=${wbi_sign}`;
|
|
90
95
|
}
|
|
91
96
|
async getWbi(params) {
|
|
@@ -96,8 +101,8 @@ class BiliAPI extends Service {
|
|
|
96
101
|
return query;
|
|
97
102
|
}
|
|
98
103
|
encrypt(text) {
|
|
99
|
-
const iv =
|
|
100
|
-
const cipher =
|
|
104
|
+
const iv = node_crypto_1.default.randomBytes(16);
|
|
105
|
+
const cipher = node_crypto_1.default.createCipheriv("aes-256-cbc", Buffer.from(this.apiConfig.key), iv);
|
|
101
106
|
const encrypted = Buffer.concat([cipher.update(text), cipher.final()]);
|
|
102
107
|
return `${iv.toString("hex")}:${encrypted.toString("hex")}`;
|
|
103
108
|
}
|
|
@@ -105,7 +110,7 @@ class BiliAPI extends Service {
|
|
|
105
110
|
const textParts = text.split(":");
|
|
106
111
|
const iv = Buffer.from(textParts.shift(), "hex");
|
|
107
112
|
const encryptedText = Buffer.from(textParts.join(":"), "hex");
|
|
108
|
-
const decipher =
|
|
113
|
+
const decipher = node_crypto_1.default.createDecipheriv("aes-256-cbc", Buffer.from(this.apiConfig.key), iv);
|
|
109
114
|
const decrypted = Buffer.concat([
|
|
110
115
|
decipher.update(encryptedText),
|
|
111
116
|
decipher.final(),
|
|
@@ -282,9 +287,9 @@ class BiliAPI extends Service {
|
|
|
282
287
|
}
|
|
283
288
|
createNewClient() {
|
|
284
289
|
// 创建cookieJar
|
|
285
|
-
this.jar = new CookieJar();
|
|
290
|
+
this.jar = new tough_cookie_1.CookieJar();
|
|
286
291
|
// 包装cookieJar
|
|
287
|
-
this.client = wrapper(
|
|
292
|
+
this.client = (0, axios_cookiejar_support_1.wrapper)(axios_1.default.create({
|
|
288
293
|
jar: this.jar,
|
|
289
294
|
headers: {
|
|
290
295
|
"Content-Type": "application/json",
|
|
@@ -400,7 +405,7 @@ class BiliAPI extends Service {
|
|
|
400
405
|
sameSite = cookieData.sameSite;
|
|
401
406
|
}
|
|
402
407
|
// 创建一个完整的 Cookie 实例
|
|
403
|
-
const cookie = new Cookie({
|
|
408
|
+
const cookie = new tough_cookie_1.Cookie({
|
|
404
409
|
key: cookieData.key,
|
|
405
410
|
value: cookieData.value,
|
|
406
411
|
expires: new Date(cookieData.expires),
|
|
@@ -413,7 +418,7 @@ class BiliAPI extends Service {
|
|
|
413
418
|
this.jar.setCookieSync(cookie, `http${cookie.secure ? "s" : ""}://${cookie.domain}${cookie.path}`, {});
|
|
414
419
|
}
|
|
415
420
|
// 对于某些 IP 地址,需要在 Cookie 中提供任意非空的 buvid3 字段
|
|
416
|
-
const buvid3Cookie = new Cookie({
|
|
421
|
+
const buvid3Cookie = new tough_cookie_1.Cookie({
|
|
417
422
|
key: "buvid3",
|
|
418
423
|
value: "some_non_empty_value", // 设置任意非空值
|
|
419
424
|
expires, // 设置过期时间
|
|
@@ -486,7 +491,7 @@ class BiliAPI extends Service {
|
|
|
486
491
|
// 如果请求失败,有可能是404,直接刷新cookie
|
|
487
492
|
}
|
|
488
493
|
// 定义Key
|
|
489
|
-
const publicKey = await
|
|
494
|
+
const publicKey = await node_crypto_1.default.subtle.importKey("jwk", {
|
|
490
495
|
kty: "RSA",
|
|
491
496
|
n: "y4HdjgJHBlbaBN04VERG4qNBIFHP6a3GozCl75AihQloSWCXC5HDNgyinEnhaQ_4-gaMud_GF50elYXLlCToR9se9Z8z433U3KjM-3Yx7ptKkmQNAMggQwAVKgq3zYAoidNEWuxpkY_mAitTSRLnsJW-NCTa0bqBFF6Wm1MxgfE",
|
|
492
497
|
e: "AQAB",
|
|
@@ -494,7 +499,7 @@ class BiliAPI extends Service {
|
|
|
494
499
|
// 定义获取CorrespondPath方法
|
|
495
500
|
async function getCorrespondPath(timestamp) {
|
|
496
501
|
const data = new TextEncoder().encode(`refresh_${timestamp}`);
|
|
497
|
-
const encrypted = new Uint8Array(await
|
|
502
|
+
const encrypted = new Uint8Array(await node_crypto_1.default.subtle.encrypt({ name: "RSA-OAEP" }, publicKey, data));
|
|
498
503
|
return encrypted.reduce((str, c) => str + c.toString(16).padStart(2, "0"), "");
|
|
499
504
|
}
|
|
500
505
|
// 获取CorrespondPath
|
|
@@ -503,7 +508,7 @@ class BiliAPI extends Service {
|
|
|
503
508
|
// 获取refresh_csrf
|
|
504
509
|
const { data: refreshCsrfHtml } = await this.client.get(`https://www.bilibili.com/correspond/1/${correspondPath}`);
|
|
505
510
|
// 创建一个虚拟的DOM元素
|
|
506
|
-
const { document } = new JSDOM(refreshCsrfHtml).window;
|
|
511
|
+
const { document } = new jsdom_1.JSDOM(refreshCsrfHtml).window;
|
|
507
512
|
// 提取标签name为1-name的内容
|
|
508
513
|
const targetElement = document.getElementById("1-name");
|
|
509
514
|
const refresh_csrf = targetElement ? targetElement.textContent : null;
|
|
@@ -571,7 +576,7 @@ class BiliAPI extends Service {
|
|
|
571
576
|
}
|
|
572
577
|
}
|
|
573
578
|
__decorate([
|
|
574
|
-
Retry({
|
|
579
|
+
(0, utils_1.Retry)({
|
|
575
580
|
attempts: 3,
|
|
576
581
|
onFailure(error, attempts) {
|
|
577
582
|
this.logger.error(`getTheUserWhoIsLiveStreaming() 第${attempts}次失败: ${error.message}`);
|
|
@@ -579,7 +584,7 @@ __decorate([
|
|
|
579
584
|
})
|
|
580
585
|
], BiliAPI.prototype, "getTheUserWhoIsLiveStreaming", null);
|
|
581
586
|
__decorate([
|
|
582
|
-
Retry({
|
|
587
|
+
(0, utils_1.Retry)({
|
|
583
588
|
attempts: 3,
|
|
584
589
|
onFailure(error, attempts) {
|
|
585
590
|
this.logger.error(`getLiveRoomInfoStreamKey() 第${attempts}次失败: ${error.message}`);
|
|
@@ -587,7 +592,7 @@ __decorate([
|
|
|
587
592
|
})
|
|
588
593
|
], BiliAPI.prototype, "getLiveRoomInfoStreamKey", null);
|
|
589
594
|
__decorate([
|
|
590
|
-
Retry({
|
|
595
|
+
(0, utils_1.Retry)({
|
|
591
596
|
attempts: 3,
|
|
592
597
|
onFailure(error, attempts) {
|
|
593
598
|
this.logger.error(`getLiveRoomInfoByUids() 第${attempts}次失败: ${error.message}`);
|
|
@@ -595,7 +600,7 @@ __decorate([
|
|
|
595
600
|
})
|
|
596
601
|
], BiliAPI.prototype, "getLiveRoomInfoByUids", null);
|
|
597
602
|
__decorate([
|
|
598
|
-
Retry({
|
|
603
|
+
(0, utils_1.Retry)({
|
|
599
604
|
attempts: 3,
|
|
600
605
|
onFailure(error, attempts) {
|
|
601
606
|
this.logger.error(`getServerUTCTime() 第${attempts}次失败: ${error.message}`);
|
|
@@ -603,7 +608,7 @@ __decorate([
|
|
|
603
608
|
})
|
|
604
609
|
], BiliAPI.prototype, "getServerUTCTime", null);
|
|
605
610
|
__decorate([
|
|
606
|
-
Retry({
|
|
611
|
+
(0, utils_1.Retry)({
|
|
607
612
|
attempts: 3,
|
|
608
613
|
onFailure(error, attempts) {
|
|
609
614
|
this.logger.error(`getTimeNow() 第${attempts}次失败: ${error.message}`);
|
|
@@ -611,7 +616,7 @@ __decorate([
|
|
|
611
616
|
})
|
|
612
617
|
], BiliAPI.prototype, "getTimeNow", null);
|
|
613
618
|
__decorate([
|
|
614
|
-
Retry({
|
|
619
|
+
(0, utils_1.Retry)({
|
|
615
620
|
attempts: 3,
|
|
616
621
|
onFailure(error, attempts) {
|
|
617
622
|
this.logger.error(`getAllGroup() 第${attempts}次失败: ${error.message}`);
|
|
@@ -619,7 +624,7 @@ __decorate([
|
|
|
619
624
|
})
|
|
620
625
|
], BiliAPI.prototype, "getAllGroup", null);
|
|
621
626
|
__decorate([
|
|
622
|
-
Retry({
|
|
627
|
+
(0, utils_1.Retry)({
|
|
623
628
|
attempts: 3,
|
|
624
629
|
onFailure(error, attempts) {
|
|
625
630
|
this.logger.error(`removeUserFromGroup() 第${attempts}次失败: ${error.message}`);
|
|
@@ -627,7 +632,7 @@ __decorate([
|
|
|
627
632
|
})
|
|
628
633
|
], BiliAPI.prototype, "removeUserFromGroup", null);
|
|
629
634
|
__decorate([
|
|
630
|
-
Retry({
|
|
635
|
+
(0, utils_1.Retry)({
|
|
631
636
|
attempts: 3,
|
|
632
637
|
onFailure(error, attempts) {
|
|
633
638
|
this.logger.error(`copyUserToGroup() 第${attempts}次失败: ${error.message}`);
|
|
@@ -635,7 +640,7 @@ __decorate([
|
|
|
635
640
|
})
|
|
636
641
|
], BiliAPI.prototype, "copyUserToGroup", null);
|
|
637
642
|
__decorate([
|
|
638
|
-
Retry({
|
|
643
|
+
(0, utils_1.Retry)({
|
|
639
644
|
attempts: 3,
|
|
640
645
|
onFailure(error, attempts) {
|
|
641
646
|
this.logger.error(`getUserSpaceDynamic() 第${attempts}次失败: ${error.message}`);
|
|
@@ -643,7 +648,7 @@ __decorate([
|
|
|
643
648
|
})
|
|
644
649
|
], BiliAPI.prototype, "getUserSpaceDynamic", null);
|
|
645
650
|
__decorate([
|
|
646
|
-
Retry({
|
|
651
|
+
(0, utils_1.Retry)({
|
|
647
652
|
attempts: 3,
|
|
648
653
|
onFailure(error, attempts) {
|
|
649
654
|
this.logger.error(`createGroup() 第${attempts}次失败: ${error.message}`);
|
|
@@ -651,7 +656,7 @@ __decorate([
|
|
|
651
656
|
})
|
|
652
657
|
], BiliAPI.prototype, "createGroup", null);
|
|
653
658
|
__decorate([
|
|
654
|
-
Retry({
|
|
659
|
+
(0, utils_1.Retry)({
|
|
655
660
|
attempts: 3,
|
|
656
661
|
onFailure(error, attempts) {
|
|
657
662
|
this.logger.error(`getAllDynamic() 第${attempts}次失败: ${error.message}`);
|
|
@@ -659,7 +664,7 @@ __decorate([
|
|
|
659
664
|
})
|
|
660
665
|
], BiliAPI.prototype, "getAllDynamic", null);
|
|
661
666
|
__decorate([
|
|
662
|
-
Retry({
|
|
667
|
+
(0, utils_1.Retry)({
|
|
663
668
|
attempts: 3,
|
|
664
669
|
onFailure(error, attempts) {
|
|
665
670
|
this.logger.error(`hasNewDynamic() 第${attempts}次失败: ${error.message}`);
|
|
@@ -667,7 +672,7 @@ __decorate([
|
|
|
667
672
|
})
|
|
668
673
|
], BiliAPI.prototype, "hasNewDynamic", null);
|
|
669
674
|
__decorate([
|
|
670
|
-
Retry({
|
|
675
|
+
(0, utils_1.Retry)({
|
|
671
676
|
attempts: 3,
|
|
672
677
|
onFailure(error, attempts) {
|
|
673
678
|
this.logger.error(`follow() 第${attempts}次失败: ${error.message}`);
|
|
@@ -675,7 +680,7 @@ __decorate([
|
|
|
675
680
|
})
|
|
676
681
|
], BiliAPI.prototype, "follow", null);
|
|
677
682
|
__decorate([
|
|
678
|
-
Retry({
|
|
683
|
+
(0, utils_1.Retry)({
|
|
679
684
|
attempts: 3,
|
|
680
685
|
onFailure(error, attempts) {
|
|
681
686
|
this.logger.error(`getRelationGroupDetail() 第${attempts}次失败: ${error.message}`);
|
|
@@ -683,7 +688,7 @@ __decorate([
|
|
|
683
688
|
})
|
|
684
689
|
], BiliAPI.prototype, "getRelationGroupDetail", null);
|
|
685
690
|
__decorate([
|
|
686
|
-
Retry({
|
|
691
|
+
(0, utils_1.Retry)({
|
|
687
692
|
attempts: 3,
|
|
688
693
|
onFailure(error, attempts) {
|
|
689
694
|
this.logger.error(`getCookieInfo() 第${attempts}次失败: ${error.message}`);
|
|
@@ -691,7 +696,7 @@ __decorate([
|
|
|
691
696
|
})
|
|
692
697
|
], BiliAPI.prototype, "getCookieInfo", null);
|
|
693
698
|
__decorate([
|
|
694
|
-
Retry({
|
|
699
|
+
(0, utils_1.Retry)({
|
|
695
700
|
attempts: 3,
|
|
696
701
|
onFailure(error, attempts) {
|
|
697
702
|
this.logger.error(`getUserInfo() 第${attempts}次失败: ${error.message}`);
|
|
@@ -699,7 +704,7 @@ __decorate([
|
|
|
699
704
|
})
|
|
700
705
|
], BiliAPI.prototype, "getUserInfo", null);
|
|
701
706
|
__decorate([
|
|
702
|
-
Retry({
|
|
707
|
+
(0, utils_1.Retry)({
|
|
703
708
|
attempts: 3,
|
|
704
709
|
onFailure(error, attempts) {
|
|
705
710
|
this.logger.error(`getWbiKeys() 第${attempts}次失败: ${error.message}`);
|
|
@@ -707,7 +712,7 @@ __decorate([
|
|
|
707
712
|
})
|
|
708
713
|
], BiliAPI.prototype, "getWbiKeys", null);
|
|
709
714
|
__decorate([
|
|
710
|
-
Retry({
|
|
715
|
+
(0, utils_1.Retry)({
|
|
711
716
|
attempts: 3,
|
|
712
717
|
onFailure(error, attempts) {
|
|
713
718
|
this.logger.error(`getMyselfInfo() 第${attempts}次失败: ${error.message}`);
|
|
@@ -715,7 +720,7 @@ __decorate([
|
|
|
715
720
|
})
|
|
716
721
|
], BiliAPI.prototype, "getMyselfInfo", null);
|
|
717
722
|
__decorate([
|
|
718
|
-
Retry({
|
|
723
|
+
(0, utils_1.Retry)({
|
|
719
724
|
attempts: 3,
|
|
720
725
|
onFailure(error, attempts) {
|
|
721
726
|
this.logger.error(`getLoginQRCode() 第${attempts}次失败: ${error.message}`);
|
|
@@ -723,7 +728,7 @@ __decorate([
|
|
|
723
728
|
})
|
|
724
729
|
], BiliAPI.prototype, "getLoginQRCode", null);
|
|
725
730
|
__decorate([
|
|
726
|
-
Retry({
|
|
731
|
+
(0, utils_1.Retry)({
|
|
727
732
|
attempts: 3,
|
|
728
733
|
onFailure(error, attempts) {
|
|
729
734
|
this.logger.error(`getLoginStatus() 第${attempts}次失败: ${error.message}`);
|
|
@@ -731,7 +736,7 @@ __decorate([
|
|
|
731
736
|
})
|
|
732
737
|
], BiliAPI.prototype, "getLoginStatus", null);
|
|
733
738
|
__decorate([
|
|
734
|
-
Retry({
|
|
739
|
+
(0, utils_1.Retry)({
|
|
735
740
|
attempts: 3,
|
|
736
741
|
onFailure(error, attempts) {
|
|
737
742
|
this.logger.error(`getLiveRoomInfo() 第${attempts}次失败: ${error.message}`);
|
|
@@ -739,7 +744,7 @@ __decorate([
|
|
|
739
744
|
})
|
|
740
745
|
], BiliAPI.prototype, "getLiveRoomInfo", null);
|
|
741
746
|
__decorate([
|
|
742
|
-
Retry({
|
|
747
|
+
(0, utils_1.Retry)({
|
|
743
748
|
attempts: 3,
|
|
744
749
|
onFailure(error, attempts) {
|
|
745
750
|
this.logger.error(`getMasterInfo() 第${attempts}次失败: ${error.message}`);
|
|
@@ -747,11 +752,11 @@ __decorate([
|
|
|
747
752
|
})
|
|
748
753
|
], BiliAPI.prototype, "getMasterInfo", null);
|
|
749
754
|
(function (BiliAPI) {
|
|
750
|
-
BiliAPI.Config = Schema.object({
|
|
751
|
-
userAgent: Schema.string(),
|
|
752
|
-
key: Schema.string()
|
|
755
|
+
BiliAPI.Config = koishi_1.Schema.object({
|
|
756
|
+
userAgent: koishi_1.Schema.string(),
|
|
757
|
+
key: koishi_1.Schema.string()
|
|
753
758
|
.pattern(/^[0-9a-f]{32}$/)
|
|
754
759
|
.required(),
|
|
755
760
|
});
|
|
756
761
|
})(BiliAPI || (BiliAPI = {}));
|
|
757
|
-
|
|
762
|
+
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("@akokko/blive-message-listener");
|
|
5
|
+
class BLive extends koishi_1.Service {
|
|
4
6
|
// 必要服务
|
|
5
7
|
static inject = ["ba"];
|
|
6
8
|
// 定义类属性
|
|
@@ -17,29 +19,24 @@ class BLive extends Service {
|
|
|
17
19
|
}
|
|
18
20
|
}
|
|
19
21
|
async startLiveRoomListener(roomId, handler) {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
Cookie: cookiesStr,
|
|
30
|
-
},
|
|
31
|
-
uid: mySelfInfo.data.mid,
|
|
22
|
+
// 获取cookieStr
|
|
23
|
+
const cookiesStr = await this.ctx.ba.getCookiesForHeader();
|
|
24
|
+
// 获取自身信息
|
|
25
|
+
const mySelfInfo = await this.ctx.ba.getMyselfInfo();
|
|
26
|
+
// 创建实例并保存到Record中
|
|
27
|
+
this.listenerRecord[roomId] = (0, blive_message_listener_1.startListen)(Number.parseInt(roomId), handler, {
|
|
28
|
+
ws: {
|
|
29
|
+
headers: {
|
|
30
|
+
Cookie: cookiesStr,
|
|
32
31
|
},
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
// logger
|
|
37
|
-
this.logger.info(`[${roomId}]监听直播间消息失败!错误:${e.message}`);
|
|
38
|
-
}
|
|
32
|
+
uid: mySelfInfo.data.mid,
|
|
33
|
+
},
|
|
34
|
+
});
|
|
39
35
|
}
|
|
40
36
|
closeListener(roomId) {
|
|
41
37
|
// 判断直播间监听器是否关闭
|
|
42
|
-
if (!this.listenerRecord ||
|
|
38
|
+
if (!this.listenerRecord ||
|
|
39
|
+
!this.listenerRecord[roomId]?.closed) {
|
|
43
40
|
// 输出logger
|
|
44
41
|
this.logger.info(`${roomId}直播间弹幕监听器无需关闭`);
|
|
45
42
|
}
|
|
@@ -58,4 +55,4 @@ class BLive extends Service {
|
|
|
58
55
|
this.logger.warn(`${roomId}直播间弹幕监听未成功关闭`);
|
|
59
56
|
}
|
|
60
57
|
}
|
|
61
|
-
|
|
58
|
+
exports.default = BLive;
|