mirror of
https://github.com/MCCTeam/Minecraft-Console-Client
synced 2025-10-14 21:22:49 +00:00
Added an option to match by colors in Auto Respond bot.
This commit is contained in:
parent
b5cf315ca1
commit
0d58887b6a
5 changed files with 30 additions and 24 deletions
|
|
@ -12,6 +12,7 @@ namespace MinecraftClient.ChatBots
|
|||
class AutoRespond : ChatBot
|
||||
{
|
||||
private string matchesFile;
|
||||
private bool matchColors;
|
||||
private List<RespondRule> respondRules;
|
||||
private enum MessageType { Public, Private, Other };
|
||||
|
||||
|
|
@ -19,9 +20,10 @@ namespace MinecraftClient.ChatBots
|
|||
/// Create a new AutoRespond bot
|
||||
/// </summary>
|
||||
/// <param name="matchesFile">INI File to load matches from</param>
|
||||
public AutoRespond(string matchesFile)
|
||||
public AutoRespond(string matchesFile, bool matchColors)
|
||||
{
|
||||
this.matchesFile = matchesFile;
|
||||
this.matchColors = matchColors;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -262,7 +264,8 @@ namespace MinecraftClient.ChatBots
|
|||
public override void GetText(string text)
|
||||
{
|
||||
//Remove colour codes
|
||||
text = GetVerbatim(text);
|
||||
if (!this.matchColors)
|
||||
text = GetVerbatim(text);
|
||||
|
||||
//Get Message type
|
||||
string sender = "", message = "";
|
||||
|
|
|
|||
|
|
@ -187,7 +187,7 @@ namespace MinecraftClient
|
|||
if (Settings.AutoRelog_Enabled) { BotLoad(new ChatBots.AutoRelog(Settings.AutoRelog_Delay_Min, Settings.AutoRelog_Delay_Max, Settings.AutoRelog_Retries)); }
|
||||
if (Settings.ScriptScheduler_Enabled) { BotLoad(new ChatBots.ScriptScheduler(Settings.ExpandVars(Settings.ScriptScheduler_TasksFile))); }
|
||||
if (Settings.RemoteCtrl_Enabled) { BotLoad(new ChatBots.RemoteControl()); }
|
||||
if (Settings.AutoRespond_Enabled) { BotLoad(new ChatBots.AutoRespond(Settings.AutoRespond_Matches)); }
|
||||
if (Settings.AutoRespond_Enabled) { BotLoad(new ChatBots.AutoRespond(Settings.AutoRespond_Matches, Settings.AutoRespond_MatchColors)); }
|
||||
if (Settings.AutoAttack_Enabled) { BotLoad(new ChatBots.AutoAttack(Settings.AutoAttack_Mode, Settings.AutoAttack_Priority, Settings.AutoAttack_OverrideAttackSpeed, Settings.AutoAttack_CooldownSeconds, Settings.AutoAttack_Interaction)); }
|
||||
if (Settings.AutoFishing_Enabled) { BotLoad(new ChatBots.AutoFishing()); }
|
||||
if (Settings.AutoEat_Enabled) { BotLoad(new ChatBots.AutoEat(Settings.AutoEat_hungerThreshold)); }
|
||||
|
|
|
|||
|
|
@ -188,6 +188,7 @@ tpaccepteveryone=false
|
|||
# /!\ This bot may get spammy depending on your rules, although the global messagecooldown setting can help you avoiding accidental spam
|
||||
enabled=false
|
||||
matchesfile=matches.ini
|
||||
matchcolors=false # Do not remove colors from text (Note: Your matches will have to include color codes (ones using the § character) in order to work)
|
||||
|
||||
[AutoAttack]
|
||||
# Automatically attack hostile mobs around you
|
||||
|
|
|
|||
|
|
@ -451,14 +451,14 @@ namespace MinecraftClient
|
|||
/// </summary>
|
||||
public static string GetVerbatim(string text)
|
||||
{
|
||||
if ( String.IsNullOrEmpty(text) )
|
||||
if (String.IsNullOrEmpty(text))
|
||||
return String.Empty;
|
||||
|
||||
int idx = 0;
|
||||
var data = new char[text.Length];
|
||||
|
||||
for ( int i = 0; i < text.Length; i++ )
|
||||
if ( text[i] != '§' )
|
||||
for (int i = 0; i < text.Length; i++)
|
||||
if (text[i] != '§')
|
||||
data[idx++] = text[i];
|
||||
else
|
||||
i++;
|
||||
|
|
@ -478,7 +478,7 @@ namespace MinecraftClient
|
|||
if (!((c >= 'a' && c <= 'z')
|
||||
|| (c >= 'A' && c <= 'Z')
|
||||
|| (c >= '0' && c <= '9')
|
||||
|| c == '_') )
|
||||
|| c == '_'))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -191,6 +191,7 @@ namespace MinecraftClient
|
|||
//Auto Respond
|
||||
public static bool AutoRespond_Enabled = false;
|
||||
public static string AutoRespond_Matches = "matches.ini";
|
||||
public static bool AutoRespond_MatchColors = false;
|
||||
|
||||
//Auto Attack
|
||||
public static bool AutoAttack_Enabled = false;
|
||||
|
|
@ -697,6 +698,7 @@ namespace MinecraftClient
|
|||
{
|
||||
case "enabled": AutoRespond_Enabled = str2bool(argValue); return true;
|
||||
case "matchesfile": AutoRespond_Matches = argValue; return true;
|
||||
case "matchcolors": AutoRespond_MatchColors = str2bool(argValue); return true;
|
||||
}
|
||||
break;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue