From 19064ac2caa76ee681fadfc695bc4ea38c1759a8 Mon Sep 17 00:00:00 2001 From: Ash Keel Date: Wed, 1 Dec 2021 23:32:51 +0100 Subject: [PATCH] Fix twitch bot custom command checking --- CHANGELOG.md | 7 +++++++ modules/twitch/bot.go | 11 ++++++++--- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2acb330..89eb6ff 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [CURRENT] + +### Fixed + +- Twitch bot: fixed command checking, previous matching only checked for prefix (eg. !verylong could be called by writing !verylonglongbaaah) + ## [1.6.3] - 2021-11-30 ### Added @@ -55,6 +61,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Stulbe integration for alerts +[CURRENT]: https://github.com/strimertul/strimertul/compare/v1.6.3...HEAD [1.6.3]: https://github.com/strimertul/strimertul/compare/v1.6.2...v1.6.3 [1.6.2]: https://github.com/strimertul/strimertul/compare/v1.6.1...v1.6.2 [1.6.1]: https://github.com/strimertul/strimertul/compare/v1.6.0...v1.6.1 diff --git a/modules/twitch/bot.go b/modules/twitch/bot.go index 3c59db8..a80694f 100644 --- a/modules/twitch/bot.go +++ b/modules/twitch/bot.go @@ -90,10 +90,15 @@ func NewBot(api *Client, config BotConfig) *Bot { continue } lc := strings.ToLower(cmd) - if strings.HasPrefix(lcmessage, lc) { - go cmdCustom(bot, cmd, data, message) - bot.lastMessage = time.Now() + if !strings.HasPrefix(lcmessage, lc) { + continue } + parts := strings.SplitN(lcmessage, " ", 2) + if parts[0] != lc { + continue + } + go cmdCustom(bot, cmd, data, message) + bot.lastMessage = time.Now() } bot.mu.Unlock()