mod_csi_simple: Consider messages encrypted payload as important (fixes part of ...
[prosody.git] / plugins / mod_ping.lua
blob5fff58d157ef0b0db8045cacc489ac6536f878ae
1 -- Prosody IM
2 -- Copyright (C) 2008-2010 Matthew Wild
3 -- Copyright (C) 2008-2010 Waqas Hussain
4 --
5 -- This project is MIT/X11 licensed. Please see the
6 -- COPYING file in the source package for more information.
7 --
9 local st = require "util.stanza";
11 module:add_feature("urn:xmpp:ping");
13 local function ping_handler(event)
14 return event.origin.send(st.reply(event.stanza));
15 end
17 module:hook("iq-get/bare/urn:xmpp:ping:ping", ping_handler);
18 module:hook("iq-get/host/urn:xmpp:ping:ping", ping_handler);
20 -- Ad-hoc command
22 local datetime = require "util.datetime".datetime;
24 function ping_command_handler (self, data, state) -- luacheck: ignore 212
25 local now = datetime();
26 return { info = "Pong\n"..now, status = "completed" };
27 end
29 module:depends "adhoc";
30 local adhoc_new = module:require "adhoc".new;
31 local descriptor = adhoc_new("Ping", "ping", ping_command_handler);
32 module:provides("adhoc", descriptor);