Comparison

plugins/mod_uptime.lua @ 235:6526df1a7277

Added mod_uptime: [XEP-0012: Last Activity] queries now work when directed at the server.
author Waqas Hussain <waqas20@gmail.com>
date Mon, 10 Nov 2008 01:33:37 +0500
child 314:851f271d25b0
comparison
equal deleted inserted replaced
234:7c8313e055fb 235:6526df1a7277
1
2 local st = require "util.stanza"
3 local send = require "core.sessionmanager".send_to_session
4
5 local jid_split = require "util.jid".split;
6 local t_concat = table.concat;
7
8 local start_time = os.time();
9
10 add_iq_handler({"c2s", "s2sin"}, "jabber:iq:last",
11 function (origin, stanza)
12 if stanza.tags[1].name == "query" then
13 if stanza.attr.type == "get" then
14 local node, host, resource = jid_split(stanza.attr.to);
15 if node or resource then
16 -- TODO
17 else
18 origin.send(st.reply(stanza):tag("query", {xmlns = "jabber:iq:last", seconds = tostring(os.difftime(os.time(), start_time))}));
19 return true;
20 end
21 end
22 end
23 end);
24
25