[templating] Fix: Use fields to get channel to support events

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

View file

@ -6,6 +6,7 @@ import (
"github.com/Luzifer/twitch-bot/plugins" "github.com/Luzifer/twitch-bot/plugins"
"github.com/go-irc/irc" "github.com/go-irc/irc"
"github.com/pkg/errors" "github.com/pkg/errors"
log "github.com/sirupsen/logrus"
) )
func init() { func init() {
@ -22,7 +23,13 @@ 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 {
state := botUserstate.Get(plugins.DeriveChannel(m, nil)) channel, ok := fields["channel"].(string)
if !ok {
log.Trace("Fields for botHasBadge function had no channel")
return false
}
state := botUserstate.Get(channel)
if state == nil { if state == nil {
return false return false
} }