koishi-plugin-cat-raising 1.3.2 → 1.3.4
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 +54 -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,55 @@ 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 anchorInfo2 = await ctx.http.get(
|
|
328
|
+
`https://api.bilibili.com/x/space/acc/info?mid=${uid}`,
|
|
329
|
+
{
|
|
330
|
+
headers: {
|
|
331
|
+
...commonHeaders,
|
|
332
|
+
Origin: "https://space.bilibili.com",
|
|
333
|
+
Referer: `https://space.bilibili.com/${uid}`
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
);
|
|
337
|
+
anchorName = anchorInfo2?.data?.name || anchorName;
|
|
338
|
+
} catch {
|
|
339
|
+
}
|
|
340
|
+
try {
|
|
341
|
+
const liveUser2 = await ctx.http.get(
|
|
342
|
+
`https://api.live.bilibili.com/live_user/v3/UserInfo/get_info?uid=${uid}`,
|
|
343
|
+
{
|
|
344
|
+
headers: {
|
|
345
|
+
...commonHeaders,
|
|
346
|
+
Origin: "https://live.bilibili.com",
|
|
347
|
+
Referer: `https://live.bilibili.com/${roomId}`
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
);
|
|
351
|
+
anchorName = liveUser2?.data?.info?.uname || anchorName;
|
|
352
|
+
} catch {
|
|
353
|
+
}
|
|
354
|
+
}
|
|
306
355
|
return { videoCount, anchorName };
|
|
307
356
|
} catch (error) {
|
|
308
357
|
const status = error?.response?.status;
|
|
@@ -426,6 +475,10 @@ function apply(ctx, config) {
|
|
|
426
475
|
});
|
|
427
476
|
}
|
|
428
477
|
__name(apply, "apply");
|
|
478
|
+
function sleep(ms) {
|
|
479
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
480
|
+
}
|
|
481
|
+
__name(sleep, "sleep");
|
|
429
482
|
// Annotate the CommonJS export names for ESM import in node:
|
|
430
483
|
0 && (module.exports = {
|
|
431
484
|
Config,
|