mirror of
https://github.com/Luzifer/badge-gen.git
synced 2024-12-20 16:41:16 +00:00
Remove twitch follower count badge
as twitch removed public requests of that information this program is no longer able to retrieve these information as a user token with a special scope is required which cannot obtained in an anonymous request Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
parent
4472bb9144
commit
3f6103d473
1 changed files with 0 additions and 38 deletions
|
@ -31,11 +31,6 @@ type twitchServiceHandler struct {
|
|||
|
||||
func (t twitchServiceHandler) GetDocumentation() serviceHandlerDocumentationList {
|
||||
return serviceHandlerDocumentationList{
|
||||
{
|
||||
ServiceName: "Twitch followers",
|
||||
DemoPath: "/twitch/followers/luziferus",
|
||||
Arguments: []string{"followers", "<user login/id>"},
|
||||
},
|
||||
{
|
||||
ServiceName: "Twitch views",
|
||||
DemoPath: "/twitch/views/luziferus",
|
||||
|
@ -55,8 +50,6 @@ func (t *twitchServiceHandler) Handle(ctx context.Context, params []string) (tit
|
|||
}
|
||||
|
||||
switch params[0] {
|
||||
case "followers":
|
||||
title, text, color, err = t.handleFollowers(ctx, params[1:])
|
||||
case "views":
|
||||
title, text, color, err = t.handleViews(ctx, params[1:])
|
||||
default:
|
||||
|
@ -66,19 +59,6 @@ func (t *twitchServiceHandler) Handle(ctx context.Context, params []string) (tit
|
|||
return
|
||||
}
|
||||
|
||||
func (t *twitchServiceHandler) handleFollowers(ctx context.Context, params []string) (title, text, color string, err error) {
|
||||
followCount, err := t.getUserFollows(params[0])
|
||||
if err != nil {
|
||||
return "", "", "", errors.Wrap(err, "requesting user follows")
|
||||
}
|
||||
|
||||
text = strconv.FormatInt(followCount, 10)
|
||||
title = "followers"
|
||||
color = "9146FF"
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
func (t *twitchServiceHandler) handleViews(ctx context.Context, params []string) (title, text, color string, err error) {
|
||||
var respData struct {
|
||||
Data []struct {
|
||||
|
@ -156,24 +136,6 @@ func (t *twitchServiceHandler) getIDForUser(login string) (string, error) {
|
|||
return respData.Data[0].ID, nil
|
||||
}
|
||||
|
||||
func (t *twitchServiceHandler) getUserFollows(user string) (int64, error) {
|
||||
var respData struct {
|
||||
Total int64
|
||||
}
|
||||
|
||||
if _, err := strconv.ParseInt(user, 10, 64); err != nil {
|
||||
if user, err = t.getIDForUser(user); err != nil {
|
||||
return 0, errors.Wrap(err, "getting id for user login")
|
||||
}
|
||||
}
|
||||
|
||||
if err := t.doTwitchRequest(http.MethodGet, fmt.Sprintf("https://api.twitch.tv/helix/users/follows?to_id=%s", user), nil, &respData); err != nil {
|
||||
return 0, errors.Wrap(err, "requesting user list")
|
||||
}
|
||||
|
||||
return respData.Total, nil
|
||||
}
|
||||
|
||||
func (t *twitchServiceHandler) doTwitchRequest(method, url string, body io.Reader, out interface{}) error {
|
||||
at, err := t.getAccessToken()
|
||||
if err != nil {
|
||||
|
|
Loading…
Reference in a new issue