From 3bc4f15db0c64106ad2c268a5f9601bc7033d6f0 Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Fri, 11 Jun 2010 13:23:10 +0100 Subject: mod_adhoc: Scan through list of items on load, in case items have been added before we were loaded --- plugins/adhoc/mod_adhoc.lua | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'plugins/adhoc/mod_adhoc.lua') diff --git a/plugins/adhoc/mod_adhoc.lua b/plugins/adhoc/mod_adhoc.lua index 6a5165ed..6f91a61b 100644 --- a/plugins/adhoc/mod_adhoc.lua +++ b/plugins/adhoc/mod_adhoc.lua @@ -58,10 +58,19 @@ module:hook("iq/host", function (event) end end, 500); +local function handle_item_added(item) + commands[item.node] = item; +end + module:hook("item-added/adhoc", function (event) - commands[event.item.node] = event.item; + return handle_item_added(event.item); end, 500); module:hook("item-removed/adhoc", function (event) commands[event.item.node] = nil; end, 500); + +-- Pick up any items that are already added +for _, item in ipairs(module:get_host_items("adhoc")) do + handle_item_added(item); +end -- cgit v1.2.3