diff options
| author | 2022-11-27 20:14:03 +0200 | |
|---|---|---|
| committer | 2022-11-27 20:14:03 +0200 | |
| commit | 8f2f188cee48096aebf5b7aeff04d632643dc7be (patch) | |
| tree | 16081bf177e3db8df4f42da0085201bcd453b187 | |
| parent | fix: Validate filter list before initiating filter add (diff) | |
fix: Handle uncached messages in filter editing
This also increases the cache size to increase the chances of ignoring filters. Since it's newest first and the antispam uses take_while, it doesn't slow down the antispam.
| -rw-r--r-- | bot/exts/filtering/_filter_lists/filter_list.py | 9 | ||||
| -rw-r--r-- | bot/exts/filtering/filtering.py | 2 | 
2 files changed, 6 insertions, 5 deletions
| diff --git a/bot/exts/filtering/_filter_lists/filter_list.py b/bot/exts/filtering/_filter_lists/filter_list.py index c829f4a8f..64c96d350 100644 --- a/bot/exts/filtering/_filter_lists/filter_list.py +++ b/bot/exts/filtering/_filter_lists/filter_list.py @@ -105,10 +105,11 @@ class AtomicList:          if ctx.event == Event.MESSAGE_EDIT and ctx.message and self.list_type == ListType.DENY:              previously_triggered = ctx.message_cache.get_message_metadata(ctx.message.id) -            ignore_filters = previously_triggered[self] -            # This updates the cache. Some filters are ignored, but they're necessary if there's another edit. -            previously_triggered[self] = relevant_filters -            if previously_triggered and self in previously_triggered: +            # The message might not be cached. +            if previously_triggered: +                ignore_filters = previously_triggered[self] +                # This updates the cache. Some filters are ignored, but they're necessary if there's another edit. +                previously_triggered[self] = relevant_filters                  relevant_filters = [filter_ for filter_ in relevant_filters if filter_ not in ignore_filters]          return relevant_filters diff --git a/bot/exts/filtering/filtering.py b/bot/exts/filtering/filtering.py index 4f4cda611..3fb627a82 100644 --- a/bot/exts/filtering/filtering.py +++ b/bot/exts/filtering/filtering.py @@ -50,7 +50,7 @@ from bot.utils.message_cache import MessageCache  log = get_logger(__name__)  WEBHOOK_ICON_URL = r"https://github.com/python-discord/branding/raw/main/icons/filter/filter_pfp.png" -CACHE_SIZE = 100 +CACHE_SIZE = 1000  HOURS_BETWEEN_NICKNAME_ALERTS = 1  OFFENSIVE_MSG_DELETE_TIME = datetime.timedelta(days=7)  WEEKLY_REPORT_ISO_DAY = 3  # 1=Monday, 7=Sunday | 
