diff options
author | Sadie Powell <sadie@witchery.services> | 2020-04-04 11:49:06 +0100 |
---|---|---|
committer | Sadie Powell <sadie@witchery.services> | 2020-04-04 12:31:14 +0100 |
commit | cbe5b993142c218e09ae972bdce91681cc0ba485 (patch) | |
tree | 61e925088e25c4ba7e1e011929fb13555400c42a /include/numericbuilder.h | |
parent | cad2f3f979b2fc45bcfa7c7b7652bbe201a5b0a0 (diff) |
Add the Numerics::CannotSendTo class and switch stuff to use it.
Diffstat (limited to 'include/numericbuilder.h')
-rw-r--r-- | include/numericbuilder.h | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/include/numericbuilder.h b/include/numericbuilder.h index 73bcc2c97..f9ca26f81 100644 --- a/include/numericbuilder.h +++ b/include/numericbuilder.h @@ -200,11 +200,55 @@ class Numeric::ParamBuilder : public GenericParamBuilder<NumStaticParams, SendEm namespace Numerics { + class CannotSendTo; class InvalidModeParameter; class NoSuchChannel; class NoSuchNick; } +/** Builder for the ERR_CANNOTSENDTOCHAN and ERR_CANTSENDTOUSER numerics. */ +class Numerics::CannotSendTo : public Numeric::Numeric +{ + public: + CannotSendTo(Channel* chan, const std::string& message) + : Numeric(ERR_CANNOTSENDTOCHAN) + { + push(chan->name); + push(message); + } + + CannotSendTo(Channel* chan, const std::string& what, ModeHandler* mh) + : Numeric(ERR_CANNOTSENDTOCHAN) + { + push(chan->name); + push(InspIRCd::Format("You cannot send %s to this channel whilst the +%c (%s) mode is set.", + what.c_str(), mh->GetModeChar(), mh->name.c_str())); + } + + CannotSendTo(Channel* chan, const std::string& what, char extban, const std::string& extbandesc) + : Numeric(ERR_CANNOTSENDTOCHAN) + { + push(chan->name); + push(InspIRCd::Format("You cannot send %s to this channel whilst %s %c: (%s) extban is set on you.", + what.c_str(), strchr("AEIOUaeiou", extban) ? "an" : "a", extban, extbandesc.c_str())); + } + + CannotSendTo(User* user, const std::string& message) + : Numeric(ERR_CANNOTSENDTOCHAN) + { + push(user->registered & REG_NICK ? user->nick : "*"); + push(message); + } + + CannotSendTo(User* user, const std::string& what, ModeHandler* mh, bool self = false) + : Numeric(ERR_CANNOTSENDTOCHAN) + { + push(user->registered & REG_NICK ? user->nick : "*"); + push(InspIRCd::Format("You cannot send %s to this user whilst %s have the +%c (%s) mode set.", + what.c_str(), self ? "you" : "they", mh->GetModeChar(), mh->name.c_str())); + } +}; + /* Builder for the ERR_INVALIDMODEPARAM numeric. */ class Numerics::InvalidModeParameter : public Numeric::Numeric { |