Software /
code /
prosody-modules
Comparison
mod_adhoc_cmd_uptime/mod_adhoc_cmd_uptime.lua @ 121:a9898f13c89e
mod_adhoc: Major refactoring. Actuall data exchange happens here now
mod_adhoc_cmd_*: Update to work with aforementioned change
author | Florian Zeitz <florob@babelmonkeys.de> |
---|---|
date | Fri, 22 Jan 2010 04:25:58 +0100 |
parent | 109:9b63fd1196c0 |
child | 124:843cadf36306 |
comparison
equal
deleted
inserted
replaced
120:7a2d33e8ad1f | 121:a9898f13c89e |
---|---|
21 return string.format("This server has been running for %d day%s, %d hour%s and %d minute%s (since %s)", | 21 return string.format("This server has been running for %d day%s, %d hour%s and %d minute%s (since %s)", |
22 days, (days ~= 1 and "s") or "", hours, (hours ~= 1 and "s") or "", | 22 days, (days ~= 1 and "s") or "", hours, (hours ~= 1 and "s") or "", |
23 minutes, (minutes ~= 1 and "s") or "", os.date("%c", prosody.start_time)); | 23 minutes, (minutes ~= 1 and "s") or "", os.date("%c", prosody.start_time)); |
24 end | 24 end |
25 | 25 |
26 function uptime_command_handler (item, origin, stanza) | 26 function uptime_command_handler (self, data, sessid) |
27 origin.send(st.reply(stanza):add_child(item:cmdtag("completed", uuid.generate()):tag("note", {type="info"}):text(uptime()))); | 27 return { info = uptime(), status = "completed" }, uuid.generate(); |
28 return true; | |
29 end | 28 end |
30 | 29 |
31 local descriptor = adhoc_new("Get uptime", "uptime", uptime_command_handler); | 30 local descriptor = adhoc_new("Get uptime", "uptime", uptime_command_handler); |
32 | 31 |
33 module:add_item ("adhoc", descriptor); | 32 module:add_item ("adhoc", descriptor); |