BOREALIS 2 Implementation (#938)

Removes BOREALIS I.
Implements HTTP POST requests, credit to Oisin100 from Yogstation13 for the ByondPOST.dll.
Implements the BOREALIS II datum and converts all calls to reroute to that.
Adds round logging to channel_announce channels.
This commit is contained in:
skull132
2016-09-18 23:28:01 +03:00
committed by GitHub
parent 682e1efa8a
commit 759c463a2c
19 changed files with 432 additions and 16 deletions
+5 -3
View File
@@ -99,10 +99,12 @@ var/list/adminhelp_ignored_words = list("unknown","the","a","an","of","monkey","
msg = "\blue <b><font color=red>Request for Help:: </font>[get_options_bar(mob, 3, 1, 1)][ai_cl]:</b> [msg]"
var/admin_number_present = 0
var/admin_number_afk = 0
for(var/client/X in admins)
if((R_ADMIN|R_MOD) & X.holder.rights)
admin_number_present++
if(X.is_afk())
admin_number_afk++
if(X.prefs.toggles & SOUND_ADMINHELP)
@@ -113,9 +115,9 @@ var/list/adminhelp_ignored_words = list("unknown","the","a","an","of","monkey","
//show it to the person adminhelping too
src << "<font color='blue'>PM to-<b>Staff </b>: [original_msg]</font>"
var/admin_number_present = admins.len - admin_number_afk
var/admin_number_active = admin_number_present - admin_number_afk
log_admin("HELP: [key_name(src)]: [original_msg] - heard by [admin_number_present] non-AFK admins.")
if(admin_number_present <= 0)
send_to_admin_discord("@everyone Request for Help from [key_name(src)]: [html_decode(original_msg)] - !![admin_number_afk ? "All admins AFK ([admin_number_afk])" : "No admins online"]!!")
if(admin_number_active <= 0)
discord_bot.send_to_admins("@everyone Request for Help from [key_name(src)]: [html_decode(original_msg)] - !![admin_number_afk ? "All admins AFK ([admin_number_afk])" : "No admins online"]!!")
feedback_add_details("admin_verb","AH") //If you are copy-pasting this, ensure the 2nd parameter is unique to the new proc!
return
+1 -1
View File
@@ -129,7 +129,7 @@
sanitize(msg)
send_to_admin_discord("PlayerPM to [sender] from [key_name(src)]: [html_decode(msg)]")
discord_bot.send_to_admins("PlayerPM to [sender] from [key_name(src)]: [html_decode(msg)]")
src << "<span class='pm'><span class='out'>" + create_text_tag("pm_out_alt", "", src) + " to <span class='name'>Discord-[sender]</span>: <span class='message'>[msg]</span></span></span>"
+2 -1
View File
@@ -1,7 +1,8 @@
var/list/forbidden_varedit_object_types = list(
/datum/admins, //Admins editing their own admin-power object? Yup, sounds like a good idea.
/obj/machinery/blackbox_recorder, //Prevents people messing with feedback gathering
/datum/feedback_variable //Prevents people messing with feedback gathering
/datum/feedback_variable, //Prevents people messing with feedback gathering
/datum/discord_bot //Nope.jpg. Stop it.
)
/*
+1 -1
View File
@@ -29,7 +29,7 @@
//log_admin("HELP: [key_name(src)]: [msg]")
/proc/Centcomm_announce(var/msg, var/mob/Sender, var/iamessage)
send_to_cciaa_discord("!!! @everyone - Emergency message from the station: `[msg]`, sent by [Sender] !!!")
discord_bot.send_to_cciaa("@here - Emergency message from the station: `[msg]`, sent by [Sender]!")
var/msg_cciaa = "\blue <b><font color=orange>CENTCOMM[iamessage ? " IA" : ""]:</font>[key_name(Sender, 1)] (<A HREF='?_src_=holder;CentcommReply=\ref[Sender]'>RPLY</A>):</b> [msg]"
msg = "\blue <b><font color=orange>CENTCOMM[iamessage ? " IA" : ""]:</font>[key_name(Sender, 1)] (<A HREF='?_src_=holder;adminplayeropts=\ref[Sender]'>PP</A>) (<A HREF='?_src_=vars;Vars=\ref[Sender]'>VV</A>) (<A HREF='?_src_=holder;subtlemessage=\ref[Sender]'>SM</A>) (<A HREF='?_src_=holder;adminplayerobservejump=\ref[Sender]'>JMP</A>) (<A HREF='?_src_=holder;secretsadmin=check_antagonist'>CA</A>) (<A HREF='?_src_=holder;BlueSpaceArtillery=\ref[Sender]'>BSA</A>) (<A HREF='?_src_=holder;CentcommReply=\ref[Sender]'>RPLY</A>):</b> [msg]"
+80
View File
@@ -0,0 +1,80 @@
/*
@===================================@
| |
| Guide to HTTP Post requests |
| |
@===================================@
Making POST requests in byond is SUPER easy with the post request DLL.
Simply use the call() function to call the post request DLL and enter your details!
The first bit of code needed will always be the same, You will never have to touch this, Copy-pasta all you like:
call("ByondPOST.dll", "send_post_request")
Well thats the first part, the harder part is to input the details into DLL. Lets do that now! The syntax to add arguments to the post request is:
call("ByondPOST.dll", "send_post_request")(PostURL, PostContent, Header)
In a lot of cases you might need more then one custom header to make a valid POST request, One such case is when you want to use the Discord API,
the discord API requires 2 custom headers, one to tell the server that you are making a JSON post request,
the header for this is "Content-Type: application/json" And another to tell the Discord API your login token,
Which looks like this "Authorization: YourLoginToken"
This can be achieved in Byond with the following code
call("ByondPOST.dll", "send_post_request")("http://example.com", somebodyhere, "Content-Type: application/json", "Authorization: YourTokenHere")
As you can see we have added some more arguments onto the proc, You can add as many arguments you like to the proc, Any argument after the PostContent
argument is considered a header.
Some example POST requests:
<-- Send Discord Message -->
call("ByondPOST.dll", "send_post_request")("https://discordapp.com/api/channels/134720091576205312/messages", " { \"content\" : \"Hello World!\" } ", "Content-Type: application/json", "Authorization: DAsDAs4!"DFdW45%fAsFSa^$!"$Xfdsfh523ds")
DLL Written by Oisin100 and modified by Skull132
*/
/*
* A generic proc for sending a post request with the aforementioned .DLL files.
* Expected arg structure:
* 1st arg - the url
* 2nd arg - the request body
* 3rd - nth arg - individual headers and their values in format: "headername: value"
*
* @return int - Error code from one of three possible sources!
* -1 indicates proc or library failure.
* 0 - 92 are curl errors, and are usually accompanied by a HTTP response code of 0 (request was never made).
* 100 - 6xx are HTTP response codes. Curl error code should be 0 in this case, but, in case that it is not,
* the HTTP response code is always returned as long as it is not 0.
*
*/
/proc/send_post_request()
if (args.len < 2)
return -1
var/result = call("ByondPOST.dll", "send_post_request")(arglist(args))
if (!result)
log_debug("ByondPOST: No result returned from external library.")
return -1
var/list/A = params2list(result)
if (!isnull(A["proc"]))
// Log the proc error. It should be reviewed by coders ASAP.
switch (A["proc"])
if ("1")
log_debug("ByondPOST: Proc error: Too few arguments sent to function.")
if ("2")
log_debug("ByondPOST: Proc error: Unable to initialize curl object.")
else
log_debug("ByondPOST: Proc error: Unknown error.")
return -1
// Curl oriented errors should leave the HTTP response code at 0, as no request was executed.
// All HTTP oriented errors will definately return a response code other than 0, so prioritize that.
// Fallback is a curl error code (0 - 92).
return text2num(A["http"]) != 0 ? text2num(A["http"]) : text2num(A["curl"])
+12 -3
View File
@@ -4,11 +4,20 @@
log_access("Logout: [key_name(src)]")
if(admin_datums[src.ckey])
if (ticker && ticker.current_state == GAME_STATE_PLAYING) //Only report this stuff if we are currently playing.
var/admins_number = admins.len
var/admins_number = 0
var/admins_number_afk = 0
for (var/client/C)
if (C.holder && (C.holder.rights & (R_MOD|R_ADMIN)))
admins_number++
if (C.is_afk())
admins_number_afk++
message_admins("Admin logout: [key_name(src)]")
if(admins_number == 0) //Apparently the admin logging out is no longer an admin at this point, so we have to check this towards 0 and not towards 1. Awell.
send_to_admin_discord("@everyone [key_name(src)] logged out - no more admins online.")
if (admins_number == 0) //Apparently the admin logging out is no longer an admin at this point, so we have to check this towards 0 and not towards 1. Awell.
discord_bot.send_to_admins("@here [key_name(src)] logged out - no more admins online.")
else if ((admins_number - admins_number_afk) <= 0)
discord_bot.send_to_admins("[key_name(src)] logged out - only AFK admins ([admins_number_afk]) are online.")
..()
return 1
+1 -1
View File
@@ -252,7 +252,7 @@ var/list/sent_faxes = list() //cache for faxes that have been sent by the admins
if((R_ADMIN|R_CCIAA) & C.holder.rights)
C << msg
send_to_cciaa_discord("New fax arrived! [faxname]: \"[sent.name]\" by [sender].")
discord_bot.send_to_cciaa("New fax arrived! [faxname]: \"[sent.name]\" by [sender].")
/obj/machinery/photocopier/faxmachine/proc/do_pda_alerts()
if (!alert_pdas || !alert_pdas.len)