Changeset f93fd2d
- Timestamp:
- 2014-07-24T03:51:07Z (10 years ago)
- Branches:
- master
- Children:
- fb87924
- Parents:
- 632627e
- git-author:
- tribut <felix@…> (24-07-14 03:51:07)
- git-committer:
- dequis <dx@…> (24-07-14 03:51:07)
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
doc/user-guide/commands.xml
r632627e rf93fd2d 1790 1790 1791 1791 <bitlbee-command name="blist"> 1792 <syntax>blist [all|online|offline|away] </syntax>1792 <syntax>blist [all|online|offline|away] [<pattern>]</syntax> 1793 1793 <short-description>List all the buddies in the current channel</short-description> 1794 1794 … … 1796 1796 <para> 1797 1797 You can get a more readable buddy list using the <emphasis>blist</emphasis> command. If you want a complete list (including the offline users) you can use the <emphasis>all</emphasis> argument. 1798 </para> 1799 1800 <para> 1801 A perl-compatible regular expression can be supplied as <emphasis>pattern</emphasis> to filter the results (case-insensitive). 1798 1802 </para> 1799 1803 </description> -
root_commands.c
r632627e rf93fd2d 1085 1085 static void cmd_blist( irc_t *irc, char **cmd ) 1086 1086 { 1087 int online = 0, away = 0, offline = 0 ;1087 int online = 0, away = 0, offline = 0, ismatch = 0; 1088 1088 GSList *l; 1089 GRegex *regex = NULL; 1090 GError *error = NULL; 1089 1091 char s[256]; 1090 1092 char *format; … … 1102 1104 online = away = 1; 1103 1105 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 1104 1115 if( strchr( irc->umode, 'b' ) != NULL ) 1105 1116 format = "%s\t%s\t%s"; … … 1118 1129 bee_user_t *bu = iu->bu; 1119 1130 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 ) 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 ) ) ) 1122 1137 continue; 1123 1138 1124 if( online == 1 ) 1125 { 1126 char st[256] = "Online"; 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 } 1127 1151 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 ++; 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 } 1170 1174 } 1171 1175 1172 1176 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 ); 1173 1180 } 1174 1181
Note: See TracChangeset
for help on using the changeset viewer.