[MIRROR] Adds linking datums in asay [MDB IGNORE] (#11771)

* Adds linking datums in asay (#65154)

* Adds linking datums in asay

Co-authored-by: Ryll Ryll <3589655+Ryll-Ryll@users.noreply.github.com>
This commit is contained in:
SkyratBot
2022-02-28 17:36:59 +01:00
committed by GitHub
parent c81956ec48
commit 4688ecfc2e
6 changed files with 51 additions and 0 deletions
+33
View File
@@ -1039,3 +1039,36 @@ GLOBAL_DATUM_INIT(admin_help_ui_handler, /datum/admin_help_ui_handler, new)
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
/**
* Checks a given message to see if any of the words contain a memory ref for a datum. Said ref should not have brackets around it
*
* Returns nothing if no refs are found, otherwise returns an associative list with ckey -> client
* Also modifies msg to underline and linkify the [ref] so other admins can click on the address to open the VV entry for said datum
*
* Arguments:
* * msg - the message being scanned
*/
/proc/check_memory_refs(msg)
if(!findtext(msg, GLOB.is_memref))
return
//explode the input msg into a list
var/list/msglist = splittext(msg, " ")
var/list/datums_to_ref = list()
var/i = 0
for(var/word in msglist)
i++
if(!length(word))
continue
var/word_with_brackets = "\[[word]\]" // the actual memory address lookups need the bracket wraps
var/datum/check_datum = locate(word_with_brackets)
if(!istype(check_datum))
continue
msglist[i] = "<u><a href='?_src_=vars;[HrefToken(TRUE)];Vars=[word_with_brackets]'>[word_with_brackets]</A></u>"
datums_to_ref[word] = word
if(length(datums_to_ref))
datums_to_ref[ADMINSAY_LINK_DATUM_REF] = jointext(msglist, " ") // without tuples, we must make do!
return datums_to_ref
+6
View File
@@ -21,6 +21,12 @@
window_flash(iter_admin_client)
SEND_SOUND(iter_admin_client.mob, sound('sound/misc/asay_ping.ogg'))
var/list/linked_datums = check_memory_refs(msg)
if(length(linked_datums) && linked_datums[ADMINSAY_LINK_DATUM_REF])
msg = linked_datums[ADMINSAY_LINK_DATUM_REF]
linked_datums -= ADMINSAY_LINK_DATUM_REF
mob.log_talk(msg, LOG_ASAY)
msg = keywords_lookup(msg)
send_asay_to_other_server(ckey, msg) //SKYRAT EDIT ADDITION