mirror of
https://github.com/Luzifer/twitch-bot.git
synced 2024-12-20 11:51:17 +00:00
[core] Fix: Replace deprecated follow API
- add `moderator:read:followers` scope to bot-defaults - document requirement of bot to be mod to read followers - adjust `GetFollowDate` method to use new channel followers endpoint Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
parent
4186e16451
commit
fbc76761b4
4 changed files with 12 additions and 11 deletions
|
@ -141,7 +141,7 @@ Example:
|
|||
|
||||
### `doesFollow`
|
||||
|
||||
Returns whether `from` follows `to`
|
||||
Returns whether `from` follows `to` (the bot must be moderator of `to` to read this)
|
||||
|
||||
Syntax: `doesFollow <from> <to>`
|
||||
|
||||
|
@ -154,7 +154,7 @@ Example:
|
|||
|
||||
### `doesFollowLongerThan`
|
||||
|
||||
Returns whether `from` follows `to` for more than `duration`
|
||||
Returns whether `from` follows `to` for more than `duration` (the bot must be moderator of `to` to read this)
|
||||
|
||||
Syntax: `doesFollowLongerThan <from> <to> <duration>`
|
||||
|
||||
|
@ -180,7 +180,7 @@ Example:
|
|||
|
||||
### `followAge`
|
||||
|
||||
Looks up when `from` followed `to` and returns the duration between then and now
|
||||
Looks up when `from` followed `to` and returns the duration between then and now (the bot must be moderator of `to` to read this)
|
||||
|
||||
Syntax: `followAge <from> <to>`
|
||||
|
||||
|
@ -193,7 +193,7 @@ Example:
|
|||
|
||||
### `followDate`
|
||||
|
||||
Looks up when `from` followed `to`
|
||||
Looks up when `from` followed `to` (the bot must be moderator of `to` to read this)
|
||||
|
||||
Syntax: `followDate <from> <to>`
|
||||
|
||||
|
@ -389,7 +389,7 @@ Example:
|
|||
|
||||
```
|
||||
# Your int this hour: {{ printf "%.0f" (mulf (seededRandom (list "int" .username (now | date "2006-01-02 15") | join ":")) 100) }}%
|
||||
< Your int this hour: 46%
|
||||
< Your int this hour: 11%
|
||||
```
|
||||
|
||||
### `streamUptime`
|
||||
|
|
|
@ -50,7 +50,7 @@ func tplTwitchDoesFollowLongerThan(args plugins.RegistrationArguments) {
|
|||
return false, errors.Wrap(err, "getting follow date")
|
||||
}
|
||||
}), plugins.TemplateFuncDocumentation{
|
||||
Description: "Returns whether `from` follows `to` for more than `duration`",
|
||||
Description: "Returns whether `from` follows `to` for more than `duration` (the bot must be moderator of `to` to read this)",
|
||||
Syntax: "doesFollowLongerThan <from> <to> <duration>",
|
||||
Example: &plugins.TemplateFuncDocumentationExample{
|
||||
Template: `{{ doesFollowLongerThan "tezrian" "luziferus" "168h" }}`,
|
||||
|
@ -73,7 +73,7 @@ func tplTwitchDoesFollow(args plugins.RegistrationArguments) {
|
|||
return false, errors.Wrap(err, "getting follow date")
|
||||
}
|
||||
}), plugins.TemplateFuncDocumentation{
|
||||
Description: "Returns whether `from` follows `to`",
|
||||
Description: "Returns whether `from` follows `to` (the bot must be moderator of `to` to read this)",
|
||||
Syntax: "doesFollow <from> <to>",
|
||||
Example: &plugins.TemplateFuncDocumentationExample{
|
||||
Template: `{{ doesFollow "tezrian" "luziferus" }}`,
|
||||
|
@ -87,7 +87,7 @@ func tplTwitchFollowAge(args plugins.RegistrationArguments) {
|
|||
since, err := args.GetTwitchClient().GetFollowDate(from, to)
|
||||
return time.Since(since), errors.Wrap(err, "getting follow date")
|
||||
}), plugins.TemplateFuncDocumentation{
|
||||
Description: "Looks up when `from` followed `to` and returns the duration between then and now",
|
||||
Description: "Looks up when `from` followed `to` and returns the duration between then and now (the bot must be moderator of `to` to read this)",
|
||||
Syntax: "followAge <from> <to>",
|
||||
Example: &plugins.TemplateFuncDocumentationExample{
|
||||
Template: `{{ followAge "tezrian" "luziferus" }}`,
|
||||
|
@ -100,7 +100,7 @@ func tplTwitchFollowDate(args plugins.RegistrationArguments) {
|
|||
args.RegisterTemplateFunction("followDate", plugins.GenericTemplateFunctionGetter(func(from, to string) (time.Time, error) {
|
||||
return args.GetTwitchClient().GetFollowDate(from, to)
|
||||
}), plugins.TemplateFuncDocumentation{
|
||||
Description: "Looks up when `from` followed `to`",
|
||||
Description: "Looks up when `from` followed `to` (the bot must be moderator of `to` to read this)",
|
||||
Syntax: "followDate <from> <to>",
|
||||
Example: &plugins.TemplateFuncDocumentationExample{
|
||||
Template: `{{ followDate "tezrian" "luziferus" }}`,
|
||||
|
|
|
@ -104,7 +104,7 @@ func (c *Client) GetFollowDate(from, to string) (time.Time, error) {
|
|||
Method: http.MethodGet,
|
||||
OKStatus: http.StatusOK,
|
||||
Out: &payload,
|
||||
URL: fmt.Sprintf("https://api.twitch.tv/helix/users/follows?to_id=%s&from_id=%s", toID, fromID),
|
||||
URL: fmt.Sprintf("https://api.twitch.tv/helix/channels/followers?broadcaster_id=%s&user_id=%s", toID, fromID),
|
||||
}); err != nil {
|
||||
return time.Time{}, errors.Wrap(err, "request follow info")
|
||||
}
|
||||
|
@ -228,7 +228,7 @@ func (c *Client) GetUserInformation(user string) (*User, error) {
|
|||
return nil, errors.Errorf("unexpected number of records returned: %d", l)
|
||||
}
|
||||
|
||||
// Follow date will not change that often, cache for a long time
|
||||
// User info will not change that often, cache for a long time
|
||||
c.apiCache.Set(cacheKey, timeDay, payload.Data[0])
|
||||
out = payload.Data[0]
|
||||
|
||||
|
|
|
@ -26,6 +26,7 @@ var (
|
|||
twitch.ScopeModeratorManageChatSettings,
|
||||
twitch.ScopeModeratorManageShieldMode,
|
||||
twitch.ScopeModeratorManageShoutouts,
|
||||
twitch.ScopeModeratorReadFollowers,
|
||||
|
||||
// Chat Scopes
|
||||
twitch.ScopeChatEdit,
|
||||
|
|
Loading…
Reference in a new issue