1
0
Fork 0
mirror of https://git.sr.ht/~ashkeel/strimertul synced 2024-09-18 01:50:50 +00:00

Make chat commands case insensitive

This commit is contained in:
Ash Keel 2021-10-05 13:06:56 +02:00
parent 6db2a510aa
commit d5fa102a8e
No known key found for this signature in database
GPG key ID: BAD8D93E7314ED3E

View file

@ -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()
}