koishi-plugin-cat-raising 1.1.0 → 1.2.1
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 +8 -2
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -229,10 +229,15 @@ async function fetchBilibiliInfo(ctx, roomId) {
|
|
|
229
229
|
const roomInfo = await ctx.http.get(`https://api.live.bilibili.com/room/v1/Room/get_info?room_id=${roomId}`);
|
|
230
230
|
const uid = roomInfo?.data?.uid;
|
|
231
231
|
if (!uid) throw new Error("无法从房间信息中获取UID");
|
|
232
|
-
const statsInfo = await
|
|
232
|
+
const [statsInfo, cardInfo] = await Promise.all([
|
|
233
|
+
ctx.http.get(`https://api.bilibili.com/x/space/navnum?mid=${uid}`),
|
|
234
|
+
ctx.http.get(`https://api.bilibili.com/x/web-interface/card?mid=${uid}`)
|
|
235
|
+
]);
|
|
233
236
|
const videoCount = statsInfo?.data?.video;
|
|
234
237
|
if (videoCount === void 0) throw new Error("无法从空间信息中获取投稿数");
|
|
235
|
-
|
|
238
|
+
const streamerName = cardInfo?.data?.card?.name;
|
|
239
|
+
if (!streamerName) throw new Error("无法从账号信息中获取主播昵称");
|
|
240
|
+
return { videoCount, streamerName };
|
|
236
241
|
} catch (error) {
|
|
237
242
|
ctx.logger.warn(`[API] 获取直播间 ${roomId} 的B站信息失败: ${error.message}`);
|
|
238
243
|
return null;
|
|
@@ -287,6 +292,7 @@ function apply(ctx, config) {
|
|
|
287
292
|
const forwardMessage = `${session.content}
|
|
288
293
|
|
|
289
294
|
---
|
|
295
|
+
主播: ${biliInfo.streamerName}
|
|
290
296
|
投稿数: ${biliInfo.videoCount}`;
|
|
291
297
|
const [forwardedMessageId] = config.isGroup ? await session.bot.sendMessage(config.targetQQ, forwardMessage) : await session.bot.sendPrivateMessage(config.targetQQ, forwardMessage);
|
|
292
298
|
forwardedHistory.push({
|