File

mod_adhoc_cmd_ping/mod_adhoc_cmd_ping.lua @ 79:34f5818c90e9

mod_proxy65: answer with correct disco#info data on a disco#info request
author Thilo Cestonaro <thilo@cestona.ro>
date Sun, 01 Nov 2009 14:37:28 +0100
parent 36:58d326d86a9a
child 109:9b63fd1196c0
line wrap: on
line source

-- Copyright (C) 2009 Thilo Cestonaro
-- 
-- This file is MIT/X11 licensed. Please see the
-- COPYING file in the source package for more information.
--

local st = require "util.stanza";
local adhoc_new = module:require "adhoc".new;

function ping_command_handler (item, origin, stanza)
	local now = os.date("%Y-%m-%dT%X");
	origin.send(st.reply(stanza):add_child(item:cmdtag("completed", now):tag("note", {type="info"}):text("Pong\n" .. now)));
	return true;
end

local descriptor = adhoc_new("Ping", "ping", ping_command_handler);

function module.unload()
	module:remove_item("adhoc", descriptor);
end

module:add_item ("adhoc", descriptor);