yz-yuki-plugin 2.0.6-6 → 2.0.6-8

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/weibo.js CHANGED
@@ -1,8 +1,8 @@
1
1
  import { Messages } from 'yunzaijs';
2
- import { WeiboQuery } from '../models/weibo/weibo.query.js';
3
- import { WeiboTask } from '../models/weibo/weibo.task.js';
2
+ import { WeiboQuery } from '../models/weibo/weibo.main.query.js';
3
+ import { WeiboTask } from '../models/weibo/weibo.main.task.js';
4
4
  import Config from '../utils/config.js';
5
- import { WeiboGetWebData } from '../models/weibo/weibo.get.web.data.js';
5
+ import { WeiboGetWebData } from '../models/weibo/weibo.main.get.web.data.js';
6
6
 
7
7
  const message = new Messages('message');
8
8
  let weiboPushData = Config.getConfigData('config', 'weibo', 'push');
package/lib/index.js CHANGED
@@ -5,7 +5,7 @@ import path from 'path';
5
5
  import { _paths } from './utils/paths.js';
6
6
  import * as index$1 from './apps/index.js';
7
7
  import { BiliTask } from './models/bilibili/bilibili.main.task.js';
8
- import { WeiboTask } from './models/weibo/weibo.task.js';
8
+ import { WeiboTask } from './models/weibo/weibo.main.task.js';
9
9
 
10
10
  const yukiPluginVersion = Config.getPackageJsonKey('version', path.join(_paths.pluginPath, 'package.json'));
11
11
  let biliConfigData = Config.getConfigData('config', 'bilibili', 'config');
@@ -37,6 +37,7 @@ class BiliTask {
37
37
  let biliConfigData = await Config.getUserConfig('bilibili', 'config');
38
38
  let biliPushData = await Config.getUserConfig('bilibili', 'push');
39
39
  let interval = biliConfigData?.interval || 7200;
40
+ logger.debug(`当前B站功能配置:${JSON.stringify(biliConfigData)}`);
40
41
  const uidMap = new Map(); // 存放group 和 private 对应所属 uid 与推送信息的映射
41
42
  const dynamicList = {}; // 存放获取的所有动态,键为 uid,值为动态数组
42
43
  await this.processBiliData(biliPushData, biliConfigData, uidMap, dynamicList);
@@ -172,10 +173,11 @@ class BiliTask {
172
173
  }
173
174
  if (sended)
174
175
  return; // 如果已经发送过,则直接返回
175
- let liveAtAll = biliConfigData.liveAtAll === true ? true : false; // 直播动态是否@全体成员,默认false
176
+ let liveAtAll = !!biliConfigData.liveAtAll === true ? true : false; // 直播动态是否@全体成员,默认false
176
177
  let liveAtAllCD = biliConfigData.liveAtAllCD || 1800; // 直播动态@全体成员 冷却时间CD,默认 30 分钟
177
178
  let liveAtAllMark = await Redis.get(`${markKey}${chatId}:liveAtAllMark`); // 直播动态@全体成员标记,默认 0
178
- let liveAtAllGroupList = new Set(Array.isArray(biliConfigData.liveAtAllGroupList) ? biliConfigData.liveAtAllGroupList : []); // 直播动态@全体成员的群组列表,默认空数组,为空则不进行@全体成员操作
179
+ // 直播动态@全体成员的群组列表,默认空数组,为空则不进行@全体成员操作
180
+ let liveAtAllGroupList = new Set(Array.isArray(biliConfigData?.liveAtAllGroupList) ? Array.from(biliConfigData.liveAtAllGroupList).map(item => String(item)) : []);
179
181
  if (!!biliConfigData.pushMsgMode) {
180
182
  const { data, uid } = await BiliQuery.formatDynamicData(pushDynamicData); // 处理动态数据
181
183
  const extentData = { ...data };
@@ -207,7 +209,7 @@ class BiliTask {
207
209
  return;
208
210
  Redis.set(`${markKey}${chatId}:${id_str}`, '1', { EX: 3600 * 72 }); // 设置已发送标记
209
211
  global?.logger?.mark('优纪插件:B站动态执行推送');
210
- if (liveAtAll && liveAtAllMark && extentData?.type === 'DYNAMIC_TYPE_LIVE_RCMD' && liveAtAllGroupList.has(chatId)) {
212
+ if (liveAtAll && !liveAtAllMark && extentData?.type === 'DYNAMIC_TYPE_LIVE_RCMD' && liveAtAllGroupList.has(String(chatId))) {
211
213
  try {
212
214
  await this.sendMessage(chatId, bot_id, chatType, Segment.at('all'));
213
215
  await Redis.set(`${markKey}${chatId}:liveAtAllMark`, 1, { EX: liveAtAllCD }); // 设置直播动态@全体成员标记为 1
@@ -238,9 +240,9 @@ class BiliTask {
238
240
  }
239
241
  }
240
242
  let mergeTextPic = !!biliConfigData.mergeTextPic === false ? false : true; // 是否合并文本和图片,默认为 true
241
- if (mergeTextPic) {
243
+ if (mergeTextPic === true) {
242
244
  const mergeMsg = [...dynamicMsg.msg, ...dynamicMsg.pics];
243
- if (liveAtAll && liveAtAllMark && dynamicMsg.dynamicType === 'DYNAMIC_TYPE_LIVE_RCMD' && liveAtAllGroupList.has(chatId)) {
245
+ if (liveAtAll && !liveAtAllMark && dynamicMsg.dynamicType === 'DYNAMIC_TYPE_LIVE_RCMD' && liveAtAllGroupList.has(String(chatId))) {
244
246
  try {
245
247
  await this.sendMessage(chatId, bot_id, chatType, Segment.at('all'));
246
248
  await Redis.set(`${markKey}${chatId}:liveAtAllMark`, 1, { EX: liveAtAllCD }); // 设置直播动态@全体成员标记为 1
@@ -253,7 +255,7 @@ class BiliTask {
253
255
  await this.sendMessage(chatId, bot_id, chatType, mergeMsg);
254
256
  }
255
257
  else {
256
- if (liveAtAll && liveAtAllMark && dynamicMsg.dynamicType === 'DYNAMIC_TYPE_LIVE_RCMD' && liveAtAllGroupList.has(chatId)) {
258
+ if (liveAtAll && !liveAtAllMark && dynamicMsg.dynamicType === 'DYNAMIC_TYPE_LIVE_RCMD' && liveAtAllGroupList.has(String(chatId))) {
257
259
  try {
258
260
  await this.sendMessage(chatId, bot_id, chatType, Segment.at('all'));
259
261
  await Redis.set(`${markKey}${chatId}:liveAtAllMark`, 1, { EX: liveAtAllCD }); // 设置直播动态@全体成员标记为 1
@@ -7,7 +7,8 @@ import { readSyncCookie, cookieWithBiliTicket } from './bilibili.main.models.js'
7
7
  async function getWebId(uid) {
8
8
  const w_webid_key = 'Yz:yuki:bili:w_webid';
9
9
  const w_webid = await Redis.get(w_webid_key);
10
- if (w_webid) {
10
+ const keyTTL = await Redis.ttl(w_webid_key);
11
+ if (w_webid && keyTTL < 259200) {
11
12
  return String(w_webid);
12
13
  }
13
14
  else {
@@ -28,8 +29,10 @@ async function getWebId(uid) {
28
29
  const decoded__RENDER_DATA__JsonString = decodeURIComponent(__RENDER_DATA__[1]);
29
30
  const accessIdRegex = /"access_id":"(.*?)"/;
30
31
  const access_id = decoded__RENDER_DATA__JsonString.match(accessIdRegex);
31
- if (access_id && access_id[1]) {
32
- await Redis.set(w_webid_key, access_id[1], { EX: 43197 * 1000 });
32
+ const ExpirationTimeRegex = /document.getElementById\("__RENDER_DATA__"\).*?setTimeout\(function\(\)\s*{window.location.reload\(true\);},\s*(\d+)\s*\*\s*(\d+)\);<\/script>/;
33
+ const ExpirationTime = htmlContent.match(ExpirationTimeRegex);
34
+ if (access_id && access_id[1] && ExpirationTime && ExpirationTime[1]) {
35
+ await Redis.set(w_webid_key, access_id[1], { EX: Number(ExpirationTime[1]) });
33
36
  return String(access_id[1]);
34
37
  }
35
38
  else {
@@ -1,6 +1,6 @@
1
1
  import axios from 'axios';
2
- import { WeiboApi } from './weibo.api.js';
3
- import { WeiboQuery } from './weibo.query.js';
2
+ import { WeiboApi } from './weibo.main.api.js';
3
+ import { WeiboQuery } from './weibo.main.query.js';
4
4
 
5
5
  class WeiboGetWebData {
6
6
  e;
@@ -1,6 +1,6 @@
1
1
  import moment from 'moment';
2
2
  import fetch from 'node-fetch';
3
- import { WeiboApi } from './weibo.api.js';
3
+ import { WeiboApi } from './weibo.main.api.js';
4
4
  import { Segment } from 'yunzaijs';
5
5
  import { JSDOM } from 'jsdom';
6
6
 
@@ -2,8 +2,8 @@ import QRCode from 'qrcode';
2
2
  import { Redis, Segment, Bot } from 'yunzaijs';
3
3
  import Config from '../../utils/config.js';
4
4
  import { renderPage } from '../../utils/image.js';
5
- import { WeiboGetWebData } from './weibo.get.web.data.js';
6
- import { WeiboQuery } from './weibo.query.js';
5
+ import { WeiboGetWebData } from './weibo.main.get.web.data.js';
6
+ import { WeiboQuery } from './weibo.main.query.js';
7
7
 
8
8
  class WeiboTask {
9
9
  taskName;
@@ -19,6 +19,7 @@ class WeiboTask {
19
19
  let weiboConfigData = await Config.getUserConfig('weibo', 'config');
20
20
  let weiboPushData = await Config.getUserConfig('weibo', 'push');
21
21
  let interval = weiboConfigData.interval || 7200; // 推送间隔时间,单位为秒,默认2小时
22
+ logger.debug(`当前微博功能配置:${JSON.stringify(weiboConfigData)}`);
22
23
  const uidMap = new Map(); // 存放group 和 private 对应所属 uid 与推送信息的映射
23
24
  const dynamicList = {}; // 存放获取的所有动态,键为 uid,值为动态数组
24
25
  await this.processWeiboData(weiboPushData, uidMap, dynamicList);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "yz-yuki-plugin",
3
- "version": "2.0.6-6",
3
+ "version": "2.0.6-8",
4
4
  "description": "优纪插件,yunzaijs 关于 微博推送、B站推送 等功能的拓展插件",
5
5
  "author": "snowtafir",
6
6
  "type": "module",
@@ -107,6 +107,6 @@
107
107
  "registry": "https://registry.npmjs.org"
108
108
  },
109
109
  "engines": {
110
- "node": ">=16.14.0"
110
+ "node": ">=20"
111
111
  }
112
112
  }