Diff

plugins/mod_ping.lua @ 3486:8a46bb70016f

mod_ping: Add ad-hoc command
author Florian Zeitz <florob@babelmonkeys.de>
date Thu, 02 Sep 2010 21:57:49 +0200
parent 2923:b7049746bd29
child 4129:c86b68abe12e
line wrap: on
line diff
--- a/plugins/mod_ping.lua	Wed Sep 01 22:46:35 2010 +0200
+++ b/plugins/mod_ping.lua	Thu Sep 02 21:57:49 2010 +0200
@@ -19,3 +19,15 @@
 
 module:hook("iq/bare/urn:xmpp:ping:ping", ping_handler);
 module:hook("iq/host/urn:xmpp:ping:ping", ping_handler);
+
+-- Ad-hoc command
+
+function ping_command_handler (self, data, state)
+	local now = os.date("%Y-%m-%dT%X");
+	return { info = "Pong\n"..now, status = "completed" };
+end
+
+local adhoc_new = module:require "adhoc".new;
+local descriptor = adhoc_new("Ping", "ping", ping_command_handler);
+module:add_item ("adhoc", descriptor);
+