使用nodeschedule替换task

This commit is contained in:
Jerry 2025-05-17 12:53:36 +08:00
parent 0a43014142
commit 38ca20eacd
2 changed files with 6 additions and 15 deletions

View File

@ -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();
}

View File

@ -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;