koishi-plugin-bilibili-notify 3.4.0-alpha.1 → 3.4.0-alpha.3
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.cjs +167 -37
- package/lib/index.mjs +167 -37
- package/package.json +1 -1
package/lib/index.cjs
CHANGED
|
@@ -365,7 +365,7 @@ var stop_words_default = stopwords;
|
|
|
365
365
|
|
|
366
366
|
//#endregion
|
|
367
367
|
//#region src/command_register.ts
|
|
368
|
-
var ComRegister = class {
|
|
368
|
+
var ComRegister = class ComRegister {
|
|
369
369
|
static inject = [
|
|
370
370
|
"bilibili-notify",
|
|
371
371
|
"bilibili-notify-api",
|
|
@@ -1300,6 +1300,11 @@ var ComRegister = class {
|
|
|
1300
1300
|
addUserToDanmakuMaker(username, danmakuMakerRecord) {
|
|
1301
1301
|
danmakuMakerRecord[username] = (danmakuMakerRecord[username] || 0) + 1;
|
|
1302
1302
|
}
|
|
1303
|
+
static GUARD_LEVEL_IMG = {
|
|
1304
|
+
[blive_message_listener.GuardLevel.Jianzhang]: "https://s1.hdslb.com/bfs/static/blive/live-pay-mono/relation/relation/assets/captain-Bjw5Byb5.png",
|
|
1305
|
+
[blive_message_listener.GuardLevel.Tidu]: "https://s1.hdslb.com/bfs/static/blive/live-pay-mono/relation/relation/assets/supervisor-u43ElIjU.png",
|
|
1306
|
+
[blive_message_listener.GuardLevel.Zongdu]: "https://s1.hdslb.com/bfs/static/blive/live-pay-mono/relation/relation/assets/governor-DpDXKEdA.png"
|
|
1307
|
+
};
|
|
1303
1308
|
async liveDetectWithListener(sub) {
|
|
1304
1309
|
let liveTime;
|
|
1305
1310
|
let pushAtTimeTimer;
|
|
@@ -1310,11 +1315,6 @@ var ComRegister = class {
|
|
|
1310
1315
|
let masterInfo;
|
|
1311
1316
|
const liveData = { likedNum: "0" };
|
|
1312
1317
|
const liveMsgObj = this.liveMsgManager.get(sub.uid);
|
|
1313
|
-
const guardLevelImg = {
|
|
1314
|
-
[blive_message_listener.GuardLevel.Jianzhang]: "https://s1.hdslb.com/bfs/static/blive/live-pay-mono/relation/relation/assets/captain-Bjw5Byb5.png",
|
|
1315
|
-
[blive_message_listener.GuardLevel.Tidu]: "https://s1.hdslb.com/bfs/static/blive/live-pay-mono/relation/relation/assets/supervisor-u43ElIjU.png",
|
|
1316
|
-
[blive_message_listener.GuardLevel.Zongdu]: "https://s1.hdslb.com/bfs/static/blive/live-pay-mono/relation/relation/assets/governor-DpDXKEdA.png"
|
|
1317
|
-
};
|
|
1318
1318
|
const sendDanmakuWordCloudAndLiveSummary = async (customLiveSummary) => {
|
|
1319
1319
|
this.logger.info("开始制作弹幕词云");
|
|
1320
1320
|
this.logger.info("正在获取前90热词");
|
|
@@ -1451,10 +1451,14 @@ var ComRegister = class {
|
|
|
1451
1451
|
liveData.likedNum = body.count.toString();
|
|
1452
1452
|
console.log(liveData.likedNum);
|
|
1453
1453
|
},
|
|
1454
|
-
onGuardBuy: ({ body }) => {
|
|
1455
|
-
const guardImg =
|
|
1456
|
-
const
|
|
1457
|
-
|
|
1454
|
+
onGuardBuy: async ({ body }) => {
|
|
1455
|
+
const guardImg = ComRegister.GUARD_LEVEL_IMG[body.guard_level];
|
|
1456
|
+
const buffer = await this.ctx["bilibili-notify-generate-img"].generateBoardingImg(guardImg, body, {
|
|
1457
|
+
masterName: masterInfo.username,
|
|
1458
|
+
masterAvatarUrl: masterInfo.userface
|
|
1459
|
+
});
|
|
1460
|
+
const img = koishi.h.image(buffer, "image/jpeg");
|
|
1461
|
+
this.broadcastToTargets(sub.uid, img, PushType.LiveGuardBuy);
|
|
1458
1462
|
},
|
|
1459
1463
|
onLiveStart: async () => {
|
|
1460
1464
|
const now = Date.now();
|
|
@@ -2018,7 +2022,7 @@ const DYNAMIC_TYPE_COURSES_SEASON = "DYNAMIC_TYPE_COURSES_SEASON";
|
|
|
2018
2022
|
const DYNAMIC_TYPE_LIVE_RCMD = "DYNAMIC_TYPE_LIVE_RCMD";
|
|
2019
2023
|
const DYNAMIC_TYPE_UGC_SEASON = "DYNAMIC_TYPE_UGC_SEASON";
|
|
2020
2024
|
const ADDITIONAL_TYPE_RESERVE = "ADDITIONAL_TYPE_RESERVE";
|
|
2021
|
-
var GenerateImg = class extends koishi.Service {
|
|
2025
|
+
var GenerateImg = class GenerateImg extends koishi.Service {
|
|
2022
2026
|
static inject = ["puppeteer"];
|
|
2023
2027
|
giConfig;
|
|
2024
2028
|
constructor(ctx, config) {
|
|
@@ -2056,16 +2060,11 @@ var GenerateImg = class extends koishi.Service {
|
|
|
2056
2060
|
<head>
|
|
2057
2061
|
<title>直播通知</title>
|
|
2058
2062
|
<style>
|
|
2059
|
-
@font-face {
|
|
2060
|
-
font-family: "Custom Font";
|
|
2061
|
-
src: url(${(0, node_url.pathToFileURL)((0, node_path.resolve)(__dirname, "font/HYZhengYuan-75W.ttf"))});
|
|
2062
|
-
}
|
|
2063
|
-
|
|
2064
2063
|
* {
|
|
2065
2064
|
margin: 0;
|
|
2066
2065
|
padding: 0;
|
|
2067
2066
|
box-sizing: border-box;
|
|
2068
|
-
font-family: \"${this.giConfig.font}\", "
|
|
2067
|
+
font-family: \"${this.giConfig.font}\", "Microsoft YaHei", "Source Han Sans", "Noto Sans CJK", sans-serif;
|
|
2069
2068
|
}
|
|
2070
2069
|
|
|
2071
2070
|
html {
|
|
@@ -2198,6 +2197,154 @@ var GenerateImg = class extends koishi.Service {
|
|
|
2198
2197
|
throw new Error(`生成图片失败!错误: ${e.toString()}`);
|
|
2199
2198
|
});
|
|
2200
2199
|
}
|
|
2200
|
+
static BG_COLOR = {
|
|
2201
|
+
[blive_message_listener.GuardLevel.None]: ["#4ebcec", "#F9CCDF"],
|
|
2202
|
+
[blive_message_listener.GuardLevel.Jianzhang]: ["#4ebcec", "#b494e5"],
|
|
2203
|
+
[blive_message_listener.GuardLevel.Tidu]: ["#d8a0e6", "#b494e5"],
|
|
2204
|
+
[blive_message_listener.GuardLevel.Zongdu]: ["#f2a053", "#ef5f5f"]
|
|
2205
|
+
};
|
|
2206
|
+
async generateBoardingImg(captainImgUrl, { guard_level, user: { face, uname, badge: { name: name$2, level, color } } }, { masterAvatarUrl, masterName }) {
|
|
2207
|
+
const bgColor = GenerateImg.BG_COLOR[guard_level];
|
|
2208
|
+
const html = `
|
|
2209
|
+
<!DOCTYPE html>
|
|
2210
|
+
<html>
|
|
2211
|
+
|
|
2212
|
+
<head>
|
|
2213
|
+
<title>上舰通知</title>
|
|
2214
|
+
<style>
|
|
2215
|
+
* {
|
|
2216
|
+
margin: 0;
|
|
2217
|
+
padding: 0;
|
|
2218
|
+
box-sizing: border-box;
|
|
2219
|
+
font-family: \"${this.giConfig.font}\", "Microsoft YaHei", "Source Han Sans", "Noto Sans CJK", sans-serif;
|
|
2220
|
+
}
|
|
2221
|
+
|
|
2222
|
+
html {
|
|
2223
|
+
width: 430px;
|
|
2224
|
+
height: auto;
|
|
2225
|
+
}
|
|
2226
|
+
|
|
2227
|
+
.bg {
|
|
2228
|
+
display: flex;
|
|
2229
|
+
justify-content: center;
|
|
2230
|
+
align-items: center;
|
|
2231
|
+
width: 430px;
|
|
2232
|
+
height: 220px;
|
|
2233
|
+
background: linear-gradient(to right bottom, ${bgColor[0]}, ${bgColor[1]});
|
|
2234
|
+
}
|
|
2235
|
+
|
|
2236
|
+
.baseplate {
|
|
2237
|
+
display: flex;
|
|
2238
|
+
justify-content: space-between;
|
|
2239
|
+
align-items: center;
|
|
2240
|
+
border-radius: 10px;
|
|
2241
|
+
width: 410px;
|
|
2242
|
+
height: 200px;
|
|
2243
|
+
box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2);
|
|
2244
|
+
background-color: rgba(255, 255, 255, 0.65);
|
|
2245
|
+
backdrop-filter: blur(10px);
|
|
2246
|
+
}
|
|
2247
|
+
|
|
2248
|
+
.info {
|
|
2249
|
+
flex: 1;
|
|
2250
|
+
height: 100%;
|
|
2251
|
+
display: flex;
|
|
2252
|
+
flex-direction: column;
|
|
2253
|
+
justify-content: space-between;
|
|
2254
|
+
padding: 10px 0 10px 10px;
|
|
2255
|
+
}
|
|
2256
|
+
|
|
2257
|
+
.user {
|
|
2258
|
+
display: flex;
|
|
2259
|
+
align-items: center;
|
|
2260
|
+
gap: 10px;
|
|
2261
|
+
}
|
|
2262
|
+
|
|
2263
|
+
.avatar {
|
|
2264
|
+
height: 90px;
|
|
2265
|
+
width: 90px;
|
|
2266
|
+
border-radius: 50%;
|
|
2267
|
+
}
|
|
2268
|
+
|
|
2269
|
+
.avatar img {
|
|
2270
|
+
width: 100%;
|
|
2271
|
+
height: 100%;
|
|
2272
|
+
border-radius: 50%;
|
|
2273
|
+
}
|
|
2274
|
+
|
|
2275
|
+
.badge {
|
|
2276
|
+
display: flex;
|
|
2277
|
+
align-items: center;
|
|
2278
|
+
height: 25px;
|
|
2279
|
+
background-color: ${color};
|
|
2280
|
+
border-radius: 25px;
|
|
2281
|
+
color: white;
|
|
2282
|
+
font-size: 12px;
|
|
2283
|
+
padding: 5px 0;
|
|
2284
|
+
border: solid 1px white;
|
|
2285
|
+
overflow: hidden;
|
|
2286
|
+
}
|
|
2287
|
+
|
|
2288
|
+
.badge-avatar {
|
|
2289
|
+
width: 25px;
|
|
2290
|
+
height: 25px;
|
|
2291
|
+
border-radius: 50%;
|
|
2292
|
+
background: url("${masterAvatarUrl}") no-repeat center;
|
|
2293
|
+
background-size: cover;
|
|
2294
|
+
margin-right: 5px;
|
|
2295
|
+
}
|
|
2296
|
+
|
|
2297
|
+
.badge span {
|
|
2298
|
+
font-weight: bold;
|
|
2299
|
+
font-size: 14px;
|
|
2300
|
+
margin-right: 5px;
|
|
2301
|
+
}
|
|
2302
|
+
|
|
2303
|
+
.desc {
|
|
2304
|
+
margin-bottom: 10px;
|
|
2305
|
+
font-size: 16px;
|
|
2306
|
+
font-weight: bold;
|
|
2307
|
+
font-style: italic;
|
|
2308
|
+
color: #333;
|
|
2309
|
+
}
|
|
2310
|
+
|
|
2311
|
+
.captain {
|
|
2312
|
+
width: 175px;
|
|
2313
|
+
height: 175px;
|
|
2314
|
+
background: url("${captainImgUrl}") no-repeat center;
|
|
2315
|
+
background-size: cover;
|
|
2316
|
+
}
|
|
2317
|
+
</style>
|
|
2318
|
+
</head>
|
|
2319
|
+
|
|
2320
|
+
<body>
|
|
2321
|
+
<div class="bg">
|
|
2322
|
+
<div class="baseplate">
|
|
2323
|
+
<div class="info">
|
|
2324
|
+
<div class="user">
|
|
2325
|
+
<div class="avatar">
|
|
2326
|
+
<img src="${face}" alt="用户头像">
|
|
2327
|
+
</div>
|
|
2328
|
+
<div class="badge">
|
|
2329
|
+
<div class="badge-avatar"></div>${name$2} <span>${level}</span>
|
|
2330
|
+
</div>
|
|
2331
|
+
</div>
|
|
2332
|
+
<div class="desc">
|
|
2333
|
+
<p>"${guard_level === blive_message_listener.GuardLevel.Jianzhang ? `${uname}号` : uname}"${guard_level === blive_message_listener.GuardLevel.Jianzhang ? "加入" : guard_level === blive_message_listener.GuardLevel.Tidu ? "就任" : "上任"}</p>
|
|
2334
|
+
"${masterName}"的大航海舰队${guard_level === blive_message_listener.GuardLevel.Tidu ? "提督" : ""}${guard_level === blive_message_listener.GuardLevel.Zongdu ? "总督" : ""}!
|
|
2335
|
+
</div>
|
|
2336
|
+
</div>
|
|
2337
|
+
<div class="captain"></div>
|
|
2338
|
+
</div>
|
|
2339
|
+
</div>
|
|
2340
|
+
</body>
|
|
2341
|
+
|
|
2342
|
+
</html>
|
|
2343
|
+
`;
|
|
2344
|
+
return await withRetry(() => this.imgHandler(html)).catch((e) => {
|
|
2345
|
+
throw new Error(`生成图片失败!错误: ${e.toString()}`);
|
|
2346
|
+
});
|
|
2347
|
+
}
|
|
2201
2348
|
richTextParser(rt, title) {
|
|
2202
2349
|
const richText = rt.reduce((accumulator, currentValue) => {
|
|
2203
2350
|
if (currentValue.emoji) return `${accumulator}<img style="width:28px; height:28px;" src="${currentValue.emoji.icon_url}"/>`;
|
|
@@ -2463,19 +2610,13 @@ var GenerateImg = class extends koishi.Service {
|
|
|
2463
2610
|
return [main$1, forwardInfo];
|
|
2464
2611
|
};
|
|
2465
2612
|
const [main] = await getDynamicMajor(data, false);
|
|
2466
|
-
const fontURL = (0, node_url.pathToFileURL)((0, node_path.resolve)(__dirname, "font/HYZhengYuan-75W.ttf"));
|
|
2467
2613
|
let style;
|
|
2468
2614
|
if (this.giConfig.enableLargeFont) style = `
|
|
2469
|
-
@font-face {
|
|
2470
|
-
font-family: "Custom Font";
|
|
2471
|
-
src: url(${fontURL});
|
|
2472
|
-
}
|
|
2473
|
-
|
|
2474
2615
|
* {
|
|
2475
2616
|
margin: 0;
|
|
2476
2617
|
padding: 0;
|
|
2477
2618
|
box-sizing: border-box;
|
|
2478
|
-
font-family: \"${this.giConfig.font}\", "
|
|
2619
|
+
font-family: \"${this.giConfig.font}\", "Microsoft YaHei", "Source Han Sans", "Noto Sans CJK", sans-serif;
|
|
2479
2620
|
}
|
|
2480
2621
|
|
|
2481
2622
|
html {
|
|
@@ -2834,16 +2975,11 @@ var GenerateImg = class extends koishi.Service {
|
|
|
2834
2975
|
}
|
|
2835
2976
|
`;
|
|
2836
2977
|
else style = `
|
|
2837
|
-
@font-face {
|
|
2838
|
-
font-family: "Custom Font";
|
|
2839
|
-
src: url(${fontURL});
|
|
2840
|
-
}
|
|
2841
|
-
|
|
2842
2978
|
* {
|
|
2843
2979
|
margin: 0;
|
|
2844
2980
|
padding: 0;
|
|
2845
2981
|
box-sizing: border-box;
|
|
2846
|
-
font-family: \"${this.giConfig.font}\", "
|
|
2982
|
+
font-family: \"${this.giConfig.font}\", "Microsoft YaHei", "Source Han Sans", "Noto Sans CJK", sans-serif;
|
|
2847
2983
|
}
|
|
2848
2984
|
|
|
2849
2985
|
html {
|
|
@@ -3288,7 +3424,6 @@ var GenerateImg = class extends koishi.Service {
|
|
|
3288
3424
|
});
|
|
3289
3425
|
}
|
|
3290
3426
|
async generateWordCloudImg(words, masterName) {
|
|
3291
|
-
const fontURL = (0, node_url.pathToFileURL)((0, node_path.resolve)(__dirname, "font/HYZhengYuan-75W.ttf"));
|
|
3292
3427
|
const wordcloudJS = (0, node_url.pathToFileURL)((0, node_path.resolve)(__dirname, "static/wordcloud2.min.js"));
|
|
3293
3428
|
const renderFunc = (0, node_url.pathToFileURL)((0, node_path.resolve)(__dirname, "static/render.js"));
|
|
3294
3429
|
const html = `
|
|
@@ -3299,16 +3434,11 @@ var GenerateImg = class extends koishi.Service {
|
|
|
3299
3434
|
<meta charset="UTF-8">
|
|
3300
3435
|
<title>高清词云展示</title>
|
|
3301
3436
|
<style>
|
|
3302
|
-
@font-face {
|
|
3303
|
-
font-family: "Custom Font";
|
|
3304
|
-
src: url(${fontURL});
|
|
3305
|
-
}
|
|
3306
|
-
|
|
3307
3437
|
* {
|
|
3308
3438
|
margin: 0;
|
|
3309
3439
|
padding: 0;
|
|
3310
3440
|
box-sizing: border-box;
|
|
3311
|
-
font-family: \"${this.giConfig.font}\", "
|
|
3441
|
+
font-family: \"${this.giConfig.font}\", "Microsoft YaHei", "Source Han Sans", "Noto Sans CJK", sans-serif;
|
|
3312
3442
|
}
|
|
3313
3443
|
|
|
3314
3444
|
html {
|
package/lib/index.mjs
CHANGED
|
@@ -340,7 +340,7 @@ var stop_words_default = stopwords;
|
|
|
340
340
|
|
|
341
341
|
//#endregion
|
|
342
342
|
//#region src/command_register.ts
|
|
343
|
-
var ComRegister = class {
|
|
343
|
+
var ComRegister = class ComRegister {
|
|
344
344
|
static inject = [
|
|
345
345
|
"bilibili-notify",
|
|
346
346
|
"bilibili-notify-api",
|
|
@@ -1275,6 +1275,11 @@ var ComRegister = class {
|
|
|
1275
1275
|
addUserToDanmakuMaker(username, danmakuMakerRecord) {
|
|
1276
1276
|
danmakuMakerRecord[username] = (danmakuMakerRecord[username] || 0) + 1;
|
|
1277
1277
|
}
|
|
1278
|
+
static GUARD_LEVEL_IMG = {
|
|
1279
|
+
[GuardLevel.Jianzhang]: "https://s1.hdslb.com/bfs/static/blive/live-pay-mono/relation/relation/assets/captain-Bjw5Byb5.png",
|
|
1280
|
+
[GuardLevel.Tidu]: "https://s1.hdslb.com/bfs/static/blive/live-pay-mono/relation/relation/assets/supervisor-u43ElIjU.png",
|
|
1281
|
+
[GuardLevel.Zongdu]: "https://s1.hdslb.com/bfs/static/blive/live-pay-mono/relation/relation/assets/governor-DpDXKEdA.png"
|
|
1282
|
+
};
|
|
1278
1283
|
async liveDetectWithListener(sub) {
|
|
1279
1284
|
let liveTime;
|
|
1280
1285
|
let pushAtTimeTimer;
|
|
@@ -1285,11 +1290,6 @@ var ComRegister = class {
|
|
|
1285
1290
|
let masterInfo;
|
|
1286
1291
|
const liveData = { likedNum: "0" };
|
|
1287
1292
|
const liveMsgObj = this.liveMsgManager.get(sub.uid);
|
|
1288
|
-
const guardLevelImg = {
|
|
1289
|
-
[GuardLevel.Jianzhang]: "https://s1.hdslb.com/bfs/static/blive/live-pay-mono/relation/relation/assets/captain-Bjw5Byb5.png",
|
|
1290
|
-
[GuardLevel.Tidu]: "https://s1.hdslb.com/bfs/static/blive/live-pay-mono/relation/relation/assets/supervisor-u43ElIjU.png",
|
|
1291
|
-
[GuardLevel.Zongdu]: "https://s1.hdslb.com/bfs/static/blive/live-pay-mono/relation/relation/assets/governor-DpDXKEdA.png"
|
|
1292
|
-
};
|
|
1293
1293
|
const sendDanmakuWordCloudAndLiveSummary = async (customLiveSummary) => {
|
|
1294
1294
|
this.logger.info("开始制作弹幕词云");
|
|
1295
1295
|
this.logger.info("正在获取前90热词");
|
|
@@ -1426,10 +1426,14 @@ var ComRegister = class {
|
|
|
1426
1426
|
liveData.likedNum = body.count.toString();
|
|
1427
1427
|
console.log(liveData.likedNum);
|
|
1428
1428
|
},
|
|
1429
|
-
onGuardBuy: ({ body }) => {
|
|
1430
|
-
const guardImg =
|
|
1431
|
-
const
|
|
1432
|
-
|
|
1429
|
+
onGuardBuy: async ({ body }) => {
|
|
1430
|
+
const guardImg = ComRegister.GUARD_LEVEL_IMG[body.guard_level];
|
|
1431
|
+
const buffer = await this.ctx["bilibili-notify-generate-img"].generateBoardingImg(guardImg, body, {
|
|
1432
|
+
masterName: masterInfo.username,
|
|
1433
|
+
masterAvatarUrl: masterInfo.userface
|
|
1434
|
+
});
|
|
1435
|
+
const img = h.image(buffer, "image/jpeg");
|
|
1436
|
+
this.broadcastToTargets(sub.uid, img, PushType.LiveGuardBuy);
|
|
1433
1437
|
},
|
|
1434
1438
|
onLiveStart: async () => {
|
|
1435
1439
|
const now = Date.now();
|
|
@@ -1993,7 +1997,7 @@ const DYNAMIC_TYPE_COURSES_SEASON = "DYNAMIC_TYPE_COURSES_SEASON";
|
|
|
1993
1997
|
const DYNAMIC_TYPE_LIVE_RCMD = "DYNAMIC_TYPE_LIVE_RCMD";
|
|
1994
1998
|
const DYNAMIC_TYPE_UGC_SEASON = "DYNAMIC_TYPE_UGC_SEASON";
|
|
1995
1999
|
const ADDITIONAL_TYPE_RESERVE = "ADDITIONAL_TYPE_RESERVE";
|
|
1996
|
-
var GenerateImg = class extends Service {
|
|
2000
|
+
var GenerateImg = class GenerateImg extends Service {
|
|
1997
2001
|
static inject = ["puppeteer"];
|
|
1998
2002
|
giConfig;
|
|
1999
2003
|
constructor(ctx, config) {
|
|
@@ -2031,16 +2035,11 @@ var GenerateImg = class extends Service {
|
|
|
2031
2035
|
<head>
|
|
2032
2036
|
<title>直播通知</title>
|
|
2033
2037
|
<style>
|
|
2034
|
-
@font-face {
|
|
2035
|
-
font-family: "Custom Font";
|
|
2036
|
-
src: url(${pathToFileURL(resolve(__dirname, "font/HYZhengYuan-75W.ttf"))});
|
|
2037
|
-
}
|
|
2038
|
-
|
|
2039
2038
|
* {
|
|
2040
2039
|
margin: 0;
|
|
2041
2040
|
padding: 0;
|
|
2042
2041
|
box-sizing: border-box;
|
|
2043
|
-
font-family: \"${this.giConfig.font}\", "
|
|
2042
|
+
font-family: \"${this.giConfig.font}\", "Microsoft YaHei", "Source Han Sans", "Noto Sans CJK", sans-serif;
|
|
2044
2043
|
}
|
|
2045
2044
|
|
|
2046
2045
|
html {
|
|
@@ -2173,6 +2172,154 @@ var GenerateImg = class extends Service {
|
|
|
2173
2172
|
throw new Error(`生成图片失败!错误: ${e.toString()}`);
|
|
2174
2173
|
});
|
|
2175
2174
|
}
|
|
2175
|
+
static BG_COLOR = {
|
|
2176
|
+
[GuardLevel.None]: ["#4ebcec", "#F9CCDF"],
|
|
2177
|
+
[GuardLevel.Jianzhang]: ["#4ebcec", "#b494e5"],
|
|
2178
|
+
[GuardLevel.Tidu]: ["#d8a0e6", "#b494e5"],
|
|
2179
|
+
[GuardLevel.Zongdu]: ["#f2a053", "#ef5f5f"]
|
|
2180
|
+
};
|
|
2181
|
+
async generateBoardingImg(captainImgUrl, { guard_level, user: { face, uname, badge: { name: name$2, level, color } } }, { masterAvatarUrl, masterName }) {
|
|
2182
|
+
const bgColor = GenerateImg.BG_COLOR[guard_level];
|
|
2183
|
+
const html = `
|
|
2184
|
+
<!DOCTYPE html>
|
|
2185
|
+
<html>
|
|
2186
|
+
|
|
2187
|
+
<head>
|
|
2188
|
+
<title>上舰通知</title>
|
|
2189
|
+
<style>
|
|
2190
|
+
* {
|
|
2191
|
+
margin: 0;
|
|
2192
|
+
padding: 0;
|
|
2193
|
+
box-sizing: border-box;
|
|
2194
|
+
font-family: \"${this.giConfig.font}\", "Microsoft YaHei", "Source Han Sans", "Noto Sans CJK", sans-serif;
|
|
2195
|
+
}
|
|
2196
|
+
|
|
2197
|
+
html {
|
|
2198
|
+
width: 430px;
|
|
2199
|
+
height: auto;
|
|
2200
|
+
}
|
|
2201
|
+
|
|
2202
|
+
.bg {
|
|
2203
|
+
display: flex;
|
|
2204
|
+
justify-content: center;
|
|
2205
|
+
align-items: center;
|
|
2206
|
+
width: 430px;
|
|
2207
|
+
height: 220px;
|
|
2208
|
+
background: linear-gradient(to right bottom, ${bgColor[0]}, ${bgColor[1]});
|
|
2209
|
+
}
|
|
2210
|
+
|
|
2211
|
+
.baseplate {
|
|
2212
|
+
display: flex;
|
|
2213
|
+
justify-content: space-between;
|
|
2214
|
+
align-items: center;
|
|
2215
|
+
border-radius: 10px;
|
|
2216
|
+
width: 410px;
|
|
2217
|
+
height: 200px;
|
|
2218
|
+
box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2);
|
|
2219
|
+
background-color: rgba(255, 255, 255, 0.65);
|
|
2220
|
+
backdrop-filter: blur(10px);
|
|
2221
|
+
}
|
|
2222
|
+
|
|
2223
|
+
.info {
|
|
2224
|
+
flex: 1;
|
|
2225
|
+
height: 100%;
|
|
2226
|
+
display: flex;
|
|
2227
|
+
flex-direction: column;
|
|
2228
|
+
justify-content: space-between;
|
|
2229
|
+
padding: 10px 0 10px 10px;
|
|
2230
|
+
}
|
|
2231
|
+
|
|
2232
|
+
.user {
|
|
2233
|
+
display: flex;
|
|
2234
|
+
align-items: center;
|
|
2235
|
+
gap: 10px;
|
|
2236
|
+
}
|
|
2237
|
+
|
|
2238
|
+
.avatar {
|
|
2239
|
+
height: 90px;
|
|
2240
|
+
width: 90px;
|
|
2241
|
+
border-radius: 50%;
|
|
2242
|
+
}
|
|
2243
|
+
|
|
2244
|
+
.avatar img {
|
|
2245
|
+
width: 100%;
|
|
2246
|
+
height: 100%;
|
|
2247
|
+
border-radius: 50%;
|
|
2248
|
+
}
|
|
2249
|
+
|
|
2250
|
+
.badge {
|
|
2251
|
+
display: flex;
|
|
2252
|
+
align-items: center;
|
|
2253
|
+
height: 25px;
|
|
2254
|
+
background-color: ${color};
|
|
2255
|
+
border-radius: 25px;
|
|
2256
|
+
color: white;
|
|
2257
|
+
font-size: 12px;
|
|
2258
|
+
padding: 5px 0;
|
|
2259
|
+
border: solid 1px white;
|
|
2260
|
+
overflow: hidden;
|
|
2261
|
+
}
|
|
2262
|
+
|
|
2263
|
+
.badge-avatar {
|
|
2264
|
+
width: 25px;
|
|
2265
|
+
height: 25px;
|
|
2266
|
+
border-radius: 50%;
|
|
2267
|
+
background: url("${masterAvatarUrl}") no-repeat center;
|
|
2268
|
+
background-size: cover;
|
|
2269
|
+
margin-right: 5px;
|
|
2270
|
+
}
|
|
2271
|
+
|
|
2272
|
+
.badge span {
|
|
2273
|
+
font-weight: bold;
|
|
2274
|
+
font-size: 14px;
|
|
2275
|
+
margin-right: 5px;
|
|
2276
|
+
}
|
|
2277
|
+
|
|
2278
|
+
.desc {
|
|
2279
|
+
margin-bottom: 10px;
|
|
2280
|
+
font-size: 16px;
|
|
2281
|
+
font-weight: bold;
|
|
2282
|
+
font-style: italic;
|
|
2283
|
+
color: #333;
|
|
2284
|
+
}
|
|
2285
|
+
|
|
2286
|
+
.captain {
|
|
2287
|
+
width: 175px;
|
|
2288
|
+
height: 175px;
|
|
2289
|
+
background: url("${captainImgUrl}") no-repeat center;
|
|
2290
|
+
background-size: cover;
|
|
2291
|
+
}
|
|
2292
|
+
</style>
|
|
2293
|
+
</head>
|
|
2294
|
+
|
|
2295
|
+
<body>
|
|
2296
|
+
<div class="bg">
|
|
2297
|
+
<div class="baseplate">
|
|
2298
|
+
<div class="info">
|
|
2299
|
+
<div class="user">
|
|
2300
|
+
<div class="avatar">
|
|
2301
|
+
<img src="${face}" alt="用户头像">
|
|
2302
|
+
</div>
|
|
2303
|
+
<div class="badge">
|
|
2304
|
+
<div class="badge-avatar"></div>${name$2} <span>${level}</span>
|
|
2305
|
+
</div>
|
|
2306
|
+
</div>
|
|
2307
|
+
<div class="desc">
|
|
2308
|
+
<p>"${guard_level === GuardLevel.Jianzhang ? `${uname}号` : uname}"${guard_level === GuardLevel.Jianzhang ? "加入" : guard_level === GuardLevel.Tidu ? "就任" : "上任"}</p>
|
|
2309
|
+
"${masterName}"的大航海舰队${guard_level === GuardLevel.Tidu ? "提督" : ""}${guard_level === GuardLevel.Zongdu ? "总督" : ""}!
|
|
2310
|
+
</div>
|
|
2311
|
+
</div>
|
|
2312
|
+
<div class="captain"></div>
|
|
2313
|
+
</div>
|
|
2314
|
+
</div>
|
|
2315
|
+
</body>
|
|
2316
|
+
|
|
2317
|
+
</html>
|
|
2318
|
+
`;
|
|
2319
|
+
return await withRetry(() => this.imgHandler(html)).catch((e) => {
|
|
2320
|
+
throw new Error(`生成图片失败!错误: ${e.toString()}`);
|
|
2321
|
+
});
|
|
2322
|
+
}
|
|
2176
2323
|
richTextParser(rt, title) {
|
|
2177
2324
|
const richText = rt.reduce((accumulator, currentValue) => {
|
|
2178
2325
|
if (currentValue.emoji) return `${accumulator}<img style="width:28px; height:28px;" src="${currentValue.emoji.icon_url}"/>`;
|
|
@@ -2438,19 +2585,13 @@ var GenerateImg = class extends Service {
|
|
|
2438
2585
|
return [main$1, forwardInfo];
|
|
2439
2586
|
};
|
|
2440
2587
|
const [main] = await getDynamicMajor(data, false);
|
|
2441
|
-
const fontURL = pathToFileURL(resolve(__dirname, "font/HYZhengYuan-75W.ttf"));
|
|
2442
2588
|
let style;
|
|
2443
2589
|
if (this.giConfig.enableLargeFont) style = `
|
|
2444
|
-
@font-face {
|
|
2445
|
-
font-family: "Custom Font";
|
|
2446
|
-
src: url(${fontURL});
|
|
2447
|
-
}
|
|
2448
|
-
|
|
2449
2590
|
* {
|
|
2450
2591
|
margin: 0;
|
|
2451
2592
|
padding: 0;
|
|
2452
2593
|
box-sizing: border-box;
|
|
2453
|
-
font-family: \"${this.giConfig.font}\", "
|
|
2594
|
+
font-family: \"${this.giConfig.font}\", "Microsoft YaHei", "Source Han Sans", "Noto Sans CJK", sans-serif;
|
|
2454
2595
|
}
|
|
2455
2596
|
|
|
2456
2597
|
html {
|
|
@@ -2809,16 +2950,11 @@ var GenerateImg = class extends Service {
|
|
|
2809
2950
|
}
|
|
2810
2951
|
`;
|
|
2811
2952
|
else style = `
|
|
2812
|
-
@font-face {
|
|
2813
|
-
font-family: "Custom Font";
|
|
2814
|
-
src: url(${fontURL});
|
|
2815
|
-
}
|
|
2816
|
-
|
|
2817
2953
|
* {
|
|
2818
2954
|
margin: 0;
|
|
2819
2955
|
padding: 0;
|
|
2820
2956
|
box-sizing: border-box;
|
|
2821
|
-
font-family: \"${this.giConfig.font}\", "
|
|
2957
|
+
font-family: \"${this.giConfig.font}\", "Microsoft YaHei", "Source Han Sans", "Noto Sans CJK", sans-serif;
|
|
2822
2958
|
}
|
|
2823
2959
|
|
|
2824
2960
|
html {
|
|
@@ -3263,7 +3399,6 @@ var GenerateImg = class extends Service {
|
|
|
3263
3399
|
});
|
|
3264
3400
|
}
|
|
3265
3401
|
async generateWordCloudImg(words, masterName) {
|
|
3266
|
-
const fontURL = pathToFileURL(resolve(__dirname, "font/HYZhengYuan-75W.ttf"));
|
|
3267
3402
|
const wordcloudJS = pathToFileURL(resolve(__dirname, "static/wordcloud2.min.js"));
|
|
3268
3403
|
const renderFunc = pathToFileURL(resolve(__dirname, "static/render.js"));
|
|
3269
3404
|
const html = `
|
|
@@ -3274,16 +3409,11 @@ var GenerateImg = class extends Service {
|
|
|
3274
3409
|
<meta charset="UTF-8">
|
|
3275
3410
|
<title>高清词云展示</title>
|
|
3276
3411
|
<style>
|
|
3277
|
-
@font-face {
|
|
3278
|
-
font-family: "Custom Font";
|
|
3279
|
-
src: url(${fontURL});
|
|
3280
|
-
}
|
|
3281
|
-
|
|
3282
3412
|
* {
|
|
3283
3413
|
margin: 0;
|
|
3284
3414
|
padding: 0;
|
|
3285
3415
|
box-sizing: border-box;
|
|
3286
|
-
font-family: \"${this.giConfig.font}\", "
|
|
3416
|
+
font-family: \"${this.giConfig.font}\", "Microsoft YaHei", "Source Han Sans", "Noto Sans CJK", sans-serif;
|
|
3287
3417
|
}
|
|
3288
3418
|
|
|
3289
3419
|
html {
|