public override void control(bot ircbot, ref IRCConfig conf, int module_id, string[] line, string command, int nick_access, string nick, string channel, bool bot_command, string type) { string module_name = ircbot.conf.module_config[module_id][0]; int max_lines = Convert.ToInt32(ircbot.conf.module_config[module_id][3]); int check_timeout = Convert.ToInt32(ircbot.conf.module_config[module_id][4]); bool warn = Convert.ToBoolean(ircbot.conf.module_config[module_id][5]); string warn_msg = ircbot.conf.module_config[module_id][6]; bool kick = Convert.ToBoolean(ircbot.conf.module_config[module_id][7]); string kick_msg = ircbot.conf.module_config[module_id][8]; bool ban = Convert.ToBoolean(ircbot.conf.module_config[module_id][9]); string ban_msg = ircbot.conf.module_config[module_id][10]; if (type.Equals("channel")) { bool nick_found = false; int cur_lines = 0; int index = 0; foreach (spam_check spam_log in spam_logs) { if (spam_log.channel.Equals(channel) && spam_log.nick.Equals(nick)) { nick_found = true; cur_lines = spam_log.lines; break; } index++; } if (cur_lines >= max_lines) { if (warn) { ircbot.sendData("PRIVMSG", channel + " :" + warn_msg); } if (ban) { string target_host = ircbot.get_user_host(nick); string tmp_ban = "*!*@" + target_host; if (target_host.Equals("")) { tmp_ban = nick + "!*@*"; } ircbot.sendData("MODE", line[2] + " +b " + tmp_ban + " :" + ban_msg); } if (kick) { ircbot.sendData("KICK", channel + " " + nick + " :" + kick_msg); } spam_logs[index].timer.Enabled = false; spam_logs.RemoveAt(index); } else { if (nick_found) { spam_logs[index].lines++; } else { spam_check tmp_spam = new spam_check(); tmp_spam.channel = channel; tmp_spam.nick = nick; tmp_spam.lines = 1; Timer tmp_timer = new Timer(); tmp_timer.Interval = check_timeout; tmp_timer.Elapsed += (sender, e) => spam_tick(sender, e, channel, nick); tmp_timer.Enabled = true; tmp_timer.AutoReset = false; tmp_spam.timer = tmp_timer; spam_logs.Add(tmp_spam); } } } }
public override void control(bot ircbot, ref IRCConfig conf, int module_id, string[] line, string command, int nick_access, string nick, string channel, bool bot_command, string type) { string module_name = ircbot.conf.module_config[module_id][0]; if (type.Equals("channel") || type.Equals("query") && bot_command == true) { foreach (List <string> tmp_command in conf.command_list) { if (module_name.Equals(tmp_command[0])) { string[] triggers = tmp_command[3].Split('|'); int command_access = Convert.ToInt32(tmp_command[5]); string[] blacklist = tmp_command[6].Split(','); bool blocked = false; bool cmd_found = false; bool spam_check = Convert.ToBoolean(tmp_command[8]); foreach (string bl_chan in blacklist) { if (bl_chan.Equals(channel)) { blocked = true; break; } } if (spam_check == true) { blocked = ircbot.get_spam_status(channel, nick); } foreach (string trigger in triggers) { if (trigger.Equals(command)) { cmd_found = true; break; } } if (blocked == true && cmd_found == true) { ircbot.sendData("NOTICE", nick + " :I am currently too busy to process that."); } if (blocked == false && cmd_found == true) { foreach (string trigger in triggers) { switch (trigger) { case "addresponse": if (spam_check == true) { ircbot.add_spam_count(channel); } if (nick_access >= command_access) { if (line.GetUpperBound(0) > 3) { string list_file = ircbot.cur_dir + Path.DirectorySeparatorChar + "modules" + Path.DirectorySeparatorChar + "Response" + Path.DirectorySeparatorChar + "dictionary.txt"; if (Directory.Exists(ircbot.cur_dir + Path.DirectorySeparatorChar + "modules" + Path.DirectorySeparatorChar + "Response" + Path.DirectorySeparatorChar + "") == false) { Directory.CreateDirectory(ircbot.cur_dir + Path.DirectorySeparatorChar + "modules" + Path.DirectorySeparatorChar + "Response"); } if (File.Exists(ircbot.cur_dir + Path.DirectorySeparatorChar + "modules" + Path.DirectorySeparatorChar + "Response" + Path.DirectorySeparatorChar + "dictionary.txt")) { StreamWriter log = File.AppendText(ircbot.cur_dir + Path.DirectorySeparatorChar + "modules" + Path.DirectorySeparatorChar + "Response" + Path.DirectorySeparatorChar + "dictionary.txt"); log.WriteLine(line[4]); log.Close(); } else { StreamWriter log_file = File.CreateText(ircbot.cur_dir + Path.DirectorySeparatorChar + "modules" + Path.DirectorySeparatorChar + "Response" + Path.DirectorySeparatorChar + "dictionary.txt"); log_file.WriteLine(line[4]); log_file.Close(); } ircbot.sendData("PRIVMSG", channel + " :Response added successfully"); } else { ircbot.sendData("NOTICE", nick + " :" + nick + ", you need to include more info."); } } else { ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command."); } break; } } } } } } if (type.Equals("channel") && bot_command == false) { if (nick != conf.nick) { try { string[] file; string list_file = ircbot.cur_dir + Path.DirectorySeparatorChar + "modules" + Path.DirectorySeparatorChar + "Response" + Path.DirectorySeparatorChar + "dictionary.txt"; if (File.Exists(list_file)) { file = System.IO.File.ReadAllLines(list_file); } else { file = null; } string tmp_line = line[3]; if (line.GetUpperBound(0) > 3) { tmp_line += " " + line[4]; } tmp_line = tmp_line.Remove(0, 1); string new_line = tmp_line.ToLowerInvariant(); bool triggered = false; if (file.GetUpperBound(0) >= 0) { foreach (string tmp_new_line in file) { string file_line = tmp_new_line.Replace("<nick>", nick); file_line = file_line.Replace("<me>", conf.nick); char[] split_type = new char[] { ':' }; char[] trigger_split = new char[] { '*' }; char[] triggered_split = new char[] { '&' }; string[] split = file_line.Split(split_type, 2); string[] triggers = split[0].Split('|'); string[] responses = split[1].Split('|'); int index = 0; for (int x = 0; x <= triggers.GetUpperBound(0); x++) { string[] terms = triggers[x].Split(trigger_split, StringSplitOptions.RemoveEmptyEntries); for (int y = 0; y <= terms.GetUpperBound(0); y++) { triggered = false; terms[y] = terms[y].ToLowerInvariant(); if (triggers[x].StartsWith("*") == false && triggers[x].EndsWith("*") == false && terms.GetUpperBound(0) == 0) { if (new_line.Equals(terms[y]) == true) { triggered = true; } else { triggered = false; break; } } else if (triggers[x].StartsWith("*") == false && y == 0) { if (new_line.StartsWith(terms[y]) == true && index <= new_line.IndexOf(terms[y])) { triggered = true; index = new_line.IndexOf(terms[y]); } else { triggered = false; break; } } else if (triggers[x].EndsWith("*") == false && y == terms.GetUpperBound(0)) { if (new_line.EndsWith(terms[y]) == true && index <= new_line.IndexOf(terms[y])) { triggered = true; index = new_line.IndexOf(terms[y]); } else { triggered = false; break; } } else { if (new_line.Contains(terms[y]) == true && index <= new_line.IndexOf(terms[y])) { triggered = true; index = new_line.IndexOf(terms[y]); } else { triggered = false; break; } } } if (triggered == true) { break; } } if (triggered == true) { ircbot.add_spam_count(channel); int number_of_responses = responses.GetUpperBound(0) + 1; Random random = new Random(); index = random.Next(0, number_of_responses); string[] events = responses[index].Split(triggered_split, StringSplitOptions.RemoveEmptyEntries); for (int y = 0; y <= events.GetUpperBound(0); y++) { if (events[y].StartsWith("<action>") == true) { ircbot.sendData("PRIVMSG", channel + " :\u0001ACTION " + events[y].Remove(0, 8) + "\u0001"); } else if (events[y].StartsWith("<delay>") == true) { Thread.Sleep(Convert.ToInt32(events[y].Remove(0, 7))); } else if (events[y].StartsWith("<part>") == true) { ircbot.sendData("PART", channel); } else if (events[y].StartsWith("<join>") == true) { ircbot.sendData("JOIN", channel); } else if (events[y].StartsWith("<kick>") == true) { if (events[y].Length > 6) { ircbot.sendData("KICK", channel + " " + nick + " :" + events[y].Remove(0, 6)); } else { ircbot.sendData("KICK", channel + " " + nick + " :No Reason"); } } else if (events[y].StartsWith("<ban>") == true) { string target_host = ircbot.get_user_host(nick); string ban = "*!*@" + target_host; if (target_host.Equals("was")) { ban = nick + "!*@*"; } if (events[y].Length > 6) { ircbot.sendData("MODE", channel + " +b " + ban + " :" + events[y].Remove(0, 6)); } else { ircbot.sendData("MODE", channel + " +b " + ban + " :No Reason"); } } else if (events[y].StartsWith("<kickban>") == true) { string target_host = ircbot.get_user_host(nick); string ban = "*!*@" + target_host; if (target_host.Equals("was")) { ban = nick + "!*@*"; } if (events[y].Length > 6) { ircbot.sendData("MODE", channel + " +b " + ban + " :" + events[y].Remove(0, 6)); ircbot.sendData("KICK", channel + " " + nick + " :" + events[y].Remove(0, 6)); } else { ircbot.sendData("MODE", channel + " +b " + ban + " :No Reason"); ircbot.sendData("KICK", channel + " " + nick + " :No Reason"); } } else if (events[y].StartsWith("<timeban>") == true) { string[] mod_line = new string[] { conf.nick, "0", channel, ":tb", events[y].Remove(0, 9) }; Modules.moderation mod = new Modules.moderation(); mod.control(ircbot, ref conf, module_id, mod_line, "tb", conf.owner_level, nick, channel, true, "channel"); } else if (events[y].StartsWith("<timekickban>") == true) { string[] mod_line = new string[] { conf.nick, "0", channel, ":tkb", events[y].Remove(0, 13) }; Modules.moderation mod = new Modules.moderation(); mod.control(ircbot, ref conf, module_id, mod_line, "tkb", conf.owner_level, nick, channel, true, "channel"); } else { ircbot.sendData("PRIVMSG", channel + " :" + events[y]); } } break; } } } } catch (Exception ex) { ircbot.sendData("PRIVMSG", channel + " :" + ex.ToString()); } } } }
public override void control(bot ircbot, ref IRCConfig conf, int module_id, string[] line, string command, int nick_access, string nick, string channel, bool bot_command, string type) { string module_name = ircbot.conf.module_config[module_id][0]; if (type.Equals("channel") || type.Equals("query") && bot_command == true) { foreach (List<string> tmp_command in conf.command_list) { if (module_name.Equals(tmp_command[0])) { string[] triggers = tmp_command[3].Split('|'); int command_access = Convert.ToInt32(tmp_command[5]); string[] blacklist = tmp_command[6].Split(','); bool blocked = false; bool cmd_found = false; bool spam_check = Convert.ToBoolean(tmp_command[8]); foreach (string bl_chan in blacklist) { if (bl_chan.Equals(channel)) { blocked = true; break; } } if (spam_check == true) { blocked = ircbot.get_spam_status(channel, nick); } foreach (string trigger in triggers) { if (trigger.Equals(command)) { cmd_found = true; break; } } if (blocked == true && cmd_found == true) { ircbot.sendData("NOTICE", nick + " :I am currently too busy to process that."); } if (blocked == false && cmd_found == true) { foreach (string trigger in triggers) { switch (trigger) { case "addresponse": if (spam_check == true) { ircbot.add_spam_count(channel); } if (nick_access >= command_access) { if (line.GetUpperBound(0) > 3) { string list_file = ircbot.cur_dir + Path.DirectorySeparatorChar + "modules" + Path.DirectorySeparatorChar + "Response" + Path.DirectorySeparatorChar + "dictionary.txt"; if (Directory.Exists(ircbot.cur_dir + Path.DirectorySeparatorChar + "modules" + Path.DirectorySeparatorChar + "Response" + Path.DirectorySeparatorChar + "") == false) { Directory.CreateDirectory(ircbot.cur_dir + Path.DirectorySeparatorChar + "modules" + Path.DirectorySeparatorChar + "Response"); } if (File.Exists(ircbot.cur_dir + Path.DirectorySeparatorChar + "modules" + Path.DirectorySeparatorChar + "Response" + Path.DirectorySeparatorChar + "dictionary.txt")) { StreamWriter log = File.AppendText(ircbot.cur_dir + Path.DirectorySeparatorChar + "modules" + Path.DirectorySeparatorChar + "Response" + Path.DirectorySeparatorChar + "dictionary.txt"); log.WriteLine(line[4]); log.Close(); } else { StreamWriter log_file = File.CreateText(ircbot.cur_dir + Path.DirectorySeparatorChar + "modules" + Path.DirectorySeparatorChar + "Response" + Path.DirectorySeparatorChar + "dictionary.txt"); log_file.WriteLine(line[4]); log_file.Close(); } ircbot.sendData("PRIVMSG", channel + " :Response added successfully"); } else { ircbot.sendData("NOTICE", nick + " :" + nick + ", you need to include more info."); } } else { ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command."); } break; } } } } } } if (type.Equals("channel") && bot_command == false) { if (nick != conf.nick) { try { string[] file; string list_file = ircbot.cur_dir + Path.DirectorySeparatorChar + "modules" + Path.DirectorySeparatorChar + "Response" + Path.DirectorySeparatorChar + "dictionary.txt"; if (File.Exists(list_file)) { file = System.IO.File.ReadAllLines(list_file); } else { file = null; } string tmp_line = line[3]; if (line.GetUpperBound(0) > 3) { tmp_line += " " + line[4]; } tmp_line = tmp_line.Remove(0, 1); string new_line = tmp_line.ToLowerInvariant(); bool triggered = false; if (file.GetUpperBound(0) >= 0) { foreach (string tmp_new_line in file) { string file_line = tmp_new_line.Replace("<nick>", nick); file_line = file_line.Replace("<me>", conf.nick); char[] split_type = new char[] { ':' }; char[] trigger_split = new char[] { '*' }; char[] triggered_split = new char[] { '&' }; string[] split = file_line.Split(split_type, 2); string[] triggers = split[0].Split('|'); string[] responses = split[1].Split('|'); int index = 0; for (int x = 0; x <= triggers.GetUpperBound(0); x++) { string[] terms = triggers[x].Split(trigger_split, StringSplitOptions.RemoveEmptyEntries); for (int y = 0; y <= terms.GetUpperBound(0); y++) { triggered = false; terms[y] = terms[y].ToLowerInvariant(); if (triggers[x].StartsWith("*") == false && triggers[x].EndsWith("*") == false && terms.GetUpperBound(0) == 0) { if (new_line.Equals(terms[y]) == true) { triggered = true; } else { triggered = false; break; } } else if (triggers[x].StartsWith("*") == false && y == 0) { if (new_line.StartsWith(terms[y]) == true && index <= new_line.IndexOf(terms[y])) { triggered = true; index = new_line.IndexOf(terms[y]); } else { triggered = false; break; } } else if (triggers[x].EndsWith("*") == false && y == terms.GetUpperBound(0)) { if (new_line.EndsWith(terms[y]) == true && index <= new_line.IndexOf(terms[y])) { triggered = true; index = new_line.IndexOf(terms[y]); } else { triggered = false; break; } } else { if (new_line.Contains(terms[y]) == true && index <= new_line.IndexOf(terms[y])) { triggered = true; index = new_line.IndexOf(terms[y]); } else { triggered = false; break; } } } if (triggered == true) { break; } } if (triggered == true) { ircbot.add_spam_count(channel); int number_of_responses = responses.GetUpperBound(0) + 1; Random random = new Random(); index = random.Next(0, number_of_responses); string[] events = responses[index].Split(triggered_split, StringSplitOptions.RemoveEmptyEntries); for (int y = 0; y <= events.GetUpperBound(0); y++) { if (events[y].StartsWith("<action>") == true) { ircbot.sendData("PRIVMSG", channel + " :\u0001ACTION " + events[y].Remove(0, 8) + "\u0001"); } else if (events[y].StartsWith("<delay>") == true) { Thread.Sleep(Convert.ToInt32(events[y].Remove(0, 7))); } else if (events[y].StartsWith("<part>") == true) { ircbot.sendData("PART", channel); } else if (events[y].StartsWith("<join>") == true) { ircbot.sendData("JOIN", channel); } else if (events[y].StartsWith("<kick>") == true) { if (events[y].Length > 6) { ircbot.sendData("KICK", channel + " " + nick + " :" + events[y].Remove(0, 6)); } else { ircbot.sendData("KICK", channel + " " + nick + " :No Reason"); } } else if (events[y].StartsWith("<ban>") == true) { string target_host = ircbot.get_user_host(nick); string ban = "*!*@" + target_host; if (target_host.Equals("was")) { ban = nick + "!*@*"; } if (events[y].Length > 6) { ircbot.sendData("MODE", channel + " +b " + ban + " :" + events[y].Remove(0, 6)); } else { ircbot.sendData("MODE", channel + " +b " + ban + " :No Reason"); } } else if (events[y].StartsWith("<kickban>") == true) { string target_host = ircbot.get_user_host(nick); string ban = "*!*@" + target_host; if (target_host.Equals("was")) { ban = nick + "!*@*"; } if (events[y].Length > 6) { ircbot.sendData("MODE", channel + " +b " + ban + " :" + events[y].Remove(0, 6)); ircbot.sendData("KICK", channel + " " + nick + " :" + events[y].Remove(0, 6)); } else { ircbot.sendData("MODE", channel + " +b " + ban + " :No Reason"); ircbot.sendData("KICK", channel + " " + nick + " :No Reason"); } } else if (events[y].StartsWith("<timeban>") == true) { string[] mod_line = new string[] { conf.nick, "0", channel, ":tb", events[y].Remove(0, 9) }; Modules.moderation mod = new Modules.moderation(); mod.control(ircbot, ref conf, module_id, mod_line, "tb", conf.owner_level, nick, channel, true, "channel"); } else if (events[y].StartsWith("<timekickban>") == true) { string[] mod_line = new string[] { conf.nick, "0", channel, ":tkb", events[y].Remove(0, 13) }; Modules.moderation mod = new Modules.moderation(); mod.control(ircbot, ref conf, module_id, mod_line, "tkb", conf.owner_level, nick, channel, true, "channel"); } else { ircbot.sendData("PRIVMSG", channel + " :" + events[y]); } } break; } } } } catch (Exception ex) { ircbot.sendData("PRIVMSG", channel + " :" + ex.ToString()); } } } }
public override void control(bot ircbot, ref IRCConfig conf, int module_id, string[] line, string command, int nick_access, string nick, string channel, bool bot_command, string type) { access access = new access(); char[] charS = new char[] { ' ' }; string module_name = ircbot.conf.module_config[module_id][0]; string disallowed_modes = ircbot.conf.module_config[module_id][3]; if (type.Equals("channel") && bot_command == true) { foreach (List<string> tmp_command in conf.command_list) { if (module_name.Equals(tmp_command[0])) { string[] triggers = tmp_command[3].Split('|'); int command_access = Convert.ToInt32(tmp_command[5]); string[] blacklist = tmp_command[6].Split(','); bool blocked = false; bool cmd_found = false; bool spam_check = Convert.ToBoolean(tmp_command[8]); foreach (string bl_chan in blacklist) { if (bl_chan.Equals(channel)) { blocked = true; break; } } if (spam_check == true) { blocked = ircbot.get_spam_status(channel, nick); } foreach (string trigger in triggers) { if (trigger.Equals(command)) { cmd_found = true; break; } } if (blocked == true && cmd_found == true) { ircbot.sendData("NOTICE", nick + " :I am currently too busy to process that."); } if (blocked == false && cmd_found == true) { foreach (string trigger in triggers) { switch (trigger) { case "founder": if (spam_check == true) { ircbot.add_spam_count(channel); } if (nick_access >= command_access) { if (line.GetUpperBound(0) > 3) { ircbot.sendData("MODE", line[2] + " +q " + line[4].ToLower()); access.set_access_list(line[4].ToLower(), line[2], conf.founder_level.ToString(), ircbot); } else { ircbot.sendData("PRIVMSG", line[2] + " :" + nick + ", you need to include more info."); } } else { ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command."); } break; case "defounder": if (spam_check == true) { ircbot.add_spam_count(channel); } if (nick_access >= command_access) { if (line.GetUpperBound(0) > 3) { ircbot.sendData("MODE", line[2] + " -q " + line[4].ToLower()); access.del_access_list(line[4].ToLower(), line[2], conf.founder_level.ToString(), ircbot); } else { ircbot.sendData("PRIVMSG", line[2] + " :" + nick + ", you need to include more info."); } } else { ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command."); } break; case "sop": if (spam_check == true) { ircbot.add_spam_count(channel); } if (nick_access >= command_access) { if (line.GetUpperBound(0) > 3) { ircbot.sendData("MODE", line[2] + " +a " + line[4].ToLower()); access.set_access_list(line[4].ToLower(), line[2], conf.sop_level.ToString(), ircbot); } else { ircbot.sendData("PRIVMSG", line[2] + " :" + nick + ", you need to include more info."); } } else { ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command."); } break; case "asop": if (spam_check == true) { ircbot.add_spam_count(channel); } if (nick_access >= command_access) { if (line.GetUpperBound(0) > 3) { ircbot.sendData("MODE", line[2] + " +a " + line[4].ToLower()); ircbot.sendData("PRIVMSG", "chanserv :SOP " + line[2] + " add " + line[4].ToLower()); access.set_access_list(line[4].ToLower(), line[2], conf.sop_level.ToString(), ircbot); } else { ircbot.sendData("PRIVMSG", line[2] + " :" + nick + ", you need to include more info."); } } else { ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command."); } break; case "deasop": if (spam_check == true) { ircbot.add_spam_count(channel); } if (nick_access >= command_access) { if (line.GetUpperBound(0) > 3) { ircbot.sendData("MODE", line[2] + " -a " + line[4].ToLower()); ircbot.sendData("PRIVMSG", "chanserv :SOP " + line[2] + " del " + line[4].ToLower()); access.del_access_list(line[4].ToLower(), line[2], conf.sop_level.ToString(), ircbot); } else { ircbot.sendData("PRIVMSG", line[2] + " :" + nick + ", you need to include more info."); } } else { ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command."); } break; case "desop": if (spam_check == true) { ircbot.add_spam_count(channel); } if (nick_access >= command_access) { if (line.GetUpperBound(0) > 3) { ircbot.sendData("MODE", line[2] + " -a " + line[4].ToLower()); access.del_access_list(line[4].ToLower(), line[2], conf.sop_level.ToString(), ircbot); } else { ircbot.sendData("PRIVMSG", line[2] + " :" + nick + ", you need to include more info."); } } else { ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command."); } break; case "op": if (spam_check == true) { ircbot.add_spam_count(channel); } if (nick_access >= command_access) { if (line.GetUpperBound(0) > 3) { ircbot.sendData("MODE", line[2] + " +o " + line[4].ToLower()); access.set_access_list(line[4].ToLower(), line[2], conf.op_level.ToString(), ircbot); } else { ircbot.sendData("PRIVMSG", line[2] + " :" + nick + ", you need to include more info."); } } else { ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command."); } break; case "aop": if (spam_check == true) { ircbot.add_spam_count(channel); } if (nick_access >= command_access) { if (line.GetUpperBound(0) > 3) { ircbot.sendData("MODE", line[2] + " +o " + line[4].ToLower()); ircbot.sendData("PRIVMSG", "chanserv :AOP " + line[2] + " add " + line[4].ToLower()); access.set_access_list(line[4].ToLower(), line[2], conf.op_level.ToString(), ircbot); } else { ircbot.sendData("PRIVMSG", line[2] + " :" + nick + ", you need to include more info."); } } else { ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command."); } break; case "deaop": if (spam_check == true) { ircbot.add_spam_count(channel); } if (nick_access >= command_access) { if (line.GetUpperBound(0) > 3) { ircbot.sendData("MODE", line[2] + " -o " + line[4].ToLower()); ircbot.sendData("PRIVMSG", "chanserv :AOP " + line[2] + " del " + line[4].ToLower()); access.del_access_list(line[4].ToLower(), line[2], conf.op_level.ToString(), ircbot); } else { ircbot.sendData("PRIVMSG", line[2] + " :" + nick + ", you need to include more info."); } } else { ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command."); } break; case "deop": if (spam_check == true) { ircbot.add_spam_count(channel); } if (nick_access >= command_access) { if (line.GetUpperBound(0) > 3) { ircbot.sendData("MODE", line[2] + " -o " + line[4].ToLower()); access.del_access_list(line[4].ToLower(), line[2], conf.op_level.ToString(), ircbot); } else { ircbot.sendData("PRIVMSG", line[2] + " :" + nick + ", you need to include more info."); } } else { ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command."); } break; case "ahop": if (spam_check == true) { ircbot.add_spam_count(channel); } if (nick_access >= command_access) { if (line.GetUpperBound(0) > 3) { ircbot.sendData("MODE", line[2] + " +h " + line[4].ToLower()); ircbot.sendData("PRIVMSG", "chanserv :HOP " + line[2] + " add " + line[4].ToLower()); access.set_access_list(line[4].ToLower(), line[2], conf.hop_level.ToString(), ircbot); } else { ircbot.sendData("PRIVMSG", line[2] + " :" + nick + ", you need to include more info."); } } else { ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command."); } break; case "deahop": if (spam_check == true) { ircbot.add_spam_count(channel); } if (nick_access >= command_access) { if (line.GetUpperBound(0) > 3) { ircbot.sendData("MODE", line[2] + " -h " + line[4].ToLower()); ircbot.sendData("PRIVMSG", "chanserv :HOP " + line[2] + " del " + line[4].ToLower()); access.del_access_list(line[4].ToLower(), line[2], conf.hop_level.ToString(), ircbot); } else { ircbot.sendData("PRIVMSG", line[2] + " :" + nick + ", you need to include more info."); } } else { ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command."); } break; case "hop": if (spam_check == true) { ircbot.add_spam_count(channel); } if (nick_access >= command_access) { if (line.GetUpperBound(0) > 3) { ircbot.sendData("MODE", line[2] + " +h " + line[4].ToLower()); access.set_access_list(line[4].ToLower(), line[2], conf.hop_level.ToString(), ircbot); } else { ircbot.sendData("PRIVMSG", line[2] + " :" + nick + ", you need to include more info."); } } else { ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command."); } break; case "dehop": if (spam_check == true) { ircbot.add_spam_count(channel); } if (nick_access >= command_access) { if (line.GetUpperBound(0) > 3) { ircbot.sendData("MODE", line[2] + " -h " + line[4].ToLower()); access.del_access_list(line[4].ToLower(), line[2], conf.hop_level.ToString(), ircbot); } else { ircbot.sendData("PRIVMSG", line[2] + " :" + nick + ", you need to include more info."); } } else { ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command."); } break; case "avoice": if (spam_check == true) { ircbot.add_spam_count(channel); } if (nick_access >= command_access) { if (line.GetUpperBound(0) > 3) { ircbot.sendData("MODE", line[2] + " +v " + line[4].ToLower()); ircbot.sendData("PRIVMSG", "chanserv :VOP " + line[2] + " add " + line[4].ToLower()); access.set_access_list(line[4].ToLower(), line[2], conf.voice_level.ToString(), ircbot); } else { ircbot.sendData("PRIVMSG", line[2] + " :" + nick + ", you need to include more info."); } } else { ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command."); } break; case "deavoice": if (spam_check == true) { ircbot.add_spam_count(channel); } if (nick_access >= command_access) { if (line.GetUpperBound(0) > 3) { ircbot.sendData("MODE", line[2] + " -v " + line[4].ToLower()); ircbot.sendData("PRIVMSG", "chanserv :VOP " + line[2] + " del " + line[4].ToLower()); access.del_access_list(line[4].ToLower(), line[2], conf.voice_level.ToString(), ircbot); } else { ircbot.sendData("PRIVMSG", line[2] + " :" + nick + ", you need to include more info."); } } else { ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command."); } break; case "voice": if (spam_check == true) { ircbot.add_spam_count(channel); } if (nick_access >= command_access) { if (line.GetUpperBound(0) > 3) { ircbot.sendData("MODE", line[2] + " +v " + line[4].ToLower()); access.set_access_list(line[4].ToLower(), line[2], conf.voice_level.ToString(), ircbot); } else { ircbot.sendData("PRIVMSG", line[2] + " :" + nick + ", you need to include more info."); } } else { ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command."); } break; case "devoice": if (spam_check == true) { ircbot.add_spam_count(channel); } if (nick_access >= command_access) { if (line.GetUpperBound(0) > 3) { ircbot.sendData("MODE", line[2] + " -v " + line[4].ToLower()); access.del_access_list(line[4].ToLower(), line[2], conf.voice_level.ToString(), ircbot); } else { ircbot.sendData("PRIVMSG", line[2] + " :" + nick + ", you need to include more info."); } } else { ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command."); } break; case "mode": if (spam_check == true) { ircbot.add_spam_count(channel); } if (nick_access >= command_access) { if (line.GetUpperBound(0) > 3) { string[] new_line = line[4].Split(charS, 2); char[] arr = new_line[0].ToCharArray(); bool mode_allowed = true; bool positive = true; int mode_index = 0; foreach (char c in arr) { if (!c.Equals('+') && !c.Equals('-')) { char[] modes_disallowed = disallowed_modes.ToCharArray(); foreach (char m in modes_disallowed) { if (m.Equals(c)) { mode_allowed = false; break; } } if (mode_allowed == true) { if (c.Equals('q') || c.Equals('a') || c.Equals('o') || c.Equals('h') || c.Equals('v')) { int mode_access = ircbot.get_access_num(c.ToString(), true); if (nick_access < mode_access) { mode_allowed = false; break; } } } if (mode_allowed) { string leading_cmd = ""; if (positive) { leading_cmd = "+"; } else { leading_cmd = "-"; } bool nick_needed = false; if (new_line.GetUpperBound(0) > 0) { string[] nicks = new_line[1].Split(charS); if (nicks.GetUpperBound(0) >= mode_index) { nick_needed = true; } } if (nick_needed) { string[] nicks = new_line[1].Split(charS); ircbot.sendData("MODE", line[2] + " " + leading_cmd + c.ToString() + " :" + nicks[mode_index]); } else { ircbot.sendData("MODE", line[2] + " " + leading_cmd + c.ToString()); } } mode_index++; } else if (c.Equals('+')) { positive = true; } else if (c.Equals('-')) { positive = false; } } if (!mode_allowed) { ircbot.sendData("PRIVMSG", line[2] + " :You do not have permission to use that command."); } } else { ircbot.sendData("PRIVMSG", line[2] + " :" + nick + ", you need to include more info."); } } else { ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command."); } break; case "topic": if (spam_check == true) { ircbot.add_spam_count(channel); } if (nick_access >= command_access) { if (line.GetUpperBound(0) > 3) { string[] new_line = line[4].Split(charS, 2); if (new_line.GetUpperBound(0) > 0) { ircbot.sendData("TOPIC", line[2] + " :" + new_line[0] + " " + new_line[1]); } else { ircbot.sendData("TOPIC", line[2] + " :" + new_line[0]); } } else { ircbot.sendData("PRIVMSG", line[2] + " :" + nick + ", you need to include more info."); } } else { ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command."); } break; case "invite": if (spam_check == true) { ircbot.add_spam_count(channel); } if (nick_access >= command_access) { if (line.GetUpperBound(0) > 3) { string[] new_line = line[4].ToLower().Split(charS, 2); if (new_line.GetUpperBound(0) > 0) { ircbot.sendData("INVITE", new_line[0] + " " + new_line[1]); } else { ircbot.sendData("INVITE", new_line[0] + " " + line[2]); } } else { ircbot.sendData("PRIVMSG", line[2] + " :" + nick + ", you need to include more info."); } } else { ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command."); } break; case "b": if (spam_check == true) { ircbot.add_spam_count(channel); } if (nick_access >= command_access) { if (line.GetUpperBound(0) > 3) { string[] new_line = line[4].ToLower().Split(charS, 2); string nicks = new_line[0].TrimStart(':'); char[] charSep = new char[] { ',' }; string[] total_nicks = new_line[0].Split(charSep, StringSplitOptions.RemoveEmptyEntries); int sent_nick_access = ircbot.get_user_access(total_nicks[0], line[2]); bool tmp_me = false; for (int y = 0; y <= total_nicks.GetUpperBound(0); y++) { if (total_nicks[y].Equals(conf.name, StringComparison.OrdinalIgnoreCase)) { tmp_me = true; } } if (sent_nick_access == conf.owner_level) { ircbot.sendData("PRIVMSG", line[2] + " :You can't ban my owner!"); } else if (tmp_me == true) { ircbot.sendData("PRIVMSG", line[2] + " :You can't ban me!"); } else { if (nick_access >= sent_nick_access) { string target_host = ircbot.get_user_host(total_nicks[0]); string ban = "*!*@" + target_host; if (target_host.Equals("")) { ban = new_line[0] + "!*@*"; } if (new_line.GetUpperBound(0) > 0) { ircbot.sendData("MODE", line[2] + " +b " + ban + " :" + new_line[1]); } else { ircbot.sendData("MODE", line[2] + " +b " + ban + " :No Reason"); } } else { ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command."); } } } else { ircbot.sendData("PRIVMSG", line[2] + " :" + nick + ", you need to include more info."); } } else { ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command."); } break; case "ub": if (spam_check == true) { ircbot.add_spam_count(channel); } if (nick_access >= command_access) { if (line.GetUpperBound(0) > 3) { string[] new_line = line[4].ToLower().Split(charS, 2); char[] charSep = new char[] { ',' }; string[] total_nicks = new_line[0].Split(charSep, StringSplitOptions.RemoveEmptyEntries); int sent_nick_access = ircbot.get_user_access(total_nicks[0].TrimStart(':'), line[2]); if (nick_access >= sent_nick_access) { string target_host = ircbot.get_user_host(total_nicks[0]); string ban = "*!*@" + target_host; if (target_host.Equals("")) { ban = new_line[0] + "!*@*"; } if (new_line.GetUpperBound(0) > 0) { ircbot.sendData("MODE", line[2] + " -b " + ban + " :" + new_line[1]); } else { ircbot.sendData("MODE", line[2] + " -b " + ban + " :No Reason"); } } else { ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command."); } } else { ircbot.sendData("PRIVMSG", line[2] + " :" + nick + ", you need to include more info."); } } else { ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command."); } break; case "clearban": if (spam_check == true) { ircbot.add_spam_count(channel); } if (nick_access >= command_access) { ircbot.sendData("PRIVMSG", "chanserv :clear " + channel + " bans"); } else { ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command."); } break; case "kb": if (spam_check == true) { ircbot.add_spam_count(channel); } if (nick_access >= command_access) { if (line.GetUpperBound(0) > 3) { string[] new_line = line[4].ToLower().Split(charS, 2); string nicks = new_line[0].TrimStart(':'); char[] charSep = new char[] { ',' }; string[] total_nicks = nicks.Split(charSep, StringSplitOptions.RemoveEmptyEntries); int sent_nick_access = ircbot.get_user_access(total_nicks[0], line[2]); bool tmp_me = false; for (int y = 0; y <= total_nicks.GetUpperBound(0); y++) { if (total_nicks[y].Equals(conf.name, StringComparison.OrdinalIgnoreCase)) { tmp_me = true; } } if (sent_nick_access == conf.owner_level) { ircbot.sendData("PRIVMSG", line[2] + " :You can't kick-ban my owner!"); } else if (tmp_me == true) { ircbot.sendData("PRIVMSG", line[2] + " :You can't kick-ban me!"); } else { if (nick_access >= sent_nick_access) { string target_host = ircbot.get_user_host(total_nicks[0]); string ban = "*!*@" + target_host; if (target_host.Equals("")) { ban = new_line[0] + "!*@*"; } if (new_line.GetUpperBound(0) > 0) { ircbot.sendData("MODE", line[2] + " +b " + ban + " :" + new_line[1]); ircbot.sendData("KICK", line[2] + " " + total_nicks[0] + " :" + new_line[1]); } else { ircbot.sendData("MODE", line[2] + " +b " + ban + " :No Reason"); ircbot.sendData("KICK", line[2] + " " + total_nicks[0] + " :No Reason"); } } else { ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command."); } } } else { ircbot.sendData("PRIVMSG", line[2] + " :" + nick + ", you need to include more info."); } } else { ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command."); } break; case "tb": if (spam_check == true) { ircbot.add_spam_count(channel); } if (nick_access >= command_access) { if (line.GetUpperBound(0) > 3) { string[] new_line = line[4].ToLower().Split(charS, 3, StringSplitOptions.RemoveEmptyEntries); if (new_line.GetUpperBound(0) > 0) { int time = Convert.ToInt32(new_line[0].TrimStart(':')); string nicks = new_line[1]; char[] charSep = new char[] { ',' }; string[] total_nicks = nicks.Split(charSep, StringSplitOptions.RemoveEmptyEntries); string target_host = ircbot.get_user_host(total_nicks[0]); int sent_nick_access = ircbot.get_user_access(total_nicks[0], line[2]); bool tmp_me = false; for (int y = 0; y <= total_nicks.GetUpperBound(0); y++) { if (total_nicks[y].Equals(conf.name, StringComparison.OrdinalIgnoreCase)) { tmp_me = true; } } if (sent_nick_access == conf.owner_level) { ircbot.sendData("PRIVMSG", line[2] + " :You can't ban my owner!"); } else if (tmp_me == true) { ircbot.sendData("PRIVMSG", line[2] + " :You can't ban me!"); } else { if (nick_access >= sent_nick_access) { string ban = "*!*@" + target_host; if (target_host.Equals("")) { ban = total_nicks[0] + "!*@*"; } if (new_line.GetUpperBound(0) > 1) { ircbot.sendData("MODE", line[2] + " +b " + ban + " :" + new_line[2]); } else { ircbot.sendData("MODE", line[2] + " +b " + ban + " :No Reason"); } Timer unban_trigger = new Timer(); unban_trigger.Interval = (Convert.ToInt32(new_line[0]) * 1000); unban_trigger.Enabled = true; unban_trigger.AutoReset = false; unban_trigger.Elapsed += (sender, e) => unban_nick(sender, e, total_nicks[0], target_host, line[2]); unban_triggers.Add(unban_trigger); main = ircbot; } else { ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command."); } } } else { ircbot.sendData("PRIVMSG", line[2] + " :" + nick + ", you need to include more info."); } } else { ircbot.sendData("PRIVMSG", line[2] + " :" + nick + ", you need to include more info."); } } else { ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command."); } break; case "tkb": if (spam_check == true) { ircbot.add_spam_count(channel); } if (nick_access >= command_access) { if (line.GetUpperBound(0) > 3) { string[] new_line = line[4].ToLower().Split(charS, 3, StringSplitOptions.RemoveEmptyEntries); if (new_line.GetUpperBound(0) > 0) { int time = Convert.ToInt32(new_line[0].TrimStart(':')); string nicks = new_line[1]; char[] charSep = new char[] { ',' }; string[] total_nicks = nicks.Split(charSep, StringSplitOptions.RemoveEmptyEntries); int sent_nick_access = ircbot.get_user_access(total_nicks[0], line[2]); string target_host = ircbot.get_user_host(total_nicks[0]); bool tmp_me = false; for (int y = 0; y <= total_nicks.GetUpperBound(0); y++) { if (total_nicks[y].Equals(conf.name, StringComparison.OrdinalIgnoreCase)) { tmp_me = true; } } if (sent_nick_access == conf.owner_level) { ircbot.sendData("PRIVMSG", line[2] + " :You can't kick-ban my owner!"); } else if (tmp_me == true) { ircbot.sendData("PRIVMSG", line[2] + " :You can't kick-ban me!"); } else { if (nick_access >= sent_nick_access) { string ban = "*!*@" + target_host; if (target_host.Equals("")) { ban = new_line[1] + "!*@*"; } if (new_line.GetUpperBound(0) > 1) { ircbot.sendData("MODE", line[2] + " +b " + ban + " :" + new_line[2]); ircbot.sendData("KICK", line[2] + " " + total_nicks[0] + " :" + new_line[2]); } else { ircbot.sendData("MODE", line[2] + " +b " + ban + " :No Reason"); ircbot.sendData("KICK", line[2] + " " + total_nicks[0] + " :No Reason"); } System.Timers.Timer unban_trigger = new System.Timers.Timer(); unban_trigger.Interval = (Convert.ToInt32(new_line[0]) * 1000); unban_trigger.Enabled = true; unban_trigger.AutoReset = false; unban_trigger.Elapsed += (sender, e) => unban_nick(sender, e, total_nicks[0], target_host, line[2]); unban_triggers.Add(unban_trigger); main = ircbot; } else { ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command."); } } } else { ircbot.sendData("PRIVMSG", line[2] + " :" + nick + ", you need to include more info."); } } else { ircbot.sendData("PRIVMSG", line[2] + " :" + nick + ", you need to include more info."); } } else { ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command."); } break; case "ak": if (spam_check == true) { ircbot.add_spam_count(channel); } if (nick_access >= command_access) { if (line.GetUpperBound(0) > 3) { string[] new_line = line[4].ToLower().Split(charS, 2); string nicks = new_line[0].TrimStart(':'); char[] charSep = new char[] { ',' }; string[] total_nicks = nicks.Split(charSep, StringSplitOptions.RemoveEmptyEntries); int sent_nick_access = ircbot.get_user_access(total_nicks[0], line[2]); bool tmp_me = false; for (int y = 0; y <= total_nicks.GetUpperBound(0); y++) { if (total_nicks[y].Equals(conf.name, StringComparison.OrdinalIgnoreCase)) { tmp_me = true; } } if (sent_nick_access == conf.owner_level) { ircbot.sendData("PRIVMSG", line[2] + " :You can't kick my owner!"); } else if (tmp_me == true) { ircbot.sendData("PRIVMSG", line[2] + " :You can't kick me!"); } else { if (nick_access >= sent_nick_access) { string target_host = ircbot.get_user_host(total_nicks[0]); if (new_line.GetUpperBound(0) > 0) { add_auto(total_nicks[0], line[2], target_host, "k", new_line[1], ircbot); } else { add_auto(total_nicks[0], line[2], target_host, "k", "No Reason", ircbot); } } else { ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command."); } } } else { ircbot.sendData("PRIVMSG", line[2] + " :" + nick + ", you need to include more info."); } } else { ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command."); } break; case "ab": if (spam_check == true) { ircbot.add_spam_count(channel); } if (nick_access >= command_access) { if (line.GetUpperBound(0) > 3) { string[] new_line = line[4].ToLower().Split(charS, 2); string target_host = ircbot.get_user_host(new_line[0]); string nicks = new_line[0].TrimStart(':'); char[] charSep = new char[] { ',' }; string[] total_nicks = nicks.Split(charSep, StringSplitOptions.RemoveEmptyEntries); int sent_nick_access = ircbot.get_user_access(total_nicks[0], line[2]); bool tmp_me = false; for (int y = 0; y <= total_nicks.GetUpperBound(0); y++) { if (total_nicks[y].Equals(conf.name, StringComparison.OrdinalIgnoreCase)) { tmp_me = true; } } if (sent_nick_access == conf.owner_level) { ircbot.sendData("PRIVMSG", line[2] + " :You can't ban my owner!"); } else if (tmp_me == true) { ircbot.sendData("PRIVMSG", line[2] + " :You can't ban me!"); } else { if (nick_access >= sent_nick_access) { if (new_line.GetUpperBound(0) > 0) { add_auto(total_nicks[0], line[2], target_host, "b", new_line[1], ircbot); } else { add_auto(total_nicks[0], line[2], target_host, "b", "No Reason", ircbot); } } else { ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command."); } } } else { ircbot.sendData("PRIVMSG", line[2] + " :" + nick + ", you need to include more info."); } } else { ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command."); } break; case "akb": if (spam_check == true) { ircbot.add_spam_count(channel); } if (nick_access >= command_access) { if (line.GetUpperBound(0) > 3) { string[] new_line = line[4].ToLower().Split(charS, 2); string target_host = ircbot.get_user_host(new_line[0]); string nicks = new_line[0].TrimStart(':'); char[] charSep = new char[] { ',' }; string[] total_nicks = nicks.Split(charSep, StringSplitOptions.RemoveEmptyEntries); int sent_nick_access = ircbot.get_user_access(total_nicks[0], line[2]); bool tmp_me = false; for (int y = 0; y <= total_nicks.GetUpperBound(0); y++) { if (total_nicks[y].Equals(conf.name, StringComparison.OrdinalIgnoreCase)) { tmp_me = true; } } if (sent_nick_access == conf.owner_level) { ircbot.sendData("PRIVMSG", line[2] + " :You can't kick-ban my owner!"); } else if (tmp_me == true) { ircbot.sendData("PRIVMSG", line[2] + " :You can't kick-ban me!"); } else { if (nick_access >= sent_nick_access) { if (new_line.GetUpperBound(0) > 0) { add_auto(total_nicks[0], line[2], target_host, "kb", new_line[1], ircbot); } else { add_auto(total_nicks[0], line[2], target_host, "kb", "No Reason", ircbot); } } else { ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command."); } } } else { ircbot.sendData("PRIVMSG", line[2] + " :" + nick + ", you need to include more info."); } } else { ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command."); } break; case "deak": if (spam_check == true) { ircbot.add_spam_count(channel); } if (nick_access >= command_access) { if (line.GetUpperBound(0) > 3) { string target_host = ircbot.get_user_host(line[4].ToLower()); del_auto(line[4].ToLower(), line[2], target_host, "k", ircbot); } else { ircbot.sendData("PRIVMSG", line[2] + " :" + nick + ", you need to include more info."); } } else { ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command."); } break; case "deab": if (spam_check == true) { ircbot.add_spam_count(channel); } if (nick_access >= command_access) { if (line.GetUpperBound(0) > 3) { string target_host = ircbot.get_user_host(line[4].ToLower()); del_auto(line[4].ToLower(), line[2], target_host, "b", ircbot); } else { ircbot.sendData("PRIVMSG", line[2] + " :" + nick + ", you need to include more info."); } } else { ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command."); } break; case "deakb": if (spam_check == true) { ircbot.add_spam_count(channel); } if (nick_access >= command_access) { if (line.GetUpperBound(0) > 3) { string target_host = ircbot.get_user_host(line[4].ToLower()); del_auto(line[4].ToLower(), line[2], target_host, "kb", ircbot); } else { ircbot.sendData("PRIVMSG", line[2] + " :" + nick + ", you need to include more info."); } } else { ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command."); } break; case "k": if (spam_check == true) { ircbot.add_spam_count(channel); } if (nick_access >= command_access) { if (line.GetUpperBound(0) > 3) { string[] new_line = line[4].ToLower().Split(charS, 2); string nicks = new_line[0].TrimStart(':'); char[] charSep = new char[] { ',' }; string[] total_nicks = nicks.Split(charSep, StringSplitOptions.RemoveEmptyEntries); int sent_nick_access = ircbot.get_user_access(total_nicks[0], line[2]); bool tmp_me = false; for (int y = 0; y <= total_nicks.GetUpperBound(0); y++) { if (total_nicks[y].Equals(conf.name, StringComparison.OrdinalIgnoreCase)) { tmp_me = true; } } if (sent_nick_access == conf.owner_level) { ircbot.sendData("PRIVMSG", line[2] + " :You can't kick my owner!"); } else if (tmp_me == true) { ircbot.sendData("PRIVMSG", line[2] + " :You can't kick me!"); } else { if (nick_access >= sent_nick_access) { if (new_line.GetUpperBound(0) > 0) { ircbot.sendData("KICK", line[2] + " " + total_nicks[0] + " :" + new_line[1]); } else { ircbot.sendData("KICK", line[2] + " " + total_nicks[0] + " :No Reason"); } } else { ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command."); } } } else { ircbot.sendData("PRIVMSG", line[2] + " :" + nick + ", you need to include more info."); } } else { ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command."); } break; case "kme": if (spam_check == true) { ircbot.add_spam_count(channel); } if (nick_access >= command_access) { if (line.GetUpperBound(0) > 3) { ircbot.sendData("KICK", line[2] + " " + nick + " :" + line[4]); } else { ircbot.sendData("KICK", line[2] + " " + nick + " :No Reason"); } } break; } } } } } } if (type.Equals("join")) { string[] user_info = line[0].Split('@'); string nick_host = user_info[1]; check_auto(nick, channel.TrimStart(':'), nick_host, ircbot); } }
public override void control(bot ircbot, ref IRCConfig conf, int module_id, string[] line, string command, int nick_access, string nick, string channel, bool bot_command, string type) { string module_name = ircbot.conf.module_config[module_id][0]; if ((type.Equals("channel") || type.Equals("query")) && bot_command == true) { foreach (List<string> tmp_command in conf.command_list) { if (module_name.Equals(tmp_command[0])) { string[] triggers = tmp_command[3].Split('|'); int command_access = Convert.ToInt32(tmp_command[5]); string[] blacklist = tmp_command[6].Split(','); bool blocked = false; bool cmd_found = false; bool spam_check = Convert.ToBoolean(tmp_command[8]); foreach (string bl_chan in blacklist) { if (bl_chan.Equals(channel)) { blocked = true; break; } } if (spam_check == true) { blocked = ircbot.get_spam_status(channel, nick); } foreach (string trigger in triggers) { if (trigger.Equals(command)) { cmd_found = true; break; } } if (blocked == true && cmd_found == true) { ircbot.sendData("NOTICE", nick + " :I am currently too busy to process that."); } if (blocked == false && cmd_found == true) { foreach (string trigger in triggers) { switch (trigger) { case "poll": if (spam_check == true) { ircbot.add_spam_count(channel); } if (nick_access >= command_access) { bool poll_active = false; foreach (poll_info tmp_poll in poll_list) { if (tmp_poll.channel.Equals(channel)) { poll_active = true; break; } } if (poll_active == false) { if (line.GetUpperBound(0) > 3) { poll_info temp_poll = new poll_info(); poll_active = true; string[] lines = line[4].Split('|'); temp_poll.question = lines[0]; temp_poll.owner = nick; temp_poll.channel = channel; temp_poll.answers = new List<List<string>>(); temp_poll.nick_responses = new List<List<string>>(); for (int x = 1; x <= lines.GetUpperBound(0); x++) { List<string> tmp_list = new List<string>(); tmp_list.Add(lines[x]); tmp_list.Add("0"); temp_poll.answers.Add(tmp_list); } ircbot.sendData("PRIVMSG", channel + " :Poll has been started by " + temp_poll.owner + ": " + temp_poll.question); for (int x = 0; x < temp_poll.answers.Count(); x++) { ircbot.sendData("PRIVMSG", channel + " :" + (x + 1).ToString() + ") " + temp_poll.answers[x][0]); } ircbot.sendData("PRIVMSG", channel + " :To Vote, type " + conf.command + "vote <answer_number>. You may only vote once per poll. You can change your vote by voting for a different answer."); poll_list.Add(temp_poll); } else { ircbot.sendData("PRIVMSG", line[2] + " :" + nick + ", you need to include more info."); } } else { ircbot.sendData("PRIVMSG", channel + " :There is currently a poll active right now. To view the current results, type " + conf.command + "results"); } } else { ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command."); } break; case "addanswer": if (spam_check == true) { ircbot.add_spam_count(channel); } if (nick_access >= command_access) { bool poll_active = false; poll_info cur_poll = new poll_info(); foreach (poll_info tmp_poll in poll_list) { if (tmp_poll.channel.Equals(channel)) { cur_poll = tmp_poll; poll_active = true; break; } } if (poll_active == true) { if (cur_poll.owner.Equals(nick)) { if (line.GetUpperBound(0) > 3) { List<string> tmp_list = new List<string>(); tmp_list.Add(line[4]); tmp_list.Add("0"); cur_poll.answers.Add(tmp_list); ircbot.sendData("PRIVMSG", channel + " :An Answer has been added to the poll."); ircbot.sendData("PRIVMSG", channel + " :" + cur_poll.answers.Count().ToString() + ")" + line[4]); } else { ircbot.sendData("PRIVMSG", line[2] + " :" + nick + ", you need to include more info."); } } else { ircbot.sendData("PRIVMSG", channel + " :You are not the poll owner."); } } else { ircbot.sendData("PRIVMSG", channel + " :There is currently no poll active right now"); } } else { ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command."); } break; case "delanswer": if (spam_check == true) { ircbot.add_spam_count(channel); } if (nick_access >= command_access) { bool poll_active = false; poll_info cur_poll = new poll_info(); foreach (poll_info tmp_poll in poll_list) { if (tmp_poll.channel.Equals(channel)) { cur_poll = tmp_poll; poll_active = true; break; } } if (poll_active == true) { if (cur_poll.owner.Equals(nick)) { if (line.GetUpperBound(0) > 3) { for (int x = 0; x < cur_poll.answers.Count(); x++) { if (x == Convert.ToInt32(line[4])) { ircbot.sendData("PRIVMSG", channel + " :Answer " + x.ToString() + " has been removed."); cur_poll.answers.RemoveAt(x); break; } } } else { ircbot.sendData("PRIVMSG", line[2] + " :" + nick + ", you need to include more info."); } } else { ircbot.sendData("PRIVMSG", channel + " :You are not the poll owner."); } } else { ircbot.sendData("PRIVMSG", channel + " :There is currently no poll active right now"); } } else { ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command."); } break; case "stoppoll": if (spam_check == true) { ircbot.add_spam_count(channel); } if (nick_access >= command_access) { bool poll_active = false; int index = 0; poll_info cur_poll = new poll_info(); foreach (poll_info tmp_poll in poll_list) { if (tmp_poll.channel.Equals(channel)) { cur_poll = tmp_poll; poll_active = true; break; } index++; } if (poll_active == true) { if (cur_poll.owner.Equals(nick) || nick_access > Convert.ToInt32(ircbot.get_user_access(cur_poll.owner, channel))) { poll_active = false; ircbot.sendData("PRIVMSG", channel + " :Results of poll by " + cur_poll.owner + ": " + cur_poll.question); for (int x = 0; x < cur_poll.answers.Count(); x++) { ircbot.sendData("PRIVMSG", channel + " :" + (x + 1).ToString() + ") " + cur_poll.answers[x][0] + " | " + cur_poll.answers[x][1] + " votes"); } poll_list.RemoveAt(index); } else { ircbot.sendData("PRIVMSG", channel + " :You are not the poll owner."); } } else { ircbot.sendData("PRIVMSG", channel + " :There is currently no poll active right now"); } } else { ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command."); } break; case "results": if (spam_check == true) { ircbot.add_spam_count(channel); } if (nick_access >= command_access) { bool poll_active = false; poll_info cur_poll = new poll_info(); foreach (poll_info tmp_poll in poll_list) { if (tmp_poll.channel.Equals(channel)) { cur_poll = tmp_poll; poll_active = true; break; } } if (poll_active == true) { ircbot.sendData("NOTICE", nick + " :Poll by " + cur_poll.owner + ": " + cur_poll.question); for (int x = 0; x < cur_poll.answers.Count(); x++) { ircbot.sendData("NOTICE", nick + " :" + (x + 1).ToString() + ") " + cur_poll.answers[x][0] + " | " + cur_poll.answers[x][1] + " votes"); } ircbot.sendData("NOTICE", nick + " :To Vote, type .vote <answer_number>. You may only vote once per poll. You can change your vote by voting for a different answer."); } else { ircbot.sendData("NOTICE", nick + " :There is currently no poll active right now"); } } else { ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command."); } break; case "vote": if (spam_check == true) { ircbot.add_spam_count(channel); } if (nick_access >= command_access) { if (line.GetUpperBound(0) > 3) { bool poll_active = false; poll_info cur_poll = new poll_info(); foreach (poll_info tmp_poll in poll_list) { if (tmp_poll.channel.Equals(channel)) { cur_poll = tmp_poll; poll_active = true; break; } } if (poll_active == true) { try { int vote = Convert.ToInt32(line[4]); if (vote > 0 && vote <= cur_poll.answers.Count()) { bool nick_voted = false; int index = 0; string nick_host = ircbot.get_user_host(nick); if (nick_host.Equals("")) { nick_host = nick; } for (int x = 0; x < cur_poll.nick_responses.Count(); x++) { if (cur_poll.nick_responses[x][0].Equals(nick_host)) { nick_voted = true; index = Convert.ToInt32(cur_poll.nick_responses[x][1]); cur_poll.nick_responses[x][1] = vote.ToString(); cur_poll.answers[index - 1][1] = (Convert.ToInt32(cur_poll.answers[index - 1][1]) - 1).ToString(); cur_poll.answers[vote - 1][1] = (Convert.ToInt32(cur_poll.answers[vote - 1][1]) + 1).ToString(); break; } } if (nick_voted == false) { List<string> tmp_list = new List<string>(); tmp_list.Add(nick_host); tmp_list.Add(vote.ToString()); cur_poll.nick_responses.Add(tmp_list); cur_poll.answers[vote - 1][1] = (Convert.ToInt32(cur_poll.answers[vote - 1][1]) + 1).ToString(); } ircbot.sendData("PRIVMSG", channel + " :Thank you for voting for " + vote.ToString()); } else { ircbot.sendData("PRIVMSG", channel + " :You need to vote for a valid answer."); } } catch { ircbot.sendData("PRIVMSG", channel + " :You need to vote for a valid answer."); } } else { ircbot.sendData("PRIVMSG", channel + " :There is currently no poll active right now"); } } else { ircbot.sendData("PRIVMSG", line[2] + " :" + nick + ", you need to include more info."); } } else { ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command."); } break; } } } } } } }
public override void control(bot ircbot, ref IRCConfig conf, int module_id, string[] line, string command, int nick_access, string nick, string channel, bool bot_command, string type) { string module_name = ircbot.conf.module_config[module_id][0]; if ((type.Equals("channel") || type.Equals("query")) && bot_command == true) { foreach (List <string> tmp_command in conf.command_list) { if (module_name.Equals(tmp_command[0])) { string[] triggers = tmp_command[3].Split('|'); int command_access = Convert.ToInt32(tmp_command[5]); string[] blacklist = tmp_command[6].Split(','); bool blocked = false; bool cmd_found = false; bool spam_check = Convert.ToBoolean(tmp_command[8]); foreach (string bl_chan in blacklist) { if (bl_chan.Equals(channel)) { blocked = true; break; } } if (spam_check == true) { blocked = ircbot.get_spam_status(channel, nick); } foreach (string trigger in triggers) { if (trigger.Equals(command)) { cmd_found = true; break; } } if (blocked == true && cmd_found == true) { ircbot.sendData("NOTICE", nick + " :I am currently too busy to process that."); } if (blocked == false && cmd_found == true) { foreach (string trigger in triggers) { switch (trigger) { case "poll": if (spam_check == true) { ircbot.add_spam_count(channel); } if (nick_access >= command_access) { bool poll_active = false; foreach (poll_info tmp_poll in poll_list) { if (tmp_poll.channel.Equals(channel)) { poll_active = true; break; } } if (poll_active == false) { if (line.GetUpperBound(0) > 3) { poll_info temp_poll = new poll_info(); poll_active = true; string[] lines = line[4].Split('|'); temp_poll.question = lines[0]; temp_poll.owner = nick; temp_poll.channel = channel; temp_poll.answers = new List <List <string> >(); temp_poll.nick_responses = new List <List <string> >(); for (int x = 1; x <= lines.GetUpperBound(0); x++) { List <string> tmp_list = new List <string>(); tmp_list.Add(lines[x]); tmp_list.Add("0"); temp_poll.answers.Add(tmp_list); } ircbot.sendData("PRIVMSG", channel + " :Poll has been started by " + temp_poll.owner + ": " + temp_poll.question); for (int x = 0; x < temp_poll.answers.Count(); x++) { ircbot.sendData("PRIVMSG", channel + " :" + (x + 1).ToString() + ") " + temp_poll.answers[x][0]); } ircbot.sendData("PRIVMSG", channel + " :To Vote, type " + conf.command + "vote <answer_number>. You may only vote once per poll. You can change your vote by voting for a different answer."); poll_list.Add(temp_poll); } else { ircbot.sendData("PRIVMSG", line[2] + " :" + nick + ", you need to include more info."); } } else { ircbot.sendData("PRIVMSG", channel + " :There is currently a poll active right now. To view the current results, type " + conf.command + "results"); } } else { ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command."); } break; case "addanswer": if (spam_check == true) { ircbot.add_spam_count(channel); } if (nick_access >= command_access) { bool poll_active = false; poll_info cur_poll = new poll_info(); foreach (poll_info tmp_poll in poll_list) { if (tmp_poll.channel.Equals(channel)) { cur_poll = tmp_poll; poll_active = true; break; } } if (poll_active == true) { if (cur_poll.owner.Equals(nick)) { if (line.GetUpperBound(0) > 3) { List <string> tmp_list = new List <string>(); tmp_list.Add(line[4]); tmp_list.Add("0"); cur_poll.answers.Add(tmp_list); ircbot.sendData("PRIVMSG", channel + " :An Answer has been added to the poll."); ircbot.sendData("PRIVMSG", channel + " :" + cur_poll.answers.Count().ToString() + ")" + line[4]); } else { ircbot.sendData("PRIVMSG", line[2] + " :" + nick + ", you need to include more info."); } } else { ircbot.sendData("PRIVMSG", channel + " :You are not the poll owner."); } } else { ircbot.sendData("PRIVMSG", channel + " :There is currently no poll active right now"); } } else { ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command."); } break; case "delanswer": if (spam_check == true) { ircbot.add_spam_count(channel); } if (nick_access >= command_access) { bool poll_active = false; poll_info cur_poll = new poll_info(); foreach (poll_info tmp_poll in poll_list) { if (tmp_poll.channel.Equals(channel)) { cur_poll = tmp_poll; poll_active = true; break; } } if (poll_active == true) { if (cur_poll.owner.Equals(nick)) { if (line.GetUpperBound(0) > 3) { for (int x = 0; x < cur_poll.answers.Count(); x++) { if (x == Convert.ToInt32(line[4])) { ircbot.sendData("PRIVMSG", channel + " :Answer " + x.ToString() + " has been removed."); cur_poll.answers.RemoveAt(x); break; } } } else { ircbot.sendData("PRIVMSG", line[2] + " :" + nick + ", you need to include more info."); } } else { ircbot.sendData("PRIVMSG", channel + " :You are not the poll owner."); } } else { ircbot.sendData("PRIVMSG", channel + " :There is currently no poll active right now"); } } else { ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command."); } break; case "stoppoll": if (spam_check == true) { ircbot.add_spam_count(channel); } if (nick_access >= command_access) { bool poll_active = false; int index = 0; poll_info cur_poll = new poll_info(); foreach (poll_info tmp_poll in poll_list) { if (tmp_poll.channel.Equals(channel)) { cur_poll = tmp_poll; poll_active = true; break; } index++; } if (poll_active == true) { if (cur_poll.owner.Equals(nick) || nick_access > Convert.ToInt32(ircbot.get_user_access(cur_poll.owner, channel))) { poll_active = false; ircbot.sendData("PRIVMSG", channel + " :Results of poll by " + cur_poll.owner + ": " + cur_poll.question); for (int x = 0; x < cur_poll.answers.Count(); x++) { ircbot.sendData("PRIVMSG", channel + " :" + (x + 1).ToString() + ") " + cur_poll.answers[x][0] + " | " + cur_poll.answers[x][1] + " votes"); } poll_list.RemoveAt(index); } else { ircbot.sendData("PRIVMSG", channel + " :You are not the poll owner."); } } else { ircbot.sendData("PRIVMSG", channel + " :There is currently no poll active right now"); } } else { ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command."); } break; case "results": if (spam_check == true) { ircbot.add_spam_count(channel); } if (nick_access >= command_access) { bool poll_active = false; poll_info cur_poll = new poll_info(); foreach (poll_info tmp_poll in poll_list) { if (tmp_poll.channel.Equals(channel)) { cur_poll = tmp_poll; poll_active = true; break; } } if (poll_active == true) { ircbot.sendData("NOTICE", nick + " :Poll by " + cur_poll.owner + ": " + cur_poll.question); for (int x = 0; x < cur_poll.answers.Count(); x++) { ircbot.sendData("NOTICE", nick + " :" + (x + 1).ToString() + ") " + cur_poll.answers[x][0] + " | " + cur_poll.answers[x][1] + " votes"); } ircbot.sendData("NOTICE", nick + " :To Vote, type .vote <answer_number>. You may only vote once per poll. You can change your vote by voting for a different answer."); } else { ircbot.sendData("NOTICE", nick + " :There is currently no poll active right now"); } } else { ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command."); } break; case "vote": if (spam_check == true) { ircbot.add_spam_count(channel); } if (nick_access >= command_access) { if (line.GetUpperBound(0) > 3) { bool poll_active = false; poll_info cur_poll = new poll_info(); foreach (poll_info tmp_poll in poll_list) { if (tmp_poll.channel.Equals(channel)) { cur_poll = tmp_poll; poll_active = true; break; } } if (poll_active == true) { try { int vote = Convert.ToInt32(line[4]); if (vote > 0 && vote <= cur_poll.answers.Count()) { bool nick_voted = false; int index = 0; string nick_host = ircbot.get_user_host(nick); if (nick_host.Equals("")) { nick_host = nick; } for (int x = 0; x < cur_poll.nick_responses.Count(); x++) { if (cur_poll.nick_responses[x][0].Equals(nick_host)) { nick_voted = true; index = Convert.ToInt32(cur_poll.nick_responses[x][1]); cur_poll.nick_responses[x][1] = vote.ToString(); cur_poll.answers[index - 1][1] = (Convert.ToInt32(cur_poll.answers[index - 1][1]) - 1).ToString(); cur_poll.answers[vote - 1][1] = (Convert.ToInt32(cur_poll.answers[vote - 1][1]) + 1).ToString(); break; } } if (nick_voted == false) { List <string> tmp_list = new List <string>(); tmp_list.Add(nick_host); tmp_list.Add(vote.ToString()); cur_poll.nick_responses.Add(tmp_list); cur_poll.answers[vote - 1][1] = (Convert.ToInt32(cur_poll.answers[vote - 1][1]) + 1).ToString(); } ircbot.sendData("PRIVMSG", channel + " :Thank you for voting for " + vote.ToString()); } else { ircbot.sendData("PRIVMSG", channel + " :You need to vote for a valid answer."); } } catch { ircbot.sendData("PRIVMSG", channel + " :You need to vote for a valid answer."); } } else { ircbot.sendData("PRIVMSG", channel + " :There is currently no poll active right now"); } } else { ircbot.sendData("PRIVMSG", line[2] + " :" + nick + ", you need to include more info."); } } else { ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command."); } break; } } } } } } }