From a6255290b22b5bcd4546332c3b83b55d12ff8a0b Mon Sep 17 00:00:00 2001 From: Rafael Bradley Date: Mon, 18 Aug 2025 22:14:55 -0300 Subject: [PATCH] Add explicit sexual language typos rule --- Cargo.lock | 2 +- Cargo.toml | 2 +- .../lists/explicit-sexual-language-typos.txt | 1 + .../calls/lists/explicit-sexual-language.txt | 3 +- src/groups/calls/moderation.rs | 37 +++++++++++++++++++ 5 files changed, 42 insertions(+), 3 deletions(-) create mode 100644 src/groups/calls/lists/explicit-sexual-language-typos.txt diff --git a/Cargo.lock b/Cargo.lock index 4173922..5eda450 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1431,7 +1431,7 @@ checksum = "df94ce210e5bc13cb6651479fa48d14f601d9858cfe0467f43ae157023b938d3" [[package]] name = "payphone" -version = "4.0.11" +version = "4.0.12" dependencies = [ "async-trait", "axum", diff --git a/Cargo.toml b/Cargo.toml index 2e51d4d..cf52760 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "payphone" -version = "4.0.11" +version = "4.0.12" edition = "2024" default-run = "payphone" diff --git a/src/groups/calls/lists/explicit-sexual-language-typos.txt b/src/groups/calls/lists/explicit-sexual-language-typos.txt new file mode 100644 index 0000000..7d13c43 --- /dev/null +++ b/src/groups/calls/lists/explicit-sexual-language-typos.txt @@ -0,0 +1 @@ +ho \ No newline at end of file diff --git a/src/groups/calls/lists/explicit-sexual-language.txt b/src/groups/calls/lists/explicit-sexual-language.txt index 8b3c500..f25134b 100644 --- a/src/groups/calls/lists/explicit-sexual-language.txt +++ b/src/groups/calls/lists/explicit-sexual-language.txt @@ -53,8 +53,9 @@ squirts bitch bih bich -ho hoe +// ho is in "explicit sexual language typos" because it's usually also a typo of "hi". it gets +// censored instead of banned. huz slut dldo diff --git a/src/groups/calls/moderation.rs b/src/groups/calls/moderation.rs index b1b096f..0af52b3 100644 --- a/src/groups/calls/moderation.rs +++ b/src/groups/calls/moderation.rs @@ -555,6 +555,42 @@ impl Rule for ExplicitSexualLanguageRule { } } +struct ExplicitSexualLanguageTypoRule { + pattern: Regex, + exceptions: Vec, +} + +impl ExplicitSexualLanguageTypoRule { + fn new() -> Self { + let (phrases, exceptions) = + parse_phrases_file(include_str!("lists/explicit-sexual-language-typos.txt")); + + let regex = regex_from_phrases_list(&phrases); + + Self { + pattern: regex, + exceptions, + } + } +} + +impl Rule for ExplicitSexualLanguageTypoRule { + fn action(&self) -> &'static Action { + &Action::SoftCensorAndWarn + } + + fn name(&self) -> &'static str { + "Explicit Sexual Language Typo" + } + + fn detect(&self, _original: &str, normalized: &str) -> (Vec, Vec) { + ( + vec![], + find_with_exceptions(normalized, &self.pattern, &self.exceptions), + ) + } +} + struct SuggestiveLanguageRule { pattern: Regex, exceptions: Vec, @@ -759,6 +795,7 @@ pub static RULES: Lazy>> = Lazy::new(|| { Arc::new(HateSpeechAndSlursRule::new()), Arc::new(ThreatsAndSelfHarmRule::new()), Arc::new(ExplicitSexualLanguageRule::new()), + Arc::new(ExplicitSexualLanguageTypoRule::new()), Arc::new(SuggestiveLanguageRule::new()), Arc::new(AdvertisingRule), Arc::new(SensitiveTopicsAndTriggeringContentRule::new()),