From 11f084978dc9d936688ed2ad0dc3e578e6e75083 Mon Sep 17 00:00:00 2001 From: lyx0 <66651385+lyx0@users.noreply.github.com> Date: Tue, 10 Oct 2023 14:28:43 +0200 Subject: [PATCH] add commands --- cmd/nourybot/commands.go | 33 +++++++++++++++++++++++++++++++++ internal/commands/duckduckgo.go | 13 +++++++++++++ internal/commands/ffz.go | 9 +++++++++ internal/commands/godocs.go | 13 +++++++++++++ internal/commands/google.go | 13 +++++++++++++ internal/commands/osrs.go | 13 +++++++++++++ internal/commands/preview.go | 14 ++++++++++++++ internal/commands/seventv.go | 9 +++++++++ internal/commands/youtube.go | 13 +++++++++++++ 9 files changed, 130 insertions(+) create mode 100644 internal/commands/duckduckgo.go create mode 100644 internal/commands/ffz.go create mode 100644 internal/commands/godocs.go create mode 100644 internal/commands/google.go create mode 100644 internal/commands/osrs.go create mode 100644 internal/commands/preview.go create mode 100644 internal/commands/seventv.go create mode 100644 internal/commands/youtube.go diff --git a/cmd/nourybot/commands.go b/cmd/nourybot/commands.go index 7a5f290..d9aae67 100644 --- a/cmd/nourybot/commands.go +++ b/cmd/nourybot/commands.go @@ -97,6 +97,39 @@ func (app *application) handleCommand(message twitch.PrivateMessage) { case "gofile": go app.NewDownload("gofile", target, cmdParams[1], message) + case "osrs": + reply = commands.OSRS(message.Message[7:len(message.Message)]) + + case "preview": + reply = commands.Preview(cmdParams[1]) + + case "thumbnail": + reply = commands.Preview(cmdParams[1]) + + case "ffz": + reply = commands.Ffz(cmdParams[1]) + + case "ddg": + reply = commands.DuckDuckGo(message.Message[6:len(message.Message)]) + + case "youtube": + reply = commands.Youtube(message.Message[10:len(message.Message)]) + + case "godocs": + reply = commands.Godocs(message.Message[9:len(message.Message)]) + + case "google": + reply = commands.Google(message.Message[9:len(message.Message)]) + + case "duckduckgo": + reply = commands.DuckDuckGo(message.Message[13:len(message.Message)]) + + case "seventv": + reply = commands.SevenTV(cmdParams[1]) + + case "7tv": + reply = commands.SevenTV(cmdParams[1]) + case "mail": app.SendEmail("Test command used!", "This is an email test") diff --git a/internal/commands/duckduckgo.go b/internal/commands/duckduckgo.go new file mode 100644 index 0000000..3ab8d00 --- /dev/null +++ b/internal/commands/duckduckgo.go @@ -0,0 +1,13 @@ +package commands + +import ( + "fmt" + "net/url" +) + +func DuckDuckGo(query string) string { + query = url.QueryEscape(query) + reply := fmt.Sprintf("https://duckduckgo.com/?va=n&hps=1&q=%s", query) + + return reply +} diff --git a/internal/commands/ffz.go b/internal/commands/ffz.go new file mode 100644 index 0000000..2ad11ee --- /dev/null +++ b/internal/commands/ffz.go @@ -0,0 +1,9 @@ +package commands + +import "fmt" + +func Ffz(query string) string { + reply := fmt.Sprintf("https://www.frankerfacez.com/emoticons/?q=%s&sort=count-desc&days=0", query) + + return reply +} diff --git a/internal/commands/godocs.go b/internal/commands/godocs.go new file mode 100644 index 0000000..6cc0b15 --- /dev/null +++ b/internal/commands/godocs.go @@ -0,0 +1,13 @@ +package commands + +import ( + "fmt" + "net/url" +) + +func Godocs(query string) string { + query = url.QueryEscape(query) + reply := fmt.Sprintf("https://godocs.io/?q=%s", query) + + return reply +} diff --git a/internal/commands/google.go b/internal/commands/google.go new file mode 100644 index 0000000..d08d77a --- /dev/null +++ b/internal/commands/google.go @@ -0,0 +1,13 @@ +package commands + +import ( + "fmt" + "net/url" +) + +func Google(query string) string { + query = url.QueryEscape(query) + reply := fmt.Sprintf("https://www.google.com/search?q=%s", query) + + return reply +} diff --git a/internal/commands/osrs.go b/internal/commands/osrs.go new file mode 100644 index 0000000..1587c76 --- /dev/null +++ b/internal/commands/osrs.go @@ -0,0 +1,13 @@ +package commands + +import ( + "fmt" + "net/url" +) + +func OSRS(query string) string { + query = url.QueryEscape(query) + reply := fmt.Sprintf("https://oldschool.runescape.wiki/?search=%s", query) + + return reply +} diff --git a/internal/commands/preview.go b/internal/commands/preview.go new file mode 100644 index 0000000..60d6b26 --- /dev/null +++ b/internal/commands/preview.go @@ -0,0 +1,14 @@ +package commands + +import ( + "fmt" + "github.com/lyx0/nourybot/internal/common" +) + +func Preview(channel string) string { + imageHeight := common.GenerateRandomNumberRange(1040, 1080) + imageWidth := common.GenerateRandomNumberRange(1890, 1920) + + reply := fmt.Sprintf("https://static-cdn.jtvnw.net/previews-ttv/live_user_%v-%vx%v.jpg", channel, imageWidth, imageHeight) + return reply +} diff --git a/internal/commands/seventv.go b/internal/commands/seventv.go new file mode 100644 index 0000000..572e12a --- /dev/null +++ b/internal/commands/seventv.go @@ -0,0 +1,9 @@ +package commands + +import "fmt" + +func SevenTV(query string) string { + reply := fmt.Sprintf("https://7tv.app/emotes?page=1&query=%s", query) + + return reply +} diff --git a/internal/commands/youtube.go b/internal/commands/youtube.go new file mode 100644 index 0000000..ea0a9ee --- /dev/null +++ b/internal/commands/youtube.go @@ -0,0 +1,13 @@ +package commands + +import ( + "fmt" + "net/url" +) + +func Youtube(query string) string { + query = url.QueryEscape(query) + reply := fmt.Sprintf("https://www.youtube.com/results?search_query=%s", query) + + return reply +}