]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/channels.cpp
Proper fix for clients that send a nickprefix on their commands (the rfc says they...
[user/henk/code/inspircd.git] / src / channels.cpp
index ce7cbb45c3d8b49a97a8f3ba01d8030e560eddf3..ccb230005f1a8b4655fbd2b6622eae3ce3ea5ca6 100644 (file)
@@ -341,6 +341,7 @@ chanrec* chanrec::ForceChan(InspIRCd* Instance, chanrec* Ptr, userrec* user, con
 {
        userrec* dummyuser = new userrec(Instance);
        std::string nick = user->nick;
+       bool silent = false;
 
        dummyuser->SetFd(FD_MAGIC_NUMBER);
        Ptr->AddUser(user);
@@ -383,7 +384,10 @@ chanrec* chanrec::ForceChan(InspIRCd* Instance, chanrec* Ptr, userrec* user, con
 
        delete dummyuser;
 
-       Ptr->WriteChannel(user,"JOIN :%s",Ptr->name);
+       FOREACH_MOD_I(Instance,I_OnUserJoin,OnUserJoin(user, Ptr, silent));
+
+       if (!silent)
+               Ptr->WriteChannel(user,"JOIN :%s",Ptr->name);
 
        /* Theyre not the first ones in here, make sure everyone else sees the modes we gave the user */
        std::string ms = Instance->Modes->ModeString(user, Ptr);
@@ -400,8 +404,7 @@ chanrec* chanrec::ForceChan(InspIRCd* Instance, chanrec* Ptr, userrec* user, con
                }
                Ptr->UserList(user);
        }
-       FOREACH_MOD_I(Instance,I_OnUserJoin,OnUserJoin(user,Ptr));
-       FOREACH_MOD_I(Instance,I_OnPostJoin,OnPostJoin(user,Ptr));
+       FOREACH_MOD_I(Instance,I_OnPostJoin,OnPostJoin(user, Ptr));
        return Ptr;
 }
 
@@ -434,14 +437,19 @@ bool chanrec::IsBanned(userrec* user)
  */
 long chanrec::PartUser(userrec *user, const char* reason)
 {
+       bool silent = false;
+
        if (!user)
                return this->GetUserCounter();
 
        UCListIter i = user->chans.find(this);
        if (i != user->chans.end())
        {
-               FOREACH_MOD(I_OnUserPart,OnUserPart(user, this, reason ? reason : ""));
-               this->WriteChannel(user, "PART %s%s%s", this->name, reason ? " :" : "", reason ? reason : "");
+               FOREACH_MOD(I_OnUserPart,OnUserPart(user, this, reason ? reason : "", silent));
+
+               if (!silent)
+                       this->WriteChannel(user, "PART %s%s%s", this->name, reason ? " :" : "", reason ? reason : "");
+
                user->chans.erase(i);
                this->RemoveAllPrefixes(user);
        }
@@ -463,6 +471,8 @@ long chanrec::PartUser(userrec *user, const char* reason)
 
 long chanrec::ServerKickUser(userrec* user, const char* reason, bool triggerevents)
 {
+       bool silent = false;
+
        if (!user || !reason)
                return this->GetUserCounter();
 
@@ -477,13 +487,15 @@ long chanrec::ServerKickUser(userrec* user, const char* reason, bool triggereven
 
        if (triggerevents)
        {
-               FOREACH_MOD(I_OnUserKick,OnUserKick(NULL,user,this,reason));
+               FOREACH_MOD(I_OnUserKick,OnUserKick(NULL, user, this, reason, silent));
        }
 
        UCListIter i = user->chans.find(this);
        if (i != user->chans.end())
        {
-               this->WriteChannelWithServ(ServerInstance->Config->ServerName, "KICK %s %s :%s", this->name, user->nick, reason);
+               if (!silent)
+                       this->WriteChannelWithServ(ServerInstance->Config->ServerName, "KICK %s %s :%s", this->name, user->nick, reason);
+
                user->chans.erase(i);
                this->RemoveAllPrefixes(user);
        }
@@ -505,6 +517,8 @@ long chanrec::ServerKickUser(userrec* user, const char* reason, bool triggereven
 
 long chanrec::KickUser(userrec *src, userrec *user, const char* reason)
 {
+       bool silent = false;
+
        if (!src || !user || !reason)
                return this->GetUserCounter();
 
@@ -549,13 +563,15 @@ long chanrec::KickUser(userrec *src, userrec *user, const char* reason)
                }
        }
 
-       FOREACH_MOD(I_OnUserKick,OnUserKick(src,user,this,reason));
+       FOREACH_MOD(I_OnUserKick,OnUserKick(src, user, this, reason, silent));
 
        UCListIter i = user->chans.find(this);
        if (i != user->chans.end())
        {
                /* zap it from the channel list of the user */
-               this->WriteChannel(src, "KICK %s %s :%s", this->name, user->nick, reason);
+               if (!silent)
+                       this->WriteChannel(src, "KICK %s %s :%s", this->name, user->nick, reason);
+
                user->chans.erase(i);
                this->RemoveAllPrefixes(user);
        }
@@ -786,7 +802,7 @@ char* chanrec::ChanModes(bool showkey)
 /* compile a userlist of a channel into a string, each nick seperated by
  * spaces and op, voice etc status shown as @ and +, and send it to 'user'
  */
-void chanrec::UserList(userrec *user)
+void chanrec::UserList(userrec *user, CUList *ulist)
 {
        char list[MAXBUF];
        size_t dlen, curlen;
@@ -795,7 +811,7 @@ void chanrec::UserList(userrec *user)
        if (!IS_LOCAL(user))
                return;
 
-       FOREACH_RESULT(I_OnUserList,OnUserList(user, this));
+       FOREACH_RESULT(I_OnUserList,OnUserList(user, this, ulist));
        if (MOD_RESULT == 1)
                return;
 
@@ -804,7 +820,8 @@ void chanrec::UserList(userrec *user)
        int numusers = 0;
        char* ptr = list + dlen;
 
-       CUList *ulist= this->GetUsers();
+       if (!ulist)
+               ulist = this->GetUsers();
 
        /* Improvement by Brain - this doesnt change in value, so why was it inside
         * the loop?
@@ -822,6 +839,9 @@ void chanrec::UserList(userrec *user)
                        continue;
                }
 
+               if (i->second->Visibility && !i->second->Visibility->VisibleTo(user))
+                       continue;
+
                size_t ptrlen = snprintf(ptr, MAXBUF, "%s%s ", this->GetPrefixChar(i->second), i->second->nick);
 
                curlen += ptrlen;