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 {
fields["msg"] = m
fields["permitTimeout"] = int64(config.PermitTimeout / time.Second)
fields["username"] = m.User
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
tpl, err := template.
New(tplString).