diff --git a/root_commands.c b/root_commands.c index a7b626b..be4282e 100644 --- a/root_commands.c +++ b/root_commands.c @@ -1242,15 +1242,45 @@ static void cmd_group( irc_t *irc, char **cmd ) { int n = 0; - if( strchr( irc->umode, 'b' ) ) - irc_usermsg( irc, "Group list:" ); - - for( l = irc->b->groups; l; l = l->next ) + if( cmd[2] == NULL ) + { + if( strchr( irc->umode, 'b' ) ) + irc_usermsg( irc, "Group list:" ); + + for( l = irc->b->groups; l; l = l->next ) + { + bee_group_t *bg = l->data; + irc_usermsg( irc, "%d. %s", n ++, bg->name ); + } + + irc_usermsg( irc, "End of group list" ); + } + else { - bee_group_t *bg = l->data; - irc_usermsg( irc, "%d. %s", n ++, bg->name ); + bee_group_t *bg = NULL; + for( l = irc->b->groups; l; l = l->next ) + { + if( !strcmp( ((bee_group_t *)l->data)->name, cmd[2] ) ) + { + bg = l->data; + break; + } + } + if (bg) + { + if( strchr( irc->umode, 'b' ) ) + irc_usermsg( irc, "Members of %s:", cmd[2] ); + for( l = irc->b->users; l; l = l->next ) + { + bee_user_t *bu = l->data; + if( bu->group == bg ) + irc_usermsg( irc, "%d. %s", n ++, bu->nick ? : bu->handle ); + } + irc_usermsg( irc, "End of member list" ); + } + else + irc_usermsg( irc, "Unknown group: %s. Please use \x02group list\x02 to get a list of available groups.", cmd[2] ); } - irc_usermsg( irc, "End of group list" ); } else {