Comparison

plugins/mod_admin_telnet.lua @ 4646:e0bd8587f2fb

mod_admin_telnet: module:list(): List global modules (part-fixes #228)
author Matthew Wild <mwild1@gmail.com>
date Sat, 21 Apr 2012 20:39:52 +0100
parent 4645:4539e99be743
child 4647:57a4f863e48f
comparison
equal deleted inserted replaced
4645:4539e99be743 4646:e0bd8587f2fb
361 end 361 end
362 362
363 function def_env.module:list(hosts) 363 function def_env.module:list(hosts)
364 if hosts == nil then 364 if hosts == nil then
365 hosts = array.collect(keys(prosody.hosts)); 365 hosts = array.collect(keys(prosody.hosts));
366 table.insert(hosts, 1, "*");
366 end 367 end
367 if type(hosts) == "string" then 368 if type(hosts) == "string" then
368 hosts = { hosts }; 369 hosts = { hosts };
369 end 370 end
370 if type(hosts) ~= "table" then 371 if type(hosts) ~= "table" then
371 return false, "Please supply a host or a list of hosts you would like to see"; 372 return false, "Please supply a host or a list of hosts you would like to see";
372 end 373 end
373 374
374 local print = self.session.print; 375 local print = self.session.print;
375 for _, host in ipairs(hosts) do 376 for _, host in ipairs(hosts) do
376 print(host..":"); 377 print((host == "*" and "Global" or host)..":");
377 local modules = array.collect(keys(prosody.hosts[host] and prosody.hosts[host].modules or {})):sort(); 378 local modules = array.collect(keys(modulemanager.get_modules(host) or {})):sort();
378 if #modules == 0 then 379 if #modules == 0 then
379 if prosody.hosts[host] then 380 if prosody.hosts[host] then
380 print(" No modules loaded"); 381 print(" No modules loaded");
381 else 382 else
382 print(" Host not found"); 383 print(" Host not found");