Comparison

plugins/mod_admin_telnet.lua @ 4807:2999f0fd1347

mod_admin_telnet: Add muc:room(jid) command to get the MUC room object
author Matthew Wild <mwild1@gmail.com>
date Wed, 02 May 2012 18:21:47 +0100
parent 4779:9f2639b3d9b1
child 4912:8d0643281fe2
comparison
equal deleted inserted replaced
4806:27a99c289b90 4807:2999f0fd1347
15 15
16 local console_listener = { default_port = 5582; default_mode = "*l"; interface = "127.0.0.1" }; 16 local console_listener = { default_port = 5582; default_mode = "*l"; interface = "127.0.0.1" };
17 17
18 local iterators = require "util.iterators"; 18 local iterators = require "util.iterators";
19 local keys, values = iterators.keys, iterators.values; 19 local keys, values = iterators.keys, iterators.values;
20 local jid_bare = require "util.jid".bare; 20 local jid = require "util.jid";
21 local jid_bare, jid_split = jid.bare, jid.split;
21 local set, array = require "util.set", require "util.array"; 22 local set, array = require "util.set", require "util.array";
22 local cert_verify_identity = require "util.x509".verify_identity; 23 local cert_verify_identity = require "util.x509".verify_identity;
23 24
24 local commands = module:shared("commands") 25 local commands = module:shared("commands")
25 local def_env = module:shared("env"); 26 local def_env = module:shared("env");
830 end 831 end
831 end 832 end
832 return true, "Closed "..n_closed.." ports"; 833 return true, "Closed "..n_closed.." ports";
833 end 834 end
834 835
836 def_env.muc = {};
837
838 local console_room_mt = {
839 __index = function (self, k) return self.room[k]; end;
840 __tostring = function (self)
841 return "MUC room <"..self.room.jid..">";
842 end;
843 };
844
845 function def_env.muc:room(room_jid)
846 local room_name, host = jid_split(room_jid);
847 if not hosts[host] then
848 return nil, "No such host: "..host;
849 elseif not hosts[host].modules.muc then
850 return nil, "Host '"..host.."' is not a MUC service";
851 end
852 local room_obj = hosts[host].modules.muc.rooms[room_jid];
853 if not room_obj then
854 return nil, "No such room: "..room_jid;
855 end
856 return setmetatable({ room = room_obj }, console_room_mt);
857 end
858
835 ------------- 859 -------------
836 860
837 function printbanner(session) 861 function printbanner(session)
838 local option = config.get("*", "core", "console_banner"); 862 local option = config.get("*", "core", "console_banner");
839 if option == nil or option == "full" or option == "graphic" then 863 if option == nil or option == "full" or option == "graphic" then