2024-08-17 19:00:30 +02:00
|
|
|
import parsetoml
|
|
|
|
|
|
|
|
import ../model/notifier_types
|
|
|
|
import ../model/state_type
|
|
|
|
|
|
|
|
proc parseUptimeKumaConf(conf: TomlValueRef): UptimeKuma =
|
|
|
|
var uk = UptimeKuma()
|
|
|
|
uk.base_url = conf{"base_url"}.getStr()
|
|
|
|
uk.states = @[]
|
|
|
|
for state in conf{"states"}.getElems():
|
|
|
|
uk.states.add(state.getStr().toState())
|
|
|
|
if uk.states.len == 0:
|
|
|
|
uk.states = defaultStates()
|
|
|
|
return uk
|
|
|
|
|
2024-08-18 16:12:44 +02:00
|
|
|
proc parseNotifiers*(in_conf: TomlValueRef): Notifiers =
|
|
|
|
var notifiers = Notifiers()
|
2024-08-17 19:00:30 +02:00
|
|
|
if in_conf.hasKey("uptimekuma"):
|
|
|
|
let u = parseUptimeKumaConf(in_conf["uptimekuma"])
|
2024-08-18 16:12:44 +02:00
|
|
|
notifiers.uptimekuma = u
|
|
|
|
echo notifiers
|
2024-08-17 19:00:30 +02:00
|
|
|
return notifiers
|