mirror of
https://github.com/Luzifer/twitch-bot.git
synced 2024-12-20 20:01:17 +00:00
[templating] Fix: Use fields to get channel to support events
Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
parent
f249c25317
commit
2b1502e64f
1 changed files with 8 additions and 1 deletions
|
@ -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
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue