koishi-plugin-bilibili-notify 3.2.11-alpha.8 → 3.3.0-rc.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/index.js +261 -236
- package/lib/index.mjs +261 -236
- package/package.json +4 -4
- package/readme.md +7 -0
package/lib/index.js
CHANGED
|
@@ -46,7 +46,6 @@ const node_https = __toESM(require("node:https"));
|
|
|
46
46
|
const axios = __toESM(require("axios"));
|
|
47
47
|
const tough_cookie = __toESM(require("tough-cookie"));
|
|
48
48
|
const jsdom = __toESM(require("jsdom"));
|
|
49
|
-
const __oxc_project_runtime_helpers_decorate = __toESM(require("@oxc-project/runtime/helpers/decorate"));
|
|
50
49
|
const __akokko_blive_message_listener = __toESM(require("@akokko/blive-message-listener"));
|
|
51
50
|
|
|
52
51
|
//#region src/config.ts
|
|
@@ -122,22 +121,6 @@ const BAConfigSchema = koishi.Schema.object({
|
|
|
122
121
|
|
|
123
122
|
//#endregion
|
|
124
123
|
//#region src/utils/index.ts
|
|
125
|
-
function Retry(options = { attempts: 3 }) {
|
|
126
|
-
return (_target, _propertyKey, descriptor) => {
|
|
127
|
-
const originalMethod = descriptor.value;
|
|
128
|
-
descriptor.value = async function(...args) {
|
|
129
|
-
let lastError;
|
|
130
|
-
for (let i = 0; i < options.attempts; i++) try {
|
|
131
|
-
return await originalMethod.apply(this, args);
|
|
132
|
-
} catch (error) {
|
|
133
|
-
lastError = error;
|
|
134
|
-
if (options.onFailure) await options.onFailure.call(this, lastError, i + 1);
|
|
135
|
-
}
|
|
136
|
-
throw lastError;
|
|
137
|
-
};
|
|
138
|
-
return descriptor;
|
|
139
|
-
};
|
|
140
|
-
}
|
|
141
124
|
/**
|
|
142
125
|
* 高阶函数:为函数添加锁机制
|
|
143
126
|
* @param {Function} fn - 需要包装的原始函数
|
|
@@ -643,14 +626,8 @@ var ComRegister = class {
|
|
|
643
626
|
await session.send("请手动填入 gt 和 challenge 后点击生成进行验证,验证完成后点击结果,根据提示输入对应validate");
|
|
644
627
|
await session.send(`gt:${data.geetest.gt}`);
|
|
645
628
|
await session.send(`challenge:${data.geetest.challenge}`);
|
|
646
|
-
await session.send("
|
|
647
|
-
const validate = await (
|
|
648
|
-
while (true) {
|
|
649
|
-
const validate$1 = await session.prompt();
|
|
650
|
-
if (validate$1?.startsWith("val ")) return validate$1.slice(4);
|
|
651
|
-
else await session.send("请输入正确的validate,格式为 val <validate>");
|
|
652
|
-
}
|
|
653
|
-
})();
|
|
629
|
+
await session.send("请直接输入validate");
|
|
630
|
+
const validate = await session.prompt();
|
|
654
631
|
const seccode = `${validate}|jordan`;
|
|
655
632
|
const { data: validateCaptchaData } = await ctx.ba.validateCaptcha(data.geetest.challenge, data.token, validate, seccode);
|
|
656
633
|
if (validateCaptchaData?.is_valid !== 1) return "验证不成功!";
|
|
@@ -3332,11 +3309,15 @@ var BiliAPI = class extends koishi.Service {
|
|
|
3332
3309
|
sub_key: ""
|
|
3333
3310
|
};
|
|
3334
3311
|
updateJob;
|
|
3312
|
+
pRetry;
|
|
3313
|
+
AbortError;
|
|
3335
3314
|
constructor(ctx, config) {
|
|
3336
3315
|
super(ctx, "ba");
|
|
3337
3316
|
this.apiConfig = config;
|
|
3338
3317
|
}
|
|
3339
3318
|
async start() {
|
|
3319
|
+
this.pRetry = (await import("p-retry")).default;
|
|
3320
|
+
this.AbortError = (await import("p-retry")).AbortError;
|
|
3340
3321
|
const CacheableLookup = (await import("cacheable-lookup")).default;
|
|
3341
3322
|
this.cacheable = new CacheableLookup();
|
|
3342
3323
|
this.cacheable.install(node_http.default.globalAgent);
|
|
@@ -3401,129 +3382,305 @@ var BiliAPI = class extends koishi.Service {
|
|
|
3401
3382
|
return decrypted.toString();
|
|
3402
3383
|
}
|
|
3403
3384
|
async getTheUserWhoIsLiveStreaming() {
|
|
3404
|
-
const
|
|
3405
|
-
|
|
3385
|
+
const run = async () => {
|
|
3386
|
+
const { data } = await this.client.get(GET_LATEST_UPDATED_UPS);
|
|
3387
|
+
return data;
|
|
3388
|
+
};
|
|
3389
|
+
return await this.pRetry(run, {
|
|
3390
|
+
onFailedAttempt: (error) => {
|
|
3391
|
+
this.logger.error(`getTheUserWhoIsLiveStreaming() 第${error.attemptNumber}次失败: ${error.message}`);
|
|
3392
|
+
},
|
|
3393
|
+
retries: 3
|
|
3394
|
+
});
|
|
3406
3395
|
}
|
|
3407
3396
|
async getLiveRoomInfoStreamKey(roomId) {
|
|
3408
|
-
const
|
|
3409
|
-
|
|
3397
|
+
const run = async () => {
|
|
3398
|
+
const { data } = await this.client.get(`${GET_LIVE_ROOM_INFO_STREAM_KEY}?id=${roomId}`);
|
|
3399
|
+
return data;
|
|
3400
|
+
};
|
|
3401
|
+
return await this.pRetry(run, {
|
|
3402
|
+
onFailedAttempt: (error) => {
|
|
3403
|
+
this.logger.error(`getLiveRoomInfoStreamKey() 第${error.attemptNumber}次失败: ${error.message}`);
|
|
3404
|
+
},
|
|
3405
|
+
retries: 3
|
|
3406
|
+
});
|
|
3410
3407
|
}
|
|
3411
3408
|
async getLiveRoomInfoByUids(uids) {
|
|
3412
|
-
const
|
|
3413
|
-
|
|
3414
|
-
|
|
3409
|
+
const run = async () => {
|
|
3410
|
+
const params = uids.map((uid) => `uids[]=${uid}`).join("&");
|
|
3411
|
+
const { data } = await this.client.get(`${GET_LIVE_ROOMS_INFO}?${params}`);
|
|
3412
|
+
return data;
|
|
3413
|
+
};
|
|
3414
|
+
return await this.pRetry(run, {
|
|
3415
|
+
onFailedAttempt: (error) => {
|
|
3416
|
+
this.logger.error(`getLiveRoomInfoByUids() 第${error.attemptNumber}次失败: ${error.message}`);
|
|
3417
|
+
},
|
|
3418
|
+
retries: 3
|
|
3419
|
+
});
|
|
3415
3420
|
}
|
|
3416
3421
|
async getServerUTCTime() {
|
|
3417
|
-
const
|
|
3418
|
-
|
|
3419
|
-
|
|
3420
|
-
|
|
3421
|
-
|
|
3422
|
-
|
|
3423
|
-
|
|
3424
|
-
|
|
3422
|
+
const run = async () => {
|
|
3423
|
+
const { data } = await this.client.get(GET_SERVER_UTC_TIME);
|
|
3424
|
+
const regex = /Date\.UTC\((.*?)\)/;
|
|
3425
|
+
const match = data.match(regex);
|
|
3426
|
+
if (match) {
|
|
3427
|
+
const timestamp = new Function(`return Date.UTC(${match[1]})`)();
|
|
3428
|
+
return timestamp / 1e3;
|
|
3429
|
+
}
|
|
3430
|
+
throw new this.AbortError("解析服务器时间失败!");
|
|
3431
|
+
};
|
|
3432
|
+
return await this.pRetry(run, {
|
|
3433
|
+
onFailedAttempt: (error) => {
|
|
3434
|
+
this.logger.error(`getServerUTCTime() 第${error.attemptNumber}次失败: ${error.message}`);
|
|
3435
|
+
},
|
|
3436
|
+
retries: 3
|
|
3437
|
+
});
|
|
3425
3438
|
}
|
|
3426
3439
|
async getTimeNow() {
|
|
3427
|
-
const
|
|
3428
|
-
|
|
3440
|
+
const run = async () => {
|
|
3441
|
+
const { data } = await this.client.get(GET_TIME_NOW);
|
|
3442
|
+
return data;
|
|
3443
|
+
};
|
|
3444
|
+
return await this.pRetry(run, {
|
|
3445
|
+
onFailedAttempt: (error) => {
|
|
3446
|
+
this.logger.error(`getTimeNow() 第${error.attemptNumber}次失败: ${error.message}`);
|
|
3447
|
+
},
|
|
3448
|
+
retries: 3
|
|
3449
|
+
});
|
|
3429
3450
|
}
|
|
3430
3451
|
async getAllGroup() {
|
|
3431
|
-
const
|
|
3432
|
-
|
|
3452
|
+
const run = async () => {
|
|
3453
|
+
const { data } = await this.client.get(GET_ALL_GROUP);
|
|
3454
|
+
return data;
|
|
3455
|
+
};
|
|
3456
|
+
return await this.pRetry(run, {
|
|
3457
|
+
onFailedAttempt: (error) => {
|
|
3458
|
+
this.logger.error(`getAllGroup() 第${error.attemptNumber}次失败: ${error.message}`);
|
|
3459
|
+
},
|
|
3460
|
+
retries: 3
|
|
3461
|
+
});
|
|
3433
3462
|
}
|
|
3434
3463
|
async removeUserFromGroup(mid) {
|
|
3435
|
-
const
|
|
3436
|
-
|
|
3437
|
-
|
|
3438
|
-
|
|
3439
|
-
|
|
3440
|
-
|
|
3441
|
-
|
|
3464
|
+
const run = async () => {
|
|
3465
|
+
const csrf = this.getCSRF();
|
|
3466
|
+
const { data } = await this.client.post(MODIFY_GROUP_MEMBER, {
|
|
3467
|
+
fids: mid,
|
|
3468
|
+
tagids: 0,
|
|
3469
|
+
csrf
|
|
3470
|
+
}, { headers: { "Content-Type": "application/x-www-form-urlencoded" } });
|
|
3471
|
+
return data;
|
|
3472
|
+
};
|
|
3473
|
+
return await this.pRetry(run, {
|
|
3474
|
+
onFailedAttempt: (error) => {
|
|
3475
|
+
this.logger.error(`removeUserFromGroup() 第${error.attemptNumber}次失败: ${error.message}`);
|
|
3476
|
+
},
|
|
3477
|
+
retries: 3
|
|
3478
|
+
});
|
|
3442
3479
|
}
|
|
3443
3480
|
async copyUserToGroup(mid, groupId) {
|
|
3444
|
-
const
|
|
3445
|
-
|
|
3446
|
-
|
|
3447
|
-
|
|
3448
|
-
|
|
3449
|
-
|
|
3450
|
-
|
|
3481
|
+
const run = async () => {
|
|
3482
|
+
const csrf = this.getCSRF();
|
|
3483
|
+
const { data } = await this.client.post(COPY_USER_TO_GROUP, {
|
|
3484
|
+
fids: mid,
|
|
3485
|
+
tagids: groupId,
|
|
3486
|
+
csrf
|
|
3487
|
+
}, { headers: { "Content-Type": "application/x-www-form-urlencoded" } });
|
|
3488
|
+
return data;
|
|
3489
|
+
};
|
|
3490
|
+
return await this.pRetry(run, {
|
|
3491
|
+
onFailedAttempt: (error) => {
|
|
3492
|
+
this.logger.error(`copyUserToGroup() 第${error.attemptNumber}次失败: ${error.message}`);
|
|
3493
|
+
},
|
|
3494
|
+
retries: 3
|
|
3495
|
+
});
|
|
3451
3496
|
}
|
|
3452
3497
|
async getUserSpaceDynamic(mid) {
|
|
3453
|
-
const
|
|
3454
|
-
|
|
3498
|
+
const run = async () => {
|
|
3499
|
+
const { data } = await this.client.get(`${GET_USER_SPACE_DYNAMIC_LIST}&host_mid=${mid}`);
|
|
3500
|
+
return data;
|
|
3501
|
+
};
|
|
3502
|
+
return await this.pRetry(run, {
|
|
3503
|
+
onFailedAttempt: (error) => {
|
|
3504
|
+
this.logger.error(`getUserSpaceDynamic() 第${error.attemptNumber}次失败: ${error.message}`);
|
|
3505
|
+
},
|
|
3506
|
+
retries: 3
|
|
3507
|
+
});
|
|
3455
3508
|
}
|
|
3456
3509
|
async createGroup(tag) {
|
|
3457
|
-
const
|
|
3458
|
-
|
|
3459
|
-
|
|
3460
|
-
|
|
3461
|
-
|
|
3510
|
+
const run = async () => {
|
|
3511
|
+
const { data } = await this.client.post(CREATE_GROUP, {
|
|
3512
|
+
tag,
|
|
3513
|
+
csrf: this.getCSRF()
|
|
3514
|
+
}, { headers: { "Content-Type": "application/x-www-form-urlencoded" } });
|
|
3515
|
+
return data;
|
|
3516
|
+
};
|
|
3517
|
+
return await this.pRetry(run, {
|
|
3518
|
+
onFailedAttempt: (error) => {
|
|
3519
|
+
this.logger.error(`createGroup() 第${error.attemptNumber}次失败: ${error.message}`);
|
|
3520
|
+
},
|
|
3521
|
+
retries: 3
|
|
3522
|
+
});
|
|
3462
3523
|
}
|
|
3463
3524
|
async getAllDynamic() {
|
|
3464
|
-
const
|
|
3465
|
-
|
|
3525
|
+
const run = async () => {
|
|
3526
|
+
const { data } = await this.client.get(GET_ALL_DYNAMIC_LIST);
|
|
3527
|
+
return data;
|
|
3528
|
+
};
|
|
3529
|
+
return await this.pRetry(run, {
|
|
3530
|
+
onFailedAttempt: (error) => {
|
|
3531
|
+
this.logger.error(`getAllDynamic() 第${error.attemptNumber}次失败: ${error.message}`);
|
|
3532
|
+
},
|
|
3533
|
+
retries: 3
|
|
3534
|
+
});
|
|
3466
3535
|
}
|
|
3467
3536
|
async hasNewDynamic(updateBaseline) {
|
|
3468
|
-
const
|
|
3469
|
-
|
|
3537
|
+
const run = async () => {
|
|
3538
|
+
const { data } = await this.client.get(`${HAS_NEW_DYNAMIC}?update_baseline=${updateBaseline}`);
|
|
3539
|
+
return data;
|
|
3540
|
+
};
|
|
3541
|
+
return await this.pRetry(run, {
|
|
3542
|
+
onFailedAttempt: (error) => {
|
|
3543
|
+
this.logger.error(`hasNewDynamic() 第${error.attemptNumber}次失败: ${error.message}`);
|
|
3544
|
+
},
|
|
3545
|
+
retries: 3
|
|
3546
|
+
});
|
|
3470
3547
|
}
|
|
3471
3548
|
async follow(fid) {
|
|
3472
|
-
const
|
|
3473
|
-
|
|
3474
|
-
|
|
3475
|
-
|
|
3476
|
-
|
|
3477
|
-
|
|
3478
|
-
|
|
3549
|
+
const run = async () => {
|
|
3550
|
+
const { data } = await this.client.post(MODIFY_RELATION, {
|
|
3551
|
+
fid,
|
|
3552
|
+
act: 1,
|
|
3553
|
+
re_src: 11,
|
|
3554
|
+
csrf: this.getCSRF()
|
|
3555
|
+
}, { headers: { "Content-Type": "application/x-www-form-urlencoded" } });
|
|
3556
|
+
return data;
|
|
3557
|
+
};
|
|
3558
|
+
return await this.pRetry(run, {
|
|
3559
|
+
onFailedAttempt: (error) => {
|
|
3560
|
+
this.logger.error(`follow() 第${error.attemptNumber}次失败: ${error.message}`);
|
|
3561
|
+
},
|
|
3562
|
+
retries: 3
|
|
3563
|
+
});
|
|
3479
3564
|
}
|
|
3480
3565
|
async getRelationGroupDetail(tagid) {
|
|
3481
|
-
const
|
|
3482
|
-
|
|
3566
|
+
const run = async () => {
|
|
3567
|
+
const { data } = await this.client.get(`${GET_RELATION_GROUP_DETAIL}?tagid=${tagid}`);
|
|
3568
|
+
return data;
|
|
3569
|
+
};
|
|
3570
|
+
return await this.pRetry(run, {
|
|
3571
|
+
onFailedAttempt: (error) => {
|
|
3572
|
+
this.logger.error(`getRelationGroupDetail() 第${error.attemptNumber}次失败: ${error.message}`);
|
|
3573
|
+
},
|
|
3574
|
+
retries: 3
|
|
3575
|
+
});
|
|
3483
3576
|
}
|
|
3484
3577
|
async getCookieInfo(refreshToken) {
|
|
3485
|
-
const
|
|
3486
|
-
this.
|
|
3487
|
-
|
|
3578
|
+
const run = async () => {
|
|
3579
|
+
const { data } = await this.client.get(`${GET_COOKIES_INFO}?csrf=${refreshToken}`).catch((e) => {
|
|
3580
|
+
this.logger.info(e.message);
|
|
3581
|
+
return null;
|
|
3582
|
+
});
|
|
3583
|
+
return data;
|
|
3584
|
+
};
|
|
3585
|
+
return await this.pRetry(run, {
|
|
3586
|
+
onFailedAttempt: (error) => {
|
|
3587
|
+
this.logger.error(`getCookieInfo() 第${error.attemptNumber}次失败: ${error.message}`);
|
|
3588
|
+
},
|
|
3589
|
+
retries: 3
|
|
3488
3590
|
});
|
|
3489
|
-
return data;
|
|
3490
3591
|
}
|
|
3491
3592
|
async getUserInfo(mid) {
|
|
3492
|
-
|
|
3493
|
-
|
|
3494
|
-
|
|
3495
|
-
|
|
3496
|
-
|
|
3497
|
-
|
|
3498
|
-
|
|
3593
|
+
const run = async () => {
|
|
3594
|
+
if (mid === "11783021") {
|
|
3595
|
+
console.log("检测到番剧出差UID,跳过远程用户接口访问");
|
|
3596
|
+
return bangumiTripData;
|
|
3597
|
+
}
|
|
3598
|
+
const wbi = await this.getWbi({ mid });
|
|
3599
|
+
const { data } = await this.client.get(`${GET_USER_INFO}?${wbi}`);
|
|
3600
|
+
return data;
|
|
3601
|
+
};
|
|
3602
|
+
return await this.pRetry(run, {
|
|
3603
|
+
onFailedAttempt: (error) => {
|
|
3604
|
+
this.logger.error(`getUserInfo() 第${error.attemptNumber}次失败: ${error.message}`);
|
|
3605
|
+
},
|
|
3606
|
+
retries: 3
|
|
3607
|
+
});
|
|
3499
3608
|
}
|
|
3500
3609
|
async getWbiKeys() {
|
|
3501
|
-
const
|
|
3502
|
-
|
|
3503
|
-
|
|
3504
|
-
|
|
3505
|
-
|
|
3610
|
+
const run = async () => {
|
|
3611
|
+
const { data } = await this.client.get("https://api.bilibili.com/x/web-interface/nav");
|
|
3612
|
+
const { data: { wbi_img: { img_url, sub_url } } } = data;
|
|
3613
|
+
return {
|
|
3614
|
+
img_key: img_url.slice(img_url.lastIndexOf("/") + 1, img_url.lastIndexOf(".")),
|
|
3615
|
+
sub_key: sub_url.slice(sub_url.lastIndexOf("/") + 1, sub_url.lastIndexOf("."))
|
|
3616
|
+
};
|
|
3506
3617
|
};
|
|
3618
|
+
return await this.pRetry(run, {
|
|
3619
|
+
onFailedAttempt: (error) => {
|
|
3620
|
+
this.logger.error(`getWbiKeys() 第${error.attemptNumber}次失败: ${error.message}`);
|
|
3621
|
+
},
|
|
3622
|
+
retries: 3
|
|
3623
|
+
});
|
|
3507
3624
|
}
|
|
3508
3625
|
async getMyselfInfo() {
|
|
3509
|
-
const
|
|
3510
|
-
|
|
3626
|
+
const run = async () => {
|
|
3627
|
+
const { data } = await this.client.get(GET_MYSELF_INFO);
|
|
3628
|
+
return data;
|
|
3629
|
+
};
|
|
3630
|
+
return await this.pRetry(run, {
|
|
3631
|
+
onFailedAttempt: (error) => {
|
|
3632
|
+
this.logger.error(`getMyselfInfo() 第${error.attemptNumber}次失败: ${error.message}`);
|
|
3633
|
+
},
|
|
3634
|
+
retries: 3
|
|
3635
|
+
});
|
|
3511
3636
|
}
|
|
3512
3637
|
async getLoginQRCode() {
|
|
3513
|
-
const
|
|
3514
|
-
|
|
3638
|
+
const run = async () => {
|
|
3639
|
+
const { data } = await this.client.get(GET_LOGIN_QRCODE);
|
|
3640
|
+
return data;
|
|
3641
|
+
};
|
|
3642
|
+
return await this.pRetry(run, {
|
|
3643
|
+
onFailedAttempt: (error) => {
|
|
3644
|
+
this.logger.error(`getLoginQRCode() 第${error.attemptNumber}次失败: ${error.message}`);
|
|
3645
|
+
},
|
|
3646
|
+
retries: 3
|
|
3647
|
+
});
|
|
3515
3648
|
}
|
|
3516
3649
|
async getLoginStatus(qrcodeKey) {
|
|
3517
|
-
const
|
|
3518
|
-
|
|
3650
|
+
const run = async () => {
|
|
3651
|
+
const { data } = await this.client.get(`${GET_LOGIN_STATUS}?qrcode_key=${qrcodeKey}`);
|
|
3652
|
+
return data;
|
|
3653
|
+
};
|
|
3654
|
+
return await this.pRetry(run, {
|
|
3655
|
+
onFailedAttempt: (error) => {
|
|
3656
|
+
this.logger.error(`getLoginStatus() 第${error.attemptNumber}次失败: ${error.message}`);
|
|
3657
|
+
},
|
|
3658
|
+
retries: 3
|
|
3659
|
+
});
|
|
3519
3660
|
}
|
|
3520
3661
|
async getLiveRoomInfo(roomId) {
|
|
3521
|
-
const
|
|
3522
|
-
|
|
3662
|
+
const run = async () => {
|
|
3663
|
+
const { data } = await this.client.get(`${GET_LIVE_ROOM_INFO}?room_id=${roomId}`);
|
|
3664
|
+
return data;
|
|
3665
|
+
};
|
|
3666
|
+
return await this.pRetry(run, {
|
|
3667
|
+
onFailedAttempt: (error) => {
|
|
3668
|
+
this.logger.error(`getLiveRoomInfo() 第${error.attemptNumber}次失败: ${error.message}`);
|
|
3669
|
+
},
|
|
3670
|
+
retries: 3
|
|
3671
|
+
});
|
|
3523
3672
|
}
|
|
3524
3673
|
async getMasterInfo(mid) {
|
|
3525
|
-
const
|
|
3526
|
-
|
|
3674
|
+
const run = async () => {
|
|
3675
|
+
const { data } = await this.client.get(`${GET_MASTER_INFO}?uid=${mid}`);
|
|
3676
|
+
return data;
|
|
3677
|
+
};
|
|
3678
|
+
return await this.pRetry(run, {
|
|
3679
|
+
onFailedAttempt: (error) => {
|
|
3680
|
+
this.logger.error(`getMasterInfo() 第${error.attemptNumber}次失败: ${error.message}`);
|
|
3681
|
+
},
|
|
3682
|
+
retries: 3
|
|
3683
|
+
});
|
|
3527
3684
|
}
|
|
3528
3685
|
disposeNotifier() {
|
|
3529
3686
|
if (this.loginNotifier) this.loginNotifier.dispose();
|
|
@@ -3807,138 +3964,6 @@ var BiliAPI = class extends koishi.Service {
|
|
|
3807
3964
|
return { data: data.data };
|
|
3808
3965
|
}
|
|
3809
3966
|
};
|
|
3810
|
-
(0, __oxc_project_runtime_helpers_decorate.default)([Retry({
|
|
3811
|
-
attempts: 3,
|
|
3812
|
-
onFailure(error, attempts) {
|
|
3813
|
-
this.logger.error(`getTheUserWhoIsLiveStreaming() 第${attempts}次失败: ${error.message}`);
|
|
3814
|
-
}
|
|
3815
|
-
})], BiliAPI.prototype, "getTheUserWhoIsLiveStreaming", null);
|
|
3816
|
-
(0, __oxc_project_runtime_helpers_decorate.default)([Retry({
|
|
3817
|
-
attempts: 3,
|
|
3818
|
-
onFailure(error, attempts) {
|
|
3819
|
-
this.logger.error(`getLiveRoomInfoStreamKey() 第${attempts}次失败: ${error.message}`);
|
|
3820
|
-
}
|
|
3821
|
-
})], BiliAPI.prototype, "getLiveRoomInfoStreamKey", null);
|
|
3822
|
-
(0, __oxc_project_runtime_helpers_decorate.default)([Retry({
|
|
3823
|
-
attempts: 3,
|
|
3824
|
-
onFailure(error, attempts) {
|
|
3825
|
-
this.logger.error(`getLiveRoomInfoByUids() 第${attempts}次失败: ${error.message}`);
|
|
3826
|
-
}
|
|
3827
|
-
})], BiliAPI.prototype, "getLiveRoomInfoByUids", null);
|
|
3828
|
-
(0, __oxc_project_runtime_helpers_decorate.default)([Retry({
|
|
3829
|
-
attempts: 3,
|
|
3830
|
-
onFailure(error, attempts) {
|
|
3831
|
-
this.logger.error(`getServerUTCTime() 第${attempts}次失败: ${error.message}`);
|
|
3832
|
-
}
|
|
3833
|
-
})], BiliAPI.prototype, "getServerUTCTime", null);
|
|
3834
|
-
(0, __oxc_project_runtime_helpers_decorate.default)([Retry({
|
|
3835
|
-
attempts: 3,
|
|
3836
|
-
onFailure(error, attempts) {
|
|
3837
|
-
this.logger.error(`getTimeNow() 第${attempts}次失败: ${error.message}`);
|
|
3838
|
-
}
|
|
3839
|
-
})], BiliAPI.prototype, "getTimeNow", null);
|
|
3840
|
-
(0, __oxc_project_runtime_helpers_decorate.default)([Retry({
|
|
3841
|
-
attempts: 3,
|
|
3842
|
-
onFailure(error, attempts) {
|
|
3843
|
-
this.logger.error(`getAllGroup() 第${attempts}次失败: ${error.message}`);
|
|
3844
|
-
}
|
|
3845
|
-
})], BiliAPI.prototype, "getAllGroup", null);
|
|
3846
|
-
(0, __oxc_project_runtime_helpers_decorate.default)([Retry({
|
|
3847
|
-
attempts: 3,
|
|
3848
|
-
onFailure(error, attempts) {
|
|
3849
|
-
this.logger.error(`removeUserFromGroup() 第${attempts}次失败: ${error.message}`);
|
|
3850
|
-
}
|
|
3851
|
-
})], BiliAPI.prototype, "removeUserFromGroup", null);
|
|
3852
|
-
(0, __oxc_project_runtime_helpers_decorate.default)([Retry({
|
|
3853
|
-
attempts: 3,
|
|
3854
|
-
onFailure(error, attempts) {
|
|
3855
|
-
this.logger.error(`copyUserToGroup() 第${attempts}次失败: ${error.message}`);
|
|
3856
|
-
}
|
|
3857
|
-
})], BiliAPI.prototype, "copyUserToGroup", null);
|
|
3858
|
-
(0, __oxc_project_runtime_helpers_decorate.default)([Retry({
|
|
3859
|
-
attempts: 3,
|
|
3860
|
-
onFailure(error, attempts) {
|
|
3861
|
-
this.logger.error(`getUserSpaceDynamic() 第${attempts}次失败: ${error.message}`);
|
|
3862
|
-
}
|
|
3863
|
-
})], BiliAPI.prototype, "getUserSpaceDynamic", null);
|
|
3864
|
-
(0, __oxc_project_runtime_helpers_decorate.default)([Retry({
|
|
3865
|
-
attempts: 3,
|
|
3866
|
-
onFailure(error, attempts) {
|
|
3867
|
-
this.logger.error(`createGroup() 第${attempts}次失败: ${error.message}`);
|
|
3868
|
-
}
|
|
3869
|
-
})], BiliAPI.prototype, "createGroup", null);
|
|
3870
|
-
(0, __oxc_project_runtime_helpers_decorate.default)([Retry({
|
|
3871
|
-
attempts: 3,
|
|
3872
|
-
onFailure(error, attempts) {
|
|
3873
|
-
this.logger.error(`getAllDynamic() 第${attempts}次失败: ${error.message}`);
|
|
3874
|
-
}
|
|
3875
|
-
})], BiliAPI.prototype, "getAllDynamic", null);
|
|
3876
|
-
(0, __oxc_project_runtime_helpers_decorate.default)([Retry({
|
|
3877
|
-
attempts: 3,
|
|
3878
|
-
onFailure(error, attempts) {
|
|
3879
|
-
this.logger.error(`hasNewDynamic() 第${attempts}次失败: ${error.message}`);
|
|
3880
|
-
}
|
|
3881
|
-
})], BiliAPI.prototype, "hasNewDynamic", null);
|
|
3882
|
-
(0, __oxc_project_runtime_helpers_decorate.default)([Retry({
|
|
3883
|
-
attempts: 3,
|
|
3884
|
-
onFailure(error, attempts) {
|
|
3885
|
-
this.logger.error(`follow() 第${attempts}次失败: ${error.message}`);
|
|
3886
|
-
}
|
|
3887
|
-
})], BiliAPI.prototype, "follow", null);
|
|
3888
|
-
(0, __oxc_project_runtime_helpers_decorate.default)([Retry({
|
|
3889
|
-
attempts: 3,
|
|
3890
|
-
onFailure(error, attempts) {
|
|
3891
|
-
this.logger.error(`getRelationGroupDetail() 第${attempts}次失败: ${error.message}`);
|
|
3892
|
-
}
|
|
3893
|
-
})], BiliAPI.prototype, "getRelationGroupDetail", null);
|
|
3894
|
-
(0, __oxc_project_runtime_helpers_decorate.default)([Retry({
|
|
3895
|
-
attempts: 3,
|
|
3896
|
-
onFailure(error, attempts) {
|
|
3897
|
-
this.logger.error(`getCookieInfo() 第${attempts}次失败: ${error.message}`);
|
|
3898
|
-
}
|
|
3899
|
-
})], BiliAPI.prototype, "getCookieInfo", null);
|
|
3900
|
-
(0, __oxc_project_runtime_helpers_decorate.default)([Retry({
|
|
3901
|
-
attempts: 3,
|
|
3902
|
-
onFailure(error, attempts) {
|
|
3903
|
-
this.logger.error(`getUserInfo() 第${attempts}次失败: ${error.message}`);
|
|
3904
|
-
}
|
|
3905
|
-
})], BiliAPI.prototype, "getUserInfo", null);
|
|
3906
|
-
(0, __oxc_project_runtime_helpers_decorate.default)([Retry({
|
|
3907
|
-
attempts: 3,
|
|
3908
|
-
onFailure(error, attempts) {
|
|
3909
|
-
this.logger.error(`getWbiKeys() 第${attempts}次失败: ${error.message}`);
|
|
3910
|
-
}
|
|
3911
|
-
})], BiliAPI.prototype, "getWbiKeys", null);
|
|
3912
|
-
(0, __oxc_project_runtime_helpers_decorate.default)([Retry({
|
|
3913
|
-
attempts: 3,
|
|
3914
|
-
onFailure(error, attempts) {
|
|
3915
|
-
this.logger.error(`getMyselfInfo() 第${attempts}次失败: ${error.message}`);
|
|
3916
|
-
}
|
|
3917
|
-
})], BiliAPI.prototype, "getMyselfInfo", null);
|
|
3918
|
-
(0, __oxc_project_runtime_helpers_decorate.default)([Retry({
|
|
3919
|
-
attempts: 3,
|
|
3920
|
-
onFailure(error, attempts) {
|
|
3921
|
-
this.logger.error(`getLoginQRCode() 第${attempts}次失败: ${error.message}`);
|
|
3922
|
-
}
|
|
3923
|
-
})], BiliAPI.prototype, "getLoginQRCode", null);
|
|
3924
|
-
(0, __oxc_project_runtime_helpers_decorate.default)([Retry({
|
|
3925
|
-
attempts: 3,
|
|
3926
|
-
onFailure(error, attempts) {
|
|
3927
|
-
this.logger.error(`getLoginStatus() 第${attempts}次失败: ${error.message}`);
|
|
3928
|
-
}
|
|
3929
|
-
})], BiliAPI.prototype, "getLoginStatus", null);
|
|
3930
|
-
(0, __oxc_project_runtime_helpers_decorate.default)([Retry({
|
|
3931
|
-
attempts: 3,
|
|
3932
|
-
onFailure(error, attempts) {
|
|
3933
|
-
this.logger.error(`getLiveRoomInfo() 第${attempts}次失败: ${error.message}`);
|
|
3934
|
-
}
|
|
3935
|
-
})], BiliAPI.prototype, "getLiveRoomInfo", null);
|
|
3936
|
-
(0, __oxc_project_runtime_helpers_decorate.default)([Retry({
|
|
3937
|
-
attempts: 3,
|
|
3938
|
-
onFailure(error, attempts) {
|
|
3939
|
-
this.logger.error(`getMasterInfo() 第${attempts}次失败: ${error.message}`);
|
|
3940
|
-
}
|
|
3941
|
-
})], BiliAPI.prototype, "getMasterInfo", null);
|
|
3942
3967
|
(function(_BiliAPI) {
|
|
3943
3968
|
const Config$1 = _BiliAPI.Config = koishi.Schema.object({
|
|
3944
3969
|
userAgent: koishi.Schema.string(),
|
package/lib/index.mjs
CHANGED
|
@@ -17,7 +17,6 @@ import https from "node:https";
|
|
|
17
17
|
import axios from "axios";
|
|
18
18
|
import { Cookie, CookieJar } from "tough-cookie";
|
|
19
19
|
import { JSDOM } from "jsdom";
|
|
20
|
-
import _decorate from "@oxc-project/runtime/helpers/decorate";
|
|
21
20
|
import { startListen } from "@akokko/blive-message-listener";
|
|
22
21
|
|
|
23
22
|
//#region rolldown:runtime
|
|
@@ -103,22 +102,6 @@ const BAConfigSchema = Schema.object({
|
|
|
103
102
|
|
|
104
103
|
//#endregion
|
|
105
104
|
//#region src/utils/index.ts
|
|
106
|
-
function Retry(options = { attempts: 3 }) {
|
|
107
|
-
return (_target, _propertyKey, descriptor) => {
|
|
108
|
-
const originalMethod = descriptor.value;
|
|
109
|
-
descriptor.value = async function(...args) {
|
|
110
|
-
let lastError;
|
|
111
|
-
for (let i = 0; i < options.attempts; i++) try {
|
|
112
|
-
return await originalMethod.apply(this, args);
|
|
113
|
-
} catch (error) {
|
|
114
|
-
lastError = error;
|
|
115
|
-
if (options.onFailure) await options.onFailure.call(this, lastError, i + 1);
|
|
116
|
-
}
|
|
117
|
-
throw lastError;
|
|
118
|
-
};
|
|
119
|
-
return descriptor;
|
|
120
|
-
};
|
|
121
|
-
}
|
|
122
105
|
/**
|
|
123
106
|
* 高阶函数:为函数添加锁机制
|
|
124
107
|
* @param {Function} fn - 需要包装的原始函数
|
|
@@ -624,14 +607,8 @@ var ComRegister = class {
|
|
|
624
607
|
await session.send("请手动填入 gt 和 challenge 后点击生成进行验证,验证完成后点击结果,根据提示输入对应validate");
|
|
625
608
|
await session.send(`gt:${data.geetest.gt}`);
|
|
626
609
|
await session.send(`challenge:${data.geetest.challenge}`);
|
|
627
|
-
await session.send("
|
|
628
|
-
const validate = await (
|
|
629
|
-
while (true) {
|
|
630
|
-
const validate$1 = await session.prompt();
|
|
631
|
-
if (validate$1?.startsWith("val ")) return validate$1.slice(4);
|
|
632
|
-
else await session.send("请输入正确的validate,格式为 val <validate>");
|
|
633
|
-
}
|
|
634
|
-
})();
|
|
610
|
+
await session.send("请直接输入validate");
|
|
611
|
+
const validate = await session.prompt();
|
|
635
612
|
const seccode = `${validate}|jordan`;
|
|
636
613
|
const { data: validateCaptchaData } = await ctx.ba.validateCaptcha(data.geetest.challenge, data.token, validate, seccode);
|
|
637
614
|
if (validateCaptchaData?.is_valid !== 1) return "验证不成功!";
|
|
@@ -3313,11 +3290,15 @@ var BiliAPI = class extends Service {
|
|
|
3313
3290
|
sub_key: ""
|
|
3314
3291
|
};
|
|
3315
3292
|
updateJob;
|
|
3293
|
+
pRetry;
|
|
3294
|
+
AbortError;
|
|
3316
3295
|
constructor(ctx, config) {
|
|
3317
3296
|
super(ctx, "ba");
|
|
3318
3297
|
this.apiConfig = config;
|
|
3319
3298
|
}
|
|
3320
3299
|
async start() {
|
|
3300
|
+
this.pRetry = (await import("p-retry")).default;
|
|
3301
|
+
this.AbortError = (await import("p-retry")).AbortError;
|
|
3321
3302
|
const CacheableLookup = (await import("cacheable-lookup")).default;
|
|
3322
3303
|
this.cacheable = new CacheableLookup();
|
|
3323
3304
|
this.cacheable.install(http.globalAgent);
|
|
@@ -3382,129 +3363,305 @@ var BiliAPI = class extends Service {
|
|
|
3382
3363
|
return decrypted.toString();
|
|
3383
3364
|
}
|
|
3384
3365
|
async getTheUserWhoIsLiveStreaming() {
|
|
3385
|
-
const
|
|
3386
|
-
|
|
3366
|
+
const run = async () => {
|
|
3367
|
+
const { data } = await this.client.get(GET_LATEST_UPDATED_UPS);
|
|
3368
|
+
return data;
|
|
3369
|
+
};
|
|
3370
|
+
return await this.pRetry(run, {
|
|
3371
|
+
onFailedAttempt: (error) => {
|
|
3372
|
+
this.logger.error(`getTheUserWhoIsLiveStreaming() 第${error.attemptNumber}次失败: ${error.message}`);
|
|
3373
|
+
},
|
|
3374
|
+
retries: 3
|
|
3375
|
+
});
|
|
3387
3376
|
}
|
|
3388
3377
|
async getLiveRoomInfoStreamKey(roomId) {
|
|
3389
|
-
const
|
|
3390
|
-
|
|
3378
|
+
const run = async () => {
|
|
3379
|
+
const { data } = await this.client.get(`${GET_LIVE_ROOM_INFO_STREAM_KEY}?id=${roomId}`);
|
|
3380
|
+
return data;
|
|
3381
|
+
};
|
|
3382
|
+
return await this.pRetry(run, {
|
|
3383
|
+
onFailedAttempt: (error) => {
|
|
3384
|
+
this.logger.error(`getLiveRoomInfoStreamKey() 第${error.attemptNumber}次失败: ${error.message}`);
|
|
3385
|
+
},
|
|
3386
|
+
retries: 3
|
|
3387
|
+
});
|
|
3391
3388
|
}
|
|
3392
3389
|
async getLiveRoomInfoByUids(uids) {
|
|
3393
|
-
const
|
|
3394
|
-
|
|
3395
|
-
|
|
3390
|
+
const run = async () => {
|
|
3391
|
+
const params = uids.map((uid) => `uids[]=${uid}`).join("&");
|
|
3392
|
+
const { data } = await this.client.get(`${GET_LIVE_ROOMS_INFO}?${params}`);
|
|
3393
|
+
return data;
|
|
3394
|
+
};
|
|
3395
|
+
return await this.pRetry(run, {
|
|
3396
|
+
onFailedAttempt: (error) => {
|
|
3397
|
+
this.logger.error(`getLiveRoomInfoByUids() 第${error.attemptNumber}次失败: ${error.message}`);
|
|
3398
|
+
},
|
|
3399
|
+
retries: 3
|
|
3400
|
+
});
|
|
3396
3401
|
}
|
|
3397
3402
|
async getServerUTCTime() {
|
|
3398
|
-
const
|
|
3399
|
-
|
|
3400
|
-
|
|
3401
|
-
|
|
3402
|
-
|
|
3403
|
-
|
|
3404
|
-
|
|
3405
|
-
|
|
3403
|
+
const run = async () => {
|
|
3404
|
+
const { data } = await this.client.get(GET_SERVER_UTC_TIME);
|
|
3405
|
+
const regex = /Date\.UTC\((.*?)\)/;
|
|
3406
|
+
const match = data.match(regex);
|
|
3407
|
+
if (match) {
|
|
3408
|
+
const timestamp = new Function(`return Date.UTC(${match[1]})`)();
|
|
3409
|
+
return timestamp / 1e3;
|
|
3410
|
+
}
|
|
3411
|
+
throw new this.AbortError("解析服务器时间失败!");
|
|
3412
|
+
};
|
|
3413
|
+
return await this.pRetry(run, {
|
|
3414
|
+
onFailedAttempt: (error) => {
|
|
3415
|
+
this.logger.error(`getServerUTCTime() 第${error.attemptNumber}次失败: ${error.message}`);
|
|
3416
|
+
},
|
|
3417
|
+
retries: 3
|
|
3418
|
+
});
|
|
3406
3419
|
}
|
|
3407
3420
|
async getTimeNow() {
|
|
3408
|
-
const
|
|
3409
|
-
|
|
3421
|
+
const run = async () => {
|
|
3422
|
+
const { data } = await this.client.get(GET_TIME_NOW);
|
|
3423
|
+
return data;
|
|
3424
|
+
};
|
|
3425
|
+
return await this.pRetry(run, {
|
|
3426
|
+
onFailedAttempt: (error) => {
|
|
3427
|
+
this.logger.error(`getTimeNow() 第${error.attemptNumber}次失败: ${error.message}`);
|
|
3428
|
+
},
|
|
3429
|
+
retries: 3
|
|
3430
|
+
});
|
|
3410
3431
|
}
|
|
3411
3432
|
async getAllGroup() {
|
|
3412
|
-
const
|
|
3413
|
-
|
|
3433
|
+
const run = async () => {
|
|
3434
|
+
const { data } = await this.client.get(GET_ALL_GROUP);
|
|
3435
|
+
return data;
|
|
3436
|
+
};
|
|
3437
|
+
return await this.pRetry(run, {
|
|
3438
|
+
onFailedAttempt: (error) => {
|
|
3439
|
+
this.logger.error(`getAllGroup() 第${error.attemptNumber}次失败: ${error.message}`);
|
|
3440
|
+
},
|
|
3441
|
+
retries: 3
|
|
3442
|
+
});
|
|
3414
3443
|
}
|
|
3415
3444
|
async removeUserFromGroup(mid) {
|
|
3416
|
-
const
|
|
3417
|
-
|
|
3418
|
-
|
|
3419
|
-
|
|
3420
|
-
|
|
3421
|
-
|
|
3422
|
-
|
|
3445
|
+
const run = async () => {
|
|
3446
|
+
const csrf = this.getCSRF();
|
|
3447
|
+
const { data } = await this.client.post(MODIFY_GROUP_MEMBER, {
|
|
3448
|
+
fids: mid,
|
|
3449
|
+
tagids: 0,
|
|
3450
|
+
csrf
|
|
3451
|
+
}, { headers: { "Content-Type": "application/x-www-form-urlencoded" } });
|
|
3452
|
+
return data;
|
|
3453
|
+
};
|
|
3454
|
+
return await this.pRetry(run, {
|
|
3455
|
+
onFailedAttempt: (error) => {
|
|
3456
|
+
this.logger.error(`removeUserFromGroup() 第${error.attemptNumber}次失败: ${error.message}`);
|
|
3457
|
+
},
|
|
3458
|
+
retries: 3
|
|
3459
|
+
});
|
|
3423
3460
|
}
|
|
3424
3461
|
async copyUserToGroup(mid, groupId) {
|
|
3425
|
-
const
|
|
3426
|
-
|
|
3427
|
-
|
|
3428
|
-
|
|
3429
|
-
|
|
3430
|
-
|
|
3431
|
-
|
|
3462
|
+
const run = async () => {
|
|
3463
|
+
const csrf = this.getCSRF();
|
|
3464
|
+
const { data } = await this.client.post(COPY_USER_TO_GROUP, {
|
|
3465
|
+
fids: mid,
|
|
3466
|
+
tagids: groupId,
|
|
3467
|
+
csrf
|
|
3468
|
+
}, { headers: { "Content-Type": "application/x-www-form-urlencoded" } });
|
|
3469
|
+
return data;
|
|
3470
|
+
};
|
|
3471
|
+
return await this.pRetry(run, {
|
|
3472
|
+
onFailedAttempt: (error) => {
|
|
3473
|
+
this.logger.error(`copyUserToGroup() 第${error.attemptNumber}次失败: ${error.message}`);
|
|
3474
|
+
},
|
|
3475
|
+
retries: 3
|
|
3476
|
+
});
|
|
3432
3477
|
}
|
|
3433
3478
|
async getUserSpaceDynamic(mid) {
|
|
3434
|
-
const
|
|
3435
|
-
|
|
3479
|
+
const run = async () => {
|
|
3480
|
+
const { data } = await this.client.get(`${GET_USER_SPACE_DYNAMIC_LIST}&host_mid=${mid}`);
|
|
3481
|
+
return data;
|
|
3482
|
+
};
|
|
3483
|
+
return await this.pRetry(run, {
|
|
3484
|
+
onFailedAttempt: (error) => {
|
|
3485
|
+
this.logger.error(`getUserSpaceDynamic() 第${error.attemptNumber}次失败: ${error.message}`);
|
|
3486
|
+
},
|
|
3487
|
+
retries: 3
|
|
3488
|
+
});
|
|
3436
3489
|
}
|
|
3437
3490
|
async createGroup(tag) {
|
|
3438
|
-
const
|
|
3439
|
-
|
|
3440
|
-
|
|
3441
|
-
|
|
3442
|
-
|
|
3491
|
+
const run = async () => {
|
|
3492
|
+
const { data } = await this.client.post(CREATE_GROUP, {
|
|
3493
|
+
tag,
|
|
3494
|
+
csrf: this.getCSRF()
|
|
3495
|
+
}, { headers: { "Content-Type": "application/x-www-form-urlencoded" } });
|
|
3496
|
+
return data;
|
|
3497
|
+
};
|
|
3498
|
+
return await this.pRetry(run, {
|
|
3499
|
+
onFailedAttempt: (error) => {
|
|
3500
|
+
this.logger.error(`createGroup() 第${error.attemptNumber}次失败: ${error.message}`);
|
|
3501
|
+
},
|
|
3502
|
+
retries: 3
|
|
3503
|
+
});
|
|
3443
3504
|
}
|
|
3444
3505
|
async getAllDynamic() {
|
|
3445
|
-
const
|
|
3446
|
-
|
|
3506
|
+
const run = async () => {
|
|
3507
|
+
const { data } = await this.client.get(GET_ALL_DYNAMIC_LIST);
|
|
3508
|
+
return data;
|
|
3509
|
+
};
|
|
3510
|
+
return await this.pRetry(run, {
|
|
3511
|
+
onFailedAttempt: (error) => {
|
|
3512
|
+
this.logger.error(`getAllDynamic() 第${error.attemptNumber}次失败: ${error.message}`);
|
|
3513
|
+
},
|
|
3514
|
+
retries: 3
|
|
3515
|
+
});
|
|
3447
3516
|
}
|
|
3448
3517
|
async hasNewDynamic(updateBaseline) {
|
|
3449
|
-
const
|
|
3450
|
-
|
|
3518
|
+
const run = async () => {
|
|
3519
|
+
const { data } = await this.client.get(`${HAS_NEW_DYNAMIC}?update_baseline=${updateBaseline}`);
|
|
3520
|
+
return data;
|
|
3521
|
+
};
|
|
3522
|
+
return await this.pRetry(run, {
|
|
3523
|
+
onFailedAttempt: (error) => {
|
|
3524
|
+
this.logger.error(`hasNewDynamic() 第${error.attemptNumber}次失败: ${error.message}`);
|
|
3525
|
+
},
|
|
3526
|
+
retries: 3
|
|
3527
|
+
});
|
|
3451
3528
|
}
|
|
3452
3529
|
async follow(fid) {
|
|
3453
|
-
const
|
|
3454
|
-
|
|
3455
|
-
|
|
3456
|
-
|
|
3457
|
-
|
|
3458
|
-
|
|
3459
|
-
|
|
3530
|
+
const run = async () => {
|
|
3531
|
+
const { data } = await this.client.post(MODIFY_RELATION, {
|
|
3532
|
+
fid,
|
|
3533
|
+
act: 1,
|
|
3534
|
+
re_src: 11,
|
|
3535
|
+
csrf: this.getCSRF()
|
|
3536
|
+
}, { headers: { "Content-Type": "application/x-www-form-urlencoded" } });
|
|
3537
|
+
return data;
|
|
3538
|
+
};
|
|
3539
|
+
return await this.pRetry(run, {
|
|
3540
|
+
onFailedAttempt: (error) => {
|
|
3541
|
+
this.logger.error(`follow() 第${error.attemptNumber}次失败: ${error.message}`);
|
|
3542
|
+
},
|
|
3543
|
+
retries: 3
|
|
3544
|
+
});
|
|
3460
3545
|
}
|
|
3461
3546
|
async getRelationGroupDetail(tagid) {
|
|
3462
|
-
const
|
|
3463
|
-
|
|
3547
|
+
const run = async () => {
|
|
3548
|
+
const { data } = await this.client.get(`${GET_RELATION_GROUP_DETAIL}?tagid=${tagid}`);
|
|
3549
|
+
return data;
|
|
3550
|
+
};
|
|
3551
|
+
return await this.pRetry(run, {
|
|
3552
|
+
onFailedAttempt: (error) => {
|
|
3553
|
+
this.logger.error(`getRelationGroupDetail() 第${error.attemptNumber}次失败: ${error.message}`);
|
|
3554
|
+
},
|
|
3555
|
+
retries: 3
|
|
3556
|
+
});
|
|
3464
3557
|
}
|
|
3465
3558
|
async getCookieInfo(refreshToken) {
|
|
3466
|
-
const
|
|
3467
|
-
this.
|
|
3468
|
-
|
|
3559
|
+
const run = async () => {
|
|
3560
|
+
const { data } = await this.client.get(`${GET_COOKIES_INFO}?csrf=${refreshToken}`).catch((e) => {
|
|
3561
|
+
this.logger.info(e.message);
|
|
3562
|
+
return null;
|
|
3563
|
+
});
|
|
3564
|
+
return data;
|
|
3565
|
+
};
|
|
3566
|
+
return await this.pRetry(run, {
|
|
3567
|
+
onFailedAttempt: (error) => {
|
|
3568
|
+
this.logger.error(`getCookieInfo() 第${error.attemptNumber}次失败: ${error.message}`);
|
|
3569
|
+
},
|
|
3570
|
+
retries: 3
|
|
3469
3571
|
});
|
|
3470
|
-
return data;
|
|
3471
3572
|
}
|
|
3472
3573
|
async getUserInfo(mid) {
|
|
3473
|
-
|
|
3474
|
-
|
|
3475
|
-
|
|
3476
|
-
|
|
3477
|
-
|
|
3478
|
-
|
|
3479
|
-
|
|
3574
|
+
const run = async () => {
|
|
3575
|
+
if (mid === "11783021") {
|
|
3576
|
+
console.log("检测到番剧出差UID,跳过远程用户接口访问");
|
|
3577
|
+
return bangumiTripData;
|
|
3578
|
+
}
|
|
3579
|
+
const wbi = await this.getWbi({ mid });
|
|
3580
|
+
const { data } = await this.client.get(`${GET_USER_INFO}?${wbi}`);
|
|
3581
|
+
return data;
|
|
3582
|
+
};
|
|
3583
|
+
return await this.pRetry(run, {
|
|
3584
|
+
onFailedAttempt: (error) => {
|
|
3585
|
+
this.logger.error(`getUserInfo() 第${error.attemptNumber}次失败: ${error.message}`);
|
|
3586
|
+
},
|
|
3587
|
+
retries: 3
|
|
3588
|
+
});
|
|
3480
3589
|
}
|
|
3481
3590
|
async getWbiKeys() {
|
|
3482
|
-
const
|
|
3483
|
-
|
|
3484
|
-
|
|
3485
|
-
|
|
3486
|
-
|
|
3591
|
+
const run = async () => {
|
|
3592
|
+
const { data } = await this.client.get("https://api.bilibili.com/x/web-interface/nav");
|
|
3593
|
+
const { data: { wbi_img: { img_url, sub_url } } } = data;
|
|
3594
|
+
return {
|
|
3595
|
+
img_key: img_url.slice(img_url.lastIndexOf("/") + 1, img_url.lastIndexOf(".")),
|
|
3596
|
+
sub_key: sub_url.slice(sub_url.lastIndexOf("/") + 1, sub_url.lastIndexOf("."))
|
|
3597
|
+
};
|
|
3487
3598
|
};
|
|
3599
|
+
return await this.pRetry(run, {
|
|
3600
|
+
onFailedAttempt: (error) => {
|
|
3601
|
+
this.logger.error(`getWbiKeys() 第${error.attemptNumber}次失败: ${error.message}`);
|
|
3602
|
+
},
|
|
3603
|
+
retries: 3
|
|
3604
|
+
});
|
|
3488
3605
|
}
|
|
3489
3606
|
async getMyselfInfo() {
|
|
3490
|
-
const
|
|
3491
|
-
|
|
3607
|
+
const run = async () => {
|
|
3608
|
+
const { data } = await this.client.get(GET_MYSELF_INFO);
|
|
3609
|
+
return data;
|
|
3610
|
+
};
|
|
3611
|
+
return await this.pRetry(run, {
|
|
3612
|
+
onFailedAttempt: (error) => {
|
|
3613
|
+
this.logger.error(`getMyselfInfo() 第${error.attemptNumber}次失败: ${error.message}`);
|
|
3614
|
+
},
|
|
3615
|
+
retries: 3
|
|
3616
|
+
});
|
|
3492
3617
|
}
|
|
3493
3618
|
async getLoginQRCode() {
|
|
3494
|
-
const
|
|
3495
|
-
|
|
3619
|
+
const run = async () => {
|
|
3620
|
+
const { data } = await this.client.get(GET_LOGIN_QRCODE);
|
|
3621
|
+
return data;
|
|
3622
|
+
};
|
|
3623
|
+
return await this.pRetry(run, {
|
|
3624
|
+
onFailedAttempt: (error) => {
|
|
3625
|
+
this.logger.error(`getLoginQRCode() 第${error.attemptNumber}次失败: ${error.message}`);
|
|
3626
|
+
},
|
|
3627
|
+
retries: 3
|
|
3628
|
+
});
|
|
3496
3629
|
}
|
|
3497
3630
|
async getLoginStatus(qrcodeKey) {
|
|
3498
|
-
const
|
|
3499
|
-
|
|
3631
|
+
const run = async () => {
|
|
3632
|
+
const { data } = await this.client.get(`${GET_LOGIN_STATUS}?qrcode_key=${qrcodeKey}`);
|
|
3633
|
+
return data;
|
|
3634
|
+
};
|
|
3635
|
+
return await this.pRetry(run, {
|
|
3636
|
+
onFailedAttempt: (error) => {
|
|
3637
|
+
this.logger.error(`getLoginStatus() 第${error.attemptNumber}次失败: ${error.message}`);
|
|
3638
|
+
},
|
|
3639
|
+
retries: 3
|
|
3640
|
+
});
|
|
3500
3641
|
}
|
|
3501
3642
|
async getLiveRoomInfo(roomId) {
|
|
3502
|
-
const
|
|
3503
|
-
|
|
3643
|
+
const run = async () => {
|
|
3644
|
+
const { data } = await this.client.get(`${GET_LIVE_ROOM_INFO}?room_id=${roomId}`);
|
|
3645
|
+
return data;
|
|
3646
|
+
};
|
|
3647
|
+
return await this.pRetry(run, {
|
|
3648
|
+
onFailedAttempt: (error) => {
|
|
3649
|
+
this.logger.error(`getLiveRoomInfo() 第${error.attemptNumber}次失败: ${error.message}`);
|
|
3650
|
+
},
|
|
3651
|
+
retries: 3
|
|
3652
|
+
});
|
|
3504
3653
|
}
|
|
3505
3654
|
async getMasterInfo(mid) {
|
|
3506
|
-
const
|
|
3507
|
-
|
|
3655
|
+
const run = async () => {
|
|
3656
|
+
const { data } = await this.client.get(`${GET_MASTER_INFO}?uid=${mid}`);
|
|
3657
|
+
return data;
|
|
3658
|
+
};
|
|
3659
|
+
return await this.pRetry(run, {
|
|
3660
|
+
onFailedAttempt: (error) => {
|
|
3661
|
+
this.logger.error(`getMasterInfo() 第${error.attemptNumber}次失败: ${error.message}`);
|
|
3662
|
+
},
|
|
3663
|
+
retries: 3
|
|
3664
|
+
});
|
|
3508
3665
|
}
|
|
3509
3666
|
disposeNotifier() {
|
|
3510
3667
|
if (this.loginNotifier) this.loginNotifier.dispose();
|
|
@@ -3788,138 +3945,6 @@ var BiliAPI = class extends Service {
|
|
|
3788
3945
|
return { data: data.data };
|
|
3789
3946
|
}
|
|
3790
3947
|
};
|
|
3791
|
-
_decorate([Retry({
|
|
3792
|
-
attempts: 3,
|
|
3793
|
-
onFailure(error, attempts) {
|
|
3794
|
-
this.logger.error(`getTheUserWhoIsLiveStreaming() 第${attempts}次失败: ${error.message}`);
|
|
3795
|
-
}
|
|
3796
|
-
})], BiliAPI.prototype, "getTheUserWhoIsLiveStreaming", null);
|
|
3797
|
-
_decorate([Retry({
|
|
3798
|
-
attempts: 3,
|
|
3799
|
-
onFailure(error, attempts) {
|
|
3800
|
-
this.logger.error(`getLiveRoomInfoStreamKey() 第${attempts}次失败: ${error.message}`);
|
|
3801
|
-
}
|
|
3802
|
-
})], BiliAPI.prototype, "getLiveRoomInfoStreamKey", null);
|
|
3803
|
-
_decorate([Retry({
|
|
3804
|
-
attempts: 3,
|
|
3805
|
-
onFailure(error, attempts) {
|
|
3806
|
-
this.logger.error(`getLiveRoomInfoByUids() 第${attempts}次失败: ${error.message}`);
|
|
3807
|
-
}
|
|
3808
|
-
})], BiliAPI.prototype, "getLiveRoomInfoByUids", null);
|
|
3809
|
-
_decorate([Retry({
|
|
3810
|
-
attempts: 3,
|
|
3811
|
-
onFailure(error, attempts) {
|
|
3812
|
-
this.logger.error(`getServerUTCTime() 第${attempts}次失败: ${error.message}`);
|
|
3813
|
-
}
|
|
3814
|
-
})], BiliAPI.prototype, "getServerUTCTime", null);
|
|
3815
|
-
_decorate([Retry({
|
|
3816
|
-
attempts: 3,
|
|
3817
|
-
onFailure(error, attempts) {
|
|
3818
|
-
this.logger.error(`getTimeNow() 第${attempts}次失败: ${error.message}`);
|
|
3819
|
-
}
|
|
3820
|
-
})], BiliAPI.prototype, "getTimeNow", null);
|
|
3821
|
-
_decorate([Retry({
|
|
3822
|
-
attempts: 3,
|
|
3823
|
-
onFailure(error, attempts) {
|
|
3824
|
-
this.logger.error(`getAllGroup() 第${attempts}次失败: ${error.message}`);
|
|
3825
|
-
}
|
|
3826
|
-
})], BiliAPI.prototype, "getAllGroup", null);
|
|
3827
|
-
_decorate([Retry({
|
|
3828
|
-
attempts: 3,
|
|
3829
|
-
onFailure(error, attempts) {
|
|
3830
|
-
this.logger.error(`removeUserFromGroup() 第${attempts}次失败: ${error.message}`);
|
|
3831
|
-
}
|
|
3832
|
-
})], BiliAPI.prototype, "removeUserFromGroup", null);
|
|
3833
|
-
_decorate([Retry({
|
|
3834
|
-
attempts: 3,
|
|
3835
|
-
onFailure(error, attempts) {
|
|
3836
|
-
this.logger.error(`copyUserToGroup() 第${attempts}次失败: ${error.message}`);
|
|
3837
|
-
}
|
|
3838
|
-
})], BiliAPI.prototype, "copyUserToGroup", null);
|
|
3839
|
-
_decorate([Retry({
|
|
3840
|
-
attempts: 3,
|
|
3841
|
-
onFailure(error, attempts) {
|
|
3842
|
-
this.logger.error(`getUserSpaceDynamic() 第${attempts}次失败: ${error.message}`);
|
|
3843
|
-
}
|
|
3844
|
-
})], BiliAPI.prototype, "getUserSpaceDynamic", null);
|
|
3845
|
-
_decorate([Retry({
|
|
3846
|
-
attempts: 3,
|
|
3847
|
-
onFailure(error, attempts) {
|
|
3848
|
-
this.logger.error(`createGroup() 第${attempts}次失败: ${error.message}`);
|
|
3849
|
-
}
|
|
3850
|
-
})], BiliAPI.prototype, "createGroup", null);
|
|
3851
|
-
_decorate([Retry({
|
|
3852
|
-
attempts: 3,
|
|
3853
|
-
onFailure(error, attempts) {
|
|
3854
|
-
this.logger.error(`getAllDynamic() 第${attempts}次失败: ${error.message}`);
|
|
3855
|
-
}
|
|
3856
|
-
})], BiliAPI.prototype, "getAllDynamic", null);
|
|
3857
|
-
_decorate([Retry({
|
|
3858
|
-
attempts: 3,
|
|
3859
|
-
onFailure(error, attempts) {
|
|
3860
|
-
this.logger.error(`hasNewDynamic() 第${attempts}次失败: ${error.message}`);
|
|
3861
|
-
}
|
|
3862
|
-
})], BiliAPI.prototype, "hasNewDynamic", null);
|
|
3863
|
-
_decorate([Retry({
|
|
3864
|
-
attempts: 3,
|
|
3865
|
-
onFailure(error, attempts) {
|
|
3866
|
-
this.logger.error(`follow() 第${attempts}次失败: ${error.message}`);
|
|
3867
|
-
}
|
|
3868
|
-
})], BiliAPI.prototype, "follow", null);
|
|
3869
|
-
_decorate([Retry({
|
|
3870
|
-
attempts: 3,
|
|
3871
|
-
onFailure(error, attempts) {
|
|
3872
|
-
this.logger.error(`getRelationGroupDetail() 第${attempts}次失败: ${error.message}`);
|
|
3873
|
-
}
|
|
3874
|
-
})], BiliAPI.prototype, "getRelationGroupDetail", null);
|
|
3875
|
-
_decorate([Retry({
|
|
3876
|
-
attempts: 3,
|
|
3877
|
-
onFailure(error, attempts) {
|
|
3878
|
-
this.logger.error(`getCookieInfo() 第${attempts}次失败: ${error.message}`);
|
|
3879
|
-
}
|
|
3880
|
-
})], BiliAPI.prototype, "getCookieInfo", null);
|
|
3881
|
-
_decorate([Retry({
|
|
3882
|
-
attempts: 3,
|
|
3883
|
-
onFailure(error, attempts) {
|
|
3884
|
-
this.logger.error(`getUserInfo() 第${attempts}次失败: ${error.message}`);
|
|
3885
|
-
}
|
|
3886
|
-
})], BiliAPI.prototype, "getUserInfo", null);
|
|
3887
|
-
_decorate([Retry({
|
|
3888
|
-
attempts: 3,
|
|
3889
|
-
onFailure(error, attempts) {
|
|
3890
|
-
this.logger.error(`getWbiKeys() 第${attempts}次失败: ${error.message}`);
|
|
3891
|
-
}
|
|
3892
|
-
})], BiliAPI.prototype, "getWbiKeys", null);
|
|
3893
|
-
_decorate([Retry({
|
|
3894
|
-
attempts: 3,
|
|
3895
|
-
onFailure(error, attempts) {
|
|
3896
|
-
this.logger.error(`getMyselfInfo() 第${attempts}次失败: ${error.message}`);
|
|
3897
|
-
}
|
|
3898
|
-
})], BiliAPI.prototype, "getMyselfInfo", null);
|
|
3899
|
-
_decorate([Retry({
|
|
3900
|
-
attempts: 3,
|
|
3901
|
-
onFailure(error, attempts) {
|
|
3902
|
-
this.logger.error(`getLoginQRCode() 第${attempts}次失败: ${error.message}`);
|
|
3903
|
-
}
|
|
3904
|
-
})], BiliAPI.prototype, "getLoginQRCode", null);
|
|
3905
|
-
_decorate([Retry({
|
|
3906
|
-
attempts: 3,
|
|
3907
|
-
onFailure(error, attempts) {
|
|
3908
|
-
this.logger.error(`getLoginStatus() 第${attempts}次失败: ${error.message}`);
|
|
3909
|
-
}
|
|
3910
|
-
})], BiliAPI.prototype, "getLoginStatus", null);
|
|
3911
|
-
_decorate([Retry({
|
|
3912
|
-
attempts: 3,
|
|
3913
|
-
onFailure(error, attempts) {
|
|
3914
|
-
this.logger.error(`getLiveRoomInfo() 第${attempts}次失败: ${error.message}`);
|
|
3915
|
-
}
|
|
3916
|
-
})], BiliAPI.prototype, "getLiveRoomInfo", null);
|
|
3917
|
-
_decorate([Retry({
|
|
3918
|
-
attempts: 3,
|
|
3919
|
-
onFailure(error, attempts) {
|
|
3920
|
-
this.logger.error(`getMasterInfo() 第${attempts}次失败: ${error.message}`);
|
|
3921
|
-
}
|
|
3922
|
-
})], BiliAPI.prototype, "getMasterInfo", null);
|
|
3923
3948
|
(function(_BiliAPI) {
|
|
3924
3949
|
const Config$1 = _BiliAPI.Config = Schema.object({
|
|
3925
3950
|
userAgent: Schema.string(),
|
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.
|
|
4
|
+
"version": "3.3.0-rc.0",
|
|
5
5
|
"main": "./lib/index.js",
|
|
6
6
|
"typings": "lib/index.d.ts",
|
|
7
7
|
"files": [
|
|
@@ -30,14 +30,14 @@
|
|
|
30
30
|
"dependencies": {
|
|
31
31
|
"@akokko/blive-message-listener": "^0.5.1",
|
|
32
32
|
"@node-rs/jieba": "^2.0.1",
|
|
33
|
-
"@oxc-project/runtime": "^0.76.0",
|
|
34
33
|
"axios": "^1.10.0",
|
|
35
|
-
"axios-cookiejar-support": "^6.0.
|
|
34
|
+
"axios-cookiejar-support": "^6.0.3",
|
|
36
35
|
"cacheable-lookup": "^7.0.0",
|
|
37
36
|
"cron": "^4.3.1",
|
|
38
37
|
"jsdom": "^26.1.0",
|
|
39
|
-
"luxon": "^3.
|
|
38
|
+
"luxon": "^3.7.1",
|
|
40
39
|
"md5": "^2.3.0",
|
|
40
|
+
"p-retry": "^6.2.1",
|
|
41
41
|
"qrcode": "^1.5.4",
|
|
42
42
|
"tough-cookie": "^5.1.2"
|
|
43
43
|
},
|
package/readme.md
CHANGED
|
@@ -318,6 +318,13 @@ uid为必填参数,为要推送的UP主的UID,index为可选参数,为要
|
|
|
318
318
|
> - ver 3.2.11-alpha.6 测试版本
|
|
319
319
|
> - ver 3.2.11-alpha.7 测试版本
|
|
320
320
|
> - ver 3.2.11-alpha.8 测试版本
|
|
321
|
+
> - ver 3.2.11-alpha.9 测试版本
|
|
322
|
+
> - ver 3.2.11-alpha.10 测试版本
|
|
323
|
+
> - ver 3.2.11-alpha.11 测试版本
|
|
324
|
+
> - ver 3.2.11-alpha.12 测试版本
|
|
325
|
+
|
|
326
|
+
> [!NOTE]
|
|
327
|
+
> - ver 3.3.0-rc.0 优化:将当前版本的订阅配置移到了新插件:`bilibili-notify-advanced-subscription` ,简化当前版本订阅配置; 新增:配置项 `advancedSub` ,开启后可通过下载插件 `bilibili-notify-advanced-subscription` 配置更自定义化的订阅配置、新增动态@全体成员功能
|
|
321
328
|
|
|
322
329
|
## 交流群
|
|
323
330
|
|