mirror of
https://github.com/lyx0/nourybot.git
synced 2024-11-13 19:49:55 +01:00
add error responses
This commit is contained in:
parent
c22e4d73bd
commit
3432c112ac
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue