Software /
code /
prosody
Annotate
plugins/mod_uptime.lua @ 512:eb50ee09c2bb
'install' libs to util before top-level make install
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Sun, 30 Nov 2008 19:31:43 +0000 |
parent | 438:193f9dd64f17 |
child | 519:cccd610a0ef9 |
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 |
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 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
|
5 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
|
6 |
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 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
|
8 |
421
63be85693710
Modules now sending disco replies
Waqas Hussain <waqas20@gmail.com>
parents:
314
diff
changeset
|
9 require "core.discomanager".set("uptime", "jabber:iq:last"); |
63be85693710
Modules now sending disco replies
Waqas Hussain <waqas20@gmail.com>
parents:
314
diff
changeset
|
10 |
438
193f9dd64f17
Bumper commit for the new modulemanager API \o/ Updates all the modules, though some more changes may be in store.
Matthew Wild <mwild1@gmail.com>
parents:
421
diff
changeset
|
11 module:add_iq_handler({"c2s", "s2sin"}, "jabber:iq:last", |
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
|
12 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
|
13 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
|
14 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
|
15 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
|
16 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
|
17 -- 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
|
18 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
|
19 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
|
20 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
|
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 end); |