]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/mode.cpp
Annotations
[user/henk/code/inspircd.git] / src / mode.cpp
index f74a2ac603afd05a3f90be5bff123c9c0d147baf..ceb801c695a04f3f920310c00e52badc4e0962f6 100644 (file)
@@ -271,6 +271,8 @@ void ModeParser::Process(const char** parameters, int pcnt, userrec *user, bool
 
        ServerInstance->Log(DEBUG,"ModeParser::Process start");
 
+       LastParse = "";
+
        /* Special case for displaying the list for listmodes,
         * e.g. MODE #chan b, or MODE #chan +b without a parameter
         */
@@ -509,10 +511,12 @@ void ModeParser::Process(const char** parameters, int pcnt, userrec *user, bool
                                if (type == MODETYPE_CHANNEL)
                                {
                                        targetchannel->WriteChannelWithServ(ServerInstance->Config->ServerName, "MODE %s %s%s", targetchannel->name, output_sequence.c_str(), parameter_list.str().c_str());
+                                       this->LastParse = targetchannel->name;
                                }
                                else
                                {
                                        targetuser->WriteServ("MODE %s %s%s",targetuser->nick,output_sequence.c_str(), parameter_list.str().c_str());
+                                       this->LastParse = targetuser->nick;
                                }
                        }
                        else
@@ -522,17 +526,28 @@ void ModeParser::Process(const char** parameters, int pcnt, userrec *user, bool
                                        ServerInstance->Log(DEBUG,"Write output sequence and parameters to channel: %s %s%s",targetchannel->name,output_sequence.c_str(),parameter_list.str().c_str());
                                        targetchannel->WriteChannel(user,"MODE %s %s%s",targetchannel->name,output_sequence.c_str(),parameter_list.str().c_str());
                                        FOREACH_MOD(I_OnMode,OnMode(user, targetchannel, TYPE_CHANNEL, output_sequence + parameter_list.str()));
+                                       this->LastParse = targetchannel->name;
                                }
                                else
                                {
                                        user->WriteTo(targetuser,"MODE %s %s%s",targetuser->nick,output_sequence.c_str(), parameter_list.str().c_str());
                                        FOREACH_MOD(I_OnMode,OnMode(user, targetuser, TYPE_USER, output_sequence));
+                                       this->LastParse = targetuser->nick;
                                }
                        }
+
+                       LastParse.append(" ");
+                       LastParse.append(output_sequence);
+                       LastParse.append(parameter_list.str());
                }
        }
 }
 
+const std::string& ModeParser::GetLastParse()
+{
+       return LastParse;
+}
+
 void ModeParser::CleanMask(std::string &mask)
 {
        std::string::size_type pos_of_pling = mask.find_first_of('!');
@@ -719,7 +734,7 @@ std::string ModeParser::ModeString(userrec* user, chanrec* channel)
                {
                        ModePair ret;
                        ret = mh->ModeSet(NULL, user, channel, user->nick);
-                       if (ret.first)
+                       if ((ret.first) && (ret.second == user->nick))
                        {
                                pars.append(" ");
                                pars.append(user->nick);
@@ -905,6 +920,9 @@ ModeParser::ModeParser(InspIRCd* Instance) : ServerInstance(Instance)
        memset(modehandlers, 0, sizeof(modehandlers));
        memset(modewatchers, 0, sizeof(modewatchers));
 
+       /* Last parse string */
+       LastParse = "";
+
        /* Initialise the RFC mode letters */
 
        /* Start with channel simple modes, no params */