Merge pull request #15263 from DeltaFire15/ping-time
Adds pinging to asay
This commit is contained in:
@@ -732,3 +732,34 @@ GLOBAL_DATUM_INIT(ahelp_tickets, /datum/admin_help_tickets, new)
|
||||
return founds
|
||||
|
||||
return msg
|
||||
|
||||
/**
|
||||
* Checks a given message to see if any of the words contain an active admin's ckey with an @ before it
|
||||
*
|
||||
* Returns nothing if no pings are found, otherwise returns an associative list with ckey -> client
|
||||
* Also modifies msg to underline the pings, then stores them in the key [ADMINSAY_PING_UNDERLINE_NAME_INDEX] for returning
|
||||
*
|
||||
* Arguments:
|
||||
* * msg - the message being scanned
|
||||
*/
|
||||
/proc/check_admin_pings(msg)
|
||||
//explode the input msg into a list
|
||||
var/list/msglist = splittext(msg, " ")
|
||||
var/list/admins_to_ping = list()
|
||||
|
||||
var/i = 0
|
||||
for(var/word in msglist)
|
||||
i++
|
||||
if(!length(word))
|
||||
continue
|
||||
if(word[1] != "@")
|
||||
continue
|
||||
var/ckey_check = lowertext(copytext(word, 2))
|
||||
var/client/client_check = GLOB.directory[ckey_check]
|
||||
if(client_check?.holder)
|
||||
msglist[i] = "<u>[word]</u>"
|
||||
admins_to_ping[ckey_check] = client_check
|
||||
|
||||
if(length(admins_to_ping))
|
||||
admins_to_ping[ADMINSAY_PING_UNDERLINE_NAME_INDEX] = jointext(msglist, " ") // without tuples, we must make do!
|
||||
return admins_to_ping
|
||||
|
||||
@@ -8,6 +8,19 @@
|
||||
msg = copytext_char(sanitize(msg), 1, MAX_MESSAGE_LEN)
|
||||
if(!msg)
|
||||
return
|
||||
|
||||
var/list/pinged_admin_clients = check_admin_pings(msg)
|
||||
if(length(pinged_admin_clients) && pinged_admin_clients[ADMINSAY_PING_UNDERLINE_NAME_INDEX])
|
||||
msg = pinged_admin_clients[ADMINSAY_PING_UNDERLINE_NAME_INDEX]
|
||||
pinged_admin_clients -= ADMINSAY_PING_UNDERLINE_NAME_INDEX
|
||||
|
||||
for(var/iter_ckey in pinged_admin_clients)
|
||||
var/client/iter_admin_client = pinged_admin_clients[iter_ckey]
|
||||
if(!iter_admin_client?.holder)
|
||||
continue
|
||||
window_flash(iter_admin_client)
|
||||
SEND_SOUND(iter_admin_client.mob, sound('sound/misc/bloop.ogg'))
|
||||
|
||||
msg = emoji_parse(msg)
|
||||
mob.log_talk(msg, LOG_ASAY)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user