From a4108ecc829c8958b636194a096a67eda9f8d769 Mon Sep 17 00:00:00 2001 From: Chris Sexton <3216719+chrissexton@users.noreply.github.com> Date: Wed, 18 May 2022 10:43:07 -0400 Subject: [PATCH] twitch: change some names to match the API --- plugins/twitch/twitch.go | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/plugins/twitch/twitch.go b/plugins/twitch/twitch.go index db03892..3f42ab3 100644 --- a/plugins/twitch/twitch.go +++ b/plugins/twitch/twitch.go @@ -156,7 +156,7 @@ func (p *TwitchPlugin) help(c bot.Connector, kind bot.Kind, message msg.Message, func (p *TwitchPlugin) twitchLoop(c bot.Connector, channel string) { frequency := p.config.GetInt("Twitch.Freq", 60) - if p.config.Get("twitch.clientid", "") == "" || p.config.Get("twitch.authorization", "") == "" { + if p.config.Get("twitch.clientid", "") == "" || p.config.Get("twitch.token", "") == "" { log.Info().Msgf("Disabling twitch autochecking.") return } @@ -172,7 +172,8 @@ func (p *TwitchPlugin) twitchLoop(c bot.Connector, channel string) { } } -func getRequest(url, clientID, authorization string) ([]byte, bool) { +func getRequest(url, clientID, token string) ([]byte, bool) { + bearer := fmt.Sprintf("Bearer %s", token) var body []byte var resp *http.Response client := &http.Client{} @@ -182,7 +183,7 @@ func getRequest(url, clientID, authorization string) ([]byte, bool) { } req.Header.Add("Client-ID", clientID) - req.Header.Add("Authorization", authorization) + req.Header.Add("Authorization", bearer) resp, err = client.Do(req) if err != nil { @@ -212,14 +213,14 @@ func (p *TwitchPlugin) checkTwitch(c bot.Connector, channel string, twitcher *Tw baseURL.RawQuery = query.Encode() - cid := p.config.Get("Twitch.ClientID", "") - auth := p.config.Get("Twitch.Authorization", "") - if cid == auth && cid == "" { + cid := p.config.Get("twitch.clientid", "") + token := p.config.Get("twitch.token", "") + if cid == token && cid == "" { log.Info().Msgf("Twitch plugin not enabled.") return } - body, ok := getRequest(baseURL.String(), cid, auth) + body, ok := getRequest(baseURL.String(), cid, token) if !ok { return }