1
0
mirror of https://github.com/anope/anope.git synced 2026-07-01 16:26:38 +02:00

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

This commit is contained in:
Adam
2013-04-11 00:08:28 -05:00
parent 207c46c871
commit 4f9b7874d6
45 changed files with 251 additions and 373 deletions
+18
View File
@@ -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;