From 30d1d9729c349fbbf9c1bf93afd0ad4aca32e233 Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Wed, 2 May 2012 18:21:47 +0100 Subject: mod_admin_telnet: Add muc:room(jid) command to get the MUC room object --- plugins/mod_admin_telnet.lua | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) (limited to 'plugins/mod_admin_telnet.lua') 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) -- cgit v1.2.3