diff options
author | Peter Powell <petpow@saberuk.com> | 2019-06-12 21:46:07 +0100 |
---|---|---|
committer | Peter Powell <petpow@saberuk.com> | 2019-06-12 21:52:58 +0100 |
commit | 9433e34b2133d8f1e77fea15447ba4d0259a5fb0 (patch) | |
tree | 8e6bb357472f2e39c31c82053a1d02d4b1f7460d /include/numericbuilder.h | |
parent | 938837af9fe92d0fef811db96a5e9d6bf8e3ae11 (diff) |
Show the mode syntax in ERR_INVALIDMODEPARAM.
Diffstat (limited to 'include/numericbuilder.h')
-rw-r--r-- | include/numericbuilder.h | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/include/numericbuilder.h b/include/numericbuilder.h index 0d55093ca..4431fbc52 100644 --- a/include/numericbuilder.h +++ b/include/numericbuilder.h @@ -207,6 +207,29 @@ namespace Numerics /* Builder for the ERR_INVALIDMODEPARAM numeric. */ class Numerics::InvalidModeParameter : public Numeric::Numeric { + private: + void push_message(ModeHandler* mode, const std::string& message) + { + if (!message.empty()) + { + // The caller has specified their own message. + push(message); + return; + } + + const std::string& syntax = mode->GetSyntax(); + if (!syntax.empty()) + { + // If the mode has a syntax hint we include it in the message. + push(InspIRCd::Format("Invalid %s mode parameter. Syntax: %s.", mode->name.c_str(), syntax.c_str())); + } + else + { + // Otherwise, send it without. + push(InspIRCd::Format("Invalid %s mode parameter.", mode->name.c_str())); + } + } + public: InvalidModeParameter(Channel* chan, ModeHandler* mode, const std::string& parameter, const std::string& message = "") : Numeric(ERR_INVALIDMODEPARAM) @@ -214,7 +237,7 @@ class Numerics::InvalidModeParameter : public Numeric::Numeric push(chan->name); push(mode->GetModeChar()); push(parameter); - push(message.empty() ? InspIRCd::Format("Invalid %s mode parameter", mode->name.c_str()) : message); + push_message(mode, message); } InvalidModeParameter(User* user, ModeHandler* mode, const std::string& parameter, const std::string& message = "") @@ -223,7 +246,7 @@ class Numerics::InvalidModeParameter : public Numeric::Numeric push(user->registered & REG_NICK ? user->nick : "*"); push(mode->GetModeChar()); push(parameter); - push(message.empty() ? InspIRCd::Format("Invalid %s mode parameter", mode->name.c_str()) : message); + push_message(mode, message); } }; |