Changeset bb151f7 for irc_channel.c


Ignore:
Timestamp:
2010-11-20T20:25:44Z (13 years ago)
Author:
Wilmer van der Gaast <wilmer@…>
Branches:
master
Children:
748bcdd
Parents:
d68365c
Message:

Added irc_channel_with_user() function to find a suitable channel to show
a user's message in, instead of just &bitlbee by default.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • irc_channel.c

    rd68365c rbb151f7  
    287287                if( icu->iu == iu )
    288288                        return icu;
     289        }
     290       
     291        return NULL;
     292}
     293
     294/* Find a channel we're currently in, that currently has iu in it. */
     295struct irc_channel *irc_channel_with_user( irc_t *irc, irc_user_t *iu )
     296{
     297        GSList *l;
     298       
     299        for( l = irc->channels; l; l = l->next )
     300        {
     301                irc_channel_t *ic = l->data;
     302               
     303                if( strcmp( set_getstr( &ic->set, "type" ), "control" ) != 0 )
     304                        continue;
     305               
     306                if( ( ic->flags & IRC_CHANNEL_JOINED ) &&
     307                    irc_channel_has_user( ic, iu ) )
     308                        return ic;
     309        }
     310       
     311        /* If there was no match, try once more but just see if the user
     312           *would* be in the channel, i.e. if s/he were online. */
     313        if( iu->bu == NULL )
     314                return NULL;
     315       
     316        for( l = irc->channels; l; l = l->next )
     317        {
     318                irc_channel_t *ic = l->data;
     319               
     320                if( strcmp( set_getstr( &ic->set, "type" ), "control" ) != 0 )
     321                        continue;
     322               
     323                if( ( ic->flags & IRC_CHANNEL_JOINED ) &&
     324                    irc_channel_wants_user( ic, iu ) )
     325                        return ic;
    289326        }
    290327       
Note: See TracChangeset for help on using the changeset viewer.