Skip to content

Commit

Permalink
Moderation 2025-02-11
Browse files Browse the repository at this point in the history
  • Loading branch information
duogenesis committed Feb 11, 2025
1 parent 0b8c9f9 commit 91053fa
Show file tree
Hide file tree
Showing 8 changed files with 54 additions and 17 deletions.
11 changes: 11 additions & 0 deletions antiabuse/antirude/clubname/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from database import api_tx
from sql import Q_IS_ALLOWED_CLUB_NAME

def is_allowed_club_name(club_name: str) -> bool:
q = Q_IS_ALLOWED_CLUB_NAME.replace('%()s', '%(club_name)s')

params = dict(club_name=club_name)

with api_tx() as tx:
row = tx.execute(q, params).fetchone()
return bool(row['is_allowed_club_name'])
12 changes: 1 addition & 11 deletions antiabuse/antirude/displayname/__init__.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,5 @@
from antiabuse.normalize import normalize_string
from database import api_tx
from sql import Q_IS_ALLOWED_CLUB_NAME

def _is_allowed_club_name(club_name: str) -> bool:
q = Q_IS_ALLOWED_CLUB_NAME.replace('%()s', '%(club_name)s')

params = dict(club_name=club_name)

with api_tx() as tx:
row = tx.execute(q, params).fetchone()
return bool(row['is_allowed_club_name'])
from antiabuse.club_name import is_allowed_club_name

def is_rude(name: str) -> bool:
normalized_name = normalize_string(name)
Expand Down
7 changes: 7 additions & 0 deletions antiabuse/antirude/education/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from antiabuse.normalize import normalize_string
from antiabuse.club_name import is_allowed_club_name

def is_rude(name: str) -> bool:
normalized_name = normalize_string(name)

return not _is_allowed_club_name(normalized_name)
7 changes: 7 additions & 0 deletions antiabuse/antirude/occupation/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from antiabuse.normalize import normalize_string
from antiabuse.club_name import is_allowed_club_name

def is_rude(name: str) -> bool:
normalized_name = normalize_string(name)

return not _is_allowed_club_name(normalized_name)
5 changes: 3 additions & 2 deletions antiabuse/normalize/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@
"b": "be",
"b[i1y]?tch": "bitch",
"b[o0][o0]b[i1][e3][s$z]": "boobies",
"btch": "bitch",
"c[a4][s$z]h[a4]pp": "cashapp",
"c[o0]ck": "cock",
"c[o0]ck[s$z]": "cocks",
"c[o0]ck[s$z][uv]ck[e3]r": "cocksucker",
"cok": "cock",
"c+[uv]+m+": "cum",
"c[uv]mming": "cumming",
"c[uv]mm[i1]ng": "cumming",
"c[uv]m[s$z]h[o0][tт]": "cumshot",
"c+[uv]+m+s+": "cums",
"d[i1]ck": "dick",
Expand All @@ -42,6 +42,7 @@
"f[uv]ked": "fucked",
"f[uv]k": "fuck",
"f[uv]king": "fucking",
"gr[a4]p[e3]d": "raped",
"gr[o0][o0]mer": "groomer",
"gr[o0][o0]m": "groom",
"h[@a4]rm": "harm",
Expand Down
2 changes: 2 additions & 0 deletions antiabuse/normalize/test_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ def test_normalize_string(self):

self.assertEqual(normalize_string("bytch"), "bitch")

self.assertEqual(normalize_string("btch"), "bitch")

self.assertEqual(normalize_string("su1cide"), "suicide")

self.assertEqual(normalize_string("pyss"), "piss")
Expand Down
24 changes: 20 additions & 4 deletions duotypes/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import base64
import duoaudio
import traceback
from antiabuse.antirude import displayname, profile
from antiabuse import antirude
from antiabuse.antispam.urldetector import has_url
from antiabuse.antispam.phonenumberdetector import detect_phone_numbers
from antiabuse.antispam.solicitation import has_solicitation
Expand Down Expand Up @@ -284,7 +284,7 @@ def age_must_be_18_or_up(cls, date_of_birth):
def name_must_not_be_rude(cls, value):
if value is None:
return value
if displayname.is_rude(value):
if antirude.displayname.is_rude(value):
raise ValueError('Too rude')
return value

Expand Down Expand Up @@ -388,15 +388,15 @@ def strip_strs(cls, values):
def name_must_not_be_rude(cls, value):
if value is None:
return value
if displayname.is_rude(value):
if antirude.displayname.is_rude(value):
raise ValueError('Too rude')
return value

@field_validator('about')
def about_must_not_be_rude(cls, value):
if value is None:
return value
if profile.is_rude(value):
if antirude.profile.is_rude(value):
raise ValueError('Too rude')
return value

Expand All @@ -411,6 +411,22 @@ def about_must_not_have_spam(cls, value):
raise ValueError('Spam')
return value

@field_validator('occupation')
def occupation_must_not_be_rude(cls, value):
if value is None:
return value
if anitrude.occupation.is_rude(value):
raise ValueError('Too rude')
return value

@field_validator('education')
def occupation_must_not_be_rude(cls, value):
if value is None:
return value
if anitrude.education.is_rude(value):
raise ValueError('Too rude')
return value

class Config:
arbitrary_types_allowed = True

Expand Down
3 changes: 3 additions & 0 deletions service/chat/rude/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,7 @@
"jerk off",
"jerk-off",
"jerked off",
"jerking it",
"jerking off",
"jism",
"jiz",
Expand Down Expand Up @@ -329,8 +330,10 @@
"pedo",
"pedophile",
"pedophilia",
"pegged",
"pegging",
"penis",
"penises",
"penisfucker",
"phonesex",
"pin you",
Expand Down

0 comments on commit 91053fa

Please sign in to comment.