Mercurial > prosody-modules
comparison 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 |
| parents | b9d063dd16d5 |
| children | 9b63fd1196c0 |
comparison
equal
deleted
inserted
replaced
| 35:3c49411d4aa3 | 36:58d326d86a9a |
|---|---|
| 3 -- This file is MIT/X11 licensed. Please see the | 3 -- This file is MIT/X11 licensed. Please see the |
| 4 -- COPYING file in the source package for more information. | 4 -- COPYING file in the source package for more information. |
| 5 -- | 5 -- |
| 6 | 6 |
| 7 local st = require "util.stanza"; | 7 local st = require "util.stanza"; |
| 8 local adhoc_new = module:require "adhoc".new; | |
| 8 | 9 |
| 9 function ping_command_handler (item, origin, stanza) | 10 function ping_command_handler (item, origin, stanza) |
| 10 local now = os.date("%Y-%m-%dT%X"); | 11 local now = os.date("%Y-%m-%dT%X"); |
| 11 origin.send(st.reply(stanza):tag("command", {xmlns="http://jabber.org/protocol/commands", status="completed", node=item.node, sessionid=now}) | 12 origin.send(st.reply(stanza):add_child(item:cmdtag("completed", now):tag("note", {type="info"}):text("Pong\n" .. now))); |
| 12 :tag("note", {type="info"}):text("Pong\n" .. now)); | |
| 13 return true; | 13 return true; |
| 14 end | 14 end |
| 15 | 15 |
| 16 local descriptor = { name="Ping", node="ping", handler=ping_command_handler }; | 16 local descriptor = adhoc_new("Ping", "ping", ping_command_handler); |
| 17 | 17 |
| 18 function module.unload() | 18 function module.unload() |
| 19 module:remove_item("adhoc", descriptor); | 19 module:remove_item("adhoc", descriptor); |
| 20 end | 20 end |
| 21 | 21 |
