mirror of
https://github.com/minetest-mods/irc.git
synced 2024-12-28 17:50:18 +01:00
Make prefixes case-insensitive
This commit is contained in:
parent
d81f80155f
commit
aa299b7a10
@ -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
|
||||||
|
Loading…
Reference in New Issue
Block a user