From 6a038405920ad4643e6d3e5817e1dd0d235727f0 Mon Sep 17 00:00:00 2001 From: Knut Ahlers Date: Thu, 6 May 2021 15:27:24 +0200 Subject: [PATCH] Fix: Do not extract fields from nil message Signed-off-by: Knut Ahlers --- msgformatter.go | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/msgformatter.go b/msgformatter.go index 23a3905..55d0dd1 100644 --- a/msgformatter.go +++ b/msgformatter.go @@ -14,12 +14,14 @@ func formatMessage(tplString string, m *irc.Message, r *rule, fields map[string] fields = map[string]interface{}{} } - fields["msg"] = m - fields["permitTimeout"] = int64(config.PermitTimeout / time.Second) - fields["username"] = m.User + 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 { - fields["channel"] = m.Params[0] + if m.Command == "PRIVMSG" && len(m.Params) > 0 { + fields["channel"] = m.Params[0] + } } // Parse and execute template