aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar ks129 <[email protected]>2020-05-30 16:32:07 +0300
committerGravatar GitHub <[email protected]>2020-05-30 16:32:07 +0300
commit0e12ff189a416127421a878c2421d7f5a369d26e (patch)
treee593b9cc5a204363ab64aa62ca0fd443968a6672
parentFiltering: Refactor bad names checking (diff)
Filtering: Create lock in `__init__`
Move lock creation from `bad_words_in_name` to `__init__`
-rw-r--r--bot/cogs/filtering.py5
1 files changed, 1 insertions, 4 deletions
diff --git a/bot/cogs/filtering.py b/bot/cogs/filtering.py
index 17113d551..c57ab0688 100644
--- a/bot/cogs/filtering.py
+++ b/bot/cogs/filtering.py
@@ -61,7 +61,7 @@ class Filtering(Cog):
def __init__(self, bot: Bot):
self.bot = bot
- self.name_lock: Optional[asyncio.Lock] = None
+ self.name_lock = asyncio.Lock()
staff_mistake_str = "If you believe this was a mistake, please let staff know!"
self.filters = {
@@ -137,9 +137,6 @@ class Filtering(Cog):
async def bad_words_in_name(self, msg: Message) -> None:
"""Check bad words from user display name. When there is more than 3 days after last alert, send new alert."""
- if not self.name_lock:
- self.name_lock = asyncio.Lock()
-
# Use lock to avoid race conditions
async with self.name_lock:
# Check does nickname have match in filters.