mirror of
https://github.com/Luzifer/twitch-bot.git
synced 2024-11-14 02:52:42 +00:00
[templating] Add followAge
function
Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
parent
9106bcbe3f
commit
63ea08a4cd
2 changed files with 19 additions and 0 deletions
|
@ -4,6 +4,8 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/pkg/errors"
|
||||||
|
|
||||||
"github.com/Luzifer/twitch-bot/v3/plugins"
|
"github.com/Luzifer/twitch-bot/v3/plugins"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -17,6 +19,10 @@ func init() {
|
||||||
return displayName, err
|
return displayName, err
|
||||||
}))
|
}))
|
||||||
|
|
||||||
|
tplFuncs.Register("followAge", plugins.GenericTemplateFunctionGetter(func(from, to string) (time.Duration, error) {
|
||||||
|
since, err := twitchClient.GetFollowDate(from, to)
|
||||||
|
return time.Since(since), errors.Wrap(err, "getting follow date")
|
||||||
|
}))
|
||||||
tplFuncs.Register("followDate", plugins.GenericTemplateFunctionGetter(func(from, to string) (time.Time, error) { return twitchClient.GetFollowDate(from, to) }))
|
tplFuncs.Register("followDate", plugins.GenericTemplateFunctionGetter(func(from, to string) (time.Time, error) { return twitchClient.GetFollowDate(from, to) }))
|
||||||
|
|
||||||
tplFuncs.Register("recentGame", plugins.GenericTemplateFunctionGetter(func(username string, v ...string) (string, error) {
|
tplFuncs.Register("recentGame", plugins.GenericTemplateFunctionGetter(func(username string, v ...string) (string, error) {
|
||||||
|
|
|
@ -134,6 +134,19 @@ Example:
|
||||||
< 5 hours, 33 minutes, 12 seconds - 5 hours, 33 minutes
|
< 5 hours, 33 minutes, 12 seconds - 5 hours, 33 minutes
|
||||||
```
|
```
|
||||||
|
|
||||||
|
#### `followAge`
|
||||||
|
|
||||||
|
Looks up when `from` followed `to` and returns the duration between then and now
|
||||||
|
|
||||||
|
Syntax: `followAge <from> <to>`
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
```
|
||||||
|
# {{ followAge "tezrian" "luziferus" }}
|
||||||
|
< 15004h14m59.116620989s
|
||||||
|
```
|
||||||
|
|
||||||
#### `followDate`
|
#### `followDate`
|
||||||
|
|
||||||
Looks up when `from` followed `to`
|
Looks up when `from` followed `to`
|
||||||
|
|
Loading…
Reference in a new issue