diff options
| author | 2018-07-30 18:33:20 +0200 | |
|---|---|---|
| committer | 2018-07-30 18:33:20 +0200 | |
| commit | 683a903d5c4124e00cf8febb6df4c89d1ca16595 (patch) | |
| tree | ca53938f888e40c34c88898dcfab7fae1e8f5a77 | |
| parent | Case insensitive URL filtering (diff) | |
Addressing all review comments from gdude
| -rw-r--r-- | bot/cogs/filtering.py | 12 | ||||
| -rw-r--r-- | config-default.yml | 2 |
2 files changed, 9 insertions, 5 deletions
diff --git a/bot/cogs/filtering.py b/bot/cogs/filtering.py index c6da923ae..9b9a9999b 100644 --- a/bot/cogs/filtering.py +++ b/bot/cogs/filtering.py @@ -139,7 +139,7 @@ class Filtering: """ for expression in Filter.word_watchlist: - if re.search(fr"\b{expression}\b", text.lower()): + if re.search(fr"\b{expression}\b", text, re.IGNORECASE): return True return False @@ -156,7 +156,7 @@ class Filtering: """ for expression in Filter.token_watchlist: - if re.search(fr"{expression}", text.lower()): + if re.search(fr"{expression}", text, re.IGNORECASE): return True return False @@ -168,11 +168,13 @@ class Filtering: the blacklisted URLs from the config file. """ - if not re.search(URL_RE.lower(), text.lower()): + if not re.search(URL_RE, text, re.IGNORECASE): return False + text = text.lower() + for url in Filter.domain_blacklist: - if url.lower() in text.lower(): + if url.lower() in text: return True return False @@ -204,7 +206,7 @@ class Filtering: # discord\.gg/gdudes-pony-farm text = text.replace("\\", "") - invites = re.findall(INVITE_RE, text) + invites = re.findall(INVITE_RE, text, re.IGNORECASE) for invite in invites: filter_invite = ( diff --git a/config-default.yml b/config-default.yml index 2beb4edbf..17c438a8f 100644 --- a/config-default.yml +++ b/config-default.yml @@ -132,6 +132,7 @@ filter: domain_blacklist: - pornhub.com + - liveleak.com word_watchlist: - goo+ks* @@ -155,6 +156,7 @@ filter: token_watchlist: - fa+g+s* - 卐 + - 卍 - cuck - nigg+(?:e*r+|a+h+?|u+h+)s? - fag+o+t+s* |