aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Sadie Powell2022-09-13 14:26:25 +0100
committerGravatar Sadie Powell2022-09-13 14:26:25 +0100
commit9155b99389542c42cf706bca2acab7c4bfb56aa9 (patch)
tree1bae206255f182a950ba5b1635bd4290d96f7e86
parentWHOIS and WHOWAS have their own empty trailing logic now. (diff)
Rework the snotices sent when a rehash loads/unloads a module.
- Fix sending a duplicate load/unload message when rehashed from the terminal. - Avoid formatting the log message twice.
-rw-r--r--src/configreader.cpp32
1 files changed, 17 insertions, 15 deletions
diff --git a/src/configreader.cpp b/src/configreader.cpp
index efe3af94d..1c8a181ca 100644
--- a/src/configreader.cpp
+++ b/src/configreader.cpp
@@ -512,21 +512,22 @@ void ServerConfig::ApplyModules(User* user)
// Don't remove core_*, just remove m_*
if (InspIRCd::Match(modname, "core_*", ascii_case_insensitive_map))
continue;
+
if (ServerInstance->Modules.Unload(mod))
{
- ServerInstance->SNO.WriteGlobalSno('r', "*** REHASH UNLOADED MODULE: %s", modname.c_str());
-
+ const std::string message = InspIRCd::Format("The %s module was unloaded.", modname.c_str());
if (user)
- user->WriteNumeric(RPL_UNLOADEDMODULE, modname, InspIRCd::Format("The %s module was unloaded.", modname.c_str()));
- else
- ServerInstance->SNO.WriteGlobalSno('r', "The %s module was unloaded.", modname.c_str());
+ user->WriteNumeric(RPL_UNLOADEDMODULE, modname, message);
+
+ ServerInstance->SNO.WriteGlobalSno('r', message);
}
else
{
+ const std::string message = InspIRCd::Format("Failed to unload the %s module: %s", modname.c_str(), ServerInstance->Modules.LastError().c_str());
if (user)
- user->WriteNumeric(ERR_CANTUNLOADMODULE, modname, InspIRCd::Format("Failed to unload the %s module: %s", modname.c_str(), ServerInstance->Modules.LastError().c_str()));
- else
- ServerInstance->SNO.WriteGlobalSno('r', "Failed to unload the %s module: %s", modname.c_str(), ServerInstance->Modules.LastError().c_str());
+ user->WriteNumeric(ERR_CANTUNLOADMODULE, modname, message);
+
+ ServerInstance->SNO.WriteGlobalSno('r', message);
}
}
@@ -538,18 +539,19 @@ void ServerConfig::ApplyModules(User* user)
if (ServerInstance->Modules.Load(modname))
{
- ServerInstance->SNO.WriteGlobalSno('r', "*** REHASH LOADED MODULE: %s", modname.c_str());
+ const std::string message = InspIRCd::Format("The %s module was loaded.", modname.c_str());
if (user)
- user->WriteNumeric(RPL_LOADEDMODULE, modname, InspIRCd::Format("The %s module was loaded.", modname.c_str()));
- else
- ServerInstance->SNO.WriteGlobalSno('r', "The %s module was loaded.", modname.c_str());
+ user->WriteNumeric(RPL_LOADEDMODULE, modname, message);
+
+ ServerInstance->SNO.WriteGlobalSno('r', message);
}
else
{
+ const std::string message = InspIRCd::Format("Failed to load the %s module: %s", modname.c_str(), ServerInstance->Modules.LastError().c_str());
if (user)
- user->WriteNumeric(ERR_CANTLOADMODULE, modname, InspIRCd::Format("Failed to load the %s module: %s", modname.c_str(), ServerInstance->Modules.LastError().c_str()));
- else
- ServerInstance->SNO.WriteGlobalSno('r', "Failed to load the %s module: %s", modname.c_str(), ServerInstance->Modules.LastError().c_str());
+ user->WriteNumeric(ERR_CANTLOADMODULE, modname, message);
+
+ ServerInstance->SNO.WriteGlobalSno('r', message);
}
}
}