mod_ping: Convert from Windows line endings
[prosody.git] / plugins / mod_uptime.lua
1 -- Prosody IM v0.4
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
10
11 local st = require "util.stanza"
12
13 local jid_split = require "util.jid".split;
14 local t_concat = table.concat;
15
16 local start_time = prosody.start_time;
17
18 module:add_feature("jabber:iq:last");
19
20 module:add_iq_handler({"c2s", "s2sin"}, "jabber:iq:last", 
21         function (origin, stanza)
22                 if stanza.tags[1].name == "query" then
23                         if stanza.attr.type == "get" then
24                                 local node, host, resource = jid_split(stanza.attr.to);
25                                 if node or resource then
26                                         -- TODO
27                                 else
28                                         origin.send(st.reply(stanza):tag("query", {xmlns = "jabber:iq:last", seconds = tostring(os.difftime(os.time(), start_time))}));
29                                         return true;
30                                 end
31                         end
32                 end
33         end);