yz-yuki-plugin 2.0.4-8 → 2.0.5-0
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/.puppeteerrc.cjs +1 -1
- package/CHANGELOG.md +3 -0
- package/README.md +19 -3
- package/defaultConfig/bilibili/config.yaml +2 -2
- package/defaultConfig/help/help.yaml +51 -51
- package/defaultConfig/weibo/config.yaml +2 -2
- package/lib/apps/bilibili.js +88 -84
- package/lib/apps/help.js +3 -3
- package/lib/apps/version.js +4 -4
- package/lib/apps/weibo.js +47 -47
- package/lib/components/dynamic/Account.js +3 -3
- package/lib/components/dynamic/Content.js +5 -5
- package/lib/components/dynamic/Footer.js +3 -3
- package/lib/components/dynamic/LogoText.js +2 -2
- package/lib/components/dynamic/MainPage.js +3 -3
- package/lib/components/loginQrcode/Page.js +1 -1
- package/lib/index.js +7 -9
- package/lib/models/bilibili/bilibili.api.d.ts +4 -4
- package/lib/models/bilibili/bilibili.api.js +13 -13
- package/lib/models/bilibili/bilibili.get.web.data.js +32 -18
- package/lib/models/bilibili/bilibili.models.d.ts +9 -9
- package/lib/models/bilibili/bilibili.models.js +248 -192
- package/lib/models/bilibili/bilibili.query.d.ts +5 -5
- package/lib/models/bilibili/bilibili.query.js +135 -114
- package/lib/models/bilibili/bilibili.task.d.ts +1 -1
- package/lib/models/bilibili/bilibili.task.js +41 -36
- package/lib/models/bilibili/bilibili.ticket.js +3 -3
- package/lib/models/bilibili/bilibili.wbi.js +10 -12
- package/lib/models/help/help.js +2 -2
- package/lib/models/weibo/weibo.api.js +2 -2
- package/lib/models/weibo/weibo.get.web.data.js +6 -7
- package/lib/models/weibo/weibo.query.d.ts +4 -4
- package/lib/models/weibo/weibo.query.js +66 -69
- package/lib/models/weibo/weibo.task.d.ts +1 -1
- package/lib/models/weibo/weibo.task.js +43 -38
- package/lib/utils/config.d.ts +2 -2
- package/lib/utils/config.js +8 -8
- package/lib/utils/paths.js +1 -1
- package/lib/utils/puppeteer.render.js +20 -22
- package/package.json +8 -4
- package/resources/css/dynamic/Account.css +1 -1
- package/resources/css/dynamic/Content.box.grid.4.css +2 -2
- package/resources/css/dynamic/Content.box.grid.9.css +2 -2
- package/resources/css/dynamic/Content.css +1 -1
- package/resources/css/dynamic/Footer.css +1 -1
- package/resources/css/dynamic/ForwardContent.css +1 -1
- package/resources/css/dynamic/LogoText.css +2 -2
- package/resources/css/dynamic/MainPage.css +4 -5
- package/resources/css/help/help.css +18 -11
- package/resources/css/loginQrcode/Page.css +7 -11
- package/resources/css/version/version.css +8 -6
package/lib/apps/bilibili.js
CHANGED
|
@@ -8,7 +8,7 @@ import { BiliGetWebData } from '../models/bilibili/bilibili.get.web.data.js';
|
|
|
8
8
|
import { applyLoginQRCode, pollLoginQRCode, saveLoginCookie, postGateway, exitBiliLogin, checkBiliLogin, readSavedCookieItems, saveLocalBiliCk, readSyncCookie, getNewTempCk, readTempCk } from '../models/bilibili/bilibili.models.js';
|
|
9
9
|
|
|
10
10
|
const message = new Messages('message');
|
|
11
|
-
let biliPushData = Config.getConfigData(
|
|
11
|
+
let biliPushData = Config.getConfigData('config', 'bilibili', 'push');
|
|
12
12
|
/** 推送任务 函数 */
|
|
13
13
|
async function biliNewPushTask(e) {
|
|
14
14
|
await new BiliTask(e).runTask();
|
|
@@ -20,11 +20,14 @@ message.use(async (e) => {
|
|
|
20
20
|
/** 添加B站动态订阅 */
|
|
21
21
|
message.use(async (e) => {
|
|
22
22
|
if (!e.isMaster) {
|
|
23
|
-
e.reply(
|
|
23
|
+
e.reply('未取得bot主人身份,无权限添加B站动态订阅');
|
|
24
24
|
}
|
|
25
25
|
else {
|
|
26
26
|
// 从消息中提取UID
|
|
27
|
-
const uid = e.msg
|
|
27
|
+
const uid = e.msg
|
|
28
|
+
.replace(/^(#|\/)(yuki|优纪)?(订阅|添加|add|ADD)(b站|B站|bili|bilibili|哔哩|哔哩哔哩)推送\s*(视频\s*|图文\s*|文章\s*|转发\s*|直播\s*)*/g, '')
|
|
29
|
+
.trim()
|
|
30
|
+
.replace(/^(uid|UID)?(:|:)?/g, '');
|
|
28
31
|
if (!uid) {
|
|
29
32
|
e.reply(`请在指令末尾指定订阅的B站up主的UID!`);
|
|
30
33
|
return true;
|
|
@@ -32,26 +35,26 @@ message.use(async (e) => {
|
|
|
32
35
|
// 获取或初始化推送数据
|
|
33
36
|
let subData = biliPushData || { group: {}, private: {} };
|
|
34
37
|
// 根据聊天类型初始化数据
|
|
35
|
-
let chatType = e.isGroup ?
|
|
38
|
+
let chatType = e.isGroup ? 'group' : 'private';
|
|
36
39
|
let chatId = e.isGroup ? e.group_id : e.user_id;
|
|
37
40
|
// 初始化群组或私聊数据
|
|
38
41
|
if (!subData[chatType][chatId]) {
|
|
39
42
|
subData[chatType][chatId] = [];
|
|
40
43
|
}
|
|
41
44
|
// 检查该 uid 是否已存在
|
|
42
|
-
const upData = subData[chatType][chatId].find(
|
|
45
|
+
const upData = subData[chatType][chatId].find(item => item.uid === uid);
|
|
43
46
|
if (upData) {
|
|
44
47
|
// 更新推送类型
|
|
45
|
-
upData.type = BiliQuery.typeHandle(upData, e.msg,
|
|
48
|
+
upData.type = BiliQuery.typeHandle(upData, e.msg, 'add');
|
|
46
49
|
biliPushData = subData;
|
|
47
|
-
Config.saveConfig(
|
|
50
|
+
Config.saveConfig('config', 'bilibili', 'push', subData);
|
|
48
51
|
e.reply(`修改b站推送动态类型成功~\n${upData.name}:${uid}`);
|
|
49
52
|
return;
|
|
50
53
|
}
|
|
51
54
|
// 获取 Bilibili 动态信息
|
|
52
55
|
const res = await new BiliGetWebData(e).getBiliDynamicListDataByUid(uid);
|
|
53
|
-
if (res.statusText !==
|
|
54
|
-
e.reply(
|
|
56
|
+
if (res.statusText !== 'OK') {
|
|
57
|
+
e.reply('出了点网络问题,等会再试试吧~');
|
|
55
58
|
return false;
|
|
56
59
|
}
|
|
57
60
|
const { code, data } = res.data || {};
|
|
@@ -61,19 +64,19 @@ message.use(async (e) => {
|
|
|
61
64
|
}
|
|
62
65
|
const { has_more, items } = data || {};
|
|
63
66
|
let infoName;
|
|
64
|
-
if (
|
|
67
|
+
if (code === 0 && has_more === false) {
|
|
65
68
|
e.reply(`检测到该uid的主页空间动态内容为空,\n执行uid:${uid} 校验...`);
|
|
66
69
|
const resp = await new BiliGetWebData(e).getBilibiUserInfoByUid(uid);
|
|
67
70
|
if (resp.statusText !== 'OK') {
|
|
68
|
-
e.reply(
|
|
71
|
+
e.reply('出了点网络问题,发起uid校验失败,等会再试试吧~');
|
|
69
72
|
return false;
|
|
70
73
|
}
|
|
71
74
|
const { code, data } = resp.data || {};
|
|
72
75
|
if (code === -400) {
|
|
73
|
-
e.reply(
|
|
76
|
+
e.reply('发起uid检验请求错误~\n将跳过校验并保存订阅,请自行检查uid是否正确。');
|
|
74
77
|
}
|
|
75
78
|
else if (code === -403) {
|
|
76
|
-
e.reply(
|
|
79
|
+
e.reply('可能是Cookie过期或api参数错误,\n访问权限不足,发起uid检验失败。\n将跳过校验并保存订阅,请自行检查uid是否正确。');
|
|
77
80
|
}
|
|
78
81
|
else if (code === -404) {
|
|
79
82
|
e.reply(`经过校验,该用户不存在,\n输入的uid: ${uid} 无效。订阅失败。`);
|
|
@@ -101,29 +104,32 @@ message.use(async (e) => {
|
|
|
101
104
|
bot_id: e.self_id, // 使用 bot_id, 对应 e_self_id
|
|
102
105
|
uid,
|
|
103
106
|
name: name,
|
|
104
|
-
type: BiliQuery.typeHandle({ uid, name }, e.msg,
|
|
107
|
+
type: BiliQuery.typeHandle({ uid, name }, e.msg, 'add')
|
|
105
108
|
});
|
|
106
109
|
biliPushData = subData;
|
|
107
|
-
Config.saveConfig(
|
|
110
|
+
Config.saveConfig('config', 'bilibili', 'push', subData);
|
|
108
111
|
e.reply(`添加b站推送成功~\n${name}:${uid}`);
|
|
109
112
|
}
|
|
110
113
|
}, [/^(#|\/)(yuki|优纪)?(订阅|添加|add|ADD)(b站|B站|bili|bilibili|哔哩|哔哩哔哩)推送\s*(视频\s*|图文\s*|文章\s*|转发\s*|直播\s*)*.*$/]);
|
|
111
114
|
/** 删除B站动态订阅 */
|
|
112
115
|
message.use(async (e) => {
|
|
113
116
|
if (!e.isMaster) {
|
|
114
|
-
e.reply(
|
|
117
|
+
e.reply('未取得bot主人身份,无权限删除B站动态订阅');
|
|
115
118
|
}
|
|
116
119
|
else {
|
|
117
120
|
// 提取用户输入的UID
|
|
118
|
-
const uid = e.msg
|
|
121
|
+
const uid = e.msg
|
|
122
|
+
.replace(/^(#|\/)(yuki|优纪)?(取消|删除|del|DEL)(b站|B站|bili|bilibili|哔哩|哔哩哔哩)推送\s*(视频\s*|图文\s*|文章\s*|转发\s*|直播\s*)*/g, '')
|
|
123
|
+
.trim()
|
|
124
|
+
.replace(/^(uid|UID)?(:|:)?/g, '');
|
|
119
125
|
if (!uid) {
|
|
120
126
|
e.reply(`请在指令末尾指定订阅的B站up主的UID!`);
|
|
121
127
|
return;
|
|
122
128
|
}
|
|
123
129
|
// 获取或初始化B站推送数据
|
|
124
|
-
let subData = Config.getConfigData(
|
|
130
|
+
let subData = Config.getConfigData('config', 'bilibili', 'push') || { group: {}, private: {} };
|
|
125
131
|
// 根据聊天类型初始化数据
|
|
126
|
-
let chatType = e.isGroup ?
|
|
132
|
+
let chatType = e.isGroup ? 'group' : 'private';
|
|
127
133
|
let chatId = e.isGroup ? e.group_id : e.user_id;
|
|
128
134
|
// 初始化群组或私聊数据
|
|
129
135
|
if (!subData[chatType][chatId]) {
|
|
@@ -136,11 +142,11 @@ message.use(async (e) => {
|
|
|
136
142
|
return;
|
|
137
143
|
}
|
|
138
144
|
// 处理订阅类型
|
|
139
|
-
const newType = BiliQuery.typeHandle(upData, e.msg,
|
|
145
|
+
const newType = BiliQuery.typeHandle(upData, e.msg, 'del');
|
|
140
146
|
let isDel = false;
|
|
141
147
|
if (newType.length) {
|
|
142
148
|
// 更新订阅类型
|
|
143
|
-
subData[chatType][chatId] = subData[chatType][chatId].map(
|
|
149
|
+
subData[chatType][chatId] = subData[chatType][chatId].map(item => {
|
|
144
150
|
if (item.uid == uid) {
|
|
145
151
|
item.type = newType;
|
|
146
152
|
}
|
|
@@ -150,13 +156,13 @@ message.use(async (e) => {
|
|
|
150
156
|
else {
|
|
151
157
|
// 删除订阅
|
|
152
158
|
isDel = true;
|
|
153
|
-
subData[chatType][chatId] = subData[chatType][chatId].filter(
|
|
159
|
+
subData[chatType][chatId] = subData[chatType][chatId].filter(item => item.uid !== uid);
|
|
154
160
|
}
|
|
155
161
|
// 保存更新后的数据
|
|
156
162
|
//biliPushData = subData;
|
|
157
|
-
Config.saveConfig(
|
|
163
|
+
Config.saveConfig('config', 'bilibili', 'push', subData);
|
|
158
164
|
// 回复用户操作结果
|
|
159
|
-
e.reply(`${isDel ?
|
|
165
|
+
e.reply(`${isDel ? '删除' : '修改'}b站推送成功~\n${uid}`);
|
|
160
166
|
}
|
|
161
167
|
}, [/^(#|\/)(yuki|优纪)?(取消|删除|del|DEL)(b站|B站|bili|bilibili|哔哩|哔哩哔哩)推送\s*(视频\s*|图文\s*|文章\s*|转发\s*|直播\s*)*.*$/]);
|
|
162
168
|
/** 扫码登录B站 */
|
|
@@ -191,18 +197,18 @@ message.use(async (e) => {
|
|
|
191
197
|
}
|
|
192
198
|
}
|
|
193
199
|
else {
|
|
194
|
-
e.reply(
|
|
200
|
+
e.reply('未取得bot主人身份,无权限配置B站登录ck');
|
|
195
201
|
}
|
|
196
202
|
}, [/^(#|\/)(yuki|优纪)?(扫码|添加|ADD|add)(b站|B站|bili|bilibili|哔哩|哔哩哔哩)登录$/]);
|
|
197
203
|
/** 删除登陆的B站ck */
|
|
198
204
|
message.use(async (e) => {
|
|
199
205
|
if (e.isMaster) {
|
|
200
206
|
await exitBiliLogin(e);
|
|
201
|
-
await Redis.set(
|
|
207
|
+
await Redis.set('Yz:yuki:bili:loginCookie', '', { EX: 3600 * 24 * 180 });
|
|
202
208
|
e.reply(`登陆的B站ck并已删除~`);
|
|
203
209
|
}
|
|
204
210
|
else {
|
|
205
|
-
e.reply(
|
|
211
|
+
e.reply('未取得bot主人身份,无权限删除B站登录ck');
|
|
206
212
|
}
|
|
207
213
|
}, [/^(#|\/)(yuki|优纪)?(取消|删除|del|DEL)(b站|B站|bili|bilibili|哔哩|哔哩哔哩)登录$/]);
|
|
208
214
|
/** 显示我的B站登录信息 */
|
|
@@ -211,7 +217,7 @@ message.use(async (e) => {
|
|
|
211
217
|
await checkBiliLogin(e);
|
|
212
218
|
}
|
|
213
219
|
else {
|
|
214
|
-
e.reply(
|
|
220
|
+
e.reply('未取得bot主人身份,无权限查看B站登录状态');
|
|
215
221
|
}
|
|
216
222
|
}, [/^(#|\/)(yuki|优纪)?我的(b站|B站|bili|bilibili|哔哩|哔哩哔哩)登录$/]);
|
|
217
223
|
/** 手动绑定本地获取的B站cookie */
|
|
@@ -221,9 +227,11 @@ message.use(async (e) => {
|
|
|
221
227
|
await e.reply('请注意账号安全,请手动撤回发送的cookie,并私聊进行添加绑定!');
|
|
222
228
|
}
|
|
223
229
|
else {
|
|
224
|
-
let localBiliCookie = e.msg
|
|
230
|
+
let localBiliCookie = e.msg
|
|
231
|
+
.replace(/^(#|\/)(yuki|优纪)?(绑定|添加|ADD|add)(b站|B站|bili|bilibili|哔哩|哔哩哔哩)(ck|CK|cookie|COOKIE)(:|:)?/g, '')
|
|
232
|
+
.trim();
|
|
225
233
|
let param = {};
|
|
226
|
-
localBiliCookie.split(';').forEach(
|
|
234
|
+
localBiliCookie.split(';').forEach(v => {
|
|
227
235
|
// 处理分割特殊cookie_token
|
|
228
236
|
let tmp = lodash.trim(v).replace('=', '$').split('$');
|
|
229
237
|
param[tmp[0]] = tmp[1];
|
|
@@ -269,17 +277,17 @@ message.use(async (e) => {
|
|
|
269
277
|
}
|
|
270
278
|
}
|
|
271
279
|
else {
|
|
272
|
-
e.reply(
|
|
280
|
+
e.reply('未取得bot主人身份,无权限配置B站登录ck');
|
|
273
281
|
}
|
|
274
282
|
}, [/^^(#|\/)(yuki|优纪)?(绑定|添加|ADD|add)(b站|B站|bili|bilibili|哔哩|哔哩哔哩)本地(ck|CK|cookie|COOKIE)(:|:)?.*$/]);
|
|
275
283
|
/** 删除绑定的本地B站ck */
|
|
276
284
|
message.use(async (e) => {
|
|
277
285
|
if (e.isMaster) {
|
|
278
|
-
await saveLocalBiliCk(
|
|
286
|
+
await saveLocalBiliCk('');
|
|
279
287
|
await e.reply(`手动绑定的B站ck已删除~`);
|
|
280
288
|
}
|
|
281
289
|
else {
|
|
282
|
-
e.reply(
|
|
290
|
+
e.reply('未取得bot主人身份,无权限删除B站登录ck');
|
|
283
291
|
}
|
|
284
292
|
}, [/^(#|\/)(yuki|优纪)?(取消|删除|del|DEL)(b站|B站|bili|bilibili|哔哩|哔哩哔哩)本地(ck|CK|cookie|COOKIE)$/]);
|
|
285
293
|
/** 当前正在使用的B站ck */
|
|
@@ -290,15 +298,15 @@ message.use(async (e) => {
|
|
|
290
298
|
else {
|
|
291
299
|
if (e.isMaster) {
|
|
292
300
|
let { cookie, mark } = await readSyncCookie();
|
|
293
|
-
if (mark ===
|
|
301
|
+
if (mark === 'localCk') {
|
|
294
302
|
e.reply(`当前使用本地获取的B站cookie:`);
|
|
295
303
|
e.reply(`${cookie}`);
|
|
296
304
|
}
|
|
297
|
-
else if (mark ===
|
|
305
|
+
else if (mark === 'loginCk') {
|
|
298
306
|
e.reply(`当前使用扫码登录的B站cookie:`);
|
|
299
307
|
e.reply(`${cookie}`);
|
|
300
308
|
}
|
|
301
|
-
else if (mark ===
|
|
309
|
+
else if (mark === 'tempCk') {
|
|
302
310
|
e.reply(`当前使用自动获取的临时B站cookie:`);
|
|
303
311
|
e.reply(`${cookie}`);
|
|
304
312
|
}
|
|
@@ -307,7 +315,7 @@ message.use(async (e) => {
|
|
|
307
315
|
}
|
|
308
316
|
}
|
|
309
317
|
else {
|
|
310
|
-
e.reply(
|
|
318
|
+
e.reply('未取得bot主人身份,无权限查看当前使用的B站cookie');
|
|
311
319
|
}
|
|
312
320
|
}
|
|
313
321
|
}, [/^(#|\/)(yuki|优纪)?(取消|删除|del|DEL)(b站|B站|bili|bilibili|哔哩|哔哩哔哩)本地(ck|CK|cookie|COOKIE)$/]);
|
|
@@ -316,7 +324,7 @@ message.use(async (e) => {
|
|
|
316
324
|
try {
|
|
317
325
|
await getNewTempCk();
|
|
318
326
|
let newTempCk = await readTempCk();
|
|
319
|
-
if (
|
|
327
|
+
if (newTempCk !== null && newTempCk !== undefined && newTempCk.length !== 0 && newTempCk !== '') {
|
|
320
328
|
e.reply(`~yuki-plugin:\n临时b站ck刷新成功~❤~\n接下来如果获取动态失败,请重启bot(手动或发送指令 #重启)刷新状态~\n如果重启续仍不可用,请考虑 #优纪添加b站登录 吧~`);
|
|
321
329
|
}
|
|
322
330
|
else {
|
|
@@ -331,23 +339,23 @@ message.use(async (e) => {
|
|
|
331
339
|
/** 订阅的全部b站推送列表 */
|
|
332
340
|
message.use(async (e) => {
|
|
333
341
|
if (!e.isMaster) {
|
|
334
|
-
e.reply(
|
|
342
|
+
e.reply('未取得bot主人身份,无权限查看Bot的全部B站订阅列表');
|
|
335
343
|
}
|
|
336
344
|
else {
|
|
337
|
-
let subData = Config.getConfigData(
|
|
345
|
+
let subData = Config.getConfigData('config', 'bilibili', 'push') || { group: {}, private: {} };
|
|
338
346
|
const messages = [];
|
|
339
347
|
const typeMap = {
|
|
340
|
-
DYNAMIC_TYPE_AV:
|
|
341
|
-
DYNAMIC_TYPE_WORD:
|
|
342
|
-
DYNAMIC_TYPE_DRAW:
|
|
343
|
-
DYNAMIC_TYPE_ARTICLE:
|
|
344
|
-
DYNAMIC_TYPE_FORWARD:
|
|
345
|
-
DYNAMIC_TYPE_LIVE_RCMD:
|
|
348
|
+
DYNAMIC_TYPE_AV: '视频',
|
|
349
|
+
DYNAMIC_TYPE_WORD: '图文',
|
|
350
|
+
DYNAMIC_TYPE_DRAW: '图文',
|
|
351
|
+
DYNAMIC_TYPE_ARTICLE: '文章',
|
|
352
|
+
DYNAMIC_TYPE_FORWARD: '转发',
|
|
353
|
+
DYNAMIC_TYPE_LIVE_RCMD: '直播'
|
|
346
354
|
};
|
|
347
355
|
// 处理群组订阅
|
|
348
356
|
if (subData.group && Object.keys(subData.group).length > 0) {
|
|
349
|
-
messages.push(
|
|
350
|
-
Object.keys(subData.group).forEach(
|
|
357
|
+
messages.push('------群组B站订阅------\n');
|
|
358
|
+
Object.keys(subData.group).forEach(groupId => {
|
|
351
359
|
messages.push(`群组ID:${groupId}:`);
|
|
352
360
|
subData.group[groupId].forEach((item) => {
|
|
353
361
|
const types = new Set();
|
|
@@ -358,14 +366,14 @@ message.use(async (e) => {
|
|
|
358
366
|
}
|
|
359
367
|
});
|
|
360
368
|
}
|
|
361
|
-
messages.push(`${item.name}:${item.uid} ${types.size ? `[${Array.from(types).join(
|
|
369
|
+
messages.push(`${item.name}:${item.uid} ${types.size ? `[${Array.from(types).join('、')}]` : ' [全部动态]'}`);
|
|
362
370
|
});
|
|
363
371
|
});
|
|
364
372
|
}
|
|
365
373
|
// 处理私聊订阅
|
|
366
374
|
if (subData.private && Object.keys(subData.private).length > 0) {
|
|
367
|
-
messages.push(
|
|
368
|
-
Object.keys(subData.private).forEach(
|
|
375
|
+
messages.push('\n------私聊B站订阅------');
|
|
376
|
+
Object.keys(subData.private).forEach(userId => {
|
|
369
377
|
messages.push(`用户ID:${userId}:`);
|
|
370
378
|
subData.private[userId].forEach((item) => {
|
|
371
379
|
const types = new Set();
|
|
@@ -376,27 +384,27 @@ message.use(async (e) => {
|
|
|
376
384
|
}
|
|
377
385
|
});
|
|
378
386
|
}
|
|
379
|
-
messages.push(`${item.name}:${item.uid} ${types.size ? `[${Array.from(types).join(
|
|
387
|
+
messages.push(`${item.name}:${item.uid} ${types.size ? `[${Array.from(types).join('、')}]` : ' [全部动态]'}`);
|
|
380
388
|
});
|
|
381
389
|
});
|
|
382
390
|
}
|
|
383
|
-
e.reply(`推送列表如下:\n${messages.join(
|
|
391
|
+
e.reply(`推送列表如下:\n${messages.join('\n')}`);
|
|
384
392
|
}
|
|
385
393
|
}, [/^(#|\/)(yuki|优纪)?(b站|B站|bili|bilibili|哔哩|哔哩哔哩)全部(推送|动态|订阅)列表$/]);
|
|
386
394
|
/** 单独群聊或私聊的订阅的b站推送列表 */
|
|
387
395
|
message.use(async (e) => {
|
|
388
|
-
let subData = Config.getConfigData(
|
|
396
|
+
let subData = Config.getConfigData('config', 'bilibili', 'push') || { group: {}, private: {} };
|
|
389
397
|
const messages = [];
|
|
390
398
|
const typeMap = {
|
|
391
|
-
DYNAMIC_TYPE_AV:
|
|
392
|
-
DYNAMIC_TYPE_WORD:
|
|
393
|
-
DYNAMIC_TYPE_DRAW:
|
|
394
|
-
DYNAMIC_TYPE_ARTICLE:
|
|
395
|
-
DYNAMIC_TYPE_FORWARD:
|
|
396
|
-
DYNAMIC_TYPE_LIVE_RCMD:
|
|
399
|
+
DYNAMIC_TYPE_AV: '视频',
|
|
400
|
+
DYNAMIC_TYPE_WORD: '图文',
|
|
401
|
+
DYNAMIC_TYPE_DRAW: '图文',
|
|
402
|
+
DYNAMIC_TYPE_ARTICLE: '文章',
|
|
403
|
+
DYNAMIC_TYPE_FORWARD: '转发',
|
|
404
|
+
DYNAMIC_TYPE_LIVE_RCMD: '直播'
|
|
397
405
|
};
|
|
398
406
|
// 根据聊天类型初始化数据
|
|
399
|
-
let chatType = e.isGroup ?
|
|
407
|
+
let chatType = e.isGroup ? 'group' : 'private';
|
|
400
408
|
let chatId = e.isGroup ? e.group_id : e.user_id;
|
|
401
409
|
if (!subData[chatType][chatId]) {
|
|
402
410
|
subData[chatType][chatId] = [];
|
|
@@ -410,73 +418,69 @@ message.use(async (e) => {
|
|
|
410
418
|
}
|
|
411
419
|
});
|
|
412
420
|
}
|
|
413
|
-
messages.push(`${item.name}:${item.uid} ${types.size ? `[${Array.from(types).join(
|
|
421
|
+
messages.push(`${item.name}:${item.uid} ${types.size ? `[${Array.from(types).join('、')}]` : ' [全部动态]'}`);
|
|
414
422
|
});
|
|
415
|
-
e.reply(`推送列表如下:\n${messages.join(
|
|
423
|
+
e.reply(`推送列表如下:\n${messages.join('\n')}`);
|
|
416
424
|
}, [/^(#|\/)(yuki|优纪)?(b站|B站|bili|bilibili|哔哩|哔哩哔哩)(推送|动态|订阅)列表$/]);
|
|
417
425
|
/**通过uid获取up主信息 */
|
|
418
426
|
message.use(async (e) => {
|
|
419
|
-
let uid = e.msg.replace(/^(#|\/)(yuki|优纪)?(b站|B站|bili|bilibili|哔哩|哔哩哔哩)(up|UP)主/g,
|
|
427
|
+
let uid = e.msg.replace(/^(#|\/)(yuki|优纪)?(b站|B站|bili|bilibili|哔哩|哔哩哔哩)(up|UP)主/g, '').trim();
|
|
420
428
|
const res = await new BiliGetWebData(e).getBilibiUserInfoByUid(uid);
|
|
421
429
|
if (res.statusText !== 'OK') {
|
|
422
|
-
e.reply(
|
|
430
|
+
e.reply('诶嘿,出了点网络问题,等会再试试吧~');
|
|
423
431
|
return;
|
|
424
432
|
}
|
|
425
433
|
const { code, data } = res.data || {};
|
|
426
434
|
if (code === -400) {
|
|
427
|
-
e.reply(
|
|
435
|
+
e.reply('获取请求错误~');
|
|
428
436
|
return;
|
|
429
437
|
}
|
|
430
438
|
else if (code === -403) {
|
|
431
|
-
e.reply(
|
|
439
|
+
e.reply('可能是Cookie过期或api参数错误,\n访问权限不足,获取失败。');
|
|
432
440
|
return;
|
|
433
441
|
}
|
|
434
442
|
else if (code === -404) {
|
|
435
|
-
e.reply(
|
|
443
|
+
e.reply('用户不存在,输入的uid无效。');
|
|
436
444
|
return;
|
|
437
445
|
}
|
|
438
|
-
const message = [
|
|
439
|
-
`昵称:${data?.name}`,
|
|
440
|
-
`\n性别:${data?.sex}`,
|
|
441
|
-
`\n等级:${data?.level}`,
|
|
442
|
-
];
|
|
446
|
+
const message = [`昵称:${data?.name}`, `\n性别:${data?.sex}`, `\n等级:${data?.level}`];
|
|
443
447
|
if (data.live_room) {
|
|
444
|
-
message.push(`***********\n---直播信息---`, `\n直播标题:${data?.live_room?.title}`, `\n直播房间:${data?.live_room?.roomid}`, `\n直播状态:${data?.live_room?.liveStatus ?
|
|
448
|
+
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}人`);
|
|
445
449
|
e.reply(`直播链接:${data?.live_room?.url}`);
|
|
446
450
|
}
|
|
447
451
|
e.reply(message);
|
|
448
452
|
}, [/^(#|\/)(yuki|优纪)?(b站|B站|bili|bilibili|哔哩|哔哩哔哩)(up|UP)主.*$/]);
|
|
449
453
|
/** 根据名称搜索up的uid*/
|
|
450
454
|
message.use(async (e) => {
|
|
451
|
-
let keyword = e.msg.replace(/^(#|\/)(yuki|优纪)?搜索(b站|B站|bili|bilibili|哔哩|哔哩哔哩)(up|UP)主/g,
|
|
455
|
+
let keyword = e.msg.replace(/^(#|\/)(yuki|优纪)?搜索(b站|B站|bili|bilibili|哔哩|哔哩哔哩)(up|UP)主/g, '').trim();
|
|
452
456
|
const res = await new BiliGetWebData(e).searchBiliUserInfoByKeyword(keyword);
|
|
453
457
|
if (res.statusText !== 'OK') {
|
|
454
|
-
e.reply(
|
|
458
|
+
e.reply('诶嘿,出了点网络问题,等会再试试吧~');
|
|
455
459
|
return;
|
|
456
460
|
}
|
|
457
|
-
const { code, data } = await res.data || {};
|
|
461
|
+
const { code, data } = (await res.data) || {};
|
|
458
462
|
if (code === -400) {
|
|
459
|
-
e.reply(
|
|
463
|
+
e.reply('搜索请求错误~');
|
|
460
464
|
return;
|
|
461
465
|
}
|
|
462
466
|
else if (code === -412) {
|
|
463
|
-
e.reply(
|
|
467
|
+
e.reply('未配置可用Cookie,请求被拦截,请配置Cookie后再试吧~');
|
|
464
468
|
return;
|
|
465
469
|
}
|
|
466
470
|
if (!data.result) {
|
|
467
|
-
e.reply(
|
|
471
|
+
e.reply('哦豁~没有搜索到该关键词相关的up主信息,请换个关键词试试吧~');
|
|
468
472
|
return;
|
|
469
473
|
}
|
|
470
474
|
if (!Array.isArray(data.result) || !data.result.every(item => typeof item === 'object' && 'uname' in item && 'mid' in item && 'fans' in item)) {
|
|
471
|
-
e.reply(
|
|
475
|
+
e.reply('哦豁~数据格式有误,请检查后重试!');
|
|
472
476
|
return;
|
|
473
477
|
}
|
|
474
478
|
const messages = [];
|
|
475
|
-
for (let index = 0; index < Math.min(
|
|
479
|
+
for (let index = 0; index < Math.min(data.result.length, 5); index++) {
|
|
476
480
|
const item = data.result[index];
|
|
477
|
-
messages.push(`${item.uname}\nUID:${item.mid}\n粉丝数:${item.fans}${index < 4 ?
|
|
481
|
+
messages.push(`${item.uname}\nUID:${item.mid}\n粉丝数:${item.fans}${index < 4 ? '\n' : ''}`);
|
|
478
482
|
}
|
|
479
|
-
e.reply(messages.join(
|
|
483
|
+
e.reply(messages.join('\n'));
|
|
480
484
|
}, [/^(#|\/)(yuki|优纪)?搜索(b站|B站|bili|bilibili|哔哩|哔哩哔哩)(up|UP)主.*$/]);
|
|
481
485
|
const YukiBli = message.ok;
|
|
482
486
|
|
package/lib/apps/help.js
CHANGED
|
@@ -21,12 +21,12 @@ message.use(async (e) => {
|
|
|
21
21
|
const ScreenshotOptionsData = {
|
|
22
22
|
SOptions: {
|
|
23
23
|
type: 'webp',
|
|
24
|
-
quality: 90
|
|
24
|
+
quality: 90
|
|
25
25
|
},
|
|
26
26
|
isSplit: false,
|
|
27
|
-
modelName: 'yukiHelp'
|
|
27
|
+
modelName: 'yukiHelp'
|
|
28
28
|
};
|
|
29
|
-
const helpImg = await renderPage(
|
|
29
|
+
const helpImg = await renderPage('help', 'Help', renderData, ScreenshotOptionsData);
|
|
30
30
|
let imgRes;
|
|
31
31
|
if (helpImg !== false) {
|
|
32
32
|
const { img } = helpImg;
|
package/lib/apps/version.js
CHANGED
|
@@ -7,7 +7,7 @@ const message = new Messages('message');
|
|
|
7
7
|
* 优纪版本
|
|
8
8
|
*/
|
|
9
9
|
message.use(async (e) => {
|
|
10
|
-
const version = new VersionData;
|
|
10
|
+
const version = new VersionData();
|
|
11
11
|
const versionData = await version.getChangelogContent();
|
|
12
12
|
const renderData = {
|
|
13
13
|
data: versionData.map((item) => ({
|
|
@@ -18,12 +18,12 @@ message.use(async (e) => {
|
|
|
18
18
|
const ScreenshotOptionsData = {
|
|
19
19
|
SOptions: {
|
|
20
20
|
type: 'webp',
|
|
21
|
-
quality: 90
|
|
21
|
+
quality: 90
|
|
22
22
|
},
|
|
23
23
|
isSplit: false,
|
|
24
|
-
modelName: 'yukiVersion'
|
|
24
|
+
modelName: 'yukiVersion'
|
|
25
25
|
};
|
|
26
|
-
const helpImg = await renderPage(
|
|
26
|
+
const helpImg = await renderPage('version', 'Version', renderData, ScreenshotOptionsData);
|
|
27
27
|
let imgRes;
|
|
28
28
|
if (helpImg !== false) {
|
|
29
29
|
const { img } = helpImg;
|