Fix: Tests fail when config is nil as of field usage

Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
Knut Ahlers 2021-05-25 01:22:07 +02:00
parent 60fe2621c4
commit dac0553bdf
Signed by: luzifer
GPG key ID: 0066F03ED215AD7D

View file

@ -16,7 +16,6 @@ func formatMessage(tplString string, m *irc.Message, r *rule, fields map[string]
if m != nil { if m != nil {
fields["msg"] = m fields["msg"] = m
fields["permitTimeout"] = int64(config.PermitTimeout / time.Second)
fields["username"] = m.User fields["username"] = m.User
if m.Command == "PRIVMSG" && len(m.Params) > 0 { if m.Command == "PRIVMSG" && len(m.Params) > 0 {
@ -24,6 +23,10 @@ func formatMessage(tplString string, m *irc.Message, r *rule, fields map[string]
} }
} }
if config != nil {
fields["permitTimeout"] = int64(config.PermitTimeout / time.Second)
}
// Parse and execute template // Parse and execute template
tpl, err := template. tpl, err := template.
New(tplString). New(tplString).