koishi-plugin-bilibili-notify 3.3.13 → 3.3.15
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/img/captain.png +0 -0
- package/lib/img/governor.png +0 -0
- package/lib/img/supervisor.png +0 -0
- package/lib/{index.js → index.cjs} +20 -24
- package/lib/index.mjs +11 -5
- package/package.json +16 -16
- /package/lib/{index.d.ts → index.d.cts} +0 -0
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -30,24 +30,18 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
30
30
|
|
|
31
31
|
//#endregion
|
|
32
32
|
let koishi = require("koishi");
|
|
33
|
-
koishi = __toESM(koishi);
|
|
34
33
|
require("@koishijs/plugin-notifier");
|
|
35
34
|
require("@koishijs/plugin-help");
|
|
35
|
+
let node_url = require("node:url");
|
|
36
|
+
let node_path = require("node:path");
|
|
37
|
+
let blive_message_listener = require("blive-message-listener");
|
|
36
38
|
let qrcode = require("qrcode");
|
|
37
39
|
qrcode = __toESM(qrcode);
|
|
38
40
|
let cron = require("cron");
|
|
39
|
-
cron = __toESM(cron);
|
|
40
41
|
let luxon = require("luxon");
|
|
41
|
-
luxon = __toESM(luxon);
|
|
42
42
|
let __node_rs_jieba = require("@node-rs/jieba");
|
|
43
|
-
__node_rs_jieba = __toESM(__node_rs_jieba);
|
|
44
43
|
let __node_rs_jieba_dict = require("@node-rs/jieba/dict");
|
|
45
|
-
__node_rs_jieba_dict = __toESM(__node_rs_jieba_dict);
|
|
46
44
|
require("koishi-plugin-puppeteer");
|
|
47
|
-
let node_path = require("node:path");
|
|
48
|
-
node_path = __toESM(node_path);
|
|
49
|
-
let node_url = require("node:url");
|
|
50
|
-
node_url = __toESM(node_url);
|
|
51
45
|
let md5 = require("md5");
|
|
52
46
|
md5 = __toESM(md5);
|
|
53
47
|
let node_crypto = require("node:crypto");
|
|
@@ -59,13 +53,8 @@ node_https = __toESM(node_https);
|
|
|
59
53
|
let axios = require("axios");
|
|
60
54
|
axios = __toESM(axios);
|
|
61
55
|
let tough_cookie = require("tough-cookie");
|
|
62
|
-
tough_cookie = __toESM(tough_cookie);
|
|
63
|
-
let jsdom = require("jsdom");
|
|
64
|
-
jsdom = __toESM(jsdom);
|
|
65
56
|
let openai = require("openai");
|
|
66
57
|
openai = __toESM(openai);
|
|
67
|
-
let blive_message_listener = require("blive-message-listener");
|
|
68
|
-
blive_message_listener = __toESM(blive_message_listener);
|
|
69
58
|
|
|
70
59
|
//#region src/config.ts
|
|
71
60
|
const BAConfigSchema = koishi.Schema.object({
|
|
@@ -199,7 +188,7 @@ async function withRetry(fn, maxAttempts = 3, delayMs = 1e3) {
|
|
|
199
188
|
} catch (error) {
|
|
200
189
|
attempt++;
|
|
201
190
|
if (attempt >= maxAttempts) throw error;
|
|
202
|
-
await new Promise((resolve$
|
|
191
|
+
await new Promise((resolve$2) => setTimeout(resolve$2, delayMs * attempt));
|
|
203
192
|
}
|
|
204
193
|
}
|
|
205
194
|
function replaceButKeep(oldObj, newObj, keepKeys) {
|
|
@@ -1321,6 +1310,11 @@ var ComRegister = class {
|
|
|
1321
1310
|
let masterInfo;
|
|
1322
1311
|
const liveData = { likedNum: "0" };
|
|
1323
1312
|
const liveMsgObj = this.liveMsgManager.get(sub.uid);
|
|
1313
|
+
const guardLevelImg = {
|
|
1314
|
+
[blive_message_listener.GuardLevel.Jianzhang]: (0, node_url.pathToFileURL)((0, node_path.resolve)(__dirname, "img/captain.png")),
|
|
1315
|
+
[blive_message_listener.GuardLevel.Tidu]: (0, node_url.pathToFileURL)((0, node_path.resolve)(__dirname, "img/supervisor.png")),
|
|
1316
|
+
[blive_message_listener.GuardLevel.Zongdu]: (0, node_url.pathToFileURL)((0, node_path.resolve)(__dirname, "img/governor.png"))
|
|
1317
|
+
};
|
|
1324
1318
|
const sendDanmakuWordCloudAndLiveSummary = async (customLiveSummary) => {
|
|
1325
1319
|
this.logger.info("开始制作弹幕词云");
|
|
1326
1320
|
this.logger.info("正在获取前90热词");
|
|
@@ -1458,7 +1452,8 @@ var ComRegister = class {
|
|
|
1458
1452
|
console.log(liveData.likedNum);
|
|
1459
1453
|
},
|
|
1460
1454
|
onGuardBuy: ({ body }) => {
|
|
1461
|
-
const
|
|
1455
|
+
const guardImg = guardLevelImg[body.guard_level];
|
|
1456
|
+
const content = (0, koishi.h)("message", [koishi.h.text(`【${masterInfo.username}的直播间】${body.user.uname}加入了大航海(${body.gift_name})`), koishi.h.image(guardImg.href)]);
|
|
1462
1457
|
this.broadcastToTargets(sub.uid, content, PushType.LiveGuardBuy);
|
|
1463
1458
|
},
|
|
1464
1459
|
onLiveStart: async () => {
|
|
@@ -1698,10 +1693,10 @@ var ComRegister = class {
|
|
|
1698
1693
|
this.subNotifier = this.ctx.notifier.create(table);
|
|
1699
1694
|
}
|
|
1700
1695
|
async checkIfLoginInfoIsLoaded() {
|
|
1701
|
-
return new Promise((resolve$
|
|
1696
|
+
return new Promise((resolve$2) => {
|
|
1702
1697
|
const check = () => {
|
|
1703
1698
|
if (!this.ctx["bilibili-notify-api"].getLoginInfoIsLoaded()) this.ctx.setTimeout(check, 500);
|
|
1704
|
-
else resolve$
|
|
1699
|
+
else resolve$2("success");
|
|
1705
1700
|
};
|
|
1706
1701
|
check();
|
|
1707
1702
|
});
|
|
@@ -4192,7 +4187,8 @@ var BiliAPI = class extends koishi.Service {
|
|
|
4192
4187
|
}
|
|
4193
4188
|
const correspondPath = await getCorrespondPath(luxon.DateTime.now().toMillis());
|
|
4194
4189
|
const { data: refreshCsrfHtml } = await this.client.get(`https://www.bilibili.com/correspond/1/${correspondPath}`);
|
|
4195
|
-
const {
|
|
4190
|
+
const { JSDOM } = await import("jsdom");
|
|
4191
|
+
const { document } = new JSDOM(refreshCsrfHtml).window;
|
|
4196
4192
|
const targetElement = document.getElementById("1-name");
|
|
4197
4193
|
const refresh_csrf = targetElement ? targetElement.textContent : null;
|
|
4198
4194
|
const { data: refreshData } = await this.client.post("https://passport.bilibili.com/x/passport-login/web/cookie/refresh", {
|
|
@@ -4409,10 +4405,10 @@ var ServerManager = class extends koishi.Service {
|
|
|
4409
4405
|
};
|
|
4410
4406
|
disposePlugin = async () => {
|
|
4411
4407
|
if (this.servers.length === 0) return false;
|
|
4412
|
-
await new Promise((resolve$
|
|
4408
|
+
await new Promise((resolve$2) => {
|
|
4413
4409
|
for (const fork of this.servers) fork.dispose();
|
|
4414
4410
|
this.servers = [];
|
|
4415
|
-
resolve$
|
|
4411
|
+
resolve$2("ok");
|
|
4416
4412
|
});
|
|
4417
4413
|
return true;
|
|
4418
4414
|
};
|
|
@@ -4422,15 +4418,15 @@ var ServerManager = class extends koishi.Service {
|
|
|
4422
4418
|
return false;
|
|
4423
4419
|
}
|
|
4424
4420
|
await this.disposePlugin();
|
|
4425
|
-
return new Promise((resolve$
|
|
4421
|
+
return new Promise((resolve$2) => {
|
|
4426
4422
|
this.ctx.setTimeout(() => {
|
|
4427
4423
|
try {
|
|
4428
4424
|
this.registerPlugin();
|
|
4429
4425
|
} catch (e) {
|
|
4430
4426
|
this.logger.error("重启插件失败", e);
|
|
4431
|
-
resolve$
|
|
4427
|
+
resolve$2(false);
|
|
4432
4428
|
}
|
|
4433
|
-
resolve$
|
|
4429
|
+
resolve$2(true);
|
|
4434
4430
|
}, 1e3);
|
|
4435
4431
|
});
|
|
4436
4432
|
};
|
package/lib/index.mjs
CHANGED
|
@@ -2,23 +2,22 @@ import "node:module";
|
|
|
2
2
|
import { Schema, Service, Universal, h } from "koishi";
|
|
3
3
|
import "@koishijs/plugin-notifier";
|
|
4
4
|
import "@koishijs/plugin-help";
|
|
5
|
+
import { pathToFileURL } from "node:url";
|
|
6
|
+
import { resolve } from "node:path";
|
|
7
|
+
import { GuardLevel, startListen } from "blive-message-listener";
|
|
5
8
|
import QRCode from "qrcode";
|
|
6
9
|
import { CronJob } from "cron";
|
|
7
10
|
import { DateTime } from "luxon";
|
|
8
11
|
import { Jieba } from "@node-rs/jieba";
|
|
9
12
|
import { dict } from "@node-rs/jieba/dict";
|
|
10
13
|
import "koishi-plugin-puppeteer";
|
|
11
|
-
import { resolve } from "node:path";
|
|
12
|
-
import { pathToFileURL } from "node:url";
|
|
13
14
|
import md5 from "md5";
|
|
14
15
|
import crypto from "node:crypto";
|
|
15
16
|
import http from "node:http";
|
|
16
17
|
import https from "node:https";
|
|
17
18
|
import axios from "axios";
|
|
18
19
|
import { Cookie, CookieJar } from "tough-cookie";
|
|
19
|
-
import { JSDOM } from "jsdom";
|
|
20
20
|
import OpenAI from "openai";
|
|
21
|
-
import { startListen } from "blive-message-listener";
|
|
22
21
|
|
|
23
22
|
//#region rolldown:runtime
|
|
24
23
|
var __defProp = Object.defineProperty;
|
|
@@ -1286,6 +1285,11 @@ var ComRegister = class {
|
|
|
1286
1285
|
let masterInfo;
|
|
1287
1286
|
const liveData = { likedNum: "0" };
|
|
1288
1287
|
const liveMsgObj = this.liveMsgManager.get(sub.uid);
|
|
1288
|
+
const guardLevelImg = {
|
|
1289
|
+
[GuardLevel.Jianzhang]: pathToFileURL(resolve(__dirname, "img/captain.png")),
|
|
1290
|
+
[GuardLevel.Tidu]: pathToFileURL(resolve(__dirname, "img/supervisor.png")),
|
|
1291
|
+
[GuardLevel.Zongdu]: pathToFileURL(resolve(__dirname, "img/governor.png"))
|
|
1292
|
+
};
|
|
1289
1293
|
const sendDanmakuWordCloudAndLiveSummary = async (customLiveSummary) => {
|
|
1290
1294
|
this.logger.info("开始制作弹幕词云");
|
|
1291
1295
|
this.logger.info("正在获取前90热词");
|
|
@@ -1423,7 +1427,8 @@ var ComRegister = class {
|
|
|
1423
1427
|
console.log(liveData.likedNum);
|
|
1424
1428
|
},
|
|
1425
1429
|
onGuardBuy: ({ body }) => {
|
|
1426
|
-
const
|
|
1430
|
+
const guardImg = guardLevelImg[body.guard_level];
|
|
1431
|
+
const content = h("message", [h.text(`【${masterInfo.username}的直播间】${body.user.uname}加入了大航海(${body.gift_name})`), h.image(guardImg.href)]);
|
|
1427
1432
|
this.broadcastToTargets(sub.uid, content, PushType.LiveGuardBuy);
|
|
1428
1433
|
},
|
|
1429
1434
|
onLiveStart: async () => {
|
|
@@ -4157,6 +4162,7 @@ var BiliAPI = class extends Service {
|
|
|
4157
4162
|
}
|
|
4158
4163
|
const correspondPath = await getCorrespondPath(DateTime.now().toMillis());
|
|
4159
4164
|
const { data: refreshCsrfHtml } = await this.client.get(`https://www.bilibili.com/correspond/1/${correspondPath}`);
|
|
4165
|
+
const { JSDOM } = await import("jsdom");
|
|
4160
4166
|
const { document } = new JSDOM(refreshCsrfHtml).window;
|
|
4161
4167
|
const targetElement = document.getElementById("1-name");
|
|
4162
4168
|
const refresh_csrf = targetElement ? targetElement.textContent : null;
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "koishi-plugin-bilibili-notify",
|
|
3
3
|
"description": "Koishi bilibili notify plugin",
|
|
4
|
-
"version": "3.3.
|
|
5
|
-
"main": "./lib/index.
|
|
4
|
+
"version": "3.3.15",
|
|
5
|
+
"main": "./lib/index.cjs",
|
|
6
6
|
"typings": "lib/index.d.ts",
|
|
7
7
|
"files": [
|
|
8
8
|
"lib",
|
|
@@ -29,30 +29,30 @@
|
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
31
|
"@node-rs/jieba": "^2.0.1",
|
|
32
|
-
"axios": "^1.
|
|
32
|
+
"axios": "^1.13.2",
|
|
33
33
|
"axios-cookiejar-support": "^6.0.4",
|
|
34
|
-
"blive-message-listener": "^0.5.
|
|
34
|
+
"blive-message-listener": "^0.5.2",
|
|
35
35
|
"cacheable-lookup": "^7.0.0",
|
|
36
36
|
"cron": "^4.3.3",
|
|
37
|
-
"jsdom": "^
|
|
38
|
-
"luxon": "^3.
|
|
37
|
+
"jsdom": "^27.1.0",
|
|
38
|
+
"luxon": "^3.8.0-alpha.1",
|
|
39
39
|
"md5": "^2.3.0",
|
|
40
|
-
"openai": "^
|
|
41
|
-
"p-retry": "^
|
|
40
|
+
"openai": "^6.8.1",
|
|
41
|
+
"p-retry": "^7.1.0",
|
|
42
42
|
"qrcode": "^1.5.4",
|
|
43
|
-
"tough-cookie": "^
|
|
43
|
+
"tough-cookie": "^6.0.0"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
|
-
"@types/jsdom": "^
|
|
46
|
+
"@types/jsdom": "^27.0.0",
|
|
47
47
|
"@types/luxon": "^3.7.1",
|
|
48
|
-
"@types/md5": "^2.3.
|
|
49
|
-
"@types/qrcode": "^1.5.
|
|
48
|
+
"@types/md5": "^2.3.6",
|
|
49
|
+
"@types/qrcode": "^1.5.6",
|
|
50
50
|
"@types/tough-cookie": "^4.0.5",
|
|
51
51
|
"koishi-plugin-puppeteer": "^3.9.0",
|
|
52
|
-
"tsdown": "^0.
|
|
52
|
+
"tsdown": "^0.16.0"
|
|
53
53
|
},
|
|
54
54
|
"peerDependencies": {
|
|
55
|
-
"koishi": "^4.18.
|
|
55
|
+
"koishi": "^4.18.9"
|
|
56
56
|
},
|
|
57
57
|
"engines": {
|
|
58
58
|
"node": ">= 20.0.0"
|
|
@@ -73,11 +73,11 @@
|
|
|
73
73
|
"access": "public"
|
|
74
74
|
},
|
|
75
75
|
"module": "./lib/index.mjs",
|
|
76
|
-
"types": "./lib/index.d.
|
|
76
|
+
"types": "./lib/index.d.cts",
|
|
77
77
|
"exports": {
|
|
78
78
|
".": {
|
|
79
79
|
"import": "./lib/index.mjs",
|
|
80
|
-
"require": "./lib/index.
|
|
80
|
+
"require": "./lib/index.cjs"
|
|
81
81
|
},
|
|
82
82
|
"./package.json": "./package.json"
|
|
83
83
|
}
|
|
File without changes
|