Fix: Do not extract fields from nil message

Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
Knut Ahlers 2021-05-06 15:27:24 +02:00
parent 5d44822a27
commit 6a03840592
Signed by: luzifer
GPG key ID: 0066F03ED215AD7D

View file

@ -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