From c0634115c1ed4e78fcfe78c2c6e7db4f3a6ba466 Mon Sep 17 00:00:00 2001 From: lyx0 Date: Sat, 16 Oct 2021 18:06:34 +0200 Subject: [PATCH] add bttvemotes command --- pkg/api/ivr.go | 0 pkg/commands/bttvemotes.go | 26 ++++++++++++++++++++++++++ pkg/handlers/command.go | 3 +++ 3 files changed, 29 insertions(+) create mode 100644 pkg/api/ivr.go create mode 100644 pkg/commands/bttvemotes.go diff --git a/pkg/api/ivr.go b/pkg/api/ivr.go new file mode 100644 index 0000000..e69de29 diff --git a/pkg/commands/bttvemotes.go b/pkg/commands/bttvemotes.go new file mode 100644 index 0000000..d8f44ac --- /dev/null +++ b/pkg/commands/bttvemotes.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 BttvEmotes(channel string, client *twitch.Client) { + resp, err := http.Get(fmt.Sprintf("https://customapi.aidenwallis.co.uk/api/v1/emotes/%s/bttv", channel)) + 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 d90a005..6eaf9c0 100644 --- a/pkg/handlers/command.go +++ b/pkg/handlers/command.go @@ -38,7 +38,10 @@ func HandleCommand(message twitch.PrivateMessage, twitchClient *twitch.Client, u case "": if msgLen == 1 { twitchClient.Say(message.Channel, "Why yes, that's my prefix :)") + return } + case "bttvemotes": + commands.BttvEmotes(message.Channel, twitchClient) return case "cf": commands.Coinflip(message.Channel, twitchClient)