diff --git a/cron/plugin.json b/cron/plugin.json index 8fef0ef..fc55d46 100644 --- a/cron/plugin.json +++ b/cron/plugin.json @@ -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"] } diff --git a/cron/plugin.ts b/cron/plugin.ts index c7e1ddb..ea6b123 100644 --- a/cron/plugin.ts +++ b/cron/plugin.ts @@ -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; } diff --git a/squeebot.repo.json b/squeebot.repo.json index 00c81c1..9383fad 100644 --- a/squeebot.repo.json +++ b/squeebot.repo.json @@ -7,7 +7,7 @@ }, { "name": "cron", - "version": "1.0.0" + "version": "1.0.1" }, { "name": "permissions",