From dac0553bdf49bade3649932be0b135b026797c6f Mon Sep 17 00:00:00 2001 From: Knut Ahlers Date: Tue, 25 May 2021 01:22:07 +0200 Subject: [PATCH] Fix: Tests fail when config is nil as of field usage Signed-off-by: Knut Ahlers --- msgformatter.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/msgformatter.go b/msgformatter.go index 55d0dd1..87df4d3 100644 --- a/msgformatter.go +++ b/msgformatter.go @@ -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).