diff --git a/MinecraftClient/ChatBots/Alerts.cs b/MinecraftClient/ChatBots/Alerts.cs index 349163b4..0f9a04d7 100644 --- a/MinecraftClient/ChatBots/Alerts.cs +++ b/MinecraftClient/ChatBots/Alerts.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.IO; +using static System.Net.WebRequestMethods; namespace MinecraftClient.ChatBots { @@ -13,6 +14,7 @@ namespace MinecraftClient.ChatBots { private string[] dictionary = new string[0]; private string[] excludelist = new string[0]; + private bool logToFile = false; /// /// Intitialize the Alerts bot @@ -21,6 +23,7 @@ namespace MinecraftClient.ChatBots { dictionary = LoadDistinctEntriesFromFile(Settings.Alerts_MatchesFile); excludelist = LoadDistinctEntriesFromFile(Settings.Alerts_ExcludesFile); + logToFile = Settings.Alerts_File_Logging; } /// @@ -42,6 +45,13 @@ namespace MinecraftClient.ChatBots Console.Beep(); //Text found ! ConsoleIO.WriteLine(text.Replace(alert, "§c" + alert + "§r")); + + if (logToFile && Settings.Alerts_LogFile.Length > 0) + { + DateTime now = DateTime.Now; + string TimeStamp = "[" + now.Year + '/' + now.Month + '/' + now.Day + ' ' + now.Hour + ':' + now.Minute + ']'; + System.IO.File.AppendAllText(Settings.Alerts_LogFile, TimeStamp + " " + GetVerbatim(text) + "\n"); + } } } } diff --git a/MinecraftClient/Resources/config/MinecraftClient.ini b/MinecraftClient/Resources/config/MinecraftClient.ini index 469eb472..8507fba4 100644 --- a/MinecraftClient/Resources/config/MinecraftClient.ini +++ b/MinecraftClient/Resources/config/MinecraftClient.ini @@ -134,6 +134,8 @@ enabled=false alertsfile=alerts.txt # List of words/strings to alert you on, e.g. "Yourname" excludesfile=alerts-exclude.txt # List of words/strings to NOT alert you on, e.g. "" beeponalert=true # Play a beep sound when a word is detected in addition to highlighting +logtofile=false # Log alerts info a file +logfile=alerts-log.txt # The name of a file where alers logs will be written [AntiAFK] # Send a command on a regular basis to avoid automatic AFK disconnection diff --git a/MinecraftClient/Settings.cs b/MinecraftClient/Settings.cs index 582da93d..ce270300 100644 --- a/MinecraftClient/Settings.cs +++ b/MinecraftClient/Settings.cs @@ -153,8 +153,10 @@ namespace MinecraftClient //Alerts Settings public static bool Alerts_Enabled = false; public static bool Alerts_Beep_Enabled = true; + public static bool Alerts_File_Logging = false; public static string Alerts_MatchesFile = "alerts.txt"; public static string Alerts_ExcludesFile = "alerts-exclude.txt"; + public static string Alerts_LogFile = "alerts-log.txt"; //ChatLog Settings public static bool ChatLog_Enabled = false; @@ -575,6 +577,8 @@ namespace MinecraftClient case "alertsfile": Alerts_MatchesFile = argValue; return true; case "excludesfile": Alerts_ExcludesFile = argValue; return true; case "beeponalert": Alerts_Beep_Enabled = str2bool(argValue); return true; + case "logtofile": Alerts_File_Logging = str2bool(argValue); return true; + case "logfile": Alerts_LogFile = argValue; return true; } break;