diff --git a/Content.Server/Chat/Systems/ChatSystem.Radio.cs b/Content.Server/Chat/Systems/ChatSystem.Radio.cs index e764b9a387..a317d07afc 100644 --- a/Content.Server/Chat/Systems/ChatSystem.Radio.cs +++ b/Content.Server/Chat/Systems/ChatSystem.Radio.cs @@ -74,7 +74,7 @@ public sealed partial class ChatSystem } // Re-capitalize message since we removed the prefix. - message = SanitizeMessageCapital(source, message); + message = SanitizeMessageCapital(message); if (_inventory.TryGetSlotEntity(source, "ears", out var entityUid) && TryComp(entityUid, out HeadsetComponent? headset)) diff --git a/Content.Server/Chat/Systems/ChatSystem.cs b/Content.Server/Chat/Systems/ChatSystem.cs index 586b2e78d8..e6bb375f22 100644 --- a/Content.Server/Chat/Systems/ChatSystem.cs +++ b/Content.Server/Chat/Systems/ChatSystem.cs @@ -127,8 +127,9 @@ public sealed partial class ChatSystem : SharedChatSystem return; bool shouldCapitalize = (desiredType != InGameICChatType.Emote); + bool shouldPunctuate = _configurationManager.GetCVar(CCVars.ChatPunctuation); - message = SanitizeInGameICMessage(source, message, out var emoteStr, shouldCapitalize); + message = SanitizeInGameICMessage(source, message, out var emoteStr, shouldCapitalize, shouldPunctuate); // Was there an emote in the message? If so, send it. if (player != null && emoteStr != message && emoteStr != null) @@ -423,11 +424,13 @@ public sealed partial class ChatSystem : SharedChatSystem } // ReSharper disable once InconsistentNaming - private string SanitizeInGameICMessage(EntityUid source, string message, out string? emoteStr, bool capitalize = true) + private string SanitizeInGameICMessage(EntityUid source, string message, out string? emoteStr, bool capitalize = true, bool punctuate = false) { var newMessage = message.Trim(); if (capitalize) - newMessage = SanitizeMessageCapital(source, newMessage); + newMessage = SanitizeMessageCapital(newMessage); + if (punctuate) + newMessage = SanitizeMessagePeriod(newMessage); newMessage = FormattedMessage.EscapeText(newMessage); _sanitizer.TrySanitizeOutSmilies(newMessage, source, out newMessage, out emoteStr); @@ -460,7 +463,7 @@ public sealed partial class ChatSystem : SharedChatSystem .Select(p => p.ConnectedClient); } - private string SanitizeMessageCapital(EntityUid source, string message) + private string SanitizeMessageCapital(string message) { if (string.IsNullOrEmpty(message)) return message; @@ -469,6 +472,16 @@ public sealed partial class ChatSystem : SharedChatSystem return message; } + private string SanitizeMessagePeriod(string message) + { + if (string.IsNullOrEmpty(message)) + return message; + // Adds a period if the last character is a letter. + if (char.IsLetter(message[^1])) + message += "."; + return message; + } + private void ClientDistanceToList(EntityUid source, int voiceRange, List playerSessions) { var ghosts = GetEntityQuery(); diff --git a/Content.Shared/CCVar/CCVars.cs b/Content.Shared/CCVar/CCVars.cs index f52edee9d7..44c4bf26d3 100644 --- a/Content.Shared/CCVar/CCVars.cs +++ b/Content.Shared/CCVar/CCVars.cs @@ -1072,6 +1072,12 @@ namespace Content.Shared.CCVar public static readonly CVarDef FlavorText = CVarDef.Create("ic.flavor_text", false, CVar.SERVER | CVar.REPLICATED); + /// + /// Adds a period at the end of a sentence if the sentence ends in a letter. + /// + public static readonly CVarDef ChatPunctuation = + CVarDef.Create("ic.punctuation", false, CVar.SERVER); + /* * Salvage */