From 346a8c8020b1449b200802f24f73907312577be7 Mon Sep 17 00:00:00 2001 From: joep van der velden Date: Sun, 7 Jun 2020 00:56:43 +0200 Subject: [PATCH 1/3] Ticket conversion possible + refactor --- .../subsystem/tickets/mentor_tickets.dm | 15 +++-- code/controllers/subsystem/tickets/tickets.dm | 57 ++++++++++++++----- code/modules/admin/topic.dm | 6 ++ code/modules/admin/verbs/adminhelp.dm | 20 ++++--- 4 files changed, 71 insertions(+), 27 deletions(-) diff --git a/code/controllers/subsystem/tickets/mentor_tickets.dm b/code/controllers/subsystem/tickets/mentor_tickets.dm index d8bae77840c..983d24c79d1 100644 --- a/code/controllers/subsystem/tickets/mentor_tickets.dm +++ b/code/controllers/subsystem/tickets/mentor_tickets.dm @@ -9,13 +9,18 @@ GLOBAL_REAL(SSmentor_tickets, /datum/controller/subsystem/tickets/mentor_tickets ticket_system_name = "Mentor Tickets" ticket_name = "Mentor Ticket" span_class = "mentorhelp" + other_ticket_name = "Admin" close_rights = R_MENTOR | R_ADMIN - -/datum/controller/subsystem/tickets/mentor_tickets/message_staff(var/msg) - message_mentorTicket(msg) + rights_needed = R_MENTOR | R_ADMIN | R_MOD /datum/controller/subsystem/tickets/mentor_tickets/Initialize() - close_messages = list("- [ticket_name] Closed -", - "Please try to be as descriptive as possible in mentor helps. Mentors do not know the full situation you're in and need more information to give you a helpful response.", + close_messages = list("- [ticket_name] Closed -", + "Please try to be as descriptive as possible in mentor helps. Mentors do not know the full situation you're in and need more information to give you a helpful response.", "Your [ticket_name] has now been closed.") return ..() + +/datum/controller/subsystem/tickets/mentor_tickets/message_staff(msg) + message_mentorTicket(msg) + +/datum/controller/subsystem/tickets/mentor_tickets/create_other_system_ticket(datum/ticket/T) + SStickets.newTicket(T.clientName, T.content, T.title) diff --git a/code/controllers/subsystem/tickets/tickets.dm b/code/controllers/subsystem/tickets/tickets.dm index 058569250ec..0ce05d0532c 100644 --- a/code/controllers/subsystem/tickets/tickets.dm +++ b/code/controllers/subsystem/tickets/tickets.dm @@ -12,24 +12,26 @@ SUBSYSTEM_DEF(tickets) name = "Admin Tickets" + init_order = INIT_ORDER_TICKETS + wait = 300 + priority = FIRE_PRIORITY_TICKETS + flags = SS_BACKGROUND + var/span_class = "adminticket" var/ticket_system_name = "Admin Tickets" var/ticket_name = "Admin Ticket" var/close_rights = R_ADMIN + var/rights_needed = R_ADMIN | R_MOD + var/other_ticket_name = "Mentor" var/list/close_messages - init_order = INIT_ORDER_TICKETS - wait = 300 - priority = FIRE_PRIORITY_TICKETS - - flags = SS_BACKGROUND - + var/list/allTickets = list() //make it here because someone might ahelp before the system has initialized var/ticketCounter = 1 /datum/controller/subsystem/tickets/Initialize() close_messages = list("- [ticket_name] Rejected! -", - "Please try to be calm, clear, and descriptive in admin helps, do not assume the staff member has seen any related events, and clearly state the names of anybody you are reporting. If you asked a question, please ensure it was clear what you were asking.", + "Please try to be calm, clear, and descriptive in admin helps, do not assume the staff member has seen any related events, and clearly state the names of anybody you are reporting. If you asked a question, please ensure it was clear what you were asking.", "Your [ticket_name] has now been closed.") return ..() @@ -112,10 +114,28 @@ SUBSYSTEM_DEF(tickets) message_staff("[usr.client] / ([usr]) resolved [ticket_name] number [N]") to_chat_safe(returnClient(N), "Your [ticket_name] has now been resolved.") return TRUE - + +/datum/controller/subsystem/tickets/proc/convert_to_other_ticket(ticketId) + if(!check_rights(rights_needed)) + return + if(alert("Are you sure to convert this ticket to an '[other_ticket_name]' ticket?",,"Yes","No") != "Yes") + return + var/datum/ticket/T = allTickets[ticketId] + convert_ticket(T) + +/datum/controller/subsystem/tickets/proc/convert_ticket(datum/ticket/T) + T.ticketState = TICKET_CLOSED + var/client/C = usr.client + to_chat_safe(T.clientName, "[key_name_hidden(C)] has converted your ticket to a [other_ticket_name] ticket. Staff has been informed and will when able.") + message_staff("[C] has converted ticket number [T.ticketNum] to a [other_ticket_name] ticket.") + log_game("[C] has converted ticket number [T.ticketNum] to a [other_ticket_name] ticket.") + create_other_system_ticket(T) + +/datum/controller/subsystem/tickets/proc/create_other_system_ticket(datum/ticket/T) + SSmentor_tickets.newTicket(T.clientName, T.content, T.title) /datum/controller/subsystem/tickets/proc/autoRespond(N) - if(!check_rights(R_ADMIN|R_MOD)) + if(!check_rights(rights_needed)) return var/datum/ticket/T = allTickets[N] @@ -124,8 +144,8 @@ SUBSYSTEM_DEF(tickets) if(alert(usr, "[T.ticketState == TICKET_OPEN ? "Another admin appears to already be handling this." : "This ticket is already marked as closed or resolved"] Are you sure you want to continue?", "Confirmation", "Yes", "No") != "Yes") return T.assignStaff(C) - - var/response_phrases = list("Thanks" = "Thanks, have a Paradise day!", + + var/response_phrases = list("Thanks" = "Thanks, have a Paradise day!", "Handling It" = "The issue is being looked into, thanks.", "Already Resolved" = "The problem has been resolved already.", "Mentorhelp" = "Please redirect your question to Mentorhelp, as they are better experienced with these types of questions.", @@ -136,7 +156,7 @@ SUBSYSTEM_DEF(tickets) "Man Up" = "Man Up", "Appeal on the Forums" = "Appealing a ban must occur on the forums. Privately messaging, or adminhelping about your ban will not resolve it. To appeal your ban, please head to [config.banappeals]" ) - + var/sorted_responses = list() for(var/key in response_phrases) //build a new list based on the short descriptive keys of the master list so we can send this as the input instead of the full paragraphs to the admin choosing which autoresponse sorted_responses += key @@ -156,14 +176,17 @@ SUBSYSTEM_DEF(tickets) resolveTicket(N) message_staff("[C] has auto responded to [T.clientName]\'s adminhelp with: [message_key] ") log_game("[C] has auto responded to [T.clientName]\'s adminhelp with: [response_phrases[message_key]]") + if("Mentorhelp") + convert_ticket(T) else var/msg_sound = sound('sound/effects/adminhelp.ogg') SEND_SOUND(returnClient(N), msg_sound) - to_chat(returnClient(N), "[key_name_hidden(C)] is autoresponding with: [response_phrases[message_key]]")//for this we want the full value of whatever key this is to tell the player so we do response_phrases[message_key] + to_chat_safe(returnClient(N), "[key_name_hidden(C)] is autoresponding with: [response_phrases[message_key]]")//for this we want the full value of whatever key this is to tell the player so we do response_phrases[message_key] message_staff("[C] has auto responded to [T.clientName]\'s adminhelp with: [message_key] ") //we want to use the short named keys for this instead of the full sentence which is why we just do message_key T.lastStaffResponse = "Autoresponse: [message_key]" resolveTicket(N) log_game("[C] has auto responded to [T.clientName]\'s adminhelp with: [response_phrases[message_key]]") + //Set ticket state with key N to closed /datum/controller/subsystem/tickets/proc/closeTicket(N) var/datum/ticket/T = allTickets[N] @@ -351,7 +374,7 @@ UI STUFF dat += "[T.content[i]]" dat += "

" - dat += "Re-Open[check_rights(R_ADMIN|R_MOD, 0) ? "Auto": ""]Resolve

" + dat += "Re-Open[check_rights(rights_needed, 0) ? "Auto": ""]Resolve

" if(!T.staffAssigned) dat += "No staff member assigned to this [ticket_name] - Take Ticket
" @@ -366,6 +389,7 @@ UI STUFF dat += "

" dat += "Close Ticket" + dat += "Convert Ticket" var/datum/browser/popup = new(user, "[ticket_system_name]detail", "[ticket_system_name] #[T.ticketNum]", 1000, 600) popup.set_content(dat) @@ -447,7 +471,6 @@ UI STUFF return if(closeTicket(indexNum)) showDetailUI(usr, indexNum) - if(href_list["detailreopen"]) var/indexNum = text2num(href_list["detailreopen"]) @@ -468,6 +491,10 @@ UI STUFF var/indexNum = text2num(href_list["autorespond"]) autoRespond(indexNum) + if(href_list["convert_ticket"]) + var/indexNum = text2num(href_list["convert_ticket"]) + convert_to_other_ticket(indexNum) + if(href_list["resolveall"]) if(ticket_system_name == "Mentor Tickets") usr.client.resolveAllMentorTickets() diff --git a/code/modules/admin/topic.dm b/code/modules/admin/topic.dm index 1a040d46e90..64c15ad5c24 100644 --- a/code/modules/admin/topic.dm +++ b/code/modules/admin/topic.dm @@ -1585,6 +1585,12 @@ return SStickets.autoRespond(index) + if(href_list["convert_ticket"]) + var/indexNum = text2num(href_list["convert_ticket"]) + if(href_list["is_mhelp"]) + SSmentor_tickets.convert_to_other_ticket(indexNum) + else + SStickets.convert_to_other_ticket(indexNum) else if(href_list["cult_nextobj"]) if(alert(usr, "Validate the current Cult objective and unlock the next one?", "Cult Cheat Code", "Yes", "No") != "Yes") return diff --git a/code/modules/admin/verbs/adminhelp.dm b/code/modules/admin/verbs/adminhelp.dm index 8ac9c4fd2b0..b64492439cf 100644 --- a/code/modules/admin/verbs/adminhelp.dm +++ b/code/modules/admin/verbs/adminhelp.dm @@ -125,22 +125,28 @@ GLOBAL_LIST_INIT(adminhelp_ignored_words, list("unknown","the","a","an","of","mo ticketNum = T.ticketNum // ticketNum is the number of their ticket. T.addResponse(src, msg) - msg = "[span][selected_type]:
[key_name(src, TRUE, selected_type)] ([ADMIN_QUE(mob,"?")]) ([ADMIN_PP(mob,"PP")]) ([ADMIN_VV(mob,"VV")]) ([ADMIN_TP(mob,"TP")]) ([ADMIN_SM(mob,"SM")]) ([admin_jump_link(mob)]) (TICKET) [ai_found ? "(CL)" : ""] (TAKE) (RESOLVE) [isMhelp ? "" : "(AUTO)"] : [span][msg]
" + var/finalised_msg = "[span][selected_type]:
[key_name(src, TRUE, selected_type)] " + finalised_msg += "([ADMIN_QUE(mob,"?")]) ([ADMIN_PP(mob,"PP")]) ([ADMIN_VV(mob,"VV")]) ([ADMIN_TP(mob,"TP")]) ([ADMIN_SM(mob,"SM")]) " + finalised_msg += "([admin_jump_link(mob)]) (TICKET) " + finalised_msg += "[ai_found ? "(CL)" : ""] (TAKE) " + finalised_msg += "(RESOLVE) [isMhelp ? "" : "(AUTO)"] " + finalised_msg += "(CONVERT) : [span][msg]
" + if(isMhelp) //Open a new adminticket and inform the user. - SSmentor_tickets.newTicket(src, prunedmsg, msg) + SSmentor_tickets.newTicket(src, prunedmsg, finalised_msg) for(var/client/X in mentorholders + modholders + adminholders) if(X.prefs.sound & SOUND_MENTORHELP) - X << 'sound/effects/adminhelp.ogg' - to_chat(X, msg) + SEND_SOUND(X, 'sound/effects/adminhelp.ogg') + to_chat(X, finalised_msg) else //Ahelp //Open a new adminticket and inform the user. - SStickets.newTicket(src, prunedmsg, msg) + SStickets.newTicket(src, prunedmsg, finalised_msg) for(var/client/X in modholders + adminholders) if(X.prefs.sound & SOUND_ADMINHELP) - X << 'sound/effects/adminhelp.ogg' + SEND_SOUND(X, 'sound/effects/adminhelp.ogg') window_flash(X) - to_chat(X, msg) + to_chat(X, finalised_msg) From 3ee0026f90595fc1f98f443a1980496b9f1f5936 Mon Sep 17 00:00:00 2001 From: joep van der velden Date: Sun, 7 Jun 2020 01:07:21 +0200 Subject: [PATCH 2/3] Message change --- code/controllers/subsystem/tickets/tickets.dm | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/code/controllers/subsystem/tickets/tickets.dm b/code/controllers/subsystem/tickets/tickets.dm index 0ce05d0532c..11f205f2735 100644 --- a/code/controllers/subsystem/tickets/tickets.dm +++ b/code/controllers/subsystem/tickets/tickets.dm @@ -126,7 +126,8 @@ SUBSYSTEM_DEF(tickets) /datum/controller/subsystem/tickets/proc/convert_ticket(datum/ticket/T) T.ticketState = TICKET_CLOSED var/client/C = usr.client - to_chat_safe(T.clientName, "[key_name_hidden(C)] has converted your ticket to a [other_ticket_name] ticket. Staff has been informed and will when able.") + to_chat_safe(T.clientName, list("[key_name_hidden(C)] has converted your ticket to a [other_ticket_name] ticket.",\ + "Be sure to use the correct type of help next time!")) message_staff("[C] has converted ticket number [T.ticketNum] to a [other_ticket_name] ticket.") log_game("[C] has converted ticket number [T.ticketNum] to a [other_ticket_name] ticket.") create_other_system_ticket(T) From 4554340b7c82cb8c027228b22c41cfd2977935ac Mon Sep 17 00:00:00 2001 From: joep van der velden Date: Tue, 11 Aug 2020 17:01:09 +0200 Subject: [PATCH 3/3] Add warning no staff online for converted ticket --- .../controllers/subsystem/tickets/mentor_tickets.dm | 1 + code/controllers/subsystem/tickets/tickets.dm | 13 +++++++++++++ 2 files changed, 14 insertions(+) diff --git a/code/controllers/subsystem/tickets/mentor_tickets.dm b/code/controllers/subsystem/tickets/mentor_tickets.dm index bf27a0f3144..af4ea2e914d 100644 --- a/code/controllers/subsystem/tickets/mentor_tickets.dm +++ b/code/controllers/subsystem/tickets/mentor_tickets.dm @@ -11,6 +11,7 @@ GLOBAL_REAL(SSmentor_tickets, /datum/controller/subsystem/tickets/mentor_tickets ticket_name = "Mentor Ticket" span_class = "mentorhelp" other_ticket_name = "Admin" + other_ticket_permission = R_ADMIN close_rights = R_MENTOR | R_ADMIN rights_needed = R_MENTOR | R_ADMIN | R_MOD diff --git a/code/controllers/subsystem/tickets/tickets.dm b/code/controllers/subsystem/tickets/tickets.dm index 95fa22c936c..e4883c39c7d 100644 --- a/code/controllers/subsystem/tickets/tickets.dm +++ b/code/controllers/subsystem/tickets/tickets.dm @@ -23,7 +23,11 @@ SUBSYSTEM_DEF(tickets) var/ticket_name = "Admin Ticket" var/close_rights = R_ADMIN var/rights_needed = R_ADMIN | R_MOD + + /// The name of the other ticket type to convert to var/other_ticket_name = "Mentor" + /// Which permission to look for when seeing if there is staff available for the other ticket type + var/other_ticket_permission = R_MENTOR var/list/close_messages var/list/allTickets = list() //make it here because someone might ahelp before the system has initialized @@ -120,9 +124,18 @@ SUBSYSTEM_DEF(tickets) return if(alert("Are you sure to convert this ticket to an '[other_ticket_name]' ticket?",,"Yes","No") != "Yes") return + if(!other_ticket_system_staff_check()) + return var/datum/ticket/T = allTickets[ticketId] convert_ticket(T) +/datum/controller/subsystem/tickets/proc/other_ticket_system_staff_check() + var/list/staff = staff_countup(other_ticket_permission) + if(!staff[1]) + if(alert("No active staff online to answer the ticket. Are you sure you want to convert the ticket?",, "No", "Yes") != "Yes") + return FALSE + return TRUE + /datum/controller/subsystem/tickets/proc/convert_ticket(datum/ticket/T) T.ticketState = TICKET_CLOSED var/client/C = usr.client