From 7d3af73d128df0300c86fb8f658566f251963102 Mon Sep 17 00:00:00 2001 From: skoglol Date: Thu, 16 Jul 2020 11:57:40 +0200 Subject: [PATCH 1/4] Fixes some adminhelp issues --- code/modules/admin/verbs/adminhelp.dm | 14 +++----- code/modules/admin/verbs/adminpm.dm | 47 +++++++++++++++------------ 2 files changed, 31 insertions(+), 30 deletions(-) diff --git a/code/modules/admin/verbs/adminhelp.dm b/code/modules/admin/verbs/adminhelp.dm index 5141b612ed3..e095ddf8930 100644 --- a/code/modules/admin/verbs/adminhelp.dm +++ b/code/modules/admin/verbs/adminhelp.dm @@ -510,16 +510,12 @@ GLOBAL_DATUM_INIT(ahelp_tickets, /datum/admin_help_tickets, new) 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) - if(alert(usr, "You already have a ticket open. Is this for the same issue?",,"Yes","No") != "No") - if(current_ticket) - current_ticket.MessageNoRecipient(msg) - current_ticket.TimeoutVerb() - return - else - to_chat(usr, "Ticket not found, creating new one...", confidential = TRUE) + if(current_ticket) + current_ticket.MessageNoRecipient(msg) + current_ticket.TimeoutVerb() + return else - current_ticket.AddInteraction("[key_name_admin(usr)] opened a new ticket.") - current_ticket.Close() + to_chat(usr, "Ticket not found, creating new one...", confidential = TRUE) new /datum/admin_help(msg, src, FALSE) diff --git a/code/modules/admin/verbs/adminpm.dm b/code/modules/admin/verbs/adminpm.dm index 34f30b9c698..86556ffa3f1 100644 --- a/code/modules/admin/verbs/adminpm.dm +++ b/code/modules/admin/verbs/adminpm.dm @@ -73,6 +73,8 @@ return var/client/recipient + var/recipient_ckey // Stored in case client is deleted between this and after the message is input + var/datum/admin_help/recipient_ticket // Stored in case client is deleted between this and after the message is input var/external = 0 if(istext(whom)) if(whom[1] == "@") @@ -84,6 +86,8 @@ else if(istype(whom, /client)) recipient = whom + recipient_ckey = recipient.ckey + recipient_ticket = recipient.current_ticket if(external) if(!externalreplyamount) //to prevent people from spamming irc/discord @@ -99,16 +103,6 @@ else - if(!recipient) - if(holder) - to_chat(src, "Error: Admin-PM: Client not found.", confidential = TRUE) - if(msg) - to_chat(src, msg, confidential = TRUE) - return - else if(msg) // you want to continue if there's no message instead of returning now - current_ticket.MessageNoRecipient(msg) - return - //get message text, limit it's length.and clean/escape html if(!msg) msg = input(src,"Message:", "Private message to [recipient.holder?.fakekey ? "an Administrator" : key_name(recipient, 0, 0)].") as message|null @@ -116,16 +110,24 @@ if(!msg) return - if(prefs.muted & MUTE_ADMINHELP) - to_chat(src, "Error: Admin-PM: You are unable to use admin PM-s (muted).", confidential = TRUE) - return - - if(!recipient) + if(!recipient) + if(GLOB.directory[recipient_ckey]) // Client has reconnected, lets try to recover + recipient = GLOB.directory[recipient_ckey] + else if(holder) to_chat(src, "Error: Admin-PM: Client not found.", confidential = TRUE) + to_chat(src, msg, confidential = TRUE) + if(recipient_ticket) + recipient_ticket.AddInteraction("No client found, message not sent:
[msg]") + return else current_ticket.MessageNoRecipient(msg) - return + return + + + if(prefs.muted & MUTE_ADMINHELP) + to_chat(src, "Error: Admin-PM: You are unable to use admin PM-s (muted).", confidential = TRUE) + return if (src.handle_spam_prevention(msg,MUTE_ADMINHELP)) return @@ -149,8 +151,11 @@ externalreplyamount-- send2adminchat("[AH ? "#[AH.id] " : ""]Reply: [ckey]", rawmsg) else - if(recipient.holder) - if(holder) //both are admins + var/badmin = FALSE //Lets figure out if an admin is getting bwoinked. + if(holder && recipient.holder && !current_ticket) //Both are admins, and this is not a reply to our own ticket. + badmin = TRUE + if(recipient.holder && !badmin) + if(holder) to_chat(recipient, "Admin PM from-[key_name(src, recipient, 1)]: [keywordparsedmsg]", confidential = TRUE) to_chat(src, "Admin PM to-[key_name(recipient, src, 1)]: [keywordparsedmsg]", confidential = TRUE) @@ -167,9 +172,9 @@ to_chat(src, "PM to-Admins: [msg]", confidential = TRUE) SSblackbox.LogAhelp(current_ticket.id, "Reply", msg, recipient.ckey, src.ckey) - //play the receiving admin the adminhelp sound (if they have them enabled) - if(recipient.prefs.toggles & SOUND_ADMINHELP) - SEND_SOUND(recipient, sound('sound/effects/adminhelp.ogg')) + //play the receiving admin the adminhelp sound (if they have them enabled) + if(recipient.prefs.toggles & SOUND_ADMINHELP) + SEND_SOUND(recipient, sound('sound/effects/adminhelp.ogg')) else if(holder) //sender is an admin but recipient is not. Do BIG RED TEXT From 0194169631ddc0c7605fff8cd5a44f741b596a7c Mon Sep 17 00:00:00 2001 From: skoglol Date: Thu, 16 Jul 2020 12:36:28 +0200 Subject: [PATCH 2/4] Oh we got several procs --- code/modules/admin/verbs/adminpm.dm | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/code/modules/admin/verbs/adminpm.dm b/code/modules/admin/verbs/adminpm.dm index 86556ffa3f1..4bc5cebb212 100644 --- a/code/modules/admin/verbs/adminpm.dm +++ b/code/modules/admin/verbs/adminpm.dm @@ -58,6 +58,14 @@ if (!msg) message_admins("[key_name_admin(src)] has cancelled their reply to [key_name_admin(C, 0, 0)]'s admin help.") return + if(!C) //We lost the client during input, disconnected or relogged. + if(GLOB.directory[AH.initiator_ckey]) // Client has reconnected, lets try to recover + whom = GLOB.directory[AH.initiator_ckey] + else + to_chat(src, "Error: Admin-PM: Client not found.", confidential = TRUE) + to_chat(src, "Message not sent:
[msg]", confidential = TRUE) + AH.AddInteraction("No client found, message not sent:
[msg]") + return cmd_admin_pm(whom, msg) //takes input from cmd_admin_pm_context, cmd_admin_pm_panel or /client/Topic and sends them a PM. @@ -86,6 +94,10 @@ else if(istype(whom, /client)) recipient = whom + if(!recipient) + to_chat(src, "Error: Admin-PM: Client not found.", confidential = TRUE) + return + recipient_ckey = recipient.ckey recipient_ticket = recipient.current_ticket @@ -116,9 +128,9 @@ else if(holder) to_chat(src, "Error: Admin-PM: Client not found.", confidential = TRUE) - to_chat(src, msg, confidential = TRUE) + to_chat(src, "Message not sent:
[msg]", confidential = TRUE) if(recipient_ticket) - recipient_ticket.AddInteraction("No client found, message not sent:
[msg]") + recipient_ticket.AddInteraction("No client found, message not sent:
[msg]") return else current_ticket.MessageNoRecipient(msg) From fcf1f2530103bad3c4ee36100b915a4dcf93e013 Mon Sep 17 00:00:00 2001 From: skoglol Date: Thu, 16 Jul 2020 12:43:23 +0200 Subject: [PATCH 3/4] sound back --- code/modules/admin/verbs/adminpm.dm | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/code/modules/admin/verbs/adminpm.dm b/code/modules/admin/verbs/adminpm.dm index 4bc5cebb212..58af87b0b0d 100644 --- a/code/modules/admin/verbs/adminpm.dm +++ b/code/modules/admin/verbs/adminpm.dm @@ -184,9 +184,9 @@ to_chat(src, "PM to-Admins: [msg]", confidential = TRUE) SSblackbox.LogAhelp(current_ticket.id, "Reply", msg, recipient.ckey, src.ckey) - //play the receiving admin the adminhelp sound (if they have them enabled) - if(recipient.prefs.toggles & SOUND_ADMINHELP) - SEND_SOUND(recipient, sound('sound/effects/adminhelp.ogg')) + //play the receiving admin the adminhelp sound (if they have them enabled) + if(recipient.prefs.toggles & SOUND_ADMINHELP) + SEND_SOUND(recipient, sound('sound/effects/adminhelp.ogg')) else if(holder) //sender is an admin but recipient is not. Do BIG RED TEXT From 7ff34fc1287744f438d70146dd7d755cf55e04a8 Mon Sep 17 00:00:00 2001 From: skoglol Date: Thu, 16 Jul 2020 16:08:01 +0200 Subject: [PATCH 4/4] excessive --- code/modules/admin/verbs/adminhelp.dm | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/code/modules/admin/verbs/adminhelp.dm b/code/modules/admin/verbs/adminhelp.dm index e095ddf8930..115feb5731e 100644 --- a/code/modules/admin/verbs/adminhelp.dm +++ b/code/modules/admin/verbs/adminhelp.dm @@ -510,15 +510,13 @@ GLOBAL_DATUM_INIT(ahelp_tickets, /datum/admin_help_tickets, new) 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) - if(current_ticket) - current_ticket.MessageNoRecipient(msg) - current_ticket.TimeoutVerb() - return - else - to_chat(usr, "Ticket not found, creating new one...", confidential = TRUE) + current_ticket.MessageNoRecipient(msg) + current_ticket.TimeoutVerb() + return new /datum/admin_help(msg, src, FALSE) + // // LOGGING //