mirror of
https://github.com/MikuLeaks/MikuSB.git
synced 2026-06-04 07:23:58 +00:00
28 lines
696 B
C#
28 lines
696 B
C#
using System.Text.RegularExpressions;
|
|
|
|
namespace MikuSB.GameServer.Game.Player;
|
|
|
|
public static partial class ChatMessageHelper
|
|
{
|
|
[GeneratedRegex(@"\s+")]
|
|
private static partial Regex MultiWhitespaceRegex();
|
|
|
|
public static uint BuildClientTimestamp()
|
|
{
|
|
return (uint)MikuSB.Util.Extensions.Extensions.GetUnixSec();
|
|
}
|
|
|
|
public static string NormalizeForClient(string? text)
|
|
{
|
|
if (string.IsNullOrWhiteSpace(text))
|
|
return string.Empty;
|
|
|
|
var normalized = text
|
|
.Replace("\r\n", " ")
|
|
.Replace('\r', ' ')
|
|
.Replace('\n', ' ');
|
|
|
|
return MultiWhitespaceRegex().Replace(normalized, " ").Trim();
|
|
}
|
|
}
|