Software /
code /
prosody
Comparison
plugins/mod_uptime.lua @ 9226:affd84be3fc3
mod_uptime: Simplify iq handling by hooking on iq-get/ instead of iq/.
author | Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> |
---|---|
date | Fri, 24 Aug 2018 20:35:17 +0200 |
parent | 8962:6c06bd455bbf |
child | 9572:867e40b82409 |
comparison
equal
deleted
inserted
replaced
9225:0ba963e82ac7 | 9226:affd84be3fc3 |
---|---|
12 module:hook_global("server-started", function() start_time = prosody.start_time end); | 12 module:hook_global("server-started", function() start_time = prosody.start_time end); |
13 | 13 |
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/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 if stanza.attr.type == "get" then | 19 origin.send(st.reply(stanza):tag("query", {xmlns = "jabber:iq:last", seconds = tostring(os.difftime(os.time(), start_time))})); |
20 origin.send(st.reply(stanza):tag("query", {xmlns = "jabber:iq:last", seconds = tostring(os.difftime(os.time(), start_time))})); | 20 return true; |
21 return true; | |
22 end | |
23 end); | 21 end); |
24 | 22 |
25 -- Ad-hoc command | 23 -- Ad-hoc command |
26 module:depends "adhoc"; | 24 module:depends "adhoc"; |
27 local adhoc_new = module:require "adhoc".new; | 25 local adhoc_new = module:require "adhoc".new; |