diff --git a/src/groups/calls/lists/mild-swear-words.txt b/src/groups/calls/lists/mild-swear-words.txt index ed4606f..9afb438 100644 --- a/src/groups/calls/lists/mild-swear-words.txt +++ b/src/groups/calls/lists/mild-swear-words.txt @@ -8,4 +8,9 @@ fuh fuck you f u f you -fuck u \ No newline at end of file +fuck u +damn +dmn +shit +sht +ass \ No newline at end of file diff --git a/src/groups/calls/lists/sensitive-topics-and-triggering-content.txt b/src/groups/calls/lists/sensitive-topics-and-triggering-content.txt new file mode 100644 index 0000000..200648a --- /dev/null +++ b/src/groups/calls/lists/sensitive-topics-and-triggering-content.txt @@ -0,0 +1 @@ +blood \ No newline at end of file diff --git a/src/groups/calls/moderation.rs b/src/groups/calls/moderation.rs index f3f6d92..a559c36 100644 --- a/src/groups/calls/moderation.rs +++ b/src/groups/calls/moderation.rs @@ -13,7 +13,7 @@ //! | 5 | Suggestive language | "slap your ass", "sexy" | Block immediately + penalty | //! | 6 | Advertising | "discord.gg/payphone" | Block immediately + penalty | //! | 7 | Sensitive topics and triggering content | "blood", "knife", "suicide method" | Block immediately + penalty | -//! | 8 | Non-english chats | | Block immediately + penalty | +//! | 8 | Non-english chats | | Soft censor + warn | //! | 9 | E-dating | "let me hit" | Block immediately + penalty | //! | 10 | Mild swear words | "damn", "shit", "ass" | Soft censor + warn | //! | 11 | Casual insults and teasing | "stupid", "dumb" | Soft censor + warn | @@ -551,6 +551,134 @@ impl Rule for SuggestiveLanguageRule { } } +struct AdvertisingRule; + +impl Rule for AdvertisingRule { + fn name(&self) -> &'static str { + "Advertising" + } + + fn action(&self) -> &'static Action { + &Action::BlockAndPenalty + } + + fn detect(&self, original: &str, _normalized: &str) -> (Vec, Vec) { + let mut detections = Vec::new(); + + for link in LinkFinder::new() + .url_must_have_scheme(false) + .links(original) + { + let link_str = link.as_str(); + + if link_str.contains("discord.gg") || link_str.contains("discord.com") { + detections.push(link_str.to_string()); + } + } + + (detections, vec![]) + } +} + +struct SensitiveTopicsAndTriggeringContentRule(Regex); + +impl SensitiveTopicsAndTriggeringContentRule { + fn new() -> Self { + let phrases: Vec<&str> = parse_phrases_file(include_str!( + "lists/sensitive-topics-and-triggering-content.txt" + )); + + let regex = regex_from_phrases_list(&phrases); + + Self(regex) + } +} + +impl Rule for SensitiveTopicsAndTriggeringContentRule { + fn name(&self) -> &'static str { + "Sensitive Topics and Triggering Content" + } + + fn action(&self) -> &'static Action { + &Action::BlockAndPenalty + } + + fn detect(&self, _original: &str, normalized: &str) -> (Vec, Vec) { + ( + vec![], + self.0 + .find_iter(normalized) + .map(|m| normalized[m.start()..m.end()].to_string()) + .collect(), + ) + } +} + +pub struct MildSwearWordsRule(Regex); + +impl MildSwearWordsRule { + fn new() -> Self { + let phrases: Vec<&str> = parse_phrases_file(include_str!("lists/mild-swear-words.txt")); + + let regex = regex_from_phrases_list(&phrases); + + Self(regex) + } +} + +impl Rule for MildSwearWordsRule { + fn name(&self) -> &'static str { + "Mild Swear Words" + } + + fn action(&self) -> &'static Action { + &Action::SoftCensorAndWarn + } + + fn detect(&self, _original: &str, normalized: &str) -> (Vec, Vec) { + ( + vec![], + self.0 + .find_iter(normalized) + .map(|m| normalized[m.start()..m.end()].to_string()) + .collect(), + ) + } +} + +pub struct CasualInsultsAndTeasing(Regex); + +impl CasualInsultsAndTeasing { + fn new() -> Self { + let phrases: Vec<&str> = + parse_phrases_file(include_str!("lists/casual-insults-and-teasing.txt")); + + let regex = regex_from_phrases_list(&phrases); + + Self(regex) + } +} + +impl Rule for CasualInsultsAndTeasing { + fn name(&self) -> &'static str { + "Casual Insults and Teasing" + } + + fn action(&self) -> &'static Action { + &Action::SoftCensorAndWarn + } + + fn detect(&self, _original: &str, normalized: &str) -> (Vec, Vec) { + ( + vec![], + self.0 + .find_iter(normalized) + .map(|m| normalized[m.start()..m.end()].to_string()) + .collect(), + ) + } +} + struct LinksRule; impl Rule for LinksRule { @@ -581,8 +709,12 @@ pub static RULES: Lazy>> = Lazy::new(|| { vec![ Arc::new(HateSpeechAndSlursRule::new()), Arc::new(ThreatsAndSelfHarmRule::new()), - Arc::new(SuggestiveLanguageRule::new()), Arc::new(ExplicitSexualLanguageRule::new()), + Arc::new(SuggestiveLanguageRule::new()), + Arc::new(AdvertisingRule), + Arc::new(SensitiveTopicsAndTriggeringContentRule::new()), + Arc::new(MildSwearWordsRule::new()), + Arc::new(CasualInsultsAndTeasing::new()), Arc::new(LinksRule), ] });