diff options
Diffstat (limited to 'plugins/mod_console.lua')
-rw-r--r-- | plugins/mod_console.lua | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/plugins/mod_console.lua b/plugins/mod_console.lua index 0d6b5e41..556f0c5d 100644 --- a/plugins/mod_console.lua +++ b/plugins/mod_console.lua @@ -65,7 +65,10 @@ function console_listener.listener(conn, data) (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 @@ -74,11 +77,6 @@ function console_listener.listener(conn, data) end end - if data:match("^>") then - data = data:gsub("^>", ""); - useglobalenv = true; - end - session.env._ = data; local chunk, err = loadstring("return "..data); @@ -97,6 +95,11 @@ function console_listener.listener(conn, 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); |