Software /
code /
prosody
Changeset
4450:15547fba1f09
mod_adhoc: Use module:handle_items()
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Sat, 10 Dec 2011 05:45:07 +0000 |
parents | 4449:ca74d8ed1a15 |
children | 4451:70275ab52ab2 |
files | plugins/adhoc/mod_adhoc.lua |
diffstat | 1 files changed, 5 insertions(+), 11 deletions(-) [+] |
line wrap: on
line diff
--- a/plugins/adhoc/mod_adhoc.lua Fri Dec 09 12:02:21 2011 +0500 +++ b/plugins/adhoc/mod_adhoc.lua Sat Dec 10 05:45:07 2011 +0000 @@ -90,19 +90,13 @@ end end, 500); -local function handle_item_added(item) +local function adhoc_added(event) + local item = event.item; commands[item.node] = item; end -module:hook("item-added/adhoc", function (event) - return handle_item_added(event.item); -end, 500); - -module:hook("item-removed/adhoc", function (event) +local function adhoc_removed(event) commands[event.item.node] = nil; -end, 500); +end --- Pick up any items that are already added -for _, item in ipairs(module:get_host_items("adhoc")) do - handle_item_added(item); -end +module:handle_items("adhoc", adhoc_added, adhoc_removed);