diff --git a/MinecraftClient/ChatBots/AutoRespond.cs b/MinecraftClient/ChatBots/AutoRespond.cs index bb14c5b1..c1c0b559 100644 --- a/MinecraftClient/ChatBots/AutoRespond.cs +++ b/MinecraftClient/ChatBots/AutoRespond.cs @@ -33,6 +33,7 @@ namespace MinecraftClient.ChatBots private string actionPublic; private string actionPrivate; private string actionOther; + private bool ownersOnly; /// /// Create a respond rule from a regex and a reponse message or command @@ -41,13 +42,15 @@ namespace MinecraftClient.ChatBots /// Internal command to run for public messages /// Internal command to run for private messages /// Internal command to run for any other messages - public RespondRule(Regex regex, string actionPublic, string actionPrivate, string actionOther) + /// Only match messages from bot owners + public RespondRule(Regex regex, string actionPublic, string actionPrivate, string actionOther, bool ownersOnly) { this.regex = regex; this.match = null; this.actionPublic = actionPublic; this.actionPrivate = actionPrivate; this.actionOther = actionOther; + this.ownersOnly = ownersOnly; } /// @@ -56,13 +59,15 @@ namespace MinecraftClient.ChatBots /// Match string /// Internal command to run for public messages /// Internal command to run for private messages - public RespondRule(string match, string actionPublic, string actionPrivate, string actionOther) + /// Only match messages from bot owners + public RespondRule(string match, string actionPublic, string actionPrivate, string actionOther, bool ownersOnly) { this.regex = null; this.match = match; this.actionPublic = actionPublic; this.actionPrivate = actionPrivate; this.actionOther = actionOther; + this.ownersOnly = ownersOnly; } /// @@ -76,6 +81,9 @@ namespace MinecraftClient.ChatBots { string toSend = null; + if (ownersOnly && (String.IsNullOrEmpty(username) || !Settings.Bots_Owners.Contains(username.ToLower()))) + return null; + switch (msgType) { case MessageType.Public: toSend = actionPublic; break; @@ -121,6 +129,7 @@ namespace MinecraftClient.ChatBots string matchAction = null; string matchActionPrivate = null; string matchActionOther = null; + bool ownersOnly = false; respondRules = new List(); foreach (string lineRAW in File.ReadAllLines(matchesFile)) @@ -133,12 +142,13 @@ namespace MinecraftClient.ChatBots switch (line.Substring(1, line.Length - 2).ToLower()) { case "match": - CheckAddMatch(matchRegex, matchString, matchAction, matchActionPrivate, matchActionOther); + CheckAddMatch(matchRegex, matchString, matchAction, matchActionPrivate, matchActionOther, ownersOnly); matchRegex = null; matchString = null; matchAction = null; matchActionPrivate = null; matchActionOther = null; + ownersOnly = false; break; } } @@ -155,12 +165,13 @@ namespace MinecraftClient.ChatBots case "action": matchAction = argValue; break; case "actionprivate": matchActionPrivate = argValue; break; case "actionother": matchActionOther = argValue; break; + case "ownersonly": ownersOnly = Settings.str2bool(argValue); break; } } } } } - CheckAddMatch(matchRegex, matchString, matchAction, matchActionPrivate, matchActionOther); + CheckAddMatch(matchRegex, matchString, matchAction, matchActionPrivate, matchActionOther, ownersOnly); } else { @@ -176,17 +187,18 @@ namespace MinecraftClient.ChatBots /// Matching string /// Action if the matching message is public /// Action if the matching message is private - private void CheckAddMatch(Regex matchRegex, string matchString, string matchAction, string matchActionPrivate, string matchActionOther) + /// Only match messages from bot owners + private void CheckAddMatch(Regex matchRegex, string matchString, string matchAction, string matchActionPrivate, string matchActionOther, bool ownersOnly) { if (matchAction != null || matchActionPrivate != null || matchActionOther != null) { if (matchRegex != null) { - respondRules.Add(new RespondRule(matchRegex, matchAction, matchActionPrivate, matchActionOther)); + respondRules.Add(new RespondRule(matchRegex, matchAction, matchActionPrivate, matchActionOther, ownersOnly)); } else if (matchString != null) { - respondRules.Add(new RespondRule(matchString, matchAction, matchActionPrivate, matchActionOther)); + respondRules.Add(new RespondRule(matchString, matchAction, matchActionPrivate, matchActionOther, ownersOnly)); } } } diff --git a/MinecraftClient/Settings.cs b/MinecraftClient/Settings.cs index 6714ef5a..bb242b4b 100644 --- a/MinecraftClient/Settings.cs +++ b/MinecraftClient/Settings.cs @@ -196,7 +196,8 @@ namespace MinecraftClient case "botowners": Bots_Owners.Clear(); foreach (string name in argValue.ToLower().Split(',')) - Bots_Owners.Add(name.Trim()); + if (!String.IsNullOrWhiteSpace(name)) + Bots_Owners.Add(name.Trim()); break; case "internalcmdchar": diff --git a/MinecraftClient/config/README.txt b/MinecraftClient/config/README.txt index 0f1ad802..f2c7035d 100644 --- a/MinecraftClient/config/README.txt +++ b/MinecraftClient/config/README.txt @@ -22,7 +22,7 @@ If Mono crashes, retry with mono-complete, not mono-runtime. Mono v4.0 to 4.2 is Using Configuration files & Enabling bots =========================================== -Simply open the INI file with a text editor and change the values. +Simply open the INI configuration file with a text editor and change the values. To enable a bot change the "enabled" value in the INI file from "false" to "true". You will still be able to send and receive chat messages when a bot is loaded. You can remove or comment some lines from the INI file to use the default values instead. @@ -34,6 +34,8 @@ You can have several INI files and drag & drop one of them over MinecraftClient. > MinecraftClient.exe username password server This will automatically connect you to the chosen server. +To specify a server and ask password interactively, use "" as password. +To specify offline mode with no password, use "-" as password. > MinecraftClient.exe username password server "/mycommand" This will automatically send "/mycommand" to the server and close. @@ -61,6 +63,7 @@ In scripts and remote control, no slash is needed to perform the command. - send : send a message or a command to the server - respawn : Use this to respawn if you are dead (like clicking "respawn" ingame) - log : display some text in the console (useful for scripts) + - list : list players logged in to the server (uses tab list info sent by server) - set varname=value : set a value which can be used as %varname% in further commands - wait