diff options
author | Adam <Adam@anope.org> | 2013-04-11 00:08:28 -0500 |
---|---|---|
committer | Adam <Adam@anope.org> | 2013-04-11 00:08:28 -0500 |
commit | 4f9b7874d6b3a41939ecc2e872ec08d03af7b5f1 (patch) | |
tree | 43162205d31b277c9ff12ee28b7e3a60d6382316 /src/modulemanager.cpp | |
parent | 207c46c871e85b55ae66acc456c6bc412c0c79f9 (diff) |
Pass new config and the new config reader to the OnReload event, aswell as call it on module load on modules that hook to it
Diffstat (limited to 'src/modulemanager.cpp')
-rw-r--r-- | src/modulemanager.cpp | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/modulemanager.cpp b/src/modulemanager.cpp index a6fa1fffd..f27561fa6 100644 --- a/src/modulemanager.cpp +++ b/src/modulemanager.cpp @@ -11,6 +11,7 @@ #include "modules.h" #include "users.h" #include "regchannel.h" +#include "config.h" #include <sys/types.h> #include <sys/stat.h> @@ -225,7 +226,24 @@ ModuleReturn ModuleManager::LoadModule(const Anope::string &modname, User *u) else Log(LOG_DEBUG_2) << "Module " << modname << " is compiled against current version of Anope " << Anope::VersionShort(); + /* If the module is hooked to the reload event it wants to initialize its config here */ + if (std::find(EventHandlers[I_OnReload].begin(), EventHandlers[I_OnReload].end(), m) != EventHandlers[I_OnReload].end()) + { + ConfigReader reader; + try + { + m->OnReload(Config, reader); + } + catch (const ConfigException &ex) + { + Log() << "Module " << modname << " couldn't load due to configuration problems: " << ex.GetReason(); + DeleteModule(m); + return MOD_ERR_EXCEPTION; + } + } + Log(LOG_DEBUG) << "Module " << modname << " loaded."; + FOREACH_MOD(I_OnModuleLoad, OnModuleLoad(u, m)); return MOD_ERR_OK; |