From 3228176caf163c27455aa976a76e77447e7ee018 Mon Sep 17 00:00:00 2001 From: lyx0 Date: Thu, 14 Oct 2021 23:04:41 +0200 Subject: [PATCH] add godocs command --- pkg/commands/godocs.go | 13 +++++++++++++ pkg/handlers/command.go | 12 ++++++++++++ 2 files changed, 25 insertions(+) create mode 100644 pkg/commands/godocs.go diff --git a/pkg/commands/godocs.go b/pkg/commands/godocs.go new file mode 100644 index 0000000..65da7e2 --- /dev/null +++ b/pkg/commands/godocs.go @@ -0,0 +1,13 @@ +package commands + +import ( + "fmt" + + "github.com/gempir/go-twitch-irc/v2" +) + +func Godocs(channel string, searchTerm string, client *twitch.Client) { + resp := fmt.Sprintf("https://godocs.io/?q=%s", searchTerm) + + client.Say(channel, resp) +} diff --git a/pkg/handlers/command.go b/pkg/handlers/command.go index ce9bf37..83102f9 100644 --- a/pkg/handlers/command.go +++ b/pkg/handlers/command.go @@ -82,6 +82,18 @@ func HandleCommand(message twitch.PrivateMessage, twitchClient *twitch.Client, u commands.Uptime(message.Channel, cmdParams[1], twitchClient) return } + case "godoc": + if msgLen == 1 { + twitchClient.Say(message.Channel, "Usage: ()godoc [term]") + } else { + commands.Godocs(message.Channel, message.Message[8:len(message.Message)], twitchClient) + } + case "godocs": + if msgLen == 1 { + twitchClient.Say(message.Channel, "Usage: ()godoc [term]") + } else { + commands.Godocs(message.Channel, message.Message[9:len(message.Message)], twitchClient) + } } }