aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Chris Lovering <[email protected]>2021-10-18 22:51:31 +0100
committerGravatar Chris Lovering <[email protected]>2021-12-06 23:08:08 +0000
commitbaf8239be8c6a4f6da4bd7ce8f8b2abeaf55e58a (patch)
treeb67b35f0a1590277e6ed870eaece2e1e604ac147
parentNormalise names before checking for matches (diff)
Check if we recently alerted about a bad name before running all filter tokens again
-rw-r--r--bot/exts/filters/filtering.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/bot/exts/filters/filtering.py b/bot/exts/filters/filtering.py
index e51d2aad6..4b1de9638 100644
--- a/bot/exts/filters/filtering.py
+++ b/bot/exts/filters/filtering.py
@@ -237,10 +237,14 @@ class Filtering(Cog):
"""Send a mod alert every 3 days if a username still matches a watchlist pattern."""
# Use lock to avoid race conditions
async with self.name_lock:
+ # Check if we recently alerted about this user first,
+ # to avoid running all the filter tokens against their name again.
+ if not await self.check_send_alert(member):
+ return
+
# Check whether the users display name contains any words in our blacklist
matches = self.get_name_matches(member.display_name)
-
- if not matches or not await self.check_send_alert(member):
+ if not matches:
return
log.info(f"Sending bad nickname alert for '{member.display_name}' ({member.id}).")