plugins/mod_time.lua

changeset 423
c9c7f026a108
child 424
3eb22492e8ab
equal deleted inserted replaced
422:61c8877d703c 423:c9c7f026a108
1
2 local st = require "util.stanza";
3 local datetime = require "util.datetime".datetime;
4
5 -- XEP-0202: Entity Time
6
7 require "core.discomanager".set("time", "urn:xmpp:time");
8
9 add_iq_handler({"c2s", "s2sin"}, "urn:xmpp:time",
10 function(session, stanza)
11 if stanza.attr.type == "get" then
12 session.send(st.reply(stanza):tag("time", {xmlns="urn:xmpp:time"})
13 :tag("tzo"):text("+00:00"):up() -- FIXME get the timezone in a platform independent fashion
14 :tag("utc"):text(datetime()));
15 end
16 end);
17
18 -- XEP-0090: Entity Time (deprecated)
19
20 require "core.discomanager".set("time", "jabber:iq:time");
21
22 add_iq_handler({"c2s", "s2sin"}, "jabber:iq:time",
23 function(session, stanza)
24 if stanza.attr.type == "get" then
25 session.send(st.reply(stanza):tag("query", {xmlns="jabber:iq:time"})
26 :tag("utc"):text(datetime()));
27 end
28 end);

mercurial