]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - include/numericbuilder.h
Remove the Kiwi links from the readme.
[user/henk/code/inspircd.git] / include / numericbuilder.h
index dc95cdaf70d4f0e533f825dd691210571114ba87..a077c666deaa9ff67e1d1261281a487d2b492d1e 100644 (file)
@@ -1,6 +1,7 @@
 /*
  * InspIRCd -- Internet Relay Chat Daemon
  *
+ *   Copyright (C) 2018-2020 Sadie Powell <sadie@witchery.services>
  *   Copyright (C) 2015-2016 Attila Molnar <attilamolnar@hush.com>
  *
  * This file is part of InspIRCd.  InspIRCd is free software: you can
@@ -85,7 +86,7 @@ class Numeric::GenericBuilder
        GenericBuilder(Sink s, unsigned int num, bool addparam = true, size_t additionalsize = 0)
                : sink(s)
                , numeric(num)
-               , max(ServerInstance->Config->Limits.MaxLine - ServerInstance->Config->ServerName.size() - additionalsize - 10)
+               , max(ServerInstance->Config->Limits.MaxLine - ServerInstance->Config->GetServerName().size() - additionalsize - 10)
        {
                if (addparam)
                        numeric.push(std::string());
@@ -155,7 +156,7 @@ class Numeric::GenericParamBuilder
                : sink(s)
                , numeric(num)
                , currlen(0)
-               , max(ServerInstance->Config->Limits.MaxLine - ServerInstance->Config->ServerName.size() - additionalsize - 10)
+               , max(ServerInstance->Config->Limits.MaxLine - ServerInstance->Config->GetServerName().size() - additionalsize - 10)
        {
        }
 
@@ -199,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 matching you.",
+                       what.c_str(), strchr("AEIOUaeiou", extban) ? "an" : "a", extban, extbandesc.c_str()));
+       }
+
+       CannotSendTo(User* user, const std::string& message)
+               : Numeric(ERR_CANTSENDTOUSER)
+       {
+               push(user->registered & REG_NICK ? user->nick : "*");
+               push(message);
+       }
+
+       CannotSendTo(User* user, const std::string& what, ModeHandler* mh, bool self = false)
+               : Numeric(ERR_CANTSENDTOUSER)
+       {
+               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
 {