view mod_adhoc_cmd_ping/mod_adhoc_cmd_ping.lua @ 39:b84b2b026eb4

mod_privacy: never block communications from one of a user's resources to another.
author Thilo Cestonaro <>
date Tue, 13 Oct 2009 23:03:58 +0200
parents 58d326d86a9a
children 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 ="%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;

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

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

module:add_item ("adhoc", descriptor);