From bd4d2dbe2174446336725a3bb3c0c44a600fa73b Mon Sep 17 00:00:00 2001 From: lyx0 Date: Sun, 17 Oct 2021 10:23:36 +0200 Subject: [PATCH] add botstatus command --- pkg/commands/botstatus.go | 26 ++++++++++++++++++++++++++ pkg/handlers/command.go | 8 ++++++++ 2 files changed, 34 insertions(+) create mode 100644 pkg/commands/botstatus.go diff --git a/pkg/commands/botstatus.go b/pkg/commands/botstatus.go new file mode 100644 index 0000000..8a590d5 --- /dev/null +++ b/pkg/commands/botstatus.go @@ -0,0 +1,26 @@ +package commands + +import ( + "fmt" + "io/ioutil" + "net/http" + + "github.com/gempir/go-twitch-irc/v2" + log "github.com/sirupsen/logrus" +) + +func BotStatus(channel string, userName string, client *twitch.Client) { + resp, err := http.Get(fmt.Sprintf("https://customapi.aidenwallis.co.uk/api/v1/twitch/botStatus/%s?includeLimits=1", userName)) + 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, string(body)) +} diff --git a/pkg/handlers/command.go b/pkg/handlers/command.go index f43fbb1..a8b26d2 100644 --- a/pkg/handlers/command.go +++ b/pkg/handlers/command.go @@ -40,6 +40,14 @@ func HandleCommand(message twitch.PrivateMessage, twitchClient *twitch.Client, u twitchClient.Say(message.Channel, "Why yes, that's my prefix :)") return } + case "botstatus": + if msgLen == 1 { + twitchClient.Say(message.Channel, "Usage: ()botstatus [username]") + return + } else { + commands.BotStatus(message.Channel, cmdParams[1], twitchClient) + return + } case "bttvemotes": commands.BttvEmotes(message.Channel, twitchClient) return