yz-yuki-plugin 2.0.7-13 → 2.0.7-14

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/CHANGELOG.md CHANGED
@@ -1,4 +1,5 @@
1
1
  # 2.0.7
2
+ * 优化获取B站文章动态内容
2
3
  * 优化订阅数据展示
3
4
  * 修复同一up订阅多个群聊订阅,推送类型合并的问题
4
5
  * 添加白名单关键词过滤功能
package/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  # YUKI-PLUGIN
4
4
 
5
- - 一个适用于 `Yunzai 系列机器人框架` 的B站动态、B站视频链接解析和微博动态订阅推送的插件
5
+ - 一个适用于 `Yunzai 系列机器人框架` 的B站动态、微博动态订阅推送和B站视频链接解析的插件
6
6
 
7
7
  - 支持 群聊/私聊 订阅B站动态和微博动态,支持定时推送,支持手动触发推送,支持简单查询B站/微博用户信息。
8
8
 
@@ -36,7 +36,27 @@ chromium-browser --version
36
36
  ## 选择安装方式
37
37
  按照网络情况以及使用的bot框架是`Yunzaijs`还是`Yunzai-V3`,选择对应的安装方式。
38
38
 
39
- ### ***(一)YunzaiJS***
39
+ ### ***(一)Yunzai-V3***
40
+
41
+ > 仅支持Yunzai-V3(TRSS/Miao)的分支,选择仓库,安装到 `yunzai/plugins`:
42
+
43
+ gitee仓库:
44
+ ```
45
+ git clone --branch main3 https://gitee.com/snowtafir/yuki-plugin.git ./plugins/yuki-plugin
46
+ ```
47
+
48
+ github仓库:
49
+ ```
50
+ git clone --branch main3 https://github.com/snowtafir/yuki-plugin.git ./plugins/yuki-plugin
51
+ ```
52
+
53
+ * 安装依赖
54
+
55
+ ```shell
56
+ pnpm install --filter=yuki-plugin
57
+ ```
58
+
59
+ ### ***(二)YunzaiJS***
40
60
  > 选择其中一种方式安装插件:
41
61
 
42
62
  1. npm包安装到`yunzaijs/node_modules`的方式,仅YunzaiJS支持:
@@ -86,26 +106,6 @@ git clone --branch main https://github.com/snowtafir/yuki-plugin.git ./plugins/y
86
106
  yarn install
87
107
  ```
88
108
 
89
- ### ***(二)Yunzai-V3***
90
-
91
- > 仅支持Yunzai-V3(TRSS/Miao)的分支,选择仓库,安装到 `yunzai/plugins`:
92
-
93
- gitee仓库:
94
- ```
95
- git clone --branch main3 https://gitee.com/snowtafir/yuki-plugin.git ./plugins/yuki-plugin
96
- ```
97
-
98
- github仓库:
99
- ```
100
- git clone --branch main3 https://github.com/snowtafir/yuki-plugin.git ./plugins/yuki-plugin
101
- ```
102
-
103
- * 安装依赖
104
-
105
- ```shell
106
- pnpm install --filter=yuki-plugin
107
- ```
108
-
109
109
  # 📦二、插件配置
110
110
 
111
111
  > [!IMPORTANT]
@@ -1,8 +1,8 @@
1
1
  import React from 'react';
2
- import { BOT_NAME, ConfigController } from 'yunzaijs';
2
+ import { ConfigController, BOT_NAME } from 'yunzaijs';
3
3
  import Config from '../../utils/config.js';
4
4
  import path from 'path';
5
- import { createRequire, _paths } from '../../utils/paths.js';
5
+ import { _paths, createRequire } from '../../utils/paths.js';
6
6
 
7
7
  // Footer.tsx
8
8
  const require = createRequire(import.meta.url);
@@ -1,8 +1,8 @@
1
1
  import React from 'react';
2
- import { BOT_NAME, ConfigController } from 'yunzaijs';
2
+ import { ConfigController, BOT_NAME } from 'yunzaijs';
3
3
  import Config from '../../utils/config.js';
4
4
  import path from 'path';
5
- import { createRequire, _paths } from '../../utils/paths.js';
5
+ import { _paths, createRequire } from '../../utils/paths.js';
6
6
 
7
7
  //help.tsx
8
8
  const require = createRequire(import.meta.url);
@@ -1,8 +1,8 @@
1
1
  import React from 'react';
2
- import { BOT_NAME, ConfigController } from 'yunzaijs';
2
+ import { ConfigController, BOT_NAME } from 'yunzaijs';
3
3
  import Config from '../../utils/config.js';
4
4
  import path from 'path';
5
- import { createRequire, _paths } from '../../utils/paths.js';
5
+ import { _paths, createRequire } from '../../utils/paths.js';
6
6
 
7
7
  const require = createRequire(import.meta.url);
8
8
  const botVersion = ConfigController.package?.version;
@@ -102,42 +102,28 @@ class BiliQuery {
102
102
  formatData.data.title = desc?.title;
103
103
  additional = data?.modules?.module_dynamic?.additional;
104
104
  // 文章内容过长,则尝试获取全文
105
+ let content = this.parseRichTextNodes(desc?.summary?.rich_text_nodes || desc?.summary?.text, additional) || '';
105
106
  if (String(desc?.summary?.text).length >= 480) {
106
107
  const fullArticleContent = await this.getFullArticleContent(this.formatUrl(desc?.jump_url));
107
108
  if (fullArticleContent) {
108
109
  const { readInfo, articleType } = fullArticleContent;
109
- // 文章链接类型为 cv(旧类型) 或者 opus(新类型)
110
- if (articleType === 'cv') {
111
- formatData.data.content = this.praseFullOldTypeArticleContent(readInfo?.content);
112
- if (String(formatData.data.content).length < 100) {
113
- formatData.data.content = this.parseRichTextNodes(desc?.summary?.rich_text_nodes || desc?.summary?.text, additional) || '';
114
- formatData.data.pics = pics;
115
- }
116
- else {
117
- formatData.data.pics = [];
110
+ // 文章类型为 cv(旧类型) 或者 opus(新类型)
111
+ if (articleType === 'opus') {
112
+ const newTypeContent = this.praseFullNewTypeArticleContent(readInfo?.paragraphs);
113
+ if (newTypeContent) {
114
+ content = newTypeContent.content || content;
115
+ pics = newTypeContent.img && newTypeContent.img.length > 0 ? newTypeContent.img : pics;
118
116
  }
119
117
  }
120
- else if (articleType === 'opus') {
121
- const FullNewTypeArticleContent = this.praseFullNewTypeArticleContent(readInfo?.paragraphs);
122
- if (FullNewTypeArticleContent) {
123
- const { content, img } = FullNewTypeArticleContent;
124
- formatData.data.content = content;
125
- formatData.data.pics = img && img.length > 0 ? img : pics;
126
- if (content && content.length < 100) {
127
- formatData.data.content = this.parseRichTextNodes(desc?.summary?.rich_text_nodes || desc?.summary?.text, additional);
128
- }
129
- }
130
- }
131
- else {
132
- formatData.data.content = this.parseRichTextNodes(desc?.summary?.rich_text_nodes || desc?.summary?.text, additional) || '';
133
- formatData.data.pics = pics;
118
+ else if (articleType === 'cv') {
119
+ const oldTypeContent = this.praseFullOldTypeArticleContent(readInfo?.content);
120
+ content = oldTypeContent || content;
134
121
  }
122
+ content = String(content).length < 100 ? this.parseRichTextNodes(desc?.summary?.rich_text_nodes || desc?.summary?.text, additional) : content;
135
123
  }
136
124
  }
137
- else {
138
- formatData.data.content = this.parseRichTextNodes(desc?.summary?.rich_text_nodes || desc?.summary?.text, additional) || '';
139
- formatData.data.pics = pics;
140
- }
125
+ formatData.data.content = content;
126
+ formatData.data.pics = pics;
141
127
  }
142
128
  else if (majorType === 'MAJOR_TYPE_ARTICLE') {
143
129
  desc = data?.modules?.module_dynamic?.major?.article || {};
@@ -251,7 +237,7 @@ class BiliQuery {
251
237
  };
252
238
  /**获取完整B站文章内容
253
239
  * @param postUrl - 文章链接: https://www.bilibili.com/read/cvxxxx 或者 https://www.bilibili.com/opus/xxxx
254
- * @returns {JSON} 完整的B站文章内容json数据
240
+ * @returns 完整的B站文章内容json数据
255
241
  */
256
242
  static async getFullArticleContent(postUrl) {
257
243
  let { cookie } = await readSyncCookie();
@@ -262,24 +248,22 @@ class BiliQuery {
262
248
  responseType: 'text'
263
249
  });
264
250
  const text = response.data;
265
- let match, readInfo, articleType;
266
- if (/^https:\/\/www.bilibili.com\/read\/cv/.test(postUrl)) {
267
- match = String(text).match(/"readInfo":([\s\S]+?),"readViewInfo":/);
268
- if (match) {
269
- const full_json_text = match[1];
270
- readInfo = JSON.parse(full_json_text);
271
- articleType = 'cv';
272
- return { readInfo, articleType };
273
- }
251
+ let matchCV, matchOPUS, readInfo, articleType;
252
+ matchCV = String(text).match(/"readInfo":([\s\S]+?),"readViewInfo":/);
253
+ matchOPUS = String(text).match(/"module_content"\s*:\s*([\s\S]+?)\s*,\s*"module_type"\s*:\s*"MODULE_TYPE_CONTENT"/);
254
+ if (matchOPUS) {
255
+ logger.info(`文章内容新`);
256
+ const full_json_text = matchOPUS[1];
257
+ readInfo = JSON.parse(full_json_text);
258
+ articleType = 'opus';
259
+ return { readInfo, articleType };
274
260
  }
275
- else if (/^https:\/\/www.bilibili.com\/opus\//.test(postUrl)) {
276
- match = String(text).match(/"module_content":([\s\S]+?),\s*"module_type":"MODULE_TYPE_CONTENT"/);
277
- if (match) {
278
- const full_json_text = match[1];
279
- readInfo = JSON.parse(full_json_text);
280
- articleType = 'opus';
281
- return { readInfo, articleType };
282
- }
261
+ else if (matchCV) {
262
+ logger.info(`文章内容旧`);
263
+ const full_json_text = matchCV[1];
264
+ readInfo = JSON.parse(full_json_text);
265
+ articleType = 'cv';
266
+ return { readInfo, articleType };
283
267
  }
284
268
  }
285
269
  catch (err) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "yz-yuki-plugin",
3
- "version": "2.0.7-13",
3
+ "version": "2.0.7-14",
4
4
  "description": "优纪插件,yunzaijs 关于 微博推送、B站推送 等功能的拓展插件",
5
5
  "author": "snowtafir",
6
6
  "type": "module",