AutoRespond tests and fixes

- Automatically add [BotName] tags to log lines
- Fix case handling and actionPrivate used for public messages
- Add a sample file for basic and regex matches
This commit is contained in:
ORelio 2015-06-21 16:40:13 +02:00
parent 3ce91188c7
commit a6b3bf0481
6 changed files with 53 additions and 12 deletions

View file

@ -12,7 +12,6 @@ namespace MinecraftClient.ChatBots
{
private string matchesFile;
private List<RespondRule> respondRules;
private static string header = "[AutoRespond] ";
/// <summary>
/// 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);
}
}
}