mirror of
https://github.com/ParadiseSS13/Paradise.git
synced 2025-12-23 16:51:53 +00:00
Add OOC throttling
This commit is contained in:
@@ -287,3 +287,6 @@
|
||||
#define SHELTER_DEPLOY_BAD_TURFS "bad turfs"
|
||||
#define SHELTER_DEPLOY_BAD_AREA "bad area"
|
||||
#define SHELTER_DEPLOY_ANCHORED_OBJECTS "anchored objects"
|
||||
|
||||
// The cooldown on OOC messages such as OOC, LOOC, praying and adminhelps
|
||||
#define OOC_COOLDOWN 20
|
||||
|
||||
@@ -32,7 +32,7 @@ var/global/admin_ooc_colour = "#b82e00"
|
||||
if(prefs.muted & MUTE_OOC)
|
||||
to_chat(src, "<span class='danger'>You cannot use OOC (muted).</span>")
|
||||
return
|
||||
if(handle_spam_prevention(msg, MUTE_OOC))
|
||||
if(handle_spam_prevention(msg, MUTE_OOC, OOC_COOLDOWN))
|
||||
return
|
||||
if(findtext(msg, "byond://"))
|
||||
to_chat(src, "<B>Advertising other servers is not allowed.</B>")
|
||||
@@ -168,7 +168,7 @@ var/global/admin_ooc_colour = "#b82e00"
|
||||
if(prefs.muted & MUTE_OOC)
|
||||
to_chat(src, "<span class='danger'>You cannot use LOOC (muted).</span>")
|
||||
return
|
||||
if(handle_spam_prevention(msg,MUTE_OOC))
|
||||
if(handle_spam_prevention(msg, MUTE_OOC, OOC_COOLDOWN))
|
||||
return
|
||||
if(findtext(msg, "byond://"))
|
||||
to_chat(src, "<B>Advertising other servers is not allowed.</B>")
|
||||
|
||||
@@ -24,7 +24,7 @@ var/list/adminhelp_ignored_words = list("unknown","the","a","an","of","monkey","
|
||||
if(!msg)
|
||||
return
|
||||
|
||||
if(src.handle_spam_prevention(msg,MUTE_ADMINHELP))
|
||||
if(handle_spam_prevention(msg, MUTE_ADMINHELP, OOC_COOLDOWN))
|
||||
return
|
||||
|
||||
msg = sanitize(copytext(msg,1,MAX_MESSAGE_LEN))
|
||||
|
||||
@@ -99,7 +99,7 @@
|
||||
adminhelp(msg) //admin we are replying to has vanished, adminhelp instead
|
||||
return
|
||||
|
||||
if(src.handle_spam_prevention(msg,MUTE_ADMINHELP))
|
||||
if(handle_spam_prevention(msg, MUTE_ADMINHELP, OOC_COOLDOWN))
|
||||
return
|
||||
|
||||
//clean the message if it's not sent by a high-rank admin
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
if(usr.client.prefs.muted & MUTE_PRAY)
|
||||
to_chat(usr, "\red You cannot pray (muted).")
|
||||
return
|
||||
if(src.client.handle_spam_prevention(msg,MUTE_PRAY))
|
||||
if(client.handle_spam_prevention(msg, MUTE_PRAY, OOC_COOLDOWN))
|
||||
return
|
||||
|
||||
var/image/cross = image('icons/obj/storage.dmi',"bible")
|
||||
|
||||
@@ -4,8 +4,9 @@
|
||||
////////////////
|
||||
var/datum/admins/holder = null
|
||||
|
||||
var/last_message = "" //Contains the last message sent by this client - used to protect against copy-paste spamming.
|
||||
var/last_message_count = 0 //contins a number of how many times a message identical to last_message was sent.
|
||||
var/last_message = "" //contains the last message sent by this client - used to protect against copy-paste spamming.
|
||||
var/last_message_count = 0 //contains a number of how many times a message identical to last_message was sent.
|
||||
var/last_message_time = 0 //holds the last time (based on world.time) a message was sent
|
||||
|
||||
/////////
|
||||
//OTHER//
|
||||
|
||||
@@ -233,19 +233,25 @@
|
||||
return 0
|
||||
return 1
|
||||
|
||||
/client/proc/handle_spam_prevention(var/message, var/mute_type)
|
||||
if(config.automute_on && !holder && src.last_message == message)
|
||||
src.last_message_count++
|
||||
if(src.last_message_count >= SPAM_TRIGGER_AUTOMUTE)
|
||||
to_chat(src, "\red You have exceeded the spam filter limit for identical messages. An auto-mute was applied.")
|
||||
cmd_admin_mute(src.mob, mute_type, 1)
|
||||
/client/proc/handle_spam_prevention(var/message, var/mute_type, var/throttle = 0)
|
||||
if(config.automute_on && !holder && last_message == message)
|
||||
last_message_count++
|
||||
if(last_message_count >= SPAM_TRIGGER_AUTOMUTE)
|
||||
to_chat(src, "<span class='danger'>You have exceeded the spam filter limit for identical messages. An auto-mute was applied.</span>")
|
||||
cmd_admin_mute(mob, mute_type, 1)
|
||||
return 1
|
||||
if(src.last_message_count >= SPAM_TRIGGER_WARNING)
|
||||
to_chat(src, "\red You are nearing the spam filter limit for identical messages.")
|
||||
if(last_message_count >= SPAM_TRIGGER_WARNING)
|
||||
to_chat(src, "<span class='danger'>You are nearing the spam filter limit for identical messages.</span>")
|
||||
return 0
|
||||
else if(throttle)
|
||||
if((last_message_time + throttle > world.time) && !check_rights(R_ADMIN, 0))
|
||||
var/wait_time = round(((last_message_time + throttle) - world.time) / 10, 1)
|
||||
to_chat(src, "<span class='danger'>You are sending messages to quickly. Please wait [wait_time] [wait_time == 1 ? "second" : "seconds"] before sending another message.</span>")
|
||||
return 1
|
||||
last_message_time = world.time
|
||||
else
|
||||
last_message = message
|
||||
src.last_message_count = 0
|
||||
last_message_count = 0
|
||||
return 0
|
||||
|
||||
//This stops files larger than UPLOAD_LIMIT being sent from client to server via input(), client.Import() etc.
|
||||
|
||||
Reference in New Issue
Block a user