diff options
author | 2019-11-14 20:15:32 +0100 | |
---|---|---|
committer | 2019-11-14 20:15:32 +0100 | |
commit | 54598dd769b320a4284594835c15eabf9875b7aa (patch) | |
tree | 97e235b6f640ddf79abbcba554ac8f8118de746e | |
parent | Use async_test helper to simplify coro testing (diff) |
Fix bug in attachments rule where last_message could potentially count twice in the sum of attachments
-rw-r--r-- | bot/rules/attachments.py | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/bot/rules/attachments.py b/bot/rules/attachments.py index c550aed76..00bb2a949 100644 --- a/bot/rules/attachments.py +++ b/bot/rules/attachments.py @@ -7,14 +7,14 @@ async def apply( last_message: Message, recent_messages: List[Message], config: Dict[str, int] ) -> Optional[Tuple[str, Iterable[Member], Iterable[Message]]]: """Detects total attachments exceeding the limit sent by a single user.""" - relevant_messages = [last_message] + [ + relevant_messages = tuple( msg for msg in recent_messages if ( msg.author == last_message.author and len(msg.attachments) > 0 ) - ] + ) total_recent_attachments = sum(len(msg.attachments) for msg in relevant_messages) if total_recent_attachments > config['max']: |