diff options
| author | 2020-06-11 08:22:01 +0300 | |
|---|---|---|
| committer | 2020-06-11 08:22:01 +0300 | |
| commit | c4acae166fa04b0e47a6faa5e454a1de8beba6b7 (patch) | |
| tree | b881b1c7dd6c0b5ffcd603c17ce1b03a9ba21df7 | |
| parent | Filtering: Fix nickname filter alert sending spaces (diff) | |
Filtering: Use walrus for better looking of code
Diffstat (limited to '')
| -rw-r--r-- | bot/cogs/filtering.py | 6 | 
1 files changed, 2 insertions, 4 deletions
diff --git a/bot/cogs/filtering.py b/bot/cogs/filtering.py index ff915ea2c..841f735e3 100644 --- a/bot/cogs/filtering.py +++ b/bot/cogs/filtering.py @@ -141,15 +141,13 @@ class Filtering(Cog):          """Check bad words from passed string (name). Return list of matches."""          matches = []          for pattern in WATCHLIST_PATTERNS: -            match = pattern.search(name) -            if match: +            if match := pattern.search(name):                  matches.append(match)          return matches      async def check_send_alert(self, member: Member) -> bool:          """When there is less than 3 days after last alert, return `False`, otherwise `True`.""" -        last_alert = await self.name_alerts.get(member.id) -        if last_alert: +        if last_alert := await self.name_alerts.get(member.id):              last_alert = datetime.utcfromtimestamp(last_alert)              if datetime.utcnow() - timedelta(days=DAYS_BETWEEN_ALERTS) < last_alert:                  log.trace(f"Last alert was too recent for {member}'s nickname.")  |