From f35fa9f2d3972cd8eaecd772f1e8e428257c0530 Mon Sep 17 00:00:00 2001 From: Cyberboss Date: Mon, 1 May 2017 13:46:30 -0400 Subject: [PATCH] PR announcement spam prevention (#24002) * PR announcement spam prevention * Use the payload * Update world.dm * Update world.dm --- code/world.dm | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/code/world.dm b/code/world.dm index 34e3265fcad..8898c7ce060 100644 --- a/code/world.dm +++ b/code/world.dm @@ -134,11 +134,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, "PR: [input["announce"]]") -#undef CHAT_PULLR + AnnouncePR(input["announce"], json_decode(input["payload"])) else if("crossmessage" in input) if(!key_valid) @@ -174,7 +170,27 @@ 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 << "PR: [announcement]" +#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 if (usr) @@ -315,4 +331,4 @@ status = s /world/proc/has_round_started() - return SSticker.HasRoundStarted() \ No newline at end of file + return SSticker.HasRoundStarted()