(function(session, data)
local useglobalenv;
- if data:match("[!.]$") then
+ if data:match("^>") then
+ data = data:gsub("^>", "");
+ useglobalenv = true;
+ else
local command = data:lower();
command = data:match("^%w+") or data:match("%p");
if commands[command] then
end
end
- if data:match("^>") then
- data = data:gsub("^>", "");
- useglobalenv = true;
- end
-
session.env._ = data;
local chunk, err = loadstring("return "..data);
local ranok, taskok, message = pcall(chunk);
+ if not (ranok or message or useglobalenv) and commands[data:lower()] then
+ commands[data:lower()](session, data);
+ return;
+ end
+
if not ranok then
session.print("Fatal error while running command, it did not complete");
session.print("Error: "..taskok);