From 13252d3b0d04bfd51b8db18c047865e207a0d94d Mon Sep 17 00:00:00 2001 From: lyx0 Date: Fri, 15 Oct 2021 18:00:37 +0200 Subject: [PATCH] add fill command --- pkg/commands/fill.go | 25 +++++++++++++++++++++++++ pkg/handlers/command.go | 8 ++++++++ 2 files changed, 33 insertions(+) create mode 100644 pkg/commands/fill.go diff --git a/pkg/commands/fill.go b/pkg/commands/fill.go new file mode 100644 index 0000000..c5f6379 --- /dev/null +++ b/pkg/commands/fill.go @@ -0,0 +1,25 @@ +package commands + +import ( + "fmt" + "strings" + + "github.com/gempir/go-twitch-irc/v2" +) + +func Fill(channel string, emote string, client *twitch.Client) { + if emote[0] == '.' || emote[0] == '/' { + client.Say(channel, ":tf:") + return + } + + // Get the length of the emote + emoteLength := (len(emote) + 1) + + // Check how often the emote fits into a single message + repeatCount := (499 / emoteLength) + + reply := strings.Repeat(fmt.Sprintf(emote+" "), repeatCount) + client.Say(channel, reply) + +} diff --git a/pkg/handlers/command.go b/pkg/handlers/command.go index 8b94c4c..f1b66d3 100644 --- a/pkg/handlers/command.go +++ b/pkg/handlers/command.go @@ -100,5 +100,13 @@ func HandleCommand(message twitch.PrivateMessage, twitchClient *twitch.Client, u return } + case "fill": + if msgLen == 1 { + twitchClient.Say(message.Channel, "Usage: ()fill [emote]") + return + } else { + commands.Fill(message.Channel, message.Message[7:len(message.Message)], twitchClient) + } + } }