diff --git a/MinecraftClient/ChatBot.cs b/MinecraftClient/ChatBot.cs
index 59fff3cd..a3d57840 100644
--- a/MinecraftClient/ChatBot.cs
+++ b/MinecraftClient/ChatBot.cs
@@ -296,13 +296,13 @@ namespace MinecraftClient
}
///
- /// Writes some text in the console. Nothing will be sent to the server.
+ /// Write some text in the console. Nothing will be sent to the server.
///
/// Log text to write
- public static void LogToConsole(object text)
+ public void LogToConsole(object text)
{
- ConsoleIO.WriteLineFormatted("§8[BOT] " + text);
+ ConsoleIO.WriteLogLine(String.Format("[{0}] {1}", this.GetType().Name, text));
string logfile = Settings.ExpandVars(Settings.chatbotLogFile);
if (!String.IsNullOrEmpty(logfile))
@@ -393,7 +393,7 @@ namespace MinecraftClient
/// File to load
/// The string array or an empty array if failed to load the file
- protected static string[] LoadDistinctEntriesFromFile(string file)
+ protected string[] LoadDistinctEntriesFromFile(string file)
{
if (File.Exists(file))
{
diff --git a/MinecraftClient/ChatBots/AutoRespond.cs b/MinecraftClient/ChatBots/AutoRespond.cs
index 567b38b0..19146854 100644
--- a/MinecraftClient/ChatBots/AutoRespond.cs
+++ b/MinecraftClient/ChatBots/AutoRespond.cs
@@ -12,7 +12,6 @@ namespace MinecraftClient.ChatBots
{
private string matchesFile;
private List respondRules;
- private static string header = "[AutoRespond] ";
///
/// Create a new AutoRespond bot
@@ -84,7 +83,7 @@ namespace MinecraftClient.ChatBots
}
else if (!String.IsNullOrEmpty(match))
{
- if (message.Contains(match))
+ if (message.ToLower().Contains(match.ToLower()))
{
return (privateMsg
? actionPrivate
@@ -137,7 +136,7 @@ namespace MinecraftClient.ChatBots
case "regex": matchRegex = new Regex(argValue); break;
case "match": matchString = argValue; break;
case "action": matchAction = argValue; break;
- case "actionprivate": matchAction = argValue; break;
+ case "actionprivate": matchActionPrivate = argValue; break;
}
}
}
@@ -182,7 +181,7 @@ namespace MinecraftClient.ChatBots
public override void GetText(string text)
{
//Remove colour codes
- text = GetVerbatim(text).ToLower();
+ text = GetVerbatim(text);
//Check if this is a valid message
string sender = "", message = "";
@@ -200,10 +199,10 @@ namespace MinecraftClient.ChatBots
if (toPerform != null)
{
string response = null;
- LogToConsole(header + toPerform);
+ LogToConsole(toPerform);
PerformInternalCommand(toPerform, ref response);
if (!String.IsNullOrEmpty(response))
- LogToConsole(header + response);
+ LogToConsole(response);
}
}
}
diff --git a/MinecraftClient/Commands/Log.cs b/MinecraftClient/Commands/Log.cs
index afc2dcef..2e435553 100644
--- a/MinecraftClient/Commands/Log.cs
+++ b/MinecraftClient/Commands/Log.cs
@@ -14,7 +14,7 @@ namespace MinecraftClient.Commands
{
if (hasArg(command))
{
- ChatBot.LogToConsole(getArg(command));
+ ConsoleIO.WriteLogLine(getArg(command));
return "";
}
else return CMDDesc;
diff --git a/MinecraftClient/ConsoleIO.cs b/MinecraftClient/ConsoleIO.cs
index dd488d52..9daeadc9 100644
--- a/MinecraftClient/ConsoleIO.cs
+++ b/MinecraftClient/ConsoleIO.cs
@@ -326,6 +326,16 @@ namespace MinecraftClient
}
}
+ ///
+ /// Write a Minecraft Console Client Log line
+ ///
+ /// Text of the log line
+
+ public static void WriteLogLine(string text)
+ {
+ WriteLineFormatted("§8[MCC] " + text);
+ }
+
#region Subfunctions
private static void ClearLineAndBuffer()
{
diff --git a/MinecraftClient/McTcpClient.cs b/MinecraftClient/McTcpClient.cs
index 769c2d02..db8b66fa 100644
--- a/MinecraftClient/McTcpClient.cs
+++ b/MinecraftClient/McTcpClient.cs
@@ -163,7 +163,7 @@ namespace MinecraftClient
{
if (AttemptsLeft > 0)
{
- ChatBot.LogToConsole("Waiting 5 seconds (" + AttemptsLeft + " attempts left)...");
+ ConsoleIO.WriteLogLine("Waiting 5 seconds (" + AttemptsLeft + " attempts left)...");
Thread.Sleep(5000); AttemptsLeft--; Program.Restart();
}
else if (!singlecommand && Settings.interactiveMode)
diff --git a/MinecraftClient/config/sample-matches.ini b/MinecraftClient/config/sample-matches.ini
new file mode 100644
index 00000000..fcf228a0
--- /dev/null
+++ b/MinecraftClient/config/sample-matches.ini
@@ -0,0 +1,32 @@
+# Minecraft Console Client
+# AutoRespond matches
+# Example config file
+
+# Structure of a match: [Match] Followed by the match and action
+# The match can be a simple match or an advanced regular expression
+# You can define a different action if the match was in a private message
+# You can use $u for username of the player triggering the match
+# Regex matches are also supported eg $1, $2, $3.. in actions
+
+# Simple example: Respond to a message containing a keyword
+
+[Match]
+match=hi
+action=send hi, $u!
+actionprivate=send /tell $u Hello!
+
+# Advanced example: Use a regular expression
+
+[Match]
+regex=^.*hello ([a-zA-Z0-9_]+).*$
+action=send hello too, $1!
+
+# You can also use any other internal command
+# Private action is optional
+
+[Match]
+match=dotest
+action=script test
+
+# Enjoy!
+# - ORelio
\ No newline at end of file