]> git.netwichtig.de Git - user/henk/code/inspircd.git/commitdiff
Added the module method OnUserPostNick for capturing a nickchange AFTER it has taken...
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>
Mon, 4 Apr 2005 18:12:23 +0000 (18:12 +0000)
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>
Mon, 4 Apr 2005 18:12:23 +0000 (18:12 +0000)
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@976 e03df62e-2008-0410-955e-edbf42e46eb7

include/modules.h
src/commands.cpp
src/modules.cpp

index 2146ec4a67a63fbc0466150b865e2bb2f7ec2b9a..c124216d6807e9b58c32d073e85831409c234d88 100644 (file)
@@ -284,12 +284,18 @@ class Module : public classbase
         * check user->server before taking any action (including returning nonzero from the method).
         * If your method returns nonzero, the nickchange is silently forbidden, and it is down to your
         * module to generate some meaninful output.
-        * You may alter the message text as you wish before relinquishing control to the next module
-        * in the chain, and if no other modules block the text this altered form of the text will be sent out
-        * to the user and possibly to other servers.
         */
        virtual int OnUserPreNick(userrec* user, std::string newnick);
        
+       /** Called after any nickchange, local or remote. This can be used to track users after nickchanges
+        * have been applied. Please note that although you can see remote nickchanges through this function, you should
+         * NOT make any changes to the userrec if the user is a remote user as this may cause a desnyc.
+         * check user->server before taking any action (including returning nonzero from the method).
+        * Because this method is called after the nickchange is taken place, no return values are possible
+        * to indicate forbidding of the nick change. Use OnUserPreNick for this.
+         */
+       virtual void OnUserPostNick(userrec* user, std::string oldnick);
+
        /** Called before an action which requires a channel privilage check.
         * This function is called before many functions which check a users status on a channel, for example
         * before opping a user, deopping a user, kicking a user, etc.
index 2ae4e0049ebc46940fc3850506ce550285876736..ef95d1f3fb384c12c688332d4492d4275bb7ebda 100644 (file)
@@ -1650,9 +1650,11 @@ void handle_nick(char **parameters, int pcnt, userrec *user)
                char buffer[MAXBUF];
                snprintf(buffer,MAXBUF,"n %s %s",user->nick,parameters[0]);
                NetSendToAll(buffer);
-               
        }
        
+       char oldnick[NICKMAX];
+       strlcpy(oldnick,user->nick,NICKMAX);
+
        /* change the nick of the user in the users_hash */
        user = ReHashNick(user->nick, parameters[0]);
        /* actually change the nick within the record */
@@ -1677,6 +1679,10 @@ void handle_nick(char **parameters, int pcnt, userrec *user)
                /* user is registered now, bit 0 = USER command, bit 1 = sent a NICK command */
                ConnectUser(user);
        }
+       if (user->registered == 7)
+       {
+               FOREACH_MOD OnUserPostNick(user,oldnick);
+       }
 }
 
 
index fff5f1c7bfe550d944a5dfeb7563b09918ce239e..a575c3fde6e81d3f0d9918001e0662e52bd84c3b 100644 (file)
@@ -321,6 +321,7 @@ int Module::OnUserPreInvite(userrec* source,userrec* dest,chanrec* channel) { re
 int Module::OnUserPreMessage(userrec* user,void* dest,int target_type, std::string &text) { return 0; };
 int Module::OnUserPreNotice(userrec* user,void* dest,int target_type, std::string &text) { return 0; };
 int Module::OnUserPreNick(userrec* user, std::string newnick) { return 0; };
+void Module::OnUserPostNick(userrec* user, std::string oldnick) { };
 int Module::OnAccessCheck(userrec* source,userrec* dest,chanrec* channel,int access_type) { return ACR_DEFAULT; };
 string_list Module::OnUserSync(userrec* user) { string_list empty; return empty; }
 string_list Module::OnChannelSync(chanrec* chan) { string_list empty; return empty; }