Adds Automuting

Adds a system adapted from Aurora that will automatically mute someone if they say things too quickly in IC, OOC, Deadchat, Ahelp, or Pray.
This commit is contained in:
Neerti
2017-01-07 16:27:35 -05:00
parent 8ae0c62d60
commit 82ad098e33
8 changed files with 32 additions and 5 deletions

View File

@@ -37,6 +37,8 @@
log_ooc("[mob.name]/[key] : [msg]")
handle_spam_prevention(MUTE_OOC)
var/ooc_style = "everyone"
if(holder && !holder.fakekey)
ooc_style = "elevated"
@@ -105,6 +107,8 @@
log_ooc("(LOCAL) [mob.name]/[key] : [msg]")
handle_spam_prevention(MUTE_OOC)
var/mob/source = mob.get_looc_source()
var/turf/T = get_turf(source)
if(!T) return
@@ -137,7 +141,7 @@
// Send a message
for(var/client/target in receivers)
var/admin_stuff = ""
if(target in admins)
admin_stuff += "/([key])"
@@ -145,7 +149,7 @@
for(var/client/target in r_receivers)
var/admin_stuff = "/([key])([admin_jump_link(mob, target.holder)])"
target << "<span class='ooc'><span class='looc'>" + create_text_tag("looc", "LOOC:", target) + " <span class='prefix'>(R)</span><EM>[display_name][admin_stuff]:</EM> <span class='message'>[msg]</span></span></span>"
/mob/proc/get_looc_source()

View File

@@ -17,6 +17,8 @@ var/list/adminhelp_ignored_words = list("unknown","the","a","an","of","monkey","
adminhelped = 1 //Determines if they get the message to reply by clicking the name.
handle_spam_prevention(MUTE_ADMINHELP)
//clean the input msg
if(!msg)
return

View File

@@ -10,6 +10,7 @@
if(!msg) return
if(usr.client)
client.handle_spam_prevention(MUTE_PRAY)
if(usr.client.prefs.muted & MUTE_PRAY)
usr << "\red You cannot pray (muted)."
return

View File

@@ -158,7 +158,8 @@
proc/cmd_admin_mute(mob/M as mob, mute_type, automute = 0)
if(automute)
if(!config.automute_on) return
if(!config.automute_on)
return
else
if(!usr || !usr.client)
return
@@ -169,8 +170,10 @@ proc/cmd_admin_mute(mob/M as mob, mute_type, automute = 0)
usr << "<font color='red'>Error: cmd_admin_mute: This mob doesn't have a client tied to it.</font>"
if(M.client.holder)
usr << "<font color='red'>Error: cmd_admin_mute: You cannot mute an admin/mod.</font>"
if(!M.client) return
if(M.client.holder) return
if(!M.client)
return
if(M.client.holder)
return
var/muteunmute
var/mute_string

View File

@@ -0,0 +1,13 @@
// Based on Aurora's anti-spam system.
/client/
var/last_message_time = 0
var/spam_alert = 0
/client/proc/handle_spam_prevention(var/mute_type = MUTE_ALL, var/spam_delay = 1 SECOND)
if(world.time - last_message_time < spam_delay)
spam_alert++
if(spam_alert > 3)
cmd_admin_mute(src.mob, mute_type, 1)
else
spam_alert = max(0, spam_alert--)
last_message_time = world.time

View File

@@ -7,6 +7,7 @@
log_say("Ghost/[src.key] : [message]")
if (src.client)
client.handle_spam_prevention(MUTE_DEADCHAT)
if(src.client.prefs.muted & MUTE_DEADCHAT)
src << "\red You cannot talk in deadchat (muted)."
return
@@ -26,6 +27,7 @@
log_emote("Ghost/[src.key] : [message]")
if(src.client)
client.handle_spam_prevention(MUTE_DEADCHAT)
if(src.client.prefs.muted & MUTE_DEADCHAT)
src << "\red You cannot emote in deadchat (muted)."
return

View File

@@ -131,6 +131,7 @@ proc/get_radio_key_from_channel(var/channel)
/mob/living/say(var/message, var/datum/language/speaking = null, var/verb="says", var/alt_name="", var/whispering = 0)
//If you're muted for IC chat
if(client)
client.handle_spam_prevention(MUTE_IC)
if((client.prefs.muted & MUTE_IC) || say_disabled)
src << "<span class='warning'>You cannot speak in IC (Muted).</span>"
return

View File

@@ -1143,6 +1143,7 @@
#include "code\modules\client\preferences_savefile.dm"
#include "code\modules\client\preferences_spawnpoints.dm"
#include "code\modules\client\preferences_toggle_procs.dm"
#include "code\modules\client\spam_prevention.dm"
#include "code\modules\client\ui_style.dm"
#include "code\modules\client\preference_setup\_defines.dm"
#include "code\modules\client\preference_setup\preference_setup.dm"