change game and weather command to new api call

This commit is contained in:
lyx0 2021-10-17 17:41:10 +02:00
parent f5aca689c0
commit 3a827bbd6f
2 changed files with 5 additions and 16 deletions

View file

@ -2,25 +2,14 @@ package commands
import ( import (
"fmt" "fmt"
"io/ioutil"
"net/http"
"github.com/gempir/go-twitch-irc/v2" "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) { 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() game := aiden.ApiCall(fmt.Sprintf("api/v1/twitch/channel/%s/game", name))
reply := fmt.Sprintf("@%s was last seen playing: %s", name, game)
body, err := ioutil.ReadAll(resp.Body) client.Say(channel, reply)
if err != nil {
log.Fatalln(err)
}
client.Say(channel, fmt.Sprintf("%s is playing: %s", name, string(body)))
} }

View file

@ -9,7 +9,7 @@ import (
func Weather(channel string, location string, client *twitch.Client) { 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) client.Say(channel, reply)
} }