From d5fa102a8ebcd2f0df4bed35be0f97e259807bad Mon Sep 17 00:00:00 2001 From: Ash Keel Date: Tue, 5 Oct 2021 13:06:56 +0200 Subject: [PATCH] Make chat commands case insensitive --- modules/twitch/bot.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/modules/twitch/bot.go b/modules/twitch/bot.go index 45ec502..e72c717 100644 --- a/modules/twitch/bot.go +++ b/modules/twitch/bot.go @@ -66,6 +66,8 @@ func NewBot(api *Client, config BotConfig) *Bot { bot.mu.Lock() bot.activeUsers[message.User.Name] = true + lcmessage := strings.ToLower(message.Message) + // Check if it's a command if strings.HasPrefix(message.Message, "!") { // Run through supported commands @@ -73,7 +75,7 @@ func NewBot(api *Client, config BotConfig) *Bot { if !data.Enabled { continue } - if strings.HasPrefix(message.Message, cmd) { + if strings.HasPrefix(lcmessage, cmd) { go data.Handler(bot, message) bot.lastMessage = time.Now() } @@ -85,7 +87,8 @@ func NewBot(api *Client, config BotConfig) *Bot { if !data.Enabled { continue } - if strings.HasPrefix(message.Message, cmd) { + lc := strings.ToLower(cmd) + if strings.HasPrefix(lcmessage, lc) { go cmdCustom(bot, cmd, data, message) bot.lastMessage = time.Now() }