From 699cd16ae146dec1f075282b27bf443f55cc94c4 Mon Sep 17 00:00:00 2001 From: duogenesis <136373989+duogenesis@users.noreply.github.com> Date: Tue, 24 Dec 2024 10:21:42 +1100 Subject: [PATCH] Moderation (#566) --- banned-club.sql | 2 ++ service/chat/__init__.py | 2 +- service/chat/offensive/__init__.py | 9 ++++++++- service/chat/offensive/test_init.py | 3 +++ test/functionality4/xmpp-rate-limit.sh | 2 +- 5 files changed, 15 insertions(+), 3 deletions(-) diff --git a/banned-club.sql b/banned-club.sql index 7a23b29..6d96c36 100644 --- a/banned-club.sql +++ b/banned-club.sql @@ -2514,6 +2514,8 @@ VALUES ('shedtwt'), ('she''s mine now bitch'), ('she took the fucking kids'), + ('shit skin'), + ('shitskin'), ('shooter'), ('shoot me'), ('shota'), diff --git a/service/chat/__init__.py b/service/chat/__init__.py index 1520664..076f021 100644 --- a/service/chat/__init__.py +++ b/service/chat/__init__.py @@ -33,7 +33,7 @@ PORT = sys.argv[1] if len(sys.argv) >= 2 else 5443 -MAX_INTROS_PER_DAY = 35 +MAX_INTROS_PER_DAY = 50 # TODO: Tables to migrate to monolithic DB: # diff --git a/service/chat/offensive/__init__.py b/service/chat/offensive/__init__.py index a29933d..4d13f81 100644 --- a/service/chat/offensive/__init__.py +++ b/service/chat/offensive/__init__.py @@ -21,6 +21,7 @@ "c+v+m+": "cum", "c0ck": "cock", "c0cksucker": "cocksucker", + "cok": "cock", "cvmming": "cumming", "cvms": "cums", "cvmshot": "cumshot", @@ -43,11 +44,13 @@ "p0rn": "porn", "pissin": "pissing", "r": "are", + "sxy": "sexy", "u": "you", "ur": "your", "urself": "yourself", "wh0re": "whore", "wh0res": "whores", + "a[s5$]{2}": "ass", } @@ -204,6 +207,7 @@ "foot job", "footjob", "fuck you", + "fuck your ass", "fuck your asshole", "fuck your brains out", "fuck your face", @@ -244,6 +248,7 @@ "hit it raw", "hoe", "hoes", + "homo", "horniest", "horny", "hotsex", @@ -376,8 +381,10 @@ "shag", "shagging", "shemale", + "shit skin", "shitdick", "shitfuck", + "shitskin", "shota", "shotacon", "skank", @@ -516,7 +523,7 @@ def _normalize_spelling(haystack: str): for needle, replacement in _normalization_map.items(): # Apparently compiled regexes are cached between invocations of # re.compile. - pattern = re.compile(f"\\b{needle}\\b", re.IGNORECASE) + pattern = re.compile(f"(?:(?<=^)|(?<=\s)){needle}(?=\s|$)", re.IGNORECASE) haystack = pattern.sub(replacement, haystack) diff --git a/service/chat/offensive/test_init.py b/service/chat/offensive/test_init.py index 19c09ca..c1c60ee 100644 --- a/service/chat/offensive/test_init.py +++ b/service/chat/offensive/test_init.py @@ -4,6 +4,9 @@ class TestIsOffensive(unittest.TestCase): def test_offensive_strings(self): + self.assertTrue( + is_offensive("fuk your as$")) + self.assertTrue( is_offensive("go fk urself please")) diff --git a/test/functionality4/xmpp-rate-limit.sh b/test/functionality4/xmpp-rate-limit.sh index 31d3c20..4c74d41 100755 --- a/test/functionality4/xmpp-rate-limit.sh +++ b/test/functionality4/xmpp-rate-limit.sh @@ -6,7 +6,7 @@ cd "$script_dir" source ../util/setup.sh mapfile -t greetings < ../fixtures/greetings.txt -max_intros_per_day=35 +max_intros_per_day=50 set -xe