Add leetspeak normalization for prohibited words
This commit is contained in:
@@ -35,6 +35,24 @@ PROHIBITED_WORDS = {
|
|||||||
'git', 'shag', 'minge', 'nonce', 'plonker', 'pillock'
|
'git', 'shag', 'minge', 'nonce', 'plonker', 'pillock'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LEET_MAP = str.maketrans({
|
||||||
|
"@": "a",
|
||||||
|
"4": "a",
|
||||||
|
"8": "b",
|
||||||
|
"3": "e",
|
||||||
|
"6": "g",
|
||||||
|
"9": "g",
|
||||||
|
"1": "i",
|
||||||
|
"!": "i",
|
||||||
|
"|": "l",
|
||||||
|
"0": "o",
|
||||||
|
"$": "s",
|
||||||
|
"5": "s",
|
||||||
|
"7": "t",
|
||||||
|
"+": "t",
|
||||||
|
"2": "z",
|
||||||
|
})
|
||||||
|
|
||||||
api = Blueprint("api", __name__, url_prefix="/api")
|
api = Blueprint("api", __name__, url_prefix="/api")
|
||||||
|
|
||||||
|
|
||||||
@@ -45,7 +63,8 @@ def _get_client_ip() -> str:
|
|||||||
|
|
||||||
def _contains_prohibited_word(text: str) -> bool:
|
def _contains_prohibited_word(text: str) -> bool:
|
||||||
lower = text.lower()
|
lower = text.lower()
|
||||||
return any(w in lower for w in PROHIBITED_WORDS)
|
normalized = lower.translate(LEET_MAP)
|
||||||
|
return any(w in lower or w in normalized for w in PROHIBITED_WORDS)
|
||||||
|
|
||||||
|
|
||||||
def _get_discord_session() -> requests.Session:
|
def _get_discord_session() -> requests.Session:
|
||||||
|
|||||||
Reference in New Issue
Block a user