diff options
author | Matthew Wild <mwild1@gmail.com> | 2012-05-02 18:21:47 +0100 |
---|---|---|
committer | Matthew Wild <mwild1@gmail.com> | 2012-05-02 18:21:47 +0100 |
commit | 30d1d9729c349fbbf9c1bf93afd0ad4aca32e233 (patch) | |
tree | b87eb36e7824b292201c0349d5a9c3a2819d1878 | |
parent | 1e7a357152dea2035dc98107cdea05b9e680cdf8 (diff) | |
download | prosody-30d1d9729c349fbbf9c1bf93afd0ad4aca32e233.tar.gz prosody-30d1d9729c349fbbf9c1bf93afd0ad4aca32e233.zip |
mod_admin_telnet: Add muc:room(jid) command to get the MUC room object
-rw-r--r-- | plugins/mod_admin_telnet.lua | 26 |
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) |