From 3f6103d4735a4d68cd6bc92aed29e02848625dac Mon Sep 17 00:00:00 2001 From: Knut Ahlers Date: Thu, 7 Sep 2023 18:08:28 +0200 Subject: [PATCH] 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 --- service_twitch.go | 38 -------------------------------------- 1 file changed, 38 deletions(-) diff --git a/service_twitch.go b/service_twitch.go index 0ea2f46..697cede 100644 --- a/service_twitch.go +++ b/service_twitch.go @@ -31,11 +31,6 @@ type twitchServiceHandler struct { func (t twitchServiceHandler) GetDocumentation() serviceHandlerDocumentationList { return serviceHandlerDocumentationList{ - { - ServiceName: "Twitch followers", - DemoPath: "/twitch/followers/luziferus", - Arguments: []string{"followers", ""}, - }, { 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 {