Software /
code /
prosody-modules
Diff
mod_adhoc_cmd_ping/mod_adhoc_cmd_ping.lua @ 36:58d326d86a9a
mod_adhoc: add adhoc.lib.lua to ease implementing new commands (as a consequence mod_adhoc is a directory now)
mod_adhoc_cmd_*: Convert to use adhoc.lib.lua
author | Florian Zeitz <florob@babelmonkeys.de> |
---|---|
date | Sun, 11 Oct 2009 01:20:16 +0200 |
parent | 28:b9d063dd16d5 |
child | 109:9b63fd1196c0 |
line wrap: on
line diff
--- a/mod_adhoc_cmd_ping/mod_adhoc_cmd_ping.lua Sat Oct 10 09:33:44 2009 +0100 +++ b/mod_adhoc_cmd_ping/mod_adhoc_cmd_ping.lua Sun Oct 11 01:20:16 2009 +0200 @@ -5,15 +5,15 @@ -- 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):tag("command", {xmlns="http://jabber.org/protocol/commands", status="completed", node=item.node, sessionid=now}) - :tag("note", {type="info"}):text("Pong\n" .. now)); + origin.send(st.reply(stanza):add_child(item:cmdtag("completed", now):tag("note", {type="info"}):text("Pong\n" .. now))); return true; end -local descriptor = { name="Ping", node="ping", handler=ping_command_handler }; +local descriptor = adhoc_new("Ping", "ping", ping_command_handler); function module.unload() module:remove_item("adhoc", descriptor);