Make prefixes case-insensitive

This commit is contained in:
ShadowNinja 2013-12-22 15:41:22 -05:00
parent d81f80155f
commit aa299b7a10
1 changed files with 5 additions and 4 deletions

View File

@ -3,15 +3,16 @@ mt_irc.bot_commands = {}
function mt_irc:check_botcmd(user, target, message) function mt_irc:check_botcmd(user, target, message)
local prefix = mt_irc.config.command_prefix local prefix = mt_irc.config.command_prefix
local nick = mt_irc.conn.nick local nick = mt_irc.conn.nick:lower()
local nickpart = message:sub(1, #nick + 2):lower()
-- First check for a nick prefix -- First check for a nick prefix
if message:sub(1, #nick + 2) == nick..": " or if nickpart == nick..": " or
message:sub(1, #nick + 2) == nick..", " then nickpart == nick..", " then
self:bot_command(user, message:sub(#nick + 3)) self:bot_command(user, message:sub(#nick + 3))
return true return true
-- Then check for the configured prefix -- Then check for the configured prefix
elseif prefix and message:sub(1, #prefix) == prefix then elseif prefix and message:sub(1, #prefix):lower() == prefix:lower() then
self:bot_command(user, message:sub(#prefix + 1)) self:bot_command(user, message:sub(#prefix + 1))
return true return true
end end