From 38ca20eacdc3e50900dcff7e4e8874b8846107f2 Mon Sep 17 00:00:00 2001 From: Jerry Date: Sat, 17 May 2025 12:53:36 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BD=BF=E7=94=A8nodeschedule=E6=9B=BF?= =?UTF-8?q?=E6=8D=A2task?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/reportBots.js | 10 +++------- apps/rssPush.js | 11 +++-------- 2 files changed, 6 insertions(+), 15 deletions(-) diff --git a/apps/reportBots.js b/apps/reportBots.js index ea88add..b1e5035 100644 --- a/apps/reportBots.js +++ b/apps/reportBots.js @@ -1,5 +1,6 @@ import botControl from '../lib/core/botControl.js'; import configControl from '../lib/config/configControl.js'; +import schedule from 'node-schedule'; export default class ReportBots extends plugin { constructor() { @@ -18,17 +19,12 @@ export default class ReportBots extends plugin { permission: 'master', }, ], - task: [ - { - name: 'crystelf定时同步', - corn: '*/30 * * * *', - fnc: () => this.autoReport(), - }, - ], }); + schedule.scheduleJob('*/30 * * * *', () => this.autoReport()); } async autoReport() { + logger.mark(`正在自动同步bot数据到晶灵核心..`); if (configControl.get('core')) { await botControl.reportBots(); } diff --git a/apps/rssPush.js b/apps/rssPush.js index 1b3442b..71043d7 100644 --- a/apps/rssPush.js +++ b/apps/rssPush.js @@ -4,6 +4,7 @@ import path from 'path'; import screenshot from '../lib/rss/screenshot.js'; import fs from 'fs'; import rssCache from '../lib/rss/rssCache.js'; +import schedule from 'node-schedule'; export default class RssPlugin extends plugin { constructor() { @@ -35,14 +36,8 @@ export default class RssPlugin extends plugin { priority: 500, }, ], - task: [ - { - name: 'RSS定时推送', - corn: '*/10 * * * *', - fnc: () => this.pushFeeds(), - }, - ], }); + schedule.scheduleJob('*/10 * * * *', () => this.pushFeeds()); } /** @@ -129,7 +124,7 @@ export default class RssPlugin extends plugin { */ async pushFeeds(e) { const feeds = configControl.get('feeds') || []; - + logger.mark(`正在检查rss流更新..`); for (const feed of feeds) { const latest = await rssTools.fetchFeed(feed.url); if (!latest || !latest.length) continue;