add godocs command

This commit is contained in:
lyx0 2021-10-14 23:04:41 +02:00
parent 737a9f6259
commit 3228176caf
2 changed files with 25 additions and 0 deletions

13
pkg/commands/godocs.go Normal file
View file

@ -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)
}

View file

@ -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)
}
}
}