inspircd

A modular C++ IRC daemon (ircd). https://www.inspircd.org/
Log | Files | Refs | README

commit ece446b149e4b5692cee1430c169ca2a255244cd
parent b4599531f97a9e6207b6bb8d728d7523b6995523
Author: Peter Powell <petpow@saberuk.com>
Date:   Fri, 26 Apr 2019 18:35:17 +0100

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.

Diffstat:
Msrc/modules/m_opermotd.cpp | 27+++++++++++++++++++--------
1 file changed, 19 insertions(+), 8 deletions(-)

diff --git 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