Merge remote-tracking branch 'ParadiseSS13/master' into multi-instance-support

This commit is contained in:
AffectedArc07
2021-10-12 20:27:07 +01:00
168 changed files with 4097 additions and 8536 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 ""