コード例 #1
0
ファイル: wolfram_alpha.cs プロジェクト: uncled1023/IRCBot
 private void get_wa(string search, string channel, bot ircbot, BotConfig Conf)
 {
     string URL = "http://api.wolframalpha.com/v2/query?input=" + System.Web.HttpUtility.UrlEncode(search) + "&appid=" + this.Options["API"] + "&format=plaintext";
     XmlNodeList xnList = null;
     try
     {
         WebClient web = new WebClient();
         web.Encoding = Encoding.UTF8;
         string results = web.DownloadString(URL);
         XmlDocument xmlDoc = new XmlDocument();
         xmlDoc.LoadXml(results);
         xnList = xmlDoc.SelectNodes("/queryresult/pod");
     }
     catch
     {
         ircbot.sendData("PRIVMSG", channel + " :Could not fetch results");
     }
     if (xnList.Count > 1)
     {
         ircbot.sendData("PRIVMSG", channel + " :Result for: " + xnList[0]["subpod"]["plaintext"].InnerText);
         ircbot.sendData("PRIVMSG", channel + " :" + xnList[1]["subpod"]["plaintext"].InnerText);
     }
     else
     {
         ircbot.sendData("PRIVMSG", channel + " :No Results Found.");
     }
 }
コード例 #2
0
ファイル: roll_call.cs プロジェクト: uncled1023/IRCBot
 public override void control(bot ircbot, BotConfig Conf, string[] line, string command, int nick_access, string nick, string channel, bool bot_command, string type)
 {
     if (type.Equals("channel") && bot_command == true)
     {
         foreach (Command tmp_command in this.Commands)
         {
             bool blocked = tmp_command.Blacklist.Contains(channel) || tmp_command.Blacklist.Contains(nick);
             bool cmd_found = false;
             bool spam_check = ircbot.get_spam_check(channel, nick, tmp_command.Spam_Check);
             if (spam_check == true)
             {
                 blocked = blocked || ircbot.get_spam_status(channel);
             }
             cmd_found = tmp_command.Triggers.Contains(command);
             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 tmp_command.Triggers)
                 {
                     switch (trigger)
                     {
                         case "rollcall":
                             if (spam_check == true)
                             {
                                 ircbot.add_spam_count(channel);
                             }
                             if (nick_access >= tmp_command.Access)
                             {
                                 if (line.GetUpperBound(0) > 3)
                                 {
                                     if (line[4].StartsWith("#"))
                                     {
                                         channel = line[4];
                                     }
                                     else
                                     {
                                         ircbot.sendData("PRIVMSG", nick + " :Please specify a valid channel");
                                     }
                                 }
                                 string nicks = "";
                                 Channel_Info chan_info = ircbot.get_chan_info(channel);
                                 foreach (Nick_Info info in chan_info.Nicks)
                                 {
                                     nicks += info.Nick + ", ";
                                 }
                                 ircbot.sendData("PRIVMSG", channel + " :" + this.Options["roll_call_message"] + ": " + nicks.Trim().TrimEnd(','));
                             }
                             break;
                     }
                 }
             }
         }
     }
 }
コード例 #3
0
ファイル: wolfram_alpha.cs プロジェクト: uncled1023/IRCBot
 public override void control(bot ircbot, BotConfig Conf, string[] line, string command, int nick_access, string nick, string channel, bool bot_command, string type)
 {
     if ((type.Equals("channel") || type.Equals("query")) && bot_command == true)
     {
         foreach (Command tmp_command in this.Commands)
         {
             bool blocked = tmp_command.Blacklist.Contains(channel) || tmp_command.Blacklist.Contains(nick);
             bool cmd_found = false;
             bool spam_check = ircbot.get_spam_check(channel, nick, tmp_command.Spam_Check);
             if (spam_check == true)
             {
                 blocked = blocked || ircbot.get_spam_status(channel);
             }
             cmd_found = tmp_command.Triggers.Contains(command);
             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 tmp_command.Triggers)
                 {
                     switch (trigger)
                     {
                         case "wa":
                             if (spam_check == true)
                             {
                                 ircbot.add_spam_count(channel);
                             }
                             if (nick_access >= tmp_command.Access)
                             {
                                 if (line.GetUpperBound(0) > 3)
                                 {
                                     // Get Urban Dictionary Info
                                     get_wa(line[4], line[2], ircbot, Conf);
                                 }
                                 else
                                 {
                                     ircbot.sendData("PRIVMSG", channel + " :" + nick + ", you need to include more info.");
                                 }
                             }
                             else
                             {
                                 ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command.");
                             }
                             break;
                     }
                 }
             }
         }
     }
 }
コード例 #4
0
ファイル: fortune.cs プロジェクト: uncled1023/IRCBot
 public override void control(bot ircbot, BotConfig Conf, string[] line, string command, int nick_access, string nick, string channel, bool bot_command, string type)
 {
     if ((type.Equals("channel") || type.Equals("query")) && bot_command == true)
     {
         foreach (Command tmp_command in this.Commands)
         {
             bool blocked = tmp_command.Blacklist.Contains(channel) || tmp_command.Blacklist.Contains(nick);
             bool cmd_found = false;
             bool spam_check = ircbot.get_spam_check(channel, nick, tmp_command.Spam_Check);
             if (spam_check == true)
             {
                 blocked = blocked || ircbot.get_spam_status(channel);
             }
             cmd_found = tmp_command.Triggers.Contains(command);
             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 tmp_command.Triggers)
                 {
                     switch (trigger)
                     {
                         case "fortune":
                             if (spam_check == true)
                             {
                                 ircbot.add_spam_count(channel);
                             }
                             if (nick_access >= tmp_command.Access)
                             {
                                 get_quote(channel, ircbot);
                             }
                             else
                             {
                                 ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command.");
                             }
                             break;
                     }
                 }
             }
         }
     }
 }
コード例 #5
0
ファイル: quote.cs プロジェクト: uncled1023/IRCBot
 public static void add_quote(string nick, string channel, string[] line, bot ircbot, BotConfig Conf)
 {
     string tab_name = channel.TrimStart('#');
     string pattern = "[^a-zA-Z0-9]"; //regex pattern
     string new_tab_name = Regex.Replace(tab_name, pattern, "_");
     string file_name = ircbot.Conf.Server_Name + "_#" + new_tab_name + ".log";
     if (Directory.Exists(ircbot.cur_dir + Path.DirectorySeparatorChar + "modules" + Path.DirectorySeparatorChar + "quotes" + Path.DirectorySeparatorChar + "logs") == false)
     {
         Directory.CreateDirectory(ircbot.cur_dir + Path.DirectorySeparatorChar + "modules" + Path.DirectorySeparatorChar + "quotes" + Path.DirectorySeparatorChar + "logs");
     }
     StreamWriter log_file = File.AppendText(ircbot.cur_dir + Path.DirectorySeparatorChar + "modules" + Path.DirectorySeparatorChar + "quotes" + Path.DirectorySeparatorChar + "logs" + Path.DirectorySeparatorChar + file_name);
     if (line.GetUpperBound(0) > 3)
     {
         log_file.WriteLine(nick + "*" + line[3].Remove(0, 1) + " " + line[4]);
     }
     else
     {
         log_file.WriteLine(nick + "*" + line[3].Remove(0, 1));
     }
     log_file.Close();
 }
コード例 #6
0
 public async Task SetGame()
 {
     await bot.SetGameAsync(BotConfig.Load().Prefix + "help");
 }
コード例 #7
0
        public bool Edit(BotConfigEditType type, string newValue)
        {
            using (var uow = _db.UnitOfWork)
            {
                var bc = uow.BotConfig.GetOrCreate(set => set);
                switch (type)
                {
                case BotConfigEditType.CurrencyGenerationChance:
                    if (float.TryParse(newValue, out var chance) &&
                        chance >= 0 &&
                        chance <= 1)
                    {
                        bc.CurrencyGenerationChance = chance;
                    }
                    else
                    {
                        return(false);
                    }
                    break;

                case BotConfigEditType.CurrencyGenerationCooldown:
                    if (int.TryParse(newValue, out var cd) && cd >= 1)
                    {
                        bc.CurrencyGenerationCooldown = cd;
                    }
                    else
                    {
                        return(false);
                    }
                    break;

                case BotConfigEditType.CurrencyName:
                    bc.CurrencyName = newValue ?? "-";
                    break;

                case BotConfigEditType.CurrencyPluralName:
                    bc.CurrencyPluralName = newValue ?? bc.CurrencyName + "s";
                    break;

                case BotConfigEditType.CurrencySign:
                    bc.CurrencySign = newValue ?? "-";
                    break;

                case BotConfigEditType.DmHelpString:
                    bc.DMHelpString = string.IsNullOrWhiteSpace(newValue)
                            ? "-"
                            : newValue;
                    break;

                case BotConfigEditType.HelpString:
                    bc.HelpString = string.IsNullOrWhiteSpace(newValue)
                            ? "-"
                            : newValue;
                    break;

                case BotConfigEditType.CurrencyDropAmount:
                    if (int.TryParse(newValue, out var amount) && amount > 0)
                    {
                        bc.CurrencyDropAmount = amount;
                    }
                    else
                    {
                        return(false);
                    }
                    break;

                case BotConfigEditType.CurrencyDropAmountMax:
                    if (newValue == null)
                    {
                        bc.CurrencyDropAmountMax = null;
                    }
                    else if (int.TryParse(newValue, out var maxAmount) && maxAmount > 0)
                    {
                        bc.CurrencyDropAmountMax = maxAmount;
                    }
                    else
                    {
                        return(false);
                    }
                    break;

                case BotConfigEditType.TriviaCurrencyReward:
                    if (int.TryParse(newValue, out var triviaReward) && triviaReward >= 0)
                    {
                        bc.TriviaCurrencyReward = triviaReward;
                    }
                    else
                    {
                        return(false);
                    }
                    break;

                case BotConfigEditType.Betroll100Multiplier:
                    if (float.TryParse(newValue, out var br100) && br100 > 0)
                    {
                        bc.Betroll100Multiplier = br100;
                    }
                    else
                    {
                        return(false);
                    }
                    break;

                case BotConfigEditType.Betroll91Multiplier:
                    if (int.TryParse(newValue, out var br91) && br91 > 0)
                    {
                        bc.Betroll91Multiplier = br91;
                    }
                    else
                    {
                        return(false);
                    }
                    break;

                case BotConfigEditType.Betroll67Multiplier:
                    if (int.TryParse(newValue, out var br67) && br67 > 0)
                    {
                        bc.Betroll67Multiplier = br67;
                    }
                    else
                    {
                        return(false);
                    }
                    break;

                case BotConfigEditType.BetflipMultiplier:
                    if (float.TryParse(newValue, out var bf) && bf > 0)
                    {
                        bc.BetflipMultiplier = bf;
                    }
                    else
                    {
                        return(false);
                    }
                    break;

                case BotConfigEditType.DailyCurrencyDecay:
                    if (float.TryParse(newValue, out var decay) && decay >= 0)
                    {
                        bc.DailyCurrencyDecay = decay;
                    }
                    else
                    {
                        return(false);
                    }
                    break;

                case BotConfigEditType.XpPerMessage:
                    if (int.TryParse(newValue, out var xp) && xp > 0)
                    {
                        bc.XpPerMessage = xp;
                    }
                    else
                    {
                        return(false);
                    }
                    break;

                case BotConfigEditType.XpMinutesTimeout:
                    if (int.TryParse(newValue, out var min) && min > 0)
                    {
                        bc.XpMinutesTimeout = min;
                    }
                    else
                    {
                        return(false);
                    }
                    break;

                case BotConfigEditType.PatreonCurrencyPerCent:
                    if (float.TryParse(newValue, out var cents) && cents > 0)
                    {
                        bc.PatreonCurrencyPerCent = cents;
                    }
                    else
                    {
                        return(false);
                    }
                    break;

                case BotConfigEditType.MinWaifuPrice:
                    if (int.TryParse(newValue, out var price) && price > 0)
                    {
                        bc.MinWaifuPrice = price;
                    }
                    else
                    {
                        return(false);
                    }
                    break;

                case BotConfigEditType.WaifuGiftMultiplier:
                    if (int.TryParse(newValue, out var mult) && mult > 0)
                    {
                        bc.WaifuGiftMultiplier = mult;
                    }
                    else
                    {
                        return(false);
                    }
                    break;

                case BotConfigEditType.MinimumTriviaWinReq:
                    if (int.TryParse(newValue, out var req) && req >= 0)
                    {
                        bc.MinimumTriviaWinReq = req;
                    }
                    else
                    {
                        return(false);
                    }
                    break;

                case BotConfigEditType.MinimumLevel:
                    if (int.TryParse(newValue, out var lmin) && lmin >= 0)
                    {
                        bc.MinimumLevel = lmin;
                    }
                    else
                    {
                        return(false);
                    }
                    break;

                case BotConfigEditType.MinBet:
                    if (int.TryParse(newValue, out var gmin) && gmin >= 0)
                    {
                        bc.MinBet = gmin;
                    }
                    else
                    {
                        return(false);
                    }
                    break;

                case BotConfigEditType.MaxBet:
                    if (int.TryParse(newValue, out var gmax) && gmax >= 0)
                    {
                        bc.MaxBet = gmax;
                    }
                    else
                    {
                        return(false);
                    }
                    break;

                case BotConfigEditType.OkColor:
                    try
                    {
                        newValue = newValue.Replace("#", "", StringComparison.InvariantCulture);
                        var c = new Color(Convert.ToUInt32(newValue, 16));
                        NadekoBot.OkColor = c;
                        bc.OkColor        = newValue;
                    }
                    catch
                    {
                        return(false);
                    }
                    break;

                case BotConfigEditType.ErrorColor:
                    try
                    {
                        newValue = newValue.Replace("#", "", StringComparison.InvariantCulture);
                        var c = new Color(Convert.ToUInt32(newValue, 16));
                        NadekoBot.ErrorColor = c;
                        bc.ErrorColor        = newValue;
                    }
                    catch
                    {
                        return(false);
                    }
                    break;

                case BotConfigEditType.ConsoleOutputType:
                    if (!Enum.TryParse <ConsoleOutputType>(newValue, true, out var val))
                    {
                        return(false);
                    }
                    bc.ConsoleOutputType = val;
                    break;

                case BotConfigEditType.CheckForUpdates:
                    if (!Enum.TryParse <UpdateCheckType>(newValue, true, out var up))
                    {
                        return(false);
                    }
                    bc.CheckForUpdates = up;
                    break;

                case BotConfigEditType.CurrencyGenerationPassword:
                    if (!bool.TryParse(newValue, out var pw))
                    {
                        return(false);
                    }
                    bc.CurrencyGenerationPassword = pw;
                    break;

                default:
                    return(false);
                }

                BotConfig = bc;
                uow.Complete();
            }
            return(true);
        }
コード例 #8
0
ファイル: owner.cs プロジェクト: uncled1023/IRCBot
 private static void ignore(string ignore_nick, string nick, bot ircbot, BotConfig Conf)
 {
     bool added = false;
     XmlNode xn = ircbot.controller.get_server_xml(Conf.Server_Name);
     string new_ignore = xn["ignore_list"].InnerText + "," + ignore_nick;
     xn["ignore_list"].InnerText = new_ignore.TrimStart(',');
     added = ircbot.controller.save_server_xml(Conf.Server_Name, xn);
     if (added)
     {
         Conf.Ignore_List += "," + nick;
         ircbot.controller.update_conf();
         ircbot.sendData("NOTICE", nick + " :" + ignore_nick + " successfully added to the ignore list!");
     }
     else
     {
         ircbot.sendData("NOTICE", nick + " :" + ignore_nick + " was not added to the ignore list.");
     }
 }
コード例 #9
0
ファイル: response.cs プロジェクト: uncled1023/IRCBot
        public override void control(bot ircbot, BotConfig Conf, string[] line, string command, int nick_access, string nick, string channel, bool bot_command, string type)
        {
            if ((type.Equals("channel") || type.Equals("query")) && bot_command == true)
            {
                foreach (Command tmp_command in this.Commands)
                {
                    bool blocked = tmp_command.Blacklist.Contains(channel) || tmp_command.Blacklist.Contains(nick);
                    bool cmd_found = false;
                    bool spam_check = ircbot.get_spam_check(channel, nick, tmp_command.Spam_Check);
                    if (spam_check == true)
                    {
                        blocked = blocked || ircbot.get_spam_status(channel);
                    }
                    cmd_found = tmp_command.Triggers.Contains(command);
                    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 tmp_command.Triggers)
                        {
                            switch (trigger)
                            {
                                case "addresponse":
                                    if (spam_check == true)
                                    {
                                        ircbot.add_spam_count(channel);
                                    }
                                    if (nick_access >= tmp_command.Access)
                                    {
                                        if (line.GetUpperBound(0) > 3)
                                        {
                                            string list_file = ircbot.cur_dir + Path.DirectorySeparatorChar + "modules" + Path.DirectorySeparatorChar + "Response" + Path.DirectorySeparatorChar + "dictionary.txt";
                                            if (Directory.Exists(ircbot.cur_dir + Path.DirectorySeparatorChar + "modules" + Path.DirectorySeparatorChar + "Response" + Path.DirectorySeparatorChar + "") == false)
                                            {
                                                Directory.CreateDirectory(ircbot.cur_dir + Path.DirectorySeparatorChar + "modules" + Path.DirectorySeparatorChar + "Response");
                                            }
                                            if (File.Exists(ircbot.cur_dir + Path.DirectorySeparatorChar + "modules" + Path.DirectorySeparatorChar + "Response" + Path.DirectorySeparatorChar + "dictionary.txt"))
                                            {
                                                StreamWriter log = File.AppendText(ircbot.cur_dir + Path.DirectorySeparatorChar + "modules" + Path.DirectorySeparatorChar + "Response" + Path.DirectorySeparatorChar + "dictionary.txt");
                                                log.WriteLine(line[4]);
                                                log.Close();
                                            }
                                            else
                                            {
                                                StreamWriter log_file = File.CreateText(ircbot.cur_dir + Path.DirectorySeparatorChar + "modules" + Path.DirectorySeparatorChar + "Response" + Path.DirectorySeparatorChar + "dictionary.txt");
                                                log_file.WriteLine(line[4]);
                                                log_file.Close();
                                            }
                                            ircbot.sendData("PRIVMSG", channel + " :Response added successfully");
                                        }
                                        else
                                        {
                                            ircbot.sendData("NOTICE", nick + " :" + nick + ", you need to include more info.");
                                        }
                                    }
                                    else
                                    {
                                        ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command.");
                                    }
                                    break;
                                case "delresponse":
                                    if (spam_check == true)
                                    {
                                        ircbot.add_spam_count(channel);
                                    }
                                    if (nick_access >= tmp_command.Access)
                                    {
                                        if (line.GetUpperBound(0) > 3)
                                        {
                                            try
                                            {
                                                bool response_found = false;
                                                string list_file = ircbot.cur_dir + Path.DirectorySeparatorChar + "modules" + Path.DirectorySeparatorChar + "Response" + Path.DirectorySeparatorChar + "dictionary.txt";
                                                if (Directory.Exists(ircbot.cur_dir + Path.DirectorySeparatorChar + "modules" + Path.DirectorySeparatorChar + "Response" + Path.DirectorySeparatorChar + "") == false)
                                                {
                                                    Directory.CreateDirectory(ircbot.cur_dir + Path.DirectorySeparatorChar + "modules" + Path.DirectorySeparatorChar + "Response");
                                                }
                                                if (File.Exists(ircbot.cur_dir + Path.DirectorySeparatorChar + "modules" + Path.DirectorySeparatorChar + "Response" + Path.DirectorySeparatorChar + "dictionary.txt"))
                                                {
                                                    string[] file = System.IO.File.ReadAllLines(list_file);

                                                    if (file.GetUpperBound(0) >= 0)
                                                    {
                                                        List<string> new_file = new List<string>();
                                                        int index = 1;
                                                        foreach (string tmp_new_line in file)
                                                        {
                                                            if (index == Convert.ToInt32(line[4]))
                                                            {
                                                                ircbot.sendData("NOTICE", nick + " :Response removed successfully.");
                                                                response_found = true;
                                                            }
                                                            else
                                                            {
                                                                new_file.Add(tmp_new_line);
                                                            }
                                                            index++;
                                                        }
                                                        System.IO.File.WriteAllLines(@list_file, new_file);
                                                    }
                                                    if (!response_found)
                                                    {
                                                        ircbot.sendData("NOTICE", nick + " :Unable to delete desired response.");
                                                    }
                                                }
                                                else
                                                {
                                                    StreamWriter log_file = File.CreateText(ircbot.cur_dir + Path.DirectorySeparatorChar + "modules" + Path.DirectorySeparatorChar + "Response" + Path.DirectorySeparatorChar + "dictionary.txt");
                                                    log_file.Close();
                                                }
                                            }
                                            catch
                                            {
                                                ircbot.sendData("NOTICE", nick + " :Please specify a valid number.");
                                            }
                                        }
                                        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 "listresponse":
                                    if (spam_check == true)
                                    {
                                        ircbot.add_spam_count(channel);
                                    }
                                    if (nick_access >= tmp_command.Access)
                                    {
                                        string list_file = ircbot.cur_dir + Path.DirectorySeparatorChar + "modules" + Path.DirectorySeparatorChar + "Response" + Path.DirectorySeparatorChar + "dictionary.txt";
                                        if (Directory.Exists(ircbot.cur_dir + Path.DirectorySeparatorChar + "modules" + Path.DirectorySeparatorChar + "Response" + Path.DirectorySeparatorChar + "") == false)
                                        {
                                            Directory.CreateDirectory(ircbot.cur_dir + Path.DirectorySeparatorChar + "modules" + Path.DirectorySeparatorChar + "Response");
                                        }
                                        if (File.Exists(ircbot.cur_dir + Path.DirectorySeparatorChar + "modules" + Path.DirectorySeparatorChar + "Response" + Path.DirectorySeparatorChar + "dictionary.txt"))
                                        {
                                            string[] file = System.IO.File.ReadAllLines(list_file);

                                            if (file.GetUpperBound(0) >= 0)
                                            {
                                                int index = 1;
                                                foreach (string tmp_new_line in file)
                                                {
                                                    ircbot.sendData("NOTICE", nick + " :[" + index + "] " + tmp_new_line);
                                                    Thread.Sleep(100);
                                                    index++;
                                                }
                                            }
                                        }
                                        else
                                        {
                                            StreamWriter log_file = File.CreateText(ircbot.cur_dir + Path.DirectorySeparatorChar + "modules" + Path.DirectorySeparatorChar + "Response" + Path.DirectorySeparatorChar + "dictionary.txt");
                                            log_file.Close();
                                        }
                                    }
                                    else
                                    {
                                        ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command.");
                                    }
                                    break;
                            }
                        }
                    }
                }
            }
            if (type.Equals("channel") && !bot_command)
            {
                if (!nick.Equals(ircbot.Nick, StringComparison.InvariantCultureIgnoreCase))
                {
                    string[] file;
                    string list_file = ircbot.cur_dir + Path.DirectorySeparatorChar + "modules" + Path.DirectorySeparatorChar + "Response" + Path.DirectorySeparatorChar + "dictionary.txt";
                    if (File.Exists(list_file))
                    {
                        file = System.IO.File.ReadAllLines(list_file);

                        string tmp_line = line[3];
                        if (line.GetUpperBound(0) > 3)
                        {
                            tmp_line += " " + line[4];
                        }
                        tmp_line = tmp_line.Remove(0, 1);
                        string new_line = tmp_line.ToLowerInvariant();
                        bool triggered = false;
                        if (file.GetUpperBound(0) >= 0)
                        {
                            foreach (string tmp_new_line in file)
                            {
                                char[] split_type = new char[] { ':' };
                                char[] trigger_split = new char[] { '*' };
                                char[] triggered_split = new char[] { '&' };
                                string[] split = tmp_new_line.Split(split_type, 3);
                                string[] channels = split[0].Split(',');
                                string[] triggers = split[1].Split('|');
                                string[] responses = split[2].Split('|');
                                bool response_allowed = false;
                                foreach (string chan in channels)
                                {
                                    if (chan.Equals(channel, StringComparison.InvariantCultureIgnoreCase) || chan.Equals(nick, StringComparison.InvariantCultureIgnoreCase) || chan.Equals("<all>"))
                                    {
                                        response_allowed = true;
                                    }
                                    if(chan.Equals("!" + nick, StringComparison.InvariantCultureIgnoreCase))
                                    {
                                        response_allowed = false;
                                        break;
                                    }
                                    if (chan.Equals("!" + channel, StringComparison.InvariantCultureIgnoreCase))
                                    {
                                        response_allowed = false;
                                        break;
                                    }
                                }
                                if (response_allowed)
                                {
                                    int index = 0;
                                    for (int x = 0; x <= triggers.GetUpperBound(0); x++)
                                    {
                                        string[] terms = triggers[x].Split(trigger_split, StringSplitOptions.RemoveEmptyEntries);
                                        for (int y = 0; y <= terms.GetUpperBound(0); y++)
                                        {
                                            triggered = false;
                                            terms[y] = terms[y].ToLowerInvariant();
                                            if (triggers[x].StartsWith("*") == false && triggers[x].EndsWith("*") == false && terms.GetUpperBound(0) == 0)
                                            {
                                                if (new_line.Equals(terms[y]) == true)
                                                {
                                                    triggered = true;
                                                }
                                                else
                                                {
                                                    triggered = false;
                                                    break;
                                                }
                                            }
                                            else if (triggers[x].StartsWith("*") == false && y == 0)
                                            {
                                                if (new_line.StartsWith(terms[y]) == true && index <= new_line.IndexOf(terms[y]))
                                                {
                                                    triggered = true;
                                                    index = new_line.IndexOf(terms[y]);
                                                }
                                                else
                                                {
                                                    triggered = false;
                                                    break;
                                                }
                                            }
                                            else if (triggers[x].EndsWith("*") == false && y == terms.GetUpperBound(0))
                                            {
                                                if (new_line.EndsWith(terms[y]) == true && index <= new_line.IndexOf(terms[y]))
                                                {
                                                    triggered = true;
                                                    index = new_line.IndexOf(terms[y]);
                                                }
                                                else
                                                {
                                                    triggered = false;
                                                    break;
                                                }
                                            }
                                            else
                                            {
                                                if (new_line.Contains(terms[y]) == true && index <= new_line.IndexOf(terms[y]))
                                                {
                                                    triggered = true;
                                                    index = new_line.IndexOf(terms[y]);
                                                }
                                                else
                                                {
                                                    triggered = false;
                                                    break;
                                                }
                                            }
                                        }
                                        if (triggered == true)
                                        {
                                            break;
                                        }
                                    }
                                    if (triggered == true)
                                    {
                                        ircbot.add_spam_count(channel);
                                        int number_of_responses = responses.GetUpperBound(0) + 1;
                                        Random random = new Random();
                                        index = random.Next(0, number_of_responses);
                                        string file_line = responses[index].Replace("<nick>", nick);
                                        file_line = file_line.Replace("<me>", Conf.Nick);
                                        file_line = file_line.Replace("<chan>", channel);
                                        string[] events = file_line.Split(triggered_split, StringSplitOptions.RemoveEmptyEntries);
                                        for (int y = 0; y <= events.GetUpperBound(0); y++)
                                        {
                                            if (events[y].StartsWith("<cmd>") == true)
                                            {
                                                char[] charSplit = new char[] { ' ' };
                                                string[] ex = events[y].Remove(0, 5).Split(charSplit, 2);
                                                string[] args;
                                                if (ex.GetUpperBound(0) > 0)
                                                {
                                                    args = ex[1].Split(charSplit);
                                                }
                                                else
                                                {
                                                    args = null;
                                                }
                                                ircbot.controller.run_command(Conf.Server_Name, channel, ex[0], args);
                                            }
                                            else if (events[y].StartsWith("<delay>") == true)
                                            {
                                                Thread.Sleep(Convert.ToInt32(events[y].Remove(0, 7)));
                                            }
                                            else
                                            {
                                                ircbot.sendData("PRIVMSG", channel + " :" + events[y]);
                                            }
                                        }
                                        break;
                                    }
                                }
                            }
                        }
                    }
                    else
                    {
                        if (!Directory.Exists(ircbot.cur_dir + Path.DirectorySeparatorChar + "modules" + Path.DirectorySeparatorChar + "Response"))
                        {
                            Directory.CreateDirectory(ircbot.cur_dir + Path.DirectorySeparatorChar + "modules" + Path.DirectorySeparatorChar + "Response");
                        }
                        File.Create(list_file);
                    }
                }
            }
        }
コード例 #10
0
        public async Task <ActionResult <GenericResponse <IReadOnlyDictionary <string, bool> > > > BotPost(string botNames, [FromBody] BotRequest request)
        {
            if (string.IsNullOrEmpty(botNames) || (request == null))
            {
                ASF.ArchiLogger.LogNullError(nameof(botNames) + " || " + nameof(request));

                return(BadRequest(new GenericResponse <IReadOnlyDictionary <string, bool> >(false, string.Format(Strings.ErrorIsEmpty, nameof(botNames) + " || " + nameof(request)))));
            }

            (bool valid, string errorMessage) = request.BotConfig.CheckValidation();

            if (!valid)
            {
                return(BadRequest(new GenericResponse <IReadOnlyDictionary <string, bool> >(false, errorMessage)));
            }

            request.BotConfig.ShouldSerializeEverything       = false;
            request.BotConfig.ShouldSerializeHelperProperties = false;

            HashSet <string> bots = botNames.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries).Where(botName => botName != SharedInfo.ASF).ToHashSet();

            Dictionary <string, bool> result = new Dictionary <string, bool>(bots.Count);

            foreach (string botName in bots)
            {
                if (Bot.Bots.TryGetValue(botName, out Bot bot))
                {
                    if (!request.BotConfig.IsSteamLoginSet && bot.BotConfig.IsSteamLoginSet)
                    {
                        request.BotConfig.SteamLogin = bot.BotConfig.SteamLogin;
                    }

                    if (!request.BotConfig.IsSteamPasswordSet && bot.BotConfig.IsSteamPasswordSet)
                    {
                        request.BotConfig.DecryptedSteamPassword = bot.BotConfig.DecryptedSteamPassword;
                    }

                    if (!request.BotConfig.IsSteamParentalCodeSet && bot.BotConfig.IsSteamParentalCodeSet)
                    {
                        request.BotConfig.SteamParentalCode = bot.BotConfig.SteamParentalCode;
                    }

                    if ((bot.BotConfig.AdditionalProperties != null) && (bot.BotConfig.AdditionalProperties.Count > 0))
                    {
                        if (request.BotConfig.AdditionalProperties == null)
                        {
                            request.BotConfig.AdditionalProperties = new Dictionary <string, JToken>(bot.BotConfig.AdditionalProperties.Count);
                        }

                        foreach ((string key, JToken value) in bot.BotConfig.AdditionalProperties.Where(property => !request.BotConfig.AdditionalProperties.ContainsKey(property.Key)))
                        {
                            request.BotConfig.AdditionalProperties.Add(key, value);
                        }

                        request.BotConfig.AdditionalProperties.TrimExcess();
                    }
                }

                string filePath = Bot.GetFilePath(botName, Bot.EFileType.Config);

                if (string.IsNullOrEmpty(filePath))
                {
                    ASF.ArchiLogger.LogNullError(filePath);

                    return(BadRequest(new GenericResponse <IReadOnlyDictionary <string, bool> >(false, string.Format(Strings.ErrorIsInvalid, nameof(filePath)))));
                }

                result[botName] = await BotConfig.Write(filePath, request.BotConfig).ConfigureAwait(false);
            }

            return(Ok(new GenericResponse <IReadOnlyDictionary <string, bool> >(result.Values.All(value => value), result)));
        }
コード例 #11
0
ファイル: quote.cs プロジェクト: uncled1023/IRCBot
 private static void get_quote(string channel, bot ircbot, BotConfig Conf)
 {
     string tab_name = channel.TrimStart('#');
     string pattern = "[^a-zA-Z0-9]"; //regex pattern
     tab_name = Regex.Replace(tab_name, pattern, "_");
     string file_name = ircbot.Conf.Server_Name + "_#" + tab_name + ".log";
     if (File.Exists(ircbot.cur_dir + Path.DirectorySeparatorChar + "modules" + Path.DirectorySeparatorChar + "quotes" + Path.DirectorySeparatorChar + "logs" + Path.DirectorySeparatorChar + file_name))
     {
         string[] log_file = System.IO.File.ReadAllLines(ircbot.cur_dir + Path.DirectorySeparatorChar + "modules" + Path.DirectorySeparatorChar + "quotes" + Path.DirectorySeparatorChar + "logs" + Path.DirectorySeparatorChar + file_name);
         int number_of_lines = log_file.GetUpperBound(0) + 1;
         if (number_of_lines > 0)
         {
             string line = "";
             Random random = new Random();
             int index = random.Next(0, number_of_lines);
             line = log_file[index];
             if (!String.IsNullOrEmpty(line))
             {
                 char[] charSep = new char[] { '*' };
                 string[] lines = line.Split(charSep, 2);
                 ircbot.sendData("PRIVMSG", channel + " :" + lines[1] + " [" + lines[0] + "]");
             }
             else
             {
                 ircbot.sendData("PRIVMSG", channel + " :There was an issue getting logs for " + channel);
             }
         }
         else
         {
             ircbot.sendData("PRIVMSG", channel + " :There are currently no logs for " + channel);
         }
     }
     else
     {
         ircbot.sendData("PRIVMSG", channel + " :There are currently no logs for " + channel);
     }
 }
コード例 #12
0
        public async Task <ActionResult <GenericResponse> > BotPost(string botNames, [FromBody] BotRequest request)
        {
            if (string.IsNullOrEmpty(botNames))
            {
                throw new ArgumentNullException(nameof(botNames));
            }

            if (request == null)
            {
                throw new ArgumentNullException(nameof(request));
            }

            if (Bot.Bots == null)
            {
                throw new InvalidOperationException(nameof(Bot.Bots));
            }

            (bool valid, string?errorMessage) = request.BotConfig.CheckValidation();

            if (!valid)
            {
                return(BadRequest(new GenericResponse(false, errorMessage)));
            }

            request.BotConfig.ShouldSerializeDefaultValues    = false;
            request.BotConfig.ShouldSerializeHelperProperties = false;
            request.BotConfig.ShouldSerializeSensitiveDetails = true;

            HashSet <string> bots = botNames.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries).ToHashSet(Bot.BotsComparer);

            if (bots.Any(botName => !ASF.IsValidBotName(botName)))
            {
                return(BadRequest(new GenericResponse(false, string.Format(CultureInfo.CurrentCulture, Strings.ErrorIsInvalid, nameof(botNames)))));
            }

            Dictionary <string, bool> result = new(bots.Count, Bot.BotsComparer);

            foreach (string botName in bots)
            {
                if (Bot.Bots.TryGetValue(botName, out Bot? bot))
                {
                    if (!request.BotConfig.IsSteamLoginSet && bot.BotConfig.IsSteamLoginSet)
                    {
                        request.BotConfig.SteamLogin = bot.BotConfig.SteamLogin;
                    }

                    if (!request.BotConfig.IsSteamPasswordSet && bot.BotConfig.IsSteamPasswordSet)
                    {
                        request.BotConfig.DecryptedSteamPassword = bot.BotConfig.DecryptedSteamPassword;
                    }

                    if (!request.BotConfig.IsSteamParentalCodeSet && bot.BotConfig.IsSteamParentalCodeSet)
                    {
                        request.BotConfig.SteamParentalCode = bot.BotConfig.SteamParentalCode;
                    }

                    if (bot.BotConfig.AdditionalProperties?.Count > 0)
                    {
                        request.BotConfig.AdditionalProperties ??= new Dictionary <string, JToken>(bot.BotConfig.AdditionalProperties.Count, bot.BotConfig.AdditionalProperties.Comparer);

                        foreach ((string key, JToken value) in bot.BotConfig.AdditionalProperties.Where(property => !request.BotConfig.AdditionalProperties.ContainsKey(property.Key)))
                        {
                            request.BotConfig.AdditionalProperties.Add(key, value);
                        }

                        request.BotConfig.AdditionalProperties.TrimExcess();
                    }
                }

                string filePath = Bot.GetFilePath(botName, Bot.EFileType.Config);

                if (string.IsNullOrEmpty(filePath))
                {
                    ASF.ArchiLogger.LogNullError(filePath);

                    return(BadRequest(new GenericResponse(false, string.Format(CultureInfo.CurrentCulture, Strings.ErrorIsInvalid, nameof(filePath)))));
                }

                result[botName] = await BotConfig.Write(filePath, request.BotConfig).ConfigureAwait(false);
            }

            return(Ok(new GenericResponse <IReadOnlyDictionary <string, bool> >(result.Values.All(value => value), result)));
        }
コード例 #13
0
ファイル: fun.cs プロジェクト: uncled1023/IRCBot
 public override void control(bot ircbot, BotConfig Conf, string[] line, string command, int nick_access, string nick, string channel, bool bot_command, string type)
 {
     if ((type.Equals("channel") || type.Equals("query")) && bot_command == true)
     {
         foreach (Command tmp_command in this.Commands)
         {
             bool blocked = tmp_command.Blacklist.Contains(channel) || tmp_command.Blacklist.Contains(nick);
             bool cmd_found = false;
             bool spam_check = ircbot.get_spam_check(channel, nick, tmp_command.Spam_Check);
             if (spam_check == true)
             {
                 blocked = blocked || ircbot.get_spam_status(channel);
             }
             cmd_found = tmp_command.Triggers.Contains(command);
             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 tmp_command.Triggers)
                 {
                     switch (trigger)
                     {
                         case "love":
                             if (spam_check == true)
                             {
                                 ircbot.add_spam_count(channel);
                             }
                             if (nick_access >= tmp_command.Access)
                             {
                                 if (line.GetUpperBound(0) > 3)
                                 {
                                     Random random = new Random();
                                     int ran_num = random.Next(0, 3);
                                     switch (ran_num)
                                     {
                                         case 0:
                                             ircbot.sendData("PRIVMSG", channel + " :\u0001ACTION Gently makes love to " + line[4] + "\u0001");
                                             break;
                                         case 1:
                                             ircbot.sendData("PRIVMSG", channel + " :\u0001ACTION sings a love ballad to " + line[4] + "\u0001");
                                             break;
                                         case 2:
                                             ircbot.sendData("PRIVMSG", channel + " :\u0001ACTION slowly sneaks up behind " + line[4] + "\u0001");
                                             ircbot.sendData("PRIVMSG", channel + " :\u0001ACTION squeezes " + line[4] + " tightly\u0001");
                                             ircbot.sendData("PRIVMSG", line[4] + " :I'll give you some more later tonight.  ;)");
                                             break;
                                         case 3:
                                             ircbot.sendData("PRIVMSG", channel + " :I love you " + line[4] + "!  Sooo much!");
                                             break;
                                     }
                                 }
                                 else
                                 {
                                     ircbot.sendData("PRIVMSG", channel + " :" + nick + ", you need to include more info.");
                                 }
                             }
                             else
                             {
                                 ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command.");
                             }
                             break;
                         case "hug":
                             if (spam_check == true)
                             {
                                 ircbot.add_spam_count(channel);
                             }
                             if (nick_access >= tmp_command.Access)
                             {
                                 if (line.GetUpperBound(0) > 3)
                                 {
                                     ircbot.sendData("PRIVMSG", channel + " :\u0001ACTION hugs " + line[4] + "\u0001");
                                 }
                                 else
                                 {
                                     ircbot.sendData("PRIVMSG", channel + " :\u0001ACTION hugs " + nick + "\u0001");
                                 }
                             }
                             else
                             {
                                 ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command.");
                             }
                             break;
                         case "slap":
                             if (spam_check == true)
                             {
                                 ircbot.add_spam_count(channel);
                             }
                             if (nick_access >= tmp_command.Access)
                             {
                                 if (line.GetUpperBound(0) > 3)
                                 {
                                     ircbot.sendData("PRIVMSG", channel + " :\u0001ACTION slaps " + line[4] + " with a large trout\u0001");
                                 }
                                 else
                                 {
                                     ircbot.sendData("PRIVMSG", channel + " :\u0001ACTION slaps " + nick + " with a large trout\u0001");
                                 }
                             }
                             else
                             {
                                 ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command.");
                             }
                             break;
                         case "bots":
                             if (spam_check == true)
                             {
                                 ircbot.add_spam_count(channel);
                             }
                             if (nick_access >= tmp_command.Access)
                             {
                                 ircbot.sendData("PRIVMSG", channel + " :Reporting in!");
                             }
                             else
                             {
                                 ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command.");
                             }
                             break;
                         case "br":
                             if (spam_check == true)
                             {
                                 ircbot.add_spam_count(channel);
                             }
                             if (nick_access >= tmp_command.Access)
                             {
                                 ircbot.sendData("PRIVMSG", channel + " :HUEHUEHUE");
                             }
                             else
                             {
                                 ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command.");
                             }
                             break;
                         case "net":
                             if (spam_check == true)
                             {
                                 ircbot.add_spam_count(channel);
                             }
                             if (nick_access >= tmp_command.Access)
                             {
                                 ircbot.sendData("PRIVMSG", channel + " :Sure is enterprise quality in here");
                             }
                             else
                             {
                                 ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command.");
                             }
                             break;
                     }
                 }
             }
         }
     }
 }
コード例 #14
0
ファイル: owner.cs プロジェクト: uncled1023/IRCBot
        public override void control(bot ircbot, BotConfig Conf, string[] line, string command, int nick_access, string nick, string channel, bool bot_command, string type)
        {
            char[] charS = new char[] { ' ' };
            if ((type.Equals("channel") || type.Equals("query")) && bot_command == true)
            {
                foreach (Command tmp_command in this.Commands)
                {
                    bool blocked = tmp_command.Blacklist.Contains(channel) || tmp_command.Blacklist.Contains(nick);
                    bool cmd_found = false;
                    bool spam_check = ircbot.get_spam_check(channel, nick, tmp_command.Spam_Check);
                    if (spam_check == true)
                    {
                        blocked = blocked || ircbot.get_spam_status(channel);
                    }
                    cmd_found = tmp_command.Triggers.Contains(command);
                    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 tmp_command.Triggers)
                        {
                            switch (trigger)
                            {
                                case "owner":
                                    if (spam_check == true)
                                    {
                                        ircbot.add_spam_count(channel);
                                    }
                                    if (nick_access >= tmp_command.Access)
                                    {
                                        if (line.GetUpperBound(0) > 3)
                                        {
                                            if (line[4].Equals(Conf.Pass))
                                            {
                                                add_owner(nick, ircbot, Conf);
                                                ircbot.sendData("NOTICE", nick + " :You are now identified as an owner!");
                                            }
                                            else
                                            {
                                                ircbot.sendData("NOTICE", nick + " :Invalid Password");
                                            }
                                        }
                                        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 "addowner":
                                    if (spam_check == true)
                                    {
                                        ircbot.add_spam_count(channel);
                                    }
                                    if (nick_access >= tmp_command.Access)
                                    {
                                        if (line.GetUpperBound(0) > 3)
                                        {
                                            add_owner(line[4], ircbot, Conf);
                                            ircbot.sendData("NOTICE", nick + " :" + line[4] + " has been added as an owner.");
                                        }
                                        else
                                        {
                                            ircbot.sendData("NOTICE", nick + " :You need to include more info.");
                                        }
                                    }
                                    else
                                    {
                                        ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command.");
                                    }
                                    break;
                                case "delowner":
                                    if (spam_check == true)
                                    {
                                        ircbot.add_spam_count(channel);
                                    }
                                    if (nick_access >= tmp_command.Access)
                                    {
                                        if (line.GetUpperBound(0) > 3)
                                        {
                                            del_owner(line[4], ircbot, Conf);
                                            ircbot.sendData("NOTICE", nick + " :" + line[4] + " has been removed as an owner.");
                                        }
                                        else
                                        {
                                            ircbot.sendData("NOTICE", nick + " :You need to include more info.");
                                        }
                                    }
                                    else
                                    {
                                        ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command.");
                                    }
                                    break;
                                case "nick":
                                    if (spam_check == true)
                                    {
                                        ircbot.add_spam_count(channel);
                                    }
                                    if (nick_access >= tmp_command.Access)
                                    {
                                        if (line.GetUpperBound(0) > 3)
                                        {
                                            ircbot.sendData("NICK", line[4]);
                                            ircbot.Nick = line[4];
                                        }
                                        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 "id":
                                    if (spam_check == true)
                                    {
                                        ircbot.add_spam_count(channel);
                                    }
                                    if (nick_access >= tmp_command.Access)
                                    {
                                        ircbot.sendData("PRIVMSG", "NickServ :Identify " + Conf.Pass);
                                        ircbot.sendData("NOTICE", nick + " :I have identified.");
                                    }
                                    else
                                    {
                                        ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command.");
                                    }
                                    break;
                                case "join":
                                    if (spam_check == true)
                                    {
                                        ircbot.add_spam_count(channel);
                                    }
                                    if (nick_access >= tmp_command.Access)
                                    {
                                        if (line.GetUpperBound(0) > 3)
                                        {
                                            string[] chan_list = line[4].Replace(' ', ',').Split(',');
                                            foreach (string chan in chan_list)
                                            {
                                                ircbot.sendData("JOIN", chan);
                                            }
                                        }
                                        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 "part":
                                    if (spam_check == true)
                                    {
                                        ircbot.add_spam_count(channel);
                                    }
                                    if (nick_access >= tmp_command.Access)
                                    {
                                        if (line.GetUpperBound(0) > 3)
                                        {
                                            string[] channels = line[4].Split(' ');
                                            bool chan_found = false;
                                            foreach (string tmp_chan in channels)
                                            {
                                                Channel_Info chan_info = ircbot.get_chan_info(tmp_chan);
                                                if (chan_info != null)
                                                {
                                                    chan_found = true;
                                                    ircbot.sendData("PART", tmp_chan);
                                                    ircbot.del_chan_info(tmp_chan);
                                                }
                                            }
                                            if (chan_found == false)
                                            {
                                                ircbot.sendData("NOTICE", nick + " :I am not in that channel.");
                                            }
                                        }
                                        else if (type.Equals("channel"))
                                        {
                                            Channel_Info chan_info = ircbot.get_chan_info(channel);
                                            if (chan_info != null)
                                            {
                                                ircbot.sendData("PART", channel);
                                                ircbot.del_chan_info(channel);
                                            }
                                            else
                                            {
                                                ircbot.sendData("NOTICE", nick + " :I am not in that channel.");
                                            }
                                        }
                                        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 "say":
                                    if (spam_check == true)
                                    {
                                        ircbot.add_spam_count(channel);
                                    }
                                    if (nick_access >= tmp_command.Access)
                                    {
                                        if (line.GetUpperBound(0) > 3)
                                        {
                                            string[] new_line = line[4].Split(charS, 2);
                                            if (new_line[0].StartsWith("#") == true && new_line.GetUpperBound(0) > 0)
                                            {
                                                ircbot.sendData("PRIVMSG", new_line[0] + " :" + new_line[1]);
                                            }
                                            else
                                            {
                                                ircbot.sendData("PRIVMSG", channel + " :" + line[4]);
                                            }
                                        }
                                        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 "action":
                                    if (spam_check == true)
                                    {
                                        ircbot.add_spam_count(channel);
                                    }
                                    if (nick_access >= tmp_command.Access)
                                    {
                                        if (line.GetUpperBound(0) > 3)
                                        {
                                            string[] new_line = line[4].Split(charS, 2);
                                            if (new_line[0].StartsWith("#") == true && new_line.GetUpperBound(0) > 0)
                                            {
                                                ircbot.sendData("PRIVMSG", new_line[0] + " :\u0001ACTION " + new_line[1] + "\u0001");
                                            }
                                            else
                                            {
                                                ircbot.sendData("PRIVMSG", channel + " :\u0001ACTION " + line[4] + "\u0001");
                                            }
                                        }
                                        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 "query":
                                    if (spam_check == true)
                                    {
                                        ircbot.add_spam_count(channel);
                                    }
                                    if (nick_access >= tmp_command.Access)
                                    {
                                        if (line.GetUpperBound(0) > 3)
                                        {
                                            string[] new_line = line[4].Split(charS, 2);
                                            if (new_line.GetUpperBound(0) > 0)
                                            {
                                                ircbot.sendData("PRIVMSG", new_line[0] + " :" + new_line[1]);
                                            }
                                            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 "quit":
                                    if (spam_check == true)
                                    {
                                        ircbot.add_spam_count(channel);
                                    }
                                    if (nick_access >= tmp_command.Access)
                                    {
                                        if (line.GetUpperBound(0) <= 3)
                                        {
                                            ircbot.sendData("QUIT", "Leaving");
                                        }
                                        else
                                        {
                                            ircbot.sendData("QUIT", ":" + line[4]); //if the command is quit, send the QUIT command to the server with a quit message
                                        }
                                        ircbot.worker.CancelAsync();
                                    }
                                    else
                                    {
                                        ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command.");
                                    }
                                    break;
                                case "quitall":
                                    if (spam_check == true)
                                    {
                                        ircbot.add_spam_count(channel);
                                    }
                                    if (nick_access >= tmp_command.Access)
                                    {
                                        foreach (var bot in ircbot.controller.bot_instances)
                                        {
                                            if (line.GetUpperBound(0) <= 3)
                                            {
                                                bot.sendData("QUIT", "Leaving");
                                            }
                                            else
                                            {
                                                bot.sendData("QUIT", ":" + line[4]);
                                            }
                                            bot.worker.CancelAsync();
                                        }
                                    }
                                    else
                                    {
                                        ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command.");
                                    }
                                    break;
                                case "cycle":
                                    if (spam_check == true)
                                    {
                                        ircbot.add_spam_count(channel);
                                    }
                                    if (nick_access >= tmp_command.Access)
                                    {
                                        ircbot.restart = true;
                                        ircbot.worker.CancelAsync();
                                    }
                                    else
                                    {
                                        ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command.");
                                    }
                                    break;
                                case "cycleall":
                                    if (spam_check == true)
                                    {
                                        ircbot.add_spam_count(channel);
                                    }
                                    if (nick_access >= tmp_command.Access)
                                    {
                                        foreach (var bot in ircbot.controller.bot_instances)
                                        {
                                            bot.restart = true;
                                            bot.worker.CancelAsync();
                                        }
                                    }
                                    else
                                    {
                                        ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command.");
                                    }
                                    break;
                                case "exit":
                                    if (spam_check == true)
                                    {
                                        ircbot.add_spam_count(channel);
                                    }
                                    if (nick_access >= tmp_command.Access)
                                    {
                                        Environment.Exit(0);
                                    }
                                    else
                                    {
                                        ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command.");
                                    }
                                    break;
                                case "restart":
                                    if (spam_check == true)
                                    {
                                        ircbot.add_spam_count(channel);
                                    }
                                    if (nick_access >= tmp_command.Access)
                                    {
                                        System.Diagnostics.Process.Start(Assembly.GetEntryAssembly().Location); // to start new instance of application
                                        Environment.Exit(0);
                                    }
                                    else
                                    {
                                        ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command.");
                                    }
                                    break;
                                case "ignore":
                                    if (spam_check == true)
                                    {
                                        ircbot.add_spam_count(channel);
                                    }
                                    if (nick_access >= tmp_command.Access)
                                    {
                                        if (line.GetUpperBound(0) > 3)
                                        {
                                            ignore(line[4], nick, ircbot, Conf);
                                        }
                                        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 "unignore":
                                    if (spam_check == true)
                                    {
                                        ircbot.add_spam_count(channel);
                                    }
                                    if (nick_access >= tmp_command.Access)
                                    {
                                        if (line.GetUpperBound(0) > 3)
                                        {
                                            unignore(line[4], nick, ircbot, Conf);
                                        }
                                        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 "ignorecmd":
                                    if (spam_check == true)
                                    {
                                        ircbot.add_spam_count(channel);
                                    }
                                    if (nick_access >= tmp_command.Access)
                                    {
                                        if (line.GetUpperBound(0) > 3)
                                        {
                                            string[] new_line = line[4].Split(charS, 2);
                                            if (new_line.GetUpperBound(0) > 0)
                                            {
                                                ignorecmd(new_line[0], new_line[1], nick, ircbot, Conf);
                                            }
                                            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 "unignorecmd":
                                    if (spam_check == true)
                                    {
                                        ircbot.add_spam_count(channel);
                                    }
                                    if (nick_access >= tmp_command.Access)
                                    {
                                        if (line.GetUpperBound(0) > 3)
                                        {
                                            string[] new_line = line[4].Split(charS, 2);
                                            if (new_line.GetUpperBound(0) > 0)
                                            {
                                                unignorecmd(new_line[0], new_line[1], nick, ircbot, Conf);
                                            }
                                            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 "ignoremodule":
                                    if (spam_check == true)
                                    {
                                        ircbot.add_spam_count(channel);
                                    }
                                    if (nick_access >= tmp_command.Access)
                                    {
                                        if (line.GetUpperBound(0) > 3)
                                        {
                                            string[] new_line = line[4].Split(charS, 2);
                                            if (new_line.GetUpperBound(0) > 0)
                                            {
                                                ignoremodule(new_line[0], new_line[1], nick, ircbot, Conf);
                                            }
                                            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 "unignoremodule":
                                    if (spam_check == true)
                                    {
                                        ircbot.add_spam_count(channel);
                                    }
                                    if (nick_access >= tmp_command.Access)
                                    {
                                        if (line.GetUpperBound(0) > 3)
                                        {
                                            string[] new_line = line[4].Split(charS, 2);
                                            if (new_line.GetUpperBound(0) > 0)
                                            {
                                                unignoremodule(new_line[0], new_line[1], nick, ircbot, Conf);
                                            }
                                            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 "blacklist":
                                    if (spam_check == true)
                                    {
                                        ircbot.add_spam_count(channel);
                                    }
                                    if (nick_access >= tmp_command.Access)
                                    {
                                        if (line.GetUpperBound(0) > 3)
                                        {
                                            add_blacklist(line[4], nick, ircbot, Conf);
                                        }
                                        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 "unblacklist":
                                    if (spam_check == true)
                                    {
                                        ircbot.add_spam_count(channel);
                                    }
                                    if (nick_access >= tmp_command.Access)
                                    {
                                        if (line.GetUpperBound(0) > 3)
                                        {
                                            unblacklist(line[4], nick, ircbot, Conf);
                                        }
                                        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 "update":
                                    if (spam_check == true)
                                    {
                                        ircbot.add_spam_count(channel);
                                    }
                                    if (nick_access >= tmp_command.Access)
                                    {
                                        ircbot.controller.update_conf();
                                    }
                                    else
                                    {
                                        ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command.");
                                    }
                                    break;
                                case "modules":
                                    if (spam_check == true)
                                    {
                                        ircbot.add_spam_count(channel);
                                    }
                                    if (nick_access >= tmp_command.Access)
                                    {
                                        string msg = "";
                                        foreach (Module module in ircbot.Conf.Modules)
                                        {
                                            msg += ", " + module.ToString().Remove(0, 12);
                                        }
                                        if (!String.IsNullOrEmpty(msg))
                                        {
                                            ircbot.sendData("NOTICE", nick + " :" + msg.TrimStart(',').Trim());
                                        }
                                        else
                                        {
                                            ircbot.sendData("NOTICE", nick + " :No Modules are loaded.");
                                        }
                                    }
                                    else
                                    {
                                        ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command.");
                                    }
                                    break;
                                case "loadmodule":
                                    if (spam_check == true)
                                    {
                                        ircbot.add_spam_count(channel);
                                    }
                                    if (nick_access >= tmp_command.Access)
                                    {
                                        if (line.GetUpperBound(0) > 3)
                                        {
                                            bool module_found = ircbot.load_module(line[4]);
                                            if (module_found == true)
                                            {
                                                if (type.Equals("channel"))
                                                {
                                                    ircbot.sendData("PRIVMSG", channel + " :Module Loaded Successfully");
                                                }
                                                else
                                                {
                                                    ircbot.sendData("NOTICE", nick + " :Module Loaded Successfully");
                                                }
                                            }
                                            else
                                            {
                                                if (type.Equals("channel"))
                                                {
                                                    ircbot.sendData("PRIVMSG", channel + " :Error loading Module");
                                                }
                                                else
                                                {
                                                    ircbot.sendData("NOTICE", nick + " :Error loading Module");
                                                }
                                            }
                                        }
                                        else
                                        {
                                            if (type.Equals("channel"))
                                            {
                                                ircbot.sendData("PRIVMSG", channel + " :" + 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 "delmodule":
                                    if (spam_check == true)
                                    {
                                        ircbot.add_spam_count(channel);
                                    }
                                    if (nick_access >= tmp_command.Access)
                                    {

                                        if (line.GetUpperBound(0) > 3)
                                        {
                                            bool module_found = ircbot.unload_module(line[4]);
                                            if (module_found == true)
                                            {
                                                if (type.Equals("channel"))
                                                {
                                                    ircbot.sendData("PRIVMSG", channel + " :Module Unloaded Successfully");
                                                }
                                                else
                                                {
                                                    ircbot.sendData("NOTICE", nick + " :Module Unloaded Successfully");
                                                }
                                            }
                                            else
                                            {
                                                if (type.Equals("channel"))
                                                {
                                                    ircbot.sendData("PRIVMSG", channel + " :No Module found");
                                                }
                                                else
                                                {
                                                    ircbot.sendData("NOTICE", nick + " :No Module found");
                                                }
                                            }
                                        }
                                        else
                                        {
                                            if (type.Equals("channel"))
                                            {
                                                ircbot.sendData("PRIVMSG", channel + " :" + 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 "addchan":
                                    if (spam_check == true)
                                    {
                                        ircbot.add_spam_count(channel);
                                    }
                                    if (nick_access >= tmp_command.Access)
                                    {
                                        if (line.GetUpperBound(0) > 3)
                                        {
                                            bool chan_allowed = true;
                                            foreach (string chan in ircbot.Conf.Chan_Blacklist.Split(','))
                                            {
                                                if (chan.Equals(line[4]))
                                                {
                                                    chan_allowed = false;
                                                    break;
                                                }
                                            }
                                            if (chan_allowed == true)
                                            {
                                                Channel_Info chan_info = ircbot.get_chan_info(line[4]);
                                                if (chan_info == null)
                                                {
                                                    if (nick_access != Conf.Owner_Level)
                                                    {
                                                        foreach (string owner_nick in Conf.Owners)
                                                        {
                                                            ircbot.sendData("NOTICE", owner_nick + " :" + nick + " has invited me to join " + line[4]);
                                                            ircbot.sendData("NOTICE", owner_nick + " :If you would like to permanently add this channel, please type " + ircbot.Conf.Command + "addchanlist " + line[4]);
                                                        }
                                                    }
                                                    ircbot.sendData("JOIN", line[4]);
                                                }
                                                else
                                                {
                                                    ircbot.sendData("NOTICE", nick + " :I'm already in that channel!");
                                                }
                                            }
                                            else
                                            {
                                                ircbot.sendData("NOTICE", nick + " :I am not allowed to join that channel.");
                                            }
                                        }
                                        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 "addchanlist":
                                    if (spam_check == true)
                                    {
                                        ircbot.add_spam_count(channel);
                                    }
                                    if (nick_access >= tmp_command.Access)
                                    {
                                        if (line.GetUpperBound(0) > 3)
                                        {
                                            Channel_Info chan_info = ircbot.get_chan_info(line[4]);
                                            if (chan_info == null)
                                            {
                                                ircbot.sendData("JOIN", line[4]);
                                            }
                                            add_channel_list(line[4], ircbot, Conf);
                                            ircbot.sendData("NOTICE", nick + " :" + line[4] + " successfully added to auto-join list.");
                                        }
                                        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 "delchanlist":
                                    if (spam_check == true)
                                    {
                                        ircbot.add_spam_count(channel);
                                    }
                                    if (nick_access >= tmp_command.Access)
                                    {
                                        if (line.GetUpperBound(0) > 3)
                                        {
                                            del_channel_list(line[4], ircbot, Conf);
                                            ircbot.sendData("NOTICE", nick + " :" + line[4] + " successfully removed from auto-join list.");
                                        }
                                        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 "nicklist":
                                    if (spam_check == true)
                                    {
                                        ircbot.add_spam_count(channel);
                                    }
                                    if (nick_access >= tmp_command.Access)
                                    {
                                        if (type.Equals("channel"))
                                        {
                                            if (line.GetUpperBound(0) > 3)
                                            {
                                                bool nick_found = false;
                                                string nick_list = "";
                                                Channel_Info chan_info = ircbot.get_chan_info(line[4]);
                                                if (chan_info != null)
                                                {
                                                    foreach (Nick_Info nick_info in chan_info.Nicks)
                                                    {
                                                        nick_list += nick_info.Nick + ", ";
                                                        nick_found = true;
                                                    }
                                                }
                                                if (nick_found)
                                                {
                                                    ircbot.sendData("NOTICE", nick + " :" + line[4] + ": " + nick_list.Trim().TrimEnd(','));
                                                }
                                                else
                                                {
                                                    ircbot.sendData("NOTICE", nick + " :No nicks in " + line[4]);
                                                }
                                            }
                                            else
                                            {
                                                bool nick_found = false;
                                                string nick_list = "";
                                                Channel_Info chan_info = ircbot.get_chan_info(channel);
                                                if (chan_info != null)
                                                {
                                                    foreach (Nick_Info nick_info in chan_info.Nicks)
                                                    {
                                                        nick_list += nick_info.Nick + ", ";
                                                        nick_found = true;
                                                    }
                                                }
                                                if (nick_found)
                                                {
                                                    ircbot.sendData("NOTICE", nick + " :" + channel + ": " + nick_list.Trim().TrimEnd(','));
                                                }
                                                else
                                                {
                                                    ircbot.sendData("NOTICE", nick + " :No nicks in " + channel);
                                                }
                                            }
                                        }
                                        else
                                        {
                                            if (line.GetUpperBound(0) > 3)
                                            {
                                                bool nick_found = false;
                                                string nick_list = "";
                                                Channel_Info chan_info = ircbot.get_chan_info(line[4]);
                                                if (chan_info != null)
                                                {
                                                    foreach (Nick_Info nick_info in chan_info.Nicks)
                                                    {
                                                        nick_list += nick_info.Nick + ", ";
                                                        nick_found = true;
                                                    }
                                                }
                                                if (nick_found)
                                                {
                                                    ircbot.sendData("NOTICE", nick + " :" + line[4] + ": " + nick_list.Trim().TrimEnd(','));
                                                }
                                                else
                                                {
                                                    ircbot.sendData("NOTICE", nick + " :No nicks in " + line[4]);
                                                }
                                            }
                                            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 "channels":
                                    if (spam_check == true)
                                    {
                                        ircbot.add_spam_count(channel);
                                    }
                                    if (nick_access >= tmp_command.Access)
                                    {
                                        bool chan_found = false;
                                        string chan_list = "";
                                        foreach (Channel_Info chan_info in ircbot.Conf.Channel_List)
                                        {
                                            if (!this.Options["hide_private"] || nick_access == Conf.Owner_Level) // if "hide on private/secret" is false
                                            {
                                                chan_list += chan_info.Channel + ", ";
                                                chan_found = true;
                                            }
                                            else
                                            {
                                                if (chan_info.Show || ircbot.get_nick_info(nick, chan_info.Channel) != null)
                                                {
                                                    chan_list += chan_info.Channel + ", ";
                                                    chan_found = true;
                                                }
                                            }
                                        }
                                        if (chan_found == true)
                                        {
                                            if (type.Equals("channel"))
                                            {
                                                if (nick_access == Conf.Owner_Level)
                                                {
                                                    ircbot.sendData("NOTICE", nick + " :I am currently in the following channels: " + chan_list.Trim().TrimEnd(','));
                                                }
                                                else
                                                {
                                                    ircbot.sendData("PRIVMSG", channel + " :I am currently in the following channels: " + chan_list.Trim().TrimEnd(','));
                                                }
                                            }
                                            else
                                            {
                                                ircbot.sendData("NOTICE", nick + " :I am currently in the following channels: " + chan_list.Trim().TrimEnd(','));
                                            }
                                        }
                                        else
                                        {
                                            if (type.Equals("channel"))
                                            {
                                                ircbot.sendData("PRIVMSG", channel + " :I'm in no channels.");
                                            }
                                            else
                                            {
                                                ircbot.sendData("NOTICE", nick + " :I'm in no channels.");
                                            }
                                        }
                                    }
                                    else
                                    {
                                        ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command.");
                                    }
                                    break;
                                case "servers":
                                    if (spam_check == true)
                                    {
                                        ircbot.add_spam_count(channel);
                                    }
                                    if (nick_access >= tmp_command.Access)
                                    {
                                        string server_list = "";
                                        foreach (bot bot in ircbot.controller.bot_instances)
                                        {
                                            if (bot.connected)
                                            {
                                                server_list += bot.Conf.Server_Address + ", ";
                                            }
                                        }
                                        if (type.Equals("channel"))
                                        {
                                            ircbot.sendData("PRIVMSG", channel + " :I am currently in the following servers: " + server_list.Trim().TrimEnd(','));
                                        }
                                        else
                                        {
                                            ircbot.sendData("NOTICE", nick + " :I am currently in the following servers: " + server_list.Trim().TrimEnd(','));
                                        }
                                    }
                                    else
                                    {
                                        ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command.");
                                    }
                                    break;
                                case "conf":
                                    if (spam_check == true)
                                    {
                                        ircbot.add_spam_count(channel);
                                    }
                                    if (nick_access >= tmp_command.Access)
                                    {
                                        if (line.GetUpperBound(0) > 3)
                                        {
                                            BotConfig myObjectType = new BotConfig();
                                            var fields = myObjectType.GetType().GetFields(BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance);
                                            switch (line[4])
                                            {
                                                case "modules":
                                                    foreach (System.Reflection.FieldInfo info in fields)
                                                    {
                                                        if (info.Name.Equals("modules"))
                                                        {
                                                            List<Bot.Modules.Module> tmp_list = (List<Bot.Modules.Module>)info.GetValue(Conf);
                                                            foreach (Bot.Modules.Module list in tmp_list)
                                                            {
                                                                string msg = "";
                                                                msg += "Class: " + list.Class_Name + " | ";
                                                                msg += "Name: " + list.Name + " | ";
                                                                string blacklist = "";
                                                                foreach (string black in list.Blacklist)
                                                                {
                                                                    blacklist += black + ", ";
                                                                }
                                                                msg += "Blacklist: " + blacklist.Trim().TrimEnd(',') + " | ";
                                                                ircbot.sendData("NOTICE", nick + " :" + msg.Trim().TrimEnd('|').TrimEnd(',').Trim());
                                                            }
                                                        }
                                                    }
                                                    break;
                                                default:
                                                    ircbot.sendData("NOTICE", nick + " :" + nick + ", I do not understand your request.");
                                                    break;
                                            }
                                        }
                                        else
                                        {
                                            BotConfig myObjectType = new BotConfig();
                                            var fields = myObjectType.GetType().GetFields(BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance);
                                            foreach (var info in fields)
                                            {
                                                if (info.GetValue(Conf) == null)
                                                {
                                                    ircbot.sendData("NOTICE", nick + " :" + info.Name + ": NULL");
                                                }
                                                else if (info.GetValue(Conf).ToString().Equals("System.Net.IPAddress[]"))
                                                {
                                                    System.Net.IPAddress[] tmp_list = (System.Net.IPAddress[])info.GetValue(Conf);
                                                    int index = 0;
                                                    foreach (System.Net.IPAddress list in tmp_list)
                                                    {
                                                        ircbot.sendData("NOTICE", nick + " :" + info.Name.Replace("k__BackingField", "") + "[" + index.ToString() + "]: " + list.ToString());
                                                        index++;
                                                    }
                                                }
                                                else if (info.GetValue(Conf).ToString().Equals("System.Collections.Generic.List`1[System.String]"))
                                                {
                                                    List<string> tmp_list = (List<string>)info.GetValue(Conf);
                                                    string response = "";
                                                    if (tmp_list.Count > 1)
                                                    {
                                                        int index = 1;
                                                        foreach (string item in tmp_list)
                                                        {
                                                            response += item;
                                                            if (index < tmp_list.Count)
                                                            {
                                                                response += ", ";
                                                            }
                                                            index++;
                                                        }
                                                    }
                                                    else
                                                    {
                                                        response += tmp_list[0];
                                                    }
                                                    ircbot.sendData("NOTICE", nick + " :" + info.Name + ": " + response);
                                                }
                                                else if (info.Name.Equals("modules"))
                                                {
                                                    List<Bot.Modules.Module> tmp_list = (List<Bot.Modules.Module>)info.GetValue(Conf);
                                                    ircbot.sendData("NOTICE", nick + " :" + info.Name + ": " + tmp_list.Count().ToString());
                                                }
                                                else if (info.Name.Equals("spam_check"))
                                                {
                                                    List<Bot.spam_info> tmp_list = (List<Bot.spam_info>)info.GetValue(Conf);
                                                    ircbot.sendData("NOTICE", nick + " :" + info.Name + ": " + tmp_list.Count().ToString());
                                                }
                                                else if (info.Name.Equals("channel_list"))
                                                {
                                                    List<Bot.Channel_Info> tmp_list = (List<Bot.Channel_Info>)info.GetValue(Conf);
                                                    ircbot.sendData("NOTICE", nick + " :" + info.Name + ": " + tmp_list.Count().ToString());
                                                }
                                                else
                                                {
                                                    ircbot.sendData("NOTICE", nick + " :" + info.Name.Replace("k__BackingField", "") + ": " + info.GetValue(Conf).ToString());
                                                }
                                            }
                                        }
                                    }
                                    else
                                    {
                                        ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command.");
                                    }
                                    break;
                                case "resources":
                                    if (spam_check == true)
                                    {
                                        ircbot.add_spam_count(channel);
                                    }
                                    if (nick_access >= tmp_command.Access)
                                    {
                                        Process currentProcess = System.Diagnostics.Process.GetCurrentProcess();
                                        float totalBytesOfMemoryUsed = (currentProcess.WorkingSet64 / 1024f) / 1024f;
                                        PerformanceCounter pc1 = new PerformanceCounter();
                                        pc1.CategoryName = "Processor";
                                        pc1.CounterName = "% Processor Time";
                                        pc1.InstanceName = "_Total";
                                        pc1.NextValue();
                                        Thread.Sleep(1000);
                                        float totalCPUUsage = pc1.NextValue();
                                        if (type.Equals("channel"))
                                        {
                                            ircbot.sendData("PRIVMSG", channel + " :CPU: " + totalCPUUsage + "%");
                                            ircbot.sendData("PRIVMSG", channel + " :RAM: " + totalBytesOfMemoryUsed + "MB");
                                        }
                                        else
                                        {
                                            ircbot.sendData("NOTICE", nick + " :CPU: " + totalCPUUsage + "%");
                                            ircbot.sendData("NOTICE", nick + " :RAM: " + totalBytesOfMemoryUsed + "MB");
                                        }
                                    }
                                    else
                                    {
                                        ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command.");
                                    }
                                    break;
                                case "clear":
                                    if (spam_check == true)
                                    {
                                        ircbot.add_spam_count(channel);
                                    }
                                    if (nick_access >= tmp_command.Access)
                                    {
                                        if (type.Equals("channel"))
                                        {
                                            if (line.GetUpperBound(0) > 3)
                                            {
                                                Channel_Info chan_info = ircbot.get_chan_info(line[4]);
                                                if (chan_info != null)
                                                {
                                                    foreach (Nick_Info nick_info in chan_info.Nicks)
                                                    {
                                                        if (!nick_info.Nick.Equals(nick, StringComparison.InvariantCultureIgnoreCase) && !nick_info.Nick.Equals(ircbot.Nick, StringComparison.InvariantCultureIgnoreCase))
                                                        {
                                                            ircbot.sendData("KICK", line[4] + " :" + nick_info.Nick);
                                                            Thread.Sleep(100);
                                                        }
                                                    }
                                                }
                                            }
                                            else
                                            {
                                                Channel_Info chan_info = ircbot.get_chan_info(channel);
                                                if (chan_info != null)
                                                {
                                                    foreach (Nick_Info nick_info in chan_info.Nicks)
                                                    {
                                                        if (!nick_info.Nick.Equals(nick, StringComparison.InvariantCultureIgnoreCase) && !nick_info.Nick.Equals(ircbot.Nick, StringComparison.InvariantCultureIgnoreCase))
                                                        {
                                                            ircbot.sendData("KICK", line[4] + " :" + nick_info.Nick);
                                                            Thread.Sleep(100);
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                        else
                                        {
                                            if (line.GetUpperBound(0) > 3)
                                            {
                                                Channel_Info chan_info = ircbot.get_chan_info(line[4]);
                                                if (chan_info != null)
                                                {
                                                    foreach (Nick_Info nick_info in chan_info.Nicks)
                                                    {
                                                        if (!nick_info.Nick.Equals(nick, StringComparison.InvariantCultureIgnoreCase) && !nick_info.Nick.Equals(ircbot.Nick, StringComparison.InvariantCultureIgnoreCase))
                                                        {
                                                            ircbot.sendData("KICK", line[4] + " :" + nick_info.Nick);
                                                            Thread.Sleep(100);
                                                        }
                                                    }
                                                }
                                            }
                                            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;
                            }
                        }
                    }
                }
            }
        }
コード例 #15
0
ファイル: owner.cs プロジェクト: uncled1023/IRCBot
 private static void unignoremodule(string module, string ignore_nick, string nick, bot ircbot, BotConfig Conf)
 {
     XmlDocument xmlDoc = ircbot.controller.get_module_xml(Conf.Server_Name);
     bool module_found_file = false;
     bool module_found_conf = false;
     XmlNode Serverxn = xmlDoc.SelectSingleNode("/modules");
     XmlNodeList ServerxnList = Serverxn.ChildNodes;
     foreach (XmlNode xn in ServerxnList)
     {
         if (xn["class_name"].InnerText.Equals(module))
         {
             string new_ignore = "";
             foreach (string list_ignore in xn["blacklist"].InnerText.Split(','))
             {
                 if (!list_ignore.Equals(ignore_nick, StringComparison.InvariantCultureIgnoreCase))
                 {
                     new_ignore += list_ignore + ",";
                 }
             }
             xn["blacklist"].InnerText = new_ignore.TrimEnd(',');
             module_found_file = true;
             break;
         }
     }
     foreach (Module tmp_module in Conf.Modules)
     {
         if (tmp_module.Class_Name.Equals(module))
         {
             tmp_module.Blacklist.Remove(ignore_nick);
             module_found_conf = true;
             break;
         }
     }
     if (module_found_file && module_found_conf)
     {
         ircbot.controller.save_module_xml(Conf.Server_Name, xmlDoc);
         ircbot.controller.update_conf();
         ircbot.sendData("NOTICE", nick + " :" + ignore_nick + " removed successfully from the " + module + " module ignore list!");
     }
     else
     {
         ircbot.sendData("NOTICE", nick + " :Module " + module + " does not exist.");
     }
 }
コード例 #16
0
ファイル: owner.cs プロジェクト: uncled1023/IRCBot
 private static void unignorecmd(string cmd, string ignore_nick, string nick, bot ircbot, BotConfig Conf)
 {
     XmlDocument xmlDoc = ircbot.controller.get_module_xml(Conf.Server_Name);
     bool cmd_found_file = false;
     bool cmd_found_conf = false;
     XmlNode Serverxn = xmlDoc.SelectSingleNode("/modules");
     XmlNodeList ServerxnList = Serverxn.ChildNodes;
     foreach (XmlNode xn in ServerxnList)
     {
         XmlNodeList cmd_nodes = xn.SelectNodes("commands");
         foreach (XmlNode cmd_node in cmd_nodes)
         {
             string[] triggers = cmd_node["triggers"].InnerText.Split('|');
             foreach (string trigger in triggers)
             {
                 if (trigger.Equals(cmd))
                 {
                     string new_ignore = "";
                     foreach (string list_ignore in cmd_node["blacklist"].InnerText.Split(','))
                     {
                         if (!list_ignore.Equals(ignore_nick, StringComparison.InvariantCultureIgnoreCase))
                         {
                             new_ignore += list_ignore + ",";
                         }
                     }
                     cmd_node["blacklist"].InnerText = new_ignore.TrimEnd(',');
                     cmd_found_file = true;
                     break;
                 }
             }
         }
         break;
     }
     foreach (Module tmp_module in Conf.Modules)
     {
         foreach (Command tmp_command in tmp_module.Commands)
         {
             if (tmp_command.Triggers.Contains(cmd))
             {
                 tmp_command.Blacklist.Remove(ignore_nick);
                 cmd_found_conf = true;
                 break;
             }
         }
     }
     if (cmd_found_file && cmd_found_conf)
     {
         ircbot.controller.save_module_xml(Conf.Server_Name, xmlDoc);
         ircbot.controller.update_conf();
         ircbot.sendData("NOTICE", nick + " :" + ignore_nick + " removed successfully from the " + ircbot.Conf.Command + cmd + " ignore list!");
     }
     else
     {
         ircbot.sendData("NOTICE", nick + " :" + ircbot.Conf.Command + cmd + " does not exist.");
     }
 }
コード例 #17
0
ファイル: owner.cs プロジェクト: uncled1023/IRCBot
 private static void unignore(string ignore_nick, string nick, bot ircbot, BotConfig Conf)
 {
     bool removed = false;
     XmlNode xn = ircbot.controller.get_server_xml(Conf.Server_Name);
     string new_ignore = "";
     Conf.Ignore_List = "";
     foreach (string list_ignore in xn["ignore_list"].InnerText.Split(','))
     {
         if (!list_ignore.Equals(ignore_nick, StringComparison.InvariantCultureIgnoreCase))
         {
             new_ignore += list_ignore + ",";
             Conf.Ignore_List += list_ignore + ",";
         }
         else
         {
             removed = true;
         }
     }
     xn["ignore_list"].InnerText = new_ignore.TrimEnd(',');
     Conf.Ignore_List = Conf.Ignore_List.TrimEnd(',');
     ircbot.controller.save_server_xml(Conf.Server_Name, xn);
     if (removed)
     {
         ircbot.controller.update_conf();
         ircbot.sendData("NOTICE", nick + " :" + ignore_nick + " successfully removed from the ignore list!");
     }
     else
     {
         ircbot.sendData("NOTICE", nick + " :" + ignore_nick + " was not removed from the ignore list.");
     }
 }
コード例 #18
0
ファイル: owner.cs プロジェクト: uncled1023/IRCBot
 private static void unblacklist(string channel, string nick, bot ircbot, BotConfig Conf)
 {
     XmlNode node = ircbot.controller.get_server_xml(Conf.Server_Name);
     string new_blacklist = "";
     Conf.Chan_Blacklist = "";
     bool removed = false;
     foreach (string list_blacklist in node["chan_blacklist"].InnerText.Split(','))
     {
         if (!list_blacklist.Equals(channel))
         {
             new_blacklist += list_blacklist + ",";
             Conf.Ignore_List += list_blacklist + ",";
         }
         else
         {
             removed = true;
         }
     }
     node["chan_blacklist"].InnerText = new_blacklist.TrimEnd(',');
     Conf.Chan_Blacklist = Conf.Chan_Blacklist.TrimEnd(',');
     ircbot.controller.save_server_xml(Conf.Server_Name, node);
     if (removed)
     {
         ircbot.controller.update_conf();
         ircbot.sendData("NOTICE", nick + " :" + channel + " successfully removed from the blacklist.");
     }
     else
     {
         ircbot.sendData("NOTICE", nick + " :" + channel + " was not removed from the blacklist.");
     }
 }
コード例 #19
0
ファイル: owner.cs プロジェクト: uncled1023/IRCBot
 private static void ignoremodule(string module, string ignore_nick, string nick, bot ircbot, BotConfig Conf)
 {
     XmlDocument xmlDoc = ircbot.controller.get_module_xml(Conf.Server_Name);
     bool module_found_file = false;
     bool module_found_conf = false;
     XmlNode Serverxn = xmlDoc.SelectSingleNode("/modules");
     XmlNodeList ServerxnList = Serverxn.ChildNodes;
     foreach (XmlNode xn in ServerxnList)
     {
         if (xn["class_name"].InnerText.Equals(module))
         {
             string old_ignore = xn["blacklist"].InnerText;
             string new_ignore = old_ignore + "," + ignore_nick;
             xn["blacklist"].InnerText = new_ignore.TrimStart(',');
             module_found_file = true;
             break;
         }
     }
     foreach (Module tmp_module in Conf.Modules)
     {
         if (tmp_module.Class_Name.Equals(module))
         {
             tmp_module.Blacklist.Add(ignore_nick);
             module_found_conf = true;
             break;
         }
     }
     if (module_found_file && module_found_conf)
     {
         ircbot.controller.save_module_xml(Conf.Server_Name, xmlDoc);
         ircbot.controller.update_conf();
         ircbot.sendData("NOTICE", nick + " :" + ignore_nick + " added successfully to the " + module + " module ignore list!");
     }
     else
     {
         ircbot.sendData("NOTICE", nick + " :Module " + module + " does not exist.");
     }
 }
コード例 #20
0
        private static void display_log(string channel, string requst_nick, string command, bot ircbot, BotConfig Conf)
        {
            string file_name = ircbot.Conf.Server_Name + ".log";
            bool   cmd_found = false;

            if (File.Exists(ircbot.cur_dir + Path.DirectorySeparatorChar + "modules" + Path.DirectorySeparatorChar + "logging" + Path.DirectorySeparatorChar + file_name))
            {
                string[] log_file        = System.IO.File.ReadAllLines(ircbot.cur_dir + Path.DirectorySeparatorChar + "modules" + Path.DirectorySeparatorChar + "logging" + Path.DirectorySeparatorChar + file_name);
                int      number_of_lines = log_file.GetUpperBound(0) + 1;
                if (number_of_lines > 0)
                {
                    int    num_uses   = 0;
                    string parameters = "";
                    string date       = "";
                    string inside     = "";
                    string nick       = "";
                    foreach (string line in log_file)
                    {
                        char[]   sep      = new char[] { '*' };
                        string[] new_line = line.Split(sep, 5);
                        if (new_line.GetUpperBound(0) > 0)
                        {
                            if (new_line[3].Equals(command))
                            {
                                if (String.IsNullOrEmpty(new_line[4]))
                                {
                                    parameters = " with the following argument: " + new_line[4];
                                }
                                else
                                {
                                    parameters = "";
                                }
                                date   = new_line[2];
                                inside = new_line[1];
                                nick   = new_line[0];
                                num_uses++;
                                cmd_found = true;
                            }
                        }
                    }
                    if (cmd_found == true)
                    {
                        ircbot.sendData("NOTICE", requst_nick + " :" + ircbot.Conf.Command + command + " has been used " + num_uses + " times.");
                        ircbot.sendData("NOTICE", requst_nick + " :It was last used by " + nick + " on " + date + " in " + inside + parameters);
                    }
                    else
                    {
                        string new_command = "";
                        foreach (string line in log_file)
                        {
                            char[]   sep      = new char[] { '*' };
                            string[] new_line = line.Split(sep, 5);
                            if (new_line.GetUpperBound(0) > 0)
                            {
                                if (new_line[0].Equals(command))
                                {
                                    if (!String.IsNullOrEmpty(new_line[4]))
                                    {
                                        parameters = " with the following argument: " + new_line[4];
                                    }
                                    else
                                    {
                                        parameters = "";
                                    }
                                    date        = new_line[2];
                                    inside      = new_line[1];
                                    nick        = new_line[0];
                                    new_command = new_line[3];
                                    num_uses++;
                                    cmd_found = true;
                                }
                            }
                        }
                        if (cmd_found == true)
                        {
                            ircbot.sendData("NOTICE", requst_nick + " :" + nick + " has used " + num_uses + " commands.");
                            ircbot.sendData("NOTICE", requst_nick + " :The last command they used was " + ircbot.Conf.Command + new_command + " on " + date + " in " + inside + parameters);
                        }
                        else
                        {
                            ircbot.sendData("NOTICE", requst_nick + " :No results found");
                        }
                    }
                }
                else
                {
                    ircbot.sendData("NOTICE", requst_nick + " :No results found");
                }
            }
            else
            {
                ircbot.sendData("NOTICE", requst_nick + " :No results found");
            }
        }
コード例 #21
0
        public void EnsureSeedData()
        {
            if (BotConfig.Any())
            {
                return;
            }
            var bc = new BotConfig();

            bc.EightBallResponses.AddRange(new HashSet <EightBallResponse> {
                new EightBallResponse {
                    Text = "Most definitely yes"
                },
                new EightBallResponse {
                    Text = "For sure"
                },
                new EightBallResponse {
                    Text = "Totally!"
                },
                new EightBallResponse {
                    Text = "Of course!"
                },
                new EightBallResponse {
                    Text = "As I see it, yes"
                },
                new EightBallResponse {
                    Text = "My sources say yes"
                },
                new EightBallResponse {
                    Text = "Yes"
                },
                new EightBallResponse {
                    Text = "Most likely"
                },
                new EightBallResponse {
                    Text = "Perhaps"
                },
                new EightBallResponse {
                    Text = "Maybe"
                },
                new EightBallResponse {
                    Text = "Not sure"
                },
                new EightBallResponse {
                    Text = "It is uncertain"
                },
                new EightBallResponse {
                    Text = "Ask me again later"
                },
                new EightBallResponse {
                    Text = "Don't count on it"
                },
                new EightBallResponse {
                    Text = "Probably not"
                },
                new EightBallResponse {
                    Text = "Very doubtful"
                },
                new EightBallResponse {
                    Text = "Most likely no"
                },
                new EightBallResponse {
                    Text = "Nope"
                },
                new EightBallResponse {
                    Text = "No"
                },
                new EightBallResponse {
                    Text = "My sources say no"
                },
                new EightBallResponse {
                    Text = "Dont even think about it"
                },
                new EightBallResponse {
                    Text = "Definitely no"
                },
                new EightBallResponse {
                    Text = "NO - It may cause disease contraction"
                }
            });

            BotConfig.Add(bc);

            SaveChanges();
        }
コード例 #22
0
ファイル: moderation.cs プロジェクト: uncled1023/IRCBot
        public override void control(bot ircbot, BotConfig Conf, 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 disallowed_modes = this.Options["disallowed_modes"];
            if (type.Equals("channel") && bot_command == true)
            {
                foreach (Command tmp_command in this.Commands)
                {
                    bool blocked = tmp_command.Blacklist.Contains(channel) || tmp_command.Blacklist.Contains(nick);
                    bool cmd_found = false;
                    bool spam_check = ircbot.get_spam_check(channel, nick, tmp_command.Spam_Check);
                    if (spam_check == true)
                    {
                        blocked = blocked || ircbot.get_spam_status(channel);
                    }
                    cmd_found = tmp_command.Triggers.Contains(command);
                    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 tmp_command.Triggers)
                        {
                            switch (trigger)
                            {
                                case "founder":
                                    if (spam_check == true)
                                    {
                                        ircbot.add_spam_count(channel);
                                    }
                                    if (nick_access >= tmp_command.Access)
                                    {
                                        if (line.GetUpperBound(0) > 3)
                                        {
                                            ircbot.sendData("MODE", line[2] + " +q " + line[4]);
                                            access.set_access_list(line[4], 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 >= tmp_command.Access)
                                    {
                                        if (line.GetUpperBound(0) > 3)
                                        {
                                            ircbot.sendData("MODE", line[2] + " -q " + line[4]);
                                            access.del_access_list(line[4], 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 >= tmp_command.Access)
                                    {
                                        if (line.GetUpperBound(0) > 3)
                                        {
                                            ircbot.sendData("MODE", line[2] + " +a " + line[4]);
                                            access.set_access_list(line[4], 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 >= tmp_command.Access)
                                    {
                                        if (line.GetUpperBound(0) > 3)
                                        {
                                            ircbot.sendData("MODE", line[2] + " +a " + line[4]);
                                            ircbot.sendData("PRIVMSG", "chanserv :SOP " + line[2] + " add " + line[4]);
                                            access.set_access_list(line[4], 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 >= tmp_command.Access)
                                    {
                                        if (line.GetUpperBound(0) > 3)
                                        {
                                            ircbot.sendData("MODE", line[2] + " -a " + line[4]);
                                            ircbot.sendData("PRIVMSG", "chanserv :SOP " + line[2] + " del " + line[4]);
                                            access.del_access_list(line[4], 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 >= tmp_command.Access)
                                    {
                                        if (line.GetUpperBound(0) > 3)
                                        {
                                            ircbot.sendData("MODE", line[2] + " -a " + line[4]);
                                            access.del_access_list(line[4], 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 >= tmp_command.Access)
                                    {
                                        if (line.GetUpperBound(0) > 3)
                                        {
                                            ircbot.sendData("MODE", line[2] + " +o " + line[4]);
                                            access.set_access_list(line[4], 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 >= tmp_command.Access)
                                    {
                                        if (line.GetUpperBound(0) > 3)
                                        {
                                            ircbot.sendData("MODE", line[2] + " +o " + line[4]);
                                            if (!ircbot.get_nick_auto("SOP", line[2], line[4]))
                                            {
                                                ircbot.sendData("PRIVMSG", "chanserv :AOP " + line[2] + " add " + line[4]);
                                            }
                                            access.set_access_list(line[4], 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 >= tmp_command.Access)
                                    {
                                        if (line.GetUpperBound(0) > 3)
                                        {
                                            ircbot.sendData("MODE", line[2] + " -o " + line[4]);
                                            ircbot.sendData("PRIVMSG", "chanserv :AOP " + line[2] + " del " + line[4]);
                                            access.del_access_list(line[4], 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 >= tmp_command.Access)
                                    {
                                        if (line.GetUpperBound(0) > 3)
                                        {
                                            ircbot.sendData("MODE", line[2] + " -o " + line[4]);
                                            access.del_access_list(line[4], 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 >= tmp_command.Access)
                                    {
                                        if (line.GetUpperBound(0) > 3)
                                        {
                                            ircbot.sendData("MODE", line[2] + " +h " + line[4]);
                                            if (!ircbot.get_nick_auto("AOP", line[2], line[4]) && !ircbot.get_nick_auto("SOP", line[2], line[4]))
                                            {
                                                ircbot.sendData("PRIVMSG", "chanserv :HOP " + line[2] + " add " + line[4]);
                                            }
                                            access.set_access_list(line[4], 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 >= tmp_command.Access)
                                    {
                                        if (line.GetUpperBound(0) > 3)
                                        {
                                            ircbot.sendData("MODE", line[2] + " -h " + line[4]);
                                            ircbot.sendData("PRIVMSG", "chanserv :HOP " + line[2] + " del " + line[4]);
                                            access.del_access_list(line[4], 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 >= tmp_command.Access)
                                    {
                                        if (line.GetUpperBound(0) > 3)
                                        {
                                            ircbot.sendData("MODE", line[2] + " +h " + line[4]);
                                            access.set_access_list(line[4], 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 >= tmp_command.Access)
                                    {
                                        if (line.GetUpperBound(0) > 3)
                                        {
                                            ircbot.sendData("MODE", line[2] + " -h " + line[4]);
                                            access.del_access_list(line[4], 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 >= tmp_command.Access)
                                    {
                                        if (line.GetUpperBound(0) > 3)
                                        {
                                            ircbot.sendData("MODE", line[2] + " +v " + line[4]);
                                            if (!ircbot.get_nick_auto("AOP", line[2], line[4]) && !ircbot.get_nick_auto("SOP", line[2], line[4]) && !ircbot.get_nick_auto("VOP", line[2], line[4]))
                                            {
                                                ircbot.sendData("PRIVMSG", "chanserv :VOP " + line[2] + " add " + line[4]);
                                            }
                                            access.set_access_list(line[4], 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 >= tmp_command.Access)
                                    {
                                        if (line.GetUpperBound(0) > 3)
                                        {
                                            ircbot.sendData("MODE", line[2] + " -v " + line[4]);
                                            ircbot.sendData("PRIVMSG", "chanserv :VOP " + line[2] + " del " + line[4]);
                                            access.del_access_list(line[4], 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 >= tmp_command.Access)
                                    {
                                        if (line.GetUpperBound(0) > 3)
                                        {
                                            ircbot.sendData("MODE", line[2] + " +v " + line[4]);
                                            access.set_access_list(line[4], 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 >= tmp_command.Access)
                                    {
                                        if (line.GetUpperBound(0) > 3)
                                        {
                                            ircbot.sendData("MODE", line[2] + " -v " + line[4]);
                                            access.del_access_list(line[4], 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 >= tmp_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 >= tmp_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 >= tmp_command.Access)
                                    {
                                        if (line.GetUpperBound(0) > 3)
                                        {
                                            string[] new_line = line[4].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 >= tmp_command.Access)
                                    {
                                        if (line.GetUpperBound(0) > 3)
                                        {
                                            string[] new_line = line[4].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_nick_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_nick_host(total_nicks[0]);
                                                    string ban = "*!*@" + target_host;
                                                    if (String.IsNullOrEmpty(target_host))
                                                    {
                                                        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 >= tmp_command.Access)
                                    {
                                        if (line.GetUpperBound(0) > 3)
                                        {
                                            string[] new_line = line[4].Split(charS, 2);
                                            char[] charSep = new char[] { ',' };
                                            string[] total_nicks = new_line[0].Split(charSep, StringSplitOptions.RemoveEmptyEntries);
                                            int sent_nick_access = ircbot.get_nick_access(total_nicks[0].TrimStart(':'), line[2]);

                                            if (nick_access >= sent_nick_access)
                                            {
                                                string target_host = ircbot.get_nick_host(total_nicks[0]);
                                                string ban = "*!*@" + target_host;
                                                if (String.IsNullOrEmpty(target_host))
                                                {
                                                    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 >= tmp_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 >= tmp_command.Access)
                                    {
                                        if (line.GetUpperBound(0) > 3)
                                        {
                                            string[] new_line = line[4].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_nick_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.InvariantCultureIgnoreCase))
                                                {
                                                    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_nick_host(total_nicks[0]);
                                                    string ban = "*!*@" + target_host;
                                                    if (String.IsNullOrEmpty(target_host))
                                                    {
                                                        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 >= tmp_command.Access)
                                    {
                                        if (line.GetUpperBound(0) > 3)
                                        {
                                            string[] new_line = line[4].Split(charS, 3, StringSplitOptions.RemoveEmptyEntries);
                                            if (new_line.GetUpperBound(0) > 0)
                                            {
                                                string nicks = new_line[1];
                                                char[] charSep = new char[] { ',' };
                                                string[] total_nicks = nicks.Split(charSep, StringSplitOptions.RemoveEmptyEntries);
                                                string target_host = ircbot.get_nick_host(total_nicks[0]);
                                                int sent_nick_access = ircbot.get_nick_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.InvariantCultureIgnoreCase))
                                                    {
                                                        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 (String.IsNullOrEmpty(target_host))
                                                        {
                                                            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 >= tmp_command.Access)
                                    {
                                        if (line.GetUpperBound(0) > 3)
                                        {
                                            string[] new_line = line[4].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_nick_access(total_nicks[0], line[2]);
                                                string target_host = ircbot.get_nick_host(total_nicks[0]);

                                                bool tmp_me = false;
                                                for (int y = 0; y <= total_nicks.GetUpperBound(0); y++)
                                                {
                                                    if (total_nicks[y].Trim().Equals(Conf.Name, StringComparison.InvariantCultureIgnoreCase))
                                                    {
                                                        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 (String.IsNullOrEmpty(target_host))
                                                        {
                                                            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 >= tmp_command.Access)
                                    {
                                        if (line.GetUpperBound(0) > 3)
                                        {
                                            string[] new_line = line[4].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_nick_access(total_nicks[0], line[2]);
                                            bool tmp_me = false;
                                            for (int y = 0; y <= total_nicks.GetUpperBound(0); y++)
                                            {
                                                if (total_nicks[y].Trim().Equals(Conf.Name, StringComparison.InvariantCultureIgnoreCase))
                                                {
                                                    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_nick_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 >= tmp_command.Access)
                                    {
                                        if (line.GetUpperBound(0) > 3)
                                        {
                                            string[] new_line = line[4].Split(charS, 2);
                                            string target_host = ircbot.get_nick_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_nick_access(total_nicks[0], line[2]);
                                            bool tmp_me = false;
                                            for (int y = 0; y <= total_nicks.GetUpperBound(0); y++)
                                            {
                                                if (total_nicks[y].Trim().Equals(Conf.Name, StringComparison.InvariantCultureIgnoreCase))
                                                {
                                                    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 >= tmp_command.Access)
                                    {
                                        if (line.GetUpperBound(0) > 3)
                                        {
                                            string[] new_line = line[4].Split(charS, 2);
                                            string target_host = ircbot.get_nick_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_nick_access(total_nicks[0], line[2]);
                                            bool tmp_me = false;
                                            for (int y = 0; y <= total_nicks.GetUpperBound(0); y++)
                                            {
                                                if (total_nicks[y].Trim().Equals(Conf.Name, StringComparison.InvariantCultureIgnoreCase))
                                                {
                                                    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 >= tmp_command.Access)
                                    {
                                        if (line.GetUpperBound(0) > 3)
                                        {
                                            string target_host = ircbot.get_nick_host(line[4]);
                                            del_auto(line[4], 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 >= tmp_command.Access)
                                    {
                                        if (line.GetUpperBound(0) > 3)
                                        {
                                            string target_host = ircbot.get_nick_host(line[4]);
                                            del_auto(line[4], 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 >= tmp_command.Access)
                                    {
                                        if (line.GetUpperBound(0) > 3)
                                        {
                                            string target_host = ircbot.get_nick_host(line[4]);
                                            del_auto(line[4], 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 >= tmp_command.Access)
                                    {
                                        if (line.GetUpperBound(0) > 3)
                                        {
                                            string[] new_line = line[4].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_nick_access(total_nicks[0], line[2]);
                                            bool tmp_me = false;
                                            for (int y = 0; y <= total_nicks.GetUpperBound(0); y++)
                                            {
                                                if (total_nicks[y].Trim().Equals(Conf.Name, StringComparison.InvariantCultureIgnoreCase))
                                                {
                                                    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 >= tmp_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);
            }
        }
コード例 #23
0
ファイル: Program.cs プロジェクト: CAG2Mark/OpenSkillBot
        public async Task MainAsync(string[] args)
        {
            TestMode = (args.Contains("--test-mode"));

            if (File.Exists("config.json"))
            {
                Config = SerializeHelper.Deserialize <BotConfig>("config.json");
            }
            // Load the Discord token.
            if (Config != null)
            {
                DiscordToken = Config.BotToken;
            }
            else if (!TestMode)
            {
                Console.WriteLine("Please enter your Discord Bot Token. If you don't have one, please create one at https://discord.com/developers/applications.");
                DiscordToken = Console.ReadLine().Trim();

                Config = new BotConfig()
                {
                    BotToken = DiscordToken
                };
                SerializeConfig();
            }

            Config.PropertyChanged += (o, e) => SerializeConfig();

            DiscordIO = new DiscordInput(DiscordToken, TestMode);

            var initTime = DateTime.UtcNow;

            Controller = new BotController(true, TestMode);
            // Controller.Initialize();

            var doneTime = DateTime.UtcNow;

            InitTime = (int)((doneTime - initTime).Ticks / TimeSpan.TicksPerMillisecond);

            // Log in to challonge.

            Challonge = new ChallongeConnection(Config.ChallongeToken);

            var chTime = DateTime.UtcNow;

            // Test connection with a basic api call
            try {
                var rs = await Challonge.GetTournaments();

                // log response time
                var chTimeNow = DateTime.UtcNow;
                var ticks     = (chTimeNow - chTime).Milliseconds;
                await DiscordIO.Log(new LogMessage(LogSeverity.Info, "Challonge", "Challonge connection OK. API response time: " + ticks + "ms"));
            } catch (ChallongeException e) {
                // connected but error on challonge
                await DiscordIO.Log(new LogMessage(LogSeverity.Error, "Challonge",
                                                   "Could not log into Challonge. Error(s) are as follows: " + Environment.NewLine + Environment.NewLine +
                                                   String.Join(Environment.NewLine, e.Errors.ToArray())));
            } catch (Exception e) {
                // most likely network error
                await DiscordIO.Log(new LogMessage(LogSeverity.Error, "Challonge", "Error connecting to Challonge.", e));
            }

            // Block this task until the program is closed.
            await Task.Delay(-1);
        }
コード例 #24
0
ファイル: owner.cs プロジェクト: uncled1023/IRCBot
 private static void del_channel_list(string channel, bot ircbot, BotConfig Conf)
 {
     XmlNode xn = ircbot.controller.get_server_xml(Conf.Server_Name);
     string new_channel = "";
     Conf.Chans = "";
     foreach (string list_chan in xn["chan_list"].InnerText.Split(','))
     {
         if (!list_chan.Equals(channel))
         {
             new_channel += list_chan + ",";
             Conf.Chans += list_chan + ",";
         }
     }
     xn["chan_list"].InnerText = new_channel.TrimEnd(',');
     Conf.Chans = Conf.Chans.TrimEnd(',');
     ircbot.controller.save_server_xml(Conf.Server_Name, xn);
 }
コード例 #25
0
ファイル: owner.cs プロジェクト: uncled1023/IRCBot
 private static void add_channel_list(string channel, bot ircbot, BotConfig Conf)
 {
     XmlNode xn = ircbot.controller.get_server_xml(Conf.Server_Name);
     string new_channel = xn["chan_list"].InnerText + "," + channel;
     xn["chan_list"].InnerText = new_channel;
     Conf.Chans += "," + channel;
     ircbot.controller.save_server_xml(Conf.Server_Name, xn);
 }
コード例 #26
0
        public override void control(bot ircbot, BotConfig Conf, string[] line, string command, int nick_access, string nick, string channel, bool bot_command, string type)
        {
            if ((type.Equals("channel") || type.Equals("query")) && bot_command == true)
            {
                foreach (Command tmp_command in this.Commands)
                {
                    bool blocked    = tmp_command.Blacklist.Contains(channel) || tmp_command.Blacklist.Contains(nick);
                    bool cmd_found  = false;
                    bool spam_check = ircbot.get_spam_check(channel, nick, tmp_command.Spam_Check);
                    if (spam_check == true)
                    {
                        blocked = blocked || ircbot.get_spam_status(channel);
                    }
                    cmd_found = tmp_command.Triggers.Contains(command);
                    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 tmp_command.Triggers)
                        {
                            switch (trigger)
                            {
                            case "addresponse":
                                if (spam_check == true)
                                {
                                    ircbot.add_spam_count(channel);
                                }
                                if (nick_access >= tmp_command.Access)
                                {
                                    if (line.GetUpperBound(0) > 3)
                                    {
                                        string list_file = ircbot.cur_dir + Path.DirectorySeparatorChar + "modules" + Path.DirectorySeparatorChar + "Response" + Path.DirectorySeparatorChar + "dictionary.txt";
                                        if (Directory.Exists(ircbot.cur_dir + Path.DirectorySeparatorChar + "modules" + Path.DirectorySeparatorChar + "Response" + Path.DirectorySeparatorChar + "") == false)
                                        {
                                            Directory.CreateDirectory(ircbot.cur_dir + Path.DirectorySeparatorChar + "modules" + Path.DirectorySeparatorChar + "Response");
                                        }
                                        if (File.Exists(ircbot.cur_dir + Path.DirectorySeparatorChar + "modules" + Path.DirectorySeparatorChar + "Response" + Path.DirectorySeparatorChar + "dictionary.txt"))
                                        {
                                            StreamWriter log = File.AppendText(ircbot.cur_dir + Path.DirectorySeparatorChar + "modules" + Path.DirectorySeparatorChar + "Response" + Path.DirectorySeparatorChar + "dictionary.txt");
                                            log.WriteLine(line[4]);
                                            log.Close();
                                        }
                                        else
                                        {
                                            StreamWriter log_file = File.CreateText(ircbot.cur_dir + Path.DirectorySeparatorChar + "modules" + Path.DirectorySeparatorChar + "Response" + Path.DirectorySeparatorChar + "dictionary.txt");
                                            log_file.WriteLine(line[4]);
                                            log_file.Close();
                                        }
                                        ircbot.sendData("PRIVMSG", channel + " :Response added successfully");
                                    }
                                    else
                                    {
                                        ircbot.sendData("NOTICE", nick + " :" + nick + ", you need to include more info.");
                                    }
                                }
                                else
                                {
                                    ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command.");
                                }
                                break;

                            case "delresponse":
                                if (spam_check == true)
                                {
                                    ircbot.add_spam_count(channel);
                                }
                                if (nick_access >= tmp_command.Access)
                                {
                                    if (line.GetUpperBound(0) > 3)
                                    {
                                        try
                                        {
                                            bool   response_found = false;
                                            string list_file      = ircbot.cur_dir + Path.DirectorySeparatorChar + "modules" + Path.DirectorySeparatorChar + "Response" + Path.DirectorySeparatorChar + "dictionary.txt";
                                            if (Directory.Exists(ircbot.cur_dir + Path.DirectorySeparatorChar + "modules" + Path.DirectorySeparatorChar + "Response" + Path.DirectorySeparatorChar + "") == false)
                                            {
                                                Directory.CreateDirectory(ircbot.cur_dir + Path.DirectorySeparatorChar + "modules" + Path.DirectorySeparatorChar + "Response");
                                            }
                                            if (File.Exists(ircbot.cur_dir + Path.DirectorySeparatorChar + "modules" + Path.DirectorySeparatorChar + "Response" + Path.DirectorySeparatorChar + "dictionary.txt"))
                                            {
                                                string[] file = System.IO.File.ReadAllLines(list_file);

                                                if (file.GetUpperBound(0) >= 0)
                                                {
                                                    List <string> new_file = new List <string>();
                                                    int           index    = 1;
                                                    foreach (string tmp_new_line in file)
                                                    {
                                                        if (index == Convert.ToInt32(line[4]))
                                                        {
                                                            ircbot.sendData("NOTICE", nick + " :Response removed successfully.");
                                                            response_found = true;
                                                        }
                                                        else
                                                        {
                                                            new_file.Add(tmp_new_line);
                                                        }
                                                        index++;
                                                    }
                                                    System.IO.File.WriteAllLines(@list_file, new_file);
                                                }
                                                if (!response_found)
                                                {
                                                    ircbot.sendData("NOTICE", nick + " :Unable to delete desired response.");
                                                }
                                            }
                                            else
                                            {
                                                StreamWriter log_file = File.CreateText(ircbot.cur_dir + Path.DirectorySeparatorChar + "modules" + Path.DirectorySeparatorChar + "Response" + Path.DirectorySeparatorChar + "dictionary.txt");
                                                log_file.Close();
                                            }
                                        }
                                        catch
                                        {
                                            ircbot.sendData("NOTICE", nick + " :Please specify a valid number.");
                                        }
                                    }
                                    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 "listresponse":
                                if (spam_check == true)
                                {
                                    ircbot.add_spam_count(channel);
                                }
                                if (nick_access >= tmp_command.Access)
                                {
                                    string list_file = ircbot.cur_dir + Path.DirectorySeparatorChar + "modules" + Path.DirectorySeparatorChar + "Response" + Path.DirectorySeparatorChar + "dictionary.txt";
                                    if (Directory.Exists(ircbot.cur_dir + Path.DirectorySeparatorChar + "modules" + Path.DirectorySeparatorChar + "Response" + Path.DirectorySeparatorChar + "") == false)
                                    {
                                        Directory.CreateDirectory(ircbot.cur_dir + Path.DirectorySeparatorChar + "modules" + Path.DirectorySeparatorChar + "Response");
                                    }
                                    if (File.Exists(ircbot.cur_dir + Path.DirectorySeparatorChar + "modules" + Path.DirectorySeparatorChar + "Response" + Path.DirectorySeparatorChar + "dictionary.txt"))
                                    {
                                        string[] file = System.IO.File.ReadAllLines(list_file);

                                        if (file.GetUpperBound(0) >= 0)
                                        {
                                            int index = 1;
                                            foreach (string tmp_new_line in file)
                                            {
                                                ircbot.sendData("NOTICE", nick + " :[" + index + "] " + tmp_new_line);
                                                Thread.Sleep(100);
                                                index++;
                                            }
                                        }
                                    }
                                    else
                                    {
                                        StreamWriter log_file = File.CreateText(ircbot.cur_dir + Path.DirectorySeparatorChar + "modules" + Path.DirectorySeparatorChar + "Response" + Path.DirectorySeparatorChar + "dictionary.txt");
                                        log_file.Close();
                                    }
                                }
                                else
                                {
                                    ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command.");
                                }
                                break;
                            }
                        }
                    }
                }
            }
            if (type.Equals("channel") && !bot_command)
            {
                if (!nick.Equals(ircbot.Nick, StringComparison.InvariantCultureIgnoreCase))
                {
                    string[] file;
                    string   list_file = ircbot.cur_dir + Path.DirectorySeparatorChar + "modules" + Path.DirectorySeparatorChar + "Response" + Path.DirectorySeparatorChar + "dictionary.txt";
                    if (File.Exists(list_file))
                    {
                        file = System.IO.File.ReadAllLines(list_file);

                        string tmp_line = line[3];
                        if (line.GetUpperBound(0) > 3)
                        {
                            tmp_line += " " + line[4];
                        }
                        tmp_line = tmp_line.Remove(0, 1);
                        string new_line  = tmp_line.ToLowerInvariant();
                        bool   triggered = false;
                        if (file.GetUpperBound(0) >= 0)
                        {
                            foreach (string tmp_new_line in file)
                            {
                                char[]   split_type       = new char[] { ':' };
                                char[]   trigger_split    = new char[] { '*' };
                                char[]   triggered_split  = new char[] { '&' };
                                string[] split            = tmp_new_line.Split(split_type, 3);
                                string[] channels         = split[0].Split(',');
                                string[] triggers         = split[1].Split('|');
                                string[] responses        = split[2].Split('|');
                                bool     response_allowed = false;
                                foreach (string chan in channels)
                                {
                                    if (chan.Equals(channel, StringComparison.InvariantCultureIgnoreCase) || chan.Equals(nick, StringComparison.InvariantCultureIgnoreCase) || chan.Equals("<all>"))
                                    {
                                        response_allowed = true;
                                    }
                                    if (chan.Equals("!" + nick, StringComparison.InvariantCultureIgnoreCase))
                                    {
                                        response_allowed = false;
                                        break;
                                    }
                                    if (chan.Equals("!" + channel, StringComparison.InvariantCultureIgnoreCase))
                                    {
                                        response_allowed = false;
                                        break;
                                    }
                                }
                                if (response_allowed)
                                {
                                    int index = 0;
                                    for (int x = 0; x <= triggers.GetUpperBound(0); x++)
                                    {
                                        string[] terms = triggers[x].Split(trigger_split, StringSplitOptions.RemoveEmptyEntries);
                                        for (int y = 0; y <= terms.GetUpperBound(0); y++)
                                        {
                                            triggered = false;
                                            terms[y]  = terms[y].ToLowerInvariant();
                                            if (triggers[x].StartsWith("*") == false && triggers[x].EndsWith("*") == false && terms.GetUpperBound(0) == 0)
                                            {
                                                if (new_line.Equals(terms[y]) == true)
                                                {
                                                    triggered = true;
                                                }
                                                else
                                                {
                                                    triggered = false;
                                                    break;
                                                }
                                            }
                                            else if (triggers[x].StartsWith("*") == false && y == 0)
                                            {
                                                if (new_line.StartsWith(terms[y]) == true && index <= new_line.IndexOf(terms[y]))
                                                {
                                                    triggered = true;
                                                    index     = new_line.IndexOf(terms[y]);
                                                }
                                                else
                                                {
                                                    triggered = false;
                                                    break;
                                                }
                                            }
                                            else if (triggers[x].EndsWith("*") == false && y == terms.GetUpperBound(0))
                                            {
                                                if (new_line.EndsWith(terms[y]) == true && index <= new_line.IndexOf(terms[y]))
                                                {
                                                    triggered = true;
                                                    index     = new_line.IndexOf(terms[y]);
                                                }
                                                else
                                                {
                                                    triggered = false;
                                                    break;
                                                }
                                            }
                                            else
                                            {
                                                if (new_line.Contains(terms[y]) == true && index <= new_line.IndexOf(terms[y]))
                                                {
                                                    triggered = true;
                                                    index     = new_line.IndexOf(terms[y]);
                                                }
                                                else
                                                {
                                                    triggered = false;
                                                    break;
                                                }
                                            }
                                        }
                                        if (triggered == true)
                                        {
                                            break;
                                        }
                                    }
                                    if (triggered == true)
                                    {
                                        ircbot.add_spam_count(channel);
                                        int    number_of_responses = responses.GetUpperBound(0) + 1;
                                        Random random = new Random();
                                        index = random.Next(0, number_of_responses);
                                        string file_line = responses[index].Replace("<nick>", nick);
                                        file_line = file_line.Replace("<me>", Conf.Nick);
                                        file_line = file_line.Replace("<chan>", channel);
                                        string[] events = file_line.Split(triggered_split, StringSplitOptions.RemoveEmptyEntries);
                                        for (int y = 0; y <= events.GetUpperBound(0); y++)
                                        {
                                            if (events[y].StartsWith("<cmd>") == true)
                                            {
                                                char[]   charSplit = new char[] { ' ' };
                                                string[] ex        = events[y].Remove(0, 5).Split(charSplit, 2);
                                                string[] args;
                                                if (ex.GetUpperBound(0) > 0)
                                                {
                                                    args = ex[1].Split(charSplit);
                                                }
                                                else
                                                {
                                                    args = null;
                                                }
                                                ircbot.controller.run_command(Conf.Server_Name, channel, ex[0], args);
                                            }
                                            else if (events[y].StartsWith("<delay>") == true)
                                            {
                                                Thread.Sleep(Convert.ToInt32(events[y].Remove(0, 7)));
                                            }
                                            else
                                            {
                                                ircbot.sendData("PRIVMSG", channel + " :" + events[y]);
                                            }
                                        }
                                        break;
                                    }
                                }
                            }
                        }
                    }
                    else
                    {
                        if (!Directory.Exists(ircbot.cur_dir + Path.DirectorySeparatorChar + "modules" + Path.DirectorySeparatorChar + "Response"))
                        {
                            Directory.CreateDirectory(ircbot.cur_dir + Path.DirectorySeparatorChar + "modules" + Path.DirectorySeparatorChar + "Response");
                        }
                        File.Create(list_file);
                    }
                }
            }
        }
コード例 #27
0
ファイル: owner.cs プロジェクト: uncled1023/IRCBot
        private static void add_owner(string nick, bot ircbot, BotConfig Conf)
        {
            if (!Conf.Owners.Contains(nick))
            {
                XmlNode xn = ircbot.controller.get_server_xml(Conf.Server_Name);
                string new_owner = xn["owner"].InnerText + "," + nick;
                xn["owner"].InnerText = new_owner;
                Conf.Owners.Add(nick);

                foreach (Channel_Info chan in Conf.Channel_List)
                {
                    Nick_Info tmp_nick = ircbot.get_nick_info(nick, chan.Channel);
                    tmp_nick.Identified = true;
                }
                ircbot.controller.save_server_xml(Conf.Server_Name, xn);
            }
            else
            {
                foreach (Channel_Info chan in Conf.Channel_List)
                {
                    Nick_Info tmp_nick = ircbot.get_nick_info(nick, chan.Channel);
                    tmp_nick.Identified = true;
                }
            }
        }
コード例 #28
0
            private void MigrateConfig0_9(IUnitOfWork uow, BotConfig botConfig)
            {
                Config0_9    oldConfig;
                const string configPath = "data/config.json";

                try
                {
                    oldConfig = JsonConvert.DeserializeObject <Config0_9>(File.ReadAllText(configPath));
                }
                catch (FileNotFoundException)
                {
                    _log.Warn("config.json not found");
                    return;
                }
                catch (Exception)
                {
                    _log.Error("Unknown error while deserializing file config.json, pls check its integrity, aborting migration");
                    throw new MigrationException();
                }

                //Basic
                botConfig.ForwardMessages     = oldConfig.ForwardMessages;
                botConfig.ForwardToAllOwners  = oldConfig.ForwardToAllOwners;
                botConfig.BufferSize          = (ulong)oldConfig.BufferSize;
                botConfig.RemindMessageFormat = oldConfig.RemindMessageFormat;
                botConfig.CurrencySign        = oldConfig.CurrencySign;
                botConfig.CurrencyName        = oldConfig.CurrencyName;
                botConfig.DMHelpString        = oldConfig.DMHelpString;
                botConfig.HelpString          = oldConfig.HelpString;

                //messages
                botConfig.RotatingStatuses = oldConfig.IsRotatingStatus;
                var messages = new List <PlayingStatus>();

                oldConfig.RotatingStatuses.ForEach(i => messages.Add(new PlayingStatus {
                    Status = i
                }));
                botConfig.RotatingStatusMessages = messages;

                //Prefix
                botConfig.ModulePrefixes.Clear();
                botConfig.ModulePrefixes.AddRange(new HashSet <ModulePrefix>
                {
                    new ModulePrefix()
                    {
                        ModuleName = "Administration",
                        Prefix     = oldConfig.CommandPrefixes.Administration
                    },
                    new ModulePrefix()
                    {
                        ModuleName = "Searches",
                        Prefix     = oldConfig.CommandPrefixes.Searches
                    },
                    new ModulePrefix()
                    {
                        ModuleName = "NSFW", Prefix = oldConfig.CommandPrefixes.NSFW
                    },
                    new ModulePrefix()
                    {
                        ModuleName = "Conversations",
                        Prefix     = oldConfig.CommandPrefixes.Conversations
                    },
                    new ModulePrefix()
                    {
                        ModuleName = "ClashOfClans",
                        Prefix     = oldConfig.CommandPrefixes.ClashOfClans
                    },
                    new ModulePrefix()
                    {
                        ModuleName = "Help", Prefix = oldConfig.CommandPrefixes.Help
                    },
                    new ModulePrefix()
                    {
                        ModuleName = "Music", Prefix = oldConfig.CommandPrefixes.Music
                    },
                    new ModulePrefix()
                    {
                        ModuleName = "Trello", Prefix = oldConfig.CommandPrefixes.Trello
                    },
                    new ModulePrefix()
                    {
                        ModuleName = "Games", Prefix = oldConfig.CommandPrefixes.Games
                    },
                    new ModulePrefix()
                    {
                        ModuleName = "Gambling",
                        Prefix     = oldConfig.CommandPrefixes.Gambling
                    },
                    new ModulePrefix()
                    {
                        ModuleName = "Permissions",
                        Prefix     = oldConfig.CommandPrefixes.Permissions
                    },
                    new ModulePrefix()
                    {
                        ModuleName = "Programming",
                        Prefix     = oldConfig.CommandPrefixes.Programming
                    },
                    new ModulePrefix()
                    {
                        ModuleName = "Pokemon", Prefix = oldConfig.CommandPrefixes.Pokemon
                    },
                    new ModulePrefix()
                    {
                        ModuleName = "Utility", Prefix = oldConfig.CommandPrefixes.Utility
                    }
                });

                //Blacklist
                var blacklist = new HashSet <BlacklistItem>(oldConfig.ServerBlacklist.Select(server => new BlacklistItem()
                {
                    ItemId = server, Type = BlacklistItem.BlacklistType.Server
                }));

                blacklist.AddRange(oldConfig.ChannelBlacklist.Select(channel => new BlacklistItem()
                {
                    ItemId = channel, Type = BlacklistItem.BlacklistType.Channel
                }));
                blacklist.AddRange(oldConfig.UserBlacklist.Select(user => new BlacklistItem()
                {
                    ItemId = user, Type = BlacklistItem.BlacklistType.User
                }));
                botConfig.Blacklist = blacklist;

                //Eightball
                botConfig.EightBallResponses = new HashSet <EightBallResponse>(oldConfig._8BallResponses.Select(response => new EightBallResponse()
                {
                    Text = response
                }));

                //customreactions
                uow.CustomReactions.AddRange(oldConfig.CustomReactions.SelectMany(cr =>
                {
                    return(cr.Value.Select(res => new CustomReaction()
                    {
                        GuildId = null,
                        IsRegex = false,
                        OwnerOnly = false,
                        Response = res,
                        Trigger = cr.Key.ToLowerInvariant(),
                    }));
                }).ToArray());

                try { File.Move(configPath, "./data/DELETE_ME_config.json"); } catch { }
            }
コード例 #29
0
ファイル: hbomb.cs プロジェクト: uncled1023/IRCBot
        private void pass_hbomb(string pass_nick, string channel, string nick, bot ircbot, BotConfig Conf, ref hbomb_info tmp_info, int index)
        {
            string tab_name = channel.TrimStart('#');
            string pattern = "[^a-zA-Z0-9]"; //regex pattern
            tab_name = Regex.Replace(tab_name, pattern, "_");
            bool nick_idle = false;

            Modules.seen seen = (Modules.seen)ircbot.get_module("seen");
            DateTime current_date = DateTime.Now;
            DateTime past_date = seen.get_seen_time(nick, channel, ircbot);
            double difference_second = 0;
            difference_second = current_date.Subtract(past_date).TotalSeconds;
            if (difference_second >= 600)
            {
                nick_idle = true;
            }
            if (nick_idle == false)
            {
                tmp_info.bomb_holder = pass_nick;
                tmp_info.previous_bomb_holder = nick;
                hbombs[index] = tmp_info;
                ircbot.sendData("PRIVMSG", channel + " :" + nick + " passed the bomb to " + pass_nick);
                ircbot.sendData("NOTICE", pass_nick + " :You now have the bomb!  Type " + ircbot.Conf.Command + "pass <nick> to pass it to someone else, or type " + ircbot.Conf.Command + "defuse <color> to try to defuse it.");
                string colors = "";
                foreach (string wire in tmp_info.wire_colors)
                {
                    colors += wire + ",";
                }
                ircbot.sendData("NOTICE", pass_nick + " :The colors of the wires are: " + colors);
            }
            else
            {
                ircbot.sendData("PRIVMSG", channel + " :Dang, you missed them! (Idle)");
            }
        }
コード例 #30
0
ファイル: owner.cs プロジェクト: uncled1023/IRCBot
        private static void del_owner(string nick, bot ircbot, BotConfig Conf)
        {
            if (Conf.Owners.Contains(nick))
            {
                string new_owner = "";
                XmlNode xn = ircbot.controller.get_server_xml(Conf.Server_Name);
                string[] new_owner_tmp = xn["owner"].InnerText.Split(',');
                for (int x = 0; x <= new_owner_tmp.GetUpperBound(0); x++)
                {
                    if (!new_owner_tmp[x].Equals(nick, StringComparison.InvariantCultureIgnoreCase))
                    {
                        new_owner += new_owner_tmp[x] + ",";
                    }
                }
                xn["owner"].InnerText = new_owner.TrimEnd(',');
                Conf.Owners.Remove(nick);

                foreach (Channel_Info chan in Conf.Channel_List)
                {
                    Nick_Info tmp_nick = ircbot.get_nick_info(nick, chan.Channel);
                    tmp_nick.Identified = false;
                }
                ircbot.controller.save_server_xml(Conf.Server_Name, xn);
            }
        }
コード例 #31
0
        public bool Edit(BotConfigEditType type, string newValue)
        {
            using (var uow = _db.UnitOfWork)
            {
                var bc = uow.BotConfig.GetOrCreate(set => set);
                switch (type)
                {
                case BotConfigEditType.CurrencyGenerationChance:
                    if (float.TryParse(newValue, out var chance) &&
                        chance >= 0 &&
                        chance <= 1)
                    {
                        bc.CurrencyGenerationChance = chance;
                    }
                    else
                    {
                        return(false);
                    }
                    break;

                case BotConfigEditType.CurrencyGenerationCooldown:
                    if (int.TryParse(newValue, out var cd) && cd >= 1)
                    {
                        bc.CurrencyGenerationCooldown = cd;
                    }
                    else
                    {
                        return(false);
                    }
                    break;

                case BotConfigEditType.CurrencyName:
                    bc.CurrencyName = newValue ?? "-";
                    break;

                case BotConfigEditType.CurrencyPluralName:
                    bc.CurrencyPluralName = newValue ?? bc.CurrencyName + "s";
                    break;

                case BotConfigEditType.CurrencySign:
                    bc.CurrencySign = newValue ?? "-";
                    break;

                case BotConfigEditType.DmHelpString:
                    bc.DMHelpString = string.IsNullOrWhiteSpace(newValue)
                            ? "-"
                            : newValue;
                    break;

                case BotConfigEditType.HelpString:
                    bc.HelpString = string.IsNullOrWhiteSpace(newValue)
                            ? "-"
                            : newValue;
                    break;

                case BotConfigEditType.CurrencyDropAmount:
                    if (int.TryParse(newValue, out var amount) && amount > 0)
                    {
                        bc.CurrencyDropAmount = amount;
                    }
                    else
                    {
                        return(false);
                    }
                    break;

                case BotConfigEditType.CurrencyDropAmountMax:
                    if (newValue == null)
                    {
                        bc.CurrencyDropAmountMax = null;
                    }
                    else if (int.TryParse(newValue, out var maxAmount) && maxAmount > 0)
                    {
                        bc.CurrencyDropAmountMax = maxAmount;
                    }
                    else
                    {
                        return(false);
                    }
                    break;

                case BotConfigEditType.MinimumBetAmount:
                    if (int.TryParse(newValue, out var minBetAmount) && minBetAmount > 0)
                    {
                        bc.MinimumBetAmount = minBetAmount;
                    }
                    else
                    {
                        return(false);
                    }
                    break;

                case BotConfigEditType.TriviaCurrencyReward:
                    if (int.TryParse(newValue, out var triviaReward) && triviaReward > 0)
                    {
                        bc.TriviaCurrencyReward = triviaReward;
                    }
                    else
                    {
                        return(false);
                    }
                    break;

                case BotConfigEditType.Betroll100Multiplier:
                    if (float.TryParse(newValue, out var br100) && br100 > 0)
                    {
                        bc.Betroll100Multiplier = br100;
                    }
                    else
                    {
                        return(false);
                    }
                    break;

                case BotConfigEditType.Betroll91Multiplier:
                    if (int.TryParse(newValue, out var br91) && br91 > 0)
                    {
                        bc.Betroll91Multiplier = br91;
                    }
                    else
                    {
                        return(false);
                    }
                    break;

                case BotConfigEditType.Betroll67Multiplier:
                    if (int.TryParse(newValue, out var br67) && br67 > 0)
                    {
                        bc.Betroll67Multiplier = br67;
                    }
                    else
                    {
                        return(false);
                    }
                    break;

                case BotConfigEditType.BetflipMultiplier:
                    if (int.TryParse(newValue, out var bf) && bf > 0)
                    {
                        bc.BetflipMultiplier = bf;
                    }
                    else
                    {
                        return(false);
                    }
                    break;

                case BotConfigEditType.XpPerMessage:
                    if (int.TryParse(newValue, out var xp) && xp > 0)
                    {
                        bc.XpPerMessage = xp;
                    }
                    else
                    {
                        return(false);
                    }
                    break;

                case BotConfigEditType.XpMinutesTimeout:
                    if (int.TryParse(newValue, out var min) && min > 0)
                    {
                        bc.XpMinutesTimeout = min;
                    }
                    else
                    {
                        return(false);
                    }
                    break;

                default:
                    return(false);
                }

                BotConfig = bc;
                uow.Complete();
            }
            return(true);
        }
コード例 #32
0
ファイル: version.cs プロジェクト: uncled1023/IRCBot
 public override void control(bot ircbot, BotConfig Conf, string[] line, string command, int nick_access, string nick, string channel, bool bot_command, string type)
 {
     if ((type.Equals("channel") || type.Equals("query")) && bot_command == true)
     {
         foreach (Command tmp_command in this.Commands)
         {
             bool blocked = tmp_command.Blacklist.Contains(channel) || tmp_command.Blacklist.Contains(nick);
             bool cmd_found = false;
             bool spam_check = ircbot.get_spam_check(channel, nick, tmp_command.Spam_Check);
             if (spam_check == true)
             {
                 blocked = blocked || ircbot.get_spam_status(channel);
             }
             cmd_found = tmp_command.Triggers.Contains(command);
             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 tmp_command.Triggers)
                 {
                     switch (trigger)
                     {
                         case "ver":
                             if (spam_check == true)
                             {
                                 ircbot.add_spam_count(channel);
                             }
                             if (nick_access >= tmp_command.Access)
                             {
                                 if (line.GetUpperBound(0) > 3)
                                 {
                                     ircbot.sendData("PRIVMSG", line[4].Split(' ')[0].Trim() + " :\u0001VERSION\u0001");
                                     List<string> tmp_list = new List<string>();
                                     tmp_list.Add(line[4].Split(' ')[0].Trim());
                                     tmp_list.Add(channel);
                                     version_list.Add(tmp_list);
                                 }
                                 else
                                 {
                                     ircbot.sendData("NOTICE", nick + " :" + nick + ", you need to include more info.");
                                 }
                             }
                             else
                             {
                                 ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command.");
                             }
                             break;
                     }
                 }
             }
         }
     }
     if (type.Equals("query"))
     {
         string version = ":\u0001VERSION\u0001";
         if (line[3] == version)
         {
             ircbot.sendData("NOTICE", nick + " :\u0001VERSION IRCBot v" + Assembly.GetExecutingAssembly().GetName().Version.ToString() + " on " + this.Options["bot_machine"] + "\u0001");
         }
     }
     if (type.Equals("line"))
     {
         string version_reply = ":\u0001VERSION";
         if (line.GetUpperBound(0) > 3)
         {
             if (line[3].Equals(version_reply))
             {
                 for (int x = 0; x < version_list.Count(); x++)
                 {
                     if (version_list[x][0].Equals(nick, StringComparison.InvariantCultureIgnoreCase))
                     {
                         string response = "[" + nick + "] Using version: " + line[4].Replace("\u0001", "");
                         ircbot.sendData("PRIVMSG", version_list[x][1] + " :" + response);
                         version_list.RemoveAt(x);
                         break;
                     }
                 }
             }
         }
     }
 }
コード例 #33
0
ファイル: flood_control.cs プロジェクト: uncled1023/IRCBot
 public override void control(bot ircbot, BotConfig Conf, string[] line, string command, int nick_access, string nick, string channel, bool bot_command, string type)
 {
     int max_lines = Convert.ToInt32(this.Options["max_lines"]);
     int check_timeout = Convert.ToInt32(this.Options["spam_timeout"]);
     bool warn = this.Options["warn"];
     string warn_msg = this.Options["warn_msg"];
     bool kick = this.Options["kick"];
     string kick_msg = this.Options["kick_msg"];
     bool ban = this.Options["ban"];
     string ban_msg = this.Options["ban_msg"];
     if (type.Equals("channel"))
     {
         bool nick_found = false;
         int cur_lines = 0;
         int index = 0;
         foreach (spam_check spam_log in spam_logs)
         {
             if (spam_log.channel.Equals(channel) && spam_log.nick.Equals(nick, StringComparison.InvariantCultureIgnoreCase) && !nick.Equals(ircbot.Nick, StringComparison.InvariantCultureIgnoreCase))
             {
                 nick_found = true;
                 cur_lines = spam_log.lines;
                 break;
             }
             index++;
         }
         if (cur_lines >= max_lines)
         {
             if (warn)
             {
                 ircbot.sendData("PRIVMSG", channel + " :" + warn_msg);
             }
             if (ban)
             {
                 string target_host = ircbot.get_nick_host(nick);
                 string tmp_ban = "*!*@" + target_host;
                 if (String.IsNullOrEmpty(target_host))
                 {
                     tmp_ban = nick + "!*@*";
                 }
                 ircbot.sendData("MODE", line[2] + " +b " + tmp_ban + " :" + ban_msg);
             }
             if (kick)
             {
                 ircbot.sendData("KICK", channel + " " + nick + " :" + kick_msg);
             }
             spam_logs[index].timer.Enabled = false;
             spam_logs.RemoveAt(index);
         }
         else
         {
             if (nick_found)
             {
                 spam_logs[index].lines++;
             }
             else if (!nick.Equals(ircbot.Nick, StringComparison.InvariantCultureIgnoreCase))
             {
                 spam_check tmp_spam = new spam_check();
                 tmp_spam.channel = channel;
                 tmp_spam.nick = nick;
                 tmp_spam.lines = 1;
                 Timer tmp_timer = new Timer();
                 tmp_timer.Interval = check_timeout;
                 tmp_timer.Elapsed += (sender, e) => spam_tick(sender, e, channel, nick);
                 tmp_timer.Enabled = true;
                 tmp_timer.AutoReset = false;
                 tmp_spam.timer = tmp_timer;
                 spam_logs.Add(tmp_spam);
             }
         }
     }
 }
コード例 #34
0
ファイル: messaging.cs プロジェクト: uncled1023/IRCBot
 public override void control(bot ircbot, BotConfig Conf, string[] line, string command, int nick_access, string nick, string channel, bool bot_command, string type)
 {
     if (type.Equals("channel") || type.Equals("query") && bot_command == true)
     {
         foreach (Command tmp_command in this.Commands)
         {
             bool blocked = tmp_command.Blacklist.Contains(channel) || tmp_command.Blacklist.Contains(nick);
             bool cmd_found = false;
             bool spam_check = ircbot.get_spam_check(channel, nick, tmp_command.Spam_Check);
             if (spam_check == true)
             {
                 blocked = blocked || ircbot.get_spam_status(channel);
             }
             cmd_found = tmp_command.Triggers.Contains(command);
             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 tmp_command.Triggers)
                 {
                     switch (trigger)
                     {
                         case "message":
                             if (spam_check == true)
                             {
                                 ircbot.add_spam_count(channel);
                             }
                             if (nick_access >= tmp_command.Access)
                             {
                                 if (line.GetUpperBound(0) > 3)
                                 {
                                     if (type.Equals("channel"))
                                     {
                                         add_message(nick, line, channel, ircbot);
                                     }
                                     else
                                     {
                                         add_message(nick, line, null, ircbot);
                                     }
                                 }
                                 else
                                 {
                                     if (type.Equals("channel"))
                                     {
                                         ircbot.sendData("PRIVMSG", channel + " :" + nick + ", you need to include more info.");
                                     }
                                     else
                                     {
                                         ircbot.sendData("PRIVMSG", nick + " :" + nick + ", you need to include more info.");
                                     }
                                 }
                             }
                             break;
                         case "anonmessage":
                             if (spam_check == true)
                             {
                                 ircbot.add_spam_count(channel);
                             }
                             if (nick_access >= tmp_command.Access)
                             {
                                 if (line.GetUpperBound(0) > 3)
                                 {
                                     if (type.Equals("channel"))
                                     {
                                         add_anonmessage(nick, line, channel, ircbot);
                                     }
                                     else
                                     {
                                         add_anonmessage(nick, line, null, ircbot);
                                     }
                                 }
                                 else
                                 {
                                     if (type.Equals("channel"))
                                     {
                                         ircbot.sendData("PRIVMSG", channel + " :" + nick + ", you need to include more info.");
                                     }
                                     else
                                     {
                                         ircbot.sendData("PRIVMSG", nick + " :" + nick + ", you need to include more info.");
                                     }
                                 }
                             }
                             break;
                     }
                 }
             }
         }
     }
     if (type.Equals("channel") || type.Equals("query") || type.Equals("join") || type.Equals("mode"))
     {
         find_message(nick, ircbot);
     }
 }
コード例 #35
0
 public BotConfigProvider(DbService db, BotConfig bc, IDataCache cache)
 {
     _db       = db;
     _cache    = cache;
     BotConfig = bc;
 }
コード例 #36
0
 public e621Command(IHttpClientFactory httpClientFactory, BotConfig config) : base(httpClientFactory)
 {
     baseUrl  = "https://e621.net/posts.json?tags=";
     _config  = config;
     username = _config.e6API.Value;
 }
コード例 #37
0
ファイル: DBConnection.cs プロジェクト: byBlurr/bBotLibrary
        public bool IsConnect()
        {
            if (Connection == null)
            {
                if (String.IsNullOrEmpty(databaseName))
                {
                    return(false);
                }

                string connstring = $"Server=127.0.0.1; database={databaseName}; UID=root; password={BotConfig.Load().DatabasePassword}";
                connection = new MySqlConnection(connstring);
                connection.Open();
            }

            return(true);
        }
コード例 #38
0
ファイル: Program.cs プロジェクト: AHpxChina/HeliumBot
        static async Task Main(string[] args)
        {
            var isDebugging = false;

            #region Initilize Bot

            Bot bot = null;

            BotConfig     botConfig     = null;
            GenshinConfig genshinConfig = null;

            Console.WriteLine("Use /help for command help");
            while (!isDebugging)
            {
                switch (Console.ReadLine())
                {
                case "/exit":
                    if (bot != null)
                    {
                        await bot.Terminate();
                    }
                    return;

                case "/bot config write":
                    Configurator <BotConfig> .WriteConfig(botConfig);

                    Logger.Log("Bot config wroted");
                    break;

                case "/bot config read":
                    botConfig = Configurator <BotConfig> .ReadConfig();

                    Logger.Log("Tried to read bot config");
                    break;

                case "/bot config generate":
                    Configurator <BotConfig> .GenerateConfig();

                    Logger.Log("Empty bot config generated");
                    break;

                case "/genshin config write":
                    Configurator <GenshinConfig> .WriteConfig(genshinConfig);

                    Logger.Log("Bot config wroted");
                    break;

                case "/genshin config read":
                    genshinConfig = Configurator <GenshinConfig> .ReadConfig();

                    Logger.Log("Tried to read config");
                    break;

                case "/genshin config generate":
                    Configurator <GenshinConfig> .GenerateConfig();

                    Logger.Log("Empty config generated");
                    break;

                case "/genshin generate dictionary":
                    Configurator <GenshinDictionary> .GenerateConfig();

                    Logger.Log("Empty genshin dictionary generated");
                    break;

                case "/bot launch":
                    var configFile      = new FileInfo(@".\Helium\BotConfig.json");
                    var newGenerateText = JsonConvert.SerializeObject(new BotConfig(), Formatting.Indented);
                    if (configFile.Exists && File.ReadAllText(configFile.FullName) != newGenerateText)
                    {
                        botConfig = Configurator <BotConfig> .ReadConfig();

                        Logger.Log("Tried to read config");
                    }

                    if (botConfig != null)
                    {
                        bot = new Bot
                        {
                            SessionHost = botConfig.SessionHost,
                            SessionPort = botConfig.SessionPort,
                            SessionKey  = botConfig.SessionKey,
                            BotQQ       = botConfig.BotQQ,
                            Plugins     = new IPlugin[]
                            {
                                new HelloWorldPlugin(),
                                new GenshinPlugin
                                {
                                    CommandBases = new CommandBase[]
                                    {
                                        new GenshinIndexCommand(),
                                        new GenshinAbyssCommand()
                                    }
                                }
                            }
                        }
                    }
                    ;

                    if (bot != null)
                    {
                        await bot.Launch();
                    }
                    break;

                case "/bot terminate":
                    await bot !.Terminate();
                    break;

                default:
                    Console.WriteLine("Usage:");
                    Console.WriteLine("/help : view commands help");
                    Console.WriteLine("/exit : exit plugin and dispose resources");
                    Console.WriteLine("/bot launch : launch bot by bot config");
                    Console.WriteLine("/bot terminate : stop bot and dispose resources but not exit plugin");
                    Console.WriteLine("/genshin generate dictionary : generate a empty genshin dictionary");
                    Console.WriteLine("/<module> config generate : generate a empty config json");
                    Console.WriteLine("/<module> config read : read config json");
                    Console.WriteLine("/<module> config write : write config json");
                    break;
                }
            }

            #endregion

            var command = new GenshinIndexCommand();
            var re      = await command.Execute(new CommandUsage
            {
                MainParam = "709195224",
                Options   = new[] { "-Avatar" },
                Prefix    = command.GetCommandPrefix()
            });

            Console.WriteLine(string.Join("\n", re));
        }
コード例 #39
0
 public override void control(bot ircbot, BotConfig Conf, string[] line, string command, int nick_access, string nick, string channel, bool bot_command, string type)
 {
     if ((type.Equals("channel") || type.Equals("query")) && bot_command == true)
     {
         foreach (Command tmp_command in this.Commands)
         {
             bool blocked    = tmp_command.Blacklist.Contains(channel) || tmp_command.Blacklist.Contains(nick);
             bool cmd_found  = false;
             bool spam_check = ircbot.get_spam_check(channel, nick, tmp_command.Spam_Check);
             if (spam_check == true)
             {
                 blocked = blocked || ircbot.get_spam_status(channel);
             }
             cmd_found = tmp_command.Triggers.Contains(command);
             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 tmp_command.Triggers)
                 {
                     switch (trigger)
                     {
                     case "last":
                         if (spam_check == true)
                         {
                             ircbot.add_spam_count(channel);
                         }
                         if (nick_access >= tmp_command.Access)
                         {
                             if (line.GetUpperBound(0) > 3)
                             {
                                 string[] args = line[4].Split(' ');
                                 if (type.Equals("channel"))
                                 {
                                     if (args.GetUpperBound(0) > 1)
                                     {
                                         int  n;
                                         bool isNumeric = int.TryParse(args[2], out n);
                                         if (isNumeric)
                                         {
                                             display_log_nick_num(args[1], Convert.ToInt32(args[2]), channel, nick, args[0], ircbot, Conf);
                                         }
                                         else
                                         {
                                             ircbot.sendData("NOTICE", nick + " :" + nick + ", you need to specify a valid number.");
                                         }
                                     }
                                     else if (args.GetUpperBound(0) > 0)
                                     {
                                         int  n;
                                         bool isNumeric = int.TryParse(args[1], out n);
                                         if (isNumeric)
                                         {
                                             display_log_number(Convert.ToInt32(args[1]), channel, nick, args[0], ircbot, Conf);
                                         }
                                         else
                                         {
                                             display_log_nick(args[1], channel, nick, args[0], ircbot, Conf);
                                         }
                                     }
                                     else
                                     {
                                         display_log(channel, nick, line[4], ircbot, Conf);
                                     }
                                 }
                                 else
                                 {
                                     if (args.GetUpperBound(0) > 0)
                                     {
                                         display_log_nick(args[1], channel, nick, args[0], ircbot, Conf);
                                     }
                                     else
                                     {
                                         display_log(channel, nick, line[4], ircbot, Conf);
                                     }
                                 }
                             }
                             else
                             {
                                 display_last_log(channel, nick, ircbot, Conf);
                             }
                         }
                         else
                         {
                             ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command.");
                         }
                         break;
                     }
                 }
             }
         }
     }
     if (type.Equals("query") && bot_command == true)
     {
         bool command_valid = false;
         foreach (Module tmp_module in Conf.Modules)
         {
             foreach (Command tmp_command in tmp_module.Commands)
             {
                 command_valid = tmp_command.Triggers.Contains(command);
                 if (command_valid == true)
                 {
                     add_log(nick, "a private message", line, ircbot);
                 }
             }
         }
     }
     if (type.Equals("channel") && bot_command == true)
     {
         bool command_valid = false;
         foreach (Module tmp_module in Conf.Modules)
         {
             foreach (Command tmp_command in tmp_module.Commands)
             {
                 command_valid = tmp_command.Triggers.Contains(command);
                 if (command_valid == true)
                 {
                     add_log(nick, channel, line, ircbot);
                 }
             }
         }
     }
 }
コード例 #40
0
        public static void WriteConfig(BotConfig bot)
        {
            string json = JsonConvert.SerializeObject(bot, Formatting.Indented);

            File.WriteAllText(ConfigPath, json);
        }
コード例 #41
0
        private static void display_log_nick_num(string nick, int number, string channel, string requst_nick, string command, bot ircbot, BotConfig Conf)
        {
            string file_name = ircbot.Conf.Server_Name + ".log";
            bool   cmd_found = false;

            if (File.Exists(ircbot.cur_dir + Path.DirectorySeparatorChar + "modules" + Path.DirectorySeparatorChar + "logging" + Path.DirectorySeparatorChar + file_name))
            {
                string[] log_file                  = System.IO.File.ReadAllLines(ircbot.cur_dir + Path.DirectorySeparatorChar + "modules" + Path.DirectorySeparatorChar + "logging" + Path.DirectorySeparatorChar + file_name);
                int      number_of_lines           = log_file.GetUpperBound(0) + 1;
                List <List <string> > command_list = new List <List <string> >();
                if (number_of_lines > 0)
                {
                    int    num_uses   = 0;
                    string parameters = "";
                    string date       = "";
                    string inside     = "";
                    foreach (string line in log_file)
                    {
                        List <string> tmp_list = new List <string>();
                        char[]        sep      = new char[] { '*' };
                        string[]      new_line = line.Split(sep, 5);
                        if (new_line.GetUpperBound(0) > 0)
                        {
                            if (new_line[0].Equals(nick, StringComparison.InvariantCultureIgnoreCase) && new_line[3].Equals(command))
                            {
                                tmp_list.Add(new_line[0]);
                                tmp_list.Add(new_line[1]);
                                tmp_list.Add(new_line[2]);
                                tmp_list.Add(new_line[3]);
                                tmp_list.Add(new_line[4]);
                                command_list.Add(tmp_list);
                                num_uses++;
                                cmd_found = true;
                            }
                        }
                    }
                    if (cmd_found == true)
                    {
                        if (number < num_uses && number >= 0)
                        {
                            if (!String.IsNullOrEmpty(command_list[number][4]))
                            {
                                parameters = " with the following argument: " + command_list[number][4];
                            }
                            else
                            {
                                parameters = "";
                            }
                            date   = command_list[number][2];
                            inside = command_list[number][1];
                            nick   = command_list[number][0];
                            ircbot.sendData("NOTICE", requst_nick + " :" + nick + " used " + ircbot.Conf.Command + command + " on " + date + " in " + inside + parameters);
                        }
                        else
                        {
                            ircbot.sendData("NOTICE", requst_nick + " :" + nick + " has not used " + ircbot.Conf.Command + command + " that many times");
                        }
                    }
                    else
                    {
                        ircbot.sendData("NOTICE", requst_nick + " :" + nick + " has not used " + ircbot.Conf.Command + command);
                    }
                }
                else
                {
                    ircbot.sendData("NOTICE", requst_nick + " :" + nick + " has not used any commands");
                }
            }
            else
            {
                ircbot.sendData("NOTICE", requst_nick + " :" + nick + " has not used any commands");
            }
        }
コード例 #42
0
        //private CancellationToken _cancelToken; //if we are interrupted during startup
        //private CancellationToken _stoppingToken; //if we are signaled to stop

        public SlackConnectionHost(ILogger logger, BotConfig config, MessageDispatcher dispatcher, ISlackClientFactory factory)
        {
            _logger     = logger ?? throw new System.ArgumentNullException(nameof(logger));
            _config     = config ?? throw new System.ArgumentNullException(nameof(config));
            _dispatcher = dispatcher ?? throw new System.ArgumentNullException(nameof(dispatcher));
        }
コード例 #43
0
        public void EnsureSeedData()
        {
            if (!BotConfig.Any())
            {
                var bc = new BotConfig();

                bc.RaceAnimals.AddRange(new HashSet <RaceAnimal>
                {
                    new RaceAnimal {
                        Icon = "🐼", Name = "Panda"
                    },
                    new RaceAnimal {
                        Icon = "🐻", Name = "Bear"
                    },
                    new RaceAnimal {
                        Icon = "🐧", Name = "Pengu"
                    },
                    new RaceAnimal {
                        Icon = "🐨", Name = "Koala"
                    },
                    new RaceAnimal {
                        Icon = "🐬", Name = "Dolphin"
                    },
                    new RaceAnimal {
                        Icon = "🐞", Name = "Ladybug"
                    },
                    new RaceAnimal {
                        Icon = "🦀", Name = "Crab"
                    },
                    new RaceAnimal {
                        Icon = "🦄", Name = "Unicorn"
                    }
                });
                bc.EightBallResponses.AddRange(new HashSet <EightBallResponse>
                {
                    new EightBallResponse()
                    {
                        Text = "Most definitely yes"
                    },
                    new EightBallResponse()
                    {
                        Text = "For sure"
                    },
                    new EightBallResponse()
                    {
                        Text = "Totally!"
                    },
                    new EightBallResponse()
                    {
                        Text = "Of course!"
                    },
                    new EightBallResponse()
                    {
                        Text = "As I see it, yes"
                    },
                    new EightBallResponse()
                    {
                        Text = "My sources say yes"
                    },
                    new EightBallResponse()
                    {
                        Text = "Yes"
                    },
                    new EightBallResponse()
                    {
                        Text = "Most likely"
                    },
                    new EightBallResponse()
                    {
                        Text = "Perhaps"
                    },
                    new EightBallResponse()
                    {
                        Text = "Maybe"
                    },
                    new EightBallResponse()
                    {
                        Text = "Not sure"
                    },
                    new EightBallResponse()
                    {
                        Text = "It is uncertain"
                    },
                    new EightBallResponse()
                    {
                        Text = "Totes"
                    },
                    new EightBallResponse()
                    {
                        Text = "Roll a d20"
                    },
                    new EightBallResponse()
                    {
                        Text = "Don't count on it"
                    },
                    new EightBallResponse()
                    {
                        Text = "Probably not"
                    },
                    new EightBallResponse()
                    {
                        Text = "Very doubtful"
                    },
                    new EightBallResponse()
                    {
                        Text = "Most likely no"
                    },
                    new EightBallResponse()
                    {
                        Text = "Crit fail! `1d20` = (1) = 1. Rocks fall, you die."
                    },
                    new EightBallResponse()
                    {
                        Text = "No"
                    },
                    new EightBallResponse()
                    {
                        Text = "My sources say no"
                    },
                    new EightBallResponse()
                    {
                        Text = "Dont even think about it"
                    },
                    new EightBallResponse()
                    {
                        Text = "Definitely no"
                    },
                    new EightBallResponse()
                    {
                        Text = "NO - Absolutely not!"
                    }
                });

                BotConfig.Add(bc);

                this.SaveChanges();
            }
        }
コード例 #44
0
ファイル: fun.cs プロジェクト: uncled1023/IRCBot
        public override void control(bot ircbot, BotConfig Conf, string[] line, string command, int nick_access, string nick, string channel, bool bot_command, string type)
        {
            if ((type.Equals("channel") || type.Equals("query")) && bot_command == true)
            {
                foreach (Command tmp_command in this.Commands)
                {
                    bool blocked    = tmp_command.Blacklist.Contains(channel) || tmp_command.Blacklist.Contains(nick);
                    bool cmd_found  = false;
                    bool spam_check = ircbot.get_spam_check(channel, nick, tmp_command.Spam_Check);
                    if (spam_check == true)
                    {
                        blocked = blocked || ircbot.get_spam_status(channel);
                    }
                    cmd_found = tmp_command.Triggers.Contains(command);
                    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 tmp_command.Triggers)
                        {
                            switch (trigger)
                            {
                            case "love":
                                if (spam_check == true)
                                {
                                    ircbot.add_spam_count(channel);
                                }
                                if (nick_access >= tmp_command.Access)
                                {
                                    if (line.GetUpperBound(0) > 3)
                                    {
                                        Random random  = new Random();
                                        int    ran_num = random.Next(0, 3);
                                        switch (ran_num)
                                        {
                                        case 0:
                                            ircbot.sendData("PRIVMSG", channel + " :\u0001ACTION Gently makes love to " + line[4] + "\u0001");
                                            break;

                                        case 1:
                                            ircbot.sendData("PRIVMSG", channel + " :\u0001ACTION sings a love ballad to " + line[4] + "\u0001");
                                            break;

                                        case 2:
                                            ircbot.sendData("PRIVMSG", channel + " :\u0001ACTION slowly sneaks up behind " + line[4] + "\u0001");
                                            ircbot.sendData("PRIVMSG", channel + " :\u0001ACTION squeezes " + line[4] + " tightly\u0001");
                                            ircbot.sendData("PRIVMSG", line[4] + " :I'll give you some more later tonight.  ;)");
                                            break;

                                        case 3:
                                            ircbot.sendData("PRIVMSG", channel + " :I love you " + line[4] + "!  Sooo much!");
                                            break;
                                        }
                                    }
                                    else
                                    {
                                        ircbot.sendData("PRIVMSG", channel + " :" + nick + ", you need to include more info.");
                                    }
                                }
                                else
                                {
                                    ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command.");
                                }
                                break;

                            case "hug":
                                if (spam_check == true)
                                {
                                    ircbot.add_spam_count(channel);
                                }
                                if (nick_access >= tmp_command.Access)
                                {
                                    if (line.GetUpperBound(0) > 3)
                                    {
                                        ircbot.sendData("PRIVMSG", channel + " :\u0001ACTION hugs " + line[4] + "\u0001");
                                    }
                                    else
                                    {
                                        ircbot.sendData("PRIVMSG", channel + " :\u0001ACTION hugs " + nick + "\u0001");
                                    }
                                }
                                else
                                {
                                    ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command.");
                                }
                                break;

                            case "slap":
                                if (spam_check == true)
                                {
                                    ircbot.add_spam_count(channel);
                                }
                                if (nick_access >= tmp_command.Access)
                                {
                                    if (line.GetUpperBound(0) > 3)
                                    {
                                        ircbot.sendData("PRIVMSG", channel + " :\u0001ACTION slaps " + line[4] + " with a large trout\u0001");
                                    }
                                    else
                                    {
                                        ircbot.sendData("PRIVMSG", channel + " :\u0001ACTION slaps " + nick + " with a large trout\u0001");
                                    }
                                }
                                else
                                {
                                    ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command.");
                                }
                                break;

                            case "bots":
                                if (spam_check == true)
                                {
                                    ircbot.add_spam_count(channel);
                                }
                                if (nick_access >= tmp_command.Access)
                                {
                                    ircbot.sendData("PRIVMSG", channel + " :Reporting in!");
                                }
                                else
                                {
                                    ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command.");
                                }
                                break;

                            case "br":
                                if (spam_check == true)
                                {
                                    ircbot.add_spam_count(channel);
                                }
                                if (nick_access >= tmp_command.Access)
                                {
                                    ircbot.sendData("PRIVMSG", channel + " :HUEHUEHUE");
                                }
                                else
                                {
                                    ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command.");
                                }
                                break;

                            case "net":
                                if (spam_check == true)
                                {
                                    ircbot.add_spam_count(channel);
                                }
                                if (nick_access >= tmp_command.Access)
                                {
                                    ircbot.sendData("PRIVMSG", channel + " :Sure is enterprise quality in here");
                                }
                                else
                                {
                                    ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command.");
                                }
                                break;
                            }
                        }
                    }
                }
            }
        }
コード例 #45
0
 public TranslatingService(BotConfig config)
 {
     _config = config;
 }
コード例 #46
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MealService" /> class.
 /// </summary>
 /// <param name="httpClient">The HTTP client.</param>
 /// <param name="botConfig">The bot configuration.</param>
 public MealService(HttpClient httpClient, BotConfig botConfig)
 {
     this.httpClient = httpClient;
     this.config     = botConfig;
 }
コード例 #47
0
        public async Task Settings()
        {
            await Context.Message.DeleteAsync();

            string serverName      = "Bruze MPG Community";
            string token           = BotConfig.Load().Token;
            string prefix          = BotConfig.Load().Prefix;
            string newUserRank     = BotConfig.Load().NewMemberRank;
            string userRank        = BotConfig.Load().UserRank;
            string musicRank       = BotConfig.Load().MusicRank;
            string programmingRank = BotConfig.Load().ProgrammingRank;
            string graphicsRank    = BotConfig.Load().GraphicsRank;

            var embed = new EmbedBuilder()
            {
                Color = Colours.adminCol
            };
            var serverNameField = new EmbedFieldBuilder()
            {
                Name = "Server Name", Value = serverName
            };
            var tokenField = new EmbedFieldBuilder()
            {
                Name = "Bot Token", Value = token, IsInline = true
            };
            var prefixField = new EmbedFieldBuilder()
            {
                Name = "Bot Prefix", Value = prefix, IsInline = true
            };
            var newUserField = new EmbedFieldBuilder()
            {
                Name = "New User Rank", Value = newUserRank, IsInline = true
            };
            var userField = new EmbedFieldBuilder()
            {
                Name = "User Rank", Value = userRank, IsInline = true
            };
            var musicField = new EmbedFieldBuilder()
            {
                Name = "Music Rank", Value = musicRank, IsInline = true
            };
            var programmingField = new EmbedFieldBuilder()
            {
                Name = "Programming Rank", Value = programmingRank, IsInline = true
            };
            var graphicsField = new EmbedFieldBuilder()
            {
                Name = "Graphics Rank", Value = graphicsRank, IsInline = true
            };

            string lol    = "---------------------------------------------------------------------------------------------------";
            string lol1   = "-------------------------------------------------------------------------------------------------";
            var    title1 = new EmbedFieldBuilder()
            {
                Name = lol, Value = lol1
            };
            var title2 = new EmbedFieldBuilder()
            {
                Name = lol, Value = lol1
            };
            var title3 = new EmbedFieldBuilder()
            {
                Name = lol, Value = lol1
            };

            embed.Title       = ("Current Server Settings");
            embed.Description = ("Here are all the current server settings.");
            embed.AddField(serverNameField);
            embed.AddField(title1);
            embed.AddField(tokenField);
            embed.AddField(prefixField);
            embed.AddField(title2);
            embed.AddField(newUserField);
            embed.AddField(userField);
            embed.AddField(title3);
            embed.AddField(musicField);
            embed.AddField(programmingField);
            embed.AddField(graphicsField);

            var message = await Context.Channel.SendMessageAsync("", false, embed);

            await Delete.DelayDeleteEmbed(message, 30);
        }
コード例 #48
0
 public SerilogGatewayEnricherFactory(Bot bot, IDiscordCache cache, BotConfig botConfig)
 {
     _bot       = bot;
     _cache     = cache;
     _botConfig = botConfig;
 }
コード例 #49
0
ファイル: quote.cs プロジェクト: uncled1023/IRCBot
 private static void get_specific_quote(string channel, string nick, bot ircbot, BotConfig Conf)
 {
     string tab_name = channel.TrimStart('#');
     string pattern = "[^a-zA-Z0-9]"; //regex pattern
     tab_name = Regex.Replace(tab_name, pattern, "_");
     string file_name = ircbot.Conf.Server_Name + "_#" + tab_name + ".log";
     if (File.Exists(ircbot.cur_dir + Path.DirectorySeparatorChar + "modules" + Path.DirectorySeparatorChar + "quotes" + Path.DirectorySeparatorChar + "logs" + Path.DirectorySeparatorChar + file_name))
     {
         string[] log_file = System.IO.File.ReadAllLines(ircbot.cur_dir + Path.DirectorySeparatorChar + "modules" + Path.DirectorySeparatorChar + "quotes" + Path.DirectorySeparatorChar + "logs" + Path.DirectorySeparatorChar + file_name);
         int number_of_lines = log_file.GetUpperBound(0) + 1;
         if (number_of_lines > 0)
         {
             string line = "";
             string line_nick = "";
             bool nick_found = false;
             List<string> quote_list = new List<string>();
             foreach (string file_line in log_file)
             {
                 char[] charSep = new char[] { '*' };
                 string[] tmp_line = file_line.Split(charSep, 2);
                 line_nick = tmp_line[0];
                 if (nick.Equals(line_nick.Trim(), StringComparison.InvariantCultureIgnoreCase))
                 {
                     nick_found = true;
                     quote_list.Add(file_line);
                 }
             }
             line_nick = "";
             line = "";
             if (nick_found == true)
             {
                 Random random = new Random();
                 number_of_lines = quote_list.Count();
                 int index = random.Next(0, number_of_lines);
                 if (quote_list.Count > 1)
                 {
                     index--;
                 }
                 line = quote_list[index];
                 if (!String.IsNullOrEmpty(line))
                 {
                     char[] charSep = new char[] { '*' };
                     string[] lines = line.Split(charSep, 2);
                     ircbot.sendData("PRIVMSG", channel + " :" + lines[1] + " [" + lines[0] + "]");
                 }
                 else
                 {
                     ircbot.sendData("PRIVMSG", channel + " :There was an issue getting logs for " + nick);
                 }
             }
             else
             {
                 ircbot.sendData("PRIVMSG", channel + " :There are currently no logs for " + nick);
             }
         }
         else
         {
             ircbot.sendData("PRIVMSG", channel + " :There are currently no logs for " + channel);
         }
     }
     else
     {
         ircbot.sendData("PRIVMSG", channel + " :There are currently no logs for " + channel);
     }
 }
コード例 #50
0
        //Initialize The Client And Config.
        public BasicBotClient(CommandService commands = null, DiscordSocketClient client = null, BotConfig config = null, Logger logger = null)
        {
            //Create our new DiscordClient (Setting LogServerity to Verbose)
            _client = client ?? new DiscordSocketClient(new DiscordSocketConfig {
                LogLevel            = LogSeverity.Verbose,
                AlwaysDownloadUsers = true,
                MessageCacheSize    = 100
            });

            //Create our new CommandService (Setting RunMode to async by default on all commands)
            _commands = commands ?? new CommandService(new CommandServiceConfig {
                DefaultRunMode        = RunMode.Async,
                CaseSensitiveCommands = false,
                LogLevel = LogSeverity.Verbose
            });

            //Get our config data from DataStorage. (config.json)
            _config = config ?? new ConfigDataHandler().GetConfig();

            //Setup our logger
            _logger = logger ?? new Logger();
        }
コード例 #51
0
ファイル: quote.cs プロジェクト: uncled1023/IRCBot
        public override void control(bot ircbot, BotConfig Conf, string[] line, string command, int nick_access, string nick, string channel, bool bot_command, string type)
        {
            if (type.Equals("channel") && bot_command == true)
            {
                foreach (Command tmp_command in this.Commands)
                {
                    bool blocked = tmp_command.Blacklist.Contains(channel) || tmp_command.Blacklist.Contains(nick);
                    bool cmd_found = false;
                    bool spam_check = ircbot.get_spam_check(channel, nick, tmp_command.Spam_Check);
                    if (spam_check == true)
                    {
                        blocked = blocked || ircbot.get_spam_status(channel);
                    }
                    cmd_found = tmp_command.Triggers.Contains(command);
                    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 tmp_command.Triggers)
                        {
                            switch (trigger)
                            {
                                case "quote":
                                    if (spam_check == true)
                                    {
                                        ircbot.add_spam_count(channel);
                                    }
                                    if (nick_access >= tmp_command.Access)
                                    {
                                        if (this.Options["allow_lookup"])
                                        {
                                            if (line.GetUpperBound(0) > 3)
                                            {
                                                get_specific_quote(channel, line[4], ircbot, Conf);
                                            }
                                            else
                                            {
                                                get_quote(channel, ircbot, Conf);
                                            }
                                        }
                                        else
                                        {
                                            get_quote(channel, ircbot, Conf);
                                        }
                                    }
                                    else
                                    {
                                        ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command.");
                                    }
                                    break;
                            }
                        }

                    }
                }
            }
            if (type.Equals("channel") && bot_command == false && !nick.Equals(Conf.Nick, StringComparison.InvariantCultureIgnoreCase))
            {
                add_quote(nick, channel, line, ircbot, Conf);
            }
        }
コード例 #52
0
 public EventHookerService(DiscordSocketClient client, CommandService command, LoggerService logger,
                           GuildUserAccountService guildUser, GlobalUserAccountService user, CreateLanguageFilesService language,
                           GuildAccountService guildAccount, CooldownService cooldown, BotConfig config)
 {
     _client       = client;
     _commands     = command;
     _logger       = logger;
     _guildUser    = guildUser;
     _user         = user;
     _language     = language;
     _guildAccount = guildAccount;
     _cooldown     = cooldown;
     _config       = config;
 }
コード例 #53
0
ファイル: about.cs プロジェクト: uncled1023/IRCBot
        public override void control(bot ircbot, BotConfig Conf, string[] line, string command, int nick_access, string nick, string channel, bool bot_command, string type)
        {
            if ((type.Equals("channel") || type.Equals("query")) && bot_command == true)
            {
                foreach (Command tmp_command in this.Commands)
                {
                    bool blocked    = tmp_command.Blacklist.Contains(channel) || tmp_command.Blacklist.Contains(nick);
                    bool cmd_found  = false;
                    bool spam_check = ircbot.get_spam_check(channel, nick, tmp_command.Spam_Check);
                    if (spam_check == true)
                    {
                        blocked = blocked || ircbot.get_spam_status(channel);
                    }
                    cmd_found = tmp_command.Triggers.Contains(command);
                    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 tmp_command.Triggers)
                        {
                            switch (trigger)
                            {
                            case "about":
                                if (spam_check == true)
                                {
                                    ircbot.add_spam_count(channel);
                                }
                                if (nick_access >= tmp_command.Access)
                                {
                                    string owner_num = " is";
                                    if (Conf.Owners.Count > 1)
                                    {
                                        owner_num = "s are";
                                    }
                                    string response = "IRCBot";
                                    if (this.Options["display_version"])
                                    {
                                        response += " v" + Assembly.GetExecutingAssembly().GetName().Version.ToString() + ".";
                                    }
                                    if (this.Options["display_creator"])
                                    {
                                        response += " Created by Uncled1023.";
                                    }
                                    if (this.Options["display_owner"])
                                    {
                                        if (Conf.Owners.Count >= 1)
                                        {
                                            response += " My owner" + owner_num + " ";
                                            if (Conf.Owners.Count > 1)
                                            {
                                                int index = 1;
                                                foreach (string owner in Conf.Owners)
                                                {
                                                    response += owner;
                                                    if (index == Conf.Owners.Count - 1)
                                                    {
                                                        response += ", and ";
                                                    }
                                                    else if (index < Conf.Owners.Count)
                                                    {
                                                        response += ", ";
                                                    }
                                                    index++;
                                                }
                                            }
                                            else
                                            {
                                                response += Conf.Owners[0];
                                            }
                                        }
                                    }
                                    if (type.Equals("channel"))
                                    {
                                        ircbot.sendData("PRIVMSG", channel + " :" + response);
                                    }
                                    else
                                    {
                                        ircbot.sendData("NOTICE", nick + " :" + response);
                                    }
                                }
                                else
                                {
                                    ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command.");
                                }
                                break;

                            case "source":
                                if (spam_check == true)
                                {
                                    ircbot.add_spam_count(channel);
                                }
                                if (nick_access >= tmp_command.Access)
                                {
                                    if (type.Equals("channel"))
                                    {
                                        ircbot.sendData("PRIVMSG", channel + " :https://github.com/uncled1023/IRCBot");
                                    }
                                    else
                                    {
                                        ircbot.sendData("NOTICE", nick + " :https://github.com/uncled1023/IRCBot");
                                    }
                                }
                                else
                                {
                                    ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command.");
                                }
                                break;

                            case "uptime":
                                if (spam_check == true)
                                {
                                    ircbot.add_spam_count(channel);
                                }
                                if (nick_access >= tmp_command.Access)
                                {
                                    DateTime now = new DateTime();
                                    now = DateTime.Now;
                                    int    days    = now.Subtract(ircbot.start_time).Days;
                                    int    hours   = now.Subtract(ircbot.start_time).Hours;
                                    int    minutes = now.Subtract(ircbot.start_time).Minutes;
                                    int    seconds = now.Subtract(ircbot.start_time).Seconds;
                                    string uptime  = "";
                                    if (days > 0)
                                    {
                                        uptime += days + " days, ";
                                    }
                                    if (hours > 0)
                                    {
                                        uptime += hours + " hours, ";
                                    }
                                    if (minutes > 0)
                                    {
                                        uptime += minutes + " minutes, ";
                                    }
                                    if (seconds > 0)
                                    {
                                        uptime += seconds + " seconds, ";
                                    }
                                    if (type.Equals("channel"))
                                    {
                                        ircbot.sendData("PRIVMSG", channel + " :I have been online for " + uptime.Trim().TrimEnd(','));
                                    }
                                    else
                                    {
                                        ircbot.sendData("NOTICE", nick + " :I have been online for " + uptime.Trim().TrimEnd(','));
                                    }
                                }
                                else
                                {
                                    ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command.");
                                }
                                break;

                            case "runtime":
                                if (spam_check == true)
                                {
                                    ircbot.add_spam_count(channel);
                                }
                                if (nick_access >= tmp_command.Access)
                                {
                                    DateTime now = new DateTime();
                                    now = DateTime.Now;
                                    int    days    = now.Subtract(ircbot.controller.run_time).Days;
                                    int    hours   = now.Subtract(ircbot.controller.run_time).Hours;
                                    int    minutes = now.Subtract(ircbot.controller.run_time).Minutes;
                                    int    seconds = now.Subtract(ircbot.controller.run_time).Seconds;
                                    string uptime  = "";
                                    if (days > 0)
                                    {
                                        uptime += days + " days, ";
                                    }
                                    if (hours > 0)
                                    {
                                        uptime += hours + " hours, ";
                                    }
                                    if (minutes > 0)
                                    {
                                        uptime += minutes + " minutes, ";
                                    }
                                    if (seconds > 0)
                                    {
                                        uptime += seconds + " seconds, ";
                                    }
                                    if (type.Equals("channel"))
                                    {
                                        ircbot.sendData("PRIVMSG", channel + " :I have been running for " + uptime.Trim().TrimEnd(','));
                                    }
                                    else
                                    {
                                        ircbot.sendData("NOTICE", nick + " :I have been running for " + uptime.Trim().TrimEnd(','));
                                    }
                                }
                                else
                                {
                                    ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command.");
                                }
                                break;
                            }
                        }
                    }
                }
            }
        }
コード例 #54
0
ファイル: NadekoContext.cs プロジェクト: TsunCyber/NadekoBot
        public void EnsureSeedData()
        {
            if (!BotConfig.Any())
            {
                var bc = new BotConfig();

                bc.RaceAnimals.AddRange(new HashSet <RaceAnimal>
                {
                    new RaceAnimal {
                        Icon = "🐼", Name = "Panda"
                    },
                    new RaceAnimal {
                        Icon = "🐻", Name = "Bear"
                    },
                    new RaceAnimal {
                        Icon = "🐧", Name = "Pengu"
                    },
                    new RaceAnimal {
                        Icon = "🐨", Name = "Koala"
                    },
                    new RaceAnimal {
                        Icon = "🐬", Name = "Dolphin"
                    },
                    new RaceAnimal {
                        Icon = "🐞", Name = "Ladybird"
                    },
                    new RaceAnimal {
                        Icon = "🦀", Name = "Crab"
                    },
                    new RaceAnimal {
                        Icon = "🦄", Name = "Unicorn"
                    }
                });
                bc.EightBallResponses.AddRange(new HashSet <EightBallResponse>
                {
                    new EightBallResponse()
                    {
                        Text = "Most definitely yes"
                    },
                    new EightBallResponse()
                    {
                        Text = "For sure"
                    },
                    new EightBallResponse()
                    {
                        Text = "Totally!"
                    },
                    new EightBallResponse()
                    {
                        Text = "Of course!"
                    },
                    new EightBallResponse()
                    {
                        Text = "As I see it, yes"
                    },
                    new EightBallResponse()
                    {
                        Text = "My sources say yes"
                    },
                    new EightBallResponse()
                    {
                        Text = "Yes"
                    },
                    new EightBallResponse()
                    {
                        Text = "Most likely"
                    },
                    new EightBallResponse()
                    {
                        Text = "Perhaps"
                    },
                    new EightBallResponse()
                    {
                        Text = "Maybe"
                    },
                    new EightBallResponse()
                    {
                        Text = "Not sure"
                    },
                    new EightBallResponse()
                    {
                        Text = "It is uncertain"
                    },
                    new EightBallResponse()
                    {
                        Text = "Ask me again later"
                    },
                    new EightBallResponse()
                    {
                        Text = "Don't count on it"
                    },
                    new EightBallResponse()
                    {
                        Text = "Probably not"
                    },
                    new EightBallResponse()
                    {
                        Text = "Very doubtful"
                    },
                    new EightBallResponse()
                    {
                        Text = "Most likely no"
                    },
                    new EightBallResponse()
                    {
                        Text = "Nope"
                    },
                    new EightBallResponse()
                    {
                        Text = "No"
                    },
                    new EightBallResponse()
                    {
                        Text = "My sources say no"
                    },
                    new EightBallResponse()
                    {
                        Text = "Dont even think about it"
                    },
                    new EightBallResponse()
                    {
                        Text = "Definitely no"
                    },
                    new EightBallResponse()
                    {
                        Text = "NO - It may cause disease contraction"
                    }
                });

                BotConfig.Add(bc);

                this.SaveChanges();
            }
        }
コード例 #55
0
ファイル: github.cs プロジェクト: uncled1023/IRCBot
 public override void control(bot ircbot, BotConfig Conf, string[] line, string command, int nick_access, string nick, string channel, bool bot_command, string type)
 {
     if ((type.Equals("channel") || type.Equals("query")) && bot_command == true)
     {
         foreach (Command tmp_command in this.Commands)
         {
             bool blocked = tmp_command.Blacklist.Contains(channel) || tmp_command.Blacklist.Contains(nick);
             bool cmd_found = false;
             bool spam_check = ircbot.get_spam_check(channel, nick, tmp_command.Spam_Check);
             if (spam_check == true)
             {
                 blocked = blocked || ircbot.get_spam_status(channel);
             }
             cmd_found = tmp_command.Triggers.Contains(command);
             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 tmp_command.Triggers)
                 {
                     switch (trigger)
                     {
                         case "bug":
                             if (spam_check == true)
                             {
                                 ircbot.add_spam_count(channel);
                             }
                             if (nick_access >= tmp_command.Access)
                             {
                                 if (line.GetUpperBound(0) > 3)
                                 {
                                     string title = "";
                                     string description = "";
                                     string[] split = line[4].Split('|');
                                     title = "[" + nick + "] " + split[0];
                                     if (split.GetUpperBound(0) > 0)
                                     {
                                         description = split[1];
                                     }
                                     List<string> label = new List<string>() { "bug" };
                                     string uri = "https://api.github.com/repos/" + this.Options["username"] + "/" + this.Options["repository"] + "/issues";
                                     string response = post_issue(ircbot, uri, title, description, this.Options["username"], label);
                                     if (String.IsNullOrEmpty(response))
                                     {
                                         ircbot.sendData("NOTICE", nick + " :Issue Added Successfully");
                                     }
                                     else
                                     {
                                         ircbot.sendData("NOTICE", nick + " :" + response);
                                     }
                                 }
                                 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 "request":
                             if (spam_check == true)
                             {
                                 ircbot.add_spam_count(channel);
                             }
                             if (nick_access >= tmp_command.Access)
                             {
                                 if (line.GetUpperBound(0) > 3)
                                 {
                                     string title = "";
                                     string description = "";
                                     string[] split = line[4].Split('|');
                                     title = "[" + nick + "] " + split[0];
                                     if (split.GetUpperBound(0) > 0)
                                     {
                                         description = split[1];
                                     }
                                     List<string> label = new List<string>() { "Feature Request" };
                                     string uri = "https://api.github.com/repos/" + this.Options["username"] + "/" + this.Options["repository"] + "/issues";
                                     string response = post_issue(ircbot, uri, title, description, this.Options["username"], label);
                                     if (String.IsNullOrEmpty(response))
                                     {
                                         ircbot.sendData("NOTICE", nick + " :Feature Request Added Successfully");
                                     }
                                     else
                                     {
                                         ircbot.sendData("NOTICE", nick + " :" + response);
                                     }
                                 }
                                 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;
                     }
                 }
             }
         }
     }
 }
コード例 #56
0
        /// <summary>
        /// Проверка конфигурации на корректность.
        /// </summary>
        /// <param name="config">Конфигурация.</param>
        /// <param name="logger">Логгер.</param>
        /// <returns>Истина, если конфигурация корректна.</returns>
        public static bool CheckConfig(BotConfig config, ILogger logger)
        {
            var validationErrors = new StringBuilder();

            if (config == null)
            {
                validationErrors.AppendLine("Configuration not found");
            }
            else
            {
                if (string.IsNullOrWhiteSpace(config.AuthToken))
                {
                    validationErrors.AppendLine($"{nameof(config.AuthToken)} not defined.");
                }

                if (config.AdminId <= 0)
                {
                    validationErrors.AppendLine($"{nameof(config.AdminId)} not defined.");
                }


                if (config.ProxySettings == null)
                {
                    validationErrors.AppendLine($"{nameof(config.ProxySettings)} not defined.");
                }
                else
                {
                    if (string.IsNullOrWhiteSpace(config.ProxySettings.Address))
                    {
                        validationErrors.AppendLine($"{nameof(config.ProxySettings)}.{nameof(config.ProxySettings.Address)} not defined.");
                    }

                    if (config.ProxySettings.Port <= 0)
                    {
                        validationErrors.AppendLine($"{nameof(config.ProxySettings)}.{nameof(config.ProxySettings.Port)} not defined.");
                    }

                    if (string.IsNullOrWhiteSpace(config.ProxySettings.Username))
                    {
                        validationErrors.AppendLine($"{nameof(config.ProxySettings)}.{nameof(config.ProxySettings.Username)} not defined.");
                    }

                    if (string.IsNullOrWhiteSpace(config.ProxySettings.Password))
                    {
                        validationErrors.AppendLine($"{nameof(config.ProxySettings)}.{nameof(config.ProxySettings.Password)} not defined.");
                    }
                }

                if (config.TorrentServerSettings == null)
                {
                    validationErrors.AppendLine($"{nameof(config.TorrentServerSettings)} not defined.");
                }
                else
                {
                    if (string.IsNullOrWhiteSpace(config.TorrentServerSettings.WatchDirectoryPath))
                    {
                        validationErrors.AppendLine($"{nameof(config.TorrentServerSettings.WatchDirectoryPath)} not defined.");
                    }

                    if (string.IsNullOrWhiteSpace(config.TorrentServerSettings.Address))
                    {
                        validationErrors.AppendLine($"{nameof(config.TorrentServerSettings)}.{nameof(config.TorrentServerSettings.Address)} not defined.");
                    }

                    if (config.TorrentServerSettings.Port <= 0)
                    {
                        validationErrors.AppendLine($"{nameof(config.TorrentServerSettings)}.{nameof(config.TorrentServerSettings.Port)} not defined.");
                    }
                }
            }

            if (validationErrors.Length > 0)
            {
                validationErrors.AppendLine("Awaiting configuration ...");
                logger.LogInformation(validationErrors.ToString());

                return(false);
            }

            return(true);
        }
コード例 #57
0
ファイル: access.cs プロジェクト: uncled1023/IRCBot
 public override void control(bot ircbot, BotConfig Conf, string[] line, string command, int nick_access, string nick, string channel, bool bot_command, string type)
 {
     if ((type.Equals("channel") || type.Equals("query")) && bot_command == true)
     {
         foreach (Command tmp_command in this.Commands)
         {
             bool blocked = tmp_command.Blacklist.Contains(channel) || tmp_command.Blacklist.Contains(nick);
             bool cmd_found = false;
             bool spam_check = ircbot.get_spam_check(channel, nick, tmp_command.Spam_Check);
             if (spam_check == true)
             {
                 blocked = blocked || ircbot.get_spam_status(channel);
             }
             cmd_found = tmp_command.Triggers.Contains(command);
             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 tmp_command.Triggers)
                 {
                     switch (trigger)
                     {
                         case "setaccess":
                             if (spam_check == true)
                             {
                                 ircbot.add_spam_count(channel);
                             }
                             if (nick_access >= tmp_command.Access)
                             {
                                 if (line.GetUpperBound(0) > 3)
                                 {
                                     string[] parse = line[4].Split(' ');
                                     if (type.Equals("query") && parse.GetUpperBound(0) > 1)
                                     {
                                         if (Convert.ToInt32(parse[2]) <= nick_access)
                                         {
                                             set_access_list(parse[0].Trim(), 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(), channel, 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 >= tmp_command.Access)
                             {
                                 if (line.GetUpperBound(0) > 3)
                                 {
                                     string[] parse = line[4].Split(' ');
                                     if (type.Equals("query") && parse.GetUpperBound(0) > 1)
                                     {
                                         if (Convert.ToInt32(parse[2]) <= nick_access)
                                         {
                                             del_access_list(parse[0].Trim(), 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(), channel, 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 >= tmp_command.Access)
                             {
                                 if (type.Equals("query") && line.GetUpperBound(0) > 3)
                                 {
                                     list_access_list(nick, line[4], ircbot);
                                 }
                                 else if (type.Equals("channel"))
                                 {
                                     list_access_list(nick, channel, 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 >= tmp_command.Access)
                             {
                                 if (line.GetUpperBound(0) > 3)
                                 {
                                     string[] new_line = line[4].Split(' ');
                                     if (new_line.GetUpperBound(0) > 0 && new_line[0].StartsWith("#"))
                                     {
                                         int viewed_access = ircbot.get_nick_access(new_line[1].Trim(), 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_nick_access(line[4].Trim(), channel);
                                         ircbot.sendData("NOTICE", nick + " :" + line[4].Trim() + " has access level " + viewed_access.ToString());
                                     }
                                     else
                                     {
                                         int viewed_access = Conf.Default_Level;
                                         foreach (Channel_Info chan in Conf.Channel_List)
                                         {
                                             int tmp_nick_access = ircbot.get_nick_access(line[4].Trim(), chan.Channel);
                                             if (tmp_nick_access > viewed_access)
                                             {
                                                 viewed_access = tmp_nick_access;
                                             }
                                         }
                                         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 + " :You do not have permission to use that command.");
                             }
                             break;
                     }
                 }
             }
         }
     }
 }
コード例 #58
0
 public BotConfigProvider(DbService db, BotConfig bc)
 {
     _db       = db;
     BotConfig = bc;
 }
コード例 #59
0
ファイル: hbomb.cs プロジェクト: uncled1023/IRCBot
        public override void control(bot ircbot, BotConfig Conf, string[] line, string command, int nick_access, string nick, string channel, bool bot_command, string type)
        {
            if (type.Equals("channel") && bot_command == true)
            {
                foreach (Command tmp_command in this.Commands)
                {
                    bool blocked = tmp_command.Blacklist.Contains(channel) || tmp_command.Blacklist.Contains(nick);
                    bool cmd_found = false;
                    bool spam_check = ircbot.get_spam_check(channel, nick, tmp_command.Spam_Check);
                    if (spam_check == true)
                    {
                        blocked = blocked || ircbot.get_spam_status(channel);
                    }
                    cmd_found = tmp_command.Triggers.Contains(command);
                    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 tmp_command.Triggers)
                        {
                            switch (trigger)
                            {
                                case "hbomb":
                                    if (spam_check == true)
                                    {
                                        ircbot.add_spam_count(channel);
                                    }
                                    if (nick_access >= tmp_command.Access)
                                    {
                                        Modules.idle idle = (Modules.idle)ircbot.get_module("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 = this.Options["wire_colors"].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 " + ircbot.Conf.Command + "pass <nick> to pass it to someone else, or type " + ircbot.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 >= tmp_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)
                                            {
                                                Modules.idle idle = (Modules.idle)ircbot.get_module("idle");
                                                if (idle.check_idle(nick) == false)
                                                {
                                                    if (tmp_info.bomb_holder.Equals(nick, StringComparison.InvariantCultureIgnoreCase))
                                                    {
                                                        if (line.GetUpperBound(0) > 3)
                                                        {
                                                            if (line[4].Trim().Equals(ircbot.Nick, StringComparison.InvariantCultureIgnoreCase))
                                                            {
                                                                ircbot.sendData("PRIVMSG", channel + " :" + nick + ", you can't pass it to me!");
                                                            }
                                                            else
                                                            {
                                                                int user_access = ircbot.get_nick_access(line[4].Trim(), channel);
                                                                if (user_access > 0 && idle.check_idle(line[4].Trim()) == false)
                                                                {
                                                                    pass_hbomb(line[4].Trim(), 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 >= tmp_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].Trim().Equals(ircbot.Nick, StringComparison.InvariantCultureIgnoreCase))
                                                {
                                                    ircbot.sendData("PRIVMSG", channel + " :" + nick + ", you can't pass it to me!");
                                                }
                                                else
                                                {
                                                    int user_access = ircbot.get_nick_access(line[4].Trim(), channel);
                                                    if (user_access > 0)
                                                    {
                                                        pass_hbomb(line[4].Trim(), 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 >= tmp_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].Trim().Equals(ircbot.Nick, StringComparison.InvariantCultureIgnoreCase))
                                                {
                                                    ircbot.sendData("PRIVMSG", channel + " :" + nick + ", you can't pass it to me!");
                                                }
                                                else
                                                {
                                                    int user_access = ircbot.get_nick_access(line[4].Trim(), channel);
                                                    if (user_access > 0)
                                                    {
                                                        pass_hbomb(line[4].Trim(), 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;
                                            }
                                            hbombs[index] = tmp_info;
                                        }
                                        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 >= tmp_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 >= tmp_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 >= tmp_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 >= tmp_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)
                                            {
                                                Modules.idle idle = (Modules.idle)ircbot.get_module("idle");
                                                if (idle.check_idle(nick) == false)
                                                {
                                                    if (tmp_info.bomb_holder.Equals(nick, StringComparison.InvariantCultureIgnoreCase))
                                                    {
                                                        if (line.GetUpperBound(0) > 3)
                                                        {
                                                            if (line[4].Trim().Equals(tmp_info.wire_color, StringComparison.InvariantCultureIgnoreCase))
                                                            {
                                                                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;
                            }
                        }
                    }
                }
            }
        }
コード例 #60
0
ファイル: owner.cs プロジェクト: uncled1023/IRCBot
 private static void add_blacklist(string channel, string nick, bot ircbot, BotConfig Conf)
 {
     XmlNode node = ircbot.controller.get_server_xml(Conf.Server_Name);
     string new_blacklist = node["chan_blacklist"].InnerText + "," + channel;
     node["chan_blacklist"].InnerText = new_blacklist.TrimStart(',');
     bool added = ircbot.controller.save_server_xml(Conf.Server_Name, node);
     if (added)
     {
         Conf.Chan_Blacklist += "," + channel;
         Conf.Chan_Blacklist = Conf.Chan_Blacklist.TrimStart(',');
         ircbot.controller.update_conf();
         ircbot.sendData("NOTICE", nick + " :" + channel + " successfully added to the blacklist.");
     }
     else
     {
         ircbot.sendData("NOTICE", nick + " :" + channel + " was not added to the blacklist.");
     }
 }