This commit is contained in:
Evert Prants 2021-10-01 21:44:48 +03:00
parent 2483a67088
commit 5ad6352a83
Signed by: evert
GPG Key ID: 1688DA83D222D0B5
3 changed files with 7 additions and 10 deletions

View File

@ -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"]
}

View File

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

View File

@ -7,7 +7,7 @@
},
{
"name": "cron",
"version": "1.0.0"
"version": "1.0.1"
},
{
"name": "permissions",