fix cron
This commit is contained in:
parent
2483a67088
commit
5ad6352a83
@ -3,7 +3,7 @@
|
||||
"name": "cron",
|
||||
"description": "API for plugin-scoped cron tasks",
|
||||
"tags": ["timers", "cron", "scheduler", "api"],
|
||||
"version": "1.0.0",
|
||||
"version": "1.0.1",
|
||||
"dependencies": ["control?"],
|
||||
"npmDependencies": ["node-cron@3.0.0"]
|
||||
"npmDependencies": ["node-cron@2.0.3"]
|
||||
}
|
||||
|
@ -1,7 +1,6 @@
|
||||
import { logger } from '@squeebot/core/lib/core';
|
||||
import {
|
||||
Plugin,
|
||||
Configurable,
|
||||
EventListener,
|
||||
IPlugin,
|
||||
} from '@squeebot/core/lib/plugin';
|
||||
@ -36,7 +35,9 @@ class CronWrapper {
|
||||
|
||||
if (!this.cronTask) {
|
||||
this.assert();
|
||||
this.cronTask = nodeCron.schedule(this.expression, this.execute, {
|
||||
this.cronTask = nodeCron.schedule(this.expression, () => {
|
||||
this.taskFn.call(this.origin);
|
||||
}, {
|
||||
scheduled: false,
|
||||
});
|
||||
}
|
||||
@ -65,10 +66,6 @@ class CronWrapper {
|
||||
this.cronTask = null;
|
||||
}
|
||||
|
||||
execute(): void {
|
||||
this.taskFn.call(this.origin);
|
||||
}
|
||||
|
||||
belongsTo(plugin: IPlugin | string): boolean {
|
||||
if (typeof plugin === 'string') {
|
||||
return this.origin.manifest.name === plugin;
|
||||
@ -78,7 +75,6 @@ class CronWrapper {
|
||||
}
|
||||
}
|
||||
|
||||
// @Configurable({})
|
||||
class CronPlugin extends Plugin {
|
||||
private timers: CronWrapper[] = [];
|
||||
|
||||
@ -134,6 +130,7 @@ class CronPlugin extends Plugin {
|
||||
newTimer.start();
|
||||
}
|
||||
|
||||
this.timers.push(newTimer);
|
||||
return newTimer;
|
||||
}
|
||||
|
||||
|
@ -7,7 +7,7 @@
|
||||
},
|
||||
{
|
||||
"name": "cron",
|
||||
"version": "1.0.0"
|
||||
"version": "1.0.1"
|
||||
},
|
||||
{
|
||||
"name": "permissions",
|
||||
|
Loading…
Reference in New Issue
Block a user