mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2025-12-10 09:42:29 +00:00
[MIRROR] Checks Filters For Cross-Station Messages [MDB IGNORE] (#16868)
* Checks Filters For Cross-Station Messages * merge conflict Co-authored-by: san7890 <the@san7890.com> Co-authored-by: tastyfish <crazychris32@gmail.com>
This commit is contained in:
@@ -1,7 +1,11 @@
|
||||
/// The time an admin has to cancel a cross-sector message
|
||||
#define CROSS_SECTOR_CANCEL_TIME (10 SECONDS)
|
||||
|
||||
/* SKYRAT EDIT REMOVAL
|
||||
/// The extended time an admin has to cancel a cross-sector message if they pass the filter, for instance
|
||||
#define EXTENDED_CROSS_SECTOR_CANCEL_TIME (30 SECONDS)
|
||||
|
||||
// SKYRAT EDIT REMOVAL BEGIN - modularized into code/__DEFINES/~skyrat_defines/security_alerts.dm
|
||||
/*
|
||||
//Security levels affect the escape shuttle timer
|
||||
/// Security level is green. (no threats)
|
||||
#define SEC_LEVEL_GREEN 0
|
||||
@@ -11,4 +15,5 @@
|
||||
#define SEC_LEVEL_RED 2
|
||||
/// Security level is delta. (station destruction immiment)
|
||||
#define SEC_LEVEL_DELTA 3
|
||||
*/ //SKYRAT EDIT END
|
||||
*/
|
||||
//SKYRAT EDIT REMOVAL END
|
||||
|
||||
@@ -10,6 +10,9 @@ SUBSYSTEM_DEF(communications)
|
||||
COOLDOWN_DECLARE(nonsilicon_message_cooldown)
|
||||
COOLDOWN_DECLARE(emergency_meeting_cooldown)
|
||||
|
||||
/// Are we trying to send a cross-station message that contains soft-filtered words? If so, flip to TRUE to extend the time admins have to cancel the message.
|
||||
var/soft_filtering = FALSE
|
||||
|
||||
/datum/controller/subsystem/communications/proc/can_announce(mob/living/user, is_silicon)
|
||||
if(is_silicon && COOLDOWN_FINISHED(src, silicon_message_cooldown))
|
||||
return TRUE
|
||||
|
||||
@@ -102,20 +102,25 @@
|
||||
// We can't add the timer without the timer ID, but we can't get the timer ID without the timer!
|
||||
// To solve this, we just use a list that we mutate later.
|
||||
var/list/data = list("input" = input)
|
||||
var/timer_id = addtimer(CALLBACK(src, .proc/receive_cross_comms_message, data), CROSS_SECTOR_CANCEL_TIME, TIMER_STOPPABLE)
|
||||
// Did we have to pass the soft filter on our origin server? Passed as a boolean value.
|
||||
var/soft_filter_passed = !!input["is_filtered"]
|
||||
var/timer_id = addtimer(CALLBACK(src, .proc/receive_cross_comms_message, data), soft_filter_passed ? EXTENDED_CROSS_SECTOR_CANCEL_TIME : CROSS_SECTOR_CANCEL_TIME, TIMER_STOPPABLE)
|
||||
data["timer_id"] = timer_id
|
||||
|
||||
LAZYADD(timers, timer_id)
|
||||
|
||||
to_chat(
|
||||
GLOB.admins,
|
||||
span_adminnotice( \
|
||||
"<b color='orange'>CROSS-SECTOR MESSAGE (INCOMING):</b> [input["sender_ckey"]] (from [input["source"]]) is about to send \
|
||||
the following message (will autoapprove in [DisplayTimeText(CROSS_SECTOR_CANCEL_TIME)]): \
|
||||
<b><a href='?src=[REF(src)];reject_cross_comms_message=[timer_id]'>REJECT</a></b><br> \
|
||||
[html_encode(input["message"])]" \
|
||||
)
|
||||
)
|
||||
var/extended_time_display = DisplayTimeText(EXTENDED_CROSS_SECTOR_CANCEL_TIME)
|
||||
var/normal_time_display = DisplayTimeText(CROSS_SECTOR_CANCEL_TIME)
|
||||
|
||||
var/message = "<b color='orange'>CROSS-SECTOR MESSAGE (INCOMING):</b> [input["sender_ckey"]] (from [input["source"]]) is about to send \
|
||||
the following message (will autoapprove in [soft_filter_passed ? "[extended_time_display]" : "[normal_time_display]"]): \
|
||||
<b><a href='?src=[REF(src)];reject_cross_comms_message=[timer_id]'>REJECT</a></b><br><br>\
|
||||
[html_encode(input["message"])]"
|
||||
|
||||
if(soft_filter_passed)
|
||||
message += "<br><br><b>NOTE: This message passed the soft filter on the origin server! The time was automatically expanded to [extended_time_display].</b>"
|
||||
|
||||
message_admins(span_adminnotice(message))
|
||||
|
||||
/datum/world_topic/comms_console/Topic(href, list/href_list)
|
||||
. = ..()
|
||||
|
||||
@@ -331,6 +331,20 @@ GLOBAL_VAR_INIT(cops_arrived, FALSE)
|
||||
if (!message)
|
||||
return
|
||||
|
||||
SScommunications.soft_filtering = FALSE
|
||||
var/list/hard_filter_result = is_ic_filtered(message)
|
||||
if(hard_filter_result)
|
||||
tgui_alert(usr, "Your message contains: (\"[hard_filter_result[CHAT_FILTER_INDEX_WORD]]\"), which is not allowed on this server.")
|
||||
return
|
||||
|
||||
var/list/soft_filter_result = is_soft_ooc_filtered(message)
|
||||
if(soft_filter_result)
|
||||
if(tgui_alert(usr,"Your message contains \"[soft_filter_result[CHAT_FILTER_INDEX_WORD]]\". \"[soft_filter_result[CHAT_FILTER_INDEX_REASON]]\", Are you sure you want to use it?", "Soft Blocked Word", list("Yes", "No")) != "Yes")
|
||||
return
|
||||
message_admins("[ADMIN_LOOKUPFLW(usr)] has passed the soft filter for \"[soft_filter_result[CHAT_FILTER_INDEX_WORD]]\". They may be using a disallowed term for a cross-station message. Increasing delay time to reject.\n\n Message: \"[html_encode(message)]\"")
|
||||
log_admin_private("[key_name(usr)] has passed the soft filter for \"[soft_filter_result[CHAT_FILTER_INDEX_WORD]]\". They may be using a disallowed term for a cross-station message. Increasing delay time to reject.\n\n Message: \"[message]\"")
|
||||
SScommunications.soft_filtering = TRUE
|
||||
|
||||
playsound(src, 'sound/machines/terminal_prompt_confirm.ogg', 50, FALSE)
|
||||
|
||||
var/destination = params["destination"]
|
||||
@@ -340,13 +354,13 @@ GLOBAL_VAR_INIT(cops_arrived, FALSE)
|
||||
GLOB.admins,
|
||||
span_adminnotice( \
|
||||
"<b color='orange'>CROSS-SECTOR MESSAGE (OUTGOING):</b> [ADMIN_LOOKUPFLW(usr)] is about to send \
|
||||
the following message to <b>[destination]</b> (will autoapprove in [DisplayTimeText(CROSS_SECTOR_CANCEL_TIME)]): \
|
||||
the following message to <b>[destination]</b> (will autoapprove in [SScommunications.soft_filtering ? DisplayTimeText(EXTENDED_CROSS_SECTOR_CANCEL_TIME) : DisplayTimeText(CROSS_SECTOR_CANCEL_TIME)]): \
|
||||
<b><a href='?src=[REF(src)];reject_cross_comms_message=1'>REJECT</a></b><br> \
|
||||
[html_encode(message)]" \
|
||||
)
|
||||
)
|
||||
|
||||
send_cross_comms_message_timer = addtimer(CALLBACK(src, .proc/send_cross_comms_message, usr, destination, message), CROSS_SECTOR_CANCEL_TIME, TIMER_STOPPABLE)
|
||||
send_cross_comms_message_timer = addtimer(CALLBACK(src, .proc/send_cross_comms_message, usr, destination, message), SScommunications.soft_filtering ? EXTENDED_CROSS_SECTOR_CANCEL_TIME : CROSS_SECTOR_CANCEL_TIME, TIMER_STOPPABLE)
|
||||
|
||||
COOLDOWN_START(src, important_action_cooldown, IMPORTANT_ACTION_COOLDOWN)
|
||||
if ("setState")
|
||||
@@ -491,10 +505,12 @@ GLOBAL_VAR_INIT(cops_arrived, FALSE)
|
||||
|
||||
var/list/payload = list()
|
||||
|
||||
var/network_name = CONFIG_GET(string/cross_comms_network)
|
||||
if (network_name)
|
||||
payload["network"] = network_name
|
||||
payload["sender_ckey"] = usr.ckey
|
||||
var/network_name = CONFIG_GET(string/cross_comms_network)
|
||||
if(network_name)
|
||||
payload["network"] = network_name
|
||||
if(SScommunications.soft_filtering)
|
||||
payload["is_filtered"] = TRUE
|
||||
|
||||
var/name_to_send = "[CONFIG_GET(string/cross_comms_name)]([station_name()])" //SKYRAT EDIT ADDITION
|
||||
|
||||
@@ -503,6 +519,7 @@ GLOBAL_VAR_INIT(cops_arrived, FALSE)
|
||||
usr.log_talk(message, LOG_SAY, tag = "message to the other server")
|
||||
message_admins("[ADMIN_LOOKUPFLW(usr)] has sent a message to the other server\[s].")
|
||||
deadchat_broadcast(" has sent an outgoing message to the other station(s).</span>", "<span class='bold'>[usr.real_name]", usr, message_type = DEADCHAT_ANNOUNCEMENT)
|
||||
SScommunications.soft_filtering = FALSE // set it to false at the end of the proc to ensure that everything prior reads as intended
|
||||
|
||||
/obj/machinery/computer/communications/ui_data(mob/user)
|
||||
var/list/data = list(
|
||||
@@ -663,6 +680,7 @@ GLOBAL_VAR_INIT(cops_arrived, FALSE)
|
||||
return
|
||||
|
||||
deltimer(send_cross_comms_message_timer)
|
||||
SScommunications.soft_filtering = FALSE
|
||||
send_cross_comms_message_timer = null
|
||||
|
||||
log_admin("[key_name(usr)] has cancelled the outgoing cross-comms message.")
|
||||
|
||||
Reference in New Issue
Block a user