mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2025-12-11 18:22:14 +00:00
Adds the ability to soft filter words, also fixes some word filter bugs (#62158)
This commit is contained in:
@@ -32,6 +32,15 @@
|
||||
|
||||
/// A regex that matches words blocked IC, but not in PDAs
|
||||
var/static/regex/ic_outside_pda_filter_regex
|
||||
|
||||
/// A regex that matches words soft blocked IC
|
||||
var/static/regex/soft_ic_filter_regex
|
||||
|
||||
/// A regex that matches words soft blocked OOC
|
||||
var/static/regex/soft_ooc_filter_regex
|
||||
|
||||
/// A regex that matches words soft blocked IC, but not in PDAs
|
||||
var/static/regex/soft_ic_outside_pda_filter_regex
|
||||
|
||||
/// An assoc list of blocked IC words to their reasons
|
||||
var/static/list/ic_filter_reasons
|
||||
@@ -42,6 +51,15 @@
|
||||
/// An assoc list of words that are blocked both IC and OOC to their reasons
|
||||
var/static/list/shared_filter_reasons
|
||||
|
||||
/// An assoc list of soft blocked IC words to their reasons
|
||||
var/static/list/soft_ic_filter_reasons
|
||||
|
||||
/// An assoc list of words that are soft blocked IC, but not in PDAs, to their reasons
|
||||
var/static/list/soft_ic_outside_pda_filter_reasons
|
||||
|
||||
/// An assoc list of words that are soft blocked both IC and OOC to their reasons
|
||||
var/static/list/soft_shared_filter_reasons
|
||||
|
||||
/datum/controller/configuration/proc/admin_reload()
|
||||
if(IsAdminAdvancedProcCall())
|
||||
return
|
||||
@@ -370,6 +388,9 @@ Example config:
|
||||
ic_filter_reasons = try_extract_from_word_filter(word_filter, "ic")
|
||||
ic_outside_pda_filter_reasons = try_extract_from_word_filter(word_filter, "ic_outside_pda")
|
||||
shared_filter_reasons = try_extract_from_word_filter(word_filter, "shared")
|
||||
soft_ic_filter_reasons = try_extract_from_word_filter(word_filter, "soft_ic")
|
||||
soft_ic_outside_pda_filter_reasons = try_extract_from_word_filter(word_filter, "soft_ic_outside_pda")
|
||||
soft_shared_filter_reasons = try_extract_from_word_filter(word_filter, "soft_shared")
|
||||
|
||||
update_chat_filter_regexes()
|
||||
|
||||
@@ -382,6 +403,9 @@ Example config:
|
||||
ic_filter_reasons = list()
|
||||
ic_outside_pda_filter_reasons = list()
|
||||
shared_filter_reasons = list()
|
||||
soft_ic_filter_reasons = list()
|
||||
soft_ic_outside_pda_filter_reasons = list()
|
||||
soft_shared_filter_reasons = list()
|
||||
|
||||
for (var/line in world.file2list("[directory]/in_character_filter.txt"))
|
||||
if (!line)
|
||||
@@ -398,6 +422,9 @@ Example config:
|
||||
ic_filter_regex = compile_filter_regex(ic_filter_reasons + ic_outside_pda_filter_reasons + shared_filter_reasons)
|
||||
ic_outside_pda_filter_regex = compile_filter_regex(ic_filter_reasons + shared_filter_reasons)
|
||||
ooc_filter_regex = compile_filter_regex(shared_filter_reasons)
|
||||
soft_ic_filter_regex = compile_filter_regex(soft_ic_filter_reasons + soft_ic_outside_pda_filter_reasons + soft_shared_filter_reasons)
|
||||
soft_ic_outside_pda_filter_regex = compile_filter_regex(soft_ic_filter_reasons + soft_shared_filter_reasons)
|
||||
soft_ooc_filter_regex = compile_filter_regex(soft_shared_filter_reasons)
|
||||
|
||||
/datum/controller/configuration/proc/try_extract_from_word_filter(list/word_filter, key)
|
||||
var/list/banned_words = word_filter[key]
|
||||
@@ -410,7 +437,11 @@ Example config:
|
||||
DelayedMessageAdmins(message)
|
||||
return list()
|
||||
|
||||
return banned_words
|
||||
var/list/formatted_banned_words = list()
|
||||
|
||||
for (var/banned_word in banned_words)
|
||||
formatted_banned_words[lowertext(banned_word)] = banned_words[banned_word]
|
||||
return formatted_banned_words
|
||||
|
||||
/datum/controller/configuration/proc/compile_filter_regex(list/banned_words)
|
||||
if (isnull(banned_words) || banned_words.len == 0)
|
||||
|
||||
Reference in New Issue
Block a user