Merge branch 'master' into nanoui-is-dead

This commit is contained in:
AffectedArc07
2020-11-26 09:34:14 +00:00
committed by GitHub
70 changed files with 719 additions and 1906 deletions
+14 -9
View File
@@ -252,19 +252,22 @@
/// Role ID to be pinged for administrative events
var/discord_admin_role_id = null // Intentional null usage
/// Webhook URL for the main public webhook
var/discord_main_webhook_url
/// Webhook URLs for the main public webhook
var/list/discord_main_webhook_urls = list()
/// Webhook URL for the admin webhook
var/discord_admin_webhook_url
/// Webhook URLs for the admin webhook
var/list/discord_admin_webhook_urls = list()
/// Webhook URL for the mentor webhook
var/discord_mentor_webhook_url
/// Webhook URLs for the mentor webhook
var/list/discord_mentor_webhook_urls = list()
/// Do we want to forward all adminhelps to the discord or just ahelps when admins are offline.
/// (This does not mean all ahelps are pinged, only ahelps sent when staff are offline get the ping, regardless of this setting)
var/discord_forward_all_ahelps = FALSE
/// URL for the CentCom Ban DB API
var/centcom_ban_db_url = null
/datum/configuration/New()
for(var/T in subtypesof(/datum/game_mode))
var/datum/game_mode/M = T
@@ -746,14 +749,16 @@
if("discord_webhooks_admin_role_id")
discord_admin_role_id = "[value]" // This MUST be a string because BYOND doesnt like massive integers
if("discord_webhooks_main_url")
discord_main_webhook_url = value
discord_main_webhook_urls = splittext(value, "|")
if("discord_webhooks_admin_url")
discord_admin_webhook_url = value
discord_admin_webhook_urls = splittext(value, "|")
if("discord_webhooks_mentor_url")
discord_mentor_webhook_url = value
discord_mentor_webhook_urls = splittext(value, "|")
if("discord_forward_all_ahelps")
discord_forward_all_ahelps = TRUE
// End discord stuff
if("centcom_ban_db_url")
centcom_ban_db_url = value
else
log_config("Unknown setting in configuration: '[name]'")
+14 -12
View File
@@ -15,30 +15,32 @@ SUBSYSTEM_DEF(discord)
/datum/controller/subsystem/discord/proc/send2discord_simple(destination, content)
if(!enabled)
return
var/webhook_url
var/list/webhook_urls
switch(destination)
if(DISCORD_WEBHOOK_ADMIN)
webhook_url = config.discord_admin_webhook_url
webhook_urls = config.discord_admin_webhook_urls
if(DISCORD_WEBHOOK_PRIMARY)
webhook_url = config.discord_main_webhook_url
webhook_urls = config.discord_main_webhook_urls
if(DISCORD_WEBHOOK_MENTOR)
webhook_url = config.discord_mentor_webhook_url
webhook_urls = config.discord_mentor_webhook_urls
var/datum/discord_webhook_payload/dwp = new()
dwp.webhook_content = content
SShttp.create_async_request(RUSTG_HTTP_METHOD_POST, webhook_url, dwp.serialize2json(), list("content-type" = "application/json"))
for(var/url in webhook_urls)
SShttp.create_async_request(RUSTG_HTTP_METHOD_POST, url, dwp.serialize2json(), list("content-type" = "application/json"))
// This one is designed to take in a [/datum/discord_webhook_payload] which was prepared beforehand
/datum/controller/subsystem/discord/proc/send2discord_complex(destination, datum/discord_webhook_payload/dwp)
if(!enabled)
return
var/webhook_url
var/list/webhook_urls
switch(destination)
if(DISCORD_WEBHOOK_ADMIN)
webhook_url = config.discord_admin_webhook_url
webhook_urls = config.discord_admin_webhook_urls
if(DISCORD_WEBHOOK_PRIMARY)
webhook_url = config.discord_main_webhook_url
SShttp.create_async_request(RUSTG_HTTP_METHOD_POST, webhook_url, dwp.serialize2json(), list("content-type" = "application/json"))
webhook_urls = config.discord_main_webhook_urls
for(var/url in webhook_urls)
SShttp.create_async_request(RUSTG_HTTP_METHOD_POST, url, dwp.serialize2json(), list("content-type" = "application/json"))
// This one is for sending messages to the admin channel if no admins are active, complete with a ping to the game admins role
/datum/controller/subsystem/discord/proc/send2discord_simple_noadmins(content, check_send_always = FALSE)
@@ -66,8 +68,8 @@ SUBSYSTEM_DEF(discord)
var/datum/discord_webhook_payload/dwp = new()
dwp.webhook_content = message
SShttp.create_async_request(RUSTG_HTTP_METHOD_POST, config.discord_admin_webhook_url, dwp.serialize2json(), list("content-type" = "application/json"))
for(var/url in config.discord_admin_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()
@@ -79,4 +81,4 @@ SUBSYSTEM_DEF(discord)
last_administration_ping = world.time + 60 SECONDS
return "<@&[config.discord_admin_role_id]>"
return "*(Role not configured)*"
return ""
+6
View File
@@ -9,12 +9,17 @@ SUBSYSTEM_DEF(http)
var/list/datum/http_request/active_async_requests
/// Variable to define if logging is enabled or not. Disabled by default since we know the requests the server is making. Enable with VV if you need to debug requests
var/logging_enabled = FALSE
/// Total requests the SS has processed in a round
var/total_requests
/datum/controller/subsystem/http/Initialize(start_timeofday)
rustg_create_async_http_client() // Open the door
active_async_requests = list()
return ..()
/datum/controller/subsystem/http/stat_entry()
..("P: [length(active_async_requests)] | T: [total_requests]")
/datum/controller/subsystem/http/fire(resumed)
for(var/r in active_async_requests)
var/datum/http_request/req = r
@@ -57,6 +62,7 @@ SUBSYSTEM_DEF(http)
// Begin it and add it to the SS active list
req.begin_async()
active_async_requests += req
total_requests++
if(logging_enabled)
// Create a log holder
+6 -3
View File
@@ -127,9 +127,10 @@ SUBSYSTEM_DEF(ticker)
if((GLOB.master_mode=="random") || (GLOB.master_mode=="secret"))
runnable_modes = config.get_runnable_modes()
if(runnable_modes.len==0)
to_chat(world, "<B>Unable to choose playable game mode.</B> Reverting to pre-game lobby.")
force_start = FALSE
current_state = GAME_STATE_PREGAME
Master.SetRunLevel(RUNLEVEL_LOBBY)
to_chat(world, "<B>Unable to choose playable game mode.</B> Reverting to pre-game lobby.")
return 0
if(GLOB.secret_force_mode != "secret")
var/datum/game_mode/M = config.pick_mode(GLOB.secret_force_mode)
@@ -147,6 +148,7 @@ SUBSYSTEM_DEF(ticker)
to_chat(world, "<B>Unable to start [mode.name].</B> Not enough players, [mode.required_players] players needed. Reverting to pre-game lobby.")
mode = null
current_state = GAME_STATE_PREGAME
force_start = FALSE
SSjobs.ResetOccupations()
Master.SetRunLevel(RUNLEVEL_LOBBY)
return 0
@@ -158,8 +160,9 @@ SUBSYSTEM_DEF(ticker)
SSjobs.DivideOccupations() //Distribute jobs
if(!can_continue)
qdel(mode)
current_state = GAME_STATE_PREGAME
to_chat(world, "<B>Error setting up [GLOB.master_mode].</B> Reverting to pre-game lobby.")
current_state = GAME_STATE_PREGAME
force_start = FALSE
SSjobs.ResetOccupations()
Master.SetRunLevel(RUNLEVEL_LOBBY)
return 0
@@ -276,7 +279,7 @@ SUBSYSTEM_DEF(ticker)
//start_events() //handles random events and space dust.
//new random event system is handled from the MC.
SSdiscord.send2discord_simple_noadmins("Round has started")
SSdiscord.send2discord_simple_noadmins("**\[Info]** Round has started")
auto_toggle_ooc(0) // Turn it off
round_start_time = world.time