/* NTTC system This is basically the replacement for NTSL and allows tickbox features such as job titles and colours, without needing a script This also means that there is no user input here, which means the system isnt prone to exploits since its only selecting options, no user input Basically, just imagine pfSense for tcomms All this code was written by Tigercat2000. I take no credit -aa07 */ #define JOB_STYLE_1 "Name (Job)" #define JOB_STYLE_2 "Name - Job" #define JOB_STYLE_3 "\[Job\] Name" #define JOB_STYLE_4 "(Job) Name" /datum/nttc_configuration var/regex/word_blacklist = new("(EXPLOIT WARNING: [ckey] attempted to upload an NTTC configuration containing JS abusable tags!") log_admin("EXPLOIT WARNING: [ckey] attempted to upload an NTTC configuration containing JS abusable tags") return FALSE var/list/var_list = json_decode(text) for(var/variable in var_list) if(variable in to_serialize) // Don't just accept any random vars jesus christ! var/sanitize_method = serialize_sanitize[variable] var/variable_value = var_list[variable] variable_value = nttc_sanitize(variable_value, sanitize_method) if(variable_value != null) vars[variable] = variable_value return TRUE // Sanitizing user input. Don't blindly trust the JSON. /datum/nttc_configuration/proc/nttc_sanitize(variable, sanitize_method) if(!sanitize_method) return null switch(sanitize_method) if("bool") return variable ? TRUE : FALSE // if("table", "array") if("array") if(!islist(variable)) return list() // Insert html filtering for the regexes here if you're boring var/newlist = json_decode(html_decode(json_encode(variable))) if(!islist(newlist)) return null return newlist if("string") return "[variable]" return variable // Primary signal modification. This is where all of the variables behavior are actually implemented. /datum/nttc_configuration/proc/modify_message(datum/tcomms_message/tcm) // Check if they should be blacklisted right off the bat. We can save CPU if the message wont even be processed if(tcm.sender_name in filtering) tcm.pass = FALSE // All job and coloring shit if(toggle_job_color || toggle_name_color) var/job = tcm.sender_job var/rank = tcm.sender_rank //if the job title is not custom, just use that to decide the rules of formatting if(job in all_jobs) job_class = all_jobs[job] else job_class = all_jobs[rank] tcm.pre_modify_name = tcm.sender_name if(toggle_name_color) var/new_name = "[tcm.sender_name]" tcm.sender_name = new_name tcm.vname = new_name // this is required because the broadcaster uses this directly if the speaker doesn't have a voice changer on if(toggle_jobs) var/new_name = "" var/job = tcm.sender_job if(job in ert_jobs) job = "ERT" if(toggle_job_color) switch(job_indicator_type) if(JOB_STYLE_1) new_name = "[tcm.sender_name] ([job])" if(JOB_STYLE_2) new_name = "[tcm.sender_name] - [job]" if(JOB_STYLE_3) new_name = "\[[job]\] [tcm.sender_name]" if(JOB_STYLE_4) new_name = "([job]) [tcm.sender_name]" else switch(job_indicator_type) if(JOB_STYLE_1) new_name = "[tcm.sender_name] ([job])" if(JOB_STYLE_2) new_name = "[tcm.sender_name] - [job]" if(JOB_STYLE_3) new_name = "\[[job]\] [tcm.sender_name]" if(JOB_STYLE_4) new_name = "([job]) [tcm.sender_name]" // Only change the name if they have a job tag set, otherwise everyone becomes unknown, and thats bad if(new_name != "") tcm.sender_name = new_name tcm.vname = new_name // this is required because the broadcaster uses this directly if the speaker doesn't have a voice changer on // This is hacky stuff for multilingual messages... var/list/message_pieces = tcm.message_pieces // Makes heads of staff bold if(toggle_command_bold) var/job = tcm.sender_job var/rank = tcm.sender_rank var/realjob = job if(!(job in all_jobs)) realjob = rank if((realjob in ert_jobs) || (realjob in heads) || (realjob in cc_jobs) || (realjob in tsf_jobs)) for(var/I in 1 to length(message_pieces)) var/datum/multilingual_say_piece/S = message_pieces[I] if(!S.message) continue if(I == 1 && !istype(S.speaking, /datum/language/noise)) // Capitalise the first section only, unless it's an emote. S.message = "[capitalize(S.message)]" S.message = "[S.message]" // Make everything bolded // Language Conversion if(setting_language && valid_languages[setting_language]) if(setting_language == "--DISABLE--") setting_language = null else for(var/datum/multilingual_say_piece/S in message_pieces) if(S.speaking != GLOB.all_languages["Noise"]) // check if they are emoting, these do not need to be translated S.speaking = GLOB.all_languages[setting_language] return tcm #undef JOB_STYLE_1 #undef JOB_STYLE_2 #undef JOB_STYLE_3 #undef JOB_STYLE_4