Adds the ability to soft filter words, also fixes some word filter bugs (#62158)

This commit is contained in:
NamelessFairy
2021-10-26 20:45:36 +01:00
committed by GitHub
parent 6e8872f178
commit 1238ce2373
27 changed files with 186 additions and 27 deletions
+18
View File
@@ -1,6 +1,9 @@
#define BLOCKED_IC "This message is not allowed IC, please use a different weird test phrase."
#define BLOCKED_IC_OUTSIDE_PDA "Kirby dancing is strictly prohibited on this server."
#define BLOCKED_SHARED "This message is not allowed anywhere, please use a different weird test phrase."
#define SOFT_BLOCKED_IC "This term is commonly considered OOC, only use it with context."
#define SOFT_BLOCKED_IC_OUTSIDE_PDA "Stop saying debug phrases ICly."
#define SOFT_BLOCKED_SHARED "You risk being banned if this term is used improperly."
/// Tests the sanity of the chat filter, ensuring it properly blocks words and gives the reason
/datum/unit_test/chat_filter_sanity
@@ -10,6 +13,9 @@
config.shared_filter_reasons = list("blockedinshared" = BLOCKED_SHARED)
config.ic_filter_reasons = list("blockedinic" = BLOCKED_IC)
config.ic_outside_pda_filter_reasons = list("<(0_0<)" = BLOCKED_IC_OUTSIDE_PDA)
config.soft_shared_filter_reasons = list("testsoftblocks" = SOFT_BLOCKED_SHARED)
config.soft_ic_filter_reasons = list("testsofterblocks" = SOFT_BLOCKED_IC)
config.soft_ic_outside_pda_filter_reasons = list("testsoftestblocks" = SOFT_BLOCKED_IC_OUTSIDE_PDA)
config.update_chat_filter_regexes()
test_filter(
@@ -50,14 +56,23 @@
ic_filter_result,
pda_filter_result,
ooc_filter_result,
soft_ic_filter_result,
soft_pda_filter_result,
soft_ooc_filter_result,
)
var/ic_filter = is_ic_filtered(message)
var/pda_filter = is_ic_filtered_for_pdas(message)
var/ooc_filter = is_ooc_filtered(message)
var/soft_ic_filter = is_soft_ic_filtered(message)
var/soft_pda_filter = is_soft_ic_filtered_for_pdas(message)
var/soft_ooc_filter = is_soft_ooc_filtered(message)
test_filter_result("IC", message, ic_filter, ic_filter_result, blocked_word)
test_filter_result("PDA", message, pda_filter, pda_filter_result, blocked_word)
test_filter_result("OOC", message, ooc_filter, ooc_filter_result, blocked_word)
test_filter_result("Soft_IC", message, soft_ic_filter, soft_ic_filter_result, blocked_word)
test_filter_result("Soft_PDA", message, soft_pda_filter, soft_pda_filter_result, blocked_word)
test_filter_result("Soft_OOC", message, soft_ooc_filter, soft_ooc_filter_result, blocked_word)
/datum/unit_test/chat_filter_sanity/proc/test_filter_result(
filter_type,
@@ -87,3 +102,6 @@
#undef BLOCKED_IC
#undef BLOCKED_IC_OUTSIDE_PDA
#undef BLOCKED_SHARED
#undef SOFT_BLOCKED_IC
#undef SOFT_BLOCKED_IC_OUTSIDE_PDA
#undef SOFT_BLOCKED_SHARED