yz-yuki-plugin 1.0.2-rc.6 → 1.0.2-rc.7
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/apps/bilibili.js
CHANGED
|
@@ -56,13 +56,17 @@ message.use(async (e) => {
|
|
|
56
56
|
e.reply("出了点网络问题,等会再试试吧~");
|
|
57
57
|
return false;
|
|
58
58
|
}
|
|
59
|
-
const
|
|
60
|
-
if (
|
|
61
|
-
e.reply(
|
|
62
|
-
logger.mark(`yuki-plugin addDynamicSub Failed:${JSON.stringify(
|
|
59
|
+
const { code, data } = res.data || {};
|
|
60
|
+
if (code === -352) {
|
|
61
|
+
e.reply(`遭遇风控,订阅校验失败~\n请检查Cookie配置后再试~`);
|
|
62
|
+
logger.mark(`yuki-plugin addDynamicSub Failed:${JSON.stringify(res.data)}`);
|
|
63
63
|
return true;
|
|
64
64
|
}
|
|
65
|
-
const { items } =
|
|
65
|
+
const { has_more, items } = data || {};
|
|
66
|
+
if ((code === 0) && (has_more === false)) {
|
|
67
|
+
e.reply(`订阅校验失败~\nup主uid:${uid} 无效,请核对uid后再试~`);
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
66
70
|
let name = items.length > 0 ? (items[0].modules.module_author?.name || uid) : uid;
|
|
67
71
|
subData[chatType][chatId].push({
|
|
68
72
|
bot_id: e.self_id,
|
|
@@ -358,12 +362,16 @@ message.use(async (e) => {
|
|
|
358
362
|
return;
|
|
359
363
|
}
|
|
360
364
|
const { code, data } = res.data || {};
|
|
361
|
-
if (code === -
|
|
362
|
-
e.reply("
|
|
365
|
+
if (code === -400) {
|
|
366
|
+
e.reply("获取请求错误~");
|
|
367
|
+
return;
|
|
368
|
+
}
|
|
369
|
+
else if (code === -403) {
|
|
370
|
+
e.reply("可能是Cookie过期或api参数错误,\n访问权限不足,获取失败。");
|
|
363
371
|
return;
|
|
364
372
|
}
|
|
365
373
|
else if (code === -404) {
|
|
366
|
-
e.reply("
|
|
374
|
+
e.reply("用户不存在,输入的uid无效。");
|
|
367
375
|
return;
|
|
368
376
|
}
|
|
369
377
|
const message = [
|
|
@@ -372,7 +380,8 @@ message.use(async (e) => {
|
|
|
372
380
|
`\n等级:${data?.level}`,
|
|
373
381
|
];
|
|
374
382
|
if (data.live_room) {
|
|
375
|
-
message.push(
|
|
383
|
+
message.push(`***********\n---直播信息---`, `\n直播标题:${data?.live_room?.title}`, `\n直播房间:${data?.live_room?.roomid}`, `\n直播状态:${data?.live_room?.liveStatus ? "直播中" : "未开播"}`, `\n观看人数:${data?.live_room?.watched_show?.num}人`);
|
|
384
|
+
e.reply(`直播链接:${data?.live_room?.url}`);
|
|
376
385
|
}
|
|
377
386
|
e.reply(message);
|
|
378
387
|
}, [/^(#|\/)(yuki|优纪)?(b站|B站|bili|bilibili|哔哩|哔哩哔哩)(up|UP)主.*$/]);
|
|
@@ -384,17 +393,27 @@ message.use(async (e) => {
|
|
|
384
393
|
return;
|
|
385
394
|
}
|
|
386
395
|
const { code, data } = await res.data || {};
|
|
387
|
-
if (code
|
|
388
|
-
e.reply("
|
|
396
|
+
if (code === -400) {
|
|
397
|
+
e.reply("搜索请求错误~");
|
|
398
|
+
return;
|
|
399
|
+
}
|
|
400
|
+
else if (code === -412) {
|
|
401
|
+
e.reply("未配置可用Cookie,请求被拦截,请配置Cookie后再试吧~");
|
|
402
|
+
return;
|
|
403
|
+
}
|
|
404
|
+
if (!data.result) {
|
|
405
|
+
e.reply("哦豁~没有搜索到该关键词相关的up主信息,请换个关键词试试吧~");
|
|
406
|
+
return;
|
|
407
|
+
}
|
|
408
|
+
if (!Array.isArray(data.result) || !data.result.every(item => typeof item === 'object' && 'uname' in item && 'mid' in item && 'fans' in item)) {
|
|
409
|
+
e.reply("哦豁~数据格式有误,请检查后重试!");
|
|
389
410
|
return;
|
|
390
411
|
}
|
|
391
412
|
const messages = [];
|
|
392
|
-
data.result.
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
return item;
|
|
397
|
-
});
|
|
413
|
+
for (let index = 0; index < Math.min((data.result).length, 5); index++) {
|
|
414
|
+
const item = data.result[index];
|
|
415
|
+
messages.push(`${item.uname}\nUID:${item.mid}\n粉丝数:${item.fans}${index < 4 ? "\n" : ""}`);
|
|
416
|
+
}
|
|
398
417
|
e.reply(messages.join("\n"));
|
|
399
418
|
}, [/^(#|\/)(yuki|优纪)?搜索(b站|B站|bili|bilibili|哔哩|哔哩哔哩)(up|UP)主.*$/]);
|
|
400
419
|
const YukiBli = message.ok;
|
|
@@ -5,6 +5,7 @@ class BiliApi {
|
|
|
5
5
|
biliSpaceUserInfo: `https://api.bilibili.com/x/space/acc/info`,
|
|
6
6
|
biliSpaceUserInfoWbi: `https://api.bilibili.com/x/space/wbi/acc/info`,
|
|
7
7
|
biliSearchUp: `https://api.bilibili.com/x/web-interface/search/type`,
|
|
8
|
+
biliSearchUpWbi: `https://api.bilibili.com/x/web-interface/wbi/search/type`,
|
|
8
9
|
biliLiveStatus: 'https://api.live.bilibili.com/room/v1/Room/get_status_info_by_uids',
|
|
9
10
|
biliCard: "https://api.bilibili.com/x/web-interface/card",
|
|
10
11
|
biliStat: "https://api.bilibili.com/x/relation/stat",
|
|
@@ -56,17 +56,20 @@ class BiliGetWebData {
|
|
|
56
56
|
return res;
|
|
57
57
|
}
|
|
58
58
|
async searchBiliUserInfoByKeyword(keyword) {
|
|
59
|
-
const url = BiliApi.BILIBIL_API.
|
|
59
|
+
const url = BiliApi.BILIBIL_API.biliSearchUpWbi;
|
|
60
60
|
let { cookie } = await readSyncCookie();
|
|
61
61
|
const data = {
|
|
62
62
|
keyword: keyword,
|
|
63
63
|
page: 1,
|
|
64
64
|
search_type: 'bili_user',
|
|
65
65
|
order: 'totalrank',
|
|
66
|
-
pagesize: 5
|
|
67
66
|
};
|
|
67
|
+
let signCookie = await readSavedCookieItems(cookie, ["SESSDATA"], false) || await readSavedCookieOtherItems(cookie, ["SESSDATA"]);
|
|
68
|
+
const { w_rid, time_stamp } = await getWbiSign(data, BiliApi.BILIBILI_HEADERS, signCookie);
|
|
68
69
|
const params = {
|
|
69
|
-
...data
|
|
70
|
+
...data,
|
|
71
|
+
w_rid: w_rid,
|
|
72
|
+
wts: time_stamp
|
|
70
73
|
};
|
|
71
74
|
const res = await axios.get(url, {
|
|
72
75
|
params,
|