yz-yuki-plugin 2.0.7-10 → 2.0.7-12

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.
@@ -13,7 +13,7 @@ class BiliQuery {
13
13
  */
14
14
  static async formatDynamicData(data) {
15
15
  const BiliDrawDynamicLinkUrl = 'https://m.bilibili.com/dynamic/';
16
- let desc, pics = [], majorType;
16
+ let desc, pics = [], majorType, additional;
17
17
  let formatData = { data: {} };
18
18
  const author = data?.modules?.module_author || {};
19
19
  formatData.data.face = author.face; // 作者头像
@@ -41,7 +41,8 @@ class BiliQuery {
41
41
  pics.map((item) => {
42
42
  return { url: item?.url, width: item?.width, height: item?.height };
43
43
  }) || [];
44
- formatData.data.content = this.parseRichTextNodes(desc?.summary?.rich_text_nodes || desc?.summary?.text) || '';
44
+ additional = data?.modules?.module_dynamic?.additional;
45
+ formatData.data.content = this.parseRichTextNodes(desc?.summary?.rich_text_nodes || desc?.summary?.text, additional) || '';
45
46
  }
46
47
  else {
47
48
  desc = data?.modules?.module_dynamic?.desc || {};
@@ -63,7 +64,8 @@ class BiliQuery {
63
64
  pics = pics.map((item) => {
64
65
  return { url: item?.url, width: item?.width, height: item?.height };
65
66
  });
66
- formatData.data.content = this.parseRichTextNodes(desc?.summary?.rich_text_nodes || desc?.summary?.text) || '';
67
+ additional = data?.modules?.module_dynamic?.additional;
68
+ formatData.data.content = this.parseRichTextNodes(desc?.summary?.rich_text_nodes || desc?.summary?.text, additional) || '';
67
69
  }
68
70
  else if (majorType === 'MAJOR_TYPE_DRAW') {
69
71
  desc = data?.modules?.module_dynamic?.desc;
@@ -98,6 +100,7 @@ class BiliQuery {
98
100
  return { url: item?.url, width: item?.width, height: item?.height };
99
101
  }) || [];
100
102
  formatData.data.title = desc?.title;
103
+ additional = data?.modules?.module_dynamic?.additional;
101
104
  // 文章内容过长,则尝试获取全文
102
105
  if (String(desc?.summary?.text).length >= 480) {
103
106
  const fullArticleContent = await this.getFullArticleContent(this.formatUrl(desc?.jump_url));
@@ -107,7 +110,7 @@ class BiliQuery {
107
110
  if (articleType === 'cv') {
108
111
  formatData.data.content = this.praseFullOldTypeArticleContent(readInfo?.content);
109
112
  if (String(formatData.data.content).length < 100) {
110
- formatData.data.content = this.parseRichTextNodes(desc?.summary?.rich_text_nodes || desc?.summary?.text) || '';
113
+ formatData.data.content = this.parseRichTextNodes(desc?.summary?.rich_text_nodes || desc?.summary?.text, additional) || '';
111
114
  formatData.data.pics = pics;
112
115
  }
113
116
  else {
@@ -121,18 +124,18 @@ class BiliQuery {
121
124
  formatData.data.content = content;
122
125
  formatData.data.pics = img && img.length > 0 ? img : pics;
123
126
  if (content && content.length < 100) {
124
- formatData.data.content = this.parseRichTextNodes(desc?.summary?.rich_text_nodes || desc?.summary?.text);
127
+ formatData.data.content = this.parseRichTextNodes(desc?.summary?.rich_text_nodes || desc?.summary?.text, additional);
125
128
  }
126
129
  }
127
130
  }
128
131
  else {
129
- formatData.data.content = this.parseRichTextNodes(desc?.summary?.rich_text_nodes || desc?.summary?.text) || '';
132
+ formatData.data.content = this.parseRichTextNodes(desc?.summary?.rich_text_nodes || desc?.summary?.text, additional) || '';
130
133
  formatData.data.pics = pics;
131
134
  }
132
135
  }
133
136
  }
134
137
  else {
135
- formatData.data.content = this.parseRichTextNodes(desc?.summary?.rich_text_nodes || desc?.summary?.text) || '';
138
+ formatData.data.content = this.parseRichTextNodes(desc?.summary?.rich_text_nodes || desc?.summary?.text, additional) || '';
136
139
  formatData.data.pics = pics;
137
140
  }
138
141
  }
@@ -195,7 +198,7 @@ class BiliQuery {
195
198
  * @param nodes - 动态内容富文本节点
196
199
  * @returns 解析后的动态内容富文本
197
200
  */
198
- static parseRichTextNodes = (nodes) => {
201
+ static parseRichTextNodes = (nodes, additional) => {
199
202
  if (typeof nodes === 'string') {
200
203
  // 将\t 替换为&nbsp;实现空格,\n 替换为 <br> 以实现换行
201
204
  nodes = nodes.replace(/\t/g, '&nbsp;');
@@ -223,7 +226,7 @@ class BiliQuery {
223
226
  return `<span data-module="desc" data-type="lottery" data-oid="${node?.rid}" class="bili-rich-text-module lottery">${node?.text}</span>`;
224
227
  case 'RICH_TEXT_NODE_TYPE_WEB':
225
228
  // 处理 RICH_TEXT_NODE_TYPE_WEB 类型,直接拼接 text 属性
226
- return node.text;
229
+ return node.orig_text || node.text;
227
230
  case 'RICH_TEXT_NODE_TYPE_EMOJI':
228
231
  // 处理表情类型,使用 img 标签显示表情
229
232
  const emoji = node.emoji;
@@ -232,6 +235,9 @@ class BiliQuery {
232
235
  // 处理商品推广类型,使用官方的HTML标签写法
233
236
  const goods_url = node?.jump_url;
234
237
  return `<span data-module="desc" data-type="goods" data-url="${goods_url}" data-oid="${node?.rid}" class="bili-rich-text-module goods ${node?.icon_name}">&ZeroWidthSpace;${node?.text}</span>`;
238
+ case 'RICH_TEXT_NODE_TYPE_VOTE':
239
+ // 处理投票类型,使用官方的HTML标签写法
240
+ return `<div data-module="additional" data-orig="0" class="bili-dyn-content__orig__additional"><div class="bili-dyn-card-vote"><div class="bili-dyn-card-vote__header"><div class="bili-dyn-card-vote__cover"></div></div> <div class="bili-dyn-card-vote__body"><div class="bili-dyn-card-vote__detail"><div class="bili-dyn-card-vote__detail__title">${node?.text}</div> <div class="bili-dyn-card-vote__detail__desc">${additional && additional?.type === 'ADDITIONAL_TYPE_VOTE' ? additional?.vote?.desc : ''}</div></div> <div class="bili-dyn-card-vote__action"><button class="bili-dyn-card-vote__action__btn_normal">${additional && additional.type === 'ADDITIONAL_TYPE_VOTE' ? additional?.vote?.button?.jump_style?.text : ''}</button></div></div></div></div>`;
235
241
  default:
236
242
  return node;
237
243
  }
@@ -74,12 +74,7 @@ class BiliTask {
74
74
  const { uid, bot_id, name, type } = subInfoOfup;
75
75
  let resp;
76
76
  // 检查是否已经请求过该 uid
77
- if (requestedDataOfUids.has(uid)) {
78
- resp = requestedDataOfUids.get(uid); // 从已请求的映射中获取响应数据
79
- const dynamicData = resp.data?.items || [];
80
- dynamicList[uid] = dynamicData;
81
- }
82
- else {
77
+ if (!requestedDataOfUids.has(uid)) {
83
78
  resp = await this.hendleEventDynamicData(uid);
84
79
  if (resp) {
85
80
  if (resp.code === 0) {
@@ -142,8 +137,9 @@ class BiliTask {
142
137
  logger.debug(`超过间隔,跳过 [ ${author?.name} : ${author?.mid} ] ${author?.pub_time} 的动态`);
143
138
  continue;
144
139
  } // 如果超过推送时间间隔,跳过当前循环
145
- if (dynamicItem.type === 'DYNAMIC_TYPE_FORWARD' && !biliConfigData.pushTransmit)
146
- continue; // 如果关闭了转发动态的推送,跳过当前循环
140
+ if (dynamicItem?.type === 'DYNAMIC_TYPE_FORWARD' && !biliConfigData.pushTransmit) {
141
+ continue;
142
+ } // 如果关闭了转发动态的推送,跳过当前循环
147
143
  willPushDynamicList.push(dynamicItem);
148
144
  }
149
145
  // 遍历待推送的动态数组,发送动态消息
@@ -151,8 +147,9 @@ class BiliTask {
151
147
  for (let [chatId, subUpInfo] of chatIdMap) {
152
148
  const { upName, types } = subUpInfo;
153
149
  for (let pushDynamicData of willPushDynamicList) {
154
- if (types && types.length && !types.includes(pushDynamicData.type))
155
- continue; // 如果禁用了某类型的动态推送,跳过当前循环
150
+ if (types && types.length > 0 && !types.includes(pushDynamicData.type)) {
151
+ continue;
152
+ } // 如果禁用了某类型的动态推送,跳过当前循环
156
153
  await this.makeDynamicMessageMap(chatId, bot_id, upName, pushDynamicData, biliConfigData, chatType, messageMap); // 发送动态消息
157
154
  await this.randomDelay(1000, 2000); // 随机延时1-2秒
158
155
  }
@@ -54,12 +54,7 @@ class WeiboTask {
54
54
  const { uid, bot_id, name, type } = subInfoOfup;
55
55
  let resp;
56
56
  // 检查是否已经请求过该 uid
57
- if (requestedDataOfUids.has(uid)) {
58
- resp = requestedDataOfUids.get(uid); // 从已请求的映射中获取响应数据
59
- const dynamicData = resp || [];
60
- dynamicList[uid] = dynamicData;
61
- }
62
- else {
57
+ if (!requestedDataOfUids.has(uid)) {
63
58
  resp = await new WeiboWebDataFetcher().getBloggerDynamicList(uid); // 获取指定 uid 的动态列表
64
59
  if (resp) {
65
60
  requestedDataOfUids.set(uid, resp); // 将响应数据存储到映射中
@@ -109,8 +104,9 @@ class WeiboTask {
109
104
  logger.debug(`超过间隔,跳过 [ ${user?.screen_name} : ${user?.id} ] ${raw_post?.mblog?.created_at} 的动态`);
110
105
  continue;
111
106
  } // 如果超过推送时间间隔,跳过当前循环
112
- if (dynamicItem.type === 'DYNAMIC_TYPE_FORWARD' && !weiboConfigData.pushTransmit)
113
- continue; // 如果关闭了转发动态的推送,跳过当前循环
107
+ if (dynamicItem?.type === 'DYNAMIC_TYPE_FORWARD' && !weiboConfigData.pushTransmit) {
108
+ continue;
109
+ } // 如果关闭了转发动态的推送,跳过当前循环
114
110
  willPushDynamicList.push(dynamicItem);
115
111
  }
116
112
  // 遍历待推送的动态数组,发送动态消息
@@ -118,8 +114,9 @@ class WeiboTask {
118
114
  for (let [chatId, subUpInfo] of chatIdMap) {
119
115
  const { upName, types } = subUpInfo;
120
116
  for (let pushDynamicData of willPushDynamicList) {
121
- if (types && types.length && !types.includes(pushDynamicData.type))
122
- continue; // 如果禁用了某类型的动态推送,跳过当前循环
117
+ if (types && types.length > 0 && !types.includes(pushDynamicData.type)) {
118
+ continue;
119
+ } // 如果禁用了某类型的动态推送,跳过当前循环
123
120
  await this.makeDynamicMessageMap(chatId, bot_id, upName, pushDynamicData, weiboConfigData, chatType, messageMap); // 发送动态消息
124
121
  await this.randomDelay(1000, 2000); // 随机延时1-2秒
125
122
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "yz-yuki-plugin",
3
- "version": "2.0.7-10",
3
+ "version": "2.0.7-12",
4
4
  "description": "优纪插件,yunzaijs 关于 微博推送、B站推送 等功能的拓展插件",
5
5
  "author": "snowtafir",
6
6
  "type": "module",
@@ -78,3 +78,96 @@
78
78
  background-image: url('./../../img/icon/dynamic/bili-rich-text-module-goods-taobao.svg');
79
79
  /* 引入SVG图标 */
80
80
  }
81
+
82
+ /* 定义B站投票标签样式 */
83
+ .bili-dyn-content__orig__additional {
84
+ margin-top: 12px;
85
+ }
86
+
87
+ .bili-dyn-card-vote {
88
+ background-color: rgba(246, 247, 248, 0.8);
89
+ border-radius: 6px;
90
+ box-sizing: border-box;
91
+ cursor: pointer;
92
+ display: flex;
93
+ height: 78px;
94
+ height: 100%;
95
+ overflow: hidden;
96
+ border: 1px solid #ff69b4;
97
+ }
98
+
99
+ .bili-dyn-card-vote__header {
100
+ flex-shrink: 0;
101
+ padding: 25px;
102
+ width: 78px;
103
+ background-color: rgb(255, 255, 255);
104
+ }
105
+
106
+ .bili-dyn-card-vote__cover {
107
+ align-items: center;
108
+ background-color: #ffffff;
109
+ border-radius: 4px;
110
+ color: #008ac5;
111
+ display: flex;
112
+ height: 100%;
113
+ justify-content: center;
114
+ width: 100%;
115
+ /* 引入SVG图标 */
116
+ background-image: url('./../../img/icon/dynamic/bili-dyn-card-vote__cover.svg');
117
+ }
118
+
119
+ .bili-dyn-card-vote__body,
120
+ .bili-dyn-card-vote__detail {
121
+ display: flex;
122
+ flex: 1;
123
+ overflow: hidden;
124
+ }
125
+
126
+ .bili-dyn-card-vote__detail {
127
+ box-sizing: border-box;
128
+ flex-direction: column;
129
+ padding: 19px 16px 15px 20px;
130
+ }
131
+
132
+ .bili-dyn-card-vote__detail__title {
133
+ color: #18191c;
134
+ font-size: 14px;
135
+ line-height: 20px;
136
+ overflow: hidden;
137
+ text-overflow: ellipsis;
138
+ transition: all 0.2s;
139
+ white-space: nowrap;
140
+ width: 100%;
141
+ }
142
+
143
+ .bili-dyn-card-vote__detail__desc {
144
+ color: #9499a0;
145
+ font-size: 12px;
146
+ line-height: 17px;
147
+ margin-top: 4px;
148
+ }
149
+
150
+ .bili-dyn-card-vote__action {
151
+ align-items: center;
152
+ display: flex;
153
+ flex-shrink: 0;
154
+ justify-content: center;
155
+ margin-right: 16px;
156
+ padding-right: 15px;
157
+ }
158
+
159
+ .bili-dyn-card-vote__action__btn_normal {
160
+ background-color: #ff69b4;
161
+ color: #ffffff;
162
+ }
163
+
164
+ .bili-dyn-card-vote__action button {
165
+ border: none;
166
+ border-radius: 6px;
167
+ box-sizing: border-box;
168
+ cursor: pointer;
169
+ font-size: 12.8px;
170
+ height: 30px;
171
+ min-width: 72px;
172
+ outline: none;
173
+ }
@@ -0,0 +1 @@
1
+ <svg style="width: 28px; height: 28px;" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 28 28" width="28" height="28"><path d="M2.4583333333333335 16.626283333333333C2.4583333333333335 15.084516666666667 3.7082066666666664 13.834616666666667 5.25 13.834616666666667L6.416666666666667 13.834616666666667C7.95846 13.834616666666667 9.208333333333334 15.084516666666667 9.208333333333334 16.626283333333333L9.208333333333334 20.70961666666667C9.208333333333334 22.251383333333333 7.95846 23.501283333333337 6.416666666666667 23.501283333333337L5.25 23.501283333333337C3.7082066666666664 23.501283333333337 2.4583333333333335 22.251383333333333 2.4583333333333335 20.70961666666667L2.4583333333333335 16.626283333333333zM5.25 15.334616666666665C4.5366333333333335 15.334616666666665 3.9583333333333335 15.912883333333335 3.9583333333333335 16.626283333333333L3.9583333333333335 20.70961666666667C3.9583333333333335 21.42301666666667 4.5366333333333335 22.001283333333337 5.25 22.001283333333337L6.416666666666667 22.001283333333337C7.130040000000001 22.001283333333337 7.708333333333335 21.42301666666667 7.708333333333335 20.70961666666667L7.708333333333335 16.626283333333333C7.708333333333335 15.912883333333335 7.130040000000001 15.334616666666665 6.416666666666667 15.334616666666665L5.25 15.334616666666665z" fill="currentColor" style="--darkreader-inline-fill: currentColor;" data-darkreader-inline-fill=""></path><path d="M10.625000000000002 6.709476666666667C10.625000000000002 5.167683333333334 11.874906666666668 3.9178100000000007 13.416666666666668 3.9178100000000007L14.583333333333334 3.9178100000000007C16.1251 3.9178100000000007 17.375 5.167683333333334 17.375 6.709476666666667L17.375 20.709500000000002C17.375 22.251266666666666 16.1251 23.50116666666667 14.583333333333334 23.50116666666667L13.416666666666668 23.50116666666667C11.874906666666668 23.50116666666667 10.625000000000002 22.251266666666666 10.625000000000002 20.709500000000002L10.625000000000002 6.709476666666667zM13.416666666666668 5.41781C12.703266666666666 5.41781 12.125 5.996103333333333 12.125 6.709476666666667L12.125 20.709500000000002C12.125 21.422816666666666 12.703266666666666 22.00116666666667 13.416666666666668 22.00116666666667L14.583333333333334 22.00116666666667C15.296733333333336 22.00116666666667 15.875000000000002 21.422816666666666 15.875000000000002 20.709500000000002L15.875000000000002 6.709476666666667C15.875000000000002 5.996103333333333 15.296733333333336 5.41781 14.583333333333334 5.41781L13.416666666666668 5.41781z" fill="currentColor" style="--darkreader-inline-fill: currentColor;" data-darkreader-inline-fill=""></path><path d="M18.791666666666668 12.8345C18.791666666666668 11.292683333333335 20.041566666666668 10.042810000000001 21.583333333333336 10.042810000000001L22.75 10.042810000000001C24.291766666666668 10.042810000000001 25.541666666666668 11.292683333333335 25.541666666666668 12.8345L25.541666666666668 20.709500000000002C25.541666666666668 22.251266666666666 24.291766666666668 23.50116666666667 22.75 23.50116666666667L21.583333333333336 23.50116666666667C20.041566666666668 23.50116666666667 18.791666666666668 22.251266666666666 18.791666666666668 20.709500000000002L18.791666666666668 12.8345zM21.583333333333336 11.542816666666667C20.869933333333336 11.542816666666667 20.291666666666668 12.121100000000002 20.291666666666668 12.8345L20.291666666666668 20.709500000000002C20.291666666666668 21.422816666666666 20.869933333333336 22.00116666666667 21.583333333333336 22.00116666666667L22.75 22.00116666666667C23.4634 22.00116666666667 24.041666666666668 21.422816666666666 24.041666666666668 20.709500000000002L24.041666666666668 12.8345C24.041666666666668 12.121100000000002 23.4634 11.542816666666667 22.75 11.542816666666667L21.583333333333336 11.542816666666667z" fill="currentColor" style="--darkreader-inline-fill: currentColor;" data-darkreader-inline-fill=""></path></svg>