Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chat Filter #6901

Merged
merged 9 commits into from
Aug 22, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
2 changes: 2 additions & 0 deletions code/controllers/configuration/entries/general.dm
Original file line number Diff line number Diff line change
Expand Up @@ -672,3 +672,5 @@ This maintains a list of ip addresses that are able to bypass topic filtering.
/datum/config_entry/string/repo_name

/datum/config_entry/string/org

/datum/config_entry/str_list/word_filter
6 changes: 6 additions & 0 deletions code/game/verbs/ooc.dm
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
to_chat(src, "Guests may not use OOC.")
return

if(!filter_message(src, msg))
return

msg = trim(strip_html(msg))
if(!msg) return

Expand Down Expand Up @@ -101,6 +104,9 @@
to_chat(src, "Guests may not use LOOC.")
return

if(!filter_message(src, msg))
return

msg = trim(strip_html(msg))
if(!msg) return

Expand Down
3 changes: 3 additions & 0 deletions code/modules/mob/dead/observer/say.dm
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
if (src.client.handle_spam_prevention(message, MUTE_DEADCHAT))
return

if(!filter_message(src, message))
return

. = src.say_dead(message)


Expand Down
21 changes: 21 additions & 0 deletions code/modules/mob/living/say.dm
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,24 @@ GLOBAL_LIST_INIT(department_radio_keys, list(
/proc/prefix_to_channel(prefix)
return GLOB.department_radio_keys[prefix]

/proc/filter_message(user, message)
var/list/banned_words = CONFIG_GET(str_list/word_filter)
var/message_lowercase = lowertext(message)

for(var/word in banned_words)
if(findtext(message_lowercase, regex(lowertext(word))))
Git-Nivrak marked this conversation as resolved.
Show resolved Hide resolved
to_chat(user,
html = "\n<font color='red' size='4'><b>-- Word Filter Message --</b></font>",
)
to_chat(user,
type = MESSAGE_TYPE_ADMINPM,
html = "\n<font color='red' size='4'><b>Your message has been automatically filtered due to its contents. Trying to circumvent this filter will get you banned.</b></font>",
)
SEND_SOUND(user, sound('sound/effects/adminhelp_new.ogg'))
return FALSE
Git-Nivrak marked this conversation as resolved.
Show resolved Hide resolved

return TRUE

///Shows custom speech bubbles for screaming, *warcry etc.
/mob/living/proc/show_speech_bubble(bubble_name, bubble_type = bubble_icon)

Expand All @@ -81,6 +99,9 @@ GLOBAL_LIST_INIT(department_radio_keys, list(

if(SEND_SIGNAL(src, COMSIG_LIVING_SPEAK, message, speaking, verb, alt_name, italics, message_range, speech_sound, sound_vol, nolog, message_mode) & COMPONENT_OVERRIDE_SPEAK) return

if(!filter_message(src, message))
return

message = process_chat_markup(message, list("~", "_"))

for(var/dst=0; dst<=1; dst++) //Will run twice if src has a clone
Expand Down
1 change: 1 addition & 0 deletions config/example/config.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
# $include resources.txt
# $include icon_source.txt
# $include relays.txt
$include word_filter.txt
Git-Nivrak marked this conversation as resolved.
Show resolved Hide resolved

## Server name: This appears at the top of the screen in-game. In this case it will read "tgstation: station_name" where station_name is the randomly generated name of the station for the round. Remove the # infront of SERVERNAME and replace 'tgstation' with the name of your choice
# SERVERNAME spacestation13
Expand Down
6 changes: 6 additions & 0 deletions config/example/word_filter.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
## Word filter
## WORD_FILTER <word>
## Case insensitive, Uses regex
Git-Nivrak marked this conversation as resolved.
Show resolved Hide resolved
#WORD_FILTER wordToBan
#WORD_FILTER otherwordtoban
#WORD_FILTER wordtoban.*withregex
Loading