Skip to content

Commit

Permalink
fix(server): fix chat message cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielMcAssey committed Jan 14, 2025
1 parent df9fae1 commit 584d911
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion GLOKON.Baiters.Core/Packets/Handlers/MessageHandler.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
using GLOKON.Baiters.Core.Models.Networking;
using System.Numerics;
using System.Text.RegularExpressions;

namespace GLOKON.Baiters.Core.Packets.Handlers
{
internal class MessageHandler(BaitersServer server) : IPacketHandler
{
private readonly Regex _messageCleanUpRegex = new(Regex.Escape("%u:"));

public void Handle(ulong sender, Packet data)
{
string playerName = "UNKNOWN";
Expand All @@ -19,7 +22,7 @@ public void Handle(ulong sender, Packet data)
SentAt = DateTime.Now,
SenderId = sender,
SenderName = playerName,
Message = ((string)data["message"]).Replace("%u", string.Empty).Trim(),
Message = _messageCleanUpRegex.Replace((string)data["message"], string.Empty, 1).Trim(),
Colour = (string)data["color"],
IsLocal = (bool)data["local"],
Position = (Vector3)data["position"],
Expand Down

0 comments on commit 584d911

Please sign in to comment.