Files
Bubberstation/code/datums/http.dm
AffectedArc07 0315245729 Adds in discord auto-roling (#49374)
About The Pull Request

When a user successfully links their BYOND accounts and discord accounts, they will now be automatically roled, based on config settings.

NOTE: This does not update pre-linked accounts, but I can write an external bot to do that if needed

RUST-G has also been updated in this PR, to be inline with this PR over at RUST-G tgstation/rust-g#23

Why It's Good For The Game

People with linked accounts can now be given a specific role in the discord, which is good for verification.
Changelog

🆑 AffectedArc07
add: Linking your discord and BYOND accounts will now give you a role in the discord
/🆑
2020-02-20 22:37:14 +13:00

75 lines
1.4 KiB
Plaintext

/datum/http_request
var/id
var/in_progress = FALSE
var/method
var/body
var/headers
var/url
var/_raw_response
/datum/http_request/proc/prepare(method, url, body = "", list/headers)
if (!length(headers))
headers = ""
else
headers = json_encode(headers)
src.method = method
src.url = url
src.body = body
src.headers = headers
/datum/http_request/proc/execute_blocking()
_raw_response = rustg_http_request_blocking(method, url, body, headers)
/datum/http_request/proc/begin_async()
if (in_progress)
CRASH("Attempted to re-use a request object.")
id = rustg_http_request_async(method, url, body, headers)
if (isnull(text2num(id)))
CRASH("Proc error: [id]")
_raw_response = "Proc error: [id]"
else
in_progress = TRUE
/datum/http_request/proc/is_complete()
if (isnull(id))
return TRUE
if (!in_progress)
return TRUE
var/r = rustg_http_check_request(id)
if (r == RUSTG_JOB_NO_RESULTS_YET)
return FALSE
else
_raw_response = r
in_progress = FALSE
return TRUE
/datum/http_request/proc/into_response()
var/datum/http_response/R = new()
try
var/list/L = json_decode(_raw_response)
R.status_code = L["status_code"]
R.headers = L["headers"]
R.body = L["body"]
catch
R.errored = TRUE
R.error = _raw_response
return R
/datum/http_response
var/status_code
var/body
var/list/headers
var/errored = FALSE
var/error