]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/coremods/core_user/core_user.cpp
Merge insp20
[user/henk/code/inspircd.git] / src / coremods / core_user / core_user.cpp
index c862c0eb1a3b711f3355c86cb52b7c746de3c253..dd778548ab95514a37e87157c92756ff70b9e9e6 100644 (file)
 #include "inspircd.h"
 #include "core_user.h"
 
-class CommandMode : public Command
-{
- public:
-       /** Constructor for mode.
-        */
-       CommandMode(Module* parent)
-               : Command(parent, "MODE", 1)
-       {
-               syntax = "<target> <modes> {<mode-parameters>}";
-       }
-
-       /** Handle command.
-        * @param parameters The parameters to the command
-        * @param user The user issuing the command
-        * @return A value from CmdResult to indicate command success or failure.
-        */
-       CmdResult Handle(const std::vector<std::string>& parameters, User* user)
-       {
-               ServerInstance->Modes->Process(parameters, user, (IS_LOCAL(user) ? ModeParser::MODE_NONE : ModeParser::MODE_LOCALONLY));
-               return CMD_SUCCESS;
-       }
-
-       RouteDescriptor GetRouting(User* user, const std::vector<std::string>& parameters)
-       {
-               return (IS_LOCAL(user) ? ROUTE_LOCALONLY : ROUTE_BROADCAST);
-       }
-};
-
 /** Handle /PASS.
  */
 class CommandPass : public SplitCommand
@@ -73,6 +45,7 @@ class CommandPass : public SplitCommand
                // Check to make sure they haven't registered -- Fix by FCS
                if (user->registered == REG_ALL)
                {
+                       user->CommandFloodPenalty += 1000;
                        user->WriteNumeric(ERR_ALREADYREGISTERED, ":You may not reregister");
                        return CMD_FAILURE;
                }
@@ -92,7 +65,6 @@ class CommandPing : public Command
        CommandPing(Module* parent)
                : Command(parent, "PING", 1, 2)
        {
-               Penalty = 0;
                syntax = "<servername> [:<servername>]";
        }
 
@@ -130,12 +102,40 @@ class CommandPong : public Command
        CmdResult Handle(const std::vector<std::string>& parameters, User* user)
        {
                // set the user as alive so they survive to next ping
-               if (IS_LOCAL(user))
-                       IS_LOCAL(user)->lastping = 1;
+               LocalUser* localuser = IS_LOCAL(user);
+               if (localuser)
+               {
+                       // Increase penalty unless we've sent a PING and this is the reply
+                       if (localuser->lastping)
+                               localuser->CommandFloodPenalty += 1000;
+                       else
+                               localuser->lastping = 1;
+               }
                return CMD_SUCCESS;
        }
 };
 
+void MessageWrapper::Wrap(const std::string& message, std::string& out)
+{
+       // If there is a fixed message, it is stored in prefix. Otherwise prefix contains
+       // only the prefix, so append the message and the suffix
+       out.assign(prefix);
+       if (!fixed)
+               out.append(message).append(suffix);
+}
+
+void MessageWrapper::ReadConfig(const char* prefixname, const char* suffixname, const char* fixedname)
+{
+       ConfigTag* tag = ServerInstance->Config->ConfValue("options");
+       prefix = tag->getString(fixedname);
+       fixed = (!prefix.empty());
+       if (!fixed)
+       {
+               prefix = tag->getString(prefixname);
+               suffix = tag->getString(suffixname);
+       }
+}
+
 class CoreModUser : public Module
 {
        CommandAway cmdaway;
@@ -155,6 +155,12 @@ class CoreModUser : public Module
        {
        }
 
+       void ReadConfig(ConfigStatus& status) CXX11_OVERRIDE
+       {
+               cmdpart.msgwrap.ReadConfig("prefixpart", "suffixpart", "fixedpart");
+               cmdquit.msgwrap.ReadConfig("prefixquit", "suffixquit", "fixedquit");
+       }
+
        Version GetVersion() CXX11_OVERRIDE
        {
                return Version("Provides the AWAY, MODE, NICK, PART, PASS, PING, PONG, QUIT and USER commands", VF_VENDOR|VF_CORE);