koishi-plugin-bilibili-notify 3.4.0-alpha.3 → 3.4.0-alpha.5
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 +112 -19
- package/lib/index.mjs +112 -19
- package/package.json +1 -1
package/lib/index.cjs
CHANGED
|
@@ -713,6 +713,19 @@ var ComRegister = class ComRegister {
|
|
|
713
713
|
this.logger.info("AI 生成完毕,结果为:");
|
|
714
714
|
this.logger.info(res.choices[0].message.content);
|
|
715
715
|
});
|
|
716
|
+
biliCom.subcommand(".img").action(async ({ session }) => {
|
|
717
|
+
const guardImg = ComRegister.GUARD_LEVEL_IMG[blive_message_listener.GuardLevel.Jianzhang];
|
|
718
|
+
const buffer = await this.ctx["bilibili-notify-generate-img"].generateBoardingImg(guardImg, {
|
|
719
|
+
guardLevel: blive_message_listener.GuardLevel.Jianzhang,
|
|
720
|
+
face: "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQSESgEED4WoyK9O5FFgrV8cHZPM4w4JgleZQ&s",
|
|
721
|
+
uname: "恶魔兔",
|
|
722
|
+
accompany: 56
|
|
723
|
+
}, {
|
|
724
|
+
masterName: "籽岷",
|
|
725
|
+
masterAvatarUrl: "https://img.touxiangkong.com/uploads/allimg/20203301251/2020/3/BjEbyu.jpg"
|
|
726
|
+
});
|
|
727
|
+
await session.send(koishi.h.image(buffer, "image/jpeg"));
|
|
728
|
+
});
|
|
716
729
|
}
|
|
717
730
|
async init(config) {
|
|
718
731
|
this.logger = this.ctx.logger("bilibili-notify-core");
|
|
@@ -1447,13 +1460,24 @@ var ComRegister = class ComRegister {
|
|
|
1447
1460
|
liveData.watchedNum = body.text_small;
|
|
1448
1461
|
},
|
|
1449
1462
|
onLikedChange: ({ body }) => {
|
|
1450
|
-
console.log(body.count);
|
|
1451
1463
|
liveData.likedNum = body.count.toString();
|
|
1452
|
-
console.log(liveData.likedNum);
|
|
1453
1464
|
},
|
|
1454
1465
|
onGuardBuy: async ({ body }) => {
|
|
1455
1466
|
const guardImg = ComRegister.GUARD_LEVEL_IMG[body.guard_level];
|
|
1456
|
-
const
|
|
1467
|
+
const data = await this.ctx["bilibili-notify-api"].getUserInfoInLive(body.user.uid.toString(), sub.uid);
|
|
1468
|
+
if (data.code !== 0) {
|
|
1469
|
+
const content = (0, koishi.h)("message", [koishi.h.text(`【${masterInfo.username}的直播间】${body.user.uname}加入了大航海(${body.gift_name})`), koishi.h.image(guardImg)]);
|
|
1470
|
+
return this.broadcastToTargets(sub.uid, content, PushType.LiveGuardBuy);
|
|
1471
|
+
}
|
|
1472
|
+
console.log(data);
|
|
1473
|
+
const userInfo = data.data;
|
|
1474
|
+
console.log(userInfo);
|
|
1475
|
+
const buffer = await this.ctx["bilibili-notify-generate-img"].generateBoardingImg(guardImg, {
|
|
1476
|
+
guardLevel: body.guard_level,
|
|
1477
|
+
uname: userInfo.uname,
|
|
1478
|
+
face: userInfo.face,
|
|
1479
|
+
accompany: userInfo.guard.accompany
|
|
1480
|
+
}, {
|
|
1457
1481
|
masterName: masterInfo.username,
|
|
1458
1482
|
masterAvatarUrl: masterInfo.userface
|
|
1459
1483
|
});
|
|
@@ -2203,8 +2227,20 @@ var GenerateImg = class GenerateImg extends koishi.Service {
|
|
|
2203
2227
|
[blive_message_listener.GuardLevel.Tidu]: ["#d8a0e6", "#b494e5"],
|
|
2204
2228
|
[blive_message_listener.GuardLevel.Zongdu]: ["#f2a053", "#ef5f5f"]
|
|
2205
2229
|
};
|
|
2206
|
-
async generateBoardingImg(captainImgUrl, {
|
|
2207
|
-
const bgColor = GenerateImg.BG_COLOR[
|
|
2230
|
+
async generateBoardingImg(captainImgUrl, { guardLevel, uname, face, accompany }, { masterAvatarUrl, masterName }) {
|
|
2231
|
+
const bgColor = GenerateImg.BG_COLOR[guardLevel];
|
|
2232
|
+
const desc = {
|
|
2233
|
+
[blive_message_listener.GuardLevel.Jianzhang]: () => {
|
|
2234
|
+
if (accompany && accompany > 0) return `"${uname}号"继续在<br/>"${masterName}"大航海舰队服役!`;
|
|
2235
|
+
return `"${uname}号"加入<br/>"${masterName}"大航海舰队!`;
|
|
2236
|
+
},
|
|
2237
|
+
[blive_message_listener.GuardLevel.Tidu]: () => {
|
|
2238
|
+
return `"${uname}"就任<br/>"${masterName}"大航海舰队提督!`;
|
|
2239
|
+
},
|
|
2240
|
+
[blive_message_listener.GuardLevel.Zongdu]: () => {
|
|
2241
|
+
return `"${uname}"上任<br/>"${masterName}"大航海舰队总督!`;
|
|
2242
|
+
}
|
|
2243
|
+
};
|
|
2208
2244
|
const html = `
|
|
2209
2245
|
<!DOCTYPE html>
|
|
2210
2246
|
<html>
|
|
@@ -2256,7 +2292,6 @@ var GenerateImg = class GenerateImg extends koishi.Service {
|
|
|
2256
2292
|
|
|
2257
2293
|
.user {
|
|
2258
2294
|
display: flex;
|
|
2259
|
-
align-items: center;
|
|
2260
2295
|
gap: 10px;
|
|
2261
2296
|
}
|
|
2262
2297
|
|
|
@@ -2270,33 +2305,61 @@ var GenerateImg = class GenerateImg extends koishi.Service {
|
|
|
2270
2305
|
width: 100%;
|
|
2271
2306
|
height: 100%;
|
|
2272
2307
|
border-radius: 50%;
|
|
2308
|
+
border: 3px solid white;
|
|
2309
|
+
}
|
|
2310
|
+
|
|
2311
|
+
.user-info {
|
|
2312
|
+
display: flex;
|
|
2313
|
+
flex-direction: column;
|
|
2314
|
+
align-items: flex-start;
|
|
2315
|
+
gap: 5px;
|
|
2316
|
+
margin-top: 10px;
|
|
2273
2317
|
}
|
|
2274
2318
|
|
|
2275
|
-
.badge {
|
|
2319
|
+
.name-badge {
|
|
2276
2320
|
display: flex;
|
|
2277
2321
|
align-items: center;
|
|
2278
|
-
height:
|
|
2279
|
-
background-color: ${
|
|
2322
|
+
height: 30px;
|
|
2323
|
+
background-color: ${bgColor[0]};
|
|
2280
2324
|
border-radius: 25px;
|
|
2281
2325
|
color: white;
|
|
2326
|
+
padding: 0 10px;
|
|
2327
|
+
border: solid 2px white;
|
|
2328
|
+
overflow: hidden;
|
|
2329
|
+
}
|
|
2330
|
+
|
|
2331
|
+
.name-badge span {
|
|
2332
|
+
max-width: 100px;
|
|
2333
|
+
white-space: nowrap;
|
|
2334
|
+
text-overflow: ellipsis;
|
|
2335
|
+
overflow: hidden;
|
|
2336
|
+
font-weight: bold;
|
|
2282
2337
|
font-size: 12px;
|
|
2283
|
-
|
|
2284
|
-
|
|
2338
|
+
}
|
|
2339
|
+
|
|
2340
|
+
.accompany {
|
|
2341
|
+
display: flex;
|
|
2342
|
+
gap: 5px;
|
|
2343
|
+
align-items: center;
|
|
2344
|
+
height: 25px;
|
|
2345
|
+
background-color: ${bgColor[0]};
|
|
2346
|
+
border-radius: 25px;
|
|
2347
|
+
border: solid 2px white;
|
|
2285
2348
|
overflow: hidden;
|
|
2286
2349
|
}
|
|
2287
2350
|
|
|
2288
|
-
.
|
|
2351
|
+
.master-avatar {
|
|
2289
2352
|
width: 25px;
|
|
2290
2353
|
height: 25px;
|
|
2291
2354
|
border-radius: 50%;
|
|
2292
2355
|
background: url("${masterAvatarUrl}") no-repeat center;
|
|
2293
2356
|
background-size: cover;
|
|
2294
|
-
margin-right: 5px;
|
|
2295
2357
|
}
|
|
2296
2358
|
|
|
2297
|
-
.
|
|
2359
|
+
.accompany span {
|
|
2360
|
+
color: white;
|
|
2361
|
+
font-size: 10px;
|
|
2298
2362
|
font-weight: bold;
|
|
2299
|
-
font-size: 14px;
|
|
2300
2363
|
margin-right: 5px;
|
|
2301
2364
|
}
|
|
2302
2365
|
|
|
@@ -2325,13 +2388,17 @@ var GenerateImg = class GenerateImg extends koishi.Service {
|
|
|
2325
2388
|
<div class="avatar">
|
|
2326
2389
|
<img src="${face}" alt="用户头像">
|
|
2327
2390
|
</div>
|
|
2328
|
-
<div class="
|
|
2329
|
-
<div class="badge
|
|
2391
|
+
<div class="user-info">
|
|
2392
|
+
<div class="name-badge">
|
|
2393
|
+
<span>${uname}</span>
|
|
2394
|
+
</div>
|
|
2395
|
+
<div class="accompany">
|
|
2396
|
+
<div class="master-avatar"></div><span>已服役 ${accompany} 天</span>
|
|
2397
|
+
</div>
|
|
2330
2398
|
</div>
|
|
2331
2399
|
</div>
|
|
2332
2400
|
<div class="desc">
|
|
2333
|
-
|
|
2334
|
-
"${masterName}"的大航海舰队${guard_level === blive_message_listener.GuardLevel.Tidu ? "提督" : ""}${guard_level === blive_message_listener.GuardLevel.Zongdu ? "总督" : ""}!
|
|
2401
|
+
${desc[guardLevel]()}
|
|
2335
2402
|
</div>
|
|
2336
2403
|
</div>
|
|
2337
2404
|
<div class="captain"></div>
|
|
@@ -3692,6 +3759,8 @@ const GET_MASTER_INFO = "https://api.live.bilibili.com/live_user/v1/Master/info"
|
|
|
3692
3759
|
const GET_TIME_NOW = "https://api.bilibili.com/x/report/click/now";
|
|
3693
3760
|
const GET_SERVER_UTC_TIME = "https://interface.bilibili.com/serverdate.js";
|
|
3694
3761
|
const GET_LATEST_UPDATED_UPS = "https://api.bilibili.com/x/polymer/web-dynamic/v1/portal";
|
|
3762
|
+
const GET_ONLINE_GOLD_RANK = "https://api.live.bilibili.com//xlive/general-interface/v1/rank/getOnlineGoldRank";
|
|
3763
|
+
const GET_USER_INFO_IN_LIVE = "https://api.live.bilibili.com/xlive/app-ucenter/v2/card/user";
|
|
3695
3764
|
const MODIFY_RELATION = "https://api.bilibili.com/x/relation/modify";
|
|
3696
3765
|
const CREATE_GROUP = "https://api.bilibili.com/x/relation/tag/create";
|
|
3697
3766
|
const MODIFY_GROUP_MEMBER = "https://api.bilibili.com/x/relation/tags/addUsers";
|
|
@@ -4085,6 +4154,30 @@ var BiliAPI = class extends koishi.Service {
|
|
|
4085
4154
|
retries: 3
|
|
4086
4155
|
});
|
|
4087
4156
|
}
|
|
4157
|
+
async getOnlineGoldRank(roomId, ruid, page = 1, pageSize = 20) {
|
|
4158
|
+
const run = async () => {
|
|
4159
|
+
const { data } = await this.client.get(`${GET_ONLINE_GOLD_RANK}?room_id=${roomId}&ruid=${ruid}&page=${page}&page_size=${pageSize}`);
|
|
4160
|
+
return data;
|
|
4161
|
+
};
|
|
4162
|
+
return await this.pRetry(run, {
|
|
4163
|
+
onFailedAttempt: (error) => {
|
|
4164
|
+
this.logger.error(`getOnlineGoldRank() 第${error.attemptNumber}次失败: ${error.message}`);
|
|
4165
|
+
},
|
|
4166
|
+
retries: 3
|
|
4167
|
+
});
|
|
4168
|
+
}
|
|
4169
|
+
async getUserInfoInLive(uid, ruid) {
|
|
4170
|
+
const run = async () => {
|
|
4171
|
+
const { data } = await this.client.get(`${GET_USER_INFO_IN_LIVE}?uid=${uid}&ruid=${ruid}`);
|
|
4172
|
+
return data;
|
|
4173
|
+
};
|
|
4174
|
+
return await this.pRetry(run, {
|
|
4175
|
+
onFailedAttempt: (error) => {
|
|
4176
|
+
this.logger.error(`getUserInfoInLive() 第${error.attemptNumber}次失败: ${error.message}`);
|
|
4177
|
+
},
|
|
4178
|
+
retries: 3
|
|
4179
|
+
});
|
|
4180
|
+
}
|
|
4088
4181
|
async chatWithAI(content) {
|
|
4089
4182
|
return await this.aiClient.chat.completions.create({
|
|
4090
4183
|
model: this.apiConfig.ai.model,
|
package/lib/index.mjs
CHANGED
|
@@ -688,6 +688,19 @@ var ComRegister = class ComRegister {
|
|
|
688
688
|
this.logger.info("AI 生成完毕,结果为:");
|
|
689
689
|
this.logger.info(res.choices[0].message.content);
|
|
690
690
|
});
|
|
691
|
+
biliCom.subcommand(".img").action(async ({ session }) => {
|
|
692
|
+
const guardImg = ComRegister.GUARD_LEVEL_IMG[GuardLevel.Jianzhang];
|
|
693
|
+
const buffer = await this.ctx["bilibili-notify-generate-img"].generateBoardingImg(guardImg, {
|
|
694
|
+
guardLevel: GuardLevel.Jianzhang,
|
|
695
|
+
face: "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQSESgEED4WoyK9O5FFgrV8cHZPM4w4JgleZQ&s",
|
|
696
|
+
uname: "恶魔兔",
|
|
697
|
+
accompany: 56
|
|
698
|
+
}, {
|
|
699
|
+
masterName: "籽岷",
|
|
700
|
+
masterAvatarUrl: "https://img.touxiangkong.com/uploads/allimg/20203301251/2020/3/BjEbyu.jpg"
|
|
701
|
+
});
|
|
702
|
+
await session.send(h.image(buffer, "image/jpeg"));
|
|
703
|
+
});
|
|
691
704
|
}
|
|
692
705
|
async init(config) {
|
|
693
706
|
this.logger = this.ctx.logger("bilibili-notify-core");
|
|
@@ -1422,13 +1435,24 @@ var ComRegister = class ComRegister {
|
|
|
1422
1435
|
liveData.watchedNum = body.text_small;
|
|
1423
1436
|
},
|
|
1424
1437
|
onLikedChange: ({ body }) => {
|
|
1425
|
-
console.log(body.count);
|
|
1426
1438
|
liveData.likedNum = body.count.toString();
|
|
1427
|
-
console.log(liveData.likedNum);
|
|
1428
1439
|
},
|
|
1429
1440
|
onGuardBuy: async ({ body }) => {
|
|
1430
1441
|
const guardImg = ComRegister.GUARD_LEVEL_IMG[body.guard_level];
|
|
1431
|
-
const
|
|
1442
|
+
const data = await this.ctx["bilibili-notify-api"].getUserInfoInLive(body.user.uid.toString(), sub.uid);
|
|
1443
|
+
if (data.code !== 0) {
|
|
1444
|
+
const content = h("message", [h.text(`【${masterInfo.username}的直播间】${body.user.uname}加入了大航海(${body.gift_name})`), h.image(guardImg)]);
|
|
1445
|
+
return this.broadcastToTargets(sub.uid, content, PushType.LiveGuardBuy);
|
|
1446
|
+
}
|
|
1447
|
+
console.log(data);
|
|
1448
|
+
const userInfo = data.data;
|
|
1449
|
+
console.log(userInfo);
|
|
1450
|
+
const buffer = await this.ctx["bilibili-notify-generate-img"].generateBoardingImg(guardImg, {
|
|
1451
|
+
guardLevel: body.guard_level,
|
|
1452
|
+
uname: userInfo.uname,
|
|
1453
|
+
face: userInfo.face,
|
|
1454
|
+
accompany: userInfo.guard.accompany
|
|
1455
|
+
}, {
|
|
1432
1456
|
masterName: masterInfo.username,
|
|
1433
1457
|
masterAvatarUrl: masterInfo.userface
|
|
1434
1458
|
});
|
|
@@ -2178,8 +2202,20 @@ var GenerateImg = class GenerateImg extends Service {
|
|
|
2178
2202
|
[GuardLevel.Tidu]: ["#d8a0e6", "#b494e5"],
|
|
2179
2203
|
[GuardLevel.Zongdu]: ["#f2a053", "#ef5f5f"]
|
|
2180
2204
|
};
|
|
2181
|
-
async generateBoardingImg(captainImgUrl, {
|
|
2182
|
-
const bgColor = GenerateImg.BG_COLOR[
|
|
2205
|
+
async generateBoardingImg(captainImgUrl, { guardLevel, uname, face, accompany }, { masterAvatarUrl, masterName }) {
|
|
2206
|
+
const bgColor = GenerateImg.BG_COLOR[guardLevel];
|
|
2207
|
+
const desc = {
|
|
2208
|
+
[GuardLevel.Jianzhang]: () => {
|
|
2209
|
+
if (accompany && accompany > 0) return `"${uname}号"继续在<br/>"${masterName}"大航海舰队服役!`;
|
|
2210
|
+
return `"${uname}号"加入<br/>"${masterName}"大航海舰队!`;
|
|
2211
|
+
},
|
|
2212
|
+
[GuardLevel.Tidu]: () => {
|
|
2213
|
+
return `"${uname}"就任<br/>"${masterName}"大航海舰队提督!`;
|
|
2214
|
+
},
|
|
2215
|
+
[GuardLevel.Zongdu]: () => {
|
|
2216
|
+
return `"${uname}"上任<br/>"${masterName}"大航海舰队总督!`;
|
|
2217
|
+
}
|
|
2218
|
+
};
|
|
2183
2219
|
const html = `
|
|
2184
2220
|
<!DOCTYPE html>
|
|
2185
2221
|
<html>
|
|
@@ -2231,7 +2267,6 @@ var GenerateImg = class GenerateImg extends Service {
|
|
|
2231
2267
|
|
|
2232
2268
|
.user {
|
|
2233
2269
|
display: flex;
|
|
2234
|
-
align-items: center;
|
|
2235
2270
|
gap: 10px;
|
|
2236
2271
|
}
|
|
2237
2272
|
|
|
@@ -2245,33 +2280,61 @@ var GenerateImg = class GenerateImg extends Service {
|
|
|
2245
2280
|
width: 100%;
|
|
2246
2281
|
height: 100%;
|
|
2247
2282
|
border-radius: 50%;
|
|
2283
|
+
border: 3px solid white;
|
|
2284
|
+
}
|
|
2285
|
+
|
|
2286
|
+
.user-info {
|
|
2287
|
+
display: flex;
|
|
2288
|
+
flex-direction: column;
|
|
2289
|
+
align-items: flex-start;
|
|
2290
|
+
gap: 5px;
|
|
2291
|
+
margin-top: 10px;
|
|
2248
2292
|
}
|
|
2249
2293
|
|
|
2250
|
-
.badge {
|
|
2294
|
+
.name-badge {
|
|
2251
2295
|
display: flex;
|
|
2252
2296
|
align-items: center;
|
|
2253
|
-
height:
|
|
2254
|
-
background-color: ${
|
|
2297
|
+
height: 30px;
|
|
2298
|
+
background-color: ${bgColor[0]};
|
|
2255
2299
|
border-radius: 25px;
|
|
2256
2300
|
color: white;
|
|
2301
|
+
padding: 0 10px;
|
|
2302
|
+
border: solid 2px white;
|
|
2303
|
+
overflow: hidden;
|
|
2304
|
+
}
|
|
2305
|
+
|
|
2306
|
+
.name-badge span {
|
|
2307
|
+
max-width: 100px;
|
|
2308
|
+
white-space: nowrap;
|
|
2309
|
+
text-overflow: ellipsis;
|
|
2310
|
+
overflow: hidden;
|
|
2311
|
+
font-weight: bold;
|
|
2257
2312
|
font-size: 12px;
|
|
2258
|
-
|
|
2259
|
-
|
|
2313
|
+
}
|
|
2314
|
+
|
|
2315
|
+
.accompany {
|
|
2316
|
+
display: flex;
|
|
2317
|
+
gap: 5px;
|
|
2318
|
+
align-items: center;
|
|
2319
|
+
height: 25px;
|
|
2320
|
+
background-color: ${bgColor[0]};
|
|
2321
|
+
border-radius: 25px;
|
|
2322
|
+
border: solid 2px white;
|
|
2260
2323
|
overflow: hidden;
|
|
2261
2324
|
}
|
|
2262
2325
|
|
|
2263
|
-
.
|
|
2326
|
+
.master-avatar {
|
|
2264
2327
|
width: 25px;
|
|
2265
2328
|
height: 25px;
|
|
2266
2329
|
border-radius: 50%;
|
|
2267
2330
|
background: url("${masterAvatarUrl}") no-repeat center;
|
|
2268
2331
|
background-size: cover;
|
|
2269
|
-
margin-right: 5px;
|
|
2270
2332
|
}
|
|
2271
2333
|
|
|
2272
|
-
.
|
|
2334
|
+
.accompany span {
|
|
2335
|
+
color: white;
|
|
2336
|
+
font-size: 10px;
|
|
2273
2337
|
font-weight: bold;
|
|
2274
|
-
font-size: 14px;
|
|
2275
2338
|
margin-right: 5px;
|
|
2276
2339
|
}
|
|
2277
2340
|
|
|
@@ -2300,13 +2363,17 @@ var GenerateImg = class GenerateImg extends Service {
|
|
|
2300
2363
|
<div class="avatar">
|
|
2301
2364
|
<img src="${face}" alt="用户头像">
|
|
2302
2365
|
</div>
|
|
2303
|
-
<div class="
|
|
2304
|
-
<div class="badge
|
|
2366
|
+
<div class="user-info">
|
|
2367
|
+
<div class="name-badge">
|
|
2368
|
+
<span>${uname}</span>
|
|
2369
|
+
</div>
|
|
2370
|
+
<div class="accompany">
|
|
2371
|
+
<div class="master-avatar"></div><span>已服役 ${accompany} 天</span>
|
|
2372
|
+
</div>
|
|
2305
2373
|
</div>
|
|
2306
2374
|
</div>
|
|
2307
2375
|
<div class="desc">
|
|
2308
|
-
|
|
2309
|
-
"${masterName}"的大航海舰队${guard_level === GuardLevel.Tidu ? "提督" : ""}${guard_level === GuardLevel.Zongdu ? "总督" : ""}!
|
|
2376
|
+
${desc[guardLevel]()}
|
|
2310
2377
|
</div>
|
|
2311
2378
|
</div>
|
|
2312
2379
|
<div class="captain"></div>
|
|
@@ -3667,6 +3734,8 @@ const GET_MASTER_INFO = "https://api.live.bilibili.com/live_user/v1/Master/info"
|
|
|
3667
3734
|
const GET_TIME_NOW = "https://api.bilibili.com/x/report/click/now";
|
|
3668
3735
|
const GET_SERVER_UTC_TIME = "https://interface.bilibili.com/serverdate.js";
|
|
3669
3736
|
const GET_LATEST_UPDATED_UPS = "https://api.bilibili.com/x/polymer/web-dynamic/v1/portal";
|
|
3737
|
+
const GET_ONLINE_GOLD_RANK = "https://api.live.bilibili.com//xlive/general-interface/v1/rank/getOnlineGoldRank";
|
|
3738
|
+
const GET_USER_INFO_IN_LIVE = "https://api.live.bilibili.com/xlive/app-ucenter/v2/card/user";
|
|
3670
3739
|
const MODIFY_RELATION = "https://api.bilibili.com/x/relation/modify";
|
|
3671
3740
|
const CREATE_GROUP = "https://api.bilibili.com/x/relation/tag/create";
|
|
3672
3741
|
const MODIFY_GROUP_MEMBER = "https://api.bilibili.com/x/relation/tags/addUsers";
|
|
@@ -4060,6 +4129,30 @@ var BiliAPI = class extends Service {
|
|
|
4060
4129
|
retries: 3
|
|
4061
4130
|
});
|
|
4062
4131
|
}
|
|
4132
|
+
async getOnlineGoldRank(roomId, ruid, page = 1, pageSize = 20) {
|
|
4133
|
+
const run = async () => {
|
|
4134
|
+
const { data } = await this.client.get(`${GET_ONLINE_GOLD_RANK}?room_id=${roomId}&ruid=${ruid}&page=${page}&page_size=${pageSize}`);
|
|
4135
|
+
return data;
|
|
4136
|
+
};
|
|
4137
|
+
return await this.pRetry(run, {
|
|
4138
|
+
onFailedAttempt: (error) => {
|
|
4139
|
+
this.logger.error(`getOnlineGoldRank() 第${error.attemptNumber}次失败: ${error.message}`);
|
|
4140
|
+
},
|
|
4141
|
+
retries: 3
|
|
4142
|
+
});
|
|
4143
|
+
}
|
|
4144
|
+
async getUserInfoInLive(uid, ruid) {
|
|
4145
|
+
const run = async () => {
|
|
4146
|
+
const { data } = await this.client.get(`${GET_USER_INFO_IN_LIVE}?uid=${uid}&ruid=${ruid}`);
|
|
4147
|
+
return data;
|
|
4148
|
+
};
|
|
4149
|
+
return await this.pRetry(run, {
|
|
4150
|
+
onFailedAttempt: (error) => {
|
|
4151
|
+
this.logger.error(`getUserInfoInLive() 第${error.attemptNumber}次失败: ${error.message}`);
|
|
4152
|
+
},
|
|
4153
|
+
retries: 3
|
|
4154
|
+
});
|
|
4155
|
+
}
|
|
4063
4156
|
async chatWithAI(content) {
|
|
4064
4157
|
return await this.aiClient.chat.completions.create({
|
|
4065
4158
|
model: this.apiConfig.ai.model,
|