diff --git a/badwords/default_words.txt b/badwords/default_words.txt index fecd33c..1885c06 100644 --- a/badwords/default_words.txt +++ b/badwords/default_words.txt @@ -19,6 +19,7 @@ bajingan* bangke bangs?t* bangsad +bangsat bastard* batshit bedebah diff --git a/config.py b/config.py index 3f42db0..65fbb1c 100644 --- a/config.py +++ b/config.py @@ -116,7 +116,7 @@ "Third warning: you will be temporarily banned for {duration} minutes due to channel join spam.", ] BADWORDS_ENABLED: bool = True -BADWORDS_INTERCEPT_TYPES: List[str] = ["CHANNEL"] +BADWORDS_INTERCEPT_TYPES: List[str] = ["CHANNEL", "PRIVATE"] BADWORDS_FILE: str = "badwords/words.txt" BADWORDS_IGNORE_ADMINS: bool = False BADWORDS_PROFILE_CHECK_ENABLED: bool = True diff --git a/moderation_utils.py b/moderation_utils.py index 199e4fa..f448f8f 100644 --- a/moderation_utils.py +++ b/moderation_utils.py @@ -19,7 +19,7 @@ def check_text_badwords(client, textmessage, content=None): content = from_tt_char(textmessage.szMessage) if not content: return - if getattr(config, "BADWORDS_IGNORE_ADMINS", True): + if getattr(config, "BADWORDS_IGNORE_ADMINS", False): try: u = client.getUser(from_uid) if u.uUserType & UserType.USERTYPE_ADMIN: @@ -39,7 +39,7 @@ def check_user_profile_badwords(client, user): try: if user.nUserID == (client.getMyUserID() or 0): return - if getattr(config, "BADWORDS_IGNORE_ADMINS", True) and ( + if getattr(config, "BADWORDS_IGNORE_ADMINS", False) and ( user.uUserType & UserType.USERTYPE_ADMIN ): return diff --git a/tests/test_badwords.py b/tests/test_badwords.py index 28eda37..b651b1b 100644 --- a/tests/test_badwords.py +++ b/tests/test_badwords.py @@ -78,6 +78,16 @@ def test_every_entry_is_usable(self): with self.subTest(entry=entry): self.assertEqual(checker.pattern_error(entry), "") + def test_shipped_list_matches_toxic_phrases(self): + filter_ = BadWordsFilter() + filter_.load_file(os.path.join(ROOT, "badwords", DEFAULT_LIST_NAME)) + self.assertTrue(filter_.contains("apa lu bangsat")) + matches = filter_.matching_entries("apa lu bangsat") + self.assertTrue(any("bangsat" in m or "bangs" in m for m in matches)) + self.assertTrue(filter_.contains("APA LU BANGSAT!")) + self.assertTrue(filter_.contains("@ai apa lu bangsat")) + + if __name__ == "__main__": unittest.main()