aboutsummaryrefslogtreecommitdiffstats
path: root/core/modulemanager.lua
diff options
context:
space:
mode:
Diffstat (limited to 'core/modulemanager.lua')
-rw-r--r--core/modulemanager.lua19
1 files changed, 12 insertions, 7 deletions
diff --git a/core/modulemanager.lua b/core/modulemanager.lua
index 1382e227..3c27e7a0 100644
--- a/core/modulemanager.lua
+++ b/core/modulemanager.lua
@@ -44,7 +44,7 @@ module "modulemanager"
local api = {}; -- Module API container
-local modulemap = {};
+local modulemap = { ["*"] = {} };
local stanza_handlers = multitable_new();
local handler_info = {};
@@ -67,19 +67,23 @@ function load(host, module_name, config)
if not (host and module_name) then
return nil, "insufficient-parameters";
end
- local mod, err = loadfile(plugin_dir.."mod_"..module_name..".lua");
- if not mod then
- log("error", "Unable to load module '%s': %s", module_name or "nil", err or "nil");
- return nil, err;
- end
if not modulemap[host] then
modulemap[host] = {};
elseif modulemap[host][module_name] then
log("warn", "%s is already loaded for %s, so not loading again", module_name, host);
return nil, "module-already-loaded";
+ elseif modulemap["*"][module_name] then
+ return nil, "global-module-already-loaded";
end
+
+ local mod, err = loadfile(plugin_dir.."mod_"..module_name..".lua");
+ if not mod then
+ log("error", "Unable to load module '%s': %s", module_name or "nil", err or "nil");
+ return nil, err;
+ end
+
local _log = logger.init(host..":"..module_name);
local api_instance = setmetatable({ name = module_name, host = host, config = config, _log = _log, log = function (self, ...) return _log(...); end }, { __index = api });
@@ -93,7 +97,8 @@ function load(host, module_name, config)
return nil, ret;
end
- modulemap[host][module_name] = mod;
+ -- Use modified host, if the module set one
+ modulemap[api_instance.host][module_name] = mod;
return true;
end