diff --git a/Plugins/ProfanityDeterment/Plugin.cs b/Plugins/ProfanityDeterment/Plugin.cs index 12966546..92aeaa47 100644 --- a/Plugins/ProfanityDeterment/Plugin.cs +++ b/Plugins/ProfanityDeterment/Plugin.cs @@ -23,6 +23,9 @@ namespace ProfanityDeterment public async Task OnEventAsync(Event E, Server S) { + if (!Settings.Configuration().EnableProfanityDeterment) + return; + if (E.Type == Event.GType.Connect) { if (!ProfanityCounts.TryAdd(E.Origin.ClientId, new Tracking(E.Origin))) diff --git a/SharedLibrary/Configuration/ApplicationConfiguration.cs b/SharedLibrary/Configuration/ApplicationConfiguration.cs index e7101af5..986f2fb0 100644 --- a/SharedLibrary/Configuration/ApplicationConfiguration.cs +++ b/SharedLibrary/Configuration/ApplicationConfiguration.cs @@ -11,6 +11,8 @@ namespace SharedLibrary.Configuration public bool EnableSteppedHierarchy { get; set; } public bool EnableClientVPNs { get; set; } public bool EnableDiscordLink { get; set; } + public bool EnableCustomSayName { get; set; } + public string CustomSayName { get; set; } public string DiscordInviteCode { get; set; } public string IPHubAPIKey { get; set; } public List Servers { get; set; } @@ -21,29 +23,22 @@ namespace SharedLibrary.Configuration public IBaseConfiguration Generate() { - Console.Write("Enable multiple owners? [y/n]: "); - EnableMultipleOwners = (Console.ReadLine().ToLower().FirstOrDefault() as char?) == 'y'; + EnableMultipleOwners = Utilities.PromptBool("Enable multiple owners"); + EnableSteppedHierarchy = Utilities.PromptBool("Enable stepped privilege hierarchy"); + EnableCustomSayName = Utilities.PromptBool("Enable custom say name"); - Console.Write("Enable stepped privilege hierarchy? [y/n]: "); - EnableSteppedHierarchy = (Console.ReadLine().ToLower().FirstOrDefault() as char?) == 'y'; + if (EnableCustomSayName) + CustomSayName = Utilities.PromptString("Enter custom say name"); - Console.Write("Enable client VPNs [y/n]: "); - EnableClientVPNs = (Console.ReadLine().ToLower().FirstOrDefault() as char?) == 'y'; + EnableClientVPNs = Utilities.PromptBool("Enable client VPNS"); if (!EnableClientVPNs) - { - Console.Write("Enter iphub.info api key: "); - IPHubAPIKey = Console.ReadLine(); - } + IPHubAPIKey = Utilities.PromptString("Enter iphub.info api key"); - Console.Write("Display discord link on webfront [y/n]: "); - EnableDiscordLink = (Console.ReadLine().ToLower().FirstOrDefault() as char?) == 'y'; + EnableDiscordLink = Utilities.PromptBool("Display discord link on webfront"); if (EnableDiscordLink) - { - Console.Write("Enter discord invite link: "); - DiscordInviteCode = Console.ReadLine(); - } + DiscordInviteCode = Utilities.PromptString("Enter discord invite link"); return this; } diff --git a/SharedLibrary/Server.cs b/SharedLibrary/Server.cs index 7869474f..126063ce 100644 --- a/SharedLibrary/Server.cs +++ b/SharedLibrary/Server.cs @@ -42,6 +42,8 @@ namespace SharedLibrary PlayerHistory = new Queue(); ChatHistory = new List(); NextMessage = 0; + CustomSayEnabled = Manager.GetApplicationSettings().Configuration().EnableCustomSayName; + CustomSayName = Manager.GetApplicationSettings().Configuration().CustomSayName; InitializeTokens(); InitializeAutoMessages(); } @@ -136,7 +138,7 @@ namespace SharedLibrary string sayCommand = (GameName == Game.IW4) ? "sayraw" : "say"; #if !DEBUG - await this.ExecuteCommandAsync($"{sayCommand} {Message}"); + await this.ExecuteCommandAsync($"{sayCommand} {(CustomSayEnabled ? CustomSayName : "")} {Message}"); #else Logger.WriteVerbose(Message.StripColors()); #endif @@ -153,7 +155,7 @@ namespace SharedLibrary #if !DEBUG if (Target.ClientNumber > -1 && Message.Length > 0 && Target.Level != Player.Permission.Console) - await this.ExecuteCommandAsync($"{tellCommand} {Target.ClientNumber} {Message}^7"); + await this.ExecuteCommandAsync($"{tellCommand} {Target.ClientNumber} {(CustomSayEnabled ? CustomSayName : "")} {Message}^7"); #else Logger.WriteVerbose($"{Target.ClientNumber}->{Message.StripColors()}"); #endif @@ -322,6 +324,10 @@ namespace SharedLibrary protected IFile LogFile; protected DateTime LastPoll; + // only here for performance + private bool CustomSayEnabled; + private string CustomSayName; + //Remote public IList CommandResult = new List(); } diff --git a/SharedLibrary/Utilities.cs b/SharedLibrary/Utilities.cs index 3451f7e6..355fcf7c 100644 --- a/SharedLibrary/Utilities.cs +++ b/SharedLibrary/Utilities.cs @@ -396,5 +396,18 @@ namespace SharedLibrary Console.Write($"{question}? [y/n]: "); return (Console.ReadLine().ToLower().FirstOrDefault() as char?) == 'y'; } + + public static string PromptString(string question) + { + Console.Write($"{question}: "); + + string response; + do + { + response = Console.ReadLine(); + } while (string.IsNullOrWhiteSpace(response)); + + return response; + } } } diff --git a/WebfrontCore/Views/Server/_ClientActivity.cshtml b/WebfrontCore/Views/Server/_ClientActivity.cshtml index a2843b4c..2a40512d 100644 --- a/WebfrontCore/Views/Server/_ClientActivity.cshtml +++ b/WebfrontCore/Views/Server/_ClientActivity.cshtml @@ -20,7 +20,7 @@ } if (Model.ChatHistory[i].Message != "CONNECTED" && Model.ChatHistory[i].Message != "DISCONNECTED") { - @Model.ChatHistory[i].Name — @message.Substring(0, Math.Min(50, message.Length - 1))
+ @Model.ChatHistory[i].Name — @message.Substring(0, Math.Min(50, message.Length))
} } } diff --git a/WebfrontCore/Views/Shared/_Layout.cshtml b/WebfrontCore/Views/Shared/_Layout.cshtml index a28d73a5..a4662b01 100644 --- a/WebfrontCore/Views/Shared/_Layout.cshtml +++ b/WebfrontCore/Views/Shared/_Layout.cshtml @@ -83,7 +83,7 @@
- @RenderSection("targetid", required: false); + @RenderSection("targetid", required: false)