diff options
author | Matthew Wild <mwild1@gmail.com> | 2009-07-09 04:34:55 +0100 |
---|---|---|
committer | Matthew Wild <mwild1@gmail.com> | 2009-07-09 04:34:55 +0100 |
commit | 46b622576dd029af33faa1d66130056b4fa8362c (patch) | |
tree | d501d8762a42de5ee53714986586931b139aa6b2 /plugins/mod_console.lua | |
parent | 453b76ef8c1a84e893bf88887672587a4c4048b8 (diff) | |
download | prosody-46b622576dd029af33faa1d66130056b4fa8362c.tar.gz prosody-46b622576dd029af33faa1d66130056b4fa8362c.zip |
mod_console: Check for commands when not executing in the global environment
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); |