diff options
author | Wilmer van der Gaast <wilmer@gaast.net> | 2010-06-07 16:39:53 +0100 |
---|---|---|
committer | Wilmer van der Gaast <wilmer@gaast.net> | 2010-06-07 16:39:53 +0100 |
commit | c5aefa4463135b3f8720785804fe183817829b00 (patch) | |
tree | 8b09b772da29b8832643645e909acce5fe17963a /irc_channel.c | |
parent | 0e8b3e855dfa370fe559729224b3bff1d4cf5b87 (diff) |
Restore "ops" command completely, and set user op status *just* before
s/he joins.
Diffstat (limited to 'irc_channel.c')
-rw-r--r-- | irc_channel.c | 32 |
1 files changed, 28 insertions, 4 deletions
diff --git a/irc_channel.c b/irc_channel.c index 8abc0486..d98d0652 100644 --- a/irc_channel.c +++ b/irc_channel.c @@ -44,9 +44,6 @@ irc_channel_t *irc_channel_new( irc_t *irc, const char *name ) strcpy( ic->mode, CMODE ); irc_channel_add_user( ic, irc->root ); - if( strcmp( set_getstr( &irc->b->set, "ops" ), "both" ) == 0 || - strcmp( set_getstr( &irc->b->set, "ops" ), "root" ) == 0 ) - irc_channel_user_set_mode( ic, irc->root, IRC_CHANNEL_USER_OP ); irc->channels = g_slist_append( irc->channels, ic ); @@ -172,6 +169,8 @@ int irc_channel_add_user( irc_channel_t *ic, irc_user_t *iu ) ic->users = g_slist_insert_sorted( ic->users, icu, irc_channel_user_cmp ); + irc_channel_update_ops( ic, set_getstr( &ic->irc->b->set, "ops" ) ); + if( iu == ic->irc->user || ic->flags & IRC_CHANNEL_JOINED ) { ic->flags |= IRC_CHANNEL_JOINED; @@ -238,7 +237,7 @@ void irc_channel_user_set_mode( irc_channel_t *ic, irc_user_t *iu, irc_channel_u { irc_channel_user_t *icu = irc_channel_has_user( ic, iu ); - if( icu->flags == flags ) + if( !icu || icu->flags == flags ) return; if( ic->flags & IRC_CHANNEL_JOINED ) @@ -283,6 +282,31 @@ static gint irc_channel_user_cmp( gconstpointer a_, gconstpointer b_ ) return irc_user_cmp( a->iu, b->iu ); } +void irc_channel_update_ops( irc_channel_t *ic, char *value ) +{ + irc_channel_user_set_mode( ic, ic->irc->root, + ( strcmp( value, "both" ) == 0 || + strcmp( value, "root" ) == 0 ) ? IRC_CHANNEL_USER_OP : 0 ); + irc_channel_user_set_mode( ic, ic->irc->user, + ( strcmp( value, "both" ) == 0 || + strcmp( value, "user" ) == 0 ) ? IRC_CHANNEL_USER_OP : 0 ); +} + +char *set_eval_irc_channel_ops( set_t *set, char *value ) +{ + irc_t *irc = set->data; + GSList *l; + + if( strcmp( value, "both" ) != 0 && strcmp( value, "none" ) != 0 && + strcmp( value, "user" ) != 0 && strcmp( value, "root" ) != 0 ) + return SET_INVALID; + + for( l = irc->channels; l; l = l->next ) + irc_channel_update_ops( l->data, value ); + + return value; +} + /* Channel-type dependent functions, for control channels: */ static gboolean control_channel_privmsg( irc_channel_t *ic, const char *msg ) { |