koishi-plugin-cat-raising 1.3.2 → 1.3.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.js +62 -1
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -107,7 +107,7 @@ function extractDateTime(line) {
|
|
|
107
107
|
if (match = line.match(/(\d{1,2})\s*[月.]\s*(\d{1,2})\s*日?/)) return `${match[1]}月${match[2]}日`;
|
|
108
108
|
if (match = line.match(/每晚\s*(\d{1,2})\s*[点时]/)) return `每晚 ${match[1].padStart(2, "0")}:00`;
|
|
109
109
|
if (match = line.match(/(\d{1,2}\s*月\s*(?:上|中|下)旬)/)) return match[1];
|
|
110
|
-
if (match = line.match(/(\d{1,2})[
|
|
110
|
+
if (match = line.match(/(\d{1,2})[::∶.点时]\s*(\d{1,2})/)) return `${match[1].padStart(2, "0")}:${match[2].padStart(2, "0")}`;
|
|
111
111
|
if (match = line.match(/(\d{1,2})\s*点\s*半/)) return `${match[1].padStart(2, "0")}:30`;
|
|
112
112
|
if (match = line.match(/\b(\d{1,2})\s*[.点时](?!\d)/)) return `${match[1].padStart(2, "0")}:00`;
|
|
113
113
|
if (match = line.match(/(\d{1,2})\s*分/)) {
|
|
@@ -303,6 +303,63 @@ async function fetchBilibiliInfo(ctx, roomId) {
|
|
|
303
303
|
} catch {
|
|
304
304
|
}
|
|
305
305
|
}
|
|
306
|
+
if (anchorName === "未知") {
|
|
307
|
+
try {
|
|
308
|
+
const baseInfo = await ctx.http.get(
|
|
309
|
+
`https://api.live.bilibili.com/xlive/web-room/v1/index/getRoomBaseInfo?room_id=${roomId}`,
|
|
310
|
+
{ headers: commonHeaders }
|
|
311
|
+
);
|
|
312
|
+
anchorName = baseInfo?.data?.anchor_info?.base_info?.uname || baseInfo?.data?.anchor_info?.uname || baseInfo?.data?.room_info?.uname || baseInfo?.data?.uname || anchorName;
|
|
313
|
+
} catch {
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
if (anchorName === "未知") {
|
|
317
|
+
await sleep(300);
|
|
318
|
+
try {
|
|
319
|
+
const infoByRoom2 = await ctx.http.get(
|
|
320
|
+
`https://api.live.bilibili.com/xlive/web-room/v1/index/getInfoByRoom?room_id=${roomId}`,
|
|
321
|
+
{ headers: commonHeaders }
|
|
322
|
+
);
|
|
323
|
+
anchorName = infoByRoom2?.data?.anchor_info?.base_info?.uname || infoByRoom2?.data?.anchor_info?.uname || anchorName;
|
|
324
|
+
} catch {
|
|
325
|
+
}
|
|
326
|
+
try {
|
|
327
|
+
const anchorInRoom = await ctx.http.get(
|
|
328
|
+
`https://api.live.bilibili.com/live_user/v1/guard/get_anchor_in_room?roomid=${roomId}`,
|
|
329
|
+
{ headers: commonHeaders }
|
|
330
|
+
);
|
|
331
|
+
anchorName = anchorInRoom?.data?.info?.uname || anchorName;
|
|
332
|
+
} catch {
|
|
333
|
+
}
|
|
334
|
+
try {
|
|
335
|
+
const anchorInfo2 = await ctx.http.get(
|
|
336
|
+
`https://api.bilibili.com/x/space/acc/info?mid=${uid}`,
|
|
337
|
+
{
|
|
338
|
+
headers: {
|
|
339
|
+
...commonHeaders,
|
|
340
|
+
Origin: "https://space.bilibili.com",
|
|
341
|
+
Referer: `https://space.bilibili.com/${uid}`
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
);
|
|
345
|
+
anchorName = anchorInfo2?.data?.name || anchorName;
|
|
346
|
+
} catch {
|
|
347
|
+
}
|
|
348
|
+
try {
|
|
349
|
+
const liveUser2 = await ctx.http.get(
|
|
350
|
+
`https://api.live.bilibili.com/live_user/v3/UserInfo/get_info?uid=${uid}`,
|
|
351
|
+
{
|
|
352
|
+
headers: {
|
|
353
|
+
...commonHeaders,
|
|
354
|
+
Origin: "https://live.bilibili.com",
|
|
355
|
+
Referer: `https://live.bilibili.com/${roomId}`
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
);
|
|
359
|
+
anchorName = liveUser2?.data?.info?.uname || anchorName;
|
|
360
|
+
} catch {
|
|
361
|
+
}
|
|
362
|
+
}
|
|
306
363
|
return { videoCount, anchorName };
|
|
307
364
|
} catch (error) {
|
|
308
365
|
const status = error?.response?.status;
|
|
@@ -426,6 +483,10 @@ function apply(ctx, config) {
|
|
|
426
483
|
});
|
|
427
484
|
}
|
|
428
485
|
__name(apply, "apply");
|
|
486
|
+
function sleep(ms) {
|
|
487
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
488
|
+
}
|
|
489
|
+
__name(sleep, "sleep");
|
|
429
490
|
// Annotate the CommonJS export names for ESM import in node:
|
|
430
491
|
0 && (module.exports = {
|
|
431
492
|
Config,
|