[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
+2
View File
@@ -147,6 +147,8 @@ GLOBAL_VAR_INIT(ghost_role_flags, (~0))
/// for asay pings, this is the index in the return list for [/proc/check_admin_pings] that contains the message modified with underlines for the spotted names
#define ADMINSAY_PING_UNDERLINE_NAME_INDEX "!underlined_names"
/// for asay datum refs, this is the index in the return list for [/proc/check_memory_refs] that contains the message modified with underlines for the linked datums
#define ADMINSAY_LINK_DATUM_REF "!datum_ref"
/// When passed in as the duration for ban_panel, will make the ban default to permanent
#define BAN_PANEL_PERMANENT "permanent"
+1
View File
@@ -28,6 +28,7 @@
#define VV_WEAKREF "Weak Reference Datum"
#define VV_MSG_MARKED "<br><font size='1' color='red'><b>Marked Object</b></font>"
#define VV_MSG_TAGGED(num) "<br><font size='1' color='red'><b>Tagged Datum #[num]</b></font>"
#define VV_MSG_EDITED "<br><font size='1' color='red'><b>Var Edited</b></font>"
#define VV_MSG_DELETED "<br><font size='1' color='red'><b>Deleted</b></font>"
+1
View File
@@ -6,6 +6,7 @@ GLOBAL_DATUM_INIT(is_email, /regex, regex("\[a-z0-9_-]+@\[a-z0-9_-]+.\[a-z0-9_-]
GLOBAL_DATUM_INIT(is_alphanumeric, /regex, regex("\[a-z0-9]+", "i"))
GLOBAL_DATUM_INIT(is_punctuation, /regex, regex("\[.!?]+", "i"))
GLOBAL_DATUM_INIT(is_color, /regex, regex("^#\[0-9a-fA-F]{6}$"))
GLOBAL_DATUM_INIT(is_memref, /regex, regex("0x\[0-9a-fA-F\]{7,8}"))
//finds text strings recognized as links on discord. Mainly used to stop embedding.
GLOBAL_DATUM_INIT(has_discord_embeddable_links, /regex, regex("(https?://\[^\\s|<\]{2,})"))
+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
@@ -42,9 +42,15 @@
sprite_text = no_icon? "\[NO ICON\]" : "<img src='vv[hash].png'></td><td>"
var/list/header = islist(D)? list("<b>/list</b>") : D.vv_get_header()
var/ref_line = copytext(refid, 2, -1) // get rid of the brackets
var/marked_line
if(holder && holder.marked_datum && holder.marked_datum == D)
marked_line = VV_MSG_MARKED
var/tagged_line
if(holder && LAZYFIND(holder.tagged_datums, D))
var/tag_index = LAZYFIND(holder.tagged_datums, D)
tagged_line = VV_MSG_TAGGED(tag_index)
var/varedited_line
if(!islist && (D.datum_flags & DF_VAR_EDITED))
varedited_line = VV_MSG_EDITED
@@ -211,7 +217,9 @@
</table>
<div align='center'>
<b><font size='1'>[formatted_type]</font></b>
<br><b><font size='1'>[ref_line]</font></b>
<span id='marked'>[marked_line]</span>
<span id='tagged'>[tagged_line]</span>
<span id='varedited'>[varedited_line]</span>
<span id='deleted'>[deleted_line]</span>
</div>