Comparison

plugins/mod_uptime.lua @ 11200:bf8f2da84007

Merge 0.11->trunk
author Kim Alvefur <zash@zash.se>
date Thu, 05 Nov 2020 22:31:25 +0100
parent 10749:abbdf72b0710
child 12977:74b9e05af71e
comparison
equal deleted inserted replaced
11199:6c7c50a4de32 11200:bf8f2da84007
14 -- XEP-0012: Last activity 14 -- XEP-0012: Last activity
15 module:add_feature("jabber:iq:last"); 15 module:add_feature("jabber:iq:last");
16 16
17 module:hook("iq-get/host/jabber:iq:last:query", function(event) 17 module:hook("iq-get/host/jabber:iq:last:query", function(event)
18 local origin, stanza = event.origin, event.stanza; 18 local origin, stanza = event.origin, event.stanza;
19 origin.send(st.reply(stanza):tag("query", {xmlns = "jabber:iq:last", seconds = tostring(os.difftime(os.time(), start_time))})); 19 origin.send(st.reply(stanza):tag("query", {xmlns = "jabber:iq:last", seconds = tostring(("%d"):format(os.difftime(os.time(), start_time)))}));
20 return true; 20 return true;
21 end); 21 end);
22 22
23 -- Ad-hoc command 23 -- Ad-hoc command
24 module:depends "adhoc"; 24 module:depends "adhoc";
40 40
41 function uptime_command_handler () 41 function uptime_command_handler ()
42 return { info = uptime_text(), status = "completed" }; 42 return { info = uptime_text(), status = "completed" };
43 end 43 end
44 44
45 local descriptor = adhoc_new("Get uptime", "uptime", uptime_command_handler); 45 local descriptor = adhoc_new("Get uptime", "uptime", uptime_command_handler, "any");
46 46
47 module:provides("adhoc", descriptor); 47 module:provides("adhoc", descriptor);