mirror of
https://github.com/Luzifer/twitch-bot.git
synced 2024-11-08 08:10:08 +00:00
25 lines
669 B
Go
25 lines
669 B
Go
package main
|
|
|
|
import (
|
|
"strings"
|
|
)
|
|
|
|
func init() {
|
|
tplFuncs.Register("displayName", genericTemplateFunctionGetter(func(username string, v ...string) (string, error) {
|
|
displayName, err := twitchClient.GetDisplayNameForUser(strings.TrimLeft(username, "#"))
|
|
if len(v) > 0 && (err != nil || displayName == "") {
|
|
return v[0], nil
|
|
}
|
|
|
|
return displayName, err
|
|
}))
|
|
|
|
tplFuncs.Register("recentGame", genericTemplateFunctionGetter(func(username string, v ...string) (string, error) {
|
|
game, _, err := twitchClient.GetRecentStreamInfo(strings.TrimLeft(username, "#"))
|
|
if len(v) > 0 && (err != nil || game == "") {
|
|
return v[0], nil
|
|
}
|
|
|
|
return game, err
|
|
}))
|
|
}
|