Add codeword highlighting (#30092)
* Added codeword highlighting * Updated to support more codeword roles, color is set serverside * Review feedback * Change to a Component-based system using SessionSpecific * Tidied up CanGetState, set Access restrictions on component * Clean-up * Makes the injection ignore brackets, restore some codewords, remove "Taste/Touch" from adjectives
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using System.Collections.Frozen;
|
||||
using System.Text.RegularExpressions;
|
||||
using Content.Shared.Popups;
|
||||
using Content.Shared.Radio;
|
||||
using Content.Shared.Speech;
|
||||
@@ -237,6 +238,18 @@ public abstract class SharedChatSystem : EntitySystem
|
||||
|
||||
return rawmsg;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Injects a tag around all found instances of a specific string in a ChatMessage.
|
||||
/// Excludes strings inside other tags and brackets.
|
||||
/// </summary>
|
||||
public static string InjectTagAroundString(ChatMessage message, string targetString, string tag, string? tagParameter)
|
||||
{
|
||||
var rawmsg = message.WrappedMessage;
|
||||
rawmsg = Regex.Replace(rawmsg, "(?i)(" + targetString + ")(?-i)(?![^[]*])", $"[{tag}={tagParameter}]$1[/{tag}]");
|
||||
return rawmsg;
|
||||
}
|
||||
|
||||
public static string GetStringInsideTag(ChatMessage message, string tag)
|
||||
{
|
||||
var rawmsg = message.WrappedMessage;
|
||||
|
||||
Reference in New Issue
Block a user