From f249c253176a5f5de6fe05c7dd49d6d8dd2ef41a Mon Sep 17 00:00:00 2001 From: Knut Ahlers Date: Wed, 29 Sep 2021 18:41:52 +0200 Subject: [PATCH] [templating] Fix: State might not be present Signed-off-by: Knut Ahlers --- functions_irc.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/functions_irc.go b/functions_irc.go index efbfd54..dfd1eb7 100644 --- a/functions_irc.go +++ b/functions_irc.go @@ -22,7 +22,12 @@ func init() { tplFuncs.Register("botHasBadge", func(m *irc.Message, r *plugins.Rule, fields map[string]interface{}) interface{} { return func(badge string) bool { - return botUserstate.Get(plugins.DeriveChannel(m, nil)).Badges.Has(badge) + state := botUserstate.Get(plugins.DeriveChannel(m, nil)) + if state == nil { + return false + } + + return state.Badges.Has(badge) } })