diff --git a/pkg/commands/eightball.go b/pkg/commands/eightball.go new file mode 100644 index 0000000..d3ff2e2 --- /dev/null +++ b/pkg/commands/eightball.go @@ -0,0 +1,28 @@ +package commands + +import ( + "io/ioutil" + "net/http" + + "github.com/gempir/go-twitch-irc/v2" + log "github.com/sirupsen/logrus" +) + +func EightBall(message twitch.PrivateMessage, client *twitch.Client) { + resp, err := http.Get("https://customapi.aidenwallis.co.uk/api/v1/misc/8ball") + if err != nil { + client.Say(message.Channel, "Something went wrong FeelsBadMan") + log.Error(err) + } + + defer resp.Body.Close() + + body, err := ioutil.ReadAll(resp.Body) + if err != nil { + client.Say(message.Channel, "Something went wrong FeelsBadMan") + log.Error(err) + } + + client.Say(message.Channel, string(body)) + +} diff --git a/pkg/handlers/command.go b/pkg/handlers/command.go index e1c2771..d1d13b0 100644 --- a/pkg/handlers/command.go +++ b/pkg/handlers/command.go @@ -64,6 +64,9 @@ func HandleCommand(message twitch.PrivateMessage, twitchClient *twitch.Client, u case "mycolor": commands.Color(message, twitchClient) return + case "8ball": + commands.EightBall(message, twitchClient) + return } }