format all output for color keys

This commit is contained in:
RaidMax 2022-04-27 15:36:58 -05:00
parent 104d9bdc4c
commit 074e36413e
2 changed files with 7 additions and 7 deletions

View File

@ -80,6 +80,7 @@ namespace IW4MAdmin.Application.RConParsers
public async Task<string[]> ExecuteCommandAsync(IRConConnection connection, string command, CancellationToken token = default)
{
command = command.FormatMessageForEngine(Configuration?.ColorCodeMapping);
var response = await connection.SendQueryAsync(StaticHelpers.QueryType.COMMAND, command, token);
return response.Where(item => item != Configuration.CommandPrefixes.RConResponse).ToArray();
}

View File

@ -222,7 +222,7 @@ namespace SharedLibraryCore
public GameEvent Broadcast(string message, EFClient sender = null)
{
var formattedMessage = string.Format(RconParser.Configuration.CommandPrefixes.Say ?? "",
$"{(CustomSayEnabled && GameName == Game.IW4 ? $"{CustomSayName}: " : "")}{message.FormatMessageForEngine(RconParser.Configuration.ColorCodeMapping)}");
$"{(CustomSayEnabled && GameName == Game.IW4 ? $"{CustomSayName}: " : "")}{message}");
ServerLogger.LogDebug("All-> {Message}",
message.FormatMessageForEngine(RconParser.Configuration.ColorCodeMapping).StripColors());
@ -270,8 +270,6 @@ namespace SharedLibraryCore
/// <param name="targetClient">EFClient to send message to</param>
protected async Task Tell(string message, EFClient targetClient)
{
var engineMessage = message.FormatMessageForEngine(RconParser.Configuration.ColorCodeMapping);
if (!Utilities.IsDevelopment)
{
var temporalClientId = targetClient.GetAdditionalProperty<string>("ConnectionClientId");
@ -280,7 +278,7 @@ namespace SharedLibraryCore
var formattedMessage = string.Format(RconParser.Configuration.CommandPrefixes.Tell,
clientNumber,
$"{(CustomSayEnabled && GameName == Game.IW4 ? $"{CustomSayName}: " : "")}{engineMessage}");
$"{(CustomSayEnabled && GameName == Game.IW4 ? $"{CustomSayName}: " : "")}{message}");
if (targetClient.ClientNumber > -1 && message.Length > 0 &&
targetClient.Level != Data.Models.Client.EFClient.Permission.Console)
{
@ -296,13 +294,14 @@ namespace SharedLibraryCore
if (targetClient.Level == Data.Models.Client.EFClient.Permission.Console)
{
Console.ForegroundColor = ConsoleColor.Green;
var cleanMessage = message.FormatMessageForEngine(RconParser.Configuration.ColorCodeMapping)
.StripColors();
using (LogContext.PushProperty("Server", ToString()))
{
ServerLogger.LogInformation("Command output received: {Message}",
engineMessage.StripColors());
ServerLogger.LogInformation("Command output received: {Message}", cleanMessage);
}
Console.WriteLine(engineMessage.StripColors());
Console.WriteLine(cleanMessage);
Console.ForegroundColor = ConsoleColor.Gray;
}
}