# HG changeset patch # User Florian Zeitz # Date 1283457469 -7200 # Node ID 8a46bb70016fd316d8c28575eb74720735b0d757 # Parent 3eee60c6a436a04db08ca2c1acc9a5404ce259c7 mod_ping: Add ad-hoc command diff -r 3eee60c6a436 -r 8a46bb70016f plugins/mod_ping.lua --- 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); +