diff --git a/apps/weibo.ts b/apps/weibo.ts index 478bccf..8528d5c 100644 --- a/apps/weibo.ts +++ b/apps/weibo.ts @@ -1,9 +1,9 @@ import { Plugin } from 'yunzaijs'; -import { WeiboQuery } from '@/models/weibo/weibo.query'; -import { WeiboTask } from '@/models/weibo/weibo.task'; +import { WeiboQuery } from '@/models/weibo/weibo.main.query'; +import { WeiboTask } from '@/models/weibo/weibo.main.task'; import Config from '@/utils/config'; import { _paths } from '@/utils/paths'; -import { WeiboGetWebData } from '@/models/weibo/weibo.get.web.data'; +import { WeiboGetWebData } from '@/models/weibo/weibo.main.get.web.data'; declare const logger: any; diff --git a/models/bilibili/bilibili.main.task.ts b/models/bilibili/bilibili.main.task.ts index 185be83..e2000e5 100644 --- a/models/bilibili/bilibili.main.task.ts +++ b/models/bilibili/bilibili.main.task.ts @@ -43,6 +43,7 @@ export class BiliTask { let biliConfigData = await Config.getUserConfig('bilibili', 'config'); let biliPushData = await Config.getUserConfig('bilibili', 'push'); let interval: number = biliConfigData?.interval || 7200; + logger.debug(`当前B站功能配置:${JSON.stringify(biliConfigData)}`); const uidMap: Map> = new Map(); // 存放group 和 private 对应所属 uid 与推送信息的映射 const dynamicList = {}; // 存放获取的所有动态,键为 uid,值为动态数组 @@ -207,10 +208,13 @@ export class BiliTask { } if (sended) return; // 如果已经发送过,则直接返回 - let liveAtAll: boolean = biliConfigData.liveAtAll === true ? true : false; // 直播动态是否@全体成员,默认false + let liveAtAll: boolean = !!biliConfigData.liveAtAll === true ? true : false; // 直播动态是否@全体成员,默认false let liveAtAllCD: number = biliConfigData.liveAtAllCD || 1800; // 直播动态@全体成员 冷却时间CD,默认 30 分钟 - let liveAtAllMark: number | string = await Redis.get(`${markKey}${chatId}:liveAtAllMark`); // 直播动态@全体成员标记,默认 0 - let liveAtAllGroupList = new Set(Array.isArray(biliConfigData.liveAtAllGroupList) ? biliConfigData.liveAtAllGroupList : []); // 直播动态@全体成员的群组列表,默认空数组,为空则不进行@全体成员操作 + let liveAtAllMark: number | string = await Redis.get(`${markKey}${chatId}:liveAtAllMark`); // 直播动态@全体成员标记 + // 直播动态@全体成员的群组列表,默认空数组,为空则不进行@全体成员操作 + let liveAtAllGroupList = new Set( + Array.isArray(biliConfigData?.liveAtAllGroupList) ? Array.from(biliConfigData.liveAtAllGroupList).map(item => String(item)) : [] + ); if (!!biliConfigData.pushMsgMode) { const { data, uid } = await BiliQuery.formatDynamicData(pushDynamicData); // 处理动态数据 @@ -250,7 +254,7 @@ export class BiliTask { global?.logger?.mark('优纪插件:B站动态执行推送'); - if (liveAtAll && liveAtAllMark && extentData?.type === 'DYNAMIC_TYPE_LIVE_RCMD' && liveAtAllGroupList.has(chatId)) { + if (liveAtAll && !liveAtAllMark && extentData?.type === 'DYNAMIC_TYPE_LIVE_RCMD' && liveAtAllGroupList.has(String(chatId))) { try { await this.sendMessage(chatId, bot_id, chatType, Segment.at('all')); await Redis.set(`${markKey}${chatId}:liveAtAllMark`, 1, { EX: liveAtAllCD }); // 设置直播动态@全体成员标记为 1 @@ -287,7 +291,7 @@ export class BiliTask { let mergeTextPic: boolean = !!biliConfigData.mergeTextPic === false ? false : true; // 是否合并文本和图片,默认为 true if (mergeTextPic) { const mergeMsg = [...dynamicMsg.msg, ...dynamicMsg.pics]; - if (liveAtAll && liveAtAllMark && dynamicMsg.dynamicType === 'DYNAMIC_TYPE_LIVE_RCMD' && liveAtAllGroupList.has(chatId)) { + if (liveAtAll && !liveAtAllMark && dynamicMsg.dynamicType === 'DYNAMIC_TYPE_LIVE_RCMD' && liveAtAllGroupList.has(String(chatId))) { try { await this.sendMessage(chatId, bot_id, chatType, Segment.at('all')); await Redis.set(`${markKey}${chatId}:liveAtAllMark`, 1, { EX: liveAtAllCD }); // 设置直播动态@全体成员标记为 1 @@ -298,7 +302,7 @@ export class BiliTask { } await this.sendMessage(chatId, bot_id, chatType, mergeMsg); } else { - if (liveAtAll && liveAtAllMark && dynamicMsg.dynamicType === 'DYNAMIC_TYPE_LIVE_RCMD' && liveAtAllGroupList.has(chatId)) { + if (liveAtAll && !liveAtAllMark && dynamicMsg.dynamicType === 'DYNAMIC_TYPE_LIVE_RCMD' && liveAtAllGroupList.has(String(chatId))) { try { await this.sendMessage(chatId, bot_id, chatType, Segment.at('all')); await Redis.set(`${markKey}${chatId}:liveAtAllMark`, 1, { EX: liveAtAllCD }); // 设置直播动态@全体成员标记为 1 diff --git a/models/weibo/weibo.api.ts b/models/weibo/weibo.main.api.ts similarity index 100% rename from models/weibo/weibo.api.ts rename to models/weibo/weibo.main.api.ts diff --git a/models/weibo/weibo.get.web.data.ts b/models/weibo/weibo.main.get.web.data.ts similarity index 94% rename from models/weibo/weibo.get.web.data.ts rename to models/weibo/weibo.main.get.web.data.ts index 40aef47..fdc9a0e 100644 --- a/models/weibo/weibo.get.web.data.ts +++ b/models/weibo/weibo.main.get.web.data.ts @@ -1,7 +1,7 @@ import axios from 'axios'; import { EventType } from 'yunzaijs'; -import { WeiboApi } from '@/models/weibo/weibo.api'; -import { WeiboQuery } from '@/models/weibo/weibo.query'; +import { WeiboApi } from '@/models/weibo/weibo.main.api'; +import { WeiboQuery } from '@/models/weibo/weibo.main.query'; declare const logger: any; diff --git a/models/weibo/weibo.query.ts b/models/weibo/weibo.main.query.ts similarity index 99% rename from models/weibo/weibo.query.ts rename to models/weibo/weibo.main.query.ts index ee024e1..240102d 100644 --- a/models/weibo/weibo.query.ts +++ b/models/weibo/weibo.main.query.ts @@ -1,6 +1,6 @@ import moment from 'moment'; import fetch from 'node-fetch'; -import { WeiboApi } from '@/models/weibo/weibo.api'; +import { WeiboApi } from '@/models/weibo/weibo.main.api'; import { Segment } from 'yunzaijs'; import { JSDOM } from 'jsdom'; diff --git a/models/weibo/weibo.task.ts b/models/weibo/weibo.main.task.ts similarity index 98% rename from models/weibo/weibo.task.ts rename to models/weibo/weibo.main.task.ts index 3f4d133..0c14e18 100644 --- a/models/weibo/weibo.task.ts +++ b/models/weibo/weibo.main.task.ts @@ -4,8 +4,8 @@ import { MainProps } from '@/components/dynamic/MainPage'; import Config from '@/utils/config'; import { renderPage } from '@/utils/image'; import { ScreenshotOptions } from '@/utils/puppeteer.render'; -import { WeiboGetWebData } from '@/models/weibo/weibo.get.web.data'; -import { WeiboQuery } from '@/models/weibo/weibo.query'; +import { WeiboGetWebData } from '@/models/weibo/weibo.main.get.web.data'; +import { WeiboQuery } from '@/models/weibo/weibo.main.query'; declare const logger: any; @@ -24,6 +24,7 @@ export class WeiboTask { let weiboConfigData = await Config.getUserConfig('weibo', 'config'); let weiboPushData = await Config.getUserConfig('weibo', 'push'); let interval: number = weiboConfigData.interval || 7200; // 推送间隔时间,单位为秒,默认2小时 + logger.debug(`当前微博功能配置:${JSON.stringify(weiboConfigData)}`); const uidMap: Map> = new Map(); // 存放group 和 private 对应所属 uid 与推送信息的映射 const dynamicList = {}; // 存放获取的所有动态,键为 uid,值为动态数组 diff --git a/package.json b/package.json index b3fbc5c..26e6cec 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "yuki-plugin", - "version": "2.0.6-6", + "version": "2.0.6-7", "author": "snowtafir", "description": "优纪插件,yunzai-V4 关于 微博推送、B站推送 等功能的拓展插件", "main": "./index",