Software /
code /
prosody
Annotate
plugins/mod_uptime.lua @ 758:b1885732e979
GPL->MIT!
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Fri, 30 Jan 2009 17:22:56 +0000 |
parent | 615:4ae3e81513f3 |
child | 759:5cccfb5da6cb |
rev | line source |
---|---|
615 | 1 -- Prosody IM v0.2 |
519
cccd610a0ef9
Insert copyright/license headers
Matthew Wild <mwild1@gmail.com>
parents:
438
diff
changeset
|
2 -- Copyright (C) 2008 Matthew Wild |
cccd610a0ef9
Insert copyright/license headers
Matthew Wild <mwild1@gmail.com>
parents:
438
diff
changeset
|
3 -- Copyright (C) 2008 Waqas Hussain |
cccd610a0ef9
Insert copyright/license headers
Matthew Wild <mwild1@gmail.com>
parents:
438
diff
changeset
|
4 -- |
758 | 5 -- This project is MIT/X11 licensed. Please see the |
6 -- COPYING file in the source package for more information. | |
519
cccd610a0ef9
Insert copyright/license headers
Matthew Wild <mwild1@gmail.com>
parents:
438
diff
changeset
|
7 -- |
cccd610a0ef9
Insert copyright/license headers
Matthew Wild <mwild1@gmail.com>
parents:
438
diff
changeset
|
8 |
cccd610a0ef9
Insert copyright/license headers
Matthew Wild <mwild1@gmail.com>
parents:
438
diff
changeset
|
9 |
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
|
10 |
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 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
|
12 |
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 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
|
14 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
|
15 |
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 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
|
17 |
541
3521e0851c9e
Change modules to use the new add_feature module API method.
Waqas Hussain <waqas20@gmail.com>
parents:
519
diff
changeset
|
18 module:add_feature("jabber:iq:last"); |
421
63be85693710
Modules now sending disco replies
Waqas Hussain <waqas20@gmail.com>
parents:
314
diff
changeset
|
19 |
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
|
20 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
|
21 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
|
22 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
|
23 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
|
24 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
|
25 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
|
26 -- 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
|
27 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
|
28 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
|
29 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
|
30 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
|
31 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
|
32 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
|
33 end); |