# HG changeset patch # User Kim Alvefur # Date 1289252484 -3600 # Node ID 0f17e574b6bb35b2819edbd16a02414fab1592a5 # Parent 23e17e64ca2573cf52045b096d991892013d3809 plugins.commands: Enable commands to be directed to the bots nick diff -r 23e17e64ca25 -r 0f17e574b6bb plugins/commands.lua --- a/plugins/commands.lua Mon Nov 08 21:27:44 2010 +0100 +++ b/plugins/commands.lua Mon Nov 08 22:41:24 2010 +0100 @@ -1,6 +1,11 @@ function riddim.plugins.commands(bot) local command_pattern = "^%"..(bot.config.command_prefix or "@").."([%a%-%_%d]+)(%s?)(.*)$"; + local direct_address_pattern = false; + if bot.config.nick then + direct_address_pattern = "^"..bot.config.nick.."[,: ]+([%a%-%_%d]+)(%s?)(.*)"; + end + local function process_command(event) local body = event.body; if not body then return; end @@ -8,6 +13,10 @@ local command, hasparam, param = body:match(command_pattern); + if not command and direct_address_pattern then + command, hasparam, param = body:match(direct_address_pattern); + end + if not command then command, hasparam, param = body:match("%[([%a%-%_%d]+)(%s?)(.*)%]"); end