25 lines
640 B
Nim
25 lines
640 B
Nim
|
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
|
||
|
|
||
|
proc parseNotifiers*(in_conf: TomlValueRef): seq[Notifier] =
|
||
|
var notifiers: seq[Notifier] = @[]
|
||
|
if in_conf.hasKey("uptimekuma"):
|
||
|
let u = parseUptimeKumaConf(in_conf["uptimekuma"])
|
||
|
echo u
|
||
|
notifiers.add(u)
|
||
|
echo notifiers[0]
|
||
|
|
||
|
return notifiers
|