Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions agent/engines/twitter/reply_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import re
import time
from typing import List, Tuple
from unicodedata import normalize

from engines.memory.significance_scorer import SignificanceScorer
from engines.twitter.post_maker import PostMaker
Expand Down Expand Up @@ -89,15 +90,12 @@ def _handle_replies(self, external_context: List[Tuple[str, str]]) -> None:

def is_spam(self, content: str) -> bool:
"""Check if content appears to be spam."""
import re
from unicodedata import normalize

# Normalize more aggressively: remove all whitespace, symbols, zero-width chars
clean = re.sub(r'[\s\.\-_\|\\/\(\)\[\]\u200b-\u200f\u2060\ufeff]+', '',
clean = re.sub(r'[\s\.\-_\|\\/\(\)\[\]\u200b-\u200f\u2060\ufeff]+', '',
normalize('NFKC', content.lower()))

patterns = [
r'[\$\€\¢\£\¥]|(?:usd[t]?|usdc|busd)',
r'[\$\€\¢\£\¥]|(?:usd[t]?|usdc|busd)',
r'(?:ca|с[aа]|market.?cap)[:\|/]?(?:\d|soon)',
r't[i1І]ck[e3Е]r|symb[o0]l|(?:trading|list).?pairs?',
r'p[uüūи][mм]p|рuмр|ⓟⓤⓜⓟ|accumulate',
Expand All @@ -116,3 +114,4 @@ def is_spam(self, content: str) -> bool:
r'(?:early|earlybird|early.?access)',
r'(?:t\.me|discord\.gg|dex\.tools)',
]
return any(re.search(pattern, clean) for pattern in patterns)