Changeset 3f9440d
- Timestamp:
- 2006-06-26T21:50:12Z (18 years ago)
- Branches:
- master
- Children:
- bf25fa3, fef6116
- Parents:
- 2f13222
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
irc.c
r2f13222 r3f9440d 649 649 void irc_names( irc_t *irc, char *channel ) 650 650 { 651 user_t *u = irc->users; 652 char *s; 653 int control = ( g_strcasecmp( channel, irc->channel ) == 0 ); 651 user_t *u; 652 char namelist[385] = ""; 654 653 struct conversation *c = NULL; 655 656 if( !control )657 c = conv_findchannel( channel );658 654 659 655 /* RFCs say there is no error reply allowed on NAMES, so when the 660 656 channel is invalid, just give an empty reply. */ 661 657 662 if( control || c ) while( u)663 { 664 if( u->online )665 { 666 if( u->gc && control)658 if( g_strcasecmp( channel, irc->channel ) == 0 ) 659 { 660 for( u = irc->users; u; u = u->next ) if( u->online ) 661 { 662 if( strlen( namelist ) + strlen( u->nick ) > sizeof( namelist ) - 4 ) 667 663 { 668 if( set_getint( irc, "away_devoice" ) && !u->away ) 669 s = "+"; 670 else 671 s = ""; 672 673 irc_reply( irc, 353, "= %s :%s%s", channel, s, u->nick ); 664 irc_reply( irc, 353, "= %s :%s", channel, namelist ); 665 *namelist = 0; 674 666 } 675 else if( !u->gc ) 667 668 if( u->gc && !u->away && set_getint( irc, "away_devoice" ) ) 669 strcat( namelist, "+" ); 670 671 strcat( namelist, u->nick ); 672 strcat( namelist, " " ); 673 } 674 } 675 else if( ( c = conv_findchannel( channel ) ) ) 676 { 677 GList *l; 678 char *ops = set_getstr( irc, "ops" ); 679 680 /* root and the user aren't in the channel userlist but should 681 show up in /NAMES, so list them first: */ 682 sprintf( namelist, "%s%s %s%s ", strcmp( ops, "root" ) == 0 || strcmp( ops, "both" ) ? "@" : "", irc->mynick, 683 strcmp( ops, "user" ) == 0 || strcmp( ops, "both" ) ? "@" : "", irc->nick ); 684 685 for( l = c->in_room; l; l = l->next ) if( ( u = user_findhandle( c->gc, l->data ) ) ) 686 { 687 if( strlen( namelist ) + strlen( u->nick ) > sizeof( namelist ) - 4 ) 676 688 { 677 if( strcmp( u->nick, irc->mynick ) == 0 && ( strcmp( set_getstr( irc, "ops" ), "root" ) == 0 || strcmp( set_getstr( irc, "ops" ), "both" ) == 0 ) ) 678 s = "@"; 679 else if( strcmp( u->nick, irc->nick ) == 0 && ( strcmp( set_getstr( irc, "ops" ), "user" ) == 0 || strcmp( set_getstr( irc, "ops" ), "both" ) == 0 ) ) 680 s = "@"; 681 else 682 s = ""; 683 684 irc_reply( irc, 353, "= %s :%s%s", channel, s, u->nick ); 689 irc_reply( irc, 353, "= %s :%s", channel, namelist ); 690 *namelist = 0; 685 691 } 686 } 687 688 u = u->next; 689 } 690 691 /* For non-controlchannel channels (group conversations) only root and 692 you are listed now. Time to show the channel people: */ 693 if( !control && c ) 694 { 695 GList *l; 696 697 for( l = c->in_room; l; l = l->next ) 698 if( ( u = user_findhandle( c->gc, l->data ) ) ) 699 irc_reply( irc, 353, "= %s :%s%s", channel, "", u->nick ); 700 } 692 693 strcat( namelist, u->nick ); 694 strcat( namelist, " " ); 695 } 696 } 697 698 if( *namelist ) 699 irc_reply( irc, 353, "= %s :%s", channel, namelist ); 701 700 702 701 irc_reply( irc, 366, "%s :End of /NAMES list", channel );
Note: See TracChangeset
for help on using the changeset viewer.