koishi-plugin-bilibili-notify 3.2.7-alpha.0 → 3.2.7-alpha.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/index.js +11 -7
- package/lib/index.mjs +11 -7
- package/package.json +1 -1
- package/readme.md +1 -0
package/lib/index.js
CHANGED
|
@@ -94428,11 +94428,11 @@ var BiliAPI = class extends koishi.Service {
|
|
|
94428
94428
|
this.cacheable.install(node_https.default.globalAgent);
|
|
94429
94429
|
await this.createNewClient();
|
|
94430
94430
|
await this.loadCookiesFromDatabase();
|
|
94431
|
-
await this.updateBiliTicket();
|
|
94432
94431
|
this.updateJob = new cron.CronJob("0 0 * * *", async () => {
|
|
94433
94432
|
await this.updateBiliTicket();
|
|
94434
94433
|
});
|
|
94435
94434
|
this.updateJob.start();
|
|
94435
|
+
await this.updateBiliTicket();
|
|
94436
94436
|
}
|
|
94437
94437
|
stop() {
|
|
94438
94438
|
this.cacheable.uninstall(node_http.default.globalAgent);
|
|
@@ -94440,12 +94440,16 @@ var BiliAPI = class extends koishi.Service {
|
|
|
94440
94440
|
this.updateJob.stop();
|
|
94441
94441
|
}
|
|
94442
94442
|
async updateBiliTicket() {
|
|
94443
|
-
|
|
94444
|
-
|
|
94445
|
-
|
|
94446
|
-
|
|
94447
|
-
|
|
94448
|
-
|
|
94443
|
+
try {
|
|
94444
|
+
const csrf = this.getCSRF();
|
|
94445
|
+
const ticket = await this.getBiliTicket(csrf);
|
|
94446
|
+
if (ticket.code !== 0) throw new Error(`获取BiliTicket失败: ${ticket.message}`);
|
|
94447
|
+
this.jar.setCookieSync(`bili_ticket=${ticket.data.ticket}; path=/; domain=.bilibili.com`, "https://www.bilibili.com");
|
|
94448
|
+
this.wbiSign.img_key = ticket.data.nav.img.slice(ticket.data.nav.img.lastIndexOf("/") + 1, ticket.data.nav.img.lastIndexOf("."));
|
|
94449
|
+
this.wbiSign.sub_key = ticket.data.nav.sub.slice(ticket.data.nav.sub.lastIndexOf("/") + 1, ticket.data.nav.sub.lastIndexOf("."));
|
|
94450
|
+
} catch (e$1) {
|
|
94451
|
+
this.logger.error(`更新BiliTicket失败: ${e$1.message}`);
|
|
94452
|
+
}
|
|
94449
94453
|
}
|
|
94450
94454
|
getMixinKey = (orig) => mixinKeyEncTab.map((n$2) => orig[n$2]).join("").slice(0, 32);
|
|
94451
94455
|
encWbi(params, img_key, sub_key) {
|
package/lib/index.mjs
CHANGED
|
@@ -94430,11 +94430,11 @@ var BiliAPI = class extends Service {
|
|
|
94430
94430
|
this.cacheable.install(https.globalAgent);
|
|
94431
94431
|
await this.createNewClient();
|
|
94432
94432
|
await this.loadCookiesFromDatabase();
|
|
94433
|
-
await this.updateBiliTicket();
|
|
94434
94433
|
this.updateJob = new CronJob("0 0 * * *", async () => {
|
|
94435
94434
|
await this.updateBiliTicket();
|
|
94436
94435
|
});
|
|
94437
94436
|
this.updateJob.start();
|
|
94437
|
+
await this.updateBiliTicket();
|
|
94438
94438
|
}
|
|
94439
94439
|
stop() {
|
|
94440
94440
|
this.cacheable.uninstall(http.globalAgent);
|
|
@@ -94442,12 +94442,16 @@ var BiliAPI = class extends Service {
|
|
|
94442
94442
|
this.updateJob.stop();
|
|
94443
94443
|
}
|
|
94444
94444
|
async updateBiliTicket() {
|
|
94445
|
-
|
|
94446
|
-
|
|
94447
|
-
|
|
94448
|
-
|
|
94449
|
-
|
|
94450
|
-
|
|
94445
|
+
try {
|
|
94446
|
+
const csrf = this.getCSRF();
|
|
94447
|
+
const ticket = await this.getBiliTicket(csrf);
|
|
94448
|
+
if (ticket.code !== 0) throw new Error(`获取BiliTicket失败: ${ticket.message}`);
|
|
94449
|
+
this.jar.setCookieSync(`bili_ticket=${ticket.data.ticket}; path=/; domain=.bilibili.com`, "https://www.bilibili.com");
|
|
94450
|
+
this.wbiSign.img_key = ticket.data.nav.img.slice(ticket.data.nav.img.lastIndexOf("/") + 1, ticket.data.nav.img.lastIndexOf("."));
|
|
94451
|
+
this.wbiSign.sub_key = ticket.data.nav.sub.slice(ticket.data.nav.sub.lastIndexOf("/") + 1, ticket.data.nav.sub.lastIndexOf("."));
|
|
94452
|
+
} catch (e$1) {
|
|
94453
|
+
this.logger.error(`更新BiliTicket失败: ${e$1.message}`);
|
|
94454
|
+
}
|
|
94451
94455
|
}
|
|
94452
94456
|
getMixinKey = (orig) => mixinKeyEncTab.map((n$2) => orig[n$2]).join("").slice(0, 32);
|
|
94453
94457
|
encWbi(params, img_key, sub_key) {
|
package/package.json
CHANGED
package/readme.md
CHANGED
|
@@ -294,6 +294,7 @@ uid为必填参数,为要推送的UP主的UID,index为可选参数,为要
|
|
|
294
294
|
> - ver 3.2.5 重构:消息推送逻辑; 新增:选项 `dynamicCron`;
|
|
295
295
|
> - ver 3.2.6-alpha.0 优化:更新依赖; 修复:长图动态向下箭头无法显示的bug;
|
|
296
296
|
> - ver 3.2.7-alpha.0 优化:将选项 `userAgent` 更改为可选项,在 `cookies` 中添加 `bili_ticket` 降低风控概率;
|
|
297
|
+
> - ver 3.2.7-alpha.1 修复:加载 `bili_ticket` 失败会导致插件加载失败;
|
|
297
298
|
|
|
298
299
|
## 交流群
|
|
299
300
|
|