From 46953e4d46fde1e3b07c6745dee957539ed97876 Mon Sep 17 00:00:00 2001 From: SkyratBot <59378654+SkyratBot@users.noreply.github.com> Date: Mon, 10 Aug 2020 08:49:28 +0200 Subject: [PATCH] [MIRROR] CentCom Galactic Ban DB: Bigger and Better Edition (#247) * CentCom Galactic Ban DB: Bigger and Better Edition (#52588) Admins will now be able to look up a player's bans from several other servers via the player panel. My hope is that porting this to as many servers as possible will encourage more servers to make their bans publicly viewable so they can be included in this system. Direct access to a server's database is not required (or even supported). Supported servers: BeeStation /vg/station OracleStation FTL13 Fulpstation TGMC Planned support (WIP): World Server Yogstation Halo: SSE Any other server willing to make their bans publicly visible. API: https://centcom.melonmesa.com Source: https://github.com/bobbahbrown/CentCom Changelog cl ike709 and bobbahbrown add: Admins can now see your bans on (some) other servers. /cl * CentCom Galactic Ban DB: Bigger and Better Edition Co-authored-by: ike709 --- .../configuration/entries/general.dm | 4 ++ code/modules/admin/admin.dm | 5 ++ code/modules/admin/topic.dm | 65 +++++++++++++++++++ config/config.txt | 7 ++ 4 files changed, 81 insertions(+) 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-