mcbot/mcbot_engine.lua
changeset 27 a166e9ab8065
parent 26 c12be727375b
child 31 71bf91612a33
--- a/mcbot/mcbot_engine.lua	Sat Apr 17 15:33:23 2010 +0200
+++ b/mcbot/mcbot_engine.lua	Sat Apr 17 15:44:09 2010 +0200
@@ -9,7 +9,7 @@
   return s:gsub("%s+$", "")
 end
 
-function string.starts(String,Start)
+function string.starts(String, Start)
    return string.sub(String, 1, string.len(Start)) == Start
 end
 
@@ -32,11 +32,18 @@
 require "cmds.bofh"
 require "cmds.xmpp"
 
-function process (line, botdata, muc)
+function process (line, botdata, muc, cmdprefix)
     local n
     line = trim(line)
     line, n = line:gsub("^"..botdata.nickname.."[,:]?%s+", "")
-    if muc and n ~= 1 then return nil, nil end
+    if muc and n ~= 1 then
+        if cmdprefix and line:starts(cmdprefix) then
+            line = line:sub(string.len(cmdprefix)+1)
+            line = line:gsub("^%s*", "")
+        else
+            return nil, nil
+        end
+    end
 
     local cmd, arg
     cmd = line:match("^(%w+)%s*[!]*$")