]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/channels.cpp
Flesh this out some more
[user/henk/code/inspircd.git] / src / channels.cpp
index 6b89883bd11b3b85441825d2c4cb01a8b5c5f294..b0de06267ed7c1e81fbdbc5a1b5c16012acfeb04 100644 (file)
@@ -20,7 +20,7 @@
 
 Channel::Channel(InspIRCd* Instance, const std::string &cname, time_t ts) : ServerInstance(Instance)
 {
-       chan_hash::iterator findchan = ServerInstance->chanlist->find(name);
+       chan_hash::iterator findchan = ServerInstance->chanlist->find(cname);
        if (findchan != Instance->chanlist->end())
                throw CoreException("Cannot create duplicate channel " + cname);
 
@@ -184,6 +184,7 @@ CUList* Channel::GetVoicedUsers()
 
 void Channel::SetDefaultModes()
 {
+       ServerInstance->Logs->Log("CHANNELS", DEBUG, "SetDefaultModes %s", ServerInstance->Config->DefaultModes);
        irc::spacesepstream list(ServerInstance->Config->DefaultModes);
        std::string modeseq;
        std::string parameter;
@@ -277,7 +278,7 @@ Channel* Channel::JoinUser(InspIRCd* Instance, User *user, const char* cn, bool
                if (IS_LOCAL(user) && override == false)
                {
                        MOD_RESULT = 0;
-                       FOREACH_RESULT_I(Instance,I_OnUserPreJoin,OnUserPreJoin(user,NULL,cname,privs));
+                       FOREACH_RESULT_I(Instance,I_OnUserPreJoin, OnUserPreJoin(user, NULL, cname, privs, key ? key : ""));
                        if (MOD_RESULT == 1)
                                return NULL;
                }
@@ -297,7 +298,7 @@ Channel* Channel::JoinUser(InspIRCd* Instance, User *user, const char* cn, bool
                if (IS_LOCAL(user) && override == false)
                {
                        MOD_RESULT = 0;
-                       FOREACH_RESULT_I(Instance,I_OnUserPreJoin,OnUserPreJoin(user,Ptr,cname,privs));
+                       FOREACH_RESULT_I(Instance,I_OnUserPreJoin, OnUserPreJoin(user, Ptr, cname, privs, key ? key : ""));
                        if (MOD_RESULT == 1)
                        {
                                return NULL;
@@ -357,7 +358,7 @@ Channel* Channel::JoinUser(InspIRCd* Instance, User *user, const char* cn, bool
        }
 
        /* As spotted by jilles, dont bother to set this on remote users */
-       if (IS_LOCAL(user) && Ptr->GetUserCounter() == 1)
+       if (IS_LOCAL(user) && Ptr->GetUserCounter() == 0)
                Ptr->SetDefaultModes();
 
        return Channel::ForceChan(Instance, Ptr, user, privs, bursting);
@@ -432,7 +433,10 @@ bool Channel::IsBanned(User* user)
        char mask[MAXBUF];
        int MOD_RESULT = 0;
        FOREACH_RESULT(I_OnCheckBan,OnCheckBan(user, this));
-       if (!MOD_RESULT)
+
+       if (MOD_RESULT == -1)
+               return true;
+       else if (MOD_RESULT == 0)
        {
                snprintf(mask, MAXBUF, "%s!%s@%s", user->nick, user->ident, user->GetIPString());
                for (BanList::iterator i = this->bans.begin(); i != this->bans.end(); i++)
@@ -523,7 +527,7 @@ long Channel::PartUser(User *user, const char* reason)
        return this->GetUserCounter();
 }
 
-long Channel::ServerKickUser(User* user, const char* reason, bool triggerevents)
+long Channel::ServerKickUser(User* user, const char* reason, bool triggerevents, const char* servername)
 {
        bool silent = false;
 
@@ -539,6 +543,9 @@ long Channel::ServerKickUser(User* user, const char* reason, bool triggerevents)
                }
        }
 
+       if (servername == NULL || *ServerInstance->Config->HideWhoisServer)
+               servername = ServerInstance->Config->ServerName;
+
        if (triggerevents)
        {
                FOREACH_MOD(I_OnUserKick,OnUserKick(NULL, user, this, reason, silent));
@@ -548,7 +555,7 @@ long Channel::ServerKickUser(User* user, const char* reason, bool triggerevents)
        if (i != user->chans.end())
        {
                if (!silent)
-                       this->WriteChannelWithServ(ServerInstance->Config->ServerName, "KICK %s %s :%s", this->name, user->nick, reason);
+                       this->WriteChannelWithServ(servername, "KICK %s %s :%s", this->name, user->nick, reason);
 
                user->chans.erase(i);
                this->RemoveAllPrefixes(user);