Bot.Modules.rules.del_rule C# (CSharp) Method

del_rule() private static method

private static del_rule ( string rule_num, string nick, string channel, bot ircbot ) : void
rule_num string
nick string
channel string
ircbot bot
return void
        private static void del_rule(string rule_num, string nick, string channel, bot ircbot)
        {
            string pattern = "[^a-zA-Z0-9]"; //regex pattern
            string tab_name = Regex.Replace(channel, pattern, "_");
            if (File.Exists(ircbot.cur_dir + Path.DirectorySeparatorChar + "modules" + Path.DirectorySeparatorChar + "rules" + Path.DirectorySeparatorChar + ircbot.Conf.Server_Name + "_" + tab_name + "_rules.txt"))
            {
                List<string> rules_file = System.IO.File.ReadAllLines(ircbot.cur_dir + Path.DirectorySeparatorChar + "modules" + Path.DirectorySeparatorChar + "rules" + Path.DirectorySeparatorChar + ircbot.Conf.Server_Name + "_" + tab_name + "_rules.txt").ToList();
                int number_of_lines = rules_file.Count + 1;
                if (number_of_lines > 0)
                {
                    int index = 0;
                    bool rule_found = false;
                    foreach (string line in rules_file)
                    {
                        if ((index + 1) == Convert.ToInt32(rule_num))
                        {
                            rules_file.RemoveAt(index);
                            rule_found = true;
                            break;
                        }
                        index++;
                    }
                    if (rule_found == false)
                    {
                        ircbot.sendData("NOTICE", nick + " :No Rules to Delete!");
                    }
                    else
                    {
                        System.IO.File.WriteAllLines(ircbot.cur_dir + Path.DirectorySeparatorChar + "modules" + Path.DirectorySeparatorChar + "rules" + Path.DirectorySeparatorChar + ircbot.Conf.Server_Name + "_" + tab_name + "_rules.txt", rules_file);
                    }
                }
                else
                {
                    ircbot.sendData("NOTICE", nick + " :No Rules to Delete!");
                }
            }
            else
            {
                ircbot.sendData("NOTICE", nick + " :There are no Rules");
            }
        }