Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • root_commands.c

    rf93fd2d r35987a1  
    3232void root_command_string( irc_t *irc, char *command )
    3333{
    34         root_command( irc, split_command_parts( command, 0 ) );
     34        root_command( irc, split_command_parts( command ) );
    3535}
    3636
     
    10851085static void cmd_blist( irc_t *irc, char **cmd )
    10861086{
    1087         int online = 0, away = 0, offline = 0, ismatch = 0;
     1087        int online = 0, away = 0, offline = 0;
    10881088        GSList *l;
    1089         GRegex *regex = NULL;
    1090         GError *error = NULL;
    10911089        char s[256];
    10921090        char *format;
     
    11041102                online = away = 1;
    11051103       
    1106         if( cmd[2] )
    1107                 regex = g_regex_new( cmd[2], G_REGEX_CASELESS, 0, &error );
    1108        
    1109         if( error )
    1110         {
    1111                 irc_rootmsg( irc, error->message );
    1112                 g_error_free( error );
    1113         }
    1114        
    11151104        if( strchr( irc->umode, 'b' ) != NULL )
    11161105                format = "%s\t%s\t%s";
     
    11291118                bee_user_t *bu = iu->bu;
    11301119               
    1131                 if( !regex || g_regex_match( regex, iu->nick, 0, NULL ) )
    1132                         ismatch = 1;
    1133                 else
    1134                         ismatch = 0;
    1135                
    1136                 if( !bu || ( irc->root->last_channel && !irc_channel_wants_user( irc->root->last_channel, iu ) ) )
     1120                if( !bu || ( irc->root->last_channel && !irc_channel_wants_user( irc->root->last_channel, iu ) ) ||
     1121                    ( bu->flags & ( BEE_USER_ONLINE | BEE_USER_AWAY ) ) != BEE_USER_ONLINE )
    11371122                        continue;
    11381123               
    1139                 if( ( bu->flags & ( BEE_USER_ONLINE | BEE_USER_AWAY ) ) == BEE_USER_ONLINE )
    1140                 {
    1141                         if( ismatch == 1 && online == 1 )
    1142                         {
    1143                                 char st[256] = "Online";
    1144                                
    1145                                 if( bu->status_msg )
    1146                                         g_snprintf( st, sizeof( st ) - 1, "Online (%s)", bu->status_msg );
    1147                                
    1148                                 g_snprintf( s, sizeof( s ) - 1, "%s %s", bu->handle, bu->ic->acc->tag );
    1149                                 irc_rootmsg( irc, format, iu->nick, s, st );
    1150                         }
     1124                if( online == 1 )
     1125                {
     1126                        char st[256] = "Online";
    11511127                       
    1152                         n_online ++;
    1153                 }
    1154                
    1155                 if( ( bu->flags & BEE_USER_ONLINE ) && ( bu->flags & BEE_USER_AWAY ) )
    1156                 {
    1157                         if( ismatch == 1 && away == 1 )
    1158                         {
    1159                                 g_snprintf( s, sizeof( s ) - 1, "%s %s", bu->handle, bu->ic->acc->tag );
    1160                                 irc_rootmsg( irc, format, iu->nick, s, irc_user_get_away( iu ) );
    1161                         }
    1162                         n_away ++;
    1163                 }
    1164                
    1165                 if( !(bu->flags & BEE_USER_ONLINE) )
    1166                 {
    1167                         if( ismatch == 1 && offline == 1 )
    1168                         {
    1169                                 g_snprintf( s, sizeof( s ) - 1, "%s %s", bu->handle, bu->ic->acc->tag );
    1170                                 irc_rootmsg( irc, format, iu->nick, s, "Offline" );
    1171                         }
    1172                         n_offline ++;
    1173                 }
     1128                        if( bu->status_msg )
     1129                                g_snprintf( st, sizeof( st ) - 1, "Online (%s)", bu->status_msg );
     1130                       
     1131                        g_snprintf( s, sizeof( s ) - 1, "%s %s", bu->handle, bu->ic->acc->tag );
     1132                        irc_rootmsg( irc, format, iu->nick, s, st );
     1133                }
     1134               
     1135                n_online ++;
     1136        }
     1137
     1138        for( l = irc->users; l; l = l->next )
     1139        {
     1140                irc_user_t *iu = l->data;
     1141                bee_user_t *bu = iu->bu;
     1142               
     1143                if( !bu || ( irc->root->last_channel && !irc_channel_wants_user( irc->root->last_channel, iu ) ) ||
     1144                    !( bu->flags & BEE_USER_ONLINE ) || !( bu->flags & BEE_USER_AWAY ) )
     1145                        continue;
     1146               
     1147                if( away == 1 )
     1148                {
     1149                        g_snprintf( s, sizeof( s ) - 1, "%s %s", bu->handle, bu->ic->acc->tag );
     1150                        irc_rootmsg( irc, format, iu->nick, s, irc_user_get_away( iu ) );
     1151                }
     1152                n_away ++;
     1153        }
     1154       
     1155        for( l = irc->users; l; l = l->next )
     1156        {
     1157                irc_user_t *iu = l->data;
     1158                bee_user_t *bu = iu->bu;
     1159               
     1160                if( !bu || ( irc->root->last_channel && !irc_channel_wants_user( irc->root->last_channel, iu ) ) ||
     1161                    bu->flags & BEE_USER_ONLINE )
     1162                        continue;
     1163               
     1164                if( offline == 1 )
     1165                {
     1166                        g_snprintf( s, sizeof( s ) - 1, "%s %s", bu->handle, bu->ic->acc->tag );
     1167                        irc_rootmsg( irc, format, iu->nick, s, "Offline" );
     1168                }
     1169                n_offline ++;
    11741170        }
    11751171       
    11761172        irc_rootmsg( irc, "%d buddies (%d available, %d away, %d offline)", n_online + n_away + n_offline, n_online, n_away, n_offline );
    1177        
    1178         if( regex )
    1179                 g_regex_unref( regex );
    11801173}
    11811174
Note: See TracChangeset for help on using the changeset viewer.