diff --git a/code/__HELPERS/chat.dm b/code/__HELPERS/chat.dm index 2f958eeed0f..4d3a8db806f 100644 --- a/code/__HELPERS/chat.dm +++ b/code/__HELPERS/chat.dm @@ -66,7 +66,9 @@ In TGS3 it will always be sent to all connected designated game chats. * category - The category of the mssage. * message - The message to send. */ -/proc/send2adminchat(category, message) +/proc/send2adminchat(category, message, embed_links = FALSE) category = replacetext(replacetext(category, "\proper", ""), "\improper", "") message = replacetext(replacetext(message, "\proper", ""), "\improper", "") + if(!embed_links) + message = GLOB.has_discord_embeddable_links.Replace(message, "<$1>") world.TgsTargetedChatBroadcast("[category] | [message]", TRUE) diff --git a/code/_globalvars/regexes.dm b/code/_globalvars/regexes.dm index bd252b68ce4..73eaab76440 100644 --- a/code/_globalvars/regexes.dm +++ b/code/_globalvars/regexes.dm @@ -5,3 +5,6 @@ GLOBAL_DATUM_INIT(is_website, /regex, regex("http|www.|\[a-z0-9_-]+.(com|org|net GLOBAL_DATUM_INIT(is_email, /regex, regex("\[a-z0-9_-]+@\[a-z0-9_-]+.\[a-z0-9_-]+", "i")) GLOBAL_DATUM_INIT(is_alphanumeric, /regex, regex("\[a-z0-9]+", "i")) GLOBAL_DATUM_INIT(is_punctuation, /regex, regex("\[.!?]+", "i")) + +//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,})"))