aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.luacheckrc1
-rw-r--r--core/moduleapi.lua5
-rw-r--r--plugins/mod_cron.lua2
-rw-r--r--teal-src/plugins/mod_cron.tl3
4 files changed, 9 insertions, 2 deletions
diff --git a/.luacheckrc b/.luacheckrc
index 21191a4e..19942f9b 100644
--- a/.luacheckrc
+++ b/.luacheckrc
@@ -52,6 +52,7 @@ files["plugins/"] = {
"module.add_identity",
"module.add_item",
"module.add_timer",
+ "module.weekly",
"module.daily",
"module.hourly",
"module.broadcast",
diff --git a/core/moduleapi.lua b/core/moduleapi.lua
index 82b1faf3..6a91a045 100644
--- a/core/moduleapi.lua
+++ b/core/moduleapi.lua
@@ -521,6 +521,11 @@ function api:daily(name, fun)
self:cron({ name = name; when = "daily"; run = fun });
end
+function api:weekly(name, fun)
+ if type(name) == "function" then fun, name = name, nil; end
+ self:cron({ name = name; when = "weekly"; run = fun });
+end
+
local path_sep = package.config:sub(1,1);
function api:get_directory()
return self.resource_path or self.path and (self.path:gsub("%"..path_sep.."[^"..path_sep.."]*$", "")) or nil;
diff --git a/plugins/mod_cron.lua b/plugins/mod_cron.lua
index e23d6815..cbb551e8 100644
--- a/plugins/mod_cron.lua
+++ b/plugins/mod_cron.lua
@@ -3,7 +3,7 @@ module:set_global();
local async = require("util.async");
local datetime = require("util.datetime");
-local periods = { hourly = 3600; daily = 86400 }
+local periods = { hourly = 3600; daily = 86400; weekly = 7 * 86400 }
local active_hosts = {}
diff --git a/teal-src/plugins/mod_cron.tl b/teal-src/plugins/mod_cron.tl
index 7a2af971..581c8c0a 100644
--- a/teal-src/plugins/mod_cron.tl
+++ b/teal-src/plugins/mod_cron.tl
@@ -12,6 +12,7 @@ end
local enum frequency
"hourly"
"daily"
+ "weekly"
end
local record task_spec
@@ -28,7 +29,7 @@ local record task_event
item : task_spec
end
-local periods : { frequency : integer } = { hourly = 3600, daily = 86400 }
+local periods : { frequency : integer } = { hourly = 3600, daily = 86400, weekly = 7*86400 }
local active_hosts : { string : boolean } = { }