public void add_spam_count(string channel) { lock (spamlock) { bool spam_added = false; bool spam_found = false; int index = 0; foreach (spam_info spam in conf.spam_check) { if (spam.spam_channel.Equals(channel)) { if (spam.spam_count > conf.spam_count_max + 1) { spam_added = true; } spam_found = true; break; } index++; } if (!spam_added && spam_found) { conf.spam_check[index].spam_count++; } else if (!spam_found) { spam_info new_spam = new spam_info(); new_spam.spam_channel = channel; new_spam.spam_activated = false; new_spam.spam_count = 1; conf.spam_check.Add(new_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") && 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 "weather": if (conf.module_config[module_id][3].Equals("True")) { if (spam_check == true) { lock (ircbot.spamlock) { bool spam_added = false; int index = 0; foreach (spam_info spam in conf.spam_check) { if (spam.spam_channel.Equals(channel)) { spam_added = true; index++; break; } } if (spam_added) { conf.spam_check[index].spam_count++; } else { spam_info new_spam = new spam_info(); new_spam.spam_channel = channel; new_spam.spam_activated = false; new_spam.spam_count = 1; conf.spam_check.Add(new_spam); } } } if (nick_access >= command_access) { if (line.GetUpperBound(0) > 3) { // Add introduction get_weather(line[4], line[2], 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 "forecast": if (conf.module_config[module_id][4].Equals("True")) { if (spam_check == true) { lock (ircbot.spamlock) { bool spam_added = false; int index = 0; foreach (spam_info spam in conf.spam_check) { if (spam.spam_channel.Equals(channel)) { spam_added = true; index++; break; } } if (spam_added) { conf.spam_check[index].spam_count++; } else { spam_info new_spam = new spam_info(); new_spam.spam_channel = channel; new_spam.spam_activated = false; new_spam.spam_count = 1; conf.spam_check.Add(new_spam); } } } if (nick_access >= command_access) { if (line.GetUpperBound(0) > 3) { // Add introduction get_forecast(line[4], line[2], ircbot, Convert.ToInt32(conf.module_config[module_id][5])); } 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") && 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 "weather": if (conf.module_config[module_id][3].Equals("True")) { if (spam_check == true) { lock (ircbot.spamlock) { bool spam_added = false; int index = 0; foreach (spam_info spam in conf.spam_check) { if (spam.spam_channel.Equals(channel)) { spam_added = true; index++; break; } } if (spam_added) { conf.spam_check[index].spam_count++; } else { spam_info new_spam = new spam_info(); new_spam.spam_channel = channel; new_spam.spam_activated = false; new_spam.spam_count = 1; conf.spam_check.Add(new_spam); } } } if (nick_access >= command_access) { if (line.GetUpperBound(0) > 3) { // Add introduction get_weather(line[4], line[2], 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 "forecast": if (conf.module_config[module_id][4].Equals("True")) { if (spam_check == true) { lock (ircbot.spamlock) { bool spam_added = false; int index = 0; foreach (spam_info spam in conf.spam_check) { if (spam.spam_channel.Equals(channel)) { spam_added = true; index++; break; } } if (spam_added) { conf.spam_check[index].spam_count++; } else { spam_info new_spam = new spam_info(); new_spam.spam_channel = channel; new_spam.spam_activated = false; new_spam.spam_count = 1; conf.spam_check.Add(new_spam); } } } if (nick_access >= command_access) { if (line.GetUpperBound(0) > 3) { // Add introduction get_forecast(line[4], line[2], ircbot, Convert.ToInt32(conf.module_config[module_id][5])); } 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; } } } } } } }