Changeset c5aefa4 for irc_channel.c


Ignore:
Timestamp:
2010-06-07T15:39:53Z (9 years ago)
Author:
Wilmer van der Gaast <wilmer@…>
Branches:
master
Children:
70f69ecc
Parents:
0e8b3e8
Message:

Restore "ops" command completely, and set user op status *just* before
s/he joins.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • irc_channel.c

    r0e8b3e8 rc5aefa4  
    4545       
    4646        irc_channel_add_user( ic, irc->root );
    47         if( strcmp( set_getstr( &irc->b->set, "ops" ), "both" ) == 0 ||
    48             strcmp( set_getstr( &irc->b->set, "ops" ), "root" ) == 0 )
    49                 irc_channel_user_set_mode( ic, irc->root, IRC_CHANNEL_USER_OP );
    5047       
    5148        irc->channels = g_slist_append( irc->channels, ic );
     
    173170        ic->users = g_slist_insert_sorted( ic->users, icu, irc_channel_user_cmp );
    174171       
     172        irc_channel_update_ops( ic, set_getstr( &ic->irc->b->set, "ops" ) );
     173       
    175174        if( iu == ic->irc->user || ic->flags & IRC_CHANNEL_JOINED )
    176175        {
     
    239238        irc_channel_user_t *icu = irc_channel_has_user( ic, iu );
    240239       
    241         if( icu->flags == flags )
     240        if( !icu || icu->flags == flags )
    242241                return;
    243242       
     
    282281       
    283282        return irc_user_cmp( a->iu, b->iu );
     283}
     284
     285void irc_channel_update_ops( irc_channel_t *ic, char *value )
     286{
     287        irc_channel_user_set_mode( ic, ic->irc->root,
     288                ( strcmp( value, "both" ) == 0 ||
     289                  strcmp( value, "root" ) == 0 ) ? IRC_CHANNEL_USER_OP : 0 );
     290        irc_channel_user_set_mode( ic, ic->irc->user,
     291                ( strcmp( value, "both" ) == 0 ||
     292                  strcmp( value, "user" ) == 0 ) ? IRC_CHANNEL_USER_OP : 0 );
     293}
     294
     295char *set_eval_irc_channel_ops( set_t *set, char *value )
     296{
     297        irc_t *irc = set->data;
     298        GSList *l;
     299       
     300        if( strcmp( value, "both" ) != 0 && strcmp( value, "none" ) != 0 &&
     301            strcmp( value, "user" ) != 0 && strcmp( value, "root" ) != 0 )
     302                return SET_INVALID;
     303       
     304        for( l = irc->channels; l; l = l->next )
     305                irc_channel_update_ops( l->data, value );
     306       
     307        return value;
    284308}
    285309
Note: See TracChangeset for help on using the changeset viewer.