yz-yuki-plugin 2.0.4-9 → 2.0.5-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/.puppeteerrc.cjs +1 -1
- package/CHANGELOG.md +4 -0
- package/README.md +19 -3
- package/defaultConfig/bilibili/config.yaml +7 -3
- 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 +2 -2
- package/lib/components/dynamic/Footer.js +3 -3
- package/lib/components/dynamic/LogoText.js +2 -2
- package/lib/components/dynamic/MainPage.js +2 -2
- 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 +2 -2
- package/lib/models/bilibili/bilibili.task.js +46 -44
- 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
|
@@ -12,33 +12,36 @@ class BiliQuery {
|
|
|
12
12
|
* @returns 序列化后的动态数据对象
|
|
13
13
|
*/
|
|
14
14
|
static async formatDynamicData(data) {
|
|
15
|
-
const BiliDrawDynamicLinkUrl =
|
|
15
|
+
const BiliDrawDynamicLinkUrl = 'https://m.bilibili.com/dynamic/';
|
|
16
16
|
let desc, pics = [], majorType;
|
|
17
17
|
let formatData = { data: {} };
|
|
18
18
|
const author = data?.modules?.module_author || {};
|
|
19
19
|
formatData.data.face = author.face; // 作者头像
|
|
20
20
|
formatData.data.name = author.name; // 作者名字
|
|
21
21
|
formatData.data.pendant = author?.pendant?.image || data?.pendant?.image; // 作者挂件
|
|
22
|
-
formatData.data.created = moment().format(
|
|
22
|
+
formatData.data.created = moment().format('YYYY年MM月DD日 HH:mm:ss'); // 创建时间
|
|
23
23
|
formatData.data.type = data.type; // 动态类型
|
|
24
24
|
switch (data.type) {
|
|
25
|
-
case
|
|
25
|
+
case 'DYNAMIC_TYPE_AV':
|
|
26
26
|
desc = data?.modules?.module_dynamic?.major?.archive || {};
|
|
27
27
|
formatData.data.title = desc?.title;
|
|
28
28
|
formatData.data.content = this.parseRichTextNodes(desc?.desc);
|
|
29
29
|
formatData.data.url = this.formatUrl(desc?.jump_url);
|
|
30
30
|
formatData.data.pubTime = author.pub_time;
|
|
31
|
-
formatData.data.pubTs = moment(author.pub_ts * 1000).format(
|
|
32
|
-
formatData.data.category =
|
|
31
|
+
formatData.data.pubTs = moment(author.pub_ts * 1000).format('YYYY年MM月DD日 HH:mm:ss');
|
|
32
|
+
formatData.data.category = '视频动态';
|
|
33
33
|
formatData.data.pics = [{ url: desc?.cover }];
|
|
34
34
|
break;
|
|
35
|
-
case
|
|
35
|
+
case 'DYNAMIC_TYPE_WORD':
|
|
36
36
|
majorType = data?.modules?.module_dynamic?.major?.type;
|
|
37
|
-
if (majorType ===
|
|
37
|
+
if (majorType === 'MAJOR_TYPE_OPUS') {
|
|
38
38
|
desc = data?.modules?.module_dynamic?.major?.opus || {};
|
|
39
39
|
pics = desc?.pics;
|
|
40
|
-
pics =
|
|
41
|
-
|
|
40
|
+
pics =
|
|
41
|
+
pics.map((item) => {
|
|
42
|
+
return { url: item?.url, width: item?.width, height: item?.height };
|
|
43
|
+
}) || [];
|
|
44
|
+
formatData.data.content = this.parseRichTextNodes(desc?.summary?.rich_text_nodes || desc?.summary?.text) || '';
|
|
42
45
|
}
|
|
43
46
|
else {
|
|
44
47
|
desc = data?.modules?.module_dynamic?.desc || {};
|
|
@@ -46,79 +49,88 @@ class BiliQuery {
|
|
|
46
49
|
pics = [];
|
|
47
50
|
formatData.data.content = this.parseRichTextNodes(desc?.text);
|
|
48
51
|
}
|
|
49
|
-
formatData.data.title =
|
|
52
|
+
formatData.data.title = '';
|
|
50
53
|
formatData.data.url = `${BiliDrawDynamicLinkUrl}${data.id_str}`;
|
|
51
54
|
formatData.data.pubTime = author.pub_time;
|
|
52
|
-
formatData.data.pubTs = moment(author.pub_ts * 1000).format(
|
|
53
|
-
formatData.data.category =
|
|
55
|
+
formatData.data.pubTs = moment(author.pub_ts * 1000).format('YYYY年MM月DD日 HH:mm:ss');
|
|
56
|
+
formatData.data.category = '图文动态';
|
|
54
57
|
break;
|
|
55
|
-
case
|
|
58
|
+
case 'DYNAMIC_TYPE_DRAW':
|
|
56
59
|
majorType = data?.modules?.module_dynamic?.major?.type;
|
|
57
|
-
if (majorType ===
|
|
60
|
+
if (majorType === 'MAJOR_TYPE_OPUS') {
|
|
58
61
|
desc = data?.modules?.module_dynamic?.major?.opus || {};
|
|
59
62
|
pics = desc?.pics;
|
|
60
|
-
pics = pics.map((item) => {
|
|
61
|
-
|
|
63
|
+
pics = pics.map((item) => {
|
|
64
|
+
return { url: item?.url, width: item?.width, height: item?.height };
|
|
65
|
+
});
|
|
66
|
+
formatData.data.content = this.parseRichTextNodes(desc?.summary?.rich_text_nodes || desc?.summary?.text) || '';
|
|
62
67
|
}
|
|
63
|
-
else if (majorType ===
|
|
68
|
+
else if (majorType === 'MAJOR_TYPE_DRAW') {
|
|
64
69
|
desc = data?.modules?.module_dynamic?.desc;
|
|
65
70
|
pics = data?.modules?.module_dynamic?.major?.draw?.items;
|
|
66
|
-
pics = pics.map((item) => {
|
|
67
|
-
|
|
71
|
+
pics = pics.map((item) => {
|
|
72
|
+
return { url: item?.url, width: item?.width, height: item?.height };
|
|
73
|
+
});
|
|
74
|
+
formatData.data.content = this.parseRichTextNodes(desc?.rich_text_nodes || desc?.text) || '';
|
|
68
75
|
}
|
|
69
76
|
else {
|
|
70
77
|
desc = data?.modules?.module_dynamic?.desc;
|
|
71
78
|
pics = data?.modules?.module_dynamic?.major?.draw?.items;
|
|
72
|
-
pics = pics.map((item) => {
|
|
79
|
+
pics = pics.map((item) => {
|
|
80
|
+
return { url: item?.src };
|
|
81
|
+
});
|
|
73
82
|
formatData.data.content = this.parseRichTextNodes(desc?.text);
|
|
74
83
|
}
|
|
75
|
-
formatData.data.title =
|
|
84
|
+
formatData.data.title = '';
|
|
76
85
|
formatData.data.url = `${BiliDrawDynamicLinkUrl}${data.id_str}`;
|
|
77
86
|
formatData.data.pubTime = author.pub_time;
|
|
78
|
-
formatData.data.pubTs = moment(author.pub_ts * 1000).format(
|
|
87
|
+
formatData.data.pubTs = moment(author.pub_ts * 1000).format('YYYY年MM月DD日 HH:mm:ss');
|
|
79
88
|
formatData.data.pics = pics;
|
|
80
|
-
formatData.data.category =
|
|
89
|
+
formatData.data.category = '图文动态';
|
|
81
90
|
break;
|
|
82
|
-
case
|
|
91
|
+
case 'DYNAMIC_TYPE_ARTICLE':
|
|
83
92
|
majorType = data?.modules?.module_dynamic?.major?.type;
|
|
84
|
-
if (majorType ===
|
|
93
|
+
if (majorType === 'MAJOR_TYPE_OPUS') {
|
|
85
94
|
desc = data?.modules?.module_dynamic?.major?.opus || {};
|
|
86
95
|
pics = desc?.pics;
|
|
87
|
-
pics =
|
|
96
|
+
pics =
|
|
97
|
+
pics.map((item) => {
|
|
98
|
+
return { url: item?.url, width: item?.width, height: item?.height };
|
|
99
|
+
}) || [];
|
|
88
100
|
formatData.data.title = desc?.title;
|
|
89
101
|
// 文章内容过长,则尝试获取全文
|
|
90
|
-
if (
|
|
102
|
+
if (desc?.summary?.text?.length >= 480) {
|
|
91
103
|
const { readInfo, articleType } = await this.getFullArticleContent(this.formatUrl(desc?.jump_url));
|
|
92
104
|
// 文章链接类型为 cv(旧类型) 或者 opus(新类型)
|
|
93
|
-
if (articleType ===
|
|
105
|
+
if (articleType === 'cv') {
|
|
94
106
|
formatData.data.content = this.praseFullOldTypeArticleContent(readInfo?.content);
|
|
95
107
|
if (String(formatData.data.content).length < 100) {
|
|
96
|
-
formatData.data.content = this.parseRichTextNodes(desc?.summary?.rich_text_nodes || desc?.summary?.text) ||
|
|
108
|
+
formatData.data.content = this.parseRichTextNodes(desc?.summary?.rich_text_nodes || desc?.summary?.text) || '';
|
|
97
109
|
formatData.data.pics = pics;
|
|
98
110
|
}
|
|
99
111
|
else {
|
|
100
112
|
formatData.data.pics = [];
|
|
101
113
|
}
|
|
102
114
|
}
|
|
103
|
-
else if (articleType ===
|
|
115
|
+
else if (articleType === 'opus') {
|
|
104
116
|
const { content, img } = this.praseFullNewTypeArticleContent(readInfo?.paragraphs);
|
|
105
117
|
formatData.data.content = content;
|
|
106
|
-
formatData.data.pics =
|
|
118
|
+
formatData.data.pics = img && img.length > 0 ? img : pics;
|
|
107
119
|
if (content && content.length < 100) {
|
|
108
120
|
formatData.data.content = this.parseRichTextNodes(desc?.summary?.rich_text_nodes || desc?.summary?.text);
|
|
109
121
|
}
|
|
110
122
|
}
|
|
111
123
|
else {
|
|
112
|
-
formatData.data.content = this.parseRichTextNodes(desc?.summary?.rich_text_nodes || desc?.summary?.text) ||
|
|
124
|
+
formatData.data.content = this.parseRichTextNodes(desc?.summary?.rich_text_nodes || desc?.summary?.text) || '';
|
|
113
125
|
formatData.data.pics = pics;
|
|
114
126
|
}
|
|
115
127
|
}
|
|
116
128
|
else {
|
|
117
|
-
formatData.data.content = this.parseRichTextNodes(desc?.summary?.rich_text_nodes || desc?.summary?.text) ||
|
|
129
|
+
formatData.data.content = this.parseRichTextNodes(desc?.summary?.rich_text_nodes || desc?.summary?.text) || '';
|
|
118
130
|
formatData.data.pics = pics;
|
|
119
131
|
}
|
|
120
132
|
}
|
|
121
|
-
else if (majorType ===
|
|
133
|
+
else if (majorType === 'MAJOR_TYPE_ARTICLE') {
|
|
122
134
|
desc = data?.modules?.module_dynamic?.major?.article || {};
|
|
123
135
|
pics = desc?.covers;
|
|
124
136
|
pics = pics.map((item) => ({ url: item }));
|
|
@@ -132,25 +144,25 @@ class BiliQuery {
|
|
|
132
144
|
}
|
|
133
145
|
formatData.data.title = desc?.title;
|
|
134
146
|
formatData.data.pics = pics;
|
|
135
|
-
formatData.data.content =
|
|
147
|
+
formatData.data.content = '';
|
|
136
148
|
}
|
|
137
149
|
formatData.data.url = this.formatUrl(desc?.jump_url);
|
|
138
150
|
formatData.data.pubTime = author.pub_time;
|
|
139
|
-
formatData.data.pubTs = moment(author.pub_ts * 1000).format(
|
|
140
|
-
formatData.data.category =
|
|
151
|
+
formatData.data.pubTs = moment(author.pub_ts * 1000).format('YYYY年MM月DD日 HH:mm:ss');
|
|
152
|
+
formatData.data.category = '文章动态';
|
|
141
153
|
break;
|
|
142
|
-
case
|
|
154
|
+
case 'DYNAMIC_TYPE_FORWARD':
|
|
143
155
|
desc = data?.modules?.module_dynamic?.desc || {};
|
|
144
|
-
formatData.data.title =
|
|
156
|
+
formatData.data.title = '';
|
|
145
157
|
formatData.data.content = this.parseRichTextNodes(desc?.rich_text_nodes) || this.parseRichTextNodes(desc?.text);
|
|
146
158
|
formatData.data.pubTime = author.pub_time;
|
|
147
|
-
formatData.data.pubTs = moment(author.pub_ts * 1000).format(
|
|
159
|
+
formatData.data.pubTs = moment(author.pub_ts * 1000).format('YYYY年MM月DD日 HH:mm:ss');
|
|
148
160
|
formatData.data.url = `${BiliDrawDynamicLinkUrl}${data.id_str}`;
|
|
149
161
|
formatData.data.pics = [data?.cover];
|
|
150
162
|
formatData.data.orig = await this.formatDynamicData(data.orig);
|
|
151
|
-
formatData.data.category =
|
|
163
|
+
formatData.data.category = '转发动态';
|
|
152
164
|
break;
|
|
153
|
-
case
|
|
165
|
+
case 'DYNAMIC_TYPE_LIVE_RCMD':
|
|
154
166
|
desc = data?.modules?.module_dynamic?.major?.live_rcmd?.content;
|
|
155
167
|
if (!desc)
|
|
156
168
|
break;
|
|
@@ -159,20 +171,19 @@ class BiliQuery {
|
|
|
159
171
|
if (!desc)
|
|
160
172
|
break;
|
|
161
173
|
formatData.data.title = desc?.title;
|
|
162
|
-
formatData.data.content =
|
|
163
|
-
formatData.data.pubTime =
|
|
164
|
-
formatData.data.pubTs =
|
|
174
|
+
formatData.data.content = '';
|
|
175
|
+
formatData.data.pubTime = '';
|
|
176
|
+
formatData.data.pubTs = '';
|
|
165
177
|
formatData.data.url = `https:${desc.link}`;
|
|
166
178
|
formatData.data.pics = [{ url: desc?.cover }];
|
|
167
|
-
formatData.data.category =
|
|
179
|
+
formatData.data.category = '直播动态';
|
|
168
180
|
break;
|
|
169
181
|
}
|
|
170
182
|
return {
|
|
171
183
|
...formatData,
|
|
172
|
-
uid: data?.id_str
|
|
184
|
+
uid: data?.id_str // 用户ID
|
|
173
185
|
};
|
|
174
186
|
}
|
|
175
|
-
;
|
|
176
187
|
/**
|
|
177
188
|
* 动态内容富文本节点解析
|
|
178
189
|
* @param nodes - 动态内容富文本节点
|
|
@@ -185,7 +196,8 @@ class BiliQuery {
|
|
|
185
196
|
return nodes.replace(/\n/g, '<br>');
|
|
186
197
|
}
|
|
187
198
|
else if (Array.isArray(nodes)) {
|
|
188
|
-
return nodes
|
|
199
|
+
return nodes
|
|
200
|
+
.map((node) => {
|
|
189
201
|
switch (node.type) {
|
|
190
202
|
case 'RICH_TEXT_NODE_TYPE_TOPIC':
|
|
191
203
|
// 确保链接以 https:// 开头
|
|
@@ -217,7 +229,8 @@ class BiliQuery {
|
|
|
217
229
|
default:
|
|
218
230
|
return node;
|
|
219
231
|
}
|
|
220
|
-
})
|
|
232
|
+
})
|
|
233
|
+
.join('');
|
|
221
234
|
}
|
|
222
235
|
else {
|
|
223
236
|
// 未知类型,直接返回
|
|
@@ -225,15 +238,15 @@ class BiliQuery {
|
|
|
225
238
|
}
|
|
226
239
|
};
|
|
227
240
|
/**获取完整B站文章内容
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
241
|
+
* @param postUrl - 文章链接: https://www.bilibili.com/read/cvxxxx 或者 https://www.bilibili.com/opus/xxxx
|
|
242
|
+
* @returns {Json} 完整的B站文章内容json数据
|
|
243
|
+
*/
|
|
231
244
|
static async getFullArticleContent(postUrl) {
|
|
232
245
|
let { cookie } = await readSyncCookie();
|
|
233
246
|
cookie = await cookieWithBiliTicket(cookie);
|
|
234
247
|
try {
|
|
235
248
|
const response = await axios.get(postUrl, {
|
|
236
|
-
headers: lodash.merge(BiliApi.BILIBILI_ARTICLE_HEADERS, {
|
|
249
|
+
headers: lodash.merge(BiliApi.BILIBILI_ARTICLE_HEADERS, { Cookie: `${cookie}`, Host: 'www.bilibili.com' }),
|
|
237
250
|
responseType: 'text'
|
|
238
251
|
});
|
|
239
252
|
const text = response.data;
|
|
@@ -275,19 +288,20 @@ class BiliQuery {
|
|
|
275
288
|
return content;
|
|
276
289
|
}
|
|
277
290
|
/**解析新版完整文章内容
|
|
278
|
-
|
|
279
|
-
|
|
291
|
+
* @param paragraphs - MODULE_TYPE_CONTENT 类型文章的段落数组
|
|
292
|
+
*/
|
|
280
293
|
static praseFullNewTypeArticleContent = (paragraphs) => {
|
|
281
294
|
if (Array.isArray(paragraphs)) {
|
|
282
295
|
// 筛选出正文和图片
|
|
283
296
|
paragraphs = paragraphs.filter(paragraph => paragraph.para_type === 1 || paragraph.para_type === 2);
|
|
284
|
-
let content =
|
|
297
|
+
let content = '';
|
|
285
298
|
let img = [];
|
|
286
299
|
paragraphs.forEach((item) => {
|
|
287
300
|
switch (item.para_type) {
|
|
288
301
|
case 1:
|
|
289
302
|
// 处理正文
|
|
290
|
-
content += item.text.nodes
|
|
303
|
+
content += item.text.nodes
|
|
304
|
+
.map((node) => {
|
|
291
305
|
let nodeType = node.type;
|
|
292
306
|
if (nodeType === 'TEXT_NODE_TYPE_RICH') {
|
|
293
307
|
let richType = node?.rich?.type;
|
|
@@ -323,14 +337,17 @@ class BiliQuery {
|
|
|
323
337
|
return node;
|
|
324
338
|
}
|
|
325
339
|
}
|
|
326
|
-
else if (nodeType ===
|
|
340
|
+
else if (nodeType === 'TEXT_NODE_TYPE_WORD') {
|
|
327
341
|
return `${node?.word?.words}<br>`;
|
|
328
342
|
}
|
|
329
|
-
})
|
|
343
|
+
})
|
|
344
|
+
.join('');
|
|
330
345
|
break;
|
|
331
346
|
case 2:
|
|
332
347
|
// 处理图片
|
|
333
|
-
img = img.concat(item?.pic?.pics.map((item) => {
|
|
348
|
+
img = img.concat(item?.pic?.pics.map((item) => {
|
|
349
|
+
return { url: item?.url, width: item?.width, height: item?.height };
|
|
350
|
+
}) || []);
|
|
334
351
|
break;
|
|
335
352
|
}
|
|
336
353
|
});
|
|
@@ -354,11 +371,11 @@ class BiliQuery {
|
|
|
354
371
|
* @returns 生成的动态消息文字内容
|
|
355
372
|
*/
|
|
356
373
|
static async formatTextDynamicData(upName, data, isForward, setData) {
|
|
357
|
-
const BiliDrawDynamicLinkUrl =
|
|
374
|
+
const BiliDrawDynamicLinkUrl = 'https://m.bilibili.com/dynamic/';
|
|
358
375
|
let desc, msg, pics, author, majorType, content, dynamicTitle;
|
|
359
376
|
let title = `B站【${upName}】动态推送:\n`;
|
|
360
377
|
switch (data.type) {
|
|
361
|
-
case
|
|
378
|
+
case 'DYNAMIC_TYPE_AV':
|
|
362
379
|
// 处理视频动态
|
|
363
380
|
desc = data?.modules?.module_dynamic?.major?.archive;
|
|
364
381
|
author = data?.modules?.module_author;
|
|
@@ -371,19 +388,22 @@ class BiliQuery {
|
|
|
371
388
|
`标题:${desc.title}\n`,
|
|
372
389
|
`${desc.desc}\n`,
|
|
373
390
|
`链接:${this.formatUrl(desc.jump_url)}\n`,
|
|
374
|
-
`时间:${author ? moment(author.pub_ts * 1000).format(
|
|
375
|
-
Segment.image(desc?.cover)
|
|
391
|
+
`时间:${author ? moment(author.pub_ts * 1000).format('YYYY年MM月DD日 HH:mm:ss') : ''}\n`,
|
|
392
|
+
Segment.image(desc?.cover)
|
|
376
393
|
];
|
|
377
394
|
return msg;
|
|
378
|
-
case
|
|
395
|
+
case 'DYNAMIC_TYPE_WORD':
|
|
379
396
|
// 处理文字动态
|
|
380
397
|
author = data?.modules?.module_author;
|
|
381
398
|
majorType = data?.modules?.module_dynamic?.major?.type;
|
|
382
|
-
if (majorType ===
|
|
399
|
+
if (majorType === 'MAJOR_TYPE_OPUS') {
|
|
383
400
|
desc = data?.modules?.module_dynamic?.major?.opus || {};
|
|
384
401
|
pics = desc?.pics;
|
|
385
|
-
pics =
|
|
386
|
-
|
|
402
|
+
pics =
|
|
403
|
+
pics.map((item) => {
|
|
404
|
+
return item?.url;
|
|
405
|
+
}) || [];
|
|
406
|
+
content = desc?.summary?.text || '';
|
|
387
407
|
}
|
|
388
408
|
else {
|
|
389
409
|
desc = data?.modules?.module_dynamic?.desc || {};
|
|
@@ -399,31 +419,35 @@ class BiliQuery {
|
|
|
399
419
|
`-----------------------------\n`,
|
|
400
420
|
`内容:${this.dynamicContentLimit(content, setData)}\n`,
|
|
401
421
|
`链接:${BiliDrawDynamicLinkUrl}${data.id_str}\n`,
|
|
402
|
-
`时间:${author ? moment(author.pub_ts * 1000).format(
|
|
422
|
+
`时间:${author ? moment(author.pub_ts * 1000).format('YYYY年MM月DD日 HH:mm:ss') : ''}`
|
|
403
423
|
];
|
|
404
424
|
return msg;
|
|
405
|
-
case
|
|
425
|
+
case 'DYNAMIC_TYPE_DRAW':
|
|
406
426
|
// 处理图文动态
|
|
407
427
|
author = data?.modules?.module_author;
|
|
408
428
|
majorType = data?.modules?.module_dynamic?.major?.type;
|
|
409
|
-
if (majorType ===
|
|
429
|
+
if (majorType === 'MAJOR_TYPE_OPUS') {
|
|
410
430
|
desc = data?.modules?.module_dynamic?.major?.opus || {};
|
|
411
431
|
pics = desc?.pics;
|
|
412
432
|
pics = pics.map((item) => {
|
|
413
433
|
return item.url;
|
|
414
434
|
});
|
|
415
|
-
content = desc?.summary?.text ||
|
|
435
|
+
content = desc?.summary?.text || '';
|
|
416
436
|
}
|
|
417
|
-
else if (majorType ===
|
|
437
|
+
else if (majorType === 'MAJOR_TYPE_DRAW') {
|
|
418
438
|
desc = data?.modules?.module_dynamic?.desc;
|
|
419
439
|
pics = data?.modules?.module_dynamic?.major?.draw?.items;
|
|
420
|
-
pics = pics.map((item) => {
|
|
421
|
-
|
|
440
|
+
pics = pics.map((item) => {
|
|
441
|
+
return item?.src;
|
|
442
|
+
});
|
|
443
|
+
content = desc?.text || '';
|
|
422
444
|
}
|
|
423
445
|
else {
|
|
424
446
|
desc = data?.modules?.module_dynamic?.desc;
|
|
425
447
|
pics = data?.modules?.module_dynamic?.major?.draw?.items;
|
|
426
|
-
pics = pics.map((item) => {
|
|
448
|
+
pics = pics.map((item) => {
|
|
449
|
+
return item?.src;
|
|
450
|
+
});
|
|
427
451
|
content = desc?.text;
|
|
428
452
|
}
|
|
429
453
|
if (!desc && !pics && !author)
|
|
@@ -441,22 +465,25 @@ class BiliQuery {
|
|
|
441
465
|
`-----------------------------\n`,
|
|
442
466
|
`${this.dynamicContentLimit(content, setData)}\n`,
|
|
443
467
|
`链接:${BiliDrawDynamicLinkUrl}${data.id_str}\n`,
|
|
444
|
-
`时间:${author ? moment(author.pub_ts * 1000).format(
|
|
445
|
-
...pics
|
|
468
|
+
`时间:${author ? moment(author.pub_ts * 1000).format('YYYY年MM月DD日 HH:mm:ss') : ''}\n`,
|
|
469
|
+
...pics
|
|
446
470
|
];
|
|
447
471
|
return msg;
|
|
448
|
-
case
|
|
472
|
+
case 'DYNAMIC_TYPE_ARTICLE':
|
|
449
473
|
// 处理文章动态
|
|
450
474
|
author = data?.modules?.module_author;
|
|
451
475
|
majorType = data?.modules?.module_dynamic?.major?.type;
|
|
452
|
-
if (majorType ===
|
|
476
|
+
if (majorType === 'MAJOR_TYPE_OPUS') {
|
|
453
477
|
desc = data?.modules?.module_dynamic?.major?.opus || {};
|
|
454
478
|
pics = desc?.pics;
|
|
455
|
-
pics =
|
|
479
|
+
pics =
|
|
480
|
+
pics.map((item) => {
|
|
481
|
+
return item.url;
|
|
482
|
+
}) || [];
|
|
456
483
|
dynamicTitle = desc?.title;
|
|
457
|
-
content = desc?.summary?.text ||
|
|
484
|
+
content = desc?.summary?.text || '';
|
|
458
485
|
}
|
|
459
|
-
else if (majorType ===
|
|
486
|
+
else if (majorType === 'MAJOR_TYPE_ARTICLE') {
|
|
460
487
|
desc = data?.modules?.module_dynamic?.major?.article || {};
|
|
461
488
|
pics = desc?.covers || [];
|
|
462
489
|
dynamicTitle = desc?.title;
|
|
@@ -469,7 +496,7 @@ class BiliQuery {
|
|
|
469
496
|
}
|
|
470
497
|
dynamicTitle = desc?.title;
|
|
471
498
|
pics = pics;
|
|
472
|
-
content =
|
|
499
|
+
content = '';
|
|
473
500
|
}
|
|
474
501
|
if (!desc && !author)
|
|
475
502
|
return;
|
|
@@ -482,11 +509,11 @@ class BiliQuery {
|
|
|
482
509
|
`-----------------------------\n`,
|
|
483
510
|
`标题:${dynamicTitle}\n`,
|
|
484
511
|
`链接:${this.formatUrl(desc.jump_url)}\n`,
|
|
485
|
-
`时间:${author ? moment(author.pub_ts * 1000).format(
|
|
486
|
-
...pics
|
|
512
|
+
`时间:${author ? moment(author.pub_ts * 1000).format('YYYY年MM月DD日 HH:mm:ss') : ''}\n`,
|
|
513
|
+
...pics
|
|
487
514
|
];
|
|
488
515
|
return msg;
|
|
489
|
-
case
|
|
516
|
+
case 'DYNAMIC_TYPE_FORWARD':
|
|
490
517
|
// 处理转发动态
|
|
491
518
|
author = data?.modules?.module_author;
|
|
492
519
|
desc = data?.modules?.module_dynamic?.desc || {};
|
|
@@ -509,12 +536,12 @@ class BiliQuery {
|
|
|
509
536
|
`-----------------------------\n`,
|
|
510
537
|
`${this.dynamicContentLimit(content, setData)}\n`,
|
|
511
538
|
`链接:${BiliDrawDynamicLinkUrl}${data.id_str}\n`,
|
|
512
|
-
`时间:${author ? moment(author.pub_ts * 1000).format(
|
|
513
|
-
|
|
514
|
-
...orig
|
|
539
|
+
`时间:${author ? moment(author.pub_ts * 1000).format('YYYY年MM月DD日 HH:mm:ss') : ''}\n`,
|
|
540
|
+
'\n---以下为转发内容---\n',
|
|
541
|
+
...orig
|
|
515
542
|
];
|
|
516
543
|
return msg;
|
|
517
|
-
case
|
|
544
|
+
case 'DYNAMIC_TYPE_LIVE_RCMD':
|
|
518
545
|
// 处理直播动态
|
|
519
546
|
desc = data?.modules?.module_dynamic?.major?.live_rcmd?.content;
|
|
520
547
|
if (!desc)
|
|
@@ -524,23 +551,17 @@ class BiliQuery {
|
|
|
524
551
|
if (!desc)
|
|
525
552
|
return;
|
|
526
553
|
title = `B站【${upName}】直播动态推送:\n`;
|
|
527
|
-
msg = [
|
|
528
|
-
title,
|
|
529
|
-
`-----------------------------\n`,
|
|
530
|
-
`标题:${desc.title}\n`,
|
|
531
|
-
`链接:https:${desc.link}\n`,
|
|
532
|
-
Segment.image(desc.cover),
|
|
533
|
-
];
|
|
554
|
+
msg = [title, `-----------------------------\n`, `标题:${desc.title}\n`, `链接:https:${desc.link}\n`, Segment.image(desc.cover)];
|
|
534
555
|
return msg;
|
|
535
556
|
default:
|
|
536
557
|
// 处理未定义的动态类型
|
|
537
558
|
(Bot.logger ?? logger)?.mark(`未处理的B站推送【${upName}】:${data.type}`);
|
|
538
|
-
return
|
|
559
|
+
return 'continue';
|
|
539
560
|
}
|
|
540
561
|
}
|
|
541
562
|
// 限制文字模式下动态内容的字数和行数
|
|
542
563
|
static dynamicContentLimit(content, setData) {
|
|
543
|
-
const lines = content.split(
|
|
564
|
+
const lines = content.split('\n');
|
|
544
565
|
const lengthLimit = setData.pushContentLenLimit || 100;
|
|
545
566
|
const lineLimit = setData.pushContentLineLimit || 5;
|
|
546
567
|
// 限制行数
|
|
@@ -555,24 +576,24 @@ class BiliQuery {
|
|
|
555
576
|
continue;
|
|
556
577
|
}
|
|
557
578
|
if (lines[i].length > remainingLength) {
|
|
558
|
-
lines[i] = lines[i].slice(0, remainingLength) +
|
|
579
|
+
lines[i] = lines[i].slice(0, remainingLength) + '...';
|
|
559
580
|
totalLength = lengthLimit;
|
|
560
581
|
}
|
|
561
582
|
else {
|
|
562
583
|
totalLength += lines[i].length;
|
|
563
584
|
}
|
|
564
585
|
}
|
|
565
|
-
return lines.join(
|
|
586
|
+
return lines.join('\n');
|
|
566
587
|
}
|
|
567
588
|
/**根据关键字更新 up 的动态类型 */
|
|
568
589
|
static typeHandle(up, msg, type) {
|
|
569
590
|
// 定义一个对象映射,将关键字映射到对应的类型
|
|
570
591
|
const typeMap = {
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
592
|
+
直播: 'DYNAMIC_TYPE_LIVE_RCMD',
|
|
593
|
+
转发: 'DYNAMIC_TYPE_FORWARD',
|
|
594
|
+
文章: 'DYNAMIC_TYPE_ARTICLE',
|
|
595
|
+
图文: ['DYNAMIC_TYPE_DRAW', 'DYNAMIC_TYPE_WORD'],
|
|
596
|
+
视频: 'DYNAMIC_TYPE_AV'
|
|
576
597
|
};
|
|
577
598
|
// 初始化新的类型集合,如果 up.type 存在则使用它,否则使用空数组
|
|
578
599
|
let newType = new Set(up.type || []);
|
|
@@ -584,11 +605,11 @@ class BiliQuery {
|
|
|
584
605
|
if (msg.indexOf(key) !== -1) {
|
|
585
606
|
if (Array.isArray(value)) {
|
|
586
607
|
// 如果 value 是数组,则对数组中的每个元素进行操作
|
|
587
|
-
value.forEach(v => action ===
|
|
608
|
+
value.forEach(v => (action === 'add' ? newType.add(v) : newType.delete(v)));
|
|
588
609
|
}
|
|
589
610
|
else {
|
|
590
611
|
// 否则直接对单个值进行操作
|
|
591
|
-
action ===
|
|
612
|
+
action === 'add' ? newType.add(value) : newType.delete(value);
|
|
592
613
|
}
|
|
593
614
|
isHandled = true; // 标记有类型被处理
|
|
594
615
|
}
|
|
@@ -596,16 +617,16 @@ class BiliQuery {
|
|
|
596
617
|
return isHandled; // 返回是否有类型被处理
|
|
597
618
|
};
|
|
598
619
|
// 根据 type 参数决定是添加还是删除类型
|
|
599
|
-
if (type ===
|
|
600
|
-
handleType(
|
|
620
|
+
if (type === 'add') {
|
|
621
|
+
handleType('add'); // 调用 handleType 函数进行类型添加
|
|
601
622
|
}
|
|
602
|
-
else if (type ===
|
|
623
|
+
else if (type === 'del') {
|
|
603
624
|
if (!newType.size) {
|
|
604
625
|
// 如果 newType 为空,则初始化它为所有可能的类型
|
|
605
626
|
newType = new Set(Object.values(typeMap).flat());
|
|
606
627
|
}
|
|
607
628
|
// 调用 handleType 函数进行类型删除,如果没有类型被删除则清空 newType
|
|
608
|
-
if (!handleType(
|
|
629
|
+
if (!handleType('delete')) {
|
|
609
630
|
newType.clear();
|
|
610
631
|
}
|
|
611
632
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { EventType } from 'yunzai';
|
|
2
|
-
import { MainProps } from
|
|
2
|
+
import { MainProps } from '@/components/dynamic/MainPage';
|
|
3
3
|
import { ScreenshotOptions } from '@/utils/puppeteer.render';
|
|
4
4
|
export declare class BiliTask {
|
|
5
5
|
taskName: string;
|
|
@@ -33,7 +33,7 @@ export declare class BiliTask {
|
|
|
33
33
|
type: string[];
|
|
34
34
|
}[];
|
|
35
35
|
};
|
|
36
|
-
}, uidMap: Map<any, Map<string, any>>, dynamicList: any
|
|
36
|
+
}, biliConfigData: any, uidMap: Map<any, Map<string, any>>, dynamicList: any): Promise<void>;
|
|
37
37
|
/**
|
|
38
38
|
* 推送动态消息
|
|
39
39
|
* @param uidMap uid 映射
|