Adds a discord ping for mhelps if there aren't any mentors online (#15533)

* V1

* send2discord_simple_nomentors() proc

* Oh and this too

* Proc name

* Warning comment

Co-authored-by: AffectedArc07 <25063394+AffectedArc07@users.noreply.github.com>

* Mentor logout notification message

Adding it in this PR since it's related

* Actually on second thought, this should definitely be its own PR instead

This reverts commit 1e93624c8b.

Co-authored-by: AffectedArc07 <25063394+AffectedArc07@users.noreply.github.com>
This commit is contained in:
SabreML
2021-10-11 10:05:18 +01:00
committed by GitHub
co-authored by AffectedArc07
parent 01ca06aa13
commit 3935be5808
4 changed files with 41 additions and 10 deletions
+33
View File
@@ -5,6 +5,8 @@ SUBSYSTEM_DEF(discord)
var/enabled = FALSE
/// Last time the administrator ping was dropped. This ensures administrators cannot be mass pinged if a large chunk of ahelps go off at once (IE: tesloose)
var/last_administration_ping = 0
/// Last time the mentor ping was dropped. This ensures mentors cannot be mass pinged if a large chunk of mhelps go off at once.
var/last_mentor_ping = 0
/datum/controller/subsystem/discord/Initialize(start_timeofday)
if(GLOB.configuration.discord.webhooks_enabled)
@@ -75,6 +77,27 @@ SUBSYSTEM_DEF(discord)
for(var/url in GLOB.configuration.discord.admin_webhook_urls)
SShttp.create_async_request(RUSTG_HTTP_METHOD_POST, url, dwp.serialize2json(), list("content-type" = "application/json"))
/datum/controller/subsystem/discord/proc/send2discord_simple_mentor(content)
var/alerttext
var/list/mentorcounter = staff_countup(R_MENTOR)
var/active_mentors = mentorcounter[1]
var/inactive_mentors = mentorcounter[3]
var/add_ping = FALSE
if(active_mentors <= 0)
add_ping = TRUE
if(inactive_mentors)
alerttext = "| **ALL MENTORS AFK**"
else
alerttext = "| **NO MENTORS ONLINE**"
var/message = "[content] [alerttext][add_ping ? handle_mentor_ping() : ""]"
var/datum/discord_webhook_payload/dwp = new()
dwp.webhook_content = message
for(var/url in GLOB.configuration.discord.mentor_webhook_urls)
SShttp.create_async_request(RUSTG_HTTP_METHOD_POST, url, dwp.serialize2json(), list("content-type" = "application/json"))
// Helper to make administrator ping easier
/datum/controller/subsystem/discord/proc/handle_administrator_ping()
// Check if a role is even set
@@ -86,3 +109,13 @@ SUBSYSTEM_DEF(discord)
return "<@&[GLOB.configuration.discord.admin_role_id]>"
return ""
/datum/controller/subsystem/discord/proc/handle_mentor_ping()
if(GLOB.configuration.discord.mentor_role_id)
if(last_mentor_ping > world.time)
return " *(Role pinged recently)*"
last_mentor_ping = world.time + 60 SECONDS
return " <@&[GLOB.configuration.discord.mentor_role_id]>"
return ""