From 4fbac65c1b9c0e7ce169c7424b87e07992dc6829 Mon Sep 17 00:00:00 2001 From: Ash Keel Date: Thu, 25 May 2023 20:36:35 +0200 Subject: [PATCH] fix: trim messages before checking for commands fixes #86 --- CHANGELOG.md | 1 + twitch/bot.go | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b4e5b46..06f41a0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Fixed some minor bugs regarding backup file sorting and migration procedures - Fixed bot cooldown being unreliable due to depending on multiple time sources +- Spaces at beginning of messages are now ignored for command checking (e.g. " !lurk" will match !lurk) ## [3.2.1] - 2023-05-17 diff --git a/twitch/bot.go b/twitch/bot.go index 9da8b42..915f376 100644 --- a/twitch/bot.go +++ b/twitch/bot.go @@ -147,10 +147,10 @@ func (b *Bot) onMessageHandler(message irc.PrivateMessage) { return } - lowercaseMessage := strings.ToLower(message.Message) + lowercaseMessage := strings.TrimSpace(strings.ToLower(message.Message)) // Check if it's a command - if strings.HasPrefix(message.Message, "!") { + if strings.HasPrefix(lowercaseMessage, "!") { // Run through supported commands for cmd, data := range b.commands.Copy() { if !data.Enabled {