mirror of
https://github.com/MCCTeam/Minecraft-Console-Client
synced 2025-10-14 21:22:49 +00:00
Auto Respond Bot
This bot allows users to add a bot that can detect and respond to certain text. The bot can be enabled/disabled via the ini file. (disabled by default) The bot uses 2 files to let the user set what to pickup and what to respond.
This commit is contained in:
parent
834e446a74
commit
43fa3fb4b4
4 changed files with 93 additions and 10 deletions
|
|
@ -21,7 +21,7 @@ namespace MinecraftClient
|
|||
public static string Password = "";
|
||||
public static string ServerIP = "";
|
||||
public static ushort ServerPort = 25565;
|
||||
public static string ServerVersion = "";
|
||||
public static string ServerVersion = "";
|
||||
public static string SingleCommand = "";
|
||||
public static string ConsoleTitle = "";
|
||||
|
||||
|
|
@ -88,12 +88,17 @@ namespace MinecraftClient
|
|||
public static bool RemoteCtrl_AutoTpaccept = true;
|
||||
public static bool RemoteCtrl_AutoTpaccept_Everyone = false;
|
||||
|
||||
//Auto Respond
|
||||
public static bool Respond_Enabled = false;
|
||||
public static string Respond_MatchesFile = "detect.txt";
|
||||
public static string Respond_RespondFile = "respond.txt";
|
||||
|
||||
//Custom app variables and Minecraft accounts
|
||||
private static Dictionary<string, string> AppVars = new Dictionary<string, string>();
|
||||
private static Dictionary<string, KeyValuePair<string, string>> Accounts = new Dictionary<string, KeyValuePair<string, string>>();
|
||||
private static Dictionary<string, KeyValuePair<string, ushort>> Servers = new Dictionary<string, KeyValuePair<string, ushort>>();
|
||||
|
||||
private enum ParseMode { Default, Main, AppVars, Proxy, AntiAFK, Hangman, Alerts, ChatLog, AutoRelog, ScriptScheduler, RemoteControl };
|
||||
private enum ParseMode { Default, Main, AppVars, Proxy, AntiAFK, Hangman, Alerts, ChatLog, AutoRelog, ScriptScheduler, RemoteControl, Auto_Respond };
|
||||
|
||||
/// <summary>
|
||||
/// Load settings from the give INI file
|
||||
|
|
@ -127,6 +132,7 @@ namespace MinecraftClient
|
|||
case "remotecontrol": pMode = ParseMode.RemoteControl; break;
|
||||
case "proxy": pMode = ParseMode.Proxy; break;
|
||||
case "appvars": pMode = ParseMode.AppVars; break;
|
||||
case "auto respond": pMode = ParseMode.Auto_Respond; break;
|
||||
default: pMode = ParseMode.Default; break;
|
||||
}
|
||||
}
|
||||
|
|
@ -201,7 +207,7 @@ namespace MinecraftClient
|
|||
Servers[server_data[0]]
|
||||
= new KeyValuePair<string, ushort>(ServerIP, ServerPort);
|
||||
}
|
||||
|
||||
|
||||
//Restore current server info
|
||||
ServerIP = server_host_temp;
|
||||
ServerPort = server_port_temp;
|
||||
|
|
@ -284,7 +290,7 @@ namespace MinecraftClient
|
|||
argValue = argValue.ToLower();
|
||||
if (argValue == "http") { proxyType = Proxy.ProxyHandler.Type.HTTP; }
|
||||
else if (argValue == "socks4") { proxyType = Proxy.ProxyHandler.Type.SOCKS4; }
|
||||
else if (argValue == "socks4a"){ proxyType = Proxy.ProxyHandler.Type.SOCKS4a;}
|
||||
else if (argValue == "socks4a") { proxyType = Proxy.ProxyHandler.Type.SOCKS4a; }
|
||||
else if (argValue == "socks5") { proxyType = Proxy.ProxyHandler.Type.SOCKS5; }
|
||||
break;
|
||||
case "server":
|
||||
|
|
@ -308,6 +314,15 @@ namespace MinecraftClient
|
|||
case ParseMode.AppVars:
|
||||
setVar(argName, argValue);
|
||||
break;
|
||||
|
||||
case ParseMode.Auto_Respond:
|
||||
switch (argName.ToLower())
|
||||
{
|
||||
case "enabled": Respond_Enabled = str2bool(argValue); break;
|
||||
case "matchfile": Respond_MatchesFile = argValue; break;
|
||||
case "respondfile": Respond_RespondFile = argValue; break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -402,7 +417,14 @@ namespace MinecraftClient
|
|||
+ "[RemoteControl]\r\n"
|
||||
+ "enabled=false\r\n"
|
||||
+ "autotpaccept=true\r\n"
|
||||
+ "tpaccepteveryone=false\r\n", Encoding.UTF8);
|
||||
+ "tpaccepteveryone=false\r\n"
|
||||
+ "\r\n"
|
||||
+ "[Auto Respond]\r\n"
|
||||
+ "enabled=false\r\n"
|
||||
+ "matchfile=detect.txt\r\n"
|
||||
+ "respondfile=respond.txt\r\n"
|
||||
+ "#To use the bot, place the text to detect in the matchfile file and the text to respond with in the respondfile\r\n"
|
||||
+ "#Each line in each file is relevant to the same line in the other document, for example if the bot detects the text in line 1 of the first file, it will respond with line 1 of the second file.\r\n", Encoding.UTF8);
|
||||
}
|
||||
|
||||
public static int str2int(string str) { try { return Convert.ToInt32(str); } catch { return 0; } }
|
||||
|
|
@ -436,7 +458,7 @@ namespace MinecraftClient
|
|||
string[] sip = server.Split(':');
|
||||
string host = sip[0];
|
||||
ushort port = 25565;
|
||||
|
||||
|
||||
if (sip.Length > 1)
|
||||
{
|
||||
try
|
||||
|
|
@ -458,7 +480,7 @@ namespace MinecraftClient
|
|||
ServerPort = Servers[server].Value;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue