#include "portab.h"
-static char UNUSED id[] = "$Id: irc-mode.c,v 1.26 2002/12/26 17:04:54 alex Exp $";
+static char UNUSED id[] = "$Id: irc-mode.c,v 1.29 2003/01/08 23:00:12 alex Exp $";
#include "imp.h"
#include <assert.h>
{
case 'a':
/* Away */
- if( Client_Type( Client ) == CLIENT_SERVER ) x[0] = 'a';
+ if( Client_Type( Client ) == CLIENT_SERVER )
+ {
+ x[0] = 'a';
+ Client_SetAway( Client, DEFAULT_AWAY_MSG );
+ }
else ok = IRC_WriteStrClient( Origin, ERR_NOPRIVILEGES_MSG, Client_ID( Origin ));
break;
case 'i':
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 )
{
Channel_ModeDel( Channel, 'l' );
Channel_SetMaxUsers( Channel, l );
- sprintf( argadd, "%ld", l );
+ snprintf( argadd, sizeof( argadd ), "%ld", l );
x[0] = *mode_ptr;
}
}
{
/* AWAY setzen */
Client_SetAway( Client, Req->argv[0] );
+ Client_ModeAdd( Client, 'a' );
IRC_WriteStrServersPrefix( Client, Client, "MODE %s :+a", Client_ID( Client ));
return IRC_WriteStrClient( Client, RPL_NOWAWAY_MSG, Client_ID( Client ));
}
else
{
/* AWAY loeschen */
- Client_SetAway( Client, NULL );
+ Client_ModeDel( Client, 'a' );
IRC_WriteStrServersPrefix( Client, Client, "MODE %s :-a", Client_ID( Client ));
return IRC_WriteStrClient( Client, RPL_UNAWAY_MSG, Client_ID( Client ));
}