aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2012-05-02 18:21:47 +0100
committerMatthew Wild <mwild1@gmail.com>2012-05-02 18:21:47 +0100
commit3d3ad3119124106c778a86dace652b750997015d (patch)
treeb87eb36e7824b292201c0349d5a9c3a2819d1878
parenta8a1bb526ff592afc774de71b1781b21b17124b4 (diff)
downloadprosody-3d3ad3119124106c778a86dace652b750997015d.tar.gz
prosody-3d3ad3119124106c778a86dace652b750997015d.zip
mod_admin_telnet: Add muc:room(jid) command to get the MUC room object
-rw-r--r--plugins/mod_admin_telnet.lua26
1 files changed, 25 insertions, 1 deletions
diff --git a/plugins/mod_admin_telnet.lua b/plugins/mod_admin_telnet.lua
index 544ea161..f4fdb39e 100644
--- a/plugins/mod_admin_telnet.lua
+++ b/plugins/mod_admin_telnet.lua
@@ -17,7 +17,8 @@ local console_listener = { default_port = 5582; default_mode = "*l"; interface =
local iterators = require "util.iterators";
local keys, values = iterators.keys, iterators.values;
-local jid_bare = require "util.jid".bare;
+local jid = require "util.jid";
+local jid_bare, jid_split = jid.bare, jid.split;
local set, array = require "util.set", require "util.array";
local cert_verify_identity = require "util.x509".verify_identity;
@@ -832,6 +833,29 @@ function def_env.port:close(close_port, close_interface)
return true, "Closed "..n_closed.." ports";
end
+def_env.muc = {};
+
+local console_room_mt = {
+ __index = function (self, k) return self.room[k]; end;
+ __tostring = function (self)
+ return "MUC room <"..self.room.jid..">";
+ end;
+};
+
+function def_env.muc:room(room_jid)
+ local room_name, host = jid_split(room_jid);
+ if not hosts[host] then
+ return nil, "No such host: "..host;
+ elseif not hosts[host].modules.muc then
+ return nil, "Host '"..host.."' is not a MUC service";
+ end
+ local room_obj = hosts[host].modules.muc.rooms[room_jid];
+ if not room_obj then
+ return nil, "No such room: "..room_jid;
+ end
+ return setmetatable({ room = room_obj }, console_room_mt);
+end
+
-------------
function printbanner(session)