From 3a827bbd6ff6faa4d73002a7571324a0d8b36b0a Mon Sep 17 00:00:00 2001 From: lyx0 Date: Sun, 17 Oct 2021 17:41:10 +0200 Subject: [PATCH] change game and weather command to new api call --- pkg/commands/game.go | 19 ++++--------------- pkg/commands/weather.go | 2 +- 2 files changed, 5 insertions(+), 16 deletions(-) diff --git a/pkg/commands/game.go b/pkg/commands/game.go index dc232b9..f3f14b9 100644 --- a/pkg/commands/game.go +++ b/pkg/commands/game.go @@ -2,25 +2,14 @@ package commands import ( "fmt" - "io/ioutil" - "net/http" "github.com/gempir/go-twitch-irc/v2" - log "github.com/sirupsen/logrus" + "github.com/lyx0/nourybot/pkg/api/aiden" ) func Game(channel string, name string, client *twitch.Client) { - resp, err := http.Get(fmt.Sprintf("https://customapi.aidenwallis.co.uk/api/v1/twitch/channel/%s/game", name)) - if err != nil { - log.Fatalln(err) - } - defer resp.Body.Close() - - body, err := ioutil.ReadAll(resp.Body) - if err != nil { - log.Fatalln(err) - } - - client.Say(channel, fmt.Sprintf("%s is playing: %s", name, string(body))) + game := aiden.ApiCall(fmt.Sprintf("api/v1/twitch/channel/%s/game", name)) + reply := fmt.Sprintf("@%s was last seen playing: %s", name, game) + client.Say(channel, reply) } diff --git a/pkg/commands/weather.go b/pkg/commands/weather.go index 7ee9405..cf0ea7e 100644 --- a/pkg/commands/weather.go +++ b/pkg/commands/weather.go @@ -9,7 +9,7 @@ import ( func Weather(channel string, location string, client *twitch.Client) { - reply := aiden.Weather(fmt.Sprintf("api/v1/misc/weather/%s", location)) + reply := aiden.ApiCall(fmt.Sprintf("api/v1/misc/weather/%s", location)) client.Say(channel, reply) }