diff options
author | B00mX0r <b00mx0r@aureus.pw> | 2017-12-19 14:15:30 -0800 |
---|---|---|
committer | B00mX0r <b00mx0r@aureus.pw> | 2017-12-22 00:35:09 -0800 |
commit | 026c579e4cac7d4545b3c8c3a0d690c8509dc713 (patch) | |
tree | d92941491ef510a9ec8ff317a9002429ae96a33e | |
parent | e467fd0a6fc9ba97b2e2f31e654803a86bbb307f (diff) |
Fixed misc. instances of ERR_NOSUCHNICK instead of channel numerics
Per #1122
-rw-r--r-- | include/numeric.h | 17 | ||||
-rw-r--r-- | include/numerics.h | 1 | ||||
-rw-r--r-- | src/coremods/core_channel/cmd_invite.cpp | 9 | ||||
-rw-r--r-- | src/coremods/core_channel/cmd_join.cpp | 2 | ||||
-rw-r--r-- | src/coremods/core_channel/cmd_kick.cpp | 9 | ||||
-rw-r--r-- | src/coremods/core_channel/cmd_names.cpp | 2 | ||||
-rw-r--r-- | src/coremods/core_channel/cmd_topic.cpp | 4 | ||||
-rw-r--r-- | src/coremods/core_privmsg.cpp | 4 | ||||
-rw-r--r-- | src/coremods/core_user/cmd_mode.cpp | 5 | ||||
-rw-r--r-- | src/coremods/core_user/cmd_part.cpp | 2 | ||||
-rw-r--r-- | src/modules/m_cycle.cpp | 2 | ||||
-rw-r--r-- | src/modules/m_knock.cpp | 2 | ||||
-rw-r--r-- | src/modules/m_namedmodes.cpp | 2 | ||||
-rw-r--r-- | src/modules/m_redirect.cpp | 2 | ||||
-rw-r--r-- | src/modules/m_remove.cpp | 9 | ||||
-rw-r--r-- | src/modules/m_satopic.cpp | 2 | ||||
-rw-r--r-- | src/modules/m_timedbans.cpp | 2 | ||||
-rw-r--r-- | src/modules/m_uninvite.cpp | 2 |
18 files changed, 54 insertions, 24 deletions
diff --git a/include/numeric.h b/include/numeric.h index 8044fe5bf..8ea2447bf 100644 --- a/include/numeric.h +++ b/include/numeric.h @@ -88,8 +88,7 @@ class Numeric::Numeric namespace Numerics { - /** ERR_NOSUCHNICK numeric - */ + /** Builder for the ERR_NOSUCHNICK numeric. */ class NoSuchNick : public Numeric::Numeric { public: @@ -97,7 +96,19 @@ namespace Numerics : Numeric(ERR_NOSUCHNICK) { push(nick); - push("No such nick/channel"); + push("No such nick"); + } + }; + + /** Builder for the ERR_NOSUCHCHANNEL numeric. */ + class NoSuchChannel : public Numeric::Numeric + { + public: + NoSuchChannel(const std::string& chan) + : Numeric(ERR_NOSUCHCHANNEL) + { + push(chan); + push("No such channel"); } }; } diff --git a/include/numerics.h b/include/numerics.h index 8befdab2e..57ecee4df 100644 --- a/include/numerics.h +++ b/include/numerics.h @@ -161,6 +161,7 @@ enum * -- A message from the IRC group for coder sanity, and w00t */ ERR_BADCHANNELKEY = 475, + ERR_BADCHANMASK = 476, ERR_INVITEONLYCHAN = 473, ERR_CHANNELISFULL = 471, ERR_BANNEDFROMCHAN = 474, diff --git a/src/coremods/core_channel/cmd_invite.cpp b/src/coremods/core_channel/cmd_invite.cpp index a1319ebc0..88b2cf86c 100644 --- a/src/coremods/core_channel/cmd_invite.cpp +++ b/src/coremods/core_channel/cmd_invite.cpp @@ -56,9 +56,14 @@ CmdResult CommandInvite::Handle (const std::vector<std::string>& parameters, Use timeout = ConvToInt(parameters[3]); } - if ((!c) || (!u) || (u->registered != REG_ALL)) + if (!c) { - user->WriteNumeric(Numerics::NoSuchNick(c ? parameters[0] : parameters[1])); + user->WriteNumeric(Numerics::NoSuchChannel(parameters[1])); + return CMD_FAILURE; + } + if ((!u) || (u->registered != REG_ALL)) + { + user->WriteNumeric(Numerics::NoSuchNick(parameters[0])); return CMD_FAILURE; } diff --git a/src/coremods/core_channel/cmd_join.cpp b/src/coremods/core_channel/cmd_join.cpp index 06e203ead..a60f1b2c6 100644 --- a/src/coremods/core_channel/cmd_join.cpp +++ b/src/coremods/core_channel/cmd_join.cpp @@ -55,6 +55,6 @@ CmdResult CommandJoin::HandleLocal(const std::vector<std::string>& parameters, L } } - user->WriteNumeric(ERR_NOSUCHCHANNEL, parameters[0], "Invalid channel name"); + user->WriteNumeric(ERR_BADCHANMASK, parameters[0], "Invalid channel name"); return CMD_FAILURE; } diff --git a/src/coremods/core_channel/cmd_kick.cpp b/src/coremods/core_channel/cmd_kick.cpp index 420ed2b83..05e279751 100644 --- a/src/coremods/core_channel/cmd_kick.cpp +++ b/src/coremods/core_channel/cmd_kick.cpp @@ -42,9 +42,14 @@ CmdResult CommandKick::Handle (const std::vector<std::string>& parameters, User else u = ServerInstance->FindNick(parameters[1]); - if ((!u) || (!c) || (u->registered != REG_ALL)) + if (!c) { - user->WriteNumeric(Numerics::NoSuchNick(c ? parameters[1] : parameters[0])); + user->WriteNumeric(Numerics::NoSuchChannel(parameters[0])); + return CMD_FAILURE; + } + if ((!u) || (u->registered != REG_ALL)) + { + user->WriteNumeric(Numerics::NoSuchNick(parameters[1])); return CMD_FAILURE; } diff --git a/src/coremods/core_channel/cmd_names.cpp b/src/coremods/core_channel/cmd_names.cpp index 21fe43cca..dd2926c33 100644 --- a/src/coremods/core_channel/cmd_names.cpp +++ b/src/coremods/core_channel/cmd_names.cpp @@ -62,7 +62,7 @@ CmdResult CommandNames::HandleLocal(const std::vector<std::string>& parameters, } } - user->WriteNumeric(Numerics::NoSuchNick(parameters[0])); + user->WriteNumeric(Numerics::NoSuchChannel(parameters[0])); return CMD_FAILURE; } diff --git a/src/coremods/core_channel/cmd_topic.cpp b/src/coremods/core_channel/cmd_topic.cpp index 835ac82ed..fe913225e 100644 --- a/src/coremods/core_channel/cmd_topic.cpp +++ b/src/coremods/core_channel/cmd_topic.cpp @@ -38,7 +38,7 @@ CmdResult CommandTopic::HandleLocal(const std::vector<std::string>& parameters, Channel* c = ServerInstance->FindChan(parameters[0]); if (!c) { - user->WriteNumeric(Numerics::NoSuchNick(parameters[0])); + user->WriteNumeric(Numerics::NoSuchChannel(parameters[0])); return CMD_FAILURE; } @@ -46,7 +46,7 @@ CmdResult CommandTopic::HandleLocal(const std::vector<std::string>& parameters, { if ((c->IsModeSet(secretmode)) && (!c->HasUser(user))) { - user->WriteNumeric(Numerics::NoSuchNick(c->name)); + user->WriteNumeric(Numerics::NoSuchChannel(c->name)); return CMD_FAILURE; } diff --git a/src/coremods/core_privmsg.cpp b/src/coremods/core_privmsg.cpp index d19ae09b5..89c74346e 100644 --- a/src/coremods/core_privmsg.cpp +++ b/src/coremods/core_privmsg.cpp @@ -180,8 +180,8 @@ CmdResult MessageCommandBase::HandleMessage(const std::vector<std::string>& para } else { - /* no such nick/channel */ - user->WriteNumeric(Numerics::NoSuchNick(target)); + /* channel does not exist */ + user->WriteNumeric(Numerics::NoSuchChannel(parameters[0])); return CMD_FAILURE; } return CMD_SUCCESS; diff --git a/src/coremods/core_user/cmd_mode.cpp b/src/coremods/core_user/cmd_mode.cpp index 2b2652606..ec75d6191 100644 --- a/src/coremods/core_user/cmd_mode.cpp +++ b/src/coremods/core_user/cmd_mode.cpp @@ -45,7 +45,10 @@ CmdResult CommandMode::Handle(const std::vector<std::string>& parameters, User* if ((!targetchannel) && (!targetuser)) { - user->WriteNumeric(Numerics::NoSuchNick(target)); + if (target[0] == '#') + user->WriteNumeric(Numerics::NoSuchChannel(target)); + else + user->WriteNumeric(Numerics::NoSuchNick(target)); return CMD_FAILURE; } if (parameters.size() == 1) diff --git a/src/coremods/core_user/cmd_part.cpp b/src/coremods/core_user/cmd_part.cpp index 4da2787d9..261d75a70 100644 --- a/src/coremods/core_user/cmd_part.cpp +++ b/src/coremods/core_user/cmd_part.cpp @@ -46,7 +46,7 @@ CmdResult CommandPart::Handle (const std::vector<std::string>& parameters, User if (!c) { - user->WriteNumeric(Numerics::NoSuchNick(parameters[0])); + user->WriteNumeric(Numerics::NoSuchChannel(parameters[0])); return CMD_FAILURE; } diff --git a/src/modules/m_cycle.cpp b/src/modules/m_cycle.cpp index 68463a4e7..1028fa977 100644 --- a/src/modules/m_cycle.cpp +++ b/src/modules/m_cycle.cpp @@ -44,7 +44,7 @@ class CommandCycle : public SplitCommand if (!channel) { - user->WriteNumeric(ERR_NOSUCHCHANNEL, parameters[0], "No such channel"); + user->WriteNumeric(Numerics::NoSuchChannel(parameters[0])); return CMD_FAILURE; } diff --git a/src/modules/m_knock.cpp b/src/modules/m_knock.cpp index 48ed3c06f..8be05fd53 100644 --- a/src/modules/m_knock.cpp +++ b/src/modules/m_knock.cpp @@ -45,7 +45,7 @@ class CommandKnock : public Command Channel* c = ServerInstance->FindChan(parameters[0]); if (!c) { - user->WriteNumeric(Numerics::NoSuchNick(parameters[0])); + user->WriteNumeric(Numerics::NoSuchChannel(parameters[0])); return CMD_FAILURE; } diff --git a/src/modules/m_namedmodes.cpp b/src/modules/m_namedmodes.cpp index cd63f4298..5c280b355 100644 --- a/src/modules/m_namedmodes.cpp +++ b/src/modules/m_namedmodes.cpp @@ -57,7 +57,7 @@ class CommandProp : public SplitCommand Channel* const chan = ServerInstance->FindChan(parameters[0]); if (!chan) { - src->WriteNumeric(Numerics::NoSuchNick(parameters[0])); + src->WriteNumeric(Numerics::NoSuchChannel(parameters[0])); return CMD_FAILURE; } diff --git a/src/modules/m_redirect.cpp b/src/modules/m_redirect.cpp index b3dc6e94d..b71a2f3db 100644 --- a/src/modules/m_redirect.cpp +++ b/src/modules/m_redirect.cpp @@ -38,7 +38,7 @@ class Redirect : public ParamMode<Redirect, LocalStringExt> { if (!ServerInstance->IsChannel(parameter)) { - source->WriteNumeric(ERR_NOSUCHCHANNEL, parameter, "Invalid channel name"); + source->WriteNumeric(Numerics::NoSuchChannel(parameter)); return MODEACTION_DENY; } } diff --git a/src/modules/m_remove.cpp b/src/modules/m_remove.cpp index dfe624702..0d816cc41 100644 --- a/src/modules/m_remove.cpp +++ b/src/modules/m_remove.cpp @@ -74,9 +74,14 @@ class RemoveBase : public Command channel = ServerInstance->FindChan(channame); /* Fix by brain - someone needs to learn to validate their input! */ - if ((!target) || (target->registered != REG_ALL) || (!channel)) + if (!channel) { - user->WriteNumeric(Numerics::NoSuchNick(channel ? username.c_str() : channame.c_str())); + user->WriteNumeric(Numerics::NoSuchChannel(channame)); + return CMD_FAILURE; + } + if ((!target) || (target->registered != REG_ALL)) + { + user->WriteNumeric(Numerics::NoSuchNick(username)); return CMD_FAILURE; } diff --git a/src/modules/m_satopic.cpp b/src/modules/m_satopic.cpp index 56fa528f4..8fe96bcf9 100644 --- a/src/modules/m_satopic.cpp +++ b/src/modules/m_satopic.cpp @@ -52,7 +52,7 @@ class CommandSATopic : public Command } else { - user->WriteNumeric(Numerics::NoSuchNick(parameters[0])); + user->WriteNumeric(Numerics::NoSuchChannel(parameters[0])); return CMD_FAILURE; } } diff --git a/src/modules/m_timedbans.cpp b/src/modules/m_timedbans.cpp index 14ef11107..2decc2d3a 100644 --- a/src/modules/m_timedbans.cpp +++ b/src/modules/m_timedbans.cpp @@ -73,7 +73,7 @@ class CommandTban : public Command Channel* channel = ServerInstance->FindChan(parameters[0]); if (!channel) { - user->WriteNumeric(Numerics::NoSuchNick(parameters[0])); + user->WriteNumeric(Numerics::NoSuchChannel(parameters[0])); return CMD_FAILURE; } unsigned int cm = channel->GetPrefixValue(user); diff --git a/src/modules/m_uninvite.cpp b/src/modules/m_uninvite.cpp index df43e2bb2..25c98e77c 100644 --- a/src/modules/m_uninvite.cpp +++ b/src/modules/m_uninvite.cpp @@ -51,7 +51,7 @@ class CommandUninvite : public Command { if (!c) { - user->WriteNumeric(Numerics::NoSuchNick(parameters[1])); + user->WriteNumeric(Numerics::NoSuchChannel(parameters[1])); } else { |