Software /
code /
prosody
Changeset
1502:0f895c06e03f
mod_console: Check for commands when not executing in the global environment
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Thu, 09 Jul 2009 04:34:55 +0100 |
parents | 1501:330b8437ac35 |
children | 1503:5970e06d9335 |
files | plugins/mod_console.lua |
diffstat | 1 files changed, 9 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/plugins/mod_console.lua Wed Jul 08 16:53:59 2009 +0100 +++ b/plugins/mod_console.lua Thu Jul 09 04:34:55 2009 +0100 @@ -65,7 +65,10 @@ (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 @@ 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 @@ 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);