diff --git a/code/controllers/configuration/entries/general.dm b/code/controllers/configuration/entries/general.dm index e829aae0adb..24e282086a5 100644 --- a/code/controllers/configuration/entries/general.dm +++ b/code/controllers/configuration/entries/general.dm @@ -491,6 +491,10 @@ /datum/config_entry/flag/auto_profile +/datum/config_entry/string/centcom_ban_db // URL for the CentCom Galactic Ban DB API + +/datum/config_entry/string/centcom_source_whitelist + // DISCORD ROLE STUFFS // Using strings for everything because BYOND does not like numbers this big // (exception to the above is required living hours haha) diff --git a/code/modules/admin/admin.dm b/code/modules/admin/admin.dm index d7bed2b6e82..e11a695ada2 100644 --- a/code/modules/admin/admin.dm +++ b/code/modules/admin/admin.dm @@ -40,6 +40,11 @@ if(M.client) body += "
\[First Seen: [M.client.player_join_date]\]\[Byond account registered on: [M.client.account_join_date]\]" + body += "

CentCom Galactic Ban DB: " + if(CONFIG_GET(string/centcom_ban_db)) + body += "Search" + else + body += "Disabled" body += "

Show related accounts by: " body += "\[ CID | " body += "IP \]" diff --git a/code/modules/admin/topic.dm b/code/modules/admin/topic.dm index ea368a13132..636a01efd6a 100644 --- a/code/modules/admin/topic.dm +++ b/code/modules/admin/topic.dm @@ -2071,6 +2071,71 @@ usr << browse(dat.Join("
"), "window=related_[C];size=420x300") + else if(href_list["centcomlookup"]) + if(!check_rights(R_ADMIN)) + return + + if(!CONFIG_GET(string/centcom_ban_db)) + to_chat(usr, "Centcom Galactic Ban DB is disabled!") + return + + var/ckey = href_list["centcomlookup"] + + // Make the request + var/datum/http_request/request = new() + request.prepare(RUSTG_HTTP_METHOD_GET, "[CONFIG_GET(string/centcom_ban_db)]/[ckey]", "", "") + request.begin_async() + UNTIL(request.is_complete() || !usr) + if (!usr) + return + var/datum/http_response/response = request.into_response() + + var/list/bans + + var/list/dat = list("") + + if(response.errored) + dat += "
Failed to connect to CentCom." + else if(response.status_code != 200) + dat += "
Failed to connect to CentCom. Status code: [response.status_code]" + else + if(response.body == "[]") + dat += "
0 bans detected for [ckey]
" + else + bans = json_decode(response["body"]) + + //Ignore bans from non-whitelisted sources, if a whitelist exists + var/list/valid_sources + if(CONFIG_GET(string/centcom_source_whitelist)) + valid_sources = splittext(CONFIG_GET(string/centcom_source_whitelist), ",") + dat += "
Bans detected for [ckey]
" + else + //Ban count is potentially inaccurate if they're using a whitelist + dat += "
[bans.len] ban\s detected for [ckey]
" + + for(var/list/ban in bans) + if(valid_sources && !(ban["sourceName"] in valid_sources)) + continue + dat += "Server: [sanitize(ban["sourceName"])]
" + dat += "RP Level: [sanitize(ban["sourceRoleplayLevel"])]
" + dat += "Type: [sanitize(ban["type"])]
" + dat += "Banned By: [sanitize(ban["bannedBy"])]
" + dat += "Reason: [sanitize(ban["reason"])]
" + dat += "Datetime: [sanitize(ban["bannedOn"])]
" + var/expiration = ban["expires"] + dat += "Expires: [expiration ? "[sanitize(expiration)]" : "Permanent"]
" + if(ban["type"] == "job") + dat += "Jobs: " + var/list/jobs = ban["jobs"] + dat += sanitize(jobs.Join(", ")) + dat += "
" + dat += "
" + + dat += "
" + var/datum/browser/popup = new(usr, "centcomlookup-[ckey]", "
Central Command Galactic Ban Database
", 700, 600) + popup.set_content(dat.Join()) + popup.open(0) + else if(href_list["modantagrep"]) if(!check_rights(R_ADMIN)) return diff --git a/config/config.txt b/config/config.txt index 93ae9d9ba36..edf887dc0e6 100644 --- a/config/config.txt +++ b/config/config.txt @@ -494,6 +494,13 @@ DEFAULT_VIEW_SQUARE 15x15 ## Enable automatic profiling - Byond 513.1506 and newer only. #AUTO_PROFILE +## Uncomment to enable global ban DB using the provided URL. The API should expect to receive a ckey at the end of the URL. +## More API details can be found here: https://centcom.melonmesa.com +#CENTCOM_BAN_DB https://centcom.melonmesa.com/ban/search +## Uncomment to enable source whitelisting, a comma-separated list (no spaces) of CentCom sources (sourceName). +## If enabled, only bans from these servers will be shown to admins using CentCom. The default sources list is an example. +#CENTCOM_SOURCE_WHITELIST Beestation MRP,TGMC,FTL13 + #### DISCORD STUFFS #### ## MAKE SURE ALL SECTIONS OF THIS ARE FILLED OUT BEFORE ENABLING ## Discord IDs can be obtained by following this guide: https://support.discord.com/hc/en-us/articles/206346498-Where-can-I-find-my-User-Server-Message-ID-