From ece446b149e4b5692cee1430c169ca2a255244cd Mon Sep 17 00:00:00 2001 From: Peter Powell Date: Fri, 26 Apr 2019 18:35:17 +0100 Subject: Fix the numerics used by the opermotd module. - Use ERR_NOOPERMOTD from UnrealIRCd and RPL_OMOTDSTART, RPL_OMOTD, and RPL_ENDOFOMOTD from ircd-ratbox. - Only send ERR_NOOPERMOTD in response to the command. --- src/modules/m_opermotd.cpp | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) (limited to 'src/modules') diff --git a/src/modules/m_opermotd.cpp b/src/modules/m_opermotd.cpp index 591dc97a8..4635cd831 100644 --- a/src/modules/m_opermotd.cpp +++ b/src/modules/m_opermotd.cpp @@ -22,6 +22,17 @@ #include "inspircd.h" +enum +{ + // From UnrealIRCd. + ERR_NOOPERMOTD = 425, + + // From ircd-ratbox. + RPL_OMOTDSTART = 720, + RPL_OMOTD = 721, + RPL_ENDOFOMOTD = 722 +}; + /** Handle /OPERMOTD */ class CommandOpermotd : public Command @@ -37,7 +48,7 @@ class CommandOpermotd : public Command CmdResult Handle(User* user, const Params& parameters) CXX11_OVERRIDE { if ((parameters.empty()) || (irc::equals(parameters[0], ServerInstance->Config->ServerName))) - ShowOperMOTD(user); + ShowOperMOTD(user, true); return CMD_SUCCESS; } @@ -48,22 +59,22 @@ class CommandOpermotd : public Command return ROUTE_LOCALONLY; } - void ShowOperMOTD(User* user) + void ShowOperMOTD(User* user, bool show_missing) { - if (opermotd.empty()) + if (opermotd.empty() && show_missing) { - user->WriteRemoteNumeric(455, "OPERMOTD file is missing"); + user->WriteRemoteNumeric(ERR_NOOPERMOTD, "OPERMOTD file is missing"); return; } - user->WriteRemoteNumeric(RPL_MOTDSTART, "- IRC Operators Message of the Day"); + user->WriteRemoteNumeric(RPL_OMOTDSTART, "- IRC Operators Message of the Day"); for (file_cache::const_iterator i = opermotd.begin(); i != opermotd.end(); ++i) { - user->WriteRemoteNumeric(RPL_MOTD, InspIRCd::Format("- %s", i->c_str())); + user->WriteRemoteNumeric(RPL_OMOTD, InspIRCd::Format("- %s", i->c_str())); } - user->WriteRemoteNumeric(RPL_ENDOFMOTD, "- End of OPERMOTD"); + user->WriteRemoteNumeric(RPL_ENDOFOMOTD, "- End of OPERMOTD"); } }; @@ -87,7 +98,7 @@ class ModuleOpermotd : public Module void OnOper(User* user, const std::string &opertype) CXX11_OVERRIDE { if (onoper && IS_LOCAL(user)) - cmd.ShowOperMOTD(user); + cmd.ShowOperMOTD(user, false); } void ReadConfig(ConfigStatus& status) CXX11_OVERRIDE -- cgit v1.2.3