profanity determent actually reads the configuration enable setting :P

removed unneeded semi colon in template
fixed accidentally truncating last character of message in activity
This commit is contained in:
RaidMax 2018-03-29 23:13:40 -05:00
parent 25cefb8b6a
commit 1bdf4e63fc
6 changed files with 37 additions and 20 deletions

View File

@ -23,6 +23,9 @@ namespace ProfanityDeterment
public async Task OnEventAsync(Event E, Server S) public async Task OnEventAsync(Event E, Server S)
{ {
if (!Settings.Configuration().EnableProfanityDeterment)
return;
if (E.Type == Event.GType.Connect) if (E.Type == Event.GType.Connect)
{ {
if (!ProfanityCounts.TryAdd(E.Origin.ClientId, new Tracking(E.Origin))) if (!ProfanityCounts.TryAdd(E.Origin.ClientId, new Tracking(E.Origin)))

View File

@ -11,6 +11,8 @@ namespace SharedLibrary.Configuration
public bool EnableSteppedHierarchy { get; set; } public bool EnableSteppedHierarchy { get; set; }
public bool EnableClientVPNs { get; set; } public bool EnableClientVPNs { get; set; }
public bool EnableDiscordLink { get; set; } public bool EnableDiscordLink { get; set; }
public bool EnableCustomSayName { get; set; }
public string CustomSayName { get; set; }
public string DiscordInviteCode { get; set; } public string DiscordInviteCode { get; set; }
public string IPHubAPIKey { get; set; } public string IPHubAPIKey { get; set; }
public List<ServerConfiguration> Servers { get; set; } public List<ServerConfiguration> Servers { get; set; }
@ -21,29 +23,22 @@ namespace SharedLibrary.Configuration
public IBaseConfiguration Generate() public IBaseConfiguration Generate()
{ {
Console.Write("Enable multiple owners? [y/n]: "); EnableMultipleOwners = Utilities.PromptBool("Enable multiple owners");
EnableMultipleOwners = (Console.ReadLine().ToLower().FirstOrDefault() as char?) == 'y'; EnableSteppedHierarchy = Utilities.PromptBool("Enable stepped privilege hierarchy");
EnableCustomSayName = Utilities.PromptBool("Enable custom say name");
Console.Write("Enable stepped privilege hierarchy? [y/n]: "); if (EnableCustomSayName)
EnableSteppedHierarchy = (Console.ReadLine().ToLower().FirstOrDefault() as char?) == 'y'; CustomSayName = Utilities.PromptString("Enter custom say name");
Console.Write("Enable client VPNs [y/n]: "); EnableClientVPNs = Utilities.PromptBool("Enable client VPNS");
EnableClientVPNs = (Console.ReadLine().ToLower().FirstOrDefault() as char?) == 'y';
if (!EnableClientVPNs) if (!EnableClientVPNs)
{ IPHubAPIKey = Utilities.PromptString("Enter iphub.info api key");
Console.Write("Enter iphub.info api key: ");
IPHubAPIKey = Console.ReadLine();
}
Console.Write("Display discord link on webfront [y/n]: "); EnableDiscordLink = Utilities.PromptBool("Display discord link on webfront");
EnableDiscordLink = (Console.ReadLine().ToLower().FirstOrDefault() as char?) == 'y';
if (EnableDiscordLink) if (EnableDiscordLink)
{ DiscordInviteCode = Utilities.PromptString("Enter discord invite link");
Console.Write("Enter discord invite link: ");
DiscordInviteCode = Console.ReadLine();
}
return this; return this;
} }

View File

@ -42,6 +42,8 @@ namespace SharedLibrary
PlayerHistory = new Queue<PlayerHistory>(); PlayerHistory = new Queue<PlayerHistory>();
ChatHistory = new List<ChatInfo>(); ChatHistory = new List<ChatInfo>();
NextMessage = 0; NextMessage = 0;
CustomSayEnabled = Manager.GetApplicationSettings().Configuration().EnableCustomSayName;
CustomSayName = Manager.GetApplicationSettings().Configuration().CustomSayName;
InitializeTokens(); InitializeTokens();
InitializeAutoMessages(); InitializeAutoMessages();
} }
@ -136,7 +138,7 @@ namespace SharedLibrary
string sayCommand = (GameName == Game.IW4) ? "sayraw" : "say"; string sayCommand = (GameName == Game.IW4) ? "sayraw" : "say";
#if !DEBUG #if !DEBUG
await this.ExecuteCommandAsync($"{sayCommand} {Message}"); await this.ExecuteCommandAsync($"{sayCommand} {(CustomSayEnabled ? CustomSayName : "")} {Message}");
#else #else
Logger.WriteVerbose(Message.StripColors()); Logger.WriteVerbose(Message.StripColors());
#endif #endif
@ -153,7 +155,7 @@ namespace SharedLibrary
#if !DEBUG #if !DEBUG
if (Target.ClientNumber > -1 && Message.Length > 0 && Target.Level != Player.Permission.Console) 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 #else
Logger.WriteVerbose($"{Target.ClientNumber}->{Message.StripColors()}"); Logger.WriteVerbose($"{Target.ClientNumber}->{Message.StripColors()}");
#endif #endif
@ -322,6 +324,10 @@ namespace SharedLibrary
protected IFile LogFile; protected IFile LogFile;
protected DateTime LastPoll; protected DateTime LastPoll;
// only here for performance
private bool CustomSayEnabled;
private string CustomSayName;
//Remote //Remote
public IList<CommandResponseInfo> CommandResult = new List<CommandResponseInfo>(); public IList<CommandResponseInfo> CommandResult = new List<CommandResponseInfo>();
} }

View File

@ -396,5 +396,18 @@ namespace SharedLibrary
Console.Write($"{question}? [y/n]: "); Console.Write($"{question}? [y/n]: ");
return (Console.ReadLine().ToLower().FirstOrDefault() as char?) == 'y'; 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;
}
} }
} }

View File

@ -20,7 +20,7 @@
} }
if (Model.ChatHistory[i].Message != "CONNECTED" && Model.ChatHistory[i].Message != "DISCONNECTED") if (Model.ChatHistory[i].Message != "CONNECTED" && Model.ChatHistory[i].Message != "DISCONNECTED")
{ {
<span class="text-light">@Model.ChatHistory[i].Name</span><span> &mdash; @message.Substring(0, Math.Min(50, message.Length - 1)) </span><br /> <span class="text-light">@Model.ChatHistory[i].Name</span><span> &mdash; @message.Substring(0, Math.Min(50, message.Length)) </span><br />
} }
} }
} }

View File

@ -83,7 +83,7 @@
</div> </div>
</div> </div>
<div id="target_id"> <div id="target_id">
@RenderSection("targetid", required: false); @RenderSection("targetid", required: false)
</div> </div>
<!-- End Action Modal --> <!-- End Action Modal -->