Software /
code /
prosody
Annotate
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 |
rev | line source |
---|---|
235
6526df1a7277
Added mod_uptime: [XEP-0012: Last Activity] queries now work when directed at the server.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
1 |
6526df1a7277
Added mod_uptime: [XEP-0012: Last Activity] queries now work when directed at the server.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
2 local st = require "util.stanza" |
6526df1a7277
Added mod_uptime: [XEP-0012: Last Activity] queries now work when directed at the server.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
3 local send = require "core.sessionmanager".send_to_session |
6526df1a7277
Added mod_uptime: [XEP-0012: Last Activity] queries now work when directed at the server.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
4 |
6526df1a7277
Added mod_uptime: [XEP-0012: Last Activity] queries now work when directed at the server.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
5 local jid_split = require "util.jid".split; |
6526df1a7277
Added mod_uptime: [XEP-0012: Last Activity] queries now work when directed at the server.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
6 local t_concat = table.concat; |
6526df1a7277
Added mod_uptime: [XEP-0012: Last Activity] queries now work when directed at the server.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
7 |
6526df1a7277
Added mod_uptime: [XEP-0012: Last Activity] queries now work when directed at the server.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
8 local start_time = os.time(); |
6526df1a7277
Added mod_uptime: [XEP-0012: Last Activity] queries now work when directed at the server.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
9 |
6526df1a7277
Added mod_uptime: [XEP-0012: Last Activity] queries now work when directed at the server.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
10 add_iq_handler({"c2s", "s2sin"}, "jabber:iq:last", |
6526df1a7277
Added mod_uptime: [XEP-0012: Last Activity] queries now work when directed at the server.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
11 function (origin, stanza) |
6526df1a7277
Added mod_uptime: [XEP-0012: Last Activity] queries now work when directed at the server.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
12 if stanza.tags[1].name == "query" then |
6526df1a7277
Added mod_uptime: [XEP-0012: Last Activity] queries now work when directed at the server.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
13 if stanza.attr.type == "get" then |
6526df1a7277
Added mod_uptime: [XEP-0012: Last Activity] queries now work when directed at the server.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
14 local node, host, resource = jid_split(stanza.attr.to); |
6526df1a7277
Added mod_uptime: [XEP-0012: Last Activity] queries now work when directed at the server.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
15 if node or resource then |
6526df1a7277
Added mod_uptime: [XEP-0012: Last Activity] queries now work when directed at the server.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
16 -- TODO |
6526df1a7277
Added mod_uptime: [XEP-0012: Last Activity] queries now work when directed at the server.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
17 else |
6526df1a7277
Added mod_uptime: [XEP-0012: Last Activity] queries now work when directed at the server.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
18 origin.send(st.reply(stanza):tag("query", {xmlns = "jabber:iq:last", seconds = tostring(os.difftime(os.time(), start_time))})); |
6526df1a7277
Added mod_uptime: [XEP-0012: Last Activity] queries now work when directed at the server.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
19 return true; |
6526df1a7277
Added mod_uptime: [XEP-0012: Last Activity] queries now work when directed at the server.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
20 end |
6526df1a7277
Added mod_uptime: [XEP-0012: Last Activity] queries now work when directed at the server.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
21 end |
6526df1a7277
Added mod_uptime: [XEP-0012: Last Activity] queries now work when directed at the server.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
22 end |
6526df1a7277
Added mod_uptime: [XEP-0012: Last Activity] queries now work when directed at the server.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
23 end); |
6526df1a7277
Added mod_uptime: [XEP-0012: Last Activity] queries now work when directed at the server.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
24 |
6526df1a7277
Added mod_uptime: [XEP-0012: Last Activity] queries now work when directed at the server.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
25 |