diff --git a/pkg/commands/game.go b/pkg/commands/game.go index f3f14b9..797e11c 100644 --- a/pkg/commands/game.go +++ b/pkg/commands/game.go @@ -5,11 +5,16 @@ import ( "github.com/gempir/go-twitch-irc/v2" "github.com/lyx0/nourybot/pkg/api/aiden" + log "github.com/sirupsen/logrus" ) func Game(channel string, name string, client *twitch.Client) { - game := aiden.ApiCall(fmt.Sprintf("api/v1/twitch/channel/%s/game", name)) + game, err := aiden.ApiCall(fmt.Sprintf("api/v1/twitch/channel/%s/game", name)) + if err != nil { + client.Say(channel, "Something went wrong FeelsBadMan") + log.Error(err) + } reply := fmt.Sprintf("@%s was last seen playing: %s", name, game) client.Say(channel, reply) } diff --git a/pkg/commands/uptime.go b/pkg/commands/uptime.go index eb9b577..12bcbbf 100644 --- a/pkg/commands/uptime.go +++ b/pkg/commands/uptime.go @@ -2,29 +2,20 @@ package commands import ( "fmt" - "io/ioutil" - "net/http" "github.com/gempir/go-twitch-irc/v2" + "github.com/lyx0/nourybot/pkg/api/aiden" log "github.com/sirupsen/logrus" ) -func Uptime(channel string, target string, client *twitch.Client) { - resp, err := http.Get(fmt.Sprintf("https://customapi.aidenwallis.co.uk/api/v1/twitch/channel/%s/uptime", target)) +func Uptime(channel string, name string, client *twitch.Client) { + resp, err := aiden.ApiCall(fmt.Sprintf("api/v1/twitch/channel/%s/uptime", name)) if err != nil { client.Say(channel, "Something went wrong FeelsBadMan") log.Error(err) } - defer resp.Body.Close() - - body, err := ioutil.ReadAll(resp.Body) - if err != nil { - client.Say(channel, "Something went wrong FeelsBadMan") - log.Error(err) - } - - client.Say(channel, string(body)) + client.Say(channel, resp) } diff --git a/pkg/commands/weather.go b/pkg/commands/weather.go index cf0ea7e..7dffced 100644 --- a/pkg/commands/weather.go +++ b/pkg/commands/weather.go @@ -5,11 +5,16 @@ import ( "github.com/gempir/go-twitch-irc/v2" "github.com/lyx0/nourybot/pkg/api/aiden" + log "github.com/sirupsen/logrus" ) func Weather(channel string, location string, client *twitch.Client) { - reply := aiden.ApiCall(fmt.Sprintf("api/v1/misc/weather/%s", location)) + reply, err := aiden.ApiCall(fmt.Sprintf("api/v1/misc/weather/%s", location)) + if err != nil { + client.Say(channel, "Something went wrong FeelsBadMan") + log.Error(err) + } client.Say(channel, reply) }