function retvals(...) local n = select('#', ...) local t = {} if select(1, ...) == false then return false, select(2, ...) end for i=2, n do t[#t+1] = tostring(select(i, ...)) end return true, table.concat(t, ', ')endcommands = { lua = function(t) local sender = t[1] local target = t[3] local nick, user, host = parsesender(sender) local mesg = getmsg(table.concat(t, ' ')) assert(mesg) local msgt = mesg:split' ' assert(msgt) -- priviligied command if not isadmin(sender) then return end local code = table.concat(range(msgt, 2), ' ') assert(code) if code:sub(1, 1) == '=' then code = 'return '..code:sub(2) end local f, err = loadstring(code) if err then notice(nick, 'Lua Error: %s', err) return end local start = os.clock() local status, r = retvals(pcall(f)) local ticks = os.clock()-start r = r or '<n/a>' if not status then notice(nick, 'Lua Error: %s', r) else msg(target, 'result: %s (ticks: %s)', r, tostring(ticks)) end end,