Skip to content

Commit

Permalink
Use generic chat message formatter.
Browse files Browse the repository at this point in the history
  • Loading branch information
snixtho committed Oct 13, 2023
1 parent 8e64be8 commit cd85f84
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
9 changes: 3 additions & 6 deletions src/EvoSC.Common/Remote/ChatRouter/RemoteChatRouter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,9 @@ private async Task HandlePlayerChatRoutingAsync(object sender, PlayerChatGbxEven
{
Task.Run(async () =>
{
await _server.SendChatMessageAsync(new TextFormatter()
.AddText("[")
.AddText(text => text.AsIsolated().AddText(player.NickName))
.AddText("] ")
.AddText(text => text.AsIsolated().AddText(chatContext.MessageText))
);
var formatted = FormattingUtils.FormatPlayerChatMessage(chatContext.Player.NickName,
chatContext.MessageText);
await _server.SendChatMessageAsync(formatted);
});
}
});
Expand Down
4 changes: 2 additions & 2 deletions src/EvoSC.Common/Util/FormattingUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,14 @@ public static string FormatTimeAsDelta(int milliseconds)
return $"+ {s:0}.{ms:000}";
}

public static string FormatPlayerChatMessage(string nickname, string message)
public static TextFormatter FormatPlayerChatMessage(string nickname, string message)
{
var formattedMessage = new TextFormatter()
.AddText("[")
.AddText(text => text.AsIsolated().AddText(nickname))
.AddText("] ")
.AddText(text => text.AsIsolated().AddText(message));

return formattedMessage.ToString();
return formattedMessage;
}
}

0 comments on commit cd85f84

Please sign in to comment.