# HG changeset patch # User Kim Alvefur # Date 1689534091 -7200 # Node ID 7435a9341bb3ad777313e1335c6191b984ea0a1a # Parent 0ccd82b965d58263a5d43aefe7b0ca9c8980ee82 core.moduleapi: Turn negative periods or "never" into infinity As a way to signal that the periodic thing should be disabled, matching existing mod_mam usage diff -r 0ccd82b965d5 -r 7435a9341bb3 core/moduleapi.lua --- a/core/moduleapi.lua Sun Jul 16 20:59:27 2023 +0200 +++ b/core/moduleapi.lua Sun Jul 16 21:01:31 2023 +0200 @@ -257,8 +257,15 @@ function api:get_option_period(name, default_value) local value = self:get_option_scalar(name, default_value); if type(value) == "number" then + if value < 0 then + self:log("debug", "Treating negative period as infinity"); + return math.huge; + end -- assume seconds return value; + elseif value == "never" then + -- usually for disabling some periodic thing + return math.huge; elseif type(value) == "string" then local ret = human_io.parse_duration(value); if value ~= nil and ret == nil then