mirror of
https://github.com/Luzifer/twitch-bot.git
synced 2024-11-10 01:00:05 +00:00
[templating] Add profileImage
function
Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
parent
253379e507
commit
2f0572c256
2 changed files with 23 additions and 0 deletions
|
@ -288,6 +288,19 @@ Example:
|
||||||
< 10000
|
< 10000
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### `profileImage`
|
||||||
|
|
||||||
|
Gets the URL of the given users profile image
|
||||||
|
|
||||||
|
Syntax: `profileImage <username>`
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
```
|
||||||
|
# {{ profileImage .username }}
|
||||||
|
< https://static-cdn.jtvnw.net/jtv_user_pictures/[...].png
|
||||||
|
```
|
||||||
|
|
||||||
### `randomString`
|
### `randomString`
|
||||||
|
|
||||||
Randomly picks a string from a list of strings
|
Randomly picks a string from a list of strings
|
||||||
|
|
|
@ -19,6 +19,7 @@ func init() {
|
||||||
tplFuncs.Register("followDate", plugins.GenericTemplateFunctionGetter(tplTwitchFollowDate))
|
tplFuncs.Register("followDate", plugins.GenericTemplateFunctionGetter(tplTwitchFollowDate))
|
||||||
tplFuncs.Register("doesFollowLongerThan", plugins.GenericTemplateFunctionGetter(tplTwitchDoesFollowLongerThan))
|
tplFuncs.Register("doesFollowLongerThan", plugins.GenericTemplateFunctionGetter(tplTwitchDoesFollowLongerThan))
|
||||||
tplFuncs.Register("lastPoll", plugins.GenericTemplateFunctionGetter(tplTwitchLastPoll))
|
tplFuncs.Register("lastPoll", plugins.GenericTemplateFunctionGetter(tplTwitchLastPoll))
|
||||||
|
tplFuncs.Register("profileImage", plugins.GenericTemplateFunctionGetter(tplTwitchProfileImage))
|
||||||
tplFuncs.Register("recentGame", plugins.GenericTemplateFunctionGetter(tplTwitchRecentGame))
|
tplFuncs.Register("recentGame", plugins.GenericTemplateFunctionGetter(tplTwitchRecentGame))
|
||||||
tplFuncs.Register("recentTitle", plugins.GenericTemplateFunctionGetter(tplTwitchRecentTitle))
|
tplFuncs.Register("recentTitle", plugins.GenericTemplateFunctionGetter(tplTwitchRecentTitle))
|
||||||
tplFuncs.Register("streamUptime", plugins.GenericTemplateFunctionGetter(tplTwitchStreamUptime))
|
tplFuncs.Register("streamUptime", plugins.GenericTemplateFunctionGetter(tplTwitchStreamUptime))
|
||||||
|
@ -110,6 +111,15 @@ func tplTwitchLastPoll(username string) (*twitch.PollInfo, error) {
|
||||||
return poll, errors.Wrap(err, "getting last poll")
|
return poll, errors.Wrap(err, "getting last poll")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func tplTwitchProfileImage(username string) (string, error) {
|
||||||
|
user, err := twitchClient.GetUserInformation(strings.TrimLeft(username, "#@"))
|
||||||
|
if err != nil {
|
||||||
|
return "", errors.Wrap(err, "getting user info")
|
||||||
|
}
|
||||||
|
|
||||||
|
return user.ProfileImageURL, nil
|
||||||
|
}
|
||||||
|
|
||||||
func tplTwitchRecentGame(username string, v ...string) (string, error) {
|
func tplTwitchRecentGame(username string, v ...string) (string, error) {
|
||||||
game, _, err := twitchClient.GetRecentStreamInfo(strings.TrimLeft(username, "#"))
|
game, _, err := twitchClient.GetRecentStreamInfo(strings.TrimLeft(username, "#"))
|
||||||
if len(v) > 0 && (err != nil || game == "") {
|
if len(v) > 0 && (err != nil || game == "") {
|
||||||
|
|
Loading…
Reference in a new issue