# HG changeset patch # User Waqas Hussain # Date 1245593759 -18000 # Node ID 9935ddfd8ccf8f5171813fbecce9ace4f19bee48 # Parent ae88b9dc7890bbe5aceb6d4e41f759b4d5a9699c modulemanager: Added simple module:require implementation diff -r ae88b9dc7890 -r 9935ddfd8ccf core/modulemanager.lua --- a/core/modulemanager.lua Sat Jun 20 22:50:38 2009 +0100 +++ b/core/modulemanager.lua Sun Jun 21 19:15:59 2009 +0500 @@ -30,7 +30,7 @@ local type = type; local next = next; local rawget = rawget; - +local error = error; local tostring = tostring; -- We need this to let modules access the real global namespace @@ -400,6 +400,15 @@ return api.hook(self, "stanza/"..(xmlns and (xmlns..":") or "")..name, function (data) return handler(data.origin, data.stanza, data); end, priority); end +function api:require(lib) + local f, n = pluginloader.load_code(self.name, lib..".lib.lua"); + if not f then + f, n = pluginloader.load_code(lib, lib..".lib.lua"); + end + if not f then error("Failed to load plugin library '"..lib.."', error: "..n); end -- FIXME better error message + return f(); +end + -------------------------------------------------------------------- local actions = {};