From 27ceadbff36088a47d48e7417b69f26dbc44d3f9 Mon Sep 17 00:00:00 2001 From: Timo Sirainen Date: Mon, 14 May 2001 17:35:24 +0000 Subject: /UNBAN now supports unbanning multiple bans with ban# (/unban 1 4 6) git-svn-id: http://svn.irssi.org/repos/irssi/trunk@1496 dbcabf3a-b0e7-0310-adc4-f8d773084564 --- src/irc/core/bans.c | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) (limited to 'src/irc/core/bans.c') diff --git a/src/irc/core/bans.c b/src/irc/core/bans.c index 0932f640..96fe0673 100644 --- a/src/irc/core/bans.c +++ b/src/irc/core/bans.c @@ -117,16 +117,28 @@ void ban_remove(IRC_CHANNEL_REC *channel, const char *bans) GString *str; GSList *tmp; char **ban, **banlist; + int found; g_return_if_fail(bans != NULL); str = g_string_new(NULL); banlist = g_strsplit(bans, " ", -1); for (ban = banlist; *ban != NULL; ban++) { + found = FALSE; for (tmp = channel->banlist; tmp != NULL; tmp = tmp->next) { BAN_REC *rec = tmp->data; - if (match_wildcards(*ban, rec->ban)) + if (match_wildcards(*ban, rec->ban)) { + g_string_sprintfa(str, "%s ", rec->ban); + found = TRUE; + } + } + + if (!found && is_numeric(*ban, '\0')) { + /* unbanning with ban# */ + BAN_REC *rec = g_slist_nth_data(channel->banlist, + atoi(*ban)-1); + if (rec != NULL) g_string_sprintfa(str, "%s ", rec->ban); } } @@ -167,17 +179,8 @@ static void command_set_ban(const char *data, IRC_SERVER_REC *server, if (set) ban_set(chanrec, nicks, ban_type); - else { - if (is_numeric(nicks, '\0')) { - /* unban with ban number */ - BAN_REC *ban = g_slist_nth_data(chanrec->banlist, - atoi(nicks)-1); - if (ban != NULL) - nicks = ban->ban; - } - + else ban_remove(chanrec, nicks); - } cmd_params_free(free_arg); } -- cgit v1.2.3