From a1959e799cd7df79709bbd12abfd981613001a28 Mon Sep 17 00:00:00 2001 From: S34N <12197162+S34NW@users.noreply.github.com> Date: Wed, 11 Jan 2023 16:59:22 +0000 Subject: [PATCH] Adds a "Ping all admins" command. (#19918) * ping all admins * optional deadmin ping * aa feedback * fixes this at AA request * Update code/modules/admin/verbs/ping_all_admins.dm Co-authored-by: Sirryan2002 <80364400+Sirryan2002@users.noreply.github.com> * Update code/modules/admin/admin_verbs.dm * Apply suggestions from code review Co-authored-by: Sirryan2002 <80364400+Sirryan2002@users.noreply.github.com> --- code/__HELPERS/_logging.dm | 4 ++ code/_globalvars/lists/mobs.dm | 3 +- code/modules/admin/IsBanned.dm | 2 +- code/modules/admin/admin_verbs.dm | 16 +++++--- code/modules/admin/verbs/adminsay.dm | 11 +++--- code/modules/admin/verbs/ping_all_admins.dm | 39 +++++++++++++++++++ code/modules/client/client_procs.dm | 2 +- code/modules/mob/login.dm | 2 +- code/modules/mob/new_player/login.dm | 2 +- goon/browserassets/css/browserOutput-dark.css | 1 + goon/browserassets/css/browserOutput.css | 1 + paradise.dme | 1 + 12 files changed, 69 insertions(+), 15 deletions(-) create mode 100644 code/modules/admin/verbs/ping_all_admins.dm diff --git a/code/__HELPERS/_logging.dm b/code/__HELPERS/_logging.dm index 3979b37d9d8..b502547b825 100644 --- a/code/__HELPERS/_logging.dm +++ b/code/__HELPERS/_logging.dm @@ -92,6 +92,10 @@ GLOBAL_PROTECT(log_end) if(GLOB.configuration.logging.adminchat_logging) rustg_log_write(GLOB.world_game_log, "ADMINSAY: [speaker.simple_info_line()]: [html_decode(text)][GLOB.log_end]") +/proc/log_ping_all_admins(text, mob/speaker) + if(GLOB.configuration.logging.adminchat_logging) + rustg_log_write(GLOB.world_game_log, "ALL ADMIN PING: [speaker.simple_info_line()]: [html_decode(text)][GLOB.log_end]") + /proc/log_qdel(text) rustg_log_write(GLOB.world_qdel_log, "QDEL: [text][GLOB.log_end]") diff --git a/code/_globalvars/lists/mobs.dm b/code/_globalvars/lists/mobs.dm index 61d970091b4..138304f0177 100644 --- a/code/_globalvars/lists/mobs.dm +++ b/code/_globalvars/lists/mobs.dm @@ -7,7 +7,8 @@ GLOBAL_LIST_EMPTY(whitelisted_species) GLOBAL_LIST_EMPTY(clients) //list of all clients GLOBAL_LIST_EMPTY(admins) //list of all clients whom are admins -GLOBAL_LIST_EMPTY(deadmins) //list of all clients who have used the de-admin verb. +GLOBAL_LIST_EMPTY(de_admins) //list of all admins who have used the de-admin verb. +GLOBAL_LIST_EMPTY(de_mentors) //list of all mentors who have used the de-admin verb. GLOBAL_LIST_EMPTY(directory) //list of all ckeys with associated client GLOBAL_LIST_EMPTY(stealthminID) //reference list with IDs that store ckeys, for stealthmins diff --git a/code/modules/admin/IsBanned.dm b/code/modules/admin/IsBanned.dm index 66c460728a2..63fa6427869 100644 --- a/code/modules/admin/IsBanned.dm +++ b/code/modules/admin/IsBanned.dm @@ -24,7 +24,7 @@ if (C && ckey == C.ckey && computer_id == C.computer_id && address == C.address) return //don't recheck connected clients. - if((ckey in GLOB.admin_datums) || (ckey in GLOB.deadmins)) + if((ckey in GLOB.admin_datums) || (ckey in GLOB.de_admins)) var/datum/admins/A = GLOB.admin_datums[ckey] if(A && (A.rights & R_ADMIN)) admin = 1 diff --git a/code/modules/admin/admin_verbs.dm b/code/modules/admin/admin_verbs.dm index 7a262ce77d4..d7bde7deb11 100644 --- a/code/modules/admin/admin_verbs.dm +++ b/code/modules/admin/admin_verbs.dm @@ -68,7 +68,8 @@ GLOBAL_LIST_INIT(admin_verbs_admin, list( /client/proc/list_ssds_afks, /client/proc/ccbdb_lookup_ckey, /client/proc/view_instances, - /client/proc/start_vote + /client/proc/start_vote, + /client/proc/ping_all_admins )) GLOBAL_LIST_INIT(admin_verbs_ban, list( /client/proc/ban_panel, @@ -632,14 +633,17 @@ GLOBAL_LIST_INIT(admin_verbs_maintainer, list( set name = "De-admin self" set category = "Admin" - if(!check_rights(R_ADMIN|R_MOD|R_MENTOR)) + if(!check_rights(R_ADMIN|R_MENTOR)) return log_admin("[key_name(usr)] deadmined themself.") message_admins("[key_name_admin(usr)] deadmined themself.") + if(check_rights(R_ADMIN, FALSE)) + GLOB.de_admins += ckey + else + GLOB.de_mentors += ckey deadmin() verbs += /client/proc/readmin - GLOB.deadmins += ckey to_chat(src, "You are now a normal player.") SSblackbox.record_feedback("tally", "admin_verb", 1, "De-admin") //If you are copy-pasting this, ensure the 2nd parameter is unique to the new proc! @@ -731,13 +735,15 @@ GLOBAL_LIST_INIT(admin_verbs_maintainer, list( D.associate(C) message_admins("[key_name_admin(usr)] re-adminned themselves.") log_admin("[key_name(usr)] re-adminned themselves.") - GLOB.deadmins -= ckey + GLOB.de_admins -= ckey + GLOB.de_mentors -= ckey SSblackbox.record_feedback("tally", "admin_verb", 1, "Re-admin") return else to_chat(src, "You are already an admin.") verbs -= /client/proc/readmin - GLOB.deadmins -= ckey + GLOB.de_admins -= ckey + GLOB.de_mentors -= ckey return /client/proc/toggle_log_hrefs() diff --git a/code/modules/admin/verbs/adminsay.dm b/code/modules/admin/verbs/adminsay.dm index 1d8c1734831..b71d37e7f81 100644 --- a/code/modules/admin/verbs/adminsay.dm +++ b/code/modules/admin/verbs/adminsay.dm @@ -21,15 +21,16 @@ SSredis.publish("byond.asay", json_encode(data)) for(var/client/C in GLOB.admins) + var/temp_message = msg if(R_ADMIN & C.holder.rights) // Lets see if this admin was pinged in the asay message - if(findtext(msg, "@[C.ckey]") || findtext(msg, "@[C.key]")) // Check ckey and key, so you can type @AffectedArc07 or @affectedarc07 + if(findtext(temp_message, "@[C.ckey]") || findtext(temp_message, "@[C.key]")) // Check ckey and key, so you can type @AffectedArc07 or @affectedarc07 SEND_SOUND(C, sound('sound/misc/ping.ogg')) - msg = replacetext(msg, "@[C.ckey]", "@[C.ckey]") - msg = replacetext(msg, "@[C.key]", "@[C.key]") // Same applies here. key and ckey. + temp_message = replacetext(temp_message, "@[C.ckey]", "@[C.ckey]") + temp_message = replacetext(temp_message, "@[C.key]", "@[C.key]") // Same applies here. key and ckey. - msg = "[msg]" - to_chat(C, "ADMIN: [key_name(usr, 1)] ([admin_jump_link(mob)]): [msg]") + temp_message = "[temp_message]" + to_chat(C, "ADMIN: [key_name(usr, 1)] ([admin_jump_link(mob)]): [temp_message]") SSblackbox.record_feedback("tally", "admin_verb", 1, "Asay") //If you are copy-pasting this, ensure the 2nd parameter is unique to the new proc! diff --git a/code/modules/admin/verbs/ping_all_admins.dm b/code/modules/admin/verbs/ping_all_admins.dm new file mode 100644 index 00000000000..ded9c427adf --- /dev/null +++ b/code/modules/admin/verbs/ping_all_admins.dm @@ -0,0 +1,39 @@ +/client/proc/ping_all_admins() + set name = "Ping all admins" + set category = "Admin" + + if(!check_rights(R_ADMIN, FALSE)) + return + + var/msg = input(src, "What message do you want the ping to show?", "Ping all admins") as text|null + msg = sanitize(copytext(msg, 1, MAX_MESSAGE_LEN)) + + if(!msg) + return + + var/list/admins_to_ping = list() + + for(var/client/C in GLOB.admins) + if(R_ADMIN & C.holder.rights) + admins_to_ping += C + + var/de_admin_also = alert(usr, "Do you want to ping admins that have used de-admin?","Ping all admins", "Yes", "No") + if(de_admin_also == "Yes") + for(var/key in GLOB.de_admins) + var/client/C = GLOB.directory[ckey] + if(!C) + continue + admins_to_ping += C + + if(length(admins_to_ping) < 2) // All by yourself? + to_chat(usr, "No other admins online to ping[de_admin_also == "Yes" ? ", including those that have used de-admin" : ""]!") + return + + var/datum/asays/asay = new(usr.ckey, usr.client.holder.rank, msg, world.timeofday) + GLOB.asays += asay + log_ping_all_admins("[length(admins_to_ping)] clients pinged: [msg]", src) + + for(var/client/C in admins_to_ping) + SEND_SOUND(C, sound('sound/misc/ping.ogg')) + to_chat(C, "ALL ADMIN PING: [key_name(usr, TRUE)] ([admin_jump_link(mob)]): [msg]") + to_chat(usr, "[length(admins_to_ping)] clients pinged.") diff --git a/code/modules/client/client_procs.dm b/code/modules/client/client_procs.dm index a6c84e9a3a1..cf570a10bab 100644 --- a/code/modules/client/client_procs.dm +++ b/code/modules/client/client_procs.dm @@ -331,7 +331,7 @@ // This also has to be manually done since no mob to use check_rights() on deadmin() verbs += /client/proc/readmin - GLOB.deadmins += ckey + GLOB.de_admins += ckey else on_holder_add() diff --git a/code/modules/mob/login.dm b/code/modules/mob/login.dm index 4020205c6e7..e97228f7869 100644 --- a/code/modules/mob/login.dm +++ b/code/modules/mob/login.dm @@ -52,7 +52,7 @@ reset_perspective(loc) - if(ckey in GLOB.deadmins) + if((ckey in GLOB.de_admins) || (ckey in GLOB.de_mentors)) verbs += /client/proc/readmin //Clear ability list and update from mob. diff --git a/code/modules/mob/new_player/login.dm b/code/modules/mob/new_player/login.dm index f2feaa91a3d..8deeafe9b5c 100644 --- a/code/modules/mob/new_player/login.dm +++ b/code/modules/mob/new_player/login.dm @@ -26,7 +26,7 @@ new_player_panel() - if(ckey in GLOB.deadmins) + if((ckey in GLOB.de_admins) || (ckey in GLOB.de_mentors)) verbs += /client/proc/readmin client?.playtitlemusic() diff --git a/goon/browserassets/css/browserOutput-dark.css b/goon/browserassets/css/browserOutput-dark.css index 7706ec47fc3..8711bc1d875 100644 --- a/goon/browserassets/css/browserOutput-dark.css +++ b/goon/browserassets/css/browserOutput-dark.css @@ -286,6 +286,7 @@ em {font-style: normal;font-weight: bold;} .srvradio {color: #bbd164;} .proradio {color: #b84f92;} .admin_channel {color: #03fc9d;font-weight: bold;} +.all_admin_ping {color: #12A5F4; font-weight: bold; font-size: 120%; text-align: center;} .mentor_channel {color: #775BFF;font-weight: bold;} .mentor_channel_admin {color: #A35CFF;font-weight: bold;} .djradio {color: #996600;} diff --git a/goon/browserassets/css/browserOutput.css b/goon/browserassets/css/browserOutput.css index 3a18b7c8b2e..8ff849cf676 100644 --- a/goon/browserassets/css/browserOutput.css +++ b/goon/browserassets/css/browserOutput.css @@ -281,6 +281,7 @@ em {font-style: normal; font-weight: bold;} .srvradio {color: #80A000;} .proradio {color: #E3027A;} .admin_channel {color: #9A04D1; font-weight: bold;} +.all_admin_ping {color: #12A5F4; font-weight: bold; font-size: 120%; text-align: center;} .mentor_channel {color: #775BFF; font-weight: bold;} .mentor_channel_admin {color: #A35CFF; font-weight: bold;} .djradio {color: #663300;} diff --git a/paradise.dme b/paradise.dme index 19513326814..06e60026f96 100644 --- a/paradise.dme +++ b/paradise.dme @@ -1270,6 +1270,7 @@ #include "code\modules\admin\verbs\one_click_antag.dm" #include "code\modules\admin\verbs\onlyone.dm" #include "code\modules\admin\verbs\onlyoneteam.dm" +#include "code\modules\admin\verbs\ping_all_admins.dm" #include "code\modules\admin\verbs\playsound.dm" #include "code\modules\admin\verbs\possess.dm" #include "code\modules\admin\verbs\pray.dm"