2021-04-21 20:43:33 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"strings"
|
|
|
|
)
|
|
|
|
|
|
|
|
func init() {
|
2021-05-24 19:42:55 +00:00
|
|
|
tplFuncs.Register("displayName", genericTemplateFunctionGetter(func(username string, v ...string) (string, error) {
|
|
|
|
displayName, err := twitch.GetDisplayNameForUser(strings.TrimLeft(username, "#"))
|
|
|
|
if err != nil && len(v) > 0 {
|
|
|
|
return v[0], nil
|
|
|
|
}
|
|
|
|
|
|
|
|
return displayName, err
|
|
|
|
}))
|
|
|
|
|
2021-04-21 20:43:33 +00:00
|
|
|
tplFuncs.Register("recentGame", genericTemplateFunctionGetter(func(username string, v ...string) (string, error) {
|
|
|
|
game, _, err := twitch.GetRecentStreamInfo(strings.TrimLeft(username, "#"))
|
|
|
|
if err != nil && len(v) > 0 {
|
|
|
|
return v[0], nil
|
|
|
|
}
|
|
|
|
|
|
|
|
return game, err
|
|
|
|
}))
|
|
|
|
}
|