mod_admin_telnet: Add command to list MUC rooms
authorMatthew Wild <mwild1@gmail.com>
Wed, 28 May 2014 11:43:34 +0000 (12:43 +0100)
committerMatthew Wild <mwild1@gmail.com>
Wed, 28 May 2014 11:43:34 +0000 (12:43 +0100)
plugins/mod_admin_telnet.lua

index 9761d2f322ff474831251f06f4b80b07b8459404..66560d448bdbaadc252350ce4f166742b592283d 100644 (file)
@@ -964,6 +964,19 @@ function def_env.muc:room(room_jid)
        return setmetatable({ room = room_obj }, console_room_mt);
 end
 
+function def_env.muc:list(host)
+       local host_session = hosts[host];
+       if not host_session or not host_session.modules.muc then
+               return nil, "Please supply the address of a local MUC component";
+       end
+       local c = 0;
+       for name in keys(host_session.modules.muc.rooms) do
+               print(name);
+               c = c + 1;
+       end
+       return true, c.." rooms";
+end
+
 local um = require"core.usermanager";
 
 def_env.user = {};