function handleMUCMessage(msg) print(tostring(getmetatable(msg.room).__index), tostring(mt), tostring(mt.roomhandle), tostring(mt.roomhandle.send)); local command, param = msg.body:match("^!([%a%-%_]+)%s?(.*)$"); if msg.ishistory then return; end if not rooms[msg.room] then print("Huh? Not in this room..."); end if command and type(commands[command]) == "function" then local ret = commands[command](msg, param); if type(ret) == "string" then if #ret < 512 then msg.room:send(ret); -- SendMUCMessage(msg.room, ret); else msg.room:send("[Too long]"); end end elseif command and type(sandbox[command]) == "function" then local is_admin = IsFromBotAdmin(msg); local success, result = eval(string.format("sandbox[%q](%q);",command, param) , { allow_functions = false, data = { room = is_admin and setmetatable({}, { __index = rooms[msg.room], __newindex = function () error("Sorry, the room info is read-only"); end}) } }); msg.room:send(result); elseif command and type(sandbox[command]) ~= "table" and type(sandbox[command]) ~= "function" and type(sandbox[command]) ~= "userdata" then msg.room:send(tostring(sandbox[command])); elseif msg.nick ~= rooms[msg.room].mynick then local ret = MatchPattern(msg); if ret then SendMUCMessage(msg.room, ret); end end end