]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/channels.cpp
Kill m_spy, which was replaced by channels/auspex in 1.2 but kept alive for nostalgia
[user/henk/code/inspircd.git] / src / channels.cpp
index 8d145aa16f7c9d8b49ae9576d1560411bf5690aa..d0533aee68d20848223a0b6695b88353828eb3fb 100644 (file)
@@ -81,29 +81,26 @@ std::string Channel::GetModeParameter(ModeHandler* mode)
 
 int Channel::SetTopic(User *u, std::string &ntopic, bool forceset)
 {
-       if (u)
+       if (!u)
+               u = ServerInstance->FakeClient;
+       if (IS_LOCAL(u) && !forceset)
        {
-               if(!forceset)
-               {
-                       ModResult res;
-                       /* 0: check status, 1: don't, -1: disallow change silently */
-
-                       FIRST_MOD_RESULT(OnPreTopicChange, res, (u,this,ntopic));
+               ModResult res;
+               FIRST_MOD_RESULT(OnPreTopicChange, res, (u,this,ntopic));
 
-                       if (res == MOD_RES_DENY)
-                               return CMD_FAILURE;
-                       if (res != MOD_RES_ALLOW)
+               if (res == MOD_RES_DENY)
+                       return CMD_FAILURE;
+               if (res != MOD_RES_ALLOW)
+               {
+                       FIRST_MOD_RESULT(OnChannelRestrictionApply, res, (u,this,"topiclock"));
+                       bool defok = IsModeSet('t') ? GetPrefixValue(u) >= HALFOP_VALUE : HasUser(u);
+                       if (!res.check(defok))
                        {
                                if (!this->HasUser(u))
-                               {
                                        u->WriteNumeric(442, "%s %s :You're not on that channel!",u->nick.c_str(), this->name.c_str());
-                                       return CMD_FAILURE;
-                               }
-                               if ((this->IsModeSet('t')) && (this->GetPrefixValue(u) < HALFOP_VALUE))
-                               {
-                                       u->WriteNumeric(482, "%s %s :You must be at least a half-operator to change the topic on this channel", u->nick.c_str(), this->name.c_str());
-                                       return CMD_FAILURE;
-                               }
+                               else
+                                       u->WriteNumeric(482, "%s %s :You do not have access to change the topic on this channel", u->nick.c_str(), this->name.c_str());
+                               return CMD_FAILURE;
                        }
                }
        }
@@ -122,11 +119,7 @@ int Channel::SetTopic(User *u, std::string &ntopic, bool forceset)
 
        this->topicset = ServerInstance->Time();
 
-       // XXX: this check for 'u' is probably pre-fake-user, and it fucking sucks anyway. we need to change this.
-       if (u)
-       {
-               FOREACH_MOD(I_OnPostTopicChange,OnPostTopicChange(u, this, this->topic));
-       }
+       FOREACH_MOD(I_OnPostTopicChange,OnPostTopicChange(u, this, this->topic));
 
        return CMD_SUCCESS;
 }
@@ -753,20 +746,14 @@ void Channel::UserList(User *user)
 {
        char list[MAXBUF];
        size_t dlen, curlen;
-       ModResult call_modules;
 
        if (!IS_LOCAL(user))
                return;
 
-       FIRST_MOD_RESULT(OnUserList, call_modules, (user, this));
-
-       if (call_modules != MOD_RES_ALLOW)
+       if (this->IsModeSet('s') && !this->HasUser(user) && !user->HasPrivPermission("channels/auspex"))
        {
-               if ((this->IsModeSet('s')) && (!this->HasUser(user)))
-               {
-                       user->WriteNumeric(ERR_NOSUCHNICK, "%s %s :No such nick/channel",user->nick.c_str(), this->name.c_str());
-                       return;
-               }
+               user->WriteNumeric(ERR_NOSUCHNICK, "%s %s :No such nick/channel",user->nick.c_str(), this->name.c_str());
+               return;
        }
 
        dlen = curlen = snprintf(list,MAXBUF,"%s %c %s :", user->nick.c_str(), this->IsModeSet('s') ? '@' : this->IsModeSet('p') ? '*' : '=',  this->name.c_str());
@@ -793,14 +780,11 @@ void Channel::UserList(User *user)
                std::string prefixlist = this->GetPrefixChar(i->first);
                std::string nick = i->first->nick;
 
-               if (call_modules != MOD_RES_DENY)
-               {
-                       FOREACH_MOD(I_OnNamesListItem, OnNamesListItem(user, i->second, prefixlist, nick));
+               FOREACH_MOD(I_OnNamesListItem, OnNamesListItem(user, i->second, prefixlist, nick));
 
-                       /* Nick was nuked, a module wants us to skip it */
-                       if (nick.empty())
-                               continue;
-               }
+               /* Nick was nuked, a module wants us to skip it */
+               if (nick.empty())
+                       continue;
 
                size_t ptrlen = 0;