]> arthur.barton.de Git - ngircd-alex.git/blobdiff - src/ngircd/channel.c
Implement channel mode "M"
[ngircd-alex.git] / src / ngircd / channel.c
index ff470246fec79e09d67ab764c6bca583138e2a00..1d1645f2e342e4ee9f01de8ea478ab2fc5eaea93 100644 (file)
@@ -845,6 +845,22 @@ Can_Send_To_Channel(CHANNEL *Chan, CLIENT *From)
 }
 
 
+static bool
+Can_Send_To_Channel_Identified(CHANNEL *Chan, CLIENT *From)
+{
+       if ((Client_ThisServer() == From) || Client_HasMode(From, 'o'))
+               return true;
+
+       if (strchr(Channel_Modes(Chan), 'M') && !Client_HasMode(From, 'R'))
+               return false;
+
+       if (Lists_Check(&Chan->list_excepts, From))
+               return true;
+
+       return !Lists_Check(&Chan->list_bans, From);
+}
+
+
 GLOBAL bool
 Channel_Write(CHANNEL *Chan, CLIENT *From, CLIENT *Client, const char *Command,
              bool SendErrors, const char *Text)
@@ -856,6 +872,13 @@ Channel_Write(CHANNEL *Chan, CLIENT *From, CLIENT *Client, const char *Command,
                                          Client_ID(From), Channel_Name(Chan));
        }
 
+       if (!Can_Send_To_Channel_Identified(Chan, From)) {
+               if (! SendErrors)
+                       return CONNECTED;
+               return IRC_WriteStrClient(From, ERR_CANNOTSENDTOCHAN_MSG,
+                                         Client_ID(From), Channel_Name(Chan));
+       }
+
        if (Client_Conn(From) > NONE)
                Conn_UpdateIdle(Client_Conn(From));