]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/command_parse.cpp
cmd_kill: log all kills from or to remote users
[user/henk/code/inspircd.git] / src / command_parse.cpp
index 7998d9cc3a982f0f71732a2f7dfe4af2b831e9f3..f3511b05b0c7c36aa4c0f41ffea961e7056b54a2 100644 (file)
@@ -60,7 +60,7 @@ bool CommandParser::LoopCall(User* user, Command* handler, const std::vector<std
         *
         * Only check for duplicates if there is one list (allow them in JOIN).
         */
-       insp::flat_set<irc::string> dupes;
+       insp::flat_set<std::string, irc::insensitive_swo> dupes;
        bool check_dupes = (extra < 0);
 
        /* Create two sepstreams, if we have only one list, then initialize the second sepstream with
@@ -80,7 +80,7 @@ bool CommandParser::LoopCall(User* user, Command* handler, const std::vector<std
         */
        while (items1.GetToken(item) && (!usemax || max++ < ServerInstance->Config->MaxTargets))
        {
-               if ((!check_dupes) || (dupes.insert(item.c_str()).second))
+               if ((!check_dupes) || (dupes.insert(item).second))
                {
                        std::vector<std::string> new_parameters(parameters);
                        new_parameters[splithere] = item;
@@ -217,7 +217,7 @@ void CommandParser::ProcessCommand(LocalUser *user, std::string &cmd)
                if (!handler)
                {
                        if (user->registered == REG_ALL)
-                               user->WriteNumeric(ERR_UNKNOWNCOMMAND, "%s :Unknown command",command.c_str());
+                               user->WriteNumeric(ERR_UNKNOWNCOMMAND, command, "Unknown command");
                        ServerInstance->stats.Unknown++;
                        return;
                }
@@ -268,15 +268,15 @@ void CommandParser::ProcessCommand(LocalUser *user, std::string &cmd)
                if (!user->IsModeSet(handler->flags_needed))
                {
                        user->CommandFloodPenalty += failpenalty;
-                       user->WriteNumeric(ERR_NOPRIVILEGES, ":Permission Denied - You do not have the required operator privileges");
+                       user->WriteNumeric(ERR_NOPRIVILEGES, "Permission Denied - You do not have the required operator privileges");
                        return;
                }
 
                if (!user->HasPermission(command))
                {
                        user->CommandFloodPenalty += failpenalty;
-                       user->WriteNumeric(ERR_NOPRIVILEGES, ":Permission Denied - Oper type %s does not have access to command %s",
-                               user->oper->name.c_str(), command.c_str());
+                       user->WriteNumeric(ERR_NOPRIVILEGES, InspIRCd::Format("Permission Denied - Oper type %s does not have access to command %s",
+                               user->oper->name.c_str(), command.c_str()));
                        return;
                }
        }
@@ -287,11 +287,11 @@ void CommandParser::ProcessCommand(LocalUser *user, std::string &cmd)
                user->CommandFloodPenalty += failpenalty;
                if (ServerInstance->Config->DisabledDontExist)
                {
-                       user->WriteNumeric(ERR_UNKNOWNCOMMAND, "%s :Unknown command", command.c_str());
+                       user->WriteNumeric(ERR_UNKNOWNCOMMAND, command, "Unknown command");
                }
                else
                {
-                       user->WriteNumeric(ERR_UNKNOWNCOMMAND, "%s :This command has been disabled.", command.c_str());
+                       user->WriteNumeric(ERR_UNKNOWNCOMMAND, command, "This command has been disabled.");
                }
 
                ServerInstance->SNO->WriteToSnoMask('a', "%s denied for %s (%s@%s)",
@@ -305,16 +305,16 @@ void CommandParser::ProcessCommand(LocalUser *user, std::string &cmd)
        if (command_p.size() < handler->min_params)
        {
                user->CommandFloodPenalty += failpenalty;
-               user->WriteNumeric(ERR_NEEDMOREPARAMS, "%s :Not enough parameters.", command.c_str());
+               user->WriteNumeric(ERR_NEEDMOREPARAMS, command, "Not enough parameters.");
                if ((ServerInstance->Config->SyntaxHints) && (user->registered == REG_ALL) && (handler->syntax.length()))
-                       user->WriteNumeric(RPL_SYNTAX, ":SYNTAX %s %s", handler->name.c_str(), handler->syntax.c_str());
+                       user->WriteNumeric(RPL_SYNTAX, InspIRCd::Format("SYNTAX %s %s", handler->name.c_str(), handler->syntax.c_str()));
                return;
        }
 
        if ((user->registered != REG_ALL) && (!handler->WorksBeforeReg()))
        {
                user->CommandFloodPenalty += failpenalty;
-               user->WriteNumeric(ERR_NOTREGISTERED, "%s :You have not registered",command.c_str());
+               user->WriteNumeric(ERR_NOTREGISTERED, command, "You have not registered");
        }
        else
        {
@@ -379,13 +379,18 @@ Command::~Command()
        ServerInstance->Parser.RemoveCommand(this);
 }
 
+void Command::RegisterService()
+{
+       if (!ServerInstance->Parser.AddCommand(this))
+               throw ModuleException("Command already exists: " + name);
+}
+
 void CommandParser::ProcessBuffer(std::string &buffer,LocalUser *user)
 {
        if (buffer.empty())
                return;
 
-       ServerInstance->Logs->Log("USERINPUT", LOG_RAWIO, "C[%s] I :%s %s",
-               user->uuid.c_str(), user->nick.c_str(), buffer.c_str());
+       ServerInstance->Logs->Log("USERINPUT", LOG_RAWIO, "C[%s] I %s", user->uuid.c_str(), buffer.c_str());
        ProcessCommand(user,buffer);
 }