Initialisation du repository de Beta
This commit is contained in:
commit
14985f6dbb
9469 changed files with 1903273 additions and 0 deletions
46
superviseur/heuristic.py
Normal file
46
superviseur/heuristic.py
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
def _assess_heuristic_risk(self, message) -> bool:
|
||||
"""
|
||||
Fast Python-side risk assessment to decide if we should AI-analyze fully.
|
||||
Returns True if message is 'risky' enough to warrant LLM usage.
|
||||
"""
|
||||
score = 0
|
||||
content = message.content
|
||||
|
||||
# 1. Social Score Factor (Base scrutiny)
|
||||
# If user is Suspect (<40), we start with higher risk score
|
||||
social_data = self.social_manager.get_user_data(message.author.id)
|
||||
reliability = social_data.get('score', 50)
|
||||
|
||||
if reliability < 30: score += 40 # Very suspicious user -> almost auto-check
|
||||
elif reliability < 50: score += 20
|
||||
|
||||
# 2. Pattern Matching (Fast Regex/Keywords)
|
||||
content_lower = content.lower()
|
||||
|
||||
# CAPS LOCK detection (> 60% caps on long messages)
|
||||
if len(content) > 10:
|
||||
caps_ratio = sum(1 for c in content if c.isupper()) / len(content)
|
||||
if caps_ratio > 0.6: score += 30
|
||||
|
||||
# Profanity / Trigger words (lightweight list)
|
||||
triggers = ["raid", "hack", "pute", "connard", "fdp", "tg", "merde", "nazi", "hitler", "suicide", "bomb", "token", "grab", "nitro", "steam", "discord.gift", "free", "@everyone", "@here"]
|
||||
for t in triggers:
|
||||
if t in content_lower:
|
||||
score += 50
|
||||
break
|
||||
|
||||
# Link spam detection
|
||||
if "http" in content_lower:
|
||||
score += 15
|
||||
|
||||
# Length anomaly (very long messages often rants)
|
||||
if len(content) > 400:
|
||||
score += 20
|
||||
|
||||
# 3. Mention Spam
|
||||
if len(message.mentions) > 3:
|
||||
score += 40
|
||||
|
||||
# Threshold decision
|
||||
# If score > 45, we analyze.
|
||||
return score >= 45
|
||||
Loading…
Add table
Add a link
Reference in a new issue