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:
parent
6db2a510aa
commit
d5fa102a8e
1 changed files with 5 additions and 2 deletions
|
@ -66,6 +66,8 @@ func NewBot(api *Client, config BotConfig) *Bot {
|
||||||
bot.mu.Lock()
|
bot.mu.Lock()
|
||||||
bot.activeUsers[message.User.Name] = true
|
bot.activeUsers[message.User.Name] = true
|
||||||
|
|
||||||
|
lcmessage := strings.ToLower(message.Message)
|
||||||
|
|
||||||
// Check if it's a command
|
// Check if it's a command
|
||||||
if strings.HasPrefix(message.Message, "!") {
|
if strings.HasPrefix(message.Message, "!") {
|
||||||
// Run through supported commands
|
// Run through supported commands
|
||||||
|
@ -73,7 +75,7 @@ func NewBot(api *Client, config BotConfig) *Bot {
|
||||||
if !data.Enabled {
|
if !data.Enabled {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if strings.HasPrefix(message.Message, cmd) {
|
if strings.HasPrefix(lcmessage, cmd) {
|
||||||
go data.Handler(bot, message)
|
go data.Handler(bot, message)
|
||||||
bot.lastMessage = time.Now()
|
bot.lastMessage = time.Now()
|
||||||
}
|
}
|
||||||
|
@ -85,7 +87,8 @@ func NewBot(api *Client, config BotConfig) *Bot {
|
||||||
if !data.Enabled {
|
if !data.Enabled {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if strings.HasPrefix(message.Message, cmd) {
|
lc := strings.ToLower(cmd)
|
||||||
|
if strings.HasPrefix(lcmessage, lc) {
|
||||||
go cmdCustom(bot, cmd, data, message)
|
go cmdCustom(bot, cmd, data, message)
|
||||||
bot.lastMessage = time.Now()
|
bot.lastMessage = time.Now()
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue