Annotate

plugins/mod_uptime.lua @ 1451:cc0aa9470775

mod_pep: Fixed boolean indexing error while casting all messages for a user
author Waqas Hussain <waqas20@gmail.com>
date Thu, 02 Jul 2009 00:43:32 +0500
parent 896:2c0b9e3c11c3
child 1494:bdfa5274e111
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
896
2c0b9e3c11c3 0.3->0.4
Matthew Wild <mwild1@gmail.com>
parents: 760
diff changeset
1 -- Prosody IM v0.4
760
90ce865eebd8 Update copyright notices for 2009
Matthew Wild <mwild1@gmail.com>
parents: 759
diff changeset
2 -- Copyright (C) 2008-2009 Matthew Wild
90ce865eebd8 Update copyright notices for 2009
Matthew Wild <mwild1@gmail.com>
parents: 759
diff changeset
3 -- Copyright (C) 2008-2009 Waqas Hussain
519
cccd610a0ef9 Insert copyright/license headers
Matthew Wild <mwild1@gmail.com>
parents: 438
diff changeset
4 --
758
b1885732e979 GPL->MIT!
Matthew Wild <mwild1@gmail.com>
parents: 615
diff changeset
5 -- This project is MIT/X11 licensed. Please see the
b1885732e979 GPL->MIT!
Matthew Wild <mwild1@gmail.com>
parents: 615
diff changeset
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);