sessionmanager: Added function send_to_interested_resources().
[prosody.git] / plugins / mod_uptime.lua
1 -- Prosody IM
2 -- Copyright (C) 2008-2009 Matthew Wild
3 -- Copyright (C) 2008-2009 Waqas Hussain
4 -- 
5 -- This project is MIT/X11 licensed. Please see the
6 -- COPYING file in the source package for more information.
7 --
8
9 local st = require "util.stanza";
10
11 local start_time = prosody.start_time;
12 prosody.events.add_handler("server-started", function() start_time = prosody.start_time end);
13
14 module:add_feature("jabber:iq:last");
15
16 module:hook("iq/host/jabber:iq:last:query", function(event)
17         local origin, stanza = event.origin, event.stanza;
18         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                 return true;
21         end
22 end);