From 0762145c2fd780897e5d9028edf5a0875545f916 Mon Sep 17 00:00:00 2001 From: lyx0 Date: Tue, 19 Oct 2021 15:25:48 +0200 Subject: [PATCH] add title command --- pkg/commands/title.go | 19 +++++++++++++++++++ pkg/handlers/command.go | 8 ++++++++ 2 files changed, 27 insertions(+) create mode 100644 pkg/commands/title.go diff --git a/pkg/commands/title.go b/pkg/commands/title.go new file mode 100644 index 0000000..0a69bea --- /dev/null +++ b/pkg/commands/title.go @@ -0,0 +1,19 @@ +package commands + +import ( + "fmt" + + "github.com/gempir/go-twitch-irc/v2" + "github.com/lyx0/nourybot/pkg/api/aiden" + log "github.com/sirupsen/logrus" +) + +func Title(channel string, target string, client *twitch.Client) { + title, err := aiden.ApiCall(fmt.Sprintf("api/v1/twitch/channel/%s/title", target)) + if err != nil { + client.Say(channel, "Something went wrong FeelsBadMan") + log.Error(err) + } + reply := fmt.Sprintf("%s title is: %s", target, title) + client.Say(channel, reply) +} diff --git a/pkg/handlers/command.go b/pkg/handlers/command.go index e8d3f0e..9da2edf 100644 --- a/pkg/handlers/command.go +++ b/pkg/handlers/command.go @@ -220,6 +220,14 @@ func HandleCommand(message twitch.PrivateMessage, twitchClient *twitch.Client, u commands.Thumbnail(message.Channel, cmdParams[1], twitchClient) return } + case "title": + if msgLen == 1 { + commands.Title(message.Channel, message.Channel, twitchClient) + return + } else { + commands.Title(message.Channel, cmdParams[1], twitchClient) + return + } case "uptime": if msgLen == 1 { commands.Uptime(message.Channel, message.Channel, twitchClient)