[MIRROR] Implements Cooldown On Uploading Books to Newscaster [MDB IGNORE] (#18337)

* Implements Cooldown On Uploading Books to Newscaster (#72112)

## About The Pull Request

Hey there,

Pretty much on the tin. We implement a cooldown on the backend for a set
amount of time to prevent people spamming the newscaster channel with a
shitload of books (rather than have absolutely no safeguards against
it), and then pipe information to the UI for user feedback.
## Why It's Good For The Game

Fixes #71290

In case you weren't already aware, letting users absolutely wreck the
shit out of player's chat via newscaster spam (all newscasters forcesay
a message when something's uploaded to it) as well as just fill the shit
up of a channel with various vulgarities isn't a really good thing.
## Changelog
🆑
fix: To prevent spam, there is now a cooldown on being able to upload
assorted books into the newscaster's channel feed.
/🆑

Let me know if the cooldown seems too long, not hard to change.

* Implements Cooldown On Uploading Books to Newscaster

Co-authored-by: san7890 <the@san7890.com>
This commit is contained in:
SkyratBot
2022-12-25 17:59:35 -08:00
committed by GitHub
co-authored by san7890
parent 7977b3028f
commit 63c29b58c0
2 changed files with 27 additions and 4 deletions
+12
View File
@@ -248,6 +248,7 @@
var/duedate
#define PRINTER_COOLDOWN (6 SECONDS)
#define NEWSCASTER_COOLDOWN (10 SECONDS)
#define LIBRARY_NEWSFEED "Nanotrasen Book Club"
//The different states the computer can be in, only send the info we need yeah?
#define LIBRARY_INVENTORY 1
@@ -307,6 +308,8 @@
var/datum/weakref/scanner
///Our cooldown on using the printer
COOLDOWN_DECLARE(printer_cooldown)
///Our cooldown on publishing books to the newscaster's "book club" channel
COOLDOWN_DECLARE(newscaster_cooldown)
/obj/machinery/computer/libraryconsole/bookmanagement/Initialize(mapload)
. = ..()
@@ -374,6 +377,10 @@
var/obj/machinery/libraryscanner/scan = get_scanner()
data["has_scanner"] = !!(scan)
data["has_cache"] = !!(scan?.cache)
data["cooldown_string"] = "[DisplayTimeText(COOLDOWN_TIMELEFT(src, newscaster_cooldown))]"
data["active_newscaster_cooldown"] = COOLDOWN_FINISHED(src, newscaster_cooldown)
if(scan?.cache)
data["cache_title"] = scan.cache.get_title()
data["cache_author"] = scan.cache.get_author()
@@ -480,6 +487,10 @@
INVOKE_ASYNC(src, PROC_REF(upload_from_scanner), upload_category)
return TRUE
if("news_post")
// We grey out the button UI-side, but let's just be safe to guard against spammy spammers.
if(!COOLDOWN_FINISHED(src, newscaster_cooldown))
say("Not enough time has passed since the last news post. Please wait.")
return
if(!GLOB.news_network)
say("No news network found on station. Aborting.")
var/channelexists = FALSE
@@ -496,6 +507,7 @@
return
GLOB.news_network.submit_article(scan.cache.content, "[scan.cache.author]: [scan.cache.title]", LIBRARY_NEWSFEED, null)
say("Upload complete. Your uploaded title is now available on station newscasters.")
COOLDOWN_START(src, newscaster_cooldown, NEWSCASTER_COOLDOWN)
return TRUE
if("print_book")
var/id = params["book_id"]