diff options
| -rw-r--r-- | account.c | 2 | ||||
| -rw-r--r-- | irc.c | 69 | ||||
| -rw-r--r-- | set.h | 1 | 
3 files changed, 36 insertions, 36 deletions
| @@ -71,7 +71,7 @@ char *set_eval_account( set_t *set, char *value )  	account_t *acc = set->data;  	/* Double-check: We refuse to edit on-line accounts. */ -	if( acc->gc ) +	if( set->flags & ACC_SET_OFFLINE_ONLY && acc->gc )  		return NULL;  	if( strcmp( set->key, "username" ) == 0 ) @@ -648,57 +648,56 @@ void irc_write_all( int now, char *format, ... )  void irc_names( irc_t *irc, char *channel )  { -	user_t *u = irc->users; -	char *s; -	int control = ( g_strcasecmp( channel, irc->channel ) == 0 ); +	user_t *u; +	char namelist[385] = "";  	struct conversation *c = NULL; -	if( !control ) -		c = conv_findchannel( channel ); -	  	/* RFCs say there is no error reply allowed on NAMES, so when the  	   channel is invalid, just give an empty reply. */ -	if( control || c ) while( u ) +	if( g_strcasecmp( channel, irc->channel ) == 0 )  	{ -		if( u->online ) +		for( u = irc->users; u; u = u->next ) if( u->online )  		{ -			if( u->gc && control ) +			if( strlen( namelist ) + strlen( u->nick ) > sizeof( namelist ) - 4 )  			{ -				if( set_getint( &irc->set, "away_devoice" ) && !u->away ) -					s = "+"; -				else -					s = ""; -				 -				irc_reply( irc, 353, "= %s :%s%s", channel, s, u->nick ); -			} -			else if( !u->gc ) -			{ -				if( strcmp( u->nick, irc->mynick ) == 0 && ( strcmp( set_getstr( &irc->set, "ops" ), "root" ) == 0 || strcmp( set_getstr( &irc->set, "ops" ), "both" ) == 0 ) ) -					s = "@"; -				else if( strcmp( u->nick, irc->nick ) == 0 && ( strcmp( set_getstr( &irc->set, "ops" ), "user" ) == 0 || strcmp( set_getstr( &irc->set, "ops" ), "both" ) == 0 ) ) -					s = "@"; -				else -					s = ""; -				 -				irc_reply( irc, 353, "= %s :%s%s", channel, s, u->nick ); +				irc_reply( irc, 353, "= %s :%s", channel, namelist ); +				*namelist = 0;  			} +			 +			if( u->gc && !u->away && set_getbool( &irc->set, "away_devoice" ) ) +				strcat( namelist, "+" ); +			 +			strcat( namelist, u->nick ); +			strcat( namelist, " " );  		} -		 -		u = u->next;  	} -	 -	/* For non-controlchannel channels (group conversations) only root and -	   you are listed now. Time to show the channel people: */ -	if( !control && c ) +	else if( ( c = conv_findchannel( channel ) ) )  	{  		GList *l; +		char *ops = set_getstr( &irc->set, "ops" ); -		for( l = c->in_room; l; l = l->next ) -			if( ( u = user_findhandle( c->gc, l->data ) ) ) -				irc_reply( irc, 353, "= %s :%s%s", channel, "", u->nick ); +		/* root and the user aren't in the channel userlist but should +		   show up in /NAMES, so list them first: */ +		sprintf( namelist, "%s%s %s%s ", strcmp( ops, "root" ) == 0 || strcmp( ops, "both" ) ? "@" : "", irc->mynick, +		                                 strcmp( ops, "user" ) == 0 || strcmp( ops, "both" ) ? "@" : "", irc->nick ); +		 +		for( l = c->in_room; l; l = l->next ) if( ( u = user_findhandle( c->gc, l->data ) ) ) +		{ +			if( strlen( namelist ) + strlen( u->nick ) > sizeof( namelist ) - 4 ) +			{ +				irc_reply( irc, 353, "= %s :%s", channel, namelist ); +				*namelist = 0; +			} +			 +			strcat( namelist, u->nick ); +			strcat( namelist, " " ); +		}  	} +	if( *namelist ) +		irc_reply( irc, 353, "= %s :%s", channel, namelist ); +	  	irc_reply( irc, 366, "%s :End of /NAMES list", channel );  } @@ -44,6 +44,7 @@ set_t *set_add( set_t **head, char *key, char *def, void *eval, void *data );  set_t *set_find( set_t **head, char *key );  G_MODULE_EXPORT char *set_getstr( set_t **head, char *key );  G_MODULE_EXPORT int set_getint( set_t **head, char *key ); +G_MODULE_EXPORT int set_getbool( set_t **head, char *key );  int set_setstr( set_t **head, char *key, char *value );  int set_setint( set_t **head, char *key, int value );  void set_del( set_t **head, char *key ); | 
