mirror of
https://github.com/Jerryplusy/crystelf-plugin.git
synced 2025-07-04 14:19:19 +00:00
使用nodeschedule替换task
This commit is contained in:
parent
0a43014142
commit
38ca20eacd
@ -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();
|
||||
}
|
||||
|
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user