Merge pull request #695 from Citadel-Station-13/upstream-merge-24002

[MIRROR] PR announcement spam prevention
This commit is contained in:
kevinz000
2017-05-06 21:36:41 -07:00
committed by GitHub
+20 -5
View File
@@ -136,11 +136,7 @@
if(!key_valid)
return "Bad Key"
else
#define CHAT_PULLR 64 //defined in preferences.dm, but not available here at compilation time
for(var/client/C in GLOB.clients)
if(C.prefs && (C.prefs.chat_toggles & CHAT_PULLR))
to_chat(C, "<span class='announce'>PR: [input["announce"]]</span>")
#undef CHAT_PULLR
AnnouncePR(input["announce"], json_decode(input["payload"]))
else if("crossmessage" in input)
if(!key_valid)
@@ -176,6 +172,25 @@
else if("server_hop" in input)
show_server_hop_transfer_screen(input["server_hop"])
#define PR_ANNOUNCEMENTS_PER_ROUND 5 //The number of unique PR announcements allowed per round
//This makes sure that a single person can only spam 3 reopens and 3 closes before being ignored
/world/proc/AnnouncePR(announcement, list/payload)
var/static/list/PRcounts = list() //PR id -> number of times announced this round
var/id = "[payload["pull_request"]["id"]]"
if(!PRcounts[id])
PRcounts[id] = 1
else
++PRcounts[id]
if(PRcounts[id] > PR_ANNOUNCEMENTS_PER_ROUND)
return
#define CHAT_PULLR 64 //defined in preferences.dm, but not available here at compilation time
for(var/client/C in GLOB.clients)
if(C.prefs && (C.prefs.chat_toggles & CHAT_PULLR))
C << "<span class='announce'>PR: [announcement]</span>"
#undef CHAT_PULLR
#define WORLD_REBOOT(X) log_world("World rebooted at [time_stamp()]"); ..(X); return;
/world/Reboot(var/reason, var/feedback_c, var/feedback_r, var/time)
if (reason == 1) //special reboot, do none of the normal stuff