diff --git a/code/controllers/configuration/entries/general.dm b/code/controllers/configuration/entries/general.dm index e829aae0adb..d2a620effa1 100644 --- a/code/controllers/configuration/entries/general.dm +++ b/code/controllers/configuration/entries/general.dm @@ -491,6 +491,8 @@ /datum/config_entry/flag/auto_profile +/datum/config_entry/string/centcom_ban_db // URL for the CentCom Galactic Ban DB API + // 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 da5e3dc7c38..da3249d6840 100644 --- a/code/modules/admin/admin.dm +++ b/code/modules/admin/admin.dm @@ -43,6 +43,11 @@ body += "

Show related accounts by: " body += "\[ CID | " body += "IP \]" + body += "

CentCom Galactic Ban DB: " + if(CONFIG_GET(string/centcom_ban_db)) + body += "Search" + else + body += "Disabled" var/rep = 0 rep += SSpersistence.antag_rep[M.ckey] body += "

Antagonist reputation: [rep]" diff --git a/code/modules/admin/topic.dm b/code/modules/admin/topic.dm index ea368a13132..015be8c1a16 100644 --- a/code/modules/admin/topic.dm +++ b/code/modules/admin/topic.dm @@ -2071,6 +2071,59 @@ 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"]) + dat += "
[bans.len] ban\s detected for [ckey]
" + for(var/list/ban in bans) + dat += "Server: [sanitize(ban["sourceName"])]
" + 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..30edbecbea2 100644 --- a/config/config.txt +++ b/config/config.txt @@ -494,6 +494,10 @@ 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/swagger/index.html +#CENTCOM_BAN_DB https://centcom.melonmesa.com/ban/search + #### 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-