mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-07-20 12:35:33 +01:00
Allows players to send more visible adminhelps when no admins are on, which'll definitely alert admins (#62711)
Co-authored-by: Watermelon914 <3052169-Watermelon914@users.noreply.gitlab.com>
This commit is contained in:
@@ -279,7 +279,7 @@
|
||||
break_counter = 0
|
||||
|
||||
var/list/other_job_lists = list(
|
||||
"Abstract" = list("Appearance", "Emote", "Deadchat", "OOC"),
|
||||
"Abstract" = list("Appearance", "Emote", "Deadchat", "OOC", "Urgent Adminhelp"),
|
||||
)
|
||||
for(var/department in other_job_lists)
|
||||
output += "<div class='column'><label class='rolegroup [ckey(department)]'>[tgui_fancy ? "<input type='checkbox' name='[department]' class='hidden' onClick='header_click_all_checkboxes(this)'>" : ""][department]</label><div class='content'>"
|
||||
|
||||
@@ -192,7 +192,7 @@ GLOBAL_DATUM_INIT(ahelp_tickets, /datum/admin_help_tickets, new)
|
||||
* * msg_raw - The first message of this admin_help: used for the initial title of the ticket
|
||||
* * is_bwoink - Boolean operator, TRUE if this ticket was started by an admin PM
|
||||
*/
|
||||
/datum/admin_help/New(msg_raw, client/C, is_bwoink)
|
||||
/datum/admin_help/New(msg_raw, client/C, is_bwoink, urgent = FALSE)
|
||||
//clean the input msg
|
||||
var/msg = sanitize(copytext_char(msg_raw, 1, MAX_MESSAGE_LEN))
|
||||
if(!msg || !C || !C.mob)
|
||||
@@ -222,16 +222,46 @@ GLOBAL_DATUM_INIT(ahelp_tickets, /datum/admin_help_tickets, new)
|
||||
AddInteraction("<font color='blue'>[key_name_admin(usr)] PM'd [LinkedReplyName()]</font>")
|
||||
message_admins("<font color='blue'>Ticket [TicketHref("#[id]")] created</font>")
|
||||
else
|
||||
MessageNoRecipient(msg_raw)
|
||||
|
||||
//send it to TGS if nobody is on and tell us how many were on
|
||||
var/admin_number_present = send2tgs_adminless_only(initiator_ckey, "Ticket #[id]: [msg]")
|
||||
log_admin_private("Ticket #[id]: [key_name(initiator)]: [name] - heard by [admin_number_present] non-AFK admins who have +BAN.")
|
||||
if(admin_number_present <= 0)
|
||||
to_chat(C, span_notice("No active admins are online, your adminhelp was sent through TGS to admins who are available. This may use IRC or Discord."), confidential = TRUE)
|
||||
heard_by_no_admins = TRUE
|
||||
MessageNoRecipient(msg_raw, urgent)
|
||||
send_message_to_tgs(msg, urgent)
|
||||
GLOB.ahelp_tickets.active_tickets += src
|
||||
|
||||
/datum/admin_help/proc/send_message_to_tgs(message, urgent = FALSE)
|
||||
var/message_to_send = message
|
||||
|
||||
if(urgent)
|
||||
var/extra_message_to_send = "[message] - Requested an admin"
|
||||
var/extra_message = CONFIG_GET(string/urgent_ahelp_message)
|
||||
if(extra_message)
|
||||
extra_message_to_send += " ([extra_message])"
|
||||
to_chat(initiator, span_boldwarning("Notified admins to prioritize your ticket"))
|
||||
send2adminchat_webhook("RELAY: [initiator_ckey] | Ticket #[id]: [extra_message_to_send]")
|
||||
//send it to TGS if nobody is on and tell us how many were on
|
||||
var/admin_number_present = send2tgs_adminless_only(initiator_ckey, "Ticket #[id]: [message_to_send]")
|
||||
log_admin_private("Ticket #[id]: [key_name(initiator)]: [name] - heard by [admin_number_present] non-AFK admins who have +BAN.")
|
||||
if(admin_number_present <= 0)
|
||||
to_chat(initiator, span_notice("No active admins are online, your adminhelp was sent to admins who are available through IRC or Discord."), confidential = TRUE)
|
||||
heard_by_no_admins = TRUE
|
||||
|
||||
/proc/send2adminchat_webhook(message)
|
||||
if(!CONFIG_GET(string/adminhelp_webhook_url))
|
||||
return
|
||||
var/message_content = replacetext(replacetext(message, "\proper", ""), "\improper", "")
|
||||
message_content = GLOB.has_discord_embeddable_links.Replace(replacetext(message, "`", ""), " ```$1``` ")
|
||||
var/list/webhook_info = list()
|
||||
webhook_info["content"] = message_content
|
||||
if(CONFIG_GET(string/adminhelp_webhook_name))
|
||||
webhook_info["username"] = CONFIG_GET(string/adminhelp_webhook_name)
|
||||
if(CONFIG_GET(string/adminhelp_webhook_pfp))
|
||||
webhook_info["avatar_url"] = CONFIG_GET(string/adminhelp_webhook_pfp)
|
||||
// Uncomment when servers are moved to TGS4
|
||||
// send2chat("[initiator_ckey] | [message_content]", "ahelp", TRUE)
|
||||
var/list/headers = list()
|
||||
headers["Content-Type"] = "application/json"
|
||||
var/datum/http_request/request = new()
|
||||
request.prepare(RUSTG_HTTP_METHOD_POST, CONFIG_GET(string/adminhelp_webhook_url), json_encode(webhook_info), headers, "tmp/response.json")
|
||||
request.begin_async()
|
||||
|
||||
/datum/admin_help/Destroy()
|
||||
RemoveActive()
|
||||
GLOB.ahelp_tickets.closed_tickets -= src
|
||||
@@ -282,7 +312,7 @@ GLOBAL_DATUM_INIT(ahelp_tickets, /datum/admin_help_tickets, new)
|
||||
|
||||
//message from the initiator without a target, all admins will see this
|
||||
//won't bug irc/discord
|
||||
/datum/admin_help/proc/MessageNoRecipient(msg)
|
||||
/datum/admin_help/proc/MessageNoRecipient(msg, urgent = FALSE)
|
||||
msg = sanitize(copytext_char(msg, 1, MAX_MESSAGE_LEN))
|
||||
var/ref_src = "[REF(src)]"
|
||||
//Message to be sent to all admins
|
||||
@@ -306,7 +336,7 @@ GLOBAL_DATUM_INIT(ahelp_tickets, /datum/admin_help_tickets, new)
|
||||
type = MESSAGE_TYPE_ADMINPM,
|
||||
html = span_adminnotice("PM to-<b>Admins</b>: <span class='linkify'>[msg]</span>"),
|
||||
confidential = TRUE)
|
||||
SSblackbox.LogAhelp(id, "Ticket Opened", msg, null, initiator.ckey)
|
||||
SSblackbox.LogAhelp(id, "Ticket Opened", msg, null, initiator.ckey, urgent = urgent)
|
||||
|
||||
//Reopen a closed ticket
|
||||
/datum/admin_help/proc/Reopen()
|
||||
@@ -535,38 +565,100 @@ GLOBAL_DATUM_INIT(ahelp_tickets, /datum/admin_help_tickets, new)
|
||||
deltimer(adminhelptimerid)
|
||||
adminhelptimerid = 0
|
||||
|
||||
// Used for methods where input via arg doesn't work
|
||||
/client/proc/get_adminhelp()
|
||||
var/msg = input(src, "Please describe your problem concisely and an admin will help as soon as they're able.", "Adminhelp contents") as message|null
|
||||
adminhelp(msg)
|
||||
GLOBAL_DATUM_INIT(admin_help_ui_handler, /datum/admin_help_ui_handler, new)
|
||||
|
||||
/client/verb/adminhelp(msg as message)
|
||||
set category = "Admin"
|
||||
set name = "Adminhelp"
|
||||
/datum/admin_help_ui_handler
|
||||
var/list/ahelp_cooldowns = list()
|
||||
|
||||
/datum/admin_help_ui_handler/ui_state(mob/user)
|
||||
return GLOB.always_state
|
||||
|
||||
/datum/admin_help_ui_handler/ui_data(mob/user)
|
||||
. = list()
|
||||
var/list/admins = get_admin_counts(R_BAN)
|
||||
.["adminCount"] = length(admins["present"])
|
||||
|
||||
/datum/admin_help_ui_handler/ui_static_data(mob/user)
|
||||
. = list()
|
||||
.["bannedFromUrgentAhelp"] = is_banned_from(user.ckey, "Urgent Adminhelp")
|
||||
.["urgentAhelpPromptMessage"] = CONFIG_GET(string/urgent_ahelp_user_prompt)
|
||||
var/webhook_url = CONFIG_GET(string/adminhelp_webhook_url)
|
||||
if(webhook_url)
|
||||
.["urgentAhelpEnabled"] = TRUE
|
||||
|
||||
/datum/admin_help_ui_handler/ui_interact(mob/user, datum/tgui/ui)
|
||||
ui = SStgui.try_update_ui(user, src, ui)
|
||||
if(!ui)
|
||||
ui = new(user, src, "Adminhelp")
|
||||
ui.open()
|
||||
ui.set_autoupdate(FALSE)
|
||||
|
||||
/datum/admin_help_ui_handler/ui_act(action, list/params, datum/tgui/ui, datum/ui_state/state)
|
||||
. = ..()
|
||||
if(.)
|
||||
return
|
||||
var/client/user_client = usr.client
|
||||
var/message = sanitize_text(trim(params["message"]))
|
||||
var/urgent = !!params["urgent"]
|
||||
var/list/admins = get_admin_counts(R_BAN)
|
||||
if(length(admins["present"]) != 0 || is_banned_from(user_client.ckey, "Urgent Adminhelp"))
|
||||
urgent = FALSE
|
||||
|
||||
if(user_client.adminhelptimerid)
|
||||
return
|
||||
|
||||
perform_adminhelp(user_client, message, urgent)
|
||||
ui.close()
|
||||
|
||||
/datum/admin_help_ui_handler/proc/perform_adminhelp(client/user_client, message, urgent)
|
||||
if(GLOB.say_disabled) //This is here to try to identify lag problems
|
||||
to_chat(usr, span_danger("Speech is currently admin-disabled."), confidential = TRUE)
|
||||
return
|
||||
|
||||
if(!message)
|
||||
return
|
||||
|
||||
//handle muting and automuting
|
||||
if(prefs.muted & MUTE_ADMINHELP)
|
||||
to_chat(src, span_danger("Error: Admin-PM: You cannot send adminhelps (Muted)."), confidential = TRUE)
|
||||
if(user_client.prefs.muted & MUTE_ADMINHELP)
|
||||
to_chat(user_client, span_danger("Error: Admin-PM: You cannot send adminhelps (Muted)."), confidential = TRUE)
|
||||
return
|
||||
if(handle_spam_prevention(msg,MUTE_ADMINHELP))
|
||||
return
|
||||
|
||||
msg = trim(msg)
|
||||
|
||||
if(!msg)
|
||||
if(user_client.handle_spam_prevention(message, MUTE_ADMINHELP))
|
||||
return
|
||||
|
||||
SSblackbox.record_feedback("tally", "admin_verb", 1, "Adminhelp") //If you are copy-pasting this, ensure the 2nd parameter is unique to the new proc!
|
||||
if(current_ticket)
|
||||
current_ticket.MessageNoRecipient(msg)
|
||||
current_ticket.TimeoutVerb()
|
||||
|
||||
if(urgent)
|
||||
if(!COOLDOWN_FINISHED(src, ahelp_cooldowns?[user_client.ckey]))
|
||||
urgent = FALSE // Prevent abuse
|
||||
else
|
||||
COOLDOWN_START(src, ahelp_cooldowns[user_client.ckey], CONFIG_GET(number/urgent_ahelp_cooldown) * (1 SECONDS))
|
||||
|
||||
if(user_client.current_ticket)
|
||||
user_client.current_ticket.TimeoutVerb()
|
||||
if(urgent)
|
||||
var/sanitized_message = sanitize(copytext_char(message, 1, MAX_MESSAGE_LEN))
|
||||
user_client.current_ticket.send_message_to_tgs(sanitized_message, urgent = TRUE)
|
||||
user_client.current_ticket.MessageNoRecipient(message, urgent)
|
||||
return
|
||||
|
||||
new /datum/admin_help(msg, src, FALSE)
|
||||
new /datum/admin_help(message, user_client, FALSE, urgent)
|
||||
|
||||
/client/verb/no_tgui_adminhelp(message as message)
|
||||
set name = "NoTguiAdminhelp"
|
||||
set hidden = TRUE
|
||||
|
||||
if(adminhelptimerid)
|
||||
return
|
||||
|
||||
message = trim(message)
|
||||
|
||||
GLOB.admin_help_ui_handler.perform_adminhelp(src, message, FALSE)
|
||||
|
||||
/client/verb/adminhelp()
|
||||
set category = "Admin"
|
||||
set name = "Adminhelp"
|
||||
GLOB.admin_help_ui_handler.ui_interact(mob)
|
||||
to_chat(src, span_boldnotice("Adminhelp failing to open or work? <a href='?src=[REF(src)];tguiless_adminhelp=1'>Click here</a>"))
|
||||
|
||||
|
||||
//
|
||||
|
||||
Reference in New Issue
Block a user