[templating] Fix: State might not be present

Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
Knut Ahlers 2021-09-29 18:41:52 +02:00
parent 87df2040e4
commit f249c25317
Signed by: luzifer
GPG key ID: 0066F03ED215AD7D

View file

@ -22,7 +22,12 @@ func init() {
tplFuncs.Register("botHasBadge", func(m *irc.Message, r *plugins.Rule, fields map[string]interface{}) interface{} { tplFuncs.Register("botHasBadge", func(m *irc.Message, r *plugins.Rule, fields map[string]interface{}) interface{} {
return func(badge string) bool { 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)
} }
}) })