56 return adhoc_handle_cmd(commands[node], origin, stanza); |
56 return adhoc_handle_cmd(commands[node], origin, stanza); |
57 end |
57 end |
58 end |
58 end |
59 end, 500); |
59 end, 500); |
60 |
60 |
|
61 local function handle_item_added(item) |
|
62 commands[item.node] = item; |
|
63 end |
|
64 |
61 module:hook("item-added/adhoc", function (event) |
65 module:hook("item-added/adhoc", function (event) |
62 commands[event.item.node] = event.item; |
66 return handle_item_added(event.item); |
63 end, 500); |
67 end, 500); |
64 |
68 |
65 module:hook("item-removed/adhoc", function (event) |
69 module:hook("item-removed/adhoc", function (event) |
66 commands[event.item.node] = nil; |
70 commands[event.item.node] = nil; |
67 end, 500); |
71 end, 500); |
|
72 |
|
73 -- Pick up any items that are already added |
|
74 for _, item in ipairs(module:get_host_items("adhoc")) do |
|
75 handle_item_added(item); |
|
76 end |