aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--bot/rules/links.py16
-rw-r--r--config-default.yml2
2 files changed, 14 insertions, 4 deletions
diff --git a/bot/rules/links.py b/bot/rules/links.py
index dfeb38c61..fa4043fcb 100644
--- a/bot/rules/links.py
+++ b/bot/rules/links.py
@@ -20,9 +20,19 @@ async def apply(
for msg in recent_messages
if msg.author == last_message.author
)
- total_links = sum(len(LINK_RE.findall(msg.content)) for msg in relevant_messages)
-
- if total_links > config['max']:
+ total_links = 0
+ messages_with_links = 0
+
+ for msg in relevant_messages:
+ total_matches = len(LINK_RE.findall(msg.content))
+ if total_matches:
+ messages_with_links += 1
+ total_links += total_matches
+
+ # Only apply the filter if we found more than one message with
+ # links to prevent wrongfully firing the rule on users posting
+ # e.g. an installation log of pip packages from GitHub.
+ if total_links > config['max'] and messages_with_links > 1:
return (
f"sent {total_links} links in {config['interval']}s",
(last_message.author,),
diff --git a/config-default.yml b/config-default.yml
index 046c1ea56..c04571482 100644
--- a/config-default.yml
+++ b/config-default.yml
@@ -288,7 +288,7 @@ anti_spam:
links:
interval: 10
- max: 20
+ max: 10
mentions:
interval: 10