private static void add_auto(string nick, string channel, string hostname, string type, string reason, bot ircbot)
{
string list_file = ircbot.cur_dir + Path.DirectorySeparatorChar + "modules" + Path.DirectorySeparatorChar + "auto_kb" + Path.DirectorySeparatorChar + ircbot.Conf.Server_Name + "_list.txt";
string add_line = nick + "*" + hostname + "*" + channel + "*" + type + "*" + reason + "*" + DateTime.Now.ToString("MMMM d, yyyy h:mm:ss tt");
bool found_nick = false;
if (File.Exists(list_file))
{
string[] old_file = System.IO.File.ReadAllLines(list_file);
List<string> new_file = new List<string>();
foreach (string file_line in old_file)
{
char[] charSeparator = new char[] { '*' };
string[] auto_nick = file_line.Split(charSeparator, 5);
if (nick.Equals(auto_nick[0], StringComparison.InvariantCultureIgnoreCase) && hostname.Equals(auto_nick[1]) && channel.Equals(auto_nick[2]) && type.Equals(auto_nick[3]))
{
new_file.Add(add_line);
found_nick = true;
}
else
{
new_file.Add(file_line);
}
}
if (found_nick == false)
{
new_file.Add(add_line);
}
System.IO.File.WriteAllLines(@list_file, new_file);
string ban = "*!*@" + hostname;
if (String.IsNullOrEmpty(hostname))
{
ban = nick + "!*@*";
}
if (type.Equals("k"))
{
ircbot.sendData("KICK", channel + " " + nick + " :" + reason);
}
else if (type.Equals("b"))
{
ircbot.sendData("MODE", channel + " +b " + ban + " :" + reason);
}
else if (type.Equals("kb"))
{
ircbot.sendData("MODE", channel + " +b " + ban + " :" + reason);
ircbot.sendData("KICK", channel + " " + nick + " :" + reason);
}
else
{
}
}
else
{
System.IO.File.WriteAllText(@list_file, add_line);
}
ircbot.sendData("PRIVMSG", channel + " :" + nick + " has been added to the a" + type + " list.");
}