Commit Diff


commit - 2688829ddde70bf4824d1492dc78289bc542b987
commit + ac587adc696330e3dbebd53ec91a5b2a9ca2c0e3
blob - 6c07cb7b6b7a915b43afd60441aed513f3ba0000
blob + b5e879c6b85adc2adc7539d585acfb0aa6ec4446
--- src/ngircd/irc-mode.c
+++ src/ngircd/irc-mode.c
@@ -14,7 +14,7 @@
 
 #include "portab.h"
 
-static char UNUSED id[] = "$Id: irc-mode.c,v 1.24.2.1 2003/01/02 18:03:05 alex Exp $";
+static char UNUSED id[] = "$Id: irc-mode.c,v 1.24.2.2 2003/01/08 23:08:12 alex Exp $";
 
 #include "imp.h"
 #include <assert.h>
@@ -246,8 +246,35 @@ Channel_Mode( CLIENT *Client, REQUEST *Req, CLIENT *Or
 	LONG l;
 
 	/* Mode request: let's answer it :-) */
-	if( Req->argc == 1 ) return IRC_WriteStrClient( Origin, RPL_CHANNELMODEIS_MSG, Client_ID( Origin ), Channel_Name( Channel ), Channel_Modes( Channel ));
+	if( Req->argc == 1 )
+	{
+		/* Member or not? -- That's the question! */
+		if( ! Channel_IsMemberOf( Channel, Origin )) return IRC_WriteStrClient( Origin, RPL_CHANNELMODEIS_MSG, Client_ID( Origin ), Channel_Name( Channel ), Channel_Modes( Channel ));
 
+		/* The sender is a member: generate extended reply */
+		strlcpy( the_modes, Channel_Modes( Channel ), sizeof( the_modes ));
+		mode_ptr = the_modes;
+		strcpy( the_args, "" );
+		while( *mode_ptr )
+		{
+			switch( *mode_ptr )
+			{
+				case 'l':
+					snprintf( argadd, sizeof( argadd ), " %ld", Channel_MaxUsers( Channel ));
+					strlcat( the_args, argadd, sizeof( the_args ));
+					break;
+				case 'k':
+					strlcat( the_args, " ", sizeof( the_args ));
+					strlcat( the_args, Channel_Key( Channel ), sizeof( the_args ));
+					break;
+			}
+			mode_ptr++;
+		}
+		if( the_args[0] ) strlcat( the_modes, the_args, sizeof( the_modes ));
+
+		return IRC_WriteStrClient( Origin, RPL_CHANNELMODEIS_MSG, Client_ID( Origin ), Channel_Name( Channel ), the_modes );
+	}
+
 	/* Is the user allowed to change modes? */
 	if( Client_Type( Client ) == CLIENT_USER )
 	{