mirror of
https://github.com/Luzifer/twitch-bot.git
synced 2024-11-14 02:52:42 +00:00
26 lines
588 B
Go
26 lines
588 B
Go
|
package main
|
||
|
|
||
|
import (
|
||
|
"strings"
|
||
|
|
||
|
"github.com/go-irc/irc"
|
||
|
"github.com/pkg/errors"
|
||
|
)
|
||
|
|
||
|
func init() {
|
||
|
tplFuncs.Register("channelCounter", func(m *irc.Message, r *rule, fields map[string]interface{}) interface{} {
|
||
|
return func(name string) (string, error) {
|
||
|
channel, ok := fields["channel"].(string)
|
||
|
if !ok {
|
||
|
return "", errors.New("channel not available")
|
||
|
}
|
||
|
|
||
|
return strings.Join([]string{channel, name}, ":"), nil
|
||
|
}
|
||
|
})
|
||
|
|
||
|
tplFuncs.Register("counterValue", genericTemplateFunctionGetter(func(name string, _ ...string) int64 {
|
||
|
return store.GetCounterValue(name)
|
||
|
}))
|
||
|
}
|