diff options
-rw-r--r-- | src/irc/core/mode-lists.c | 40 |
1 files changed, 24 insertions, 16 deletions
diff --git a/src/irc/core/mode-lists.c b/src/irc/core/mode-lists.c index 8d0a9eab..d7fef183 100644 --- a/src/irc/core/mode-lists.c +++ b/src/irc/core/mode-lists.c @@ -44,6 +44,22 @@ void banlist_free(GSList *banlist) ban_free(&banlist, banlist->data); } +static BAN_REC *banlist_find(GSList *list, const char *ban) +{ + GSList *tmp; + + g_return_val_if_fail(ban != NULL, NULL); + + for (tmp = list; tmp != NULL; tmp = tmp->next) { + BAN_REC *rec = tmp->data; + + if (g_strcasecmp(rec->ban, ban) == 0) + return rec; + } + + return NULL; +} + BAN_REC *banlist_add(IRC_CHANNEL_REC *channel, const char *ban, const char *nick, time_t time) { @@ -52,6 +68,14 @@ BAN_REC *banlist_add(IRC_CHANNEL_REC *channel, const char *ban, g_return_val_if_fail(channel != NULL, NULL); g_return_val_if_fail(ban != NULL, NULL); + rec = banlist_find(channel->banlist, ban); + if (rec != NULL) { + /* duplicate - ignore. some servers send duplicates + for non-ops because they just replace the hostname with + eg. "localhost"... */ + return NULL; + } + rec = g_new(BAN_REC, 1); rec->ban = g_strdup(ban); rec->setby = nick == NULL || *nick == '\0' ? NULL : @@ -64,22 +88,6 @@ BAN_REC *banlist_add(IRC_CHANNEL_REC *channel, const char *ban, return rec; } -static BAN_REC *banlist_find(GSList *list, const char *ban) -{ - GSList *tmp; - - g_return_val_if_fail(ban != NULL, NULL); - - for (tmp = list; tmp != NULL; tmp = tmp->next) { - BAN_REC *rec = tmp->data; - - if (g_strcasecmp(rec->ban, ban) == 0) - return rec; - } - - return NULL; -} - void banlist_remove(IRC_CHANNEL_REC *channel, const char *ban) { BAN_REC *rec; |