mirror of
https://github.com/MCCTeam/Minecraft-Console-Client
synced 2025-11-07 17:36:07 +00:00
Normalize AutoRespond bot
Move FromFile method from bots to ChatBot class Rename file and class, removing space and underscore.
This commit is contained in:
parent
b07091e3dd
commit
53156bdf98
5 changed files with 33 additions and 50 deletions
|
|
@ -14,36 +14,13 @@ namespace MinecraftClient.ChatBots
|
|||
private string[] dictionary = new string[0];
|
||||
private string[] excludelist = new string[0];
|
||||
|
||||
/// <summary>
|
||||
/// Import alerts from the specified file
|
||||
/// </summary>
|
||||
/// <param name="file"></param>
|
||||
/// <returns></returns>
|
||||
private static string[] FromFile(string file)
|
||||
{
|
||||
if (File.Exists(file))
|
||||
{
|
||||
//Read all lines from file, remove lines with no text, convert to lowercase,
|
||||
//remove duplicate entries, convert to a string array, and return the result.
|
||||
return File.ReadAllLines(file)
|
||||
.Where(line => !String.IsNullOrWhiteSpace(line))
|
||||
.Select(line => line.ToLower())
|
||||
.Distinct().ToArray();
|
||||
}
|
||||
else
|
||||
{
|
||||
LogToConsole("File not found: " + Settings.Alerts_MatchesFile);
|
||||
return new string[0];
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Intitialize the Alerts bot
|
||||
/// </summary>
|
||||
public override void Initialize()
|
||||
{
|
||||
dictionary = FromFile(Settings.Alerts_MatchesFile);
|
||||
excludelist = FromFile(Settings.Alerts_ExcludesFile);
|
||||
dictionary = LoadDistinctEntriesFromFile(Settings.Alerts_MatchesFile);
|
||||
excludelist = LoadDistinctEntriesFromFile(Settings.Alerts_ExcludesFile);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
|||
|
|
@ -6,34 +6,16 @@ using System.IO;
|
|||
|
||||
namespace MinecraftClient.ChatBots
|
||||
{
|
||||
class Auto_Respond : ChatBot
|
||||
class AutoRespond : ChatBot
|
||||
{
|
||||
private String[] respondon = new String[0];
|
||||
private String[] torespond = new String[0];
|
||||
|
||||
private static string[] FromFile(string file)
|
||||
{
|
||||
if (File.Exists(file))
|
||||
{
|
||||
//Read all lines from file, remove lines with no text, convert to lowercase,
|
||||
//remove duplicate entries, convert to a string array, and return the result.
|
||||
return File.ReadAllLines(file)
|
||||
.Where(line => !String.IsNullOrWhiteSpace(line))
|
||||
.Select(line => line.ToLower())
|
||||
.Distinct().ToArray();
|
||||
}
|
||||
else
|
||||
{
|
||||
LogToConsole("File not found: " + file);
|
||||
return new string[0];
|
||||
}
|
||||
}
|
||||
private string[] respondon = new string[0];
|
||||
private string[] torespond = new string[0];
|
||||
|
||||
//Initalize the bot
|
||||
public override void Initialize()
|
||||
{
|
||||
respondon = FromFile(Settings.Respond_MatchesFile);
|
||||
torespond = FromFile(Settings.Respond_RespondFile);
|
||||
respondon = LoadDistinctEntriesFromFile(Settings.Respond_MatchesFile);
|
||||
torespond = LoadDistinctEntriesFromFile(Settings.Respond_RespondFile);
|
||||
ConsoleIO.WriteLine("Auto Respond Bot Sucessfully loaded!");
|
||||
}
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue