Software /
code /
prosody-modules
Comparison
mod_adhoc_cmd_modules/mod_adhoc_cmd_modules.lua @ 203:4927b9737bb7
mod_adhoc_cmd_modules: Initial version. Provides a "List loaded modules" cmd for now
author | Florian Zeitz <florob@babelmonkeys.de> |
---|---|
date | Fri, 09 Jul 2010 01:36:32 +0200 |
child | 205:a6361a1fda5e |
comparison
equal
deleted
inserted
replaced
202:d11478ae374e | 203:4927b9737bb7 |
---|---|
1 -- Copyright (C) 2009-2010 Florian Zeitz | |
2 -- | |
3 -- This file is MIT/X11 licensed. Please see the | |
4 -- COPYING file in the source package for more information. | |
5 -- | |
6 | |
7 local _G = _G; | |
8 | |
9 local prosody = _G.prosody; | |
10 local hosts = prosody.hosts; | |
11 | |
12 require "util.iterators"; | |
13 local dataforms_new = require "util.dataforms".new; | |
14 local array = require "util.array"; | |
15 local adhoc_new = module:require "adhoc".new; | |
16 | |
17 function list_modules_handler(self, data, state) | |
18 local list_modules_result = dataforms_new { | |
19 title = "List of loaded modules"; | |
20 | |
21 { name = "FORM_TYPE", type = "hidden", value = "http://prosody.im/protocol/modules#list" }; | |
22 { name = "modules", type = "text-multi", label = "The following modules are loaded:" }; | |
23 }; | |
24 | |
25 local modules = array.collect(keys(hosts[data.to].modules)):sort() | |
26 local modules_str = nil; | |
27 for _, name in ipairs(modules) do | |
28 modules_str = ((modules_str and modules_str .. "\n") or "") .. name; | |
29 end | |
30 | |
31 return { status = "completed", result = { layout = list_modules_result; data = { modules = modules_str } } }; | |
32 end | |
33 | |
34 local list_modules_desc = adhoc_new("List loaded modules", "http://prosody.im/protocol/modules#list", list_modules_handler, "admin"); | |
35 | |
36 module:add_item("adhoc", list_modules_desc); |