mirror of
https://github.com/ParadiseSS13/Paradise.git
synced 2025-12-25 17:51:17 +00:00
SSdiscord tweaks (#14899)
* SSdiscord tweaks * Update code/modules/admin/verbs/adminhelp.dm
This commit is contained in:
@@ -252,14 +252,14 @@
|
||||
/// 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)
|
||||
@@ -749,11 +749,11 @@
|
||||
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
|
||||
|
||||
@@ -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 ""
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -279,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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user