Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions badwords/default_words.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ bajingan*
bangke
bangs?t*
bangsad
bangsat
bastard*
batshit
bedebah
Expand Down
2 changes: 1 addition & 1 deletion config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions moderation_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
Expand Down
10 changes: 10 additions & 0 deletions tests/test_badwords.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Loading