]> git.netwichtig.de Git - user/henk/code/inspircd.git/commitdiff
Implement <options:prefixpart|suffixpart|fixedpart>
authorw00t <w00t@e03df62e-2008-0410-955e-edbf42e46eb7>
Thu, 10 Jan 2008 11:47:15 +0000 (11:47 +0000)
committerw00t <w00t@e03df62e-2008-0410-955e-edbf42e46eb7>
Thu, 10 Jan 2008 11:47:15 +0000 (11:47 +0000)
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@8690 e03df62e-2008-0410-955e-edbf42e46eb7

include/configreader.h
src/commands/cmd_part.cpp
src/configreader.cpp

index 05194fbeac9badb07a99884304ffe76a20055262..847b816c0b1f78d7a7e86b6800c68c0047bc529b 100644 (file)
@@ -348,6 +348,18 @@ class CoreExport ServerConfig : public Extensible
         */
        char FixedQuit[MAXBUF];
 
+       /** The part prefix in use, or an empty string
+        */
+       char PrefixPart[MAXBUF];
+
+       /** The part suffix in use, or an empty string
+        */
+       char SuffixPart[MAXBUF];
+
+       /** The fixed part message in use, or an empty string
+        */
+       char FixedPart[MAXBUF];
+
        /** The last string found within a <die> tag, or
         * an empty string.
         */
index 46108eca24e1c69434e5242aa69e8b107e87d2b6..aaff9e30fb300f35fd5e32463bd5d20ebae079a4 100644 (file)
@@ -21,6 +21,25 @@ extern "C" DllExport Command* init_command(InspIRCd* Instance)
 
 CmdResult CommandPart::Handle (const char** parameters, int pcnt, User *user)
 {
+       std::string reason;
+
+       if (IS_LOCAL(user))
+       {
+               if (*ServerInstance->Config->FixedPart)
+                       reason = ServerInstance->Config->FixedPart;
+               else
+               {
+                       if (pcnt > 1)
+                               reason = ServerInstance->Config->PrefixPart + std::string(parameters[1]) + ServerInstance->Config->SuffixPart;
+                       else
+                               reason = "";
+               }
+       }
+       else
+       {
+               reason = pcnt ? parameters[1] : "";
+       }
+
        if (ServerInstance->Parser->LoopCall(user, this, parameters, pcnt, 0))
                return CMD_SUCCESS;
 
@@ -28,7 +47,8 @@ CmdResult CommandPart::Handle (const char** parameters, int pcnt, User *user)
        
        if (c)
        {
-               if (!c->PartUser(user, pcnt > 1 ? parameters[1] : NULL))
+               const char *rreason = reason.empty() ? NULL : reason.c_str();
+               if (!c->PartUser(user, rreason))
                        /* Arse, who stole our channel! :/ */
                        delete c;
        }
index eff49307c9c4b08e1ea29d957298927b630c6c58..b5d999f1d2e543ec519fa3de82b62c808ef085ea 100644 (file)
@@ -815,6 +815,9 @@ void ServerConfig::Read(bool bail, User* user, int pass)
                {"options",     "prefixquit",   "",                     new ValueContainerChar (this->PrefixQuit),              DT_CHARPTR,  NoValidation},
                {"options",     "suffixquit",   "",                     new ValueContainerChar (this->SuffixQuit),              DT_CHARPTR,  NoValidation},
                {"options",     "fixedquit",    "",                     new ValueContainerChar (this->FixedQuit),               DT_CHARPTR,  NoValidation},
+               {"options",     "prefixpart",   "",                     new ValueContainerChar (this->PrefixPart),              DT_CHARPTR,  NoValidation},
+               {"options",     "suffixpart",   "",                     new ValueContainerChar (this->SuffixPart),              DT_CHARPTR,  NoValidation},
+               {"options",     "fixedpart",    "",                     new ValueContainerChar (this->FixedPart),               DT_CHARPTR,  NoValidation},
                {"options",     "loglevel",     "default",              new ValueContainerChar (debug),                         DT_CHARPTR,  ValidateLogLevel},
                {"options",     "netbuffersize","10240",                new ValueContainerInt  (&this->NetBufferSize),          DT_INTEGER,  ValidateNetBufferSize},
                {"options",     "maxwho",       "128",                  new ValueContainerInt  (&this->MaxWhoResults),          DT_INTEGER,  ValidateMaxWho},