aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/mod_console.lua
diff options
context:
space:
mode:
authorWaqas Hussain <waqas20@gmail.com>2010-07-26 01:52:04 +0500
committerWaqas Hussain <waqas20@gmail.com>2010-07-26 01:52:04 +0500
commit84cb6ce694c9a908fcefd202c68b789b2f335df7 (patch)
treec0b6b18960d0b577800d25f4220038d2c2309558 /plugins/mod_console.lua
parentcc1b764839c0039c5dcbda94c0ed531490a92984 (diff)
downloadprosody-84cb6ce694c9a908fcefd202c68b789b2f335df7.tar.gz
prosody-84cb6ce694c9a908fcefd202c68b789b2f335df7.zip
mod_console: Override dofile() in the console environment (this lets print() print to the console session for example).
Diffstat (limited to 'plugins/mod_console.lua')
-rw-r--r--plugins/mod_console.lua8
1 files changed, 7 insertions, 1 deletions
diff --git a/plugins/mod_console.lua b/plugins/mod_console.lua
index 20d04afe..ab47c52f 100644
--- a/plugins/mod_console.lua
+++ b/plugins/mod_console.lua
@@ -27,7 +27,13 @@ local default_env_mt = { __index = def_env };
prosody.console = { commands = commands, env = def_env };
local function redirect_output(_G, session)
- return setmetatable({ print = session.print }, { __index = function (t, k) return rawget(_G, k); end, __newindex = function (t, k, v) rawset(_G, k, v); end });
+ local env = setmetatable({ print = session.print }, { __index = function (t, k) return rawget(_G, k); end, __newindex = function (t, k, v) rawset(_G, k, v); end });
+ env.dofile = function(name)
+ local f, err = loadfile(name);
+ if not f then return f, err; end
+ return setfenv(f, env)();
+ end;
+ return env;
end
console = {};