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") && 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 "hbomb": if (spam_check == true) { ircbot.add_spam_count(channel); } if (nick_access >= command_access) { int module_index = 0; foreach (Modules.Module module in ircbot.module_list) { string module_type = module.GetType().ToString(); if (module_type.Equals("IRCBot.Modules.idle")) { break; } else { module_index++; } } Modules.idle idle; if (module_index < ircbot.module_list.Count()) { idle = (Modules.idle)ircbot.module_list[module_index]; } else { idle = new Modules.idle(); } if (idle.check_idle(nick) == false) { bool hbomb_active = false; hbomb_info tmp_info = new hbomb_info(); foreach (hbomb_info bomb in hbombs) { if (bomb.bomb_channel.Equals(channel)) { tmp_info = bomb; hbomb_active = true; break; } } if (hbomb_active == false) { tmp_info.bomb_locked = false; tmp_info.bomb_trigger = new System.Timers.Timer(); tmp_info.wire_colors = ircbot.conf.module_config[module_id][3].Split(','); tmp_info.bomb_channel = channel; Random random_color = new Random(); int color_index = random_color.Next(0, tmp_info.wire_colors.GetUpperBound(0) + 1); tmp_info.wire_color = tmp_info.wire_colors[color_index]; Random random = new Random(); int index = random.Next(10, 60); tmp_info.bomb_trigger.Elapsed += (System, EventArgs) => activate_bomb(channel); tmp_info.bomb_trigger.Interval = (index * 1000); tmp_info.bomb_trigger.Enabled = true; tmp_info.bomb_trigger.AutoReset = false; main = ircbot; tmp_info.previous_bomb_holder = nick; tmp_info.bomb_holder = nick; ircbot.sendData("PRIVMSG", channel + " :" + nick + " has started the timer! If the bomb gets passed to you, type " + conf.command + "pass <nick> to pass it to someone else, or type " + conf.command + "defuse <color> to try to defuse it."); string colors = ""; foreach (string wire in tmp_info.wire_colors) { colors += wire + ","; } ircbot.sendData("NOTICE", nick + " :You need to hurry and pass the bomb before it blows up! Or you can try to defuse it yourself. The colors are: " + colors.TrimEnd(',')); hbombs.Add(tmp_info); } else { if (tmp_info.bomb_channel.Equals(channel)) { ircbot.sendData("PRIVMSG", channel + " :There is already a bomb counting down."); } else { ircbot.sendData("PRIVMSG", line[2] + " :There is already a bomb counting down in " + tmp_info.bomb_channel + "."); } } } else { ircbot.sendData("PRIVMSG", channel + " :You can not start a HBomb when you are idle."); } } else { ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command."); } break; case "pass": if (spam_check == true) { ircbot.add_spam_count(channel); } if (nick_access >= command_access) { int index = 0; bool hbomb_active = false; hbomb_info tmp_info = new hbomb_info(); foreach (hbomb_info bomb in hbombs) { if (bomb.bomb_channel.Equals(channel)) { tmp_info = bomb; hbomb_active = true; break; } index++; } if (hbomb_active == true) { if (!tmp_info.bomb_locked) { int module_index = 0; foreach (Modules.Module module in ircbot.module_list) { string module_type = module.GetType().ToString(); if (module_type.Equals("IRCBot.Modules.idle")) { break; } else { module_index++; } } Modules.idle idle; if (module_index < ircbot.module_list.Count()) { idle = (Modules.idle)ircbot.module_list[module_index]; } else { idle = new Modules.idle(); } if (idle.check_idle(nick) == false) { if (tmp_info.bomb_holder.Equals(nick)) { if (line.GetUpperBound(0) > 3) { if (line[4].TrimEnd(' ').ToLower().Equals(conf.nick.ToLower())) { ircbot.sendData("PRIVMSG", channel + " :" + nick + ", you can't pass it to me!"); } else { int user_access = ircbot.get_user_access(line[4].TrimEnd(' ').ToLower(), channel); if (user_access > 0 && idle.check_idle(line[4].TrimEnd(' ').ToLower()) == false) { pass_hbomb(line[4].TrimEnd(' ').ToLower(), channel, nick, ircbot, conf, ref tmp_info, index); } else { ircbot.sendData("PRIVMSG", channel + " :" + nick + ", you can't pass to them!"); } } } else { ircbot.sendData("PRIVMSG", channel + " :" + nick + ", you need to pass the bomb to someone."); } } else { ircbot.sendData("PRIVMSG", channel + " :You don't have the bomb!"); } } else { ircbot.sendData("PRIVMSG", channel + " :You can not pass the HBomb when you are idle."); } } else { ircbot.sendData("PRIVMSG", channel + " :You can not pass a locked bomb."); } } else { ircbot.sendData("PRIVMSG", channel + " :There isn't a bomb to pass!"); } } else { ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command."); } break; case "set_bomb": if (spam_check == true) { ircbot.add_spam_count(channel); } if (nick_access >= command_access) { int index = 0; bool hbomb_active = false; hbomb_info tmp_info = new hbomb_info(); foreach (hbomb_info bomb in hbombs) { if (bomb.bomb_channel.Equals(channel)) { tmp_info = bomb; hbomb_active = true; break; } index++; } if (hbomb_active == true) { if (line.GetUpperBound(0) > 3) { if (line[4].TrimEnd(' ').ToLower().Equals(conf.nick.ToLower())) { ircbot.sendData("PRIVMSG", channel + " :" + nick + ", you can't pass it to me!"); } else { int user_access = ircbot.get_user_access(line[4].TrimEnd(' ').ToLower(), channel); if (user_access > 0) { pass_hbomb(line[4].TrimEnd(' ').ToLower(), channel, nick, ircbot, conf, ref tmp_info, index); } else { ircbot.sendData("PRIVMSG", channel + " :" + nick + ", that user isn't online!"); } } } else { ircbot.sendData("PRIVMSG", channel + " :" + nick + ", you need to pass the bomb to someone."); } } else { ircbot.sendData("PRIVMSG", channel + " :There isn't a bomb to pass!"); } } else { ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command."); } break; case "lock_bomb": if (spam_check == true) { ircbot.add_spam_count(channel); } if (nick_access >= command_access) { int index = 0; bool hbomb_active = false; hbomb_info tmp_info = new hbomb_info(); foreach (hbomb_info bomb in hbombs) { if (bomb.bomb_channel.Equals(channel)) { tmp_info = bomb; hbomb_active = true; break; } index++; } if (hbomb_active == true) { if (line.GetUpperBound(0) > 3) { if (line[4].TrimEnd(' ').ToLower().Equals(conf.nick.ToLower())) { ircbot.sendData("PRIVMSG", channel + " :" + nick + ", you can't pass it to me!"); } else { int user_access = ircbot.get_user_access(line[4].TrimEnd(' ').ToLower(), channel); if (user_access > 0) { pass_hbomb(line[4].TrimEnd(' ').ToLower(), channel, nick, ircbot, conf, ref tmp_info, index); tmp_info.bomb_locked = true; } else { ircbot.sendData("PRIVMSG", channel + " :" + nick + ", that user isn't online!"); } } } else { tmp_info.bomb_locked = true; } } else { ircbot.sendData("PRIVMSG", channel + " :There isn't a bomb to lock!"); } } else { ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command."); } break; case "unlock_bomb": if (spam_check == true) { ircbot.add_spam_count(channel); } if (nick_access >= command_access) { int index = 0; bool hbomb_active = false; hbomb_info tmp_info = new hbomb_info(); foreach (hbomb_info bomb in hbombs) { if (bomb.bomb_channel.Equals(channel)) { tmp_info = bomb; hbomb_active = true; break; } index++; } if (hbomb_active == true) { tmp_info.bomb_locked = false; hbombs[index] = tmp_info; } else { ircbot.sendData("PRIVMSG", channel + " :There isn't a bomb to unlock!"); } } else { ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command."); } break; case "detonate": if (spam_check == true) { ircbot.add_spam_count(channel); } if (nick_access >= command_access) { bool hbomb_active = false; foreach (hbomb_info bomb in hbombs) { if (bomb.bomb_channel.Equals(channel)) { hbomb_active = true; break; } } if (hbomb_active == true) { main = ircbot; activate_bomb(channel); } else { ircbot.sendData("PRIVMSG", channel + " :There isn't a bomb to blow up!"); } } else { ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command."); } break; case "stop_bomb": if (spam_check == true) { ircbot.add_spam_count(channel); } if (nick_access >= command_access) { int index = 0; bool hbomb_active = false; hbomb_info tmp_info = new hbomb_info(); foreach (hbomb_info bomb in hbombs) { if (bomb.bomb_channel.Equals(channel)) { tmp_info = bomb; hbomb_active = true; break; } index++; } if (hbomb_active == true) { hbombs.RemoveAt(index); ircbot.sendData("PRIVMSG", channel + " :Bomb has been defused and thrown away."); } else { ircbot.sendData("PRIVMSG", channel + " :There isn't a bomb to stop!"); } } else { ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command."); } break; case "defuse": if (spam_check == true) { ircbot.add_spam_count(channel); } if (nick_access >= command_access) { int index = 0; bool hbomb_active = false; hbomb_info tmp_info = new hbomb_info(); foreach (hbomb_info bomb in hbombs) { if (bomb.bomb_channel.Equals(channel)) { tmp_info = bomb; hbomb_active = true; break; } index++; } if (hbomb_active == true) { if (!tmp_info.bomb_locked) { int module_index = 0; foreach (Modules.Module module in ircbot.module_list) { string module_type = module.GetType().ToString(); if (module_type.Equals("IRCBot.Modules.idle")) { break; } else { module_index++; } } Modules.idle idle; if (module_index < ircbot.module_list.Count()) { idle = (Modules.idle)ircbot.module_list[module_index]; } else { idle = new Modules.idle(); } if (idle.check_idle(nick) == false) { if (tmp_info.bomb_holder.Equals(nick)) { if (line.GetUpperBound(0) > 3) { if (line[4].ToLower().Equals(tmp_info.wire_color.ToLower())) { ircbot.sendData("PRIVMSG", channel + " :You have successfully defused the bomb!"); if (tmp_info.previous_bomb_holder.Equals(tmp_info.bomb_holder)) { } else { ircbot.sendData("KICK", tmp_info.bomb_channel + " " + tmp_info.previous_bomb_holder + " :BOOM!!!"); } hbombs.RemoveAt(index); } else { main = ircbot; activate_bomb(channel); } } else { ircbot.sendData("PRIVMSG", channel + " :" + nick + ", you need to cut a wire."); } } else { ircbot.sendData("PRIVMSG", channel + " :You don't have the bomb!"); } } else { ircbot.sendData("PRIVMSG", channel + " :You can not defuse the HBomb when you are idle."); } } else { ircbot.sendData("PRIVMSG", channel + " :You can not defuse the HBomb when it is locked."); } } else { ircbot.sendData("PRIVMSG", channel + " :There isn't a bomb to defuse!"); } } 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") && 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 "hbomb": if (spam_check == true) { ircbot.add_spam_count(channel); } if (nick_access >= command_access) { int module_index = 0; foreach (Modules.Module module in ircbot.module_list) { string module_type = module.GetType().ToString(); if (module_type.Equals("IRCBot.Modules.idle")) { break; } else { module_index++; } } Modules.idle idle; if (module_index < ircbot.module_list.Count()) { idle = (Modules.idle)ircbot.module_list[module_index]; } else { idle = new Modules.idle(); } if (idle.check_idle(nick) == false) { bool hbomb_active = false; hbomb_info tmp_info = new hbomb_info(); foreach (hbomb_info bomb in hbombs) { if (bomb.bomb_channel.Equals(channel)) { tmp_info = bomb; hbomb_active = true; break; } } if (hbomb_active == false) { tmp_info.bomb_locked = false; tmp_info.bomb_trigger = new System.Timers.Timer(); tmp_info.wire_colors = ircbot.conf.module_config[module_id][3].Split(','); tmp_info.bomb_channel = channel; Random random_color = new Random(); int color_index = random_color.Next(0, tmp_info.wire_colors.GetUpperBound(0) + 1); tmp_info.wire_color = tmp_info.wire_colors[color_index]; Random random = new Random(); int index = random.Next(10, 60); tmp_info.bomb_trigger.Elapsed += (System, EventArgs) => activate_bomb(channel); tmp_info.bomb_trigger.Interval = (index * 1000); tmp_info.bomb_trigger.Enabled = true; tmp_info.bomb_trigger.AutoReset = false; main = ircbot; tmp_info.previous_bomb_holder = nick; tmp_info.bomb_holder = nick; ircbot.sendData("PRIVMSG", channel + " :" + nick + " has started the timer! If the bomb gets passed to you, type " + conf.command + "pass <nick> to pass it to someone else, or type " + conf.command + "defuse <color> to try to defuse it."); string colors = ""; foreach (string wire in tmp_info.wire_colors) { colors += wire + ","; } ircbot.sendData("NOTICE", nick + " :You need to hurry and pass the bomb before it blows up! Or you can try to defuse it yourself. The colors are: " + colors.TrimEnd(',')); hbombs.Add(tmp_info); } else { if (tmp_info.bomb_channel.Equals(channel)) { ircbot.sendData("PRIVMSG", channel + " :There is already a bomb counting down."); } else { ircbot.sendData("PRIVMSG", line[2] + " :There is already a bomb counting down in " + tmp_info.bomb_channel + "."); } } } else { ircbot.sendData("PRIVMSG", channel + " :You can not start a HBomb when you are idle."); } } else { ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command."); } break; case "pass": if (spam_check == true) { ircbot.add_spam_count(channel); } if (nick_access >= command_access) { int index = 0; bool hbomb_active = false; hbomb_info tmp_info = new hbomb_info(); foreach (hbomb_info bomb in hbombs) { if (bomb.bomb_channel.Equals(channel)) { tmp_info = bomb; hbomb_active = true; break; } index++; } if (hbomb_active == true) { if (!tmp_info.bomb_locked) { int module_index = 0; foreach (Modules.Module module in ircbot.module_list) { string module_type = module.GetType().ToString(); if (module_type.Equals("IRCBot.Modules.idle")) { break; } else { module_index++; } } Modules.idle idle; if (module_index < ircbot.module_list.Count()) { idle = (Modules.idle)ircbot.module_list[module_index]; } else { idle = new Modules.idle(); } if (idle.check_idle(nick) == false) { if (tmp_info.bomb_holder.Equals(nick)) { if (line.GetUpperBound(0) > 3) { if (line[4].TrimEnd(' ').ToLower().Equals(conf.nick.ToLower())) { ircbot.sendData("PRIVMSG", channel + " :" + nick + ", you can't pass it to me!"); } else { int user_access = ircbot.get_user_access(line[4].TrimEnd(' ').ToLower(), channel); if (user_access > 0 && idle.check_idle(line[4].TrimEnd(' ').ToLower()) == false) { pass_hbomb(line[4].TrimEnd(' ').ToLower(), channel, nick, ircbot, conf, ref tmp_info, index); } else { ircbot.sendData("PRIVMSG", channel + " :" + nick + ", you can't pass to them!"); } } } else { ircbot.sendData("PRIVMSG", channel + " :" + nick + ", you need to pass the bomb to someone."); } } else { ircbot.sendData("PRIVMSG", channel + " :You don't have the bomb!"); } } else { ircbot.sendData("PRIVMSG", channel + " :You can not pass the HBomb when you are idle."); } } else { ircbot.sendData("PRIVMSG", channel + " :You can not pass a locked bomb."); } } else { ircbot.sendData("PRIVMSG", channel + " :There isn't a bomb to pass!"); } } else { ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command."); } break; case "set_bomb": if (spam_check == true) { ircbot.add_spam_count(channel); } if (nick_access >= command_access) { int index = 0; bool hbomb_active = false; hbomb_info tmp_info = new hbomb_info(); foreach (hbomb_info bomb in hbombs) { if (bomb.bomb_channel.Equals(channel)) { tmp_info = bomb; hbomb_active = true; break; } index++; } if (hbomb_active == true) { if (line.GetUpperBound(0) > 3) { if (line[4].TrimEnd(' ').ToLower().Equals(conf.nick.ToLower())) { ircbot.sendData("PRIVMSG", channel + " :" + nick + ", you can't pass it to me!"); } else { int user_access = ircbot.get_user_access(line[4].TrimEnd(' ').ToLower(), channel); if (user_access > 0) { pass_hbomb(line[4].TrimEnd(' ').ToLower(), channel, nick, ircbot, conf, ref tmp_info, index); } else { ircbot.sendData("PRIVMSG", channel + " :" + nick + ", that user isn't online!"); } } } else { ircbot.sendData("PRIVMSG", channel + " :" + nick + ", you need to pass the bomb to someone."); } } else { ircbot.sendData("PRIVMSG", channel + " :There isn't a bomb to pass!"); } } else { ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command."); } break; case "lock_bomb": if (spam_check == true) { ircbot.add_spam_count(channel); } if (nick_access >= command_access) { int index = 0; bool hbomb_active = false; hbomb_info tmp_info = new hbomb_info(); foreach (hbomb_info bomb in hbombs) { if (bomb.bomb_channel.Equals(channel)) { tmp_info = bomb; hbomb_active = true; break; } index++; } if (hbomb_active == true) { if (line.GetUpperBound(0) > 3) { if (line[4].TrimEnd(' ').ToLower().Equals(conf.nick.ToLower())) { ircbot.sendData("PRIVMSG", channel + " :" + nick + ", you can't pass it to me!"); } else { int user_access = ircbot.get_user_access(line[4].TrimEnd(' ').ToLower(), channel); if (user_access > 0) { pass_hbomb(line[4].TrimEnd(' ').ToLower(), channel, nick, ircbot, conf, ref tmp_info, index); tmp_info.bomb_locked = true; } else { ircbot.sendData("PRIVMSG", channel + " :" + nick + ", that user isn't online!"); } } } else { tmp_info.bomb_locked = true; } } else { ircbot.sendData("PRIVMSG", channel + " :There isn't a bomb to lock!"); } } else { ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command."); } break; case "unlock_bomb": if (spam_check == true) { ircbot.add_spam_count(channel); } if (nick_access >= command_access) { int index = 0; bool hbomb_active = false; hbomb_info tmp_info = new hbomb_info(); foreach (hbomb_info bomb in hbombs) { if (bomb.bomb_channel.Equals(channel)) { tmp_info = bomb; hbomb_active = true; break; } index++; } if (hbomb_active == true) { tmp_info.bomb_locked = false; hbombs[index] = tmp_info; } else { ircbot.sendData("PRIVMSG", channel + " :There isn't a bomb to unlock!"); } } else { ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command."); } break; case "detonate": if (spam_check == true) { ircbot.add_spam_count(channel); } if (nick_access >= command_access) { bool hbomb_active = false; foreach (hbomb_info bomb in hbombs) { if (bomb.bomb_channel.Equals(channel)) { hbomb_active = true; break; } } if (hbomb_active == true) { main = ircbot; activate_bomb(channel); } else { ircbot.sendData("PRIVMSG", channel + " :There isn't a bomb to blow up!"); } } else { ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command."); } break; case "stop_bomb": if (spam_check == true) { ircbot.add_spam_count(channel); } if (nick_access >= command_access) { int index = 0; bool hbomb_active = false; hbomb_info tmp_info = new hbomb_info(); foreach (hbomb_info bomb in hbombs) { if (bomb.bomb_channel.Equals(channel)) { tmp_info = bomb; hbomb_active = true; break; } index++; } if (hbomb_active == true) { hbombs.RemoveAt(index); ircbot.sendData("PRIVMSG", channel + " :Bomb has been defused and thrown away."); } else { ircbot.sendData("PRIVMSG", channel + " :There isn't a bomb to stop!"); } } else { ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command."); } break; case "defuse": if (spam_check == true) { ircbot.add_spam_count(channel); } if (nick_access >= command_access) { int index = 0; bool hbomb_active = false; hbomb_info tmp_info = new hbomb_info(); foreach (hbomb_info bomb in hbombs) { if (bomb.bomb_channel.Equals(channel)) { tmp_info = bomb; hbomb_active = true; break; } index++; } if (hbomb_active == true) { if (!tmp_info.bomb_locked) { int module_index = 0; foreach (Modules.Module module in ircbot.module_list) { string module_type = module.GetType().ToString(); if (module_type.Equals("IRCBot.Modules.idle")) { break; } else { module_index++; } } Modules.idle idle; if (module_index < ircbot.module_list.Count()) { idle = (Modules.idle)ircbot.module_list[module_index]; } else { idle = new Modules.idle(); } if (idle.check_idle(nick) == false) { if (tmp_info.bomb_holder.Equals(nick)) { if (line.GetUpperBound(0) > 3) { if (line[4].ToLower().Equals(tmp_info.wire_color.ToLower())) { ircbot.sendData("PRIVMSG", channel + " :You have successfully defused the bomb!"); if (tmp_info.previous_bomb_holder.Equals(tmp_info.bomb_holder)) { } else { ircbot.sendData("KICK", tmp_info.bomb_channel + " " + tmp_info.previous_bomb_holder + " :BOOM!!!"); } hbombs.RemoveAt(index); } else { main = ircbot; activate_bomb(channel); } } else { ircbot.sendData("PRIVMSG", channel + " :" + nick + ", you need to cut a wire."); } } else { ircbot.sendData("PRIVMSG", channel + " :You don't have the bomb!"); } } else { ircbot.sendData("PRIVMSG", channel + " :You can not defuse the HBomb when you are idle."); } } else { ircbot.sendData("PRIVMSG", channel + " :You can not defuse the HBomb when it is locked."); } } else { ircbot.sendData("PRIVMSG", channel + " :There isn't a bomb to defuse!"); } } 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; } } } } } } }
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 void del_access_list(string nick, string channel, string access, bot ircbot) { string file_name = ircbot.server_name + "_list.txt"; DateTime current_date = DateTime.Now; if (Directory.Exists(ircbot.cur_dir + Path.DirectorySeparatorChar + "modules" + Path.DirectorySeparatorChar + "access" + Path.DirectorySeparatorChar + "") == false) { Directory.CreateDirectory(ircbot.cur_dir + Path.DirectorySeparatorChar + "modules" + Path.DirectorySeparatorChar + "access"); } if (File.Exists(ircbot.cur_dir + Path.DirectorySeparatorChar + "modules" + Path.DirectorySeparatorChar + "access" + Path.DirectorySeparatorChar + file_name)) { string[] log_file = System.IO.File.ReadAllLines(ircbot.cur_dir + Path.DirectorySeparatorChar + "modules" + Path.DirectorySeparatorChar + "access" + Path.DirectorySeparatorChar + file_name); int number_of_lines = log_file.GetUpperBound(0) + 1; List <string> new_file = new List <string>(); if (number_of_lines > 0) { foreach (string lines in log_file) { char[] sep = new char[] { '*' }; string[] new_line = lines.Split(sep, 3); if (new_line.GetUpperBound(0) > 0) { if (new_line[0].Trim().Equals(nick) && new_line[1].Trim().Equals(channel)) { string[] tmp_line = new_line[2].Trim().Split(','); string new_access = ""; foreach (string line in tmp_line) { if (line.Equals(access)) { } else { new_access += "," + line; } } if (new_access.TrimStart(',').TrimEnd(',') != "") { new_file.Add(new_line[0].Trim() + "*" + new_line[1].Trim() + "*" + new_access.TrimStart(',').TrimEnd(',')); } } else { new_file.Add(lines); } } } System.IO.File.WriteAllLines(ircbot.cur_dir + Path.DirectorySeparatorChar + "modules" + Path.DirectorySeparatorChar + "access" + Path.DirectorySeparatorChar + file_name, new_file); } } for (int x = 0; x < ircbot.nick_list.Count(); x++) { if (ircbot.nick_list[x][0].Equals(channel)) { for (int i = 2; i < ircbot.nick_list[x].Count(); i++) { string[] split = ircbot.nick_list[x][i].Split(':'); if (split[1].Equals(nick)) { int new_access = ircbot.get_user_op(nick, channel); ircbot.nick_list[x][i] = new_access.ToString() + ":" + nick; new_access = ircbot.get_user_access(nick, channel); ircbot.nick_list[x][i] = new_access.ToString() + ":" + nick; 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 "access": if (spam_check == true) { ircbot.add_spam_count(channel); } if (nick_access >= command_access) { if (line.GetUpperBound(0) > 3) { string[] parse = line[4].Split(' '); if (parse.GetUpperBound(0) > 1) { if (Convert.ToInt32(parse[2]) <= nick_access) { set_access_list(parse[0].Trim().ToLower(), parse[1], parse[2], ircbot); ircbot.sendData("NOTICE", nick + " :" + parse[0].Trim() + " has been added to access level " + parse[2]); } else { ircbot.sendData("NOTICE", nick + " :You do not have permission to change their access."); } } else if (type.Equals("channel") && parse.GetUpperBound(0) > 0) { if (Convert.ToInt32(parse[1]) <= nick_access) { set_access_list(parse[0].Trim().ToLower(), line[2], parse[1], ircbot); ircbot.sendData("NOTICE", nick + " :" + parse[0].Trim() + " has been added to access level " + parse[1]); } else { ircbot.sendData("NOTICE", nick + " :You do not have permission to change their access."); } } else { ircbot.sendData("NOTICE", nick + " :" + nick + ", you need to include more info."); } } 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; case "delaccess": if (spam_check == true) { ircbot.add_spam_count(channel); } if (nick_access >= command_access) { if (line.GetUpperBound(0) > 3) { string[] parse = line[4].Split(' '); if (parse.GetUpperBound(0) > 1) { if (Convert.ToInt32(parse[2]) <= nick_access) { del_access_list(parse[0].Trim().ToLower(), parse[1], parse[2], ircbot); ircbot.sendData("NOTICE", nick + " :" + parse[0].Trim() + " has been removed from access level " + parse[2]); } else { ircbot.sendData("NOTICE", nick + " :You do not have permission to change their access."); } } else if (type.Equals("channel") && parse.GetUpperBound(0) > 0) { if (Convert.ToInt32(parse[1]) <= nick_access) { del_access_list(parse[0].Trim().ToLower(), line[2], parse[1], ircbot); ircbot.sendData("NOTICE", nick + " :" + parse[0].Trim() + " has been removed from access level " + parse[1]); } else { ircbot.sendData("NOTICE", nick + " :You do not have permission to change their access."); } } else { ircbot.sendData("NOTICE", nick + " :" + nick + ", you need to include more info."); } } 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; case "listaccess": if (spam_check == true) { ircbot.add_spam_count(channel); } if (nick_access >= command_access) { if (line.GetUpperBound(0) > 3) { list_access_list(nick, line[4], ircbot); } else if (type.Equals("channel")) { list_access_list(nick, line[2], ircbot); } 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; case "getaccess": 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(' '); if (new_line.GetUpperBound(0) > 0 && new_line[0].StartsWith("#")) { int viewed_access = ircbot.get_user_access(new_line[1].Trim().ToLower(), new_line[0].Trim()); ircbot.sendData("NOTICE", nick + " :" + new_line[1].Trim() + " has access level " + viewed_access.ToString()); } else if (type.Equals("channel")) { int viewed_access = ircbot.get_user_access(line[4].Trim().ToLower(), channel); ircbot.sendData("NOTICE", nick + " :" + line[4].Trim() + " has access level " + viewed_access.ToString()); } else { ircbot.sendData("NOTICE", nick + " :" + nick + ", you need to include more info."); } } 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; } } } } } } }
public void del_access_list(string nick, string channel, string access, bot ircbot) { string file_name = ircbot.server_name + "_list.txt"; DateTime current_date = DateTime.Now; if (Directory.Exists(ircbot.cur_dir + Path.DirectorySeparatorChar + "modules" + Path.DirectorySeparatorChar + "access" + Path.DirectorySeparatorChar + "") == false) { Directory.CreateDirectory(ircbot.cur_dir + Path.DirectorySeparatorChar + "modules" + Path.DirectorySeparatorChar + "access"); } if (File.Exists(ircbot.cur_dir + Path.DirectorySeparatorChar + "modules" + Path.DirectorySeparatorChar + "access" + Path.DirectorySeparatorChar + file_name)) { string[] log_file = System.IO.File.ReadAllLines(ircbot.cur_dir + Path.DirectorySeparatorChar + "modules" + Path.DirectorySeparatorChar + "access" + Path.DirectorySeparatorChar + file_name); int number_of_lines = log_file.GetUpperBound(0) + 1; List<string> new_file = new List<string>(); if (number_of_lines > 0) { foreach (string lines in log_file) { char[] sep = new char[] { '*' }; string[] new_line = lines.Split(sep, 3); if (new_line.GetUpperBound(0) > 0) { if (new_line[0].Trim().Equals(nick) && new_line[1].Trim().Equals(channel)) { string[] tmp_line = new_line[2].Trim().Split(','); string new_access = ""; foreach (string line in tmp_line) { if (line.Equals(access)) { } else { new_access += "," + line; } } if (new_access.TrimStart(',').TrimEnd(',') != "") { new_file.Add(new_line[0].Trim() + "*" + new_line[1].Trim() + "*" + new_access.TrimStart(',').TrimEnd(',')); } } else { new_file.Add(lines); } } } System.IO.File.WriteAllLines(ircbot.cur_dir + Path.DirectorySeparatorChar + "modules" + Path.DirectorySeparatorChar + "access" + Path.DirectorySeparatorChar + file_name, new_file); } } for (int x = 0; x < ircbot.nick_list.Count(); x++) { if (ircbot.nick_list[x][0].Equals(channel)) { for (int i = 2; i < ircbot.nick_list[x].Count(); i++) { string[] split = ircbot.nick_list[x][i].Split(':'); if (split[1].Equals(nick)) { int new_access = ircbot.get_user_op(nick, channel); ircbot.nick_list[x][i] = new_access.ToString() + ":" + nick; new_access = ircbot.get_user_access(nick, channel); ircbot.nick_list[x][i] = new_access.ToString() + ":" + nick; 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 "access": if (spam_check == true) { ircbot.add_spam_count(channel); } if (nick_access >= command_access) { if (line.GetUpperBound(0) > 3) { string[] parse = line[4].Split(' '); if (parse.GetUpperBound(0) > 1) { if (Convert.ToInt32(parse[2]) <= nick_access) { set_access_list(parse[0].Trim().ToLower(), parse[1], parse[2], ircbot); ircbot.sendData("NOTICE", nick + " :" + parse[0].Trim() + " has been added to access level " + parse[2]); } else { ircbot.sendData("NOTICE", nick + " :You do not have permission to change their access."); } } else if (type.Equals("channel") && parse.GetUpperBound(0) > 0) { if (Convert.ToInt32(parse[1]) <= nick_access) { set_access_list(parse[0].Trim().ToLower(), line[2], parse[1], ircbot); ircbot.sendData("NOTICE", nick + " :" + parse[0].Trim() + " has been added to access level " + parse[1]); } else { ircbot.sendData("NOTICE", nick + " :You do not have permission to change their access."); } } else { ircbot.sendData("NOTICE", nick + " :" + nick + ", you need to include more info."); } } 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; case "delaccess": if (spam_check == true) { ircbot.add_spam_count(channel); } if (nick_access >= command_access) { if (line.GetUpperBound(0) > 3) { string[] parse = line[4].Split(' '); if (parse.GetUpperBound(0) > 1) { if (Convert.ToInt32(parse[2]) <= nick_access) { del_access_list(parse[0].Trim().ToLower(), parse[1], parse[2], ircbot); ircbot.sendData("NOTICE", nick + " :" + parse[0].Trim() + " has been removed from access level " + parse[2]); } else { ircbot.sendData("NOTICE", nick + " :You do not have permission to change their access."); } } else if (type.Equals("channel") && parse.GetUpperBound(0) > 0) { if (Convert.ToInt32(parse[1]) <= nick_access) { del_access_list(parse[0].Trim().ToLower(), line[2], parse[1], ircbot); ircbot.sendData("NOTICE", nick + " :" + parse[0].Trim() + " has been removed from access level " + parse[1]); } else { ircbot.sendData("NOTICE", nick + " :You do not have permission to change their access."); } } else { ircbot.sendData("NOTICE", nick + " :" + nick + ", you need to include more info."); } } 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; case "listaccess": if (spam_check == true) { ircbot.add_spam_count(channel); } if (nick_access >= command_access) { if (line.GetUpperBound(0) > 3) { list_access_list(nick, line[4], ircbot); } else if (type.Equals("channel")) { list_access_list(nick, line[2], ircbot); } 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; case "getaccess": 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(' '); if (new_line.GetUpperBound(0) > 0 && new_line[0].StartsWith("#")) { int viewed_access = ircbot.get_user_access(new_line[1].Trim().ToLower(), new_line[0].Trim()); ircbot.sendData("NOTICE", nick + " :" + new_line[1].Trim() + " has access level " + viewed_access.ToString()); } else if (type.Equals("channel")) { int viewed_access = ircbot.get_user_access(line[4].Trim().ToLower(), channel); ircbot.sendData("NOTICE", nick + " :" + line[4].Trim() + " has access level " + viewed_access.ToString()); } else { ircbot.sendData("NOTICE", nick + " :" + nick + ", you need to include more info."); } } 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; } } } } } } }