mirror of
https://github.com/VOREStation/VOREStation.git
synced 2026-07-21 12:05:28 +01:00
Experimental implementation of automated role pings
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
var/global/last_fax_role_request
|
||||
|
||||
/obj/machinery/photocopier/faxmachine
|
||||
req_one_access = list()
|
||||
|
||||
@@ -47,6 +49,21 @@
|
||||
query_string += "&sentname=[url_encode(sent.name)]"
|
||||
world.Export("[config.chat_webhook_url]?[query_string]")
|
||||
|
||||
/**
|
||||
* Call the chat webhook to transmit a notification of a job request
|
||||
*/
|
||||
/obj/machinery/photocopier/faxmachine/proc/message_chat_rolerequest(var/font_colour="#006100", var/role_to_ping, var/reason, var/jobname)
|
||||
if(config.chat_webhook_url || 1)
|
||||
spawn(0)
|
||||
var/query_string = "type=rolerequest"
|
||||
query_string += "&key=[url_encode(config.chat_webhook_key)]"
|
||||
query_string += "&ping=[url_encode(role_to_ping)]"
|
||||
query_string += "&color=[url_encode(font_colour)]"
|
||||
query_string += "&reason=[url_encode(reason)]"
|
||||
query_string += "&job=[url_encode(jobname)]"
|
||||
world.Export("[config.chat_webhook_url]?[query_string]")
|
||||
to_world(query_string)
|
||||
|
||||
//
|
||||
// Overrides/additions to stock defines go here, as well as hooks. Sort them by
|
||||
// the object they are overriding. So all /mob/living together, etc.
|
||||
@@ -55,3 +72,80 @@
|
||||
var/chat_webhook_url = "" // URL of the webhook for sending announcements/faxes to discord chat.
|
||||
var/chat_webhook_key = "" // Shared secret for authenticating to the chat webhook
|
||||
var/fax_export_dir = "data/faxes" // Directory in which to write exported fax HTML files.
|
||||
|
||||
|
||||
/obj/machinery/photocopier/faxmachine/verb/request_roles()
|
||||
set name = "Staff Request Form"
|
||||
set category = "Object"
|
||||
set src in oview(1)
|
||||
|
||||
var/mob/living/L = usr
|
||||
|
||||
if(!L || !isturf(L.loc) || !isliving(L))
|
||||
return
|
||||
if(!ishuman(L) && !issilicon(L))
|
||||
return
|
||||
if(L.stat || L.restrained())
|
||||
return
|
||||
if(last_fax_role_request && (world.time - last_fax_role_request < 5 MINUTES))
|
||||
to_chat(L, "<span class='warning'>The global automated relays are still recalibrating. Try again later or relay your request in written form for processing.</span>")
|
||||
return
|
||||
|
||||
var/confirmation = tgui_alert(L, "Are you sure you want to send automated crew request?", "Confirmation", list("Yes", "No", "Cancel"))
|
||||
if(confirmation != "Yes")
|
||||
return
|
||||
|
||||
var/list/jobs = list()
|
||||
for(var/datum/department/dept as anything in SSjob.get_all_department_datums())
|
||||
if(!dept.assignable || dept.centcom_only)
|
||||
continue
|
||||
jobs |= SSjob.get_job_titles_in_department(dept.name)
|
||||
|
||||
var/role = tgui_input_list(L, "Pick the job to request.", "Job Request", jobs)
|
||||
if(!role)
|
||||
return
|
||||
|
||||
var/reason = ""
|
||||
reason = tgui_input_text(L, "Reason (maximum 100 symbols):","Reason")
|
||||
if(length(reason) > 110)
|
||||
to_chat(L, "<span class='warning'>The reason you've input is too long. Try again briefer.</span>")
|
||||
return
|
||||
|
||||
var/final_conf = tgui_alert(L, "You are about to request [role]. Are you sure?", "Confirmation", list("Yes", "No", "Cancel"))
|
||||
if(final_conf != "Yes")
|
||||
return
|
||||
|
||||
var/datum/department/ping_dept = SSjob.get_ping_role(role)
|
||||
if(!ping_dept)
|
||||
to_chat(L, "<span class='warning'>Selected job cannot be requested for \[ERRORDEPTNOTFOUND] reason. Please report this to system administrator.</span>")
|
||||
return
|
||||
var/message_color = "#FFFFFF"
|
||||
var/ping_name = null
|
||||
switch(ping_dept.name)
|
||||
if(DEPARTMENT_COMMAND)
|
||||
ping_name = "Command"
|
||||
if(DEPARTMENT_SECURITY)
|
||||
ping_name = "Security"
|
||||
if(DEPARTMENT_ENGINEERING)
|
||||
ping_name = "Engineering"
|
||||
if(DEPARTMENT_MEDICAL)
|
||||
ping_name = "Medical"
|
||||
if(DEPARTMENT_RESEARCH)
|
||||
ping_name = "Research"
|
||||
if(DEPARTMENT_CARGO)
|
||||
ping_name = "Supply"
|
||||
if(DEPARTMENT_CIVILIAN)
|
||||
ping_name = "Service"
|
||||
if(DEPARTMENT_PLANET)
|
||||
ping_name = "Expedition"
|
||||
if(DEPARTMENT_SYNTHETIC)
|
||||
ping_name = "Silicon"
|
||||
//if(DEPARTMENT_TALON)
|
||||
// ping_name = "Offmap"
|
||||
if(!ping_name)
|
||||
to_chat(L, "<span class='warning'>Selected job cannot be requested for \[ERRORUNKNOWNDEPT] reason. Please report this to system administrator.</span>")
|
||||
return
|
||||
message_color = ping_dept.color
|
||||
|
||||
message_chat_rolerequest(message_color, ping_name, reason, role)
|
||||
last_fax_role_request = world.time
|
||||
Reference in New Issue
Block a user