]> git.netwichtig.de Git - user/henk/code/inspircd.git/commitdiff
Add const std::string &original_command to OnPreCommand and OnPostCommand, which...
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>
Sun, 17 Sep 2006 14:01:53 +0000 (14:01 +0000)
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>
Sun, 17 Sep 2006 14:01:53 +0000 (14:01 +0000)
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@5265 e03df62e-2008-0410-955e-edbf42e46eb7

18 files changed:
include/modules.h
src/cmd_kill.cpp
src/cmd_quit.cpp
src/command_parse.cpp
src/modules.cpp
src/modules/extra/m_sqllog.cpp
src/modules/extra/m_sqloper.cpp
src/modules/extra/m_ssl_oper_cert.cpp
src/modules/m_alias.cpp
src/modules/m_blockamsg.cpp
src/modules/m_conn_lusers.cpp
src/modules/m_conn_waitpong.cpp
src/modules/m_namesx.cpp
src/modules/m_operlog.cpp
src/modules/m_override.cpp
src/modules/m_safelist.cpp
src/modules/m_securelist.cpp
src/modules/m_spanningtree.cpp

index c497155add6a5fcb03ac918561f1731c25651363..95dbd764ee20c1e3815a4930a5fbe9961acb659d 100644 (file)
@@ -997,9 +997,10 @@ class Module : public Extensible
         * @param pcnt The nuimber of parameters passed to the command
         * @param user the user issuing the command
         * @param validated True if the command has passed all checks, e.g. it is recognised, has enough parameters, the user has permission to execute it, etc.
+        * @param original_line The entire original line as passed to the parser from the user
         * @return 1 to block the command, 0 to allow
         */
-       virtual int OnPreCommand(const std::string &command, const char** parameters, int pcnt, userrec *user, bool validated);
+       virtual int OnPreCommand(const std::string &command, const char** parameters, int pcnt, userrec *user, bool validated, const std::string &original_line);
 
        /** Called after any command has been executed.
         * This event occurs for all registered commands, wether they are registered in the core,
@@ -1011,8 +1012,9 @@ class Module : public Extensible
         * @param pcnt The nuimber of parameters passed to the command
         * @param user the user issuing the command
         * @param result The return code given by the command handler, one of CMD_SUCCESS or CMD_FAILURE
+        * @param original_line The entire original line as passed to the parser from the user
         */
-       virtual void OnPostCommand(const std::string &command, const char** parameters, int pcnt, userrec *user, CmdResult result);
+       virtual void OnPostCommand(const std::string &command, const char** parameters, int pcnt, userrec *user, CmdResult result, const std::string &original_line);
 
        /** Called to check if a user who is connecting can now be allowed to register
         * If any modules return false for this function, the user is held in the waiting
index 4d1a6d4ff620ae0bd67d02f9a74be49c9306f6dc..6f42c1b382b8bcf160ef24be315d095ff3cc2831 100644 (file)
@@ -68,7 +68,8 @@ CmdResult cmd_kill::Handle (const char** parameters, int pcnt, userrec *user)
 
                        if (u == user)
                        {
-                               FOREACH_MOD(I_OnPostCommand,OnPostCommand("KILL", parameters, pcnt, user, CMD_SUCCESS));
+                               std::string original_command = std::string("KILL ") + u->nick + " :"+parameters[1];
+                               FOREACH_MOD(I_OnPostCommand,OnPostCommand("KILL", parameters, pcnt, user, CMD_SUCCESS,original_command));
                                return CMD_USER_DELETED;
                        }
                        DELETE(u);
index 41cc48c8e587cec71dff886143fd7b056bb7324d..26502c3857fb1cf8a47d068f125cae8c583a4947 100644 (file)
@@ -31,6 +31,7 @@ CmdResult cmd_quit::Handle (const char** parameters, int pcnt, userrec *user)
 {
        user_hash::iterator iter = ServerInstance->clientlist.find(user->nick);
        char reason[MAXBUF];
+       std::string quitmsg = "Client exited";
 
        if (user->registered == REG_ALL)
        {
@@ -47,9 +48,11 @@ CmdResult cmd_quit::Handle (const char** parameters, int pcnt, userrec *user)
                         */
                        if (IS_LOCAL(user))
                        {
-                               user->Write("ERROR :Closing link (%s@%s) [%s%s]",user->ident,user->host,ServerInstance->Config->PrefixQuit,parameters[0]);
-                               ServerInstance->SNO->WriteToSnoMask('q',"Client exiting: %s!%s@%s [%s%s]",user->nick,user->ident,user->host,ServerInstance->Config->PrefixQuit,parameters[0]);
-                               user->WriteCommonExcept("QUIT :%s%s",ServerInstance->Config->PrefixQuit,parameters[0]);
+                               quitmsg = ServerInstance->Config->PrefixQuit;
+                               quitmsg.append(parameters[0]);
+                               user->Write("ERROR :Closing link (%s@%s) [%s]",user->ident,user->host,quitmsg.c_str());
+                               ServerInstance->SNO->WriteToSnoMask('q',"Client exiting: %s!%s@%s [%s]",user->nick,user->ident,user->host,quitmsg.c_str());
+                               user->WriteCommonExcept("QUIT :%s", quitmsg.c_str());
                        }
                        else
                        {
@@ -63,7 +66,7 @@ CmdResult cmd_quit::Handle (const char** parameters, int pcnt, userrec *user)
                {
                        if (IS_LOCAL(user))
                        {
-                               user->Write("ERROR :Closing link (%s@%s) [QUIT]",user->ident,user->host);
+                               user->Write("ERROR :Closing link (%s@%s) []",user->ident,user->host);
                                ServerInstance->SNO->WriteToSnoMask('q',"Client exiting: %s!%s@%s [Client exited]",user->nick,user->ident,user->host);
                        }
                        else
@@ -100,7 +103,12 @@ CmdResult cmd_quit::Handle (const char** parameters, int pcnt, userrec *user)
                user->PurgeEmptyChannels();
        }
 
-       FOREACH_MOD(I_OnPostCommand,OnPostCommand("QUIT", parameters, pcnt, user, CMD_SUCCESS));
+       if (IS_LOCAL(user))
+       {
+               std::string original_command = "QUIT :" + quitmsg;
+               FOREACH_MOD(I_OnPostCommand,OnPostCommand("QUIT", parameters, pcnt, user, CMD_SUCCESS, original_command));
+       }
+
        DELETE(user);
        return CMD_USER_DELETED;
 }
index a158ff6a36be9ac17d8e2def2f2ec91465988758..881e1abc7740a668a57dffdf945adfc026d9b009 100644 (file)
@@ -327,7 +327,7 @@ void CommandParser::ProcessCommand(userrec *user, std::string &cmd)
        std::transform(command.begin(), command.end(), command.begin(), ::toupper);
                
        int MOD_RESULT = 0;
-       FOREACH_RESULT(I_OnPreCommand,OnPreCommand(command,command_p,items,user,false));
+       FOREACH_RESULT(I_OnPreCommand,OnPreCommand(command,command_p,items,user,false,cmd));
        if (MOD_RESULT == 1) {
                return;
        }
@@ -374,7 +374,7 @@ void CommandParser::ProcessCommand(userrec *user, std::string &cmd)
                                cm->second->total_bytes += cmd.length();
 
                                int MOD_RESULT = 0;
-                               FOREACH_RESULT(I_OnPreCommand,OnPreCommand(command,command_p,items,user,true));
+                               FOREACH_RESULT(I_OnPreCommand,OnPreCommand(command,command_p,items,user,true,cmd));
                                if (MOD_RESULT == 1)
                                        return;
 
@@ -387,7 +387,7 @@ void CommandParser::ProcessCommand(userrec *user, std::string &cmd)
 
                                if (result != CMD_USER_DELETED)
                                {
-                                       FOREACH_MOD(I_OnPostCommand,OnPostCommand(command, command_p, items, user, result));
+                                       FOREACH_MOD(I_OnPostCommand,OnPostCommand(command, command_p, items, user, result,cmd));
                                }
                                return;
                        }
index f5e83c0930eee8d28353f3ffae25e7c773fb1c03..db5a976c5421c145a62f2554f96145a756a7cd6d 100644 (file)
@@ -131,8 +131,8 @@ int         Module::OnKill(userrec* source, userrec* dest, const std::string &reason) {
 void           Module::OnLoadModule(Module* mod,const std::string &name) { };
 void           Module::OnUnloadModule(Module* mod,const std::string &name) { };
 void           Module::OnBackgroundTimer(time_t curtime) { };
-int            Module::OnPreCommand(const std::string &command, const char** parameters, int pcnt, userrec *user, bool validated) { return 0; };
-void           Module::OnPostCommand(const std::string &command, const char** parameters, int pcnt, userrec *user, CmdResult result) { };
+int            Module::OnPreCommand(const std::string &command, const char** parameters, int pcnt, userrec *user, bool validated, const std::string &original_line) { return 0; };
+void           Module::OnPostCommand(const std::string &command, const char** parameters, int pcnt, userrec *user, CmdResult result, const std::string &original_line) { };
 bool           Module::OnCheckReady(userrec* user) { return true; };
 void           Module::OnUserRegister(userrec* user) { };
 int            Module::OnUserPreKick(userrec* source, userrec* user, chanrec* chan, const std::string &reason) { return 0; };
index 62d4baeeb7ad02a52923ecb0f737372fc9618fab..c3130079cf3a4dd35fbb215a738f72598aff6cf7 100644 (file)
@@ -353,7 +353,7 @@ class ModuleSQLLog : public Module
                return 0;
        }
 
-       virtual int OnPreCommand(const std::string &command, const char** parameters, int pcnt, userrec *user, bool validated)
+       virtual int OnPreCommand(const std::string &command, const char** parameters, int pcnt, userrec *user, bool validated, const std::string &original_line)
        {
                if ((command == "GLINE") || (command == "KLINE") || (command == "ELINE") || (command == "ZLINE"))
                {
index 867dab8a9526e00175ed7624f93b8929940ee6fd..e36e97caef416d2f549203ed50338f423aa1c1b2 100644 (file)
@@ -65,7 +65,7 @@ public:
                List[I_OnRequest] = List[I_OnRehash] = List[I_OnPreCommand] = 1;
        }
 
-       virtual int OnPreCommand(const std::string &command, const char** parameters, int pcnt, userrec *user, bool validated)
+       virtual int OnPreCommand(const std::string &command, const char** parameters, int pcnt, userrec *user, bool validated, const std::string &original_line)
        {
                if (validated && (command == "OPER"))
                {
index 1f11e9b6877f5ad914e4094a2d30dc2254e8847a..e441755fb8db66058b76d3fcb05904e237e70e14 100644 (file)
@@ -113,7 +113,7 @@ class ModuleOperSSLCert : public Module
        }
 
 
-       virtual int OnPreCommand(const std::string &command, const char** parameters, int pcnt, userrec *user, bool validated)
+       virtual int OnPreCommand(const std::string &command, const char** parameters, int pcnt, userrec *user, bool validated, const std::string &original_line)
        {
                irc::string cmd = command.c_str();
                
index fd3dedff2dec5169a79cdde94a2551a771a6cc33..6a4eaf7953e2237306ba6efdd4acf196809a9eeb 100644 (file)
@@ -92,7 +92,7 @@ class ModuleAlias : public Module
                return Version(1,0,0,1,VF_VENDOR);
        }
 
-       virtual int OnPreCommand(const std::string &command, const char** parameters, int pcnt, userrec *user, bool validated)
+       virtual int OnPreCommand(const std::string &command, const char** parameters, int pcnt, userrec *user, bool validated, const std::string &original_line)
        {
                userrec *u = NULL;
                irc::string c = command.c_str();
index c0fb7651e8b4fdd4147eb3604424017effde690e..55f3d382997766a42914cc568426b6834976bc7f 100644 (file)
@@ -95,7 +95,7 @@ public:
                DELETE(Conf);
        }
 
-       virtual int OnPreCommand(const std::string &command, const char** parameters, int pcnt, userrec *user, bool validated)
+       virtual int OnPreCommand(const std::string &command, const char** parameters, int pcnt, userrec *user, bool validated, const std::string &original_line)
        {
                // Don't do anything with unregistered users, or remote ones.
                if(!user || (user->registered != REG_ALL) || !IS_LOCAL(user))
index bd444338edd9955b4f8d80f5be91e3c2c0ccec6d..2c4f8da41ba39f4f68ace7d4d497eaa9a3e6abcd 100644 (file)
@@ -66,7 +66,7 @@ class ModuleConnLUSERS : public Module
                Module* Proto = ServerInstance->FindModule("m_spanningtree.so");
                if (Proto)
                {
-                       Proto->OnPreCommand("LUSERS", NULL, 0, user, true);
+                       Proto->OnPreCommand("LUSERS", NULL, 0, user, true, "LUSERS");
                }
                else
                {
index 937577c5ec2443e67b0758a5374943d0a9eb48cf..346555a1d386eb42ead9cc26f78fa3d3870dbb57 100644 (file)
@@ -79,7 +79,7 @@ class ModuleWaitPong : public Module
                user->Extend("waitpong_pingstr", pingrpl);
        }
        
-       virtual int OnPreCommand(const std::string &command, const char** parameters, int pcnt, userrec* user, bool validated)
+       virtual int OnPreCommand(const std::string &command, const char** parameters, int pcnt, userrec* user, bool validated, const std::string &original_line)
        {
                if(command == "PONG")
                {
index e55e436ce75508c70209f67b90e480c60bb1dbfd..27bef92f5a9e1ba27ad02dc9bfc70b39a467a90b 100644 (file)
@@ -53,7 +53,7 @@ class ModuleNamesX : public Module
                output.append(" NAMESX");
        }
 
-        virtual int OnPreCommand(const std::string &command, const char** parameters, int pcnt, userrec *user, bool validated)
+        virtual int OnPreCommand(const std::string &command, const char** parameters, int pcnt, userrec *user, bool validated, const std::string &original_line)
        {
                irc::string c = command.c_str();
                /* We don't actually create a proper command handler class for PROTOCTL,
index 062e8197906b81d8d0cf63c01f5a564d04f46c2b..9b3028bd3040d0819dde8d91985bb4c58bb7065d 100644 (file)
@@ -48,7 +48,7 @@ class ModuleOperLog : public Module
                List[I_OnPreCommand] = List[I_On005Numeric] = 1;
        }
 
-       virtual int OnPreCommand(const std::string &command, const char** parameters, int pcnt, userrec *user, bool validated)
+       virtual int OnPreCommand(const std::string &command, const char** parameters, int pcnt, userrec *user, bool validated, const std::string &original_line)
        {
                /* If the command doesnt appear to be valid, we dont want to mess with it. */
                if (!validated)
index bb5121771322a861f7149f7505d238f709c668ee..026b2798d7c13af4ec863e4b5ce1e7412c1dec4e 100644 (file)
@@ -68,7 +68,7 @@ class ModuleOverride : public Module
                List[I_OnRehash] = List[I_OnAccessCheck] = List[I_On005Numeric] = List[I_OnUserPreJoin] = List[I_OnUserPreKick] = List[I_OnPostCommand] = 1;
        }
 
-       virtual void OnPostCommand(const std::string &command, const char** parameters, int pcnt, userrec *user, CmdResult result)
+       virtual void OnPostCommand(const std::string &command, const char** parameters, int pcnt, userrec *user, CmdResult result, const std::string &original_line)
        {
                if ((NoisyOverride) && (OverriddenMode) && (irc::string(command.c_str()) == "MODE") && (result == CMD_SUCCESS))
                {
index ac7225b5eba3f9fdea68cbc3ce26d6303eeaff51..28d4ebd8547d1daeeea2b4fbcd7242477c84fa92 100644 (file)
@@ -169,7 +169,7 @@ class ModuleSafeList : public Module
         * OnPreCommand()
         *   Intercept the LIST command.
         */ 
-       virtual int OnPreCommand(const std::string &command, const char** parameters, int pcnt, userrec *user, bool validated)
+       virtual int OnPreCommand(const std::string &command, const char** parameters, int pcnt, userrec *user, bool validated, const std::string &original_line)
        {
                /* If the command doesnt appear to be valid, we dont want to mess with it. */
                if (!validated)
index 14eb2aecff8a3039fc8d1cd9f7853bde76ed53f6..f059c10384b6ae19829f783853957f74b7b6ff07 100644 (file)
@@ -53,7 +53,7 @@ class ModuleSecureList : public Module
         * OnPreCommand()
         *   Intercept the LIST command.
         */ 
-       virtual int OnPreCommand(const std::string &command, const char** parameters, int pcnt, userrec *user, bool validated)
+       virtual int OnPreCommand(const std::string &command, const char** parameters, int pcnt, userrec *user, bool validated, const std::string &original_line)
        {
                /* If the command doesnt appear to be valid, we dont want to mess with it. */
                if (!validated)
index 7555a027e8146c63341b45c321e172ccd894883a..5b62697d711ce8eb1790f509d85c100b17130563 100644 (file)
@@ -601,7 +601,8 @@ class cmd_rconnect : public command_t
                        ServerInstance->SNO->WriteToSnoMask('l',"Remote CONNECT from %s matching \002%s\002, connecting server \002%s\002",user->nick,parameters[0],parameters[1]);
                        const char* para[1];
                        para[0] = parameters[1];
-                       Creator->OnPreCommand("CONNECT", para, 1, user, true);
+                       std::string original_command = std::string("CONNECT ") + parameters[1];
+                       Creator->OnPreCommand("CONNECT", para, 1, user, true, original_command);
 
                        return CMD_SUCCESS;
                }
@@ -4224,7 +4225,7 @@ class ModuleSpanningTree : public Module
                return 0;
        }
 
-       virtual int OnPreCommand(const std::string &command, const char** parameters, int pcnt, userrec *user, bool validated)
+       virtual int OnPreCommand(const std::string &command, const char** parameters, int pcnt, userrec *user, bool validated, const std::string &original_line)
        {
                /* If the command doesnt appear to be valid, we dont want to mess with it. */
                if (!validated)
@@ -4286,7 +4287,7 @@ class ModuleSpanningTree : public Module
                return 0;
        }
 
-       virtual void OnPostCommand(const std::string &command, const char** parameters, int pcnt, userrec *user, CmdResult result)
+       virtual void OnPostCommand(const std::string &command, const char** parameters, int pcnt, userrec *user, CmdResult result, const std::string &original_line)
        {
                if ((result == CMD_SUCCESS) && (ServerInstance->IsValidModuleCommand(command, pcnt, user)))
                {