From bf6a8c5aa5afcc4e2773246de1c5c23e35d0bda1 Mon Sep 17 00:00:00 2001 From: Amunak Date: Fri, 28 Nov 2014 10:16:56 +0100 Subject: [PATCH] Adminhelp refactoring, you can now type adminhelp in command box. Formatted some code, also added a confirmation for the sender if their adminhelp looks fine. --- code/modules/admin/verbs/adminhelp.dm | 44 ++++++++++++--------------- 1 file changed, 20 insertions(+), 24 deletions(-) diff --git a/code/modules/admin/verbs/adminhelp.dm b/code/modules/admin/verbs/adminhelp.dm index 945390332f..8695dc2f47 100644 --- a/code/modules/admin/verbs/adminhelp.dm +++ b/code/modules/admin/verbs/adminhelp.dm @@ -3,7 +3,7 @@ //This is a list of words which are ignored by the parser when comparing message contents for names. MUST BE IN LOWER CASE! var/list/adminhelp_ignored_words = list("unknown","the","a","an","of","monkey","alien","as") -/client/verb/adminhelp() +/client/verb/adminhelp(msg as null|text) set category = "Admin" set name = "Adminhelp" @@ -16,7 +16,6 @@ var/list/adminhelp_ignored_words = list("unknown","the","a","an","of","monkey"," src << "Error: Admin-PM: You cannot send adminhelps (Muted)." return - adminhelped = 1 //Determines if they get the message to reply by clicking the name. /**src.verbs -= /client/verb/adminhelp @@ -25,26 +24,29 @@ var/list/adminhelp_ignored_words = list("unknown","the","a","an","of","monkey"," src.verbs += /client/verb/adminhelp // 2 minute cool-down for adminhelps src.verbs += /client/verb/adminhelp // 2 minute cool-down for adminhelps//Go to hell **/ - var/msg var/list/type = list ("Gameplay/Roleplay question", "Rule/Gameplay issue", "Bug report") var/selected_type = input("Pick a category.", "Admin Help", null, null) as null|anything in type - if(selected_type) + if(!selected_type) + return + if(!msg) msg = input("Please enter your message:", "Admin Help", null, null) as text + if(!msg || alert("The following message will be sent to staff that administers\n the '[selected_type]' category:\n\n[msg]\n", "Admin Help", "Ok", "Cancel") == "Cancel") + return + var/selected_upper = uppertext(selected_type) if(src.handle_spam_prevention(msg,MUTE_ADMINHELP)) return - //clean the input msg - if(!msg) return + if(!msg) + return msg = sanitize(copytext(msg,1,MAX_MESSAGE_LEN)) - if(!msg) return + if(!msg) + return var/original_msg = msg - - //explode the input msg into a list var/list/msglist = text2list(msg, " ") @@ -98,14 +100,15 @@ var/list/adminhelp_ignored_words = list("unknown","the","a","an","of","monkey"," continue msg += "[original_word] " - if(!mob) return //this doesn't happen - - var/ref_mob = "\ref[mob]" - var/mentor_msg = "\blue [selected_upper]: [get_options_bar(mob, 0, 0, 1, 0)][ai_found ? " (CL)" : ""]: [msg]" - var/dev_msg = "\blue [selected_upper]: [get_options_bar(mob, 3, 0, 1, 0)][ai_found ? " (CL)" : ""]: [msg]" - msg = "\blue [selected_upper]: [get_options_bar(mob, 2, 1, 1)][ai_found ? " (CL)" : ""]: [msg]" - + if(!mob) //this doesn't happen + return + var/ai_cl + if(ai_found) + ai_cl = " (CL)" + var/mentor_msg = "\blue [selected_upper]: [get_options_bar(mob, 0, 0, 1, 0)][ai_cl]: [msg]" + var/dev_msg = "\blue [selected_upper]: [get_options_bar(mob, 3, 0, 1, 0)][ai_cl]: [msg]" + msg = "\blue [selected_upper]: [get_options_bar(mob, 2, 1, 1)][ai_cl]: [msg]" var/admin_number_afk = 0 @@ -158,10 +161,6 @@ var/list/adminhelp_ignored_words = list("unknown","the","a","an","of","monkey"," X << 'sound/effects/adminhelp.ogg' X << dev_msg - - - - /*for(var/client/X in admins) if((R_ADMIN|R_MOD|R_MENTOR) & X.holder.rights) if(X.is_afk()) @@ -179,10 +178,7 @@ var/list/adminhelp_ignored_words = list("unknown","the","a","an","of","monkey"," var/admin_number_present = admins.len - admin_number_afk log_admin("HELP: [key_name(src)]: [original_msg] - heard by [admin_number_present] non-AFK admins.") if(admin_number_present <= 0) - if(!admin_number_afk) - send2adminirc("[selected_upper] from [key_name(src)]: [html_decode(original_msg)] - !!No admins online!!") - else - send2adminirc("[selected_upper] from [key_name(src)]: [html_decode(original_msg)] - !!All admins AFK ([admin_number_afk])!!") + send2adminirc("[selected_upper] from [key_name(src)]: [html_decode(original_msg)] - !![admin_number_afk ? "All admins AFK ([admin_number_afk])" : "No admins online"]!!") else send2adminirc("[selected_upper] from [key_name(src)]: [html_decode(original_msg)]") feedback_add_details("admin_verb","AH") //If you are copy-pasting this, ensure the 2nd parameter is unique to the new proc!