Esempio n. 1
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 "isitup":
                         if (spam_check == true)
                         {
                             ircbot.add_spam_count(channel);
                         }
                         if (nick_access >= tmp_command.Access)
                         {
                             if (line.GetUpperBound(0) > 3)
                             {
                                 bool isitup = CheckConnection(line[4]);
                                 if (isitup)
                                 {
                                     ircbot.sendData("PRIVMSG", channel + " :" + line[4] + " is up for me!");
                                 }
                                 else
                                 {
                                     ircbot.sendData("PRIVMSG", channel + " :" + line[4] + " looks down for me too.");
                                 }
                             }
                             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;
                     }
                 }
             }
         }
     }
 }
Esempio n. 2
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") && 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;
                     }
                 }
             }
         }
     }
 }
Esempio n. 3
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") && 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;
                     }
                 }
             }
         }
     }
 }
Esempio n. 4
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") && 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 "seen":
                         if (spam_check == true)
                         {
                             ircbot.add_spam_count(channel);
                         }
                         if (nick_access >= tmp_command.Access)
                         {
                             if (line.GetUpperBound(0) > 3)
                             {
                                 display_seen(line[4].Trim(), line[2], ircbot);
                             }
                             else
                             {
                                 ircbot.sendData("NOTICE", nick + " :" + nick + ", you need to include more info.");
                             }
                         }
                         else
                         {
                             ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command.");
                         }
                         break;
                     }
                 }
             }
         }
     }
     if (type.Equals("line") || type.Equals("channel") || type.Equals("invite") || type.Equals("join") || type.Equals("mode") || type.Equals("part") || type.Equals("quit") || type.Equals("nick"))
     {
         add_seen(nick.Trim(), channel, line, ircbot);
     }
 }
Esempio n. 5
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 "pingme":
                         if (spam_check == true)
                         {
                             ircbot.add_spam_count(channel);
                         }
                         if (nick_access >= tmp_command.Access)
                         {
                             int           epoch        = (int)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds;
                             List <string> tmp_list     = new List <string>();
                             string        current_time = DateTime.Now.ToLongTimeString();
                             tmp_list.Add(nick);
                             tmp_list.Add(channel);
                             tmp_list.Add(current_time);
                             ping_list.Add(tmp_list);
                             ircbot.sendData("PRIVMSG", nick + " :\u0001PING " + epoch.ToString() + "\u0001");
                         }
                         else
                         {
                             ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command.");
                         }
                         break;
                     }
                 }
             }
         }
     }
     if (type.Equals("line") || type.Equals("query"))
     {
         check_ping(line, ircbot, nick);
     }
 }
Esempio n. 6
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 "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;
                     }
                 }
             }
         }
     }
 }
Esempio n. 7
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 "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;
                     }
                 }
             }
         }
     }
 }
Esempio n. 8
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 "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;
                     }
                 }
             }
         }
     }
 }
Esempio n. 9
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") && 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);
     }
 }
Esempio n. 10
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 "google":
                                if (spam_check == true)
                                {
                                    ircbot.add_spam_count(channel);
                                }
                                if (nick_access >= tmp_command.Access)
                                {
                                    if (line.GetUpperBound(0) > 3)
                                    {
                                        if (line[4].StartsWith("DCC SEND"))
                                        {
                                            ircbot.sendData("PRIVMSG", channel + " :Invalid Search Term");
                                        }
                                        else
                                        {
                                            try
                                            {
                                                List <SearchResult> results = GoogleSearch(line[4]);
                                                if (results.Count > 0)
                                                {
                                                    foreach (SearchResult searchType in results)
                                                    {
                                                        ircbot.sendData("PRIVMSG", channel + " :" + searchType.title.Replace("<b>", "").Replace("</b>", "").Replace("&quot;", "\"").Replace("&#39", "'").Replace("&amp;", "&") + ": " + searchType.content.Replace("<b>", "").Replace("</b>", "").Replace("&quot;", "\"").Replace("&#39", "'").Replace("&amp;", "&"));

                                                        if (this.Options["show_url"])
                                                        {
                                                            ircbot.sendData("PRIVMSG", channel + " :" + HttpUtility.UrlDecode(searchType.url));
                                                        }
                                                        break;
                                                    }
                                                }
                                                else
                                                {
                                                    ircbot.sendData("PRIVMSG", channel + " :No Results Found");
                                                }
                                            }
                                            catch
                                            {
                                                ircbot.sendData("PRIVMSG", channel + " :Sorry, Google isn't responding to me right now.  Try again later.");
                                            }
                                        }
                                    }
                                    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;
                            }
                        }
                    }
                }
            }
        }
Esempio n. 11
0
 public override void control(bot ircbot, ref IRCConfig conf, int module_id, string[] line, string command, int nick_access, string nick, string channel, bool bot_command, string type)
 {
     string module_name = ircbot.conf.module_config[module_id][0];
     if (type.Equals("channel") && bot_command == true)
     {
         foreach (List<string> tmp_command in conf.command_list)
         {
             if (module_name.Equals(tmp_command[0]))
             {
                 string[] triggers = tmp_command[3].Split('|');
                 int command_access = Convert.ToInt32(tmp_command[5]);
                 string[] blacklist = tmp_command[6].Split(',');
                 bool blocked = false;
                 bool cmd_found = false;
                 bool spam_check = Convert.ToBoolean(tmp_command[8]);
                 foreach (string bl_chan in blacklist)
                 {
                     if (bl_chan.Equals(channel))
                     {
                         blocked = true;
                         break;
                     }
                 }
                 if (spam_check == true)
                 {
                     blocked = ircbot.get_spam_status(channel, nick);
                 }
                 foreach (string trigger in triggers)
                 {
                     if (trigger.Equals(command))
                     {
                         cmd_found = true;
                         break;
                     }
                 }
                 if (blocked == true && cmd_found == true)
                 {
                     ircbot.sendData("NOTICE", nick + " :I am currently too busy to process that.");
                 }
                 if (blocked == false && cmd_found == true)
                 {
                     foreach (string trigger in triggers)
                     {
                         switch (trigger)
                         {
                             case "ver":
                                 if (spam_check == true)
                                 {
                                     ircbot.add_spam_count(channel);
                                 }
                                 if (nick_access >= command_access)
                                 {
                                     if (line.GetUpperBound(0) > 3)
                                     {
                                         ircbot.sendData("PRIVMSG", line[4].Trim().ToLower() + " :\u0001VERSION\u0001");
                                         List<string> tmp_list = new List<string>();
                                         tmp_list.Add(line[4].Trim().ToLower());
                                         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)
         {
             AboutBox1 about = new AboutBox1();
             ircbot.sendData("NOTICE", nick + " :\u0001VERSION IRCBot v" + about.AssemblyVersion + " on " + conf.module_config[module_id][3] + "\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))
                     {
                         string response = "[" + nick + "] Using version: " + line[4].Replace("\u0001", "");
                         ircbot.sendData("PRIVMSG", version_list[x][1] + " :" + response);
                         version_list.RemoveAt(x);
                         break;
                     }
                 }
             }
         }
     }
 }
Esempio n. 12
0
 public override void control(bot ircbot, ref IRCConfig conf, int module_id, string[] line, string command, int nick_access, string nick, string channel, bool bot_command, string type)
 {
     string module_name = ircbot.conf.module_config[module_id][0];
     if (type.Equals("channel") && bot_command == true)
     {
         foreach (List<string> tmp_command in conf.command_list)
         {
             if (module_name.Equals(tmp_command[0]))
             {
                 string[] triggers = tmp_command[3].Split('|');
                 int command_access = Convert.ToInt32(tmp_command[5]);
                 string[] blacklist = tmp_command[6].Split(',');
                 bool blocked = false;
                 bool cmd_found = false;
                 bool spam_check = Convert.ToBoolean(tmp_command[8]);
                 foreach (string bl_chan in blacklist)
                 {
                     if (bl_chan.Equals(channel))
                     {
                         blocked = true;
                         break;
                     }
                 }
                 if (spam_check == true)
                 {
                     blocked = ircbot.get_spam_status(channel, nick);
                 }
                 foreach (string trigger in triggers)
                 {
                     if (trigger.Equals(command))
                     {
                         cmd_found = true;
                         break;
                     }
                 }
                 if (blocked == true && cmd_found == true)
                 {
                     ircbot.sendData("NOTICE", nick + " :I am currently too busy to process that.");
                 }
                 if (blocked == false && cmd_found == true)
                 {
                     foreach (string trigger in triggers)
                     {
                         switch (trigger)
                         {
                             case "love":
                                 if (spam_check == true)
                                 {
                                     ircbot.add_spam_count(channel);
                                 }
                                 if (nick_access >= 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", 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 "hug":
                                 if (spam_check == true)
                                 {
                                     ircbot.add_spam_count(channel);
                                 }
                                 if (nick_access >= 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 >= 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 >= 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 >= 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 >= 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;
                         }
                     }
                 }
             }
         }
     }
 }
Esempio n. 13
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 "4chan":
                                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 (args.GetUpperBound(0) > 1)
                                        {
                                            try
                                            {
                                                bool thread_id = false;
                                                bool reply_id  = false;
                                                if (args[1].StartsWith("#"))
                                                {
                                                    thread_id = true;
                                                    args[1]   = args[1].TrimStart('#');
                                                }
                                                if (args[2].StartsWith("#"))
                                                {
                                                    reply_id = true;
                                                    args[2]  = args[2].TrimStart('#');
                                                }
                                                bool thread_found = get_reply(channel, ircbot, args[0], args[1], args[2], thread_id, reply_id);
                                                if (!thread_found)
                                                {
                                                    ircbot.sendData("PRIVMSG", channel + " :Could not find the thread specified");
                                                }
                                            }
                                            catch
                                            {
                                                ircbot.sendData("PRIVMSG", channel + " :Could not find the thread specified");
                                            }
                                        }
                                        else if (args.GetUpperBound(0) > 0)
                                        {
                                            try
                                            {
                                                bool thread_id = false;
                                                if (args[1].StartsWith("#"))
                                                {
                                                    thread_id = true;
                                                    args[1]   = args[1].TrimStart('#');
                                                }
                                                bool thread_found = get_thread(channel, ircbot, args[0], args[1], thread_id);
                                                if (!thread_found)
                                                {
                                                    ircbot.sendData("PRIVMSG", channel + " :Could not find the thread specified");
                                                }
                                            }
                                            catch
                                            {
                                                ircbot.sendData("PRIVMSG", channel + " :Could not find the thread specified");
                                            }
                                        }
                                        else
                                        {
                                            bool thread_found = get_thread(channel, ircbot, args[0], "0", false);
                                            if (!thread_found)
                                            {
                                                ircbot.sendData("PRIVMSG", channel + " :Could not find the board specified");
                                            }
                                        }
                                    }
                                    else
                                    {
                                        string    uri  = "https://a.4cdn.org/boards.json";
                                        WebClient chan = new WebClient();
                                        chan.Encoding = Encoding.UTF8;
                                        var json_data = string.Empty;
                                        json_data = chan.DownloadString(uri);
                                        XmlDocument xmlDoc     = JsonConvert.DeserializeXmlNode(json_data, "_4chan");
                                        XmlNodeList board_list = xmlDoc.SelectNodes("_4chan/boards");
                                        string      msg        = "";
                                        foreach (XmlNode tmp_board in board_list)
                                        {
                                            msg += " /" + tmp_board["board"].InnerText + "/,";
                                        }
                                        if (!String.IsNullOrEmpty(msg))
                                        {
                                            ircbot.sendData("PRIVMSG", channel + " :Boards Available:" + msg.TrimEnd(','));
                                        }
                                        else
                                        {
                                            ircbot.sendData("PRIVMSG", channel + " :No Boards Available");
                                        }
                                    }
                                }
                                else
                                {
                                    ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command.");
                                }
                                break;

                            case "next_thread":
                                if (spam_check == true)
                                {
                                    ircbot.add_spam_count(channel);
                                }
                                if (nick_access >= tmp_command.Access)
                                {
                                    bool   chan_found = false;
                                    string board      = "";
                                    string thread     = "";
                                    bool   thread_id  = false;
                                    for (int x = 0; x < Board_stats.Count(); x++)
                                    {
                                        if (Board_stats[x].channel.Equals(channel))
                                        {
                                            chan_found = true;
                                            board      = Board_stats[x].cur_board;
                                            thread     = (Board_stats[x].cur_OP_num + 1).ToString();
                                        }
                                    }
                                    if (!chan_found)
                                    {
                                        string    uri  = "https://a.4cdn.org/boards.json";
                                        WebClient chan = new WebClient();
                                        chan.Encoding = Encoding.UTF8;
                                        var json_data = string.Empty;
                                        json_data = chan.DownloadString(uri);
                                        XmlDocument xmlDoc     = JsonConvert.DeserializeXmlNode(json_data, "_4chan");
                                        XmlNodeList board_list = xmlDoc.SelectNodes("_4chan/boards");
                                        Random      rand       = new Random();
                                        int         stop       = rand.Next(board_list.Count);
                                        int         index      = 0;
                                        foreach (XmlNode tmp_board in board_list)
                                        {
                                            if (stop == index)
                                            {
                                                board = tmp_board["board"].InnerText;
                                                break;
                                            }
                                            index++;
                                        }
                                        thread = "0";
                                    }
                                    bool thread_found = get_thread(channel, ircbot, board, thread, thread_id);
                                    if (!thread_found)
                                    {
                                        ircbot.sendData("PRIVMSG", channel + " :Could not find the thread specified");
                                    }
                                }
                                else
                                {
                                    ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command.");
                                }
                                break;

                            case "next_reply":
                                if (spam_check == true)
                                {
                                    ircbot.add_spam_count(channel);
                                }
                                if (nick_access >= tmp_command.Access)
                                {
                                    bool   chan_found = false;
                                    string board      = "";
                                    string thread     = "";
                                    string reply      = "";
                                    bool   thread_id  = false;
                                    bool   reply_id   = false;
                                    for (int x = 0; x < Board_stats.Count(); x++)
                                    {
                                        if (Board_stats[x].channel.Equals(channel))
                                        {
                                            chan_found = true;
                                            board      = Board_stats[x].cur_board;
                                            thread     = Board_stats[x].cur_thread;
                                            thread_id  = true;
                                            reply      = (Board_stats[x].cur_reply_num + 1).ToString();
                                        }
                                    }
                                    if (!chan_found)
                                    {
                                        string    uri  = "https://a.4cdn.org/boards.json";
                                        WebClient chan = new WebClient();
                                        chan.Encoding = Encoding.UTF8;
                                        var json_data = string.Empty;
                                        json_data = chan.DownloadString(uri);
                                        XmlDocument xmlDoc     = JsonConvert.DeserializeXmlNode(json_data, "_4chan");
                                        XmlNodeList board_list = xmlDoc.SelectNodes("_4chan/boards");
                                        Random      rand       = new Random();
                                        int         stop       = rand.Next(board_list.Count);
                                        int         index      = 0;
                                        foreach (XmlNode tmp_board in board_list)
                                        {
                                            if (stop == index)
                                            {
                                                board = tmp_board["board"].InnerText;
                                                break;
                                            }
                                            index++;
                                        }
                                        thread = "0";
                                        reply  = "0";
                                    }
                                    bool thread_found = get_reply(channel, ircbot, board, thread, reply, thread_id, reply_id);
                                    if (!thread_found)
                                    {
                                        ircbot.sendData("PRIVMSG", channel + " :Could not find the thread specified");
                                    }
                                }
                                else
                                {
                                    ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command.");
                                }
                                break;

                            case "4chansearch":
                                if (spam_check == true)
                                {
                                    ircbot.add_spam_count(channel);
                                }
                                if (nick_access >= tmp_command.Access)
                                {
                                    if (line.GetUpperBound(0) > 3)
                                    {
                                        char[]   sep  = new char[] { ' ' };
                                        string[] args = line[4].Split(sep, 2);
                                        if (args.GetUpperBound(0) > 0)
                                        {
                                            try
                                            {
                                                bool thread_found = search_board(channel, ircbot, args[0], args[1]);
                                                if (!thread_found)
                                                {
                                                    ircbot.sendData("PRIVMSG", channel + " :Could not find a similar post.");
                                                }
                                            }
                                            catch
                                            {
                                                ircbot.sendData("PRIVMSG", channel + " :Could not find the board specified.");
                                            }
                                        }
                                        else
                                        {
                                            ircbot.sendData("PRIVMSG", channel + " :You need to include more info.");
                                        }
                                    }
                                    else
                                    {
                                        ircbot.sendData("PRIVMSG", channel + " :You need to include more info.");
                                    }
                                }
                                else
                                {
                                    ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command.");
                                }
                                break;
                            }
                        }
                    }
                }
            }
        }
Esempio n. 14
0
        public override void control(bot ircbot, ref IRCConfig conf, int module_id, string[] line, string command, int nick_access, string nick, string channel, bool bot_command, string type)
        {
            string module_name = ircbot.conf.module_config[module_id][0];
            if (type.Equals("channel") && bot_command == true)
            {
                foreach (List<string> tmp_command in conf.command_list)
                {
                    if (module_name.Equals(tmp_command[0]))
                    {
                        string[] triggers = tmp_command[3].Split('|');
                        int command_access = Convert.ToInt32(tmp_command[5]);
                        string[] blacklist = tmp_command[6].Split(',');
                        bool blocked = false;
                        bool cmd_found = false;
                        bool spam_check = Convert.ToBoolean(tmp_command[8]);
                        foreach (string bl_chan in blacklist)
                        {
                            if (bl_chan.Equals(channel))
                            {
                                blocked = true;
                                break;
                            }
                        }
                        if (spam_check == true)
                        {
                            blocked = ircbot.get_spam_status(channel, nick);
                        }
                        foreach (string trigger in triggers)
                        {
                            if (trigger.Equals(command))
                            {
                                cmd_found = true;
                                break;
                            }
                        }
                        if (blocked == true && cmd_found == true)
                        {
                            ircbot.sendData("NOTICE", nick + " :I am currently too busy to process that.");
                        }
                        if (blocked == false && cmd_found == true)
                        {
                            foreach (string trigger in triggers)
                            {
                                switch (trigger)
                                {
                                    case "google":
                                        if (spam_check == true)
                                        {
                                            ircbot.add_spam_count(channel);
                                        }
                                        if (nick_access >= command_access)
                                        {
                                            if (line.GetUpperBound(0) > 3)
                                            {
                                                if (line[4].StartsWith("DCC SEND"))
                                                {
                                                    ircbot.sendData("PRIVMSG", line[2] + " :Invalid Search Term");
                                                }
                                                else
                                                {
                                                    ISearchResult searchClass = new GoogleSearch(line[4]);
                                                    try
                                                    {
                                                        var list = searchClass.Search();
                                                        if (list.Count > 0)
                                                        {
                                                            foreach (var searchType in list)
                                                            {
                                                                ircbot.sendData("PRIVMSG", line[2] + " :" + searchType.title.Replace("<b>", "").Replace("</b>", "").Replace("&quot;", "\"").Replace("&#39", "'").Replace("&amp;", "&") + ": " + searchType.content.Replace("<b>", "").Replace("</b>", "").Replace("&quot;", "\"").Replace("&#39", "'").Replace("&amp;", "&"));

                                                                if (conf.module_config[module_id][3].Equals("True"))
                                                                {
                                                                    ircbot.sendData("PRIVMSG", line[2] + " :" + searchType.url);
                                                                }
                                                                break;
                                                            }
                                                        }
                                                        else
                                                        {
                                                            ircbot.sendData("PRIVMSG", line[2] + " :No Results Found");
                                                        }
                                                    }
                                                    catch
                                                    {
                                                        ircbot.sendData("PRIVMSG", line[2] + " :I can't search atm.");
                                                    }
                                                }
                                            }
                                            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;
                                }
                            }
                        }
                    }
                }
            }
        }
Esempio n. 15
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);
                    }
                }
            }
        }
Esempio n. 16
0
 public override void control(bot ircbot, ref IRCConfig conf, int module_id, string[] line, string command, int nick_access, string nick, string channel, bool bot_command, string type)
 {
     string module_name = ircbot.conf.module_config[module_id][0];
     if (type.Equals("channel") && bot_command == true)
     {
         foreach (List<string> tmp_command in conf.command_list)
         {
             if (module_name.Equals(tmp_command[0]))
             {
                 string[] triggers = tmp_command[3].Split('|');
                 int command_access = Convert.ToInt32(tmp_command[5]);
                 string[] blacklist = tmp_command[6].Split(',');
                 bool blocked = false;
                 bool cmd_found = false;
                 bool spam_check = Convert.ToBoolean(tmp_command[8]);
                 foreach (string bl_chan in blacklist)
                 {
                     if (bl_chan.Equals(channel))
                     {
                         blocked = true;
                         break;
                     }
                 }
                 if (spam_check == true)
                 {
                     blocked = ircbot.get_spam_status(channel, nick);
                 }
                 foreach (string trigger in triggers)
                 {
                     if (trigger.Equals(command))
                     {
                         cmd_found = true;
                         break;
                     }
                 }
                 if (blocked == true && cmd_found == true)
                 {
                     ircbot.sendData("NOTICE", nick + " :I am currently too busy to process that.");
                 }
                 if (blocked == false && cmd_found == true)
                 {
                     foreach (string trigger in triggers)
                     {
                         switch (trigger)
                         {
                             case "4chan":
                                 if (spam_check == true)
                                 {
                                     ircbot.add_spam_count(channel);
                                 }
                                 if (nick_access >= command_access)
                                 {
                                     if (line.GetUpperBound(0) > 3)
                                     {
                                         string[] args = line[4].Split(' ');
                                         if (args.GetUpperBound(0) > 1)
                                         {
                                             try
                                             {
                                                 bool thread_id = false;
                                                 bool reply_id = false;
                                                 if (args[1].StartsWith("#"))
                                                 {
                                                     thread_id = true;
                                                     args[1] = args[1].TrimStart('#');
                                                 }
                                                 if (args[2].StartsWith("#"))
                                                 {
                                                     reply_id = true;
                                                     args[2] = args[2].TrimStart('#');
                                                 }
                                                 bool thread_found = get_reply(channel, ircbot, args[0], args[1], args[2], thread_id, reply_id);
                                                 if (!thread_found)
                                                 {
                                                     ircbot.sendData("PRIVMSG", channel + " :Could not find the thread specified");
                                                 }
                                             }
                                             catch
                                             {
                                                 ircbot.sendData("PRIVMSG", channel + " :Could not find the thread specified");
                                             }
                                         }
                                         else if (args.GetUpperBound(0) > 0)
                                         {
                                             try
                                             {
                                                 bool thread_id = false;
                                                 if (args[1].StartsWith("#"))
                                                 {
                                                     thread_id = true;
                                                     args[1] = args[1].TrimStart('#');
                                                 }
                                                 bool thread_found = get_thread(channel, ircbot, args[0], args[1], thread_id);
                                                 if (!thread_found)
                                                 {
                                                     ircbot.sendData("PRIVMSG", channel + " :Could not find the thread specified");
                                                 }
                                             }
                                             catch
                                             {
                                                 ircbot.sendData("PRIVMSG", channel + " :Could not find the thread specified");
                                             }
                                         }
                                         else
                                         {
                                             bool thread_found = get_thread(channel, ircbot, args[0], "0", false);
                                             if (!thread_found)
                                             {
                                                 ircbot.sendData("PRIVMSG", channel + " :Could not find the board specified");
                                             }
                                         }
                                     }
                                     else
                                     {
                                         string uri = "https://api.4chan.org/boards.json";
                                         WebClient chan = new WebClient();
                                         var json_data = string.Empty;
                                         json_data = chan.DownloadString(uri);
                                         XmlDocument xmlDoc = JsonConvert.DeserializeXmlNode(json_data, "_4chan");
                                         XmlNodeList board_list = xmlDoc.SelectNodes("_4chan/boards");
                                         string msg = "";
                                         foreach (XmlNode tmp_board in board_list)
                                         {
                                             msg += " /" + tmp_board["board"].InnerText + "/,";
                                         }
                                         if (!msg.Equals(string.Empty))
                                         {
                                             ircbot.sendData("PRIVMSG", channel + " :Boards Available:" + msg.TrimEnd(','));
                                         }
                                         else
                                         {
                                             ircbot.sendData("PRIVMSG", channel + " :No Boards Available");
                                         }
                                     }
                                 }
                                 else
                                 {
                                     ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command.");
                                 }
                                 break;
                             case "next_thread":
                                 if (spam_check == true)
                                 {
                                     ircbot.add_spam_count(channel);
                                 }
                                 if (nick_access >= command_access)
                                 {
                                     bool chan_found = false;
                                     string board = "";
                                     string thread = "";
                                     bool thread_id = false;
                                     for (int x = 0; x < Board_stats.Count(); x++)
                                     {
                                         if (Board_stats[x].channel.Equals(channel))
                                         {
                                             chan_found = true;
                                             board = Board_stats[x].cur_board;
                                             thread = (Board_stats[x].cur_OP_num + 1).ToString();
                                         }
                                     }
                                     if (!chan_found)
                                     {
                                         string uri = "https://api.4chan.org/boards.json";
                                         WebClient chan = new WebClient();
                                         var json_data = string.Empty;
                                         json_data = chan.DownloadString(uri);
                                         XmlDocument xmlDoc = JsonConvert.DeserializeXmlNode(json_data, "_4chan");
                                         XmlNodeList board_list = xmlDoc.SelectNodes("_4chan/boards");
                                         Random rand = new Random();
                                         int stop = rand.Next(board_list.Count);
                                         int index = 0;
                                         foreach(XmlNode tmp_board in board_list)
                                         {
                                             if(stop == index)
                                             {
                                                 board = tmp_board["board"].InnerText;
                                                 break;
                                             }
                                             index++;
                                         }
                                         thread = "0";
                                     }
                                     bool thread_found = get_thread(channel, ircbot, board, thread, thread_id);
                                     if (!thread_found)
                                     {
                                         ircbot.sendData("PRIVMSG", channel + " :Could not find the thread specified");
                                     }
                                 }
                                 else
                                 {
                                     ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command.");
                                 }
                                 break;
                             case "next_reply":
                                 if (spam_check == true)
                                 {
                                     ircbot.add_spam_count(channel);
                                 }
                                 if (nick_access >= command_access)
                                 {
                                     bool chan_found = false;
                                     string board = "";
                                     string thread = "";
                                     string reply = "";
                                     bool thread_id = false;
                                     bool reply_id = false;
                                     for (int x = 0; x < Board_stats.Count(); x++)
                                     {
                                         if (Board_stats[x].channel.Equals(channel))
                                         {
                                             chan_found = true;
                                             board = Board_stats[x].cur_board;
                                             thread = Board_stats[x].cur_thread;
                                             thread_id = true;
                                             reply = (Board_stats[x].cur_reply_num + 1).ToString();
                                         }
                                     }
                                     if (!chan_found)
                                     {
                                         string uri = "https://api.4chan.org/boards.json";
                                         WebClient chan = new WebClient();
                                         var json_data = string.Empty;
                                         json_data = chan.DownloadString(uri);
                                         XmlDocument xmlDoc = JsonConvert.DeserializeXmlNode(json_data, "_4chan");
                                         XmlNodeList board_list = xmlDoc.SelectNodes("_4chan/boards");
                                         Random rand = new Random();
                                         int stop = rand.Next(board_list.Count);
                                         int index = 0;
                                         foreach (XmlNode tmp_board in board_list)
                                         {
                                             if (stop == index)
                                             {
                                                 board = tmp_board["board"].InnerText;
                                                 break;
                                             }
                                             index++;
                                         }
                                         thread = "0";
                                         reply = "0";
                                     }
                                     bool thread_found = get_reply(channel, ircbot, board, thread, reply, thread_id, reply_id);
                                     if (!thread_found)
                                     {
                                         ircbot.sendData("PRIVMSG", channel + " :Could not find the thread specified");
                                     }
                                 }
                                 else
                                 {
                                     ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command.");
                                 }
                                 break;
                         }
                     }
                 }
             }
         }
     }
 }
Esempio n. 17
0
 public override void control(bot ircbot, ref IRCConfig conf, int module_id, string[] line, string command, int nick_access, string nick, string channel, bool bot_command, string type)
 {
     string module_name = ircbot.conf.module_config[module_id][0];
     if (type.Equals("channel") && bot_command == true)
     {
         foreach (List<string> tmp_command in conf.command_list)
         {
             if (module_name.Equals(tmp_command[0]))
             {
                 string[] triggers = tmp_command[3].Split('|');
                 int command_access = Convert.ToInt32(tmp_command[5]);
                 string[] blacklist = tmp_command[6].Split(',');
                 bool blocked = false;
                 bool cmd_found = false;
                 bool spam_check = Convert.ToBoolean(tmp_command[8]);
                 foreach (string bl_chan in blacklist)
                 {
                     if (bl_chan.Equals(channel))
                     {
                         blocked = true;
                         break;
                     }
                 }
                 if (spam_check == true)
                 {
                     blocked = ircbot.get_spam_status(channel, nick);
                 }
                 foreach (string trigger in triggers)
                 {
                     if (trigger.Equals(command))
                     {
                         cmd_found = true;
                         break;
                     }
                 }
                 if (blocked == true && cmd_found == true)
                 {
                     ircbot.sendData("NOTICE", nick + " :I am currently too busy to process that.");
                 }
                 if (blocked == false && cmd_found == true)
                 {
                     foreach (string trigger in triggers)
                     {
                         switch (trigger)
                         {
                             case "rollcall":
                                 if (spam_check == true)
                                 {
                                     ircbot.add_spam_count(channel);
                                 }
                                 if (nick_access >= 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 = "";
                                     for (int x = 0; x < ircbot.nick_list.Count(); x++)
                                     {
                                         if (ircbot.nick_list[x][0].Equals(channel))
                                         {
                                             for (int i = 1; i < ircbot.nick_list[x].Count(); i++)
                                             {
                                                 string[] split = ircbot.nick_list[x][i].Split(':');
                                                 if (split.GetUpperBound(0) > 0)
                                                 {
                                                     nicks += split[1] + ", ";
                                                 }
                                             }
                                             break;
                                         }
                                     }
                                     ircbot.sendData("PRIVMSG", channel + " :" + conf.module_config[module_id][3] + ": " + nicks.Trim().TrimEnd(','));
                                 }
                                 break;
                         }
                     }
                 }
             }
         }
     }
 }
Esempio n. 18
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 "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;
                     }
                 }
             }
         }
     }
 }
Esempio n. 19
0
 public override void control(bot ircbot, ref IRCConfig conf, int module_id, string[] line, string command, int nick_access, string nick, string channel, bool bot_command, string type)
 {
     string module_name = ircbot.conf.module_config[module_id][0];
     if (type.Equals("channel") && bot_command == true)
     {
         foreach (List<string> tmp_command in conf.command_list)
         {
             if (module_name.Equals(tmp_command[0]))
             {
                 string[] triggers = tmp_command[3].Split('|');
                 int command_access = Convert.ToInt32(tmp_command[5]);
                 string[] blacklist = tmp_command[6].Split(',');
                 bool blocked = false;
                 bool cmd_found = false;
                 bool spam_check = Convert.ToBoolean(tmp_command[8]);
                 foreach (string bl_chan in blacklist)
                 {
                     if (bl_chan.Equals(channel))
                     {
                         blocked = true;
                         break;
                     }
                 }
                 if (spam_check == true)
                 {
                     blocked = ircbot.get_spam_status(channel, nick);
                 }
                 foreach (string trigger in triggers)
                 {
                     if (trigger.Equals(command))
                     {
                         cmd_found = true;
                         break;
                     }
                 }
                 if (blocked == true && cmd_found == true)
                 {
                     ircbot.sendData("NOTICE", nick + " :I am currently too busy to process that.");
                 }
                 if (blocked == false && cmd_found == true)
                 {
                     foreach (string trigger in triggers)
                     {
                         switch (trigger)
                         {
                             case "roll":
                                 if (spam_check == true)
                                 {
                                     ircbot.add_spam_count(channel);
                                 }
                                 if (nick_access >= command_access)
                                 {
                                     if (line.GetUpperBound(0) > 3)
                                     {
                                         string[] new_line = line[4].Trim().Split(' ');
                                         if (new_line.GetUpperBound(0) > 0)
                                         {
                                             int num_dice = 0;
                                             int num_sides = 0;
                                             List<List<int>> roll_results = new List<List<int>>();
                                             try
                                             {
                                                 num_dice = Convert.ToInt32(new_line[0].Trim());
                                             }
                                             catch (Exception ex)
                                             {
                                                 if (ex != null)
                                                 {
                                                     num_dice = 1;
                                                 }
                                             }
                                             try
                                             {
                                                 num_sides = Convert.ToInt32(new_line[1].Trim());
                                             }
                                             catch (Exception ex)
                                             {
                                                 if (ex != null)
                                                 {
                                                     num_sides = 6;
                                                 }
                                             }
                                             if (num_dice > Convert.ToInt32(conf.module_config[module_id][3]))
                                             {
                                                 num_dice = Convert.ToInt32(conf.module_config[module_id][3]);
                                             }
                                             if (num_sides > Convert.ToInt32(conf.module_config[module_id][4]))
                                             {
                                                 num_sides = Convert.ToInt32(conf.module_config[module_id][4]);
                                             }
                                             for (int x = 0; x < num_dice; x++)
                                             {
                                                 System.Threading.Thread.Sleep(100);
                                                 Random random = new Random();
                                                 int ran_num = random.Next(1, num_sides + 1);
                                                 bool num_found = false;
                                                 foreach (List<int> num in roll_results)
                                                 {
                                                     if (num[0] == ran_num)
                                                     {
                                                         num[1]++;
                                                         num_found = true;
                                                         break;
                                                     }
                                                 }
                                                 if (num_found == false)
                                                 {
                                                     List<int> tmp = new List<int>();
                                                     tmp.Add(ran_num);
                                                     tmp.Add(1);
                                                     roll_results.Add(tmp);
                                                 }
                                             }
                                             string msg = "";
                                             foreach (List<int> num in roll_results)
                                             {
                                                 msg += num[1] + " [" + num[0] + "'s] | ";
                                             }
                                             ircbot.sendData("PRIVMSG", channel + " :Rolling " + num_dice + " " + num_sides + "-sided dice: " + msg.Trim().TrimEnd('|').Trim());
                                         }
                                         else
                                         {
                                             int num_dice = 0;
                                             List<List<int>> roll_results = new List<List<int>>();
                                             try
                                             {
                                                 num_dice = Convert.ToInt32(new_line[0]);
                                             }
                                             catch (Exception ex)
                                             {
                                                 if (ex != null)
                                                 {
                                                     num_dice = 1;
                                                 }
                                             }
                                             if (num_dice > Convert.ToInt32(conf.module_config[module_id][3]))
                                             {
                                                 num_dice = Convert.ToInt32(conf.module_config[module_id][3]);
                                             }
                                             for (int x = 0; x < num_dice; x++)
                                             {
                                                 System.Threading.Thread.Sleep(100);
                                                 Random random = new Random();
                                                 int ran_num = random.Next(1, 7);
                                                 bool num_found = false;
                                                 foreach (List<int> num in roll_results)
                                                 {
                                                     if (num[0] == ran_num)
                                                     {
                                                         num[1]++;
                                                         num_found = true;
                                                         break;
                                                     }
                                                 }
                                                 if (num_found == false)
                                                 {
                                                     List<int> tmp = new List<int>();
                                                     tmp.Add(ran_num);
                                                     tmp.Add(1);
                                                     roll_results.Add(tmp);
                                                 }
                                             }
                                             string msg = "";
                                             foreach (List<int> num in roll_results)
                                             {
                                                 msg += num[1] + " [" + num[0] + "'s] | ";
                                             }
                                             ircbot.sendData("PRIVMSG", channel + " :Rolling " + num_dice + " 6-sided dice: " + msg.Trim().TrimEnd('|').Trim());
                                         }
                                     }
                                     else
                                     {
                                         Random random = new Random();
                                         int ran_num = random.Next(1, 7);
                                         ircbot.sendData("PRIVMSG", channel + " :Rolling 1 6-sided dice: " + ran_num.ToString());
                                     }
                                 }
                                 else
                                 {
                                     ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command.");
                                 }
                                 break;
                         }
                     }
                 }
             }
         }
     }
 }
Esempio n. 20
0
        public override void control(bot ircbot, ref IRCConfig conf, int module_id, string[] line, string command, int nick_access, string nick, string channel, bool bot_command, string type)
        {
            string module_name = ircbot.conf.module_config[module_id][0];

            if ((type.Equals("channel") || type.Equals("query")) && bot_command == true)
            {
                foreach (List <string> tmp_command in conf.command_list)
                {
                    if (module_name.Equals(tmp_command[0]))
                    {
                        string[] triggers       = tmp_command[3].Split('|');
                        int      command_access = Convert.ToInt32(tmp_command[5]);
                        string[] blacklist      = tmp_command[6].Split(',');
                        bool     blocked        = false;
                        bool     cmd_found      = false;
                        bool     spam_check     = Convert.ToBoolean(tmp_command[8]);
                        foreach (string bl_chan in blacklist)
                        {
                            if (bl_chan.Equals(channel))
                            {
                                blocked = true;
                                break;
                            }
                        }
                        if (spam_check == true)
                        {
                            blocked = ircbot.get_spam_status(channel, nick);
                        }
                        foreach (string trigger in triggers)
                        {
                            if (trigger.Equals(command))
                            {
                                cmd_found = true;
                                break;
                            }
                        }
                        if (blocked == true && cmd_found == true)
                        {
                            ircbot.sendData("NOTICE", nick + " :I am currently too busy to process that.");
                        }
                        if (blocked == false && cmd_found == true)
                        {
                            foreach (string trigger in triggers)
                            {
                                switch (trigger)
                                {
                                case "access":
                                    if (spam_check == true)
                                    {
                                        ircbot.add_spam_count(channel);
                                    }
                                    if (nick_access >= command_access)
                                    {
                                        if (line.GetUpperBound(0) > 3)
                                        {
                                            string[] parse = line[4].Split(' ');
                                            if (parse.GetUpperBound(0) > 1)
                                            {
                                                if (Convert.ToInt32(parse[2]) <= nick_access)
                                                {
                                                    set_access_list(parse[0].Trim().ToLower(), parse[1], parse[2], ircbot);
                                                    ircbot.sendData("NOTICE", nick + " :" + parse[0].Trim() + " has been added to access level " + parse[2]);
                                                }
                                                else
                                                {
                                                    ircbot.sendData("NOTICE", nick + " :You do not have permission to change their access.");
                                                }
                                            }
                                            else if (type.Equals("channel") && parse.GetUpperBound(0) > 0)
                                            {
                                                if (Convert.ToInt32(parse[1]) <= nick_access)
                                                {
                                                    set_access_list(parse[0].Trim().ToLower(), line[2], parse[1], ircbot);
                                                    ircbot.sendData("NOTICE", nick + " :" + parse[0].Trim() + " has been added to access level " + parse[1]);
                                                }
                                                else
                                                {
                                                    ircbot.sendData("NOTICE", nick + " :You do not have permission to change their access.");
                                                }
                                            }
                                            else
                                            {
                                                ircbot.sendData("NOTICE", nick + " :" + nick + ", you need to include more info.");
                                            }
                                        }
                                        else
                                        {
                                            ircbot.sendData("NOTICE", nick + " :" + nick + ", you need to include more info.");
                                        }
                                    }
                                    else
                                    {
                                        ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command.");
                                    }
                                    break;

                                case "delaccess":
                                    if (spam_check == true)
                                    {
                                        ircbot.add_spam_count(channel);
                                    }
                                    if (nick_access >= command_access)
                                    {
                                        if (line.GetUpperBound(0) > 3)
                                        {
                                            string[] parse = line[4].Split(' ');
                                            if (parse.GetUpperBound(0) > 1)
                                            {
                                                if (Convert.ToInt32(parse[2]) <= nick_access)
                                                {
                                                    del_access_list(parse[0].Trim().ToLower(), parse[1], parse[2], ircbot);
                                                    ircbot.sendData("NOTICE", nick + " :" + parse[0].Trim() + " has been removed from access level " + parse[2]);
                                                }
                                                else
                                                {
                                                    ircbot.sendData("NOTICE", nick + " :You do not have permission to change their access.");
                                                }
                                            }
                                            else if (type.Equals("channel") && parse.GetUpperBound(0) > 0)
                                            {
                                                if (Convert.ToInt32(parse[1]) <= nick_access)
                                                {
                                                    del_access_list(parse[0].Trim().ToLower(), line[2], parse[1], ircbot);
                                                    ircbot.sendData("NOTICE", nick + " :" + parse[0].Trim() + " has been removed from access level " + parse[1]);
                                                }
                                                else
                                                {
                                                    ircbot.sendData("NOTICE", nick + " :You do not have permission to change their access.");
                                                }
                                            }
                                            else
                                            {
                                                ircbot.sendData("NOTICE", nick + " :" + nick + ", you need to include more info.");
                                            }
                                        }
                                        else
                                        {
                                            ircbot.sendData("NOTICE", nick + " :" + nick + ", you need to include more info.");
                                        }
                                    }
                                    else
                                    {
                                        ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command.");
                                    }
                                    break;

                                case "listaccess":
                                    if (spam_check == true)
                                    {
                                        ircbot.add_spam_count(channel);
                                    }
                                    if (nick_access >= command_access)
                                    {
                                        if (line.GetUpperBound(0) > 3)
                                        {
                                            list_access_list(nick, line[4], ircbot);
                                        }
                                        else if (type.Equals("channel"))
                                        {
                                            list_access_list(nick, line[2], ircbot);
                                        }
                                        else
                                        {
                                            ircbot.sendData("NOTICE", nick + " :" + nick + ", you need to include more info.");
                                        }
                                    }
                                    else
                                    {
                                        ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command.");
                                    }
                                    break;

                                case "getaccess":
                                    if (spam_check == true)
                                    {
                                        ircbot.add_spam_count(channel);
                                    }
                                    if (nick_access >= command_access)
                                    {
                                        if (line.GetUpperBound(0) > 3)
                                        {
                                            string[] new_line = line[4].ToLower().Split(' ');
                                            if (new_line.GetUpperBound(0) > 0 && new_line[0].StartsWith("#"))
                                            {
                                                int viewed_access = ircbot.get_user_access(new_line[1].Trim().ToLower(), new_line[0].Trim());
                                                ircbot.sendData("NOTICE", nick + " :" + new_line[1].Trim() + " has access level " + viewed_access.ToString());
                                            }
                                            else if (type.Equals("channel"))
                                            {
                                                int viewed_access = ircbot.get_user_access(line[4].Trim().ToLower(), channel);
                                                ircbot.sendData("NOTICE", nick + " :" + line[4].Trim() + " has access level " + viewed_access.ToString());
                                            }
                                            else
                                            {
                                                ircbot.sendData("NOTICE", nick + " :" + nick + ", you need to include more info.");
                                            }
                                        }
                                        else
                                        {
                                            ircbot.sendData("NOTICE", nick + " :" + nick + ", you need to include more info.");
                                        }
                                    }
                                    else
                                    {
                                        ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command.");
                                    }
                                    break;
                                }
                            }
                        }
                    }
                }
            }
        }
Esempio n. 21
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") && 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 "intro":
                                if (spam_check == true)
                                {
                                    ircbot.add_spam_count(channel);
                                }
                                if (nick_access >= tmp_command.Access)
                                {
                                    if (line.GetUpperBound(0) > 3)
                                    {
                                        // Add introduction
                                        string char_limit = this.Options["max_char"];
                                        add_intro(nick, line[2], line, ircbot, Convert.ToInt32(char_limit));
                                    }
                                    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 "introdelete":
                                if (spam_check == true)
                                {
                                    ircbot.add_spam_count(channel);
                                }
                                if (nick_access >= tmp_command.Access)
                                {
                                    // Delete Introduction
                                    delete_intro(nick, line[2], ircbot);
                                }
                                else
                                {
                                    ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command.");
                                }
                                break;
                            }
                        }
                    }
                }
            }
            if (type.Equals("join"))
            {
                check_intro(nick, channel.TrimStart(':'), ircbot);
            }
        }
Esempio n. 22
0
 public override void control(bot ircbot, ref IRCConfig conf, int module_id, string[] line, string command, int nick_access, string nick, string channel, bool bot_command, string type)
 {
     string module_name = ircbot.conf.module_config[module_id][0];
     if (type.Equals("channel") || type.Equals("query") && bot_command == true)
     {
         foreach (List<string> tmp_command in conf.command_list)
         {
             if (module_name.Equals(tmp_command[0]))
             {
                 string[] triggers = tmp_command[3].Split('|');
                 int command_access = Convert.ToInt32(tmp_command[5]);
                 string[] blacklist = tmp_command[6].Split(',');
                 bool blocked = false;
                 bool cmd_found = false;
                 bool spam_check = Convert.ToBoolean(tmp_command[8]);
                 foreach (string bl_chan in blacklist)
                 {
                     if (bl_chan.Equals(channel))
                     {
                         blocked = true;
                         break;
                     }
                 }
                 if (spam_check == true)
                 {
                     blocked = ircbot.get_spam_status(channel, nick);
                 }
                 foreach (string trigger in triggers)
                 {
                     if (trigger.Equals(command))
                     {
                         cmd_found = true;
                         break;
                     }
                 }
                 if (blocked == true && cmd_found == true)
                 {
                     ircbot.sendData("NOTICE", nick + " :I am currently too busy to process that.");
                 }
                 if (blocked == false && cmd_found == true)
                 {
                     foreach (string trigger in triggers)
                     {
                         switch (trigger)
                         {
                             case "about":
                                 if (spam_check == true)
                                 {
                                     ircbot.add_spam_count(channel);
                                 }
                                 if (nick_access >= command_access)
                                 {
                                     AboutBox1 about = new AboutBox1();
                                     string[] owners = conf.owner.TrimStart(',').TrimEnd(',').Split(',');
                                     string owner_num = " is";
                                     if (owners.GetUpperBound(0) > 0)
                                     {
                                         owner_num = "s are";
                                     }
                                     string response = "IRCBot";
                                     if (conf.module_config[module_id][3].Equals("True"))
                                     {
                                         response += " v" + about.AssemblyVersion + ".";
                                     }
                                     if (conf.module_config[module_id][4].Equals("True"))
                                     {
                                         response += " Created by Uncled1023.";
                                     }
                                     if (conf.module_config[module_id][5].Equals("True"))
                                     {
                                         response += " My owner" + owner_num + " ";
                                         if (owners.GetUpperBound(0) > 1)
                                         {
                                             int index = 0;
                                             foreach (string owner in owners)
                                             {
                                                 response += owner;
                                                 if (index == owners.GetUpperBound(0) - 1)
                                                 {
                                                     response += ", and ";
                                                 }
                                                 else if(index < owners.GetUpperBound(0))
                                                 {
                                                     response += ", ";
                                                 }
                                                 index++;
                                             }
                                         }
                                         else
                                         {
                                             response += conf.owner.TrimStart(',').TrimEnd(',').Replace(",", " and ");
                                         }
                                     }
                                     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 "uptime":
                                 if (spam_check == true)
                                 {
                                     ircbot.add_spam_count(channel);
                                 }
                                 if (nick_access >= 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;
                         }
                     }
                 }
             }
         }
     }
 }
Esempio n. 23
0
        public override void control(bot ircbot, ref IRCConfig conf, int module_id, string[] line, string command, int nick_access, string nick, string channel, bool bot_command, string type)
        {
            string module_name = ircbot.conf.module_config[module_id][0];

            if (type.Equals("channel") && bot_command == true)
            {
                foreach (List <string> tmp_command in conf.command_list)
                {
                    if (module_name.Equals(tmp_command[0]))
                    {
                        string[] triggers       = tmp_command[3].Split('|');
                        int      command_access = Convert.ToInt32(tmp_command[5]);
                        string[] blacklist      = tmp_command[6].Split(',');
                        bool     blocked        = false;
                        bool     cmd_found      = false;
                        bool     spam_check     = Convert.ToBoolean(tmp_command[8]);
                        foreach (string bl_chan in blacklist)
                        {
                            if (bl_chan.Equals(channel))
                            {
                                blocked = true;
                                break;
                            }
                        }
                        if (spam_check == true)
                        {
                            blocked = ircbot.get_spam_status(channel, nick);
                        }
                        foreach (string trigger in triggers)
                        {
                            if (trigger.Equals(command))
                            {
                                cmd_found = true;
                                break;
                            }
                        }
                        if (blocked == true && cmd_found == true)
                        {
                            ircbot.sendData("NOTICE", nick + " :I am currently too busy to process that.");
                        }
                        if (blocked == false && cmd_found == true)
                        {
                            foreach (string trigger in triggers)
                            {
                                switch (trigger)
                                {
                                case "ver":
                                    if (spam_check == true)
                                    {
                                        ircbot.add_spam_count(channel);
                                    }
                                    if (nick_access >= command_access)
                                    {
                                        if (line.GetUpperBound(0) > 3)
                                        {
                                            ircbot.sendData("PRIVMSG", line[4].Trim().ToLower() + " :\u0001VERSION\u0001");
                                            List <string> tmp_list = new List <string>();
                                            tmp_list.Add(line[4].Trim().ToLower());
                                            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)
                {
                    AboutBox1 about = new AboutBox1();
                    ircbot.sendData("NOTICE", nick + " :\u0001VERSION IRCBot v" + about.AssemblyVersion + " on " + conf.module_config[module_id][3] + "\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))
                            {
                                string response = "[" + nick + "] Using version: " + line[4].Replace("\u0001", "");
                                ircbot.sendData("PRIVMSG", version_list[x][1] + " :" + response);
                                version_list.RemoveAt(x);
                                break;
                            }
                        }
                    }
                }
            }
        }
Esempio n. 24
0
        public override void control(bot ircbot, ref IRCConfig conf, int module_id, string[] line, string command, int nick_access, string nick, string channel, bool bot_command, string type)
        {
            string module_name = ircbot.conf.module_config[module_id][0];

            if (type.Equals("channel") && bot_command == true)
            {
                foreach (List <string> tmp_command in conf.command_list)
                {
                    if (module_name.Equals(tmp_command[0]))
                    {
                        string[] triggers       = tmp_command[3].Split('|');
                        int      command_access = Convert.ToInt32(tmp_command[5]);
                        string[] blacklist      = tmp_command[6].Split(',');
                        bool     blocked        = false;
                        bool     cmd_found      = false;
                        bool     spam_check     = Convert.ToBoolean(tmp_command[8]);
                        foreach (string bl_chan in blacklist)
                        {
                            if (bl_chan.Equals(channel))
                            {
                                blocked = true;
                                break;
                            }
                        }
                        if (spam_check == true)
                        {
                            blocked = ircbot.get_spam_status(channel, nick);
                        }
                        foreach (string trigger in triggers)
                        {
                            if (trigger.Equals(command))
                            {
                                cmd_found = true;
                                break;
                            }
                        }
                        if (blocked == true && cmd_found == true)
                        {
                            ircbot.sendData("NOTICE", nick + " :I am currently too busy to process that.");
                        }
                        if (blocked == false && cmd_found == true)
                        {
                            foreach (string trigger in triggers)
                            {
                                switch (trigger)
                                {
                                case "4chan":
                                    if (spam_check == true)
                                    {
                                        ircbot.add_spam_count(channel);
                                    }
                                    if (nick_access >= command_access)
                                    {
                                        if (line.GetUpperBound(0) > 3)
                                        {
                                            string[] args = line[4].Split(' ');
                                            if (args.GetUpperBound(0) > 1)
                                            {
                                                try
                                                {
                                                    bool thread_id = false;
                                                    bool reply_id  = false;
                                                    if (args[1].StartsWith("#"))
                                                    {
                                                        thread_id = true;
                                                        args[1]   = args[1].TrimStart('#');
                                                    }
                                                    if (args[2].StartsWith("#"))
                                                    {
                                                        reply_id = true;
                                                        args[2]  = args[2].TrimStart('#');
                                                    }
                                                    bool thread_found = get_reply(channel, ircbot, args[0], args[1], args[2], thread_id, reply_id);
                                                    if (!thread_found)
                                                    {
                                                        ircbot.sendData("PRIVMSG", channel + " :Could not find the thread specified");
                                                    }
                                                }
                                                catch
                                                {
                                                    ircbot.sendData("PRIVMSG", channel + " :Could not find the thread specified");
                                                }
                                            }
                                            else if (args.GetUpperBound(0) > 0)
                                            {
                                                try
                                                {
                                                    bool thread_id = false;
                                                    if (args[1].StartsWith("#"))
                                                    {
                                                        thread_id = true;
                                                        args[1]   = args[1].TrimStart('#');
                                                    }
                                                    bool thread_found = get_thread(channel, ircbot, args[0], args[1], thread_id);
                                                    if (!thread_found)
                                                    {
                                                        ircbot.sendData("PRIVMSG", channel + " :Could not find the thread specified");
                                                    }
                                                }
                                                catch
                                                {
                                                    ircbot.sendData("PRIVMSG", channel + " :Could not find the thread specified");
                                                }
                                            }
                                            else
                                            {
                                                bool thread_found = get_thread(channel, ircbot, args[0], "0", false);
                                                if (!thread_found)
                                                {
                                                    ircbot.sendData("PRIVMSG", channel + " :Could not find the board specified");
                                                }
                                            }
                                        }
                                        else
                                        {
                                            string    uri       = "https://api.4chan.org/boards.json";
                                            WebClient chan      = new WebClient();
                                            var       json_data = string.Empty;
                                            json_data = chan.DownloadString(uri);
                                            XmlDocument xmlDoc     = JsonConvert.DeserializeXmlNode(json_data, "_4chan");
                                            XmlNodeList board_list = xmlDoc.SelectNodes("_4chan/boards");
                                            string      msg        = "";
                                            foreach (XmlNode tmp_board in board_list)
                                            {
                                                msg += " /" + tmp_board["board"].InnerText + "/,";
                                            }
                                            if (!msg.Equals(string.Empty))
                                            {
                                                ircbot.sendData("PRIVMSG", channel + " :Boards Available:" + msg.TrimEnd(','));
                                            }
                                            else
                                            {
                                                ircbot.sendData("PRIVMSG", channel + " :No Boards Available");
                                            }
                                        }
                                    }
                                    else
                                    {
                                        ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command.");
                                    }
                                    break;

                                case "next_thread":
                                    if (spam_check == true)
                                    {
                                        ircbot.add_spam_count(channel);
                                    }
                                    if (nick_access >= command_access)
                                    {
                                        bool   chan_found = false;
                                        string board      = "";
                                        string thread     = "";
                                        bool   thread_id  = false;
                                        for (int x = 0; x < Board_stats.Count(); x++)
                                        {
                                            if (Board_stats[x].channel.Equals(channel))
                                            {
                                                chan_found = true;
                                                board      = Board_stats[x].cur_board;
                                                thread     = (Board_stats[x].cur_OP_num + 1).ToString();
                                            }
                                        }
                                        if (!chan_found)
                                        {
                                            string    uri       = "https://api.4chan.org/boards.json";
                                            WebClient chan      = new WebClient();
                                            var       json_data = string.Empty;
                                            json_data = chan.DownloadString(uri);
                                            XmlDocument xmlDoc     = JsonConvert.DeserializeXmlNode(json_data, "_4chan");
                                            XmlNodeList board_list = xmlDoc.SelectNodes("_4chan/boards");
                                            Random      rand       = new Random();
                                            int         stop       = rand.Next(board_list.Count);
                                            int         index      = 0;
                                            foreach (XmlNode tmp_board in board_list)
                                            {
                                                if (stop == index)
                                                {
                                                    board = tmp_board["board"].InnerText;
                                                    break;
                                                }
                                                index++;
                                            }
                                            thread = "0";
                                        }
                                        bool thread_found = get_thread(channel, ircbot, board, thread, thread_id);
                                        if (!thread_found)
                                        {
                                            ircbot.sendData("PRIVMSG", channel + " :Could not find the thread specified");
                                        }
                                    }
                                    else
                                    {
                                        ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command.");
                                    }
                                    break;

                                case "next_reply":
                                    if (spam_check == true)
                                    {
                                        ircbot.add_spam_count(channel);
                                    }
                                    if (nick_access >= command_access)
                                    {
                                        bool   chan_found = false;
                                        string board      = "";
                                        string thread     = "";
                                        string reply      = "";
                                        bool   thread_id  = false;
                                        bool   reply_id   = false;
                                        for (int x = 0; x < Board_stats.Count(); x++)
                                        {
                                            if (Board_stats[x].channel.Equals(channel))
                                            {
                                                chan_found = true;
                                                board      = Board_stats[x].cur_board;
                                                thread     = Board_stats[x].cur_thread;
                                                thread_id  = true;
                                                reply      = (Board_stats[x].cur_reply_num + 1).ToString();
                                            }
                                        }
                                        if (!chan_found)
                                        {
                                            string    uri       = "https://api.4chan.org/boards.json";
                                            WebClient chan      = new WebClient();
                                            var       json_data = string.Empty;
                                            json_data = chan.DownloadString(uri);
                                            XmlDocument xmlDoc     = JsonConvert.DeserializeXmlNode(json_data, "_4chan");
                                            XmlNodeList board_list = xmlDoc.SelectNodes("_4chan/boards");
                                            Random      rand       = new Random();
                                            int         stop       = rand.Next(board_list.Count);
                                            int         index      = 0;
                                            foreach (XmlNode tmp_board in board_list)
                                            {
                                                if (stop == index)
                                                {
                                                    board = tmp_board["board"].InnerText;
                                                    break;
                                                }
                                                index++;
                                            }
                                            thread = "0";
                                            reply  = "0";
                                        }
                                        bool thread_found = get_reply(channel, ircbot, board, thread, reply, thread_id, reply_id);
                                        if (!thread_found)
                                        {
                                            ircbot.sendData("PRIVMSG", channel + " :Could not find the thread specified");
                                        }
                                    }
                                    else
                                    {
                                        ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command.");
                                    }
                                    break;
                                }
                            }
                        }
                    }
                }
            }
        }
Esempio n. 25
0
        public override void control(bot ircbot, ref IRCConfig conf, int module_id, string[] line, string command, int nick_access, string nick, string channel, bool bot_command, string type)
        {
            string module_name = ircbot.conf.module_config[module_id][0];

            if ((type.Equals("channel") || type.Equals("query")) && bot_command == true)
            {
                foreach (List <string> tmp_command in conf.command_list)
                {
                    if (module_name.Equals(tmp_command[0]))
                    {
                        string[] triggers       = tmp_command[3].Split('|');
                        int      command_access = Convert.ToInt32(tmp_command[5]);
                        string[] blacklist      = tmp_command[6].Split(',');
                        bool     blocked        = false;
                        bool     cmd_found      = false;
                        bool     spam_check     = Convert.ToBoolean(tmp_command[8]);
                        foreach (string bl_chan in blacklist)
                        {
                            if (bl_chan.Equals(channel))
                            {
                                blocked = true;
                                break;
                            }
                        }
                        if (spam_check == true)
                        {
                            blocked = ircbot.get_spam_status(channel, nick);
                        }
                        foreach (string trigger in triggers)
                        {
                            if (trigger.Equals(command))
                            {
                                cmd_found = true;
                                break;
                            }
                        }
                        if (blocked == true && cmd_found == true)
                        {
                            ircbot.sendData("NOTICE", nick + " :I am currently too busy to process that.");
                        }
                        if (blocked == false && cmd_found == true)
                        {
                            foreach (string trigger in triggers)
                            {
                                switch (trigger)
                                {
                                case "poll":
                                    if (spam_check == true)
                                    {
                                        ircbot.add_spam_count(channel);
                                    }
                                    if (nick_access >= command_access)
                                    {
                                        bool poll_active = false;
                                        foreach (poll_info tmp_poll in poll_list)
                                        {
                                            if (tmp_poll.channel.Equals(channel))
                                            {
                                                poll_active = true;
                                                break;
                                            }
                                        }
                                        if (poll_active == false)
                                        {
                                            if (line.GetUpperBound(0) > 3)
                                            {
                                                poll_info temp_poll = new poll_info();
                                                poll_active = true;
                                                string[] lines = line[4].Split('|');
                                                temp_poll.question       = lines[0];
                                                temp_poll.owner          = nick;
                                                temp_poll.channel        = channel;
                                                temp_poll.answers        = new List <List <string> >();
                                                temp_poll.nick_responses = new List <List <string> >();
                                                for (int x = 1; x <= lines.GetUpperBound(0); x++)
                                                {
                                                    List <string> tmp_list = new List <string>();
                                                    tmp_list.Add(lines[x]);
                                                    tmp_list.Add("0");
                                                    temp_poll.answers.Add(tmp_list);
                                                }
                                                ircbot.sendData("PRIVMSG", channel + " :Poll has been started by " + temp_poll.owner + ": " + temp_poll.question);
                                                for (int x = 0; x < temp_poll.answers.Count(); x++)
                                                {
                                                    ircbot.sendData("PRIVMSG", channel + " :" + (x + 1).ToString() + ") " + temp_poll.answers[x][0]);
                                                }
                                                ircbot.sendData("PRIVMSG", channel + " :To Vote, type " + conf.command + "vote <answer_number>.  You may only vote once per poll.  You can change your vote by voting for a different answer.");
                                                poll_list.Add(temp_poll);
                                            }
                                            else
                                            {
                                                ircbot.sendData("PRIVMSG", line[2] + " :" + nick + ", you need to include more info.");
                                            }
                                        }
                                        else
                                        {
                                            ircbot.sendData("PRIVMSG", channel + " :There is currently a poll active right now.  To view the current results, type " + conf.command + "results");
                                        }
                                    }
                                    else
                                    {
                                        ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command.");
                                    }
                                    break;

                                case "addanswer":
                                    if (spam_check == true)
                                    {
                                        ircbot.add_spam_count(channel);
                                    }
                                    if (nick_access >= command_access)
                                    {
                                        bool      poll_active = false;
                                        poll_info cur_poll    = new poll_info();
                                        foreach (poll_info tmp_poll in poll_list)
                                        {
                                            if (tmp_poll.channel.Equals(channel))
                                            {
                                                cur_poll    = tmp_poll;
                                                poll_active = true;
                                                break;
                                            }
                                        }
                                        if (poll_active == true)
                                        {
                                            if (cur_poll.owner.Equals(nick))
                                            {
                                                if (line.GetUpperBound(0) > 3)
                                                {
                                                    List <string> tmp_list = new List <string>();
                                                    tmp_list.Add(line[4]);
                                                    tmp_list.Add("0");
                                                    cur_poll.answers.Add(tmp_list);
                                                    ircbot.sendData("PRIVMSG", channel + " :An Answer has been added to the poll.");
                                                    ircbot.sendData("PRIVMSG", channel + " :" + cur_poll.answers.Count().ToString() + ")" + line[4]);
                                                }
                                                else
                                                {
                                                    ircbot.sendData("PRIVMSG", line[2] + " :" + nick + ", you need to include more info.");
                                                }
                                            }
                                            else
                                            {
                                                ircbot.sendData("PRIVMSG", channel + " :You are not the poll owner.");
                                            }
                                        }
                                        else
                                        {
                                            ircbot.sendData("PRIVMSG", channel + " :There is currently no poll active right now");
                                        }
                                    }
                                    else
                                    {
                                        ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command.");
                                    }
                                    break;

                                case "delanswer":
                                    if (spam_check == true)
                                    {
                                        ircbot.add_spam_count(channel);
                                    }
                                    if (nick_access >= command_access)
                                    {
                                        bool      poll_active = false;
                                        poll_info cur_poll    = new poll_info();
                                        foreach (poll_info tmp_poll in poll_list)
                                        {
                                            if (tmp_poll.channel.Equals(channel))
                                            {
                                                cur_poll    = tmp_poll;
                                                poll_active = true;
                                                break;
                                            }
                                        }
                                        if (poll_active == true)
                                        {
                                            if (cur_poll.owner.Equals(nick))
                                            {
                                                if (line.GetUpperBound(0) > 3)
                                                {
                                                    for (int x = 0; x < cur_poll.answers.Count(); x++)
                                                    {
                                                        if (x == Convert.ToInt32(line[4]))
                                                        {
                                                            ircbot.sendData("PRIVMSG", channel + " :Answer " + x.ToString() + " has been removed.");
                                                            cur_poll.answers.RemoveAt(x);
                                                            break;
                                                        }
                                                    }
                                                }
                                                else
                                                {
                                                    ircbot.sendData("PRIVMSG", line[2] + " :" + nick + ", you need to include more info.");
                                                }
                                            }
                                            else
                                            {
                                                ircbot.sendData("PRIVMSG", channel + " :You are not the poll owner.");
                                            }
                                        }
                                        else
                                        {
                                            ircbot.sendData("PRIVMSG", channel + " :There is currently no poll active right now");
                                        }
                                    }
                                    else
                                    {
                                        ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command.");
                                    }
                                    break;

                                case "stoppoll":
                                    if (spam_check == true)
                                    {
                                        ircbot.add_spam_count(channel);
                                    }
                                    if (nick_access >= command_access)
                                    {
                                        bool      poll_active = false;
                                        int       index       = 0;
                                        poll_info cur_poll    = new poll_info();
                                        foreach (poll_info tmp_poll in poll_list)
                                        {
                                            if (tmp_poll.channel.Equals(channel))
                                            {
                                                cur_poll    = tmp_poll;
                                                poll_active = true;
                                                break;
                                            }
                                            index++;
                                        }
                                        if (poll_active == true)
                                        {
                                            if (cur_poll.owner.Equals(nick) || nick_access > Convert.ToInt32(ircbot.get_user_access(cur_poll.owner, channel)))
                                            {
                                                poll_active = false;

                                                ircbot.sendData("PRIVMSG", channel + " :Results of poll by " + cur_poll.owner + ": " + cur_poll.question);
                                                for (int x = 0; x < cur_poll.answers.Count(); x++)
                                                {
                                                    ircbot.sendData("PRIVMSG", channel + " :" + (x + 1).ToString() + ") " + cur_poll.answers[x][0] + " | " + cur_poll.answers[x][1] + " votes");
                                                }
                                                poll_list.RemoveAt(index);
                                            }
                                            else
                                            {
                                                ircbot.sendData("PRIVMSG", channel + " :You are not the poll owner.");
                                            }
                                        }
                                        else
                                        {
                                            ircbot.sendData("PRIVMSG", channel + " :There is currently no poll active right now");
                                        }
                                    }
                                    else
                                    {
                                        ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command.");
                                    }
                                    break;

                                case "results":
                                    if (spam_check == true)
                                    {
                                        ircbot.add_spam_count(channel);
                                    }
                                    if (nick_access >= command_access)
                                    {
                                        bool      poll_active = false;
                                        poll_info cur_poll    = new poll_info();
                                        foreach (poll_info tmp_poll in poll_list)
                                        {
                                            if (tmp_poll.channel.Equals(channel))
                                            {
                                                cur_poll    = tmp_poll;
                                                poll_active = true;
                                                break;
                                            }
                                        }
                                        if (poll_active == true)
                                        {
                                            ircbot.sendData("NOTICE", nick + " :Poll by " + cur_poll.owner + ": " + cur_poll.question);
                                            for (int x = 0; x < cur_poll.answers.Count(); x++)
                                            {
                                                ircbot.sendData("NOTICE", nick + " :" + (x + 1).ToString() + ") " + cur_poll.answers[x][0] + " | " + cur_poll.answers[x][1] + " votes");
                                            }
                                            ircbot.sendData("NOTICE", nick + " :To Vote, type .vote <answer_number>.  You may only vote once per poll.  You can change your vote by voting for a different answer.");
                                        }
                                        else
                                        {
                                            ircbot.sendData("NOTICE", nick + " :There is currently no poll active right now");
                                        }
                                    }
                                    else
                                    {
                                        ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command.");
                                    }
                                    break;

                                case "vote":
                                    if (spam_check == true)
                                    {
                                        ircbot.add_spam_count(channel);
                                    }
                                    if (nick_access >= command_access)
                                    {
                                        if (line.GetUpperBound(0) > 3)
                                        {
                                            bool      poll_active = false;
                                            poll_info cur_poll    = new poll_info();
                                            foreach (poll_info tmp_poll in poll_list)
                                            {
                                                if (tmp_poll.channel.Equals(channel))
                                                {
                                                    cur_poll    = tmp_poll;
                                                    poll_active = true;
                                                    break;
                                                }
                                            }
                                            if (poll_active == true)
                                            {
                                                try
                                                {
                                                    int vote = Convert.ToInt32(line[4]);
                                                    if (vote > 0 && vote <= cur_poll.answers.Count())
                                                    {
                                                        bool   nick_voted = false;
                                                        int    index      = 0;
                                                        string nick_host  = ircbot.get_user_host(nick);
                                                        if (nick_host.Equals(""))
                                                        {
                                                            nick_host = nick;
                                                        }
                                                        for (int x = 0; x < cur_poll.nick_responses.Count(); x++)
                                                        {
                                                            if (cur_poll.nick_responses[x][0].Equals(nick_host))
                                                            {
                                                                nick_voted = true;
                                                                index      = Convert.ToInt32(cur_poll.nick_responses[x][1]);
                                                                cur_poll.nick_responses[x][1]  = vote.ToString();
                                                                cur_poll.answers[index - 1][1] = (Convert.ToInt32(cur_poll.answers[index - 1][1]) - 1).ToString();
                                                                cur_poll.answers[vote - 1][1]  = (Convert.ToInt32(cur_poll.answers[vote - 1][1]) + 1).ToString();
                                                                break;
                                                            }
                                                        }
                                                        if (nick_voted == false)
                                                        {
                                                            List <string> tmp_list = new List <string>();
                                                            tmp_list.Add(nick_host);
                                                            tmp_list.Add(vote.ToString());
                                                            cur_poll.nick_responses.Add(tmp_list);
                                                            cur_poll.answers[vote - 1][1] = (Convert.ToInt32(cur_poll.answers[vote - 1][1]) + 1).ToString();
                                                        }
                                                        ircbot.sendData("PRIVMSG", channel + " :Thank you for voting for " + vote.ToString());
                                                    }
                                                    else
                                                    {
                                                        ircbot.sendData("PRIVMSG", channel + " :You need to vote for a valid answer.");
                                                    }
                                                }
                                                catch
                                                {
                                                    ircbot.sendData("PRIVMSG", channel + " :You need to vote for a valid answer.");
                                                }
                                            }
                                            else
                                            {
                                                ircbot.sendData("PRIVMSG", channel + " :There is currently no poll active right now");
                                            }
                                        }
                                        else
                                        {
                                            ircbot.sendData("PRIVMSG", line[2] + " :" + nick + ", you need to include more info.");
                                        }
                                    }
                                    else
                                    {
                                        ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command.");
                                    }
                                    break;
                                }
                            }
                        }
                    }
                }
            }
        }
Esempio n. 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)
        {
            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 "alarm":
                                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, StringSplitOptions.RemoveEmptyEntries);
                                        if (new_line.GetUpperBound(0) > 0)
                                        {
                                            bool int_allowed = true;
                                            int  time        = 0;
                                            try
                                            {
                                                time = Convert.ToInt32(new_line[0]);
                                                if ((time * 1000) <= 0)
                                                {
                                                    int_allowed = false;
                                                }
                                            }
                                            catch
                                            {
                                                int_allowed = false;
                                            }
                                            if (int_allowed == true)
                                            {
                                                char[]   charSplit = new char[] { ' ' };
                                                string[] ex        = new_line[1].Split(charSplit);
                                                if (ex[0].TrimStart(Convert.ToChar(ircbot.Conf.Command)).Equals("alarm"))
                                                {
                                                    if (type.Equals("channel"))
                                                    {
                                                        ircbot.sendData("PRIVMSG", channel + " :Recursion is bad.");
                                                    }
                                                    else
                                                    {
                                                        ircbot.sendData("PRIVMSG", nick + " :Recursion is bad.");
                                                    }
                                                }
                                                else
                                                {
                                                    tmp_conf = Conf;
                                                    Timer alarm_trigger = new Timer();
                                                    alarm_trigger.Interval  = (time * 1000);
                                                    alarm_trigger.Enabled   = true;
                                                    alarm_trigger.AutoReset = false;
                                                    alarm_trigger.Elapsed  += (sender, e) => ring_alarm(sender, e, ircbot, nick, line[0], nick_access, channel, type, new_line[1]);
                                                    alarms.Add(alarm_trigger);

                                                    if (type.Equals("channel"))
                                                    {
                                                        ircbot.sendData("PRIVMSG", channel + " :Alarm added for " + new_line[0] + " seconds from now.");
                                                    }
                                                    else
                                                    {
                                                        ircbot.sendData("PRIVMSG", nick + " :Alarm added for " + new_line[0] + " seconds from now.");
                                                    }
                                                }
                                            }
                                            else
                                            {
                                                if (type.Equals("channel"))
                                                {
                                                    ircbot.sendData("PRIVMSG", channel + " :" + nick + ", please pick a valid time.");
                                                }
                                                else
                                                {
                                                    ircbot.sendData("PRIVMSG", nick + " :" + nick + ", please pick a valid time.");
                                                }
                                            }
                                        }
                                        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.");
                                            }
                                        }
                                    }
                                    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.");
                                        }
                                    }
                                }
                                else
                                {
                                    ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command.");
                                }
                                break;
                            }
                        }
                    }
                }
            }
        }
Esempio n. 27
0
        public override void control(bot ircbot, ref IRCConfig conf, int module_id, string[] line, string command, int nick_access, string nick, string channel, bool bot_command, string type)
        {
            string module_name = ircbot.conf.module_config[module_id][0];

            if ((type.Equals("channel") || type.Equals("query")) && bot_command == true)
            {
                foreach (List <string> tmp_command in conf.command_list)
                {
                    if (module_name.Equals(tmp_command[0]))
                    {
                        string[] triggers       = tmp_command[3].Split('|');
                        int      command_access = Convert.ToInt32(tmp_command[5]);
                        string[] blacklist      = tmp_command[6].Split(',');
                        bool     blocked        = false;
                        bool     cmd_found      = false;
                        bool     spam_check     = Convert.ToBoolean(tmp_command[8]);
                        foreach (string bl_chan in blacklist)
                        {
                            if (bl_chan.Equals(channel))
                            {
                                blocked = true;
                                break;
                            }
                        }
                        if (spam_check == true)
                        {
                            blocked = ircbot.get_spam_status(channel, nick);
                        }
                        foreach (string trigger in triggers)
                        {
                            if (trigger.Equals(command))
                            {
                                cmd_found = true;
                                break;
                            }
                        }
                        if (blocked == true && cmd_found == true)
                        {
                            ircbot.sendData("NOTICE", nick + " :I am currently too busy to process that.");
                        }
                        if (blocked == false && cmd_found == true)
                        {
                            foreach (string trigger in triggers)
                            {
                                switch (trigger)
                                {
                                case "idle":
                                    if (spam_check == true)
                                    {
                                        ircbot.add_spam_count(channel);
                                    }
                                    if (nick_access >= command_access)
                                    {
                                        bool nick_found = false;
                                        foreach (string idle_nick in idle_list)
                                        {
                                            if (idle_nick.Equals(nick))
                                            {
                                                nick_found = true;
                                                break;
                                            }
                                        }
                                        if (nick_found == false)
                                        {
                                            idle_list.Add(nick);
                                            ircbot.sendData("NOTICE", nick + " :You are now set as idle.  Type .deidle to come back.");
                                        }
                                        else
                                        {
                                            ircbot.sendData("NOTICE", nick + " :You are already idle.  Type .deidle to come back.");
                                        }
                                    }
                                    else
                                    {
                                        ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command.");
                                    }
                                    break;

                                case "deidle":
                                    if (spam_check == true)
                                    {
                                        ircbot.add_spam_count(channel);
                                    }
                                    if (nick_access >= command_access)
                                    {
                                        bool nick_found = false;
                                        foreach (string idle_nick in idle_list)
                                        {
                                            if (idle_nick.Equals(nick))
                                            {
                                                nick_found = true;
                                                break;
                                            }
                                        }
                                        if (nick_found == true)
                                        {
                                            idle_list.Remove(nick);
                                            ircbot.sendData("NOTICE", nick + " :Welcome back!");
                                        }
                                        else
                                        {
                                            ircbot.sendData("NOTICE", nick + " :You are already idle.  Type .deidle to come back.");
                                        }
                                    }
                                    else
                                    {
                                        ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command.");
                                    }
                                    break;
                                }
                            }
                        }
                    }
                }
            }
        }
Esempio n. 28
0
        public override void control(bot ircbot, ref IRCConfig conf, int module_id, string[] line, string command, int nick_access, string nick, string channel, bool bot_command, string type)
        {
            string module_name = ircbot.conf.module_config[module_id][0];
            if ((type.Equals("channel") || type.Equals("query")) && bot_command == true)
            {
                foreach (List<string> tmp_command in conf.command_list)
                {
                    if (module_name.Equals(tmp_command[0]))
                    {
                        string[] triggers = tmp_command[3].Split('|');
                        int command_access = Convert.ToInt32(tmp_command[5]);
                        string[] blacklist = tmp_command[6].Split(',');
                        bool blocked = false;
                        bool cmd_found = false;
                        bool spam_check = Convert.ToBoolean(tmp_command[8]);
                        foreach (string bl_chan in blacklist)
                        {
                            if (bl_chan.Equals(channel))
                            {
                                blocked = true;
                                break;
                            }
                        }
                        if (spam_check == true)
                        {
                            blocked = ircbot.get_spam_status(channel, nick);
                        }
                        foreach (string trigger in triggers)
                        {
                            if (trigger.Equals(command))
                            {
                                cmd_found = true;
                                break;
                            }
                        }
                        if (blocked == true && cmd_found == true)
                        {
                            ircbot.sendData("NOTICE", nick + " :I am currently too busy to process that.");
                        }
                        if (blocked == false && cmd_found == true)
                        {
                            foreach (string trigger in triggers)
                            {
                                switch (trigger)
                                {
                                    case "poll":
                                        if (spam_check == true)
                                        {
                                            ircbot.add_spam_count(channel);
                                        }
                                        if (nick_access >= command_access)
                                        {
                                            bool poll_active = false;
                                            foreach (poll_info tmp_poll in poll_list)
                                            {
                                                if (tmp_poll.channel.Equals(channel))
                                                {
                                                    poll_active = true;
                                                    break;
                                                }
                                            }
                                            if (poll_active == false)
                                            {
                                                if (line.GetUpperBound(0) > 3)
                                                {
                                                    poll_info temp_poll = new poll_info();
                                                    poll_active = true;
                                                    string[] lines = line[4].Split('|');
                                                    temp_poll.question = lines[0];
                                                    temp_poll.owner = nick;
                                                    temp_poll.channel = channel;
                                                    temp_poll.answers = new List<List<string>>();
                                                    temp_poll.nick_responses = new List<List<string>>();
                                                    for (int x = 1; x <= lines.GetUpperBound(0); x++)
                                                    {
                                                        List<string> tmp_list = new List<string>();
                                                        tmp_list.Add(lines[x]);
                                                        tmp_list.Add("0");
                                                        temp_poll.answers.Add(tmp_list);
                                                    }
                                                    ircbot.sendData("PRIVMSG", channel + " :Poll has been started by " + temp_poll.owner + ": " + temp_poll.question);
                                                    for (int x = 0; x < temp_poll.answers.Count(); x++)
                                                    {
                                                        ircbot.sendData("PRIVMSG", channel + " :" + (x + 1).ToString() + ") " + temp_poll.answers[x][0]);
                                                    }
                                                    ircbot.sendData("PRIVMSG", channel + " :To Vote, type " + conf.command + "vote <answer_number>.  You may only vote once per poll.  You can change your vote by voting for a different answer.");
                                                    poll_list.Add(temp_poll);
                                                }
                                                else
                                                {
                                                    ircbot.sendData("PRIVMSG", line[2] + " :" + nick + ", you need to include more info.");
                                                }
                                            }
                                            else
                                            {
                                                ircbot.sendData("PRIVMSG", channel + " :There is currently a poll active right now.  To view the current results, type " + conf.command + "results");
                                            }
                                        }
                                        else
                                        {
                                            ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command.");
                                        }
                                        break;
                                    case "addanswer":
                                        if (spam_check == true)
                                        {
                                            ircbot.add_spam_count(channel);
                                        }
                                        if (nick_access >= command_access)
                                        {
                                            bool poll_active = false;
                                            poll_info cur_poll = new poll_info();
                                            foreach (poll_info tmp_poll in poll_list)
                                            {
                                                if (tmp_poll.channel.Equals(channel))
                                                {
                                                    cur_poll = tmp_poll;
                                                    poll_active = true;
                                                    break;
                                                }
                                            }
                                            if (poll_active == true)
                                            {
                                                if (cur_poll.owner.Equals(nick))
                                                {
                                                    if (line.GetUpperBound(0) > 3)
                                                    {
                                                            List<string> tmp_list = new List<string>();
                                                            tmp_list.Add(line[4]);
                                                            tmp_list.Add("0");
                                                            cur_poll.answers.Add(tmp_list);
                                                            ircbot.sendData("PRIVMSG", channel + " :An Answer has been added to the poll.");
                                                            ircbot.sendData("PRIVMSG", channel + " :" + cur_poll.answers.Count().ToString() + ")" + line[4]);
                                                    }
                                                    else
                                                    {
                                                        ircbot.sendData("PRIVMSG", line[2] + " :" + nick + ", you need to include more info.");
                                                    }
                                                }
                                                else
                                                {
                                                    ircbot.sendData("PRIVMSG", channel + " :You are not the poll owner.");
                                                }
                                            }
                                            else
                                            {
                                                ircbot.sendData("PRIVMSG", channel + " :There is currently no poll active right now");
                                            }
                                        }
                                        else
                                        {
                                            ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command.");
                                        }
                                        break;
                                    case "delanswer":
                                        if (spam_check == true)
                                        {
                                            ircbot.add_spam_count(channel);
                                        }
                                        if (nick_access >= command_access)
                                        {
                                            bool poll_active = false;
                                            poll_info cur_poll = new poll_info();
                                            foreach (poll_info tmp_poll in poll_list)
                                            {
                                                if (tmp_poll.channel.Equals(channel))
                                                {
                                                    cur_poll = tmp_poll;
                                                    poll_active = true;
                                                    break;
                                                }
                                            }
                                            if (poll_active == true)
                                            {
                                                if (cur_poll.owner.Equals(nick))
                                                {
                                                    if (line.GetUpperBound(0) > 3)
                                                    {
                                                        for (int x = 0; x < cur_poll.answers.Count(); x++)
                                                        {
                                                            if (x == Convert.ToInt32(line[4]))
                                                            {
                                                                ircbot.sendData("PRIVMSG", channel + " :Answer " + x.ToString() + " has been removed.");
                                                                cur_poll.answers.RemoveAt(x);
                                                                break;
                                                            }
                                                        }
                                                    }
                                                    else
                                                    {
                                                        ircbot.sendData("PRIVMSG", line[2] + " :" + nick + ", you need to include more info.");
                                                    }
                                                }
                                                else
                                                {
                                                    ircbot.sendData("PRIVMSG", channel + " :You are not the poll owner.");
                                                }
                                            }
                                            else
                                            {
                                                ircbot.sendData("PRIVMSG", channel + " :There is currently no poll active right now");
                                            }
                                        }
                                        else
                                        {
                                            ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command.");
                                        }
                                        break;
                                    case "stoppoll":
                                        if (spam_check == true)
                                        {
                                            ircbot.add_spam_count(channel);
                                        }
                                        if (nick_access >= command_access)
                                        {
                                            bool poll_active = false;
                                            int index = 0;
                                            poll_info cur_poll = new poll_info();
                                            foreach (poll_info tmp_poll in poll_list)
                                            {
                                                if (tmp_poll.channel.Equals(channel))
                                                {
                                                    cur_poll = tmp_poll;
                                                    poll_active = true;
                                                    break;
                                                }
                                                index++;
                                            }
                                            if (poll_active == true)
                                            {
                                                if (cur_poll.owner.Equals(nick) || nick_access > Convert.ToInt32(ircbot.get_user_access(cur_poll.owner, channel)))
                                                {
                                                    poll_active = false;

                                                    ircbot.sendData("PRIVMSG", channel + " :Results of poll by " + cur_poll.owner + ": " + cur_poll.question);
                                                    for (int x = 0; x < cur_poll.answers.Count(); x++)
                                                    {
                                                        ircbot.sendData("PRIVMSG", channel + " :" + (x + 1).ToString() + ") " + cur_poll.answers[x][0] + " | " + cur_poll.answers[x][1] + " votes");
                                                    }
                                                    poll_list.RemoveAt(index);
                                                }
                                                else
                                                {
                                                    ircbot.sendData("PRIVMSG", channel + " :You are not the poll owner.");
                                                }
                                            }
                                            else
                                            {
                                                ircbot.sendData("PRIVMSG", channel + " :There is currently no poll active right now");
                                            }
                                        }
                                        else
                                        {
                                            ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command.");
                                        }
                                        break;
                                    case "results":
                                        if (spam_check == true)
                                        {
                                            ircbot.add_spam_count(channel);
                                        }
                                        if (nick_access >= command_access)
                                        {
                                            bool poll_active = false;
                                            poll_info cur_poll = new poll_info();
                                            foreach (poll_info tmp_poll in poll_list)
                                            {
                                                if (tmp_poll.channel.Equals(channel))
                                                {
                                                    cur_poll = tmp_poll;
                                                    poll_active = true;
                                                    break;
                                                }
                                            }
                                            if (poll_active == true)
                                            {
                                                ircbot.sendData("NOTICE", nick + " :Poll by " + cur_poll.owner + ": " + cur_poll.question);
                                                for (int x = 0; x < cur_poll.answers.Count(); x++)
                                                {
                                                    ircbot.sendData("NOTICE", nick + " :" + (x + 1).ToString() + ") " + cur_poll.answers[x][0] + " | " + cur_poll.answers[x][1] + " votes");
                                                }
                                                ircbot.sendData("NOTICE", nick + " :To Vote, type .vote <answer_number>.  You may only vote once per poll.  You can change your vote by voting for a different answer.");
                                            }
                                            else
                                            {
                                                ircbot.sendData("NOTICE", nick + " :There is currently no poll active right now");
                                            }
                                        }
                                        else
                                        {
                                            ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command.");
                                        }
                                        break;
                                    case "vote":
                                        if (spam_check == true)
                                        {
                                            ircbot.add_spam_count(channel);
                                        }
                                        if (nick_access >= command_access)
                                        {
                                            if (line.GetUpperBound(0) > 3)
                                            {
                                                bool poll_active = false;
                                                poll_info cur_poll = new poll_info();
                                                foreach (poll_info tmp_poll in poll_list)
                                                {
                                                    if (tmp_poll.channel.Equals(channel))
                                                    {
                                                        cur_poll = tmp_poll;
                                                        poll_active = true;
                                                        break;
                                                    }
                                                }
                                                if (poll_active == true)
                                                {
                                                    try
                                                    {
                                                        int vote = Convert.ToInt32(line[4]);
                                                        if (vote > 0 && vote <= cur_poll.answers.Count())
                                                        {
                                                            bool nick_voted = false;
                                                            int index = 0;
                                                            string nick_host = ircbot.get_user_host(nick);
                                                            if (nick_host.Equals(""))
                                                            {
                                                                nick_host = nick;
                                                            }
                                                            for (int x = 0; x < cur_poll.nick_responses.Count(); x++)
                                                            {
                                                                if (cur_poll.nick_responses[x][0].Equals(nick_host))
                                                                {
                                                                    nick_voted = true;
                                                                    index = Convert.ToInt32(cur_poll.nick_responses[x][1]);
                                                                    cur_poll.nick_responses[x][1] = vote.ToString();
                                                                    cur_poll.answers[index - 1][1] = (Convert.ToInt32(cur_poll.answers[index - 1][1]) - 1).ToString();
                                                                    cur_poll.answers[vote - 1][1] = (Convert.ToInt32(cur_poll.answers[vote - 1][1]) + 1).ToString();
                                                                    break;
                                                                }
                                                            }
                                                            if (nick_voted == false)
                                                            {
                                                                List<string> tmp_list = new List<string>();
                                                                tmp_list.Add(nick_host);
                                                                tmp_list.Add(vote.ToString());
                                                                cur_poll.nick_responses.Add(tmp_list);
                                                                cur_poll.answers[vote - 1][1] = (Convert.ToInt32(cur_poll.answers[vote - 1][1]) + 1).ToString();
                                                            }
                                                            ircbot.sendData("PRIVMSG", channel + " :Thank you for voting for " + vote.ToString());
                                                        }
                                                        else
                                                        {
                                                            ircbot.sendData("PRIVMSG", channel + " :You need to vote for a valid answer.");
                                                        }
                                                    }
                                                    catch
                                                    {
                                                        ircbot.sendData("PRIVMSG", channel + " :You need to vote for a valid answer.");
                                                    }
                                                }
                                                else
                                                {
                                                    ircbot.sendData("PRIVMSG", channel + " :There is currently no poll active right now");
                                                }
                                            }
                                            else
                                            {
                                                ircbot.sendData("PRIVMSG", line[2] + " :" + nick + ", you need to include more info.");
                                            }
                                        }
                                        else
                                        {
                                            ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command.");
                                        }
                                        break;
                                }
                            }
                        }
                    }
                }
            }
        }
Esempio n. 29
0
 public override void control(bot ircbot, ref IRCConfig conf, int module_id, string[] line, string command, int nick_access, string nick, string channel, bool bot_command, string type)
 {
     string module_name = ircbot.conf.module_config[module_id][0];
     if (type.Equals("channel") && bot_command == true)
     {
         foreach (List<string> tmp_command in conf.command_list)
         {
             if (module_name.Equals(tmp_command[0]))
             {
                 string[] triggers = tmp_command[3].Split('|');
                 int command_access = Convert.ToInt32(tmp_command[5]);
                 string[] blacklist = tmp_command[6].Split(',');
                 bool blocked = false;
                 bool cmd_found = false;
                 bool spam_check = Convert.ToBoolean(tmp_command[8]);
                 foreach (string bl_chan in blacklist)
                 {
                     if (bl_chan.Equals(channel))
                     {
                         blocked = true;
                         break;
                     }
                 }
                 if (spam_check == true)
                 {
                     blocked = ircbot.get_spam_status(channel, nick);
                 }
                 foreach (string trigger in triggers)
                 {
                     if (trigger.Equals(command))
                     {
                         cmd_found = true;
                         break;
                     }
                 }
                 if (blocked == true && cmd_found == true)
                 {
                     ircbot.sendData("NOTICE", nick + " :I am currently too busy to process that.");
                 }
                 if (blocked == false && cmd_found == true)
                 {
                     foreach (string trigger in triggers)
                     {
                         switch (trigger)
                         {
                             case "pingme":
                                 if (spam_check == true)
                                 {
                                     ircbot.add_spam_count(channel);
                                 }
                                 if (nick_access >= command_access)
                                 {
                                     int epoch = (int)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds;
                                     ircbot.sendData("PRIVMSG", nick + " :\u0001PING " + epoch.ToString() + "\u0001");
                                     List<string> tmp_list = new List<string>();
                                     string current_time = DateTime.Now.ToLongTimeString();
                                     tmp_list.Add(nick);
                                     tmp_list.Add(channel);
                                     tmp_list.Add(current_time);
                                     ping_list.Add(tmp_list);
                                 }
                                 else
                                 {
                                     ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command.");
                                 }
                                 break;
                         }
                     }
                 }
             }
         }
     }
     if (type.Equals("line") || type.Equals("query"))
     {
         check_ping(line, ircbot, nick);
     }
 }
Esempio n. 30
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 "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);
     }
 }
Esempio n. 31
0
 public override void control(bot ircbot, ref IRCConfig conf, int module_id, string[] line, string command, int nick_access, string nick, string channel, bool bot_command, string type)
 {
     string module_name = ircbot.conf.module_config[module_id][0];
     if ((type.Equals("channel") || type.Equals("query")) && bot_command == true)
     {
         foreach (List<string> tmp_command in conf.command_list)
         {
             if (module_name.Equals(tmp_command[0]))
             {
                 string[] triggers = tmp_command[3].Split('|');
                 int command_access = Convert.ToInt32(tmp_command[5]);
                 string[] blacklist = tmp_command[6].Split(',');
                 bool blocked = false;
                 bool cmd_found = false;
                 bool spam_check = Convert.ToBoolean(tmp_command[8]);
                 foreach (string bl_chan in blacklist)
                 {
                     if (bl_chan.Equals(channel))
                     {
                         blocked = true;
                         break;
                     }
                 }
                 if (spam_check == true)
                 {
                     blocked = ircbot.get_spam_status(channel, nick);
                 }
                 foreach (string trigger in triggers)
                 {
                     if (trigger.Equals(command))
                     {
                         cmd_found = true;
                         break;
                     }
                 }
                 if (blocked == true && cmd_found == true)
                 {
                     ircbot.sendData("NOTICE", nick + " :I am currently too busy to process that.");
                 }
                 if (blocked == false && cmd_found == true)
                 {
                     foreach (string trigger in triggers)
                     {
                         switch (trigger)
                         {
                             case "survey":
                                 if (spam_check == true)
                                 {
                                     ircbot.add_spam_count(channel);
                                 }
                                 if (nick_access >= command_access)
                                 {
                                     if (line.GetUpperBound(0) > 3)
                                     {
                                         int num_survey = 1;
                                         try
                                         {
                                             num_survey = Convert.ToInt32(line[4].Trim());
                                             start_survey(nick, nick_access, num_survey - 1, ircbot, conf);
                                         }
                                         catch
                                         {
                                             ircbot.sendData("NOTICE", nick + " :You need to choose a valid survey.  To view all surveys, please type " + conf.command + "surveys");
                                         }
                                     }
                                     else
                                     {
                                         ircbot.sendData("NOTICE", nick + " :You need to choose a valid survey.  To view all surveys, please type " + conf.command + "surveys");
                                     }
                                 }
                                 else
                                 {
                                     ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command.");
                                 }
                                 break;
                             case "nextquestion":
                                 if (spam_check == true)
                                 {
                                     ircbot.add_spam_count(channel);
                                 }
                                 if (nick_access >= command_access)
                                 {
                                     continue_survey(nick, nick_access, ircbot, conf);
                                 }
                                 else
                                 {
                                     ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command.");
                                 }
                                 break;
                             case "finishsurvey":
                                 if (spam_check == true)
                                 {
                                     ircbot.add_spam_count(channel);
                                 }
                                 if (nick_access >= command_access)
                                 {
                                     int index = 0;
                                     foreach (survey_info survey in active_surveys)
                                     {
                                         if (nick.Equals(survey.nick) && survey.user_submission == false)
                                         {
                                             if (Directory.Exists(ircbot.cur_dir + Path.DirectorySeparatorChar + "modules" + Path.DirectorySeparatorChar + "survey" + Path.DirectorySeparatorChar + "surveys" + Path.DirectorySeparatorChar + ""))
                                             {
                                                 FileInfo fi = new FileInfo(ircbot.cur_dir + Path.DirectorySeparatorChar + "modules" + Path.DirectorySeparatorChar + "survey" + Path.DirectorySeparatorChar + "surveys" + Path.DirectorySeparatorChar + "");
                                                 DirectoryInfo di = fi.Directory;
                                                 FileSystemInfo[] fsi = di.GetFiles();
                                                 if (fsi.GetUpperBound(0) >= 0 && fsi.GetUpperBound(0) >= survey.survey_number)
                                                 {
                                                     string[] questions = File.ReadAllLines(fsi[survey.survey_number].FullName);
                                                     if (questions.GetUpperBound(0) > 2)
                                                     {
                                                         ircbot.sendData("PRIVMSG", nick + " :Thank you for submitting the survey.  It is survey #" + (survey.survey_number + 1).ToString());
                                                         active_surveys.RemoveAt(index);
                                                     }
                                                     else
                                                     {
                                                         ircbot.sendData("PRIVMSG", nick + " :You need to submit at least one question for your survey.");
                                                     }
                                                 }
                                                 else
                                                 {
                                                     ircbot.sendData("PRIVMSG", nick + " :The survey no longer exists.  Please retry adding your survey.");
                                                 }
                                             }
                                             else
                                             {
                                                 ircbot.sendData("PRIVMSG", nick + " :The survey no longer exists.  Please retry adding your survey.");
                                             }
                                             break;
                                         }
                                         index++;
                                     }
                                 }
                                 else
                                 {
                                     ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command.");
                                 }
                                 break;
                             case "cancelsurvey":
                                 if (spam_check == true)
                                 {
                                     ircbot.add_spam_count(channel);
                                 }
                                 if (nick_access >= command_access)
                                 {
                                     int index = 0;
                                     foreach (survey_info survey in active_surveys)
                                     {
                                         if (nick.Equals(survey.nick) && survey.user_submission == false)
                                         {
                                             if (Directory.Exists(ircbot.cur_dir + Path.DirectorySeparatorChar + "modules" + Path.DirectorySeparatorChar + "survey" + Path.DirectorySeparatorChar + "surveys" + Path.DirectorySeparatorChar + ""))
                                             {
                                                 FileInfo fi = new FileInfo(ircbot.cur_dir + Path.DirectorySeparatorChar + "modules" + Path.DirectorySeparatorChar + "survey" + Path.DirectorySeparatorChar + "surveys" + Path.DirectorySeparatorChar + "");
                                                 DirectoryInfo di = fi.Directory;
                                                 FileSystemInfo[] fsi = di.GetFiles();
                                                 if (fsi.GetUpperBound(0) >= 0 && fsi.GetUpperBound(0) >= survey.survey_number)
                                                 {
                                                     File.Delete(fsi[survey.survey_number].FullName);
                                                     string[] owners = File.ReadAllLines(fsi[survey.survey_number].FullName)[2].Split(',');
                                                     foreach (string owner in owners)
                                                     {
                                                         ircbot.sendData("NOTICE", owner + " :" + nick + " has canceled your survey, " + File.ReadAllLines(fsi[survey.survey_number].FullName)[1]);
                                                     }
                                                     active_surveys.RemoveAt(index);
                                                 }
                                                 else
                                                 {
                                                     ircbot.sendData("NOTICE", nick + " :The survey does not exist.");
                                                 }
                                             }
                                             else
                                             {
                                                 ircbot.sendData("NOTICE", nick + " :The survey does not exist.");
                                             }
                                             break;
                                         }
                                         else if(nick.Equals(survey.nick) && survey.user_submission == true)
                                         {
                                             if (Directory.Exists(ircbot.cur_dir + Path.DirectorySeparatorChar + "modules" + Path.DirectorySeparatorChar + "survey" + Path.DirectorySeparatorChar + "answers" + Path.DirectorySeparatorChar + survey.name + Path.DirectorySeparatorChar + nick))
                                             {
                                                 Directory.Delete(ircbot.cur_dir + Path.DirectorySeparatorChar + "modules" + Path.DirectorySeparatorChar + "survey" + Path.DirectorySeparatorChar + "answers" + Path.DirectorySeparatorChar + survey.name + Path.DirectorySeparatorChar + nick, true);
                                                 active_surveys.RemoveAt(index);
                                             }
                                             else
                                             {
                                                 ircbot.sendData("NOTICE", nick + " :The survey does not exist.");
                                             }
                                             break;
                                         }
                                         index++;
                                     }
                                 }
                                 else
                                 {
                                     ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command.");
                                 }
                                 break;
                             case "surveys":
                                 if (spam_check == true)
                                 {
                                     ircbot.add_spam_count(channel);
                                 }
                                 if (nick_access >= command_access)
                                 {
                                     if (line.GetUpperBound(0) > 3)
                                     {
                                         int num_survey = 1;
                                         char[] sep = new char[] { ' ' };
                                         string[] new_line = line[4].Split(sep, StringSplitOptions.RemoveEmptyEntries);
                                         if (new_line.GetUpperBound(0) > 0)
                                         {
                                             try
                                             {
                                                 num_survey = Convert.ToInt32(new_line[0].Trim());
                                                 view_survey(num_survey - 1, nick_access, nick, new_line[1].ToLower(), ircbot, conf);
                                             }
                                             catch
                                             {
                                                 ircbot.sendData("NOTICE", nick + " :You need to choose a valid survey.  To view all surveys, please type " + conf.command + "surveys");
                                             }
                                         }
                                         else
                                         {
                                             try
                                             {
                                                 num_survey = Convert.ToInt32(new_line[0].Trim());
                                                 view_survey(num_survey - 1, nick_access, nick, null, ircbot, conf);
                                             }
                                             catch
                                             {
                                                 ircbot.sendData("NOTICE", nick + " :You need to choose a valid survey.  To view all surveys, please type " + conf.command + "surveys");
                                             }
                                         }
                                     }
                                     else
                                     {
                                         view_survey(-1, nick_access, nick, null, ircbot, conf);
                                     }
                                 }
                                 else
                                 {
                                     ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command.");
                                 }
                                 break;
                             case "addsurveyowner":
                                 if (spam_check == true)
                                 {
                                     ircbot.add_spam_count(channel);
                                 }
                                 if (nick_access >= command_access)
                                 {
                                     if (line.GetUpperBound(0) > 3)
                                     {
                                         int num_survey = 1;
                                         string[] new_line = line[4].Split(' ');
                                         try
                                         {
                                             num_survey = Convert.ToInt32(new_line[0]);
                                             add_survey_owner(num_survey - 1, nick, new_line[1].ToLower(), ircbot, conf);
                                         }
                                         catch
                                         {
                                             ircbot.sendData("NOTICE", nick + " :You need to choose a valid survey.  To view all surveys, please type " + conf.command + "surveys");
                                         }
                                     }
                                     else
                                     {
                                         ircbot.sendData("NOTICE", nick + " :You need to choose a valid survey.  To view all surveys, please type " + conf.command + "surveys");
                                     }
                                 }
                                 else
                                 {
                                     ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command.");
                                 }
                                 break;
                             case "delsurveyowner":
                                 if (spam_check == true)
                                 {
                                     ircbot.add_spam_count(channel);
                                 }
                                 if (nick_access >= command_access)
                                 {
                                     if (line.GetUpperBound(0) > 3)
                                     {
                                         int num_survey = 1;
                                         string[] new_line = line[4].Split(' ');
                                         try
                                         {
                                             num_survey = Convert.ToInt32(new_line[0]);
                                             del_survey_owner(num_survey - 1, nick, new_line[1].ToLower(), ircbot, conf);
                                         }
                                         catch
                                         {
                                             ircbot.sendData("NOTICE", nick + " :You need to choose a valid survey.  To view all surveys, please type " + conf.command + "surveys");
                                         }
                                     }
                                     else
                                     {
                                         ircbot.sendData("NOTICE", nick + " :You need to choose a valid survey.  To view all surveys, please type " + conf.command + "surveys");
                                     }
                                 }
                                 else
                                 {
                                     ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command.");
                                 }
                                 break;
                             case "addsurvey":
                                 if (spam_check == true)
                                 {
                                     ircbot.add_spam_count(channel);
                                 }
                                 if (nick_access >= command_access)
                                 {
                                     if (line.GetUpperBound(0) > 3)
                                     {
                                         char[] charSep = new char[] { ' ' };
                                         string[] new_line = line[4].Split(charSep, 2);
                                         if (new_line.GetUpperBound(0) > 0)
                                         {
                                             int survey_access = conf.user_level - 1;
                                             bool access_valid = true;
                                             try
                                             {
                                                 survey_access = Convert.ToInt32(new_line[0]);
                                             }
                                             catch
                                             {
                                                 access_valid = false;
                                                 ircbot.sendData("NOTICE", nick + " :Please choose a valid access level.");
                                             }
                                             if (access_valid == true)
                                             {
                                                 add_survey(nick, survey_access, new_line[1], ircbot, conf);
                                             }
                                             else
                                             {
                                                 ircbot.sendData("NOTICE", nick + " :Please include the survey access level and title for the survey.  Ex: " + conf.command + "addsurvey 1 Title of Survey");
                                             }
                                         }
                                         else
                                         {
                                             ircbot.sendData("NOTICE", nick + " :Please include the survey access level and title for the survey.  Ex: " + conf.command + "addsurvey 1 Title of Survey");
                                         }
                                     }
                                     else
                                     {
                                         ircbot.sendData("NOTICE", nick + " :Please include the survey access level and title for the survey.  Ex: " + conf.command + "addsurvey 1 Title of Survey");
                                     }
                                 }
                                 else
                                 {
                                     ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command.");
                                 }
                                 break;
                             case "delsurvey":
                                 if (spam_check == true)
                                 {
                                     ircbot.add_spam_count(channel);
                                 }
                                 if (nick_access >= command_access)
                                 {
                                     if (line.GetUpperBound(0) > 3)
                                     {
                                         int num_survey = 1;
                                         try
                                         {
                                             num_survey = Convert.ToInt32(line[4].Trim());
                                             del_survey(nick, num_survey - 1, ircbot, conf);
                                         }
                                         catch
                                         {
                                             ircbot.sendData("NOTICE", nick + " :You need to choose a valid survey.  To view all surveys, please type " + conf.command + "surveys");
                                         }
                                     }
                                     else
                                     {
                                         ircbot.sendData("NOTICE", nick + " :You need to choose a valid survey.  To view all surveys, please type " + conf.command + "surveys");
                                     }
                                 }
                                 else
                                 {
                                     ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command.");
                                 }
                                 break;
                         }
                     }
                 }
             }
         }
     }
     if (type.Equals("query") && bot_command == false)
     {
         foreach (survey_info survey in active_surveys)
         {
             if (nick.Equals(survey.nick))
             {
                 string answer = "";
                 if (line.GetUpperBound(0) > 3)
                 {
                     answer = line[3].Remove(0,1) + " " + line[4] + Environment.NewLine;
                 }
                 else
                 {
                     answer = line[3].Remove(0, 1) + Environment.NewLine;
                 }
                 if (survey.user_submission == true)
                 {
                     if (!Directory.Exists(ircbot.cur_dir + Path.DirectorySeparatorChar + "modules" + Path.DirectorySeparatorChar + "survey" + Path.DirectorySeparatorChar + "answers" + Path.DirectorySeparatorChar + survey.name + Path.DirectorySeparatorChar + survey.nick + Path.DirectorySeparatorChar + ""))
                     {
                         Directory.CreateDirectory(ircbot.cur_dir + Path.DirectorySeparatorChar + "modules" + Path.DirectorySeparatorChar + "survey" + Path.DirectorySeparatorChar + "answers" + Path.DirectorySeparatorChar + survey.name + Path.DirectorySeparatorChar + survey.nick + Path.DirectorySeparatorChar + "");
                     }
                     File.AppendAllText(ircbot.cur_dir + Path.DirectorySeparatorChar + "modules" + Path.DirectorySeparatorChar + "survey" + Path.DirectorySeparatorChar + "answers" + Path.DirectorySeparatorChar + survey.name + Path.DirectorySeparatorChar + survey.nick + " " + Path.DirectorySeparatorChar + survey.current_question + ".txt", answer);
                 }
                 else
                 {
                     if (!Directory.Exists(ircbot.cur_dir + Path.DirectorySeparatorChar + "modules" + Path.DirectorySeparatorChar + "survey" + Path.DirectorySeparatorChar + "surveys" + Path.DirectorySeparatorChar + ""))
                     {
                         Directory.CreateDirectory(ircbot.cur_dir + Path.DirectorySeparatorChar + "modules" + Path.DirectorySeparatorChar + "survey" + Path.DirectorySeparatorChar + "surveys" + Path.DirectorySeparatorChar + "");
                     }
                     File.AppendAllText(ircbot.cur_dir + Path.DirectorySeparatorChar + "modules" + Path.DirectorySeparatorChar + "survey" + Path.DirectorySeparatorChar + "surveys" + Path.DirectorySeparatorChar + survey.name + ".txt", answer);
                 }
                 break;
             }
         }
     }
 }
Esempio n. 32
0
        public override void control(bot ircbot, ref IRCConfig conf, int module_id, string[] line, string command, int nick_access, string nick, string channel, bool bot_command, string type)
        {
            access access = new access();

            char[] charS = new char[] { ' ' };
            string module_name = ircbot.conf.module_config[module_id][0];
            if ((type.Equals("channel") || type.Equals("query")) && bot_command == true)
            {
                foreach (List<string> tmp_command in conf.command_list)
                {
                    if (module_name.Equals(tmp_command[0]))
                    {
                        string[] triggers = tmp_command[3].Split('|');
                        int command_access = Convert.ToInt32(tmp_command[5]);
                        string[] blacklist = tmp_command[6].Split(',');
                        bool blocked = false;
                        bool cmd_found = false;
                        bool spam_check = Convert.ToBoolean(tmp_command[8]);
                        foreach (string bl_chan in blacklist)
                        {
                            if (bl_chan.Equals(channel))
                            {
                                blocked = true;
                                break;
                            }
                        }
                        if (spam_check == true)
                        {
                            blocked = ircbot.get_spam_status(channel, nick);
                        }
                        foreach (string trigger in triggers)
                        {
                            if (trigger.Equals(command))
                            {
                                cmd_found = true;
                                break;
                            }
                        }
                        if (blocked == true && cmd_found == true)
                        {
                            ircbot.sendData("NOTICE", nick + " :I am currently too busy to process that.");
                        }
                        if (blocked == false && cmd_found == true)
                        {
                            foreach (string trigger in triggers)
                            {
                                switch (trigger)
                                {
                                    case "alarm":
                                        if (spam_check == true)
                                        {
                                            ircbot.add_spam_count(channel);
                                        }
                                        if (nick_access >= command_access)
                                        {
                                            if (line.GetUpperBound(0) > 3)
                                            {
                                                string[] new_line = line[4].Split(charS, 2, StringSplitOptions.RemoveEmptyEntries);
                                                if (new_line.GetUpperBound(0) > 0)
                                                {
                                                    bool int_allowed = true;
                                                    int time = 0;
                                                    try
                                                    {
                                                        time = Convert.ToInt32(new_line[0]);
                                                        if ((time * 1000) <= 0)
                                                        {
                                                            int_allowed = false;
                                                        }
                                                    }
                                                    catch
                                                    {
                                                        int_allowed = false;
                                                    }
                                                    if (int_allowed == true)
                                                    {
                                                        char[] charSplit = new char[] { ' ' };
                                                        string[] ex = new_line[1].Split(charSplit);
                                                        if (ex[0].TrimStart(Convert.ToChar(conf.command)).Equals("alarm"))
                                                        {
                                                            if (type.Equals("channel"))
                                                            {
                                                                ircbot.sendData("PRIVMSG", line[2] + " :Recursion is bad.");
                                                            }
                                                            else
                                                            {
                                                                ircbot.sendData("PRIVMSG", nick + " :Recursion is bad.");
                                                            }
                                                        }
                                                        else
                                                        {
                                                            tmp_conf = conf;
                                                            Timer alarm_trigger = new Timer();
                                                            alarm_trigger.Interval = (time * 1000);
                                                            alarm_trigger.Enabled = true;
                                                            alarm_trigger.AutoReset = false;
                                                            alarm_trigger.Elapsed += (sender, e) => ring_alarm(sender, e, ircbot, nick, line[0], nick_access, channel, type, new_line[1]);
                                                            alarms.Add(alarm_trigger);

                                                            if (type.Equals("channel"))
                                                            {
                                                                ircbot.sendData("PRIVMSG", line[2] + " :Alarm added for " + new_line[0] + " seconds from now.");
                                                            }
                                                            else
                                                            {
                                                                ircbot.sendData("PRIVMSG", nick + " :Alarm added for " + new_line[0] + " seconds from now.");
                                                            }
                                                        }
                                                    }
                                                    else
                                                    {
                                                        if (type.Equals("channel"))
                                                        {
                                                            ircbot.sendData("PRIVMSG", line[2] + " :" + nick + ", please pick a valid time.");
                                                        }
                                                        else
                                                        {
                                                            ircbot.sendData("PRIVMSG", nick + " :" + nick + ", please pick a valid time.");
                                                        }
                                                    }
                                                }
                                                else
                                                {
                                                    if (type.Equals("channel"))
                                                    {
                                                        ircbot.sendData("PRIVMSG", line[2] + " :" + nick + ", you need to include more info.");
                                                    }
                                                    else
                                                    {
                                                        ircbot.sendData("PRIVMSG", nick + " :" + nick + ", you need to include more info.");
                                                    }
                                                }
                                            }
                                            else
                                            {
                                                if (type.Equals("channel"))
                                                {
                                                    ircbot.sendData("PRIVMSG", line[2] + " :" + nick + ", you need to include more info.");
                                                }
                                                else
                                                {
                                                    ircbot.sendData("PRIVMSG", nick + " :" + nick + ", you need to include more info.");
                                                }
                                            }
                                        }
                                        else
                                        {
                                            ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command.");
                                        }
                                        break;
                                }
                            }
                        }
                    }
                }
            }
        }
Esempio n. 33
0
        public override void control(bot ircbot, ref IRCConfig conf, int module_id, string[] line, string command, int nick_access, string nick, string channel, bool bot_command, string type)
        {
            string module_name = ircbot.conf.module_config[module_id][0];

            if (type.Equals("channel") && bot_command == true)
            {
                foreach (List <string> tmp_command in conf.command_list)
                {
                    if (module_name.Equals(tmp_command[0]))
                    {
                        string[] triggers       = tmp_command[3].Split('|');
                        int      command_access = Convert.ToInt32(tmp_command[5]);
                        string[] blacklist      = tmp_command[6].Split(',');
                        bool     blocked        = false;
                        bool     cmd_found      = false;
                        bool     spam_check     = Convert.ToBoolean(tmp_command[8]);
                        foreach (string bl_chan in blacklist)
                        {
                            if (bl_chan.Equals(channel))
                            {
                                blocked = true;
                                break;
                            }
                        }
                        if (spam_check == true)
                        {
                            blocked = ircbot.get_spam_status(channel, nick);
                        }
                        foreach (string trigger in triggers)
                        {
                            if (trigger.Equals(command))
                            {
                                cmd_found = true;
                                break;
                            }
                        }
                        if (blocked == true && cmd_found == true)
                        {
                            ircbot.sendData("NOTICE", nick + " :I am currently too busy to process that.");
                        }
                        if (blocked == false && cmd_found == true)
                        {
                            foreach (string trigger in triggers)
                            {
                                switch (trigger)
                                {
                                case "love":
                                    if (spam_check == true)
                                    {
                                        ircbot.add_spam_count(channel);
                                    }
                                    if (nick_access >= 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", 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 "hug":
                                    if (spam_check == true)
                                    {
                                        ircbot.add_spam_count(channel);
                                    }
                                    if (nick_access >= 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 >= 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 >= 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 >= 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 >= 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;
                                }
                            }
                        }
                    }
                }
            }
        }
Esempio n. 34
0
 public override void control(bot ircbot, ref IRCConfig conf, int module_id, string[] line, string command, int nick_access, string nick, string channel, bool bot_command, string type)
 {
     string module_name = ircbot.conf.module_config[module_id][0];
     if (type.Equals("channel") && bot_command == true)
     {
         foreach (List<string> tmp_command in conf.command_list)
         {
             if (module_name.Equals(tmp_command[0]))
             {
                 string[] triggers = tmp_command[3].Split('|');
                 int command_access = Convert.ToInt32(tmp_command[5]);
                 string[] blacklist = tmp_command[6].Split(',');
                 bool blocked = false;
                 bool cmd_found = false;
                 bool spam_check = Convert.ToBoolean(tmp_command[8]);
                 foreach (string bl_chan in blacklist)
                 {
                     if (bl_chan.Equals(channel))
                     {
                         blocked = true;
                         break;
                     }
                 }
                 if (spam_check == true)
                 {
                     blocked = ircbot.get_spam_status(channel, nick);
                 }
                 foreach (string trigger in triggers)
                 {
                     if (trigger.Equals(command))
                     {
                         cmd_found = true;
                         break;
                     }
                 }
                 if (blocked == true && cmd_found == true)
                 {
                     ircbot.sendData("NOTICE", nick + " :I am currently too busy to process that.");
                 }
                 if (blocked == false && cmd_found == true)
                 {
                     foreach (string trigger in triggers)
                     {
                         switch (trigger)
                         {
                             case "stopchat":
                                 if (spam_check == true)
                                 {
                                     ircbot.add_spam_count(channel);
                                 }
                                 if (nick_access >= command_access)
                                 {
                                     foreach (string chat_nick in chatting_nick)
                                     {
                                         if (chat_nick.Equals(nick))
                                         {
                                             still_chatting = false;
                                             chatting_nick.Clear();
                                             chat_time.Enabled = false;
                                             chat_time.Stop();
                                             ircbot.sendData("PRIVMSG", channel + " :Ok, I will stop.");
                                             break;
                                         }
                                     }
                                     if (still_chatting == true)
                                     {
                                         ircbot.sendData("PRIVMSG", channel + " :You are not currently talking to me.");
                                     }
                                 }
                                 else
                                 {
                                     ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command.");
                                 }
                                 break;
                         }
                     }
                 }
             }
         }
     }
     if (type.Equals("channel") && bot_command == false)
     {
         chat_time.Interval = Convert.ToInt32(conf.module_config[module_id][3]) * 1000;
         if (line.GetUpperBound(0) >= 3)
         {
             string msg = "";
             if (line.GetUpperBound(0) > 3)
             {
                 msg = line[3].TrimStart(':') + " " + line[4];
             }
             else
             {
                 msg = line[3].TrimStart(':');
             }
             string[] words = msg.Split(' ');
             bool me_in = false;
             foreach (string word in words)
             {
                 if (word.ToLower().Contains(conf.nick.ToLower()))
                 {
                     me_in = true;
                     break;
                 }
             }
             if (me_in == true || still_chatting == true)
             {
                 bool nick_found = false;
                 for (int x = 0; x < chatting_nick.Count(); x++)
                 {
                     if (chatting_nick[x].Equals(nick))
                     {
                         nick_found = true;
                     }
                 }
                 if (me_in == true && nick_found == false)
                 {
                     chatting_nick.Add(nick);
                     nick_found = true;
                 }
                 if (nick_found == true)
                 {
                     // Start Chatting
                     still_chatting = false;
                     chat_time.Stop();
                     Request r = new Request(msg, myUser, myBot);
                     Result res = myBot.Chat(r);
                     AboutBox1 about = new AboutBox1();
                     ircbot.sendData("PRIVMSG", channel + " :" + res.Output.Replace("[nick]", nick).Replace("[me]", conf.nick).Replace("[owner]", conf.owner.TrimStart(',').TrimEnd(',').Replace(",", " and ")).Replace("[version]", about.AssemblyVersion).Replace("\n", " "));
                     chat_time.Start();
                     still_chatting = true;
                 }
             }
         }
     }
 }
Esempio n. 35
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 "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;
                     }
                 }
             }
         }
     }
 }
Esempio n. 36
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 "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;
                            }
                        }
                    }
                }
            }
        }
Esempio n. 37
0
 public override void control(bot ircbot, ref IRCConfig conf, int module_id, string[] line, string command, int nick_access, string nick, string channel, bool bot_command, string type)
 {
     string module_name = ircbot.conf.module_config[module_id][0];
     if (type.Equals("channel") && bot_command == true)
     {
         foreach (List<string> tmp_command in conf.command_list)
         {
             if (module_name.Equals(tmp_command[0]))
             {
                 string[] triggers = tmp_command[3].Split('|');
                 int command_access = Convert.ToInt32(tmp_command[5]);
                 string[] blacklist = tmp_command[6].Split(',');
                 bool blocked = false;
                 bool cmd_found = false;
                 bool spam_check = Convert.ToBoolean(tmp_command[8]);
                 foreach (string bl_chan in blacklist)
                 {
                     if (bl_chan.Equals(channel))
                     {
                         blocked = true;
                         break;
                     }
                 }
                 if (spam_check == true)
                 {
                     blocked = ircbot.get_spam_status(channel, nick);
                 }
                 foreach (string trigger in triggers)
                 {
                     if (trigger.Equals(command))
                     {
                         cmd_found = true;
                         break;
                     }
                 }
                 if (blocked == true && cmd_found == true)
                 {
                     ircbot.sendData("NOTICE", nick + " :I am currently too busy to process that.");
                 }
                 if (blocked == false && cmd_found == true)
                 {
                     foreach (string trigger in triggers)
                     {
                         switch (trigger)
                         {
                             case "ud":
                                 if (spam_check == true)
                                 {
                                     ircbot.add_spam_count(channel);
                                 }
                                 if (nick_access >= command_access)
                                 {
                                     if (line.GetUpperBound(0) > 3)
                                     {
                                         // Get Urban Dictionary Info
                                         get_ud(line[4], line[2], ircbot, conf, module_id);
                                     }
                                     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;
                         }
                     }
                 }
             }
         }
     }
 }
Esempio n. 38
0
 public override void control(bot ircbot, ref IRCConfig conf, int module_id, string[] line, string command, int nick_access, string nick, string channel, bool bot_command, string type)
 {
     char[] charS = new char[] { ' ' };
     string module_name = ircbot.conf.module_config[module_id][0];
     if ((type.Equals("channel") || type.Equals("query")) && bot_command == true)
     {
         foreach (List<string> tmp_command in conf.command_list)
         {
             if (module_name.Equals(tmp_command[0]))
             {
                 string[] triggers = tmp_command[3].Split('|');
                 int command_access = Convert.ToInt32(tmp_command[5]);
                 string[] blacklist = tmp_command[6].Split(',');
                 bool blocked = false;
                 bool cmd_found = false;
                 bool spam_check = Convert.ToBoolean(tmp_command[8]);
                 foreach (string bl_chan in blacklist)
                 {
                     if (bl_chan.Equals(channel))
                     {
                         blocked = true;
                         break;
                     }
                 }
                 if (spam_check == true)
                 {
                     blocked = ircbot.get_spam_status(channel, nick);
                 }
                 foreach (string trigger in triggers)
                 {
                     if (trigger.Equals(command))
                     {
                         cmd_found = true;
                         break;
                     }
                 }
                 if (blocked == true && cmd_found == true)
                 {
                     ircbot.sendData("NOTICE", nick + " :I am currently too busy to process that.");
                 }
                 if (blocked == false && cmd_found == true)
                 {
                     foreach (string trigger in triggers)
                     {
                         switch (trigger)
                         {
                             case "bug":
                                 if (spam_check == true)
                                 {
                                     ircbot.add_spam_count(channel);
                                 }
                                 if (nick_access >= 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/" + ircbot.conf.module_config[module_id][3] + "/" + ircbot.conf.module_config[module_id][5] + "/issues";
                                         string response = post_issue(ircbot, module_id, uri, title, description, ircbot.conf.module_config[module_id][3], label);
                                         if (response.Equals(""))
                                         {
                                             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 >= 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/" + ircbot.conf.module_config[module_id][3] + "/" + ircbot.conf.module_config[module_id][5] + "/issues";
                                         string response = post_issue(ircbot, module_id, uri, title, description, ircbot.conf.module_config[module_id][3], label);
                                         if (response.Equals(""))
                                         {
                                             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;
                         }
                     }
                 }
             }
         }
     }
 }
Esempio n. 39
0
 public override void control(bot ircbot, ref IRCConfig conf, int module_id, string[] line, string command, int nick_access, string nick, string channel, bool bot_command, string type)
 {
     string module_name = ircbot.conf.module_config[module_id][0];
     if ((type.Equals("channel") || type.Equals("query")) && bot_command == true)
     {
         foreach (List<string> tmp_command in conf.command_list)
         {
             if (module_name.Equals(tmp_command[0]))
             {
                 string[] triggers = tmp_command[3].Split('|');
                 int command_access = Convert.ToInt32(tmp_command[5]);
                 string[] blacklist = tmp_command[6].Split(',');
                 bool blocked = false;
                 bool cmd_found = false;
                 bool spam_check = Convert.ToBoolean(tmp_command[8]);
                 foreach (string bl_chan in blacklist)
                 {
                     if (bl_chan.Equals(channel))
                     {
                         blocked = true;
                         break;
                     }
                 }
                 if (spam_check == true)
                 {
                     blocked = ircbot.get_spam_status(channel, nick);
                 }
                 foreach (string trigger in triggers)
                 {
                     if (trigger.Equals(command))
                     {
                         cmd_found = true;
                         break;
                     }
                 }
                 if (blocked == true && cmd_found == true)
                 {
                     ircbot.sendData("NOTICE", nick + " :I am currently too busy to process that.");
                 }
                 if (blocked == false && cmd_found == true)
                 {
                     foreach (string trigger in triggers)
                     {
                         switch (trigger)
                         {
                             case "last":
                                 if (spam_check == true)
                                 {
                                     ircbot.add_spam_count(channel);
                                 }
                                 if (nick_access >= 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 (List<string> tmp_command in conf.command_list)
         {
             string[] triggers = tmp_command[3].Split('|');
             foreach (string trigger in triggers)
             {
                 if (command.Equals(trigger))
                 {
                     command_valid = true;
                     break;
                 }
             }
             if (command_valid == true)
             {
                 break;
             }
         }
         if (command_valid == true)
         {
             add_log(nick, "a private message", line, ircbot);
         }
     }
     if (type.Equals("channel") && bot_command == true)
     {
         bool command_valid = false;
         foreach (List<string> tmp_command in conf.command_list)
         {
             string[] triggers = tmp_command[3].Split('|');
             foreach (string trigger in triggers)
             {
                 if (command.Equals(trigger))
                 {
                     command_valid = true;
                     break;
                 }
             }
             if (command_valid == true)
             {
                 break;
             }
         }
         if (command_valid == true)
         {
             add_log(nick, channel, line, ircbot);
         }
     }
 }
Esempio n. 40
0
        public override void control(bot ircbot, ref IRCConfig conf, int module_id, string[] line, string command, int nick_access, string nick, string channel, bool bot_command, string type)
        {
            string module_name = ircbot.conf.module_config[module_id][0];

            if (type.Equals("channel") && bot_command == true)
            {
                foreach (List <string> tmp_command in conf.command_list)
                {
                    if (module_name.Equals(tmp_command[0]))
                    {
                        string[] triggers       = tmp_command[3].Split('|');
                        int      command_access = Convert.ToInt32(tmp_command[5]);
                        string[] blacklist      = tmp_command[6].Split(',');
                        bool     blocked        = false;
                        bool     cmd_found      = false;
                        bool     spam_check     = Convert.ToBoolean(tmp_command[8]);
                        foreach (string bl_chan in blacklist)
                        {
                            if (bl_chan.Equals(channel))
                            {
                                blocked = true;
                                break;
                            }
                        }
                        if (spam_check == true)
                        {
                            blocked = ircbot.get_spam_status(channel, nick);
                        }
                        foreach (string trigger in triggers)
                        {
                            if (trigger.Equals(command))
                            {
                                cmd_found = true;
                                break;
                            }
                        }
                        if (blocked == true && cmd_found == true)
                        {
                            ircbot.sendData("NOTICE", nick + " :I am currently too busy to process that.");
                        }
                        if (blocked == false && cmd_found == true)
                        {
                            foreach (string trigger in triggers)
                            {
                                switch (trigger)
                                {
                                case "quote":
                                    if (spam_check == true)
                                    {
                                        ircbot.add_spam_count(channel);
                                    }
                                    if (nick_access >= command_access)
                                    {
                                        if (conf.module_config[module_id][3].Equals("True"))
                                        {
                                            if (line.GetUpperBound(0) > 3)
                                            {
                                                get_specific_quote(line[2], line[4].ToLower(), ircbot, conf);
                                            }
                                            else
                                            {
                                                get_quote(line[2], ircbot, conf);
                                            }
                                        }
                                        else
                                        {
                                            get_quote(line[2], 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 != conf.nick)
            {
                add_quote(nick, channel, line, ircbot, conf);
            }
        }
Esempio n. 41
0
        public override void control(bot ircbot, ref IRCConfig conf, int module_id, string[] line, string command, int nick_access, string nick, string channel, bool bot_command, string type)
        {
            string module_name = ircbot.conf.module_config[module_id][0];
            if (type.Equals("channel") && bot_command == true)
            {
                foreach (List<string> tmp_command in conf.command_list)
                {
                    if (module_name.Equals(tmp_command[0]))
                    {
                        string[] triggers = tmp_command[3].Split('|');
                        int command_access = Convert.ToInt32(tmp_command[5]);
                        string[] blacklist = tmp_command[6].Split(',');
                        bool blocked = false;
                        bool cmd_found = false;
                        bool spam_check = Convert.ToBoolean(tmp_command[8]);
                        foreach (string bl_chan in blacklist)
                        {
                            if (bl_chan.Equals(channel))
                            {
                                blocked = true;
                                break;
                            }
                        }
                        if (spam_check == true)
                        {
                            blocked = ircbot.get_spam_status(channel, nick);
                        }
                        foreach (string trigger in triggers)
                        {
                            if (trigger.Equals(command))
                            {
                                cmd_found = true;
                                break;
                            }
                        }
                        if (blocked == true && cmd_found == true)
                        {
                            ircbot.sendData("NOTICE", nick + " :I am currently too busy to process that.");
                        }
                        if (blocked == false && cmd_found == true)
                        {
                            foreach (string trigger in triggers)
                            {
                                switch (trigger)
                                {
                                    case "hbomb":
                                        if (spam_check == true)
                                        {
                                            ircbot.add_spam_count(channel);
                                        }
                                        if (nick_access >= command_access)
                                        {
                                            int module_index = 0;
                                            foreach (Modules.Module module in ircbot.module_list)
                                            {
                                                string module_type = module.GetType().ToString();
                                                if (module_type.Equals("IRCBot.Modules.idle"))
                                                {
                                                    break;
                                                }
                                                else
                                                {
                                                    module_index++;
                                                }
                                            }
                                            Modules.idle idle;
                                            if (module_index < ircbot.module_list.Count())
                                            {
                                                idle = (Modules.idle)ircbot.module_list[module_index];
                                            }
                                            else
                                            {
                                                idle = new Modules.idle();
                                            }
                                            if (idle.check_idle(nick) == false)
                                            {
                                                bool hbomb_active = false;
                                                hbomb_info tmp_info = new hbomb_info();
                                                foreach (hbomb_info bomb in hbombs)
                                                {
                                                    if (bomb.bomb_channel.Equals(channel))
                                                    {
                                                        tmp_info = bomb;
                                                        hbomb_active = true;
                                                        break;
                                                    }
                                                }
                                                if (hbomb_active == false)
                                                {
                                                    tmp_info.bomb_locked = false;
                                                    tmp_info.bomb_trigger = new System.Timers.Timer();
                                                    tmp_info.wire_colors = ircbot.conf.module_config[module_id][3].Split(',');
                                                    tmp_info.bomb_channel = channel;

                                                    Random random_color = new Random();
                                                    int color_index = random_color.Next(0, tmp_info.wire_colors.GetUpperBound(0) + 1);
                                                    tmp_info.wire_color = tmp_info.wire_colors[color_index];

                                                    Random random = new Random();
                                                    int index = random.Next(10, 60);

                                                    tmp_info.bomb_trigger.Elapsed += (System, EventArgs) => activate_bomb(channel);
                                                    tmp_info.bomb_trigger.Interval = (index * 1000);
                                                    tmp_info.bomb_trigger.Enabled = true;
                                                    tmp_info.bomb_trigger.AutoReset = false;

                                                    main = ircbot;

                                                    tmp_info.previous_bomb_holder = nick;
                                                    tmp_info.bomb_holder = nick;

                                                    ircbot.sendData("PRIVMSG", channel + " :" + nick + " has started the timer!  If the bomb gets passed to you, type " + conf.command + "pass <nick> to pass it to someone else, or type " + conf.command + "defuse <color> to try to defuse it.");
                                                    string colors = "";
                                                    foreach (string wire in tmp_info.wire_colors)
                                                    {
                                                        colors += wire + ",";
                                                    }
                                                    ircbot.sendData("NOTICE", nick + " :You need to hurry and pass the bomb before it blows up!  Or you can try to defuse it yourself.  The colors are: " + colors.TrimEnd(','));
                                                    hbombs.Add(tmp_info);
                                                }
                                                else
                                                {
                                                    if (tmp_info.bomb_channel.Equals(channel))
                                                    {
                                                        ircbot.sendData("PRIVMSG", channel + " :There is already a bomb counting down.");
                                                    }
                                                    else
                                                    {
                                                        ircbot.sendData("PRIVMSG", line[2] + " :There is already a bomb counting down in " + tmp_info.bomb_channel + ".");
                                                    }
                                                }
                                            }
                                            else
                                            {
                                                ircbot.sendData("PRIVMSG", channel + " :You can not start a HBomb when you are idle.");
                                            }
                                        }
                                        else
                                        {
                                            ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command.");
                                        }
                                        break;
                                    case "pass":
                                        if (spam_check == true)
                                        {
                                            ircbot.add_spam_count(channel);
                                        }
                                        if (nick_access >= command_access)
                                        {
                                            int index = 0;
                                            bool hbomb_active = false;
                                            hbomb_info tmp_info = new hbomb_info();
                                            foreach (hbomb_info bomb in hbombs)
                                            {
                                                if (bomb.bomb_channel.Equals(channel))
                                                {
                                                    tmp_info = bomb;
                                                    hbomb_active = true;
                                                    break;
                                                }
                                                index++;
                                            }
                                            if (hbomb_active == true)
                                            {
                                                if (!tmp_info.bomb_locked)
                                                {
                                                    int module_index = 0;
                                                    foreach (Modules.Module module in ircbot.module_list)
                                                    {
                                                        string module_type = module.GetType().ToString();
                                                        if (module_type.Equals("IRCBot.Modules.idle"))
                                                        {
                                                            break;
                                                        }
                                                        else
                                                        {
                                                            module_index++;
                                                        }
                                                    }
                                                    Modules.idle idle;
                                                    if (module_index < ircbot.module_list.Count())
                                                    {
                                                        idle = (Modules.idle)ircbot.module_list[module_index];
                                                    }
                                                    else
                                                    {
                                                        idle = new Modules.idle();
                                                    }
                                                    if (idle.check_idle(nick) == false)
                                                    {
                                                        if (tmp_info.bomb_holder.Equals(nick))
                                                        {
                                                            if (line.GetUpperBound(0) > 3)
                                                            {
                                                                if (line[4].TrimEnd(' ').ToLower().Equals(conf.nick.ToLower()))
                                                                {
                                                                    ircbot.sendData("PRIVMSG", channel + " :" + nick + ", you can't pass it to me!");
                                                                }
                                                                else
                                                                {
                                                                    int user_access = ircbot.get_user_access(line[4].TrimEnd(' ').ToLower(), channel);
                                                                    if (user_access > 0 && idle.check_idle(line[4].TrimEnd(' ').ToLower()) == false)
                                                                    {
                                                                        pass_hbomb(line[4].TrimEnd(' ').ToLower(), channel, nick, ircbot, conf, ref tmp_info, index);
                                                                    }
                                                                    else
                                                                    {
                                                                        ircbot.sendData("PRIVMSG", channel + " :" + nick + ", you can't pass to them!");
                                                                    }
                                                                }
                                                            }
                                                            else
                                                            {
                                                                ircbot.sendData("PRIVMSG", channel + " :" + nick + ", you need to pass the bomb to someone.");
                                                            }
                                                        }
                                                        else
                                                        {
                                                            ircbot.sendData("PRIVMSG", channel + " :You don't have the bomb!");
                                                        }
                                                    }
                                                    else
                                                    {
                                                        ircbot.sendData("PRIVMSG", channel + " :You can not pass the HBomb when you are idle.");
                                                    }
                                                }
                                                else
                                                {
                                                    ircbot.sendData("PRIVMSG", channel + " :You can not pass a locked bomb.");
                                                }
                                            }
                                            else
                                            {
                                                ircbot.sendData("PRIVMSG", channel + " :There isn't a bomb to pass!");
                                            }
                                        }
                                        else
                                        {
                                            ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command.");
                                        }
                                        break;
                                    case "set_bomb":
                                        if (spam_check == true)
                                        {
                                            ircbot.add_spam_count(channel);
                                        }
                                        if (nick_access >= command_access)
                                        {
                                            int index = 0;
                                            bool hbomb_active = false;
                                            hbomb_info tmp_info = new hbomb_info();
                                            foreach (hbomb_info bomb in hbombs)
                                            {
                                                if (bomb.bomb_channel.Equals(channel))
                                                {
                                                    tmp_info = bomb;
                                                    hbomb_active = true;
                                                    break;
                                                }
                                                index++;
                                            }
                                            if (hbomb_active == true)
                                            {
                                                if (line.GetUpperBound(0) > 3)
                                                {
                                                    if (line[4].TrimEnd(' ').ToLower().Equals(conf.nick.ToLower()))
                                                    {
                                                        ircbot.sendData("PRIVMSG", channel + " :" + nick + ", you can't pass it to me!");
                                                    }
                                                    else
                                                    {
                                                        int user_access = ircbot.get_user_access(line[4].TrimEnd(' ').ToLower(), channel);
                                                        if (user_access > 0)
                                                        {
                                                            pass_hbomb(line[4].TrimEnd(' ').ToLower(), channel, nick, ircbot, conf, ref tmp_info, index);
                                                        }
                                                        else
                                                        {
                                                            ircbot.sendData("PRIVMSG", channel + " :" + nick + ", that user isn't online!");
                                                        }
                                                    }
                                                }
                                                else
                                                {
                                                    ircbot.sendData("PRIVMSG", channel + " :" + nick + ", you need to pass the bomb to someone.");
                                                }

                                            }
                                            else
                                            {
                                                ircbot.sendData("PRIVMSG", channel + " :There isn't a bomb to pass!");
                                            }
                                        }
                                        else
                                        {
                                            ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command.");
                                        }
                                        break;
                                    case "lock_bomb":
                                        if (spam_check == true)
                                        {
                                            ircbot.add_spam_count(channel);
                                        }
                                        if (nick_access >= command_access)
                                        {
                                            int index = 0;
                                            bool hbomb_active = false;
                                            hbomb_info tmp_info = new hbomb_info();
                                            foreach (hbomb_info bomb in hbombs)
                                            {
                                                if (bomb.bomb_channel.Equals(channel))
                                                {
                                                    tmp_info = bomb;
                                                    hbomb_active = true;
                                                    break;
                                                }
                                                index++;
                                            }
                                            if (hbomb_active == true)
                                            {
                                                if (line.GetUpperBound(0) > 3)
                                                {
                                                    if (line[4].TrimEnd(' ').ToLower().Equals(conf.nick.ToLower()))
                                                    {
                                                        ircbot.sendData("PRIVMSG", channel + " :" + nick + ", you can't pass it to me!");
                                                    }
                                                    else
                                                    {
                                                        int user_access = ircbot.get_user_access(line[4].TrimEnd(' ').ToLower(), channel);
                                                        if (user_access > 0)
                                                        {
                                                            pass_hbomb(line[4].TrimEnd(' ').ToLower(), channel, nick, ircbot, conf, ref tmp_info, index);
                                                            tmp_info.bomb_locked = true;
                                                        }
                                                        else
                                                        {
                                                            ircbot.sendData("PRIVMSG", channel + " :" + nick + ", that user isn't online!");
                                                        }
                                                    }
                                                }
                                                else
                                                {
                                                    tmp_info.bomb_locked = true;
                                                }

                                            }
                                            else
                                            {
                                                ircbot.sendData("PRIVMSG", channel + " :There isn't a bomb to lock!");
                                            }
                                        }
                                        else
                                        {
                                            ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command.");
                                        }
                                        break;
                                    case "unlock_bomb":
                                        if (spam_check == true)
                                        {
                                            ircbot.add_spam_count(channel);
                                        }
                                        if (nick_access >= command_access)
                                        {
                                            int index = 0;
                                            bool hbomb_active = false;
                                            hbomb_info tmp_info = new hbomb_info();
                                            foreach (hbomb_info bomb in hbombs)
                                            {
                                                if (bomb.bomb_channel.Equals(channel))
                                                {
                                                    tmp_info = bomb;
                                                    hbomb_active = true;
                                                    break;
                                                }
                                                index++;
                                            }
                                            if (hbomb_active == true)
                                            {
                                                tmp_info.bomb_locked = false;
                                                hbombs[index] = tmp_info;
                                            }
                                            else
                                            {
                                                ircbot.sendData("PRIVMSG", channel + " :There isn't a bomb to unlock!");
                                            }
                                        }
                                        else
                                        {
                                            ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command.");
                                        }
                                        break;
                                    case "detonate":
                                        if (spam_check == true)
                                        {
                                            ircbot.add_spam_count(channel);
                                        }
                                        if (nick_access >= command_access)
                                        {
                                            bool hbomb_active = false;
                                            foreach (hbomb_info bomb in hbombs)
                                            {
                                                if (bomb.bomb_channel.Equals(channel))
                                                {
                                                    hbomb_active = true;
                                                    break;
                                                }
                                            }
                                            if (hbomb_active == true)
                                            {
                                                main = ircbot;
                                                activate_bomb(channel);
                                            }
                                            else
                                            {
                                                ircbot.sendData("PRIVMSG", channel + " :There isn't a bomb to blow up!");
                                            }
                                        }
                                        else
                                        {
                                            ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command.");
                                        }
                                        break;
                                    case "stop_bomb":
                                        if (spam_check == true)
                                        {
                                            ircbot.add_spam_count(channel);
                                        }
                                        if (nick_access >= command_access)
                                        {
                                            int index = 0;
                                            bool hbomb_active = false;
                                            hbomb_info tmp_info = new hbomb_info();
                                            foreach (hbomb_info bomb in hbombs)
                                            {
                                                if (bomb.bomb_channel.Equals(channel))
                                                {
                                                    tmp_info = bomb;
                                                    hbomb_active = true;
                                                    break;
                                                }
                                                index++;
                                            }
                                            if (hbomb_active == true)
                                            {
                                                hbombs.RemoveAt(index);
                                                ircbot.sendData("PRIVMSG", channel + " :Bomb has been defused and thrown away.");
                                            }
                                            else
                                            {
                                                ircbot.sendData("PRIVMSG", channel + " :There isn't a bomb to stop!");
                                            }
                                        }
                                        else
                                        {
                                            ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command.");
                                        }
                                        break;
                                    case "defuse":
                                        if (spam_check == true)
                                        {
                                            ircbot.add_spam_count(channel);
                                        }
                                        if (nick_access >= command_access)
                                        {
                                            int index = 0;
                                            bool hbomb_active = false;
                                            hbomb_info tmp_info = new hbomb_info();
                                            foreach (hbomb_info bomb in hbombs)
                                            {
                                                if (bomb.bomb_channel.Equals(channel))
                                                {
                                                    tmp_info = bomb;
                                                    hbomb_active = true;
                                                    break;
                                                }
                                                index++;
                                            }
                                            if (hbomb_active == true)
                                            {
                                                if (!tmp_info.bomb_locked)
                                                {
                                                    int module_index = 0;
                                                    foreach (Modules.Module module in ircbot.module_list)
                                                    {
                                                        string module_type = module.GetType().ToString();
                                                        if (module_type.Equals("IRCBot.Modules.idle"))
                                                        {
                                                            break;
                                                        }
                                                        else
                                                        {
                                                            module_index++;
                                                        }
                                                    }
                                                    Modules.idle idle;
                                                    if (module_index < ircbot.module_list.Count())
                                                    {
                                                        idle = (Modules.idle)ircbot.module_list[module_index];
                                                    }
                                                    else
                                                    {
                                                        idle = new Modules.idle();
                                                    }
                                                    if (idle.check_idle(nick) == false)
                                                    {
                                                        if (tmp_info.bomb_holder.Equals(nick))
                                                        {
                                                            if (line.GetUpperBound(0) > 3)
                                                            {
                                                                if (line[4].ToLower().Equals(tmp_info.wire_color.ToLower()))
                                                                {
                                                                    ircbot.sendData("PRIVMSG", channel + " :You have successfully defused the bomb!");
                                                                    if (tmp_info.previous_bomb_holder.Equals(tmp_info.bomb_holder))
                                                                    {
                                                                    }
                                                                    else
                                                                    {
                                                                        ircbot.sendData("KICK", tmp_info.bomb_channel + " " + tmp_info.previous_bomb_holder + " :BOOM!!!");
                                                                    }
                                                                    hbombs.RemoveAt(index);
                                                                }
                                                                else
                                                                {
                                                                    main = ircbot;
                                                                    activate_bomb(channel);
                                                                }
                                                            }
                                                            else
                                                            {
                                                                ircbot.sendData("PRIVMSG", channel + " :" + nick + ", you need to cut a wire.");
                                                            }
                                                        }
                                                        else
                                                        {
                                                            ircbot.sendData("PRIVMSG", channel + " :You don't have the bomb!");
                                                        }
                                                    }
                                                    else
                                                    {
                                                        ircbot.sendData("PRIVMSG", channel + " :You can not defuse the HBomb when you are idle.");
                                                    }
                                                }
                                                else
                                                {
                                                    ircbot.sendData("PRIVMSG", channel + " :You can not defuse the HBomb when it is locked.");
                                                }
                                            }
                                            else
                                            {
                                                ircbot.sendData("PRIVMSG", channel + " :There isn't a bomb to defuse!");
                                            }
                                        }
                                        else
                                        {
                                            ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command.");
                                        }
                                        break;
                                }
                            }
                        }
                    }
                }
            }
        }
Esempio n. 42
0
        public override void control(bot ircbot, ref IRCConfig conf, int module_id, string[] line, string command, int nick_access, string nick, string channel, bool bot_command, string type)
        {
            string module_name = ircbot.conf.module_config[module_id][0];

            if (type.Equals("channel") && bot_command == true)
            {
                foreach (List <string> tmp_command in conf.command_list)
                {
                    if (module_name.Equals(tmp_command[0]))
                    {
                        string[] triggers       = tmp_command[3].Split('|');
                        int      command_access = Convert.ToInt32(tmp_command[5]);
                        string[] blacklist      = tmp_command[6].Split(',');
                        bool     blocked        = false;
                        bool     cmd_found      = false;
                        bool     spam_check     = Convert.ToBoolean(tmp_command[8]);
                        foreach (string bl_chan in blacklist)
                        {
                            if (bl_chan.Equals(channel))
                            {
                                blocked = true;
                                break;
                            }
                        }
                        if (spam_check == true)
                        {
                            blocked = ircbot.get_spam_status(channel, nick);
                        }
                        foreach (string trigger in triggers)
                        {
                            if (trigger.Equals(command))
                            {
                                cmd_found = true;
                                break;
                            }
                        }
                        if (blocked == true && cmd_found == true)
                        {
                            ircbot.sendData("NOTICE", nick + " :I am currently too busy to process that.");
                        }
                        if (blocked == false && cmd_found == true)
                        {
                            foreach (string trigger in triggers)
                            {
                                switch (trigger)
                                {
                                case "isitup":
                                    if (spam_check == true)
                                    {
                                        ircbot.add_spam_count(channel);
                                    }
                                    if (nick_access >= command_access)
                                    {
                                        if (line.GetUpperBound(0) > 3)
                                        {
                                            bool isitup = CheckConnection(line[4]);
                                            if (isitup)
                                            {
                                                ircbot.sendData("PRIVMSG", channel + " :" + line[4] + " is up for me!");
                                            }
                                            else
                                            {
                                                ircbot.sendData("PRIVMSG", channel + " :" + line[4] + " looks down for me too.");
                                            }
                                        }
                                        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;
                                }
                            }
                        }
                    }
                }
            }
        }
Esempio n. 43
0
        public override void control(bot ircbot, ref IRCConfig conf, int module_id, string[] line, string command, int nick_access, string nick, string channel, bool bot_command, string type)
        {
            string module_name = ircbot.conf.module_config[module_id][0];

            if (type.Equals("channel") && bot_command == true)
            {
                foreach (List <string> tmp_command in conf.command_list)
                {
                    if (module_name.Equals(tmp_command[0]))
                    {
                        string[] triggers       = tmp_command[3].Split('|');
                        int      command_access = Convert.ToInt32(tmp_command[5]);
                        string[] blacklist      = tmp_command[6].Split(',');
                        bool     blocked        = false;
                        bool     cmd_found      = false;
                        bool     spam_check     = Convert.ToBoolean(tmp_command[8]);
                        foreach (string bl_chan in blacklist)
                        {
                            if (bl_chan.Equals(channel))
                            {
                                blocked = true;
                                break;
                            }
                        }
                        if (spam_check == true)
                        {
                            blocked = ircbot.get_spam_status(channel, nick);
                        }
                        foreach (string trigger in triggers)
                        {
                            if (trigger.Equals(command))
                            {
                                cmd_found = true;
                                break;
                            }
                        }
                        if (blocked == true && cmd_found == true)
                        {
                            ircbot.sendData("NOTICE", nick + " :I am currently too busy to process that.");
                        }
                        if (blocked == false && cmd_found == true)
                        {
                            foreach (string trigger in triggers)
                            {
                                switch (trigger)
                                {
                                case "pingme":
                                    if (spam_check == true)
                                    {
                                        ircbot.add_spam_count(channel);
                                    }
                                    if (nick_access >= command_access)
                                    {
                                        int epoch = (int)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds;
                                        ircbot.sendData("PRIVMSG", nick + " :\u0001PING " + epoch.ToString() + "\u0001");
                                        List <string> tmp_list     = new List <string>();
                                        string        current_time = DateTime.Now.ToLongTimeString();
                                        tmp_list.Add(nick);
                                        tmp_list.Add(channel);
                                        tmp_list.Add(current_time);
                                        ping_list.Add(tmp_list);
                                    }
                                    else
                                    {
                                        ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command.");
                                    }
                                    break;
                                }
                            }
                        }
                    }
                }
            }
            if (type.Equals("line") || type.Equals("query"))
            {
                check_ping(line, ircbot, nick);
            }
        }
Esempio n. 44
0
        public override void control(bot ircbot, ref IRCConfig conf, int module_id, string[] line, string command, int nick_access, string nick, string channel, bool bot_command, string type)
        {
            string module_name = ircbot.conf.module_config[module_id][0];

            if (type.Equals("channel") && bot_command == true)
            {
                foreach (List <string> tmp_command in conf.command_list)
                {
                    if (module_name.Equals(tmp_command[0]))
                    {
                        string[] triggers       = tmp_command[3].Split('|');
                        int      command_access = Convert.ToInt32(tmp_command[5]);
                        string[] blacklist      = tmp_command[6].Split(',');
                        bool     blocked        = false;
                        bool     cmd_found      = false;
                        bool     spam_check     = Convert.ToBoolean(tmp_command[8]);
                        foreach (string bl_chan in blacklist)
                        {
                            if (bl_chan.Equals(channel))
                            {
                                blocked = true;
                                break;
                            }
                        }
                        if (spam_check == true)
                        {
                            blocked = ircbot.get_spam_status(channel, nick);
                        }
                        foreach (string trigger in triggers)
                        {
                            if (trigger.Equals(command))
                            {
                                cmd_found = true;
                                break;
                            }
                        }
                        if (blocked == true && cmd_found == true)
                        {
                            ircbot.sendData("NOTICE", nick + " :I am currently too busy to process that.");
                        }
                        if (blocked == false && cmd_found == true)
                        {
                            foreach (string trigger in triggers)
                            {
                                switch (trigger)
                                {
                                case "google":
                                    if (spam_check == true)
                                    {
                                        ircbot.add_spam_count(channel);
                                    }
                                    if (nick_access >= command_access)
                                    {
                                        if (line.GetUpperBound(0) > 3)
                                        {
                                            if (line[4].StartsWith("DCC SEND"))
                                            {
                                                ircbot.sendData("PRIVMSG", line[2] + " :Invalid Search Term");
                                            }
                                            else
                                            {
                                                ISearchResult searchClass = new GoogleSearch(line[4]);
                                                try
                                                {
                                                    var list = searchClass.Search();
                                                    if (list.Count > 0)
                                                    {
                                                        foreach (var searchType in list)
                                                        {
                                                            ircbot.sendData("PRIVMSG", line[2] + " :" + searchType.title.Replace("<b>", "").Replace("</b>", "").Replace("&quot;", "\"").Replace("&#39", "'").Replace("&amp;", "&") + ": " + searchType.content.Replace("<b>", "").Replace("</b>", "").Replace("&quot;", "\"").Replace("&#39", "'").Replace("&amp;", "&"));

                                                            if (conf.module_config[module_id][3].Equals("True"))
                                                            {
                                                                ircbot.sendData("PRIVMSG", line[2] + " :" + searchType.url);
                                                            }
                                                            break;
                                                        }
                                                    }
                                                    else
                                                    {
                                                        ircbot.sendData("PRIVMSG", line[2] + " :No Results Found");
                                                    }
                                                }
                                                catch
                                                {
                                                    ircbot.sendData("PRIVMSG", line[2] + " :I can't search atm.");
                                                }
                                            }
                                        }
                                        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;
                                }
                            }
                        }
                    }
                }
            }
        }
Esempio n. 45
0
        public override void control(bot ircbot, ref IRCConfig conf, int module_id, string[] line, string command, int nick_access, string nick, string channel, bool bot_command, string type)
        {
            access access = new access();

            char[] charS       = new char[] { ' ' };
            string module_name = ircbot.conf.module_config[module_id][0];

            if ((type.Equals("channel") || type.Equals("query")) && bot_command == true)
            {
                foreach (List <string> tmp_command in conf.command_list)
                {
                    if (module_name.Equals(tmp_command[0]))
                    {
                        string[] triggers       = tmp_command[3].Split('|');
                        int      command_access = Convert.ToInt32(tmp_command[5]);
                        string[] blacklist      = tmp_command[6].Split(',');
                        bool     blocked        = false;
                        bool     cmd_found      = false;
                        bool     spam_check     = Convert.ToBoolean(tmp_command[8]);
                        foreach (string bl_chan in blacklist)
                        {
                            if (bl_chan.Equals(channel))
                            {
                                blocked = true;
                                break;
                            }
                        }
                        if (spam_check == true)
                        {
                            blocked = ircbot.get_spam_status(channel, nick);
                        }
                        foreach (string trigger in triggers)
                        {
                            if (trigger.Equals(command))
                            {
                                cmd_found = true;
                                break;
                            }
                        }
                        if (blocked == true && cmd_found == true)
                        {
                            ircbot.sendData("NOTICE", nick + " :I am currently too busy to process that.");
                        }
                        if (blocked == false && cmd_found == true)
                        {
                            foreach (string trigger in triggers)
                            {
                                switch (trigger)
                                {
                                case "alarm":
                                    if (spam_check == true)
                                    {
                                        ircbot.add_spam_count(channel);
                                    }
                                    if (nick_access >= command_access)
                                    {
                                        if (line.GetUpperBound(0) > 3)
                                        {
                                            string[] new_line = line[4].Split(charS, 2, StringSplitOptions.RemoveEmptyEntries);
                                            if (new_line.GetUpperBound(0) > 0)
                                            {
                                                bool int_allowed = true;
                                                int  time        = 0;
                                                try
                                                {
                                                    time = Convert.ToInt32(new_line[0]);
                                                    if ((time * 1000) <= 0)
                                                    {
                                                        int_allowed = false;
                                                    }
                                                }
                                                catch
                                                {
                                                    int_allowed = false;
                                                }
                                                if (int_allowed == true)
                                                {
                                                    char[]   charSplit = new char[] { ' ' };
                                                    string[] ex        = new_line[1].Split(charSplit);
                                                    if (ex[0].TrimStart(Convert.ToChar(conf.command)).Equals("alarm"))
                                                    {
                                                        if (type.Equals("channel"))
                                                        {
                                                            ircbot.sendData("PRIVMSG", line[2] + " :Recursion is bad.");
                                                        }
                                                        else
                                                        {
                                                            ircbot.sendData("PRIVMSG", nick + " :Recursion is bad.");
                                                        }
                                                    }
                                                    else
                                                    {
                                                        tmp_conf = conf;
                                                        Timer alarm_trigger = new Timer();
                                                        alarm_trigger.Interval  = (time * 1000);
                                                        alarm_trigger.Enabled   = true;
                                                        alarm_trigger.AutoReset = false;
                                                        alarm_trigger.Elapsed  += (sender, e) => ring_alarm(sender, e, ircbot, nick, line[0], nick_access, channel, type, new_line[1]);
                                                        alarms.Add(alarm_trigger);

                                                        if (type.Equals("channel"))
                                                        {
                                                            ircbot.sendData("PRIVMSG", line[2] + " :Alarm added for " + new_line[0] + " seconds from now.");
                                                        }
                                                        else
                                                        {
                                                            ircbot.sendData("PRIVMSG", nick + " :Alarm added for " + new_line[0] + " seconds from now.");
                                                        }
                                                    }
                                                }
                                                else
                                                {
                                                    if (type.Equals("channel"))
                                                    {
                                                        ircbot.sendData("PRIVMSG", line[2] + " :" + nick + ", please pick a valid time.");
                                                    }
                                                    else
                                                    {
                                                        ircbot.sendData("PRIVMSG", nick + " :" + nick + ", please pick a valid time.");
                                                    }
                                                }
                                            }
                                            else
                                            {
                                                if (type.Equals("channel"))
                                                {
                                                    ircbot.sendData("PRIVMSG", line[2] + " :" + nick + ", you need to include more info.");
                                                }
                                                else
                                                {
                                                    ircbot.sendData("PRIVMSG", nick + " :" + nick + ", you need to include more info.");
                                                }
                                            }
                                        }
                                        else
                                        {
                                            if (type.Equals("channel"))
                                            {
                                                ircbot.sendData("PRIVMSG", line[2] + " :" + nick + ", you need to include more info.");
                                            }
                                            else
                                            {
                                                ircbot.sendData("PRIVMSG", nick + " :" + nick + ", you need to include more info.");
                                            }
                                        }
                                    }
                                    else
                                    {
                                        ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command.");
                                    }
                                    break;
                                }
                            }
                        }
                    }
                }
            }
        }
Esempio n. 46
0
 public override void control(bot ircbot, ref IRCConfig conf, int module_id, string[] line, string command, int nick_access, string nick, string channel, bool bot_command, string type)
 {
     string module_name = ircbot.conf.module_config[module_id][0];
     if ((type.Equals("channel") || type.Equals("query")) && bot_command == true)
     {
         foreach (List<string> tmp_command in conf.command_list)
         {
             if (module_name.Equals(tmp_command[0]))
             {
                 string[] triggers = tmp_command[3].Split('|');
                 int command_access = Convert.ToInt32(tmp_command[5]);
                 string[] blacklist = tmp_command[6].Split(',');
                 bool blocked = false;
                 bool cmd_found = false;
                 bool spam_check = Convert.ToBoolean(tmp_command[8]);
                 foreach (string bl_chan in blacklist)
                 {
                     if (bl_chan.Equals(channel))
                     {
                         blocked = true;
                         break;
                     }
                 }
                 if (spam_check == true)
                 {
                     blocked = ircbot.get_spam_status(channel, nick);
                 }
                 foreach (string trigger in triggers)
                 {
                     if (trigger.Equals(command))
                     {
                         cmd_found = true;
                         break;
                     }
                 }
                 if (blocked == true && cmd_found == true)
                 {
                     ircbot.sendData("NOTICE", nick + " :I am currently too busy to process that.");
                 }
                 if (blocked == false && cmd_found == true)
                 {
                     foreach (string trigger in triggers)
                     {
                         switch (trigger)
                         {
                             case "access":
                                 if (spam_check == true)
                                 {
                                     ircbot.add_spam_count(channel);
                                 }
                                 if (nick_access >= command_access)
                                 {
                                     if (line.GetUpperBound(0) > 3)
                                     {
                                         string[] parse = line[4].Split(' ');
                                         if (parse.GetUpperBound(0) > 1)
                                         {
                                             if (Convert.ToInt32(parse[2]) <= nick_access)
                                             {
                                                 set_access_list(parse[0].Trim().ToLower(), parse[1], parse[2], ircbot);
                                                 ircbot.sendData("NOTICE", nick + " :" + parse[0].Trim() + " has been added to access level " + parse[2]);
                                             }
                                             else
                                             {
                                                 ircbot.sendData("NOTICE", nick + " :You do not have permission to change their access.");
                                             }
                                         }
                                         else if (type.Equals("channel") && parse.GetUpperBound(0) > 0)
                                         {
                                             if (Convert.ToInt32(parse[1]) <= nick_access)
                                             {
                                                 set_access_list(parse[0].Trim().ToLower(), line[2], parse[1], ircbot);
                                                 ircbot.sendData("NOTICE", nick + " :" + parse[0].Trim() + " has been added to access level " + parse[1]);
                                             }
                                             else
                                             {
                                                 ircbot.sendData("NOTICE", nick + " :You do not have permission to change their access.");
                                             }
                                         }
                                         else
                                         {
                                             ircbot.sendData("NOTICE", nick + " :" + nick + ", you need to include more info.");
                                         }
                                     }
                                     else
                                     {
                                         ircbot.sendData("NOTICE", nick + " :" + nick + ", you need to include more info.");
                                     }
                                 }
                                 else
                                 {
                                     ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command.");
                                 }
                                 break;
                             case "delaccess":
                                 if (spam_check == true)
                                 {
                                     ircbot.add_spam_count(channel);
                                 }
                                 if (nick_access >= command_access)
                                 {
                                     if (line.GetUpperBound(0) > 3)
                                     {
                                         string[] parse = line[4].Split(' ');
                                         if (parse.GetUpperBound(0) > 1)
                                         {
                                             if (Convert.ToInt32(parse[2]) <= nick_access)
                                             {
                                                 del_access_list(parse[0].Trim().ToLower(), parse[1], parse[2], ircbot);
                                                 ircbot.sendData("NOTICE", nick + " :" + parse[0].Trim() + " has been removed from access level " + parse[2]);
                                             }
                                             else
                                             {
                                                 ircbot.sendData("NOTICE", nick + " :You do not have permission to change their access.");
                                             }
                                         }
                                         else if (type.Equals("channel") && parse.GetUpperBound(0) > 0)
                                         {
                                             if (Convert.ToInt32(parse[1]) <= nick_access)
                                             {
                                                 del_access_list(parse[0].Trim().ToLower(), line[2], parse[1], ircbot);
                                                 ircbot.sendData("NOTICE", nick + " :" + parse[0].Trim() + " has been removed from access level " + parse[1]);
                                             }
                                             else
                                             {
                                                 ircbot.sendData("NOTICE", nick + " :You do not have permission to change their access.");
                                             }
                                         }
                                         else
                                         {
                                             ircbot.sendData("NOTICE", nick + " :" + nick + ", you need to include more info.");
                                         }
                                     }
                                     else
                                     {
                                         ircbot.sendData("NOTICE", nick + " :" + nick + ", you need to include more info.");
                                     }
                                 }
                                 else
                                 {
                                     ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command.");
                                 }
                                 break;
                             case "listaccess":
                                 if (spam_check == true)
                                 {
                                     ircbot.add_spam_count(channel);
                                 }
                                 if (nick_access >= command_access)
                                 {
                                     if (line.GetUpperBound(0) > 3)
                                     {
                                         list_access_list(nick, line[4], ircbot);
                                     }
                                     else if (type.Equals("channel"))
                                     {
                                         list_access_list(nick, line[2], ircbot);
                                     }
                                     else
                                     {
                                         ircbot.sendData("NOTICE", nick + " :" + nick + ", you need to include more info.");
                                     }
                                 }
                                 else
                                 {
                                     ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command.");
                                 }
                                 break;
                             case "getaccess":
                                 if (spam_check == true)
                                 {
                                     ircbot.add_spam_count(channel);
                                 }
                                 if (nick_access >= command_access)
                                 {
                                     if (line.GetUpperBound(0) > 3)
                                     {
                                         string[] new_line = line[4].ToLower().Split(' ');
                                         if (new_line.GetUpperBound(0) > 0 && new_line[0].StartsWith("#"))
                                         {
                                             int viewed_access = ircbot.get_user_access(new_line[1].Trim().ToLower(), new_line[0].Trim());
                                             ircbot.sendData("NOTICE", nick + " :" + new_line[1].Trim() + " has access level " + viewed_access.ToString());
                                         }
                                         else if (type.Equals("channel"))
                                         {
                                             int viewed_access = ircbot.get_user_access(line[4].Trim().ToLower(), channel);
                                             ircbot.sendData("NOTICE", nick + " :" + line[4].Trim() + " has access level " + viewed_access.ToString());
                                         }
                                         else
                                         {
                                             ircbot.sendData("NOTICE", nick + " :" + nick + ", you need to include more info.");
                                         }
                                     }
                                     else
                                     {
                                         ircbot.sendData("NOTICE", nick + " :" + nick + ", you need to include more info.");
                                     }
                                 }
                                 else
                                 {
                                     ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command.");
                                 }
                                 break;
                         }
                     }
                 }
             }
         }
     }
 }
Esempio n. 47
0
        public override void control(bot ircbot, ref IRCConfig conf, int module_id, string[] line, string command, int nick_access, string nick, string channel, bool bot_command, string type)
        {
            string module_name = ircbot.conf.module_config[module_id][0];
            if (type.Equals("channel") || type.Equals("query") && bot_command == true)
            {
                foreach (List<string> tmp_command in conf.command_list)
                {
                    if (module_name.Equals(tmp_command[0]))
                    {
                        string[] triggers = tmp_command[3].Split('|');
                        int command_access = Convert.ToInt32(tmp_command[5]);
                        string[] blacklist = tmp_command[6].Split(',');
                        bool blocked = false;
                        bool cmd_found = false;
                        bool spam_check = Convert.ToBoolean(tmp_command[8]);
                        foreach (string bl_chan in blacklist)
                        {
                            if (bl_chan.Equals(channel))
                            {
                                blocked = true;
                                break;
                            }
                        }
                        if (spam_check == true)
                        {
                            blocked = ircbot.get_spam_status(channel, nick);
                        }
                        foreach (string trigger in triggers)
                        {
                            if (trigger.Equals(command))
                            {
                                cmd_found = true;
                                break;
                            }
                        }
                        if (blocked == true && cmd_found == true)
                        {
                            ircbot.sendData("NOTICE", nick + " :I am currently too busy to process that.");
                        }
                        if (blocked == false && cmd_found == true)
                        {
                            foreach (string trigger in triggers)
                            {
                                switch (trigger)
                                {
                                    case "addresponse":
                                        if (spam_check == true)
                                        {
                                            ircbot.add_spam_count(channel);
                                        }
                                        if (nick_access >= command_access)
                                        {
                                            if (line.GetUpperBound(0) > 3)
                                            {
                                                string list_file = ircbot.cur_dir + Path.DirectorySeparatorChar + "modules" + Path.DirectorySeparatorChar + "Response" + Path.DirectorySeparatorChar + "dictionary.txt";
                                                if (Directory.Exists(ircbot.cur_dir + Path.DirectorySeparatorChar + "modules" + Path.DirectorySeparatorChar + "Response" + Path.DirectorySeparatorChar + "") == false)
                                                {
                                                    Directory.CreateDirectory(ircbot.cur_dir + Path.DirectorySeparatorChar + "modules" + Path.DirectorySeparatorChar + "Response");
                                                }
                                                if (File.Exists(ircbot.cur_dir + Path.DirectorySeparatorChar + "modules" + Path.DirectorySeparatorChar + "Response" + Path.DirectorySeparatorChar + "dictionary.txt"))
                                                {
                                                    StreamWriter log = File.AppendText(ircbot.cur_dir + Path.DirectorySeparatorChar + "modules" + Path.DirectorySeparatorChar + "Response" + Path.DirectorySeparatorChar + "dictionary.txt");
                                                    log.WriteLine(line[4]);
                                                    log.Close();
                                                }
                                                else
                                                {
                                                    StreamWriter log_file = File.CreateText(ircbot.cur_dir + Path.DirectorySeparatorChar + "modules" + Path.DirectorySeparatorChar + "Response" + Path.DirectorySeparatorChar + "dictionary.txt");
                                                    log_file.WriteLine(line[4]);
                                                    log_file.Close();
                                                }
                                                ircbot.sendData("PRIVMSG", channel + " :Response added successfully");
                                            }
                                            else
                                            {
                                                ircbot.sendData("NOTICE", nick + " :" + nick + ", you need to include more info.");
                                            }
                                        }
                                        else
                                        {
                                            ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command.");
                                        }
                                        break;
                                }
                            }
                        }
                    }
                }
            }
            if (type.Equals("channel") && bot_command == false)
            {
                if (nick != conf.nick)
                {
                    try
                    {
                        string[] file;
                        string list_file = ircbot.cur_dir + Path.DirectorySeparatorChar + "modules" + Path.DirectorySeparatorChar + "Response" + Path.DirectorySeparatorChar + "dictionary.txt";
                        if (File.Exists(list_file))
                        {
                            file = System.IO.File.ReadAllLines(list_file);
                        }
                        else
                        {
                            file = null;
                        }

                        string tmp_line = line[3];
                        if (line.GetUpperBound(0) > 3)
                        {
                            tmp_line += " " + line[4];
                        }
                        tmp_line = tmp_line.Remove(0, 1);
                        string new_line = tmp_line.ToLowerInvariant();
                        bool triggered = false;
                        if (file.GetUpperBound(0) >= 0)
                        {
                            foreach (string tmp_new_line in file)
                            {
                                string file_line = tmp_new_line.Replace("<nick>", nick);
                                file_line = file_line.Replace("<me>", conf.nick);
                                char[] split_type = new char[] { ':' };
                                char[] trigger_split = new char[] { '*' };
                                char[] triggered_split = new char[] { '&' };
                                string[] split = file_line.Split(split_type, 2);
                                string[] triggers = split[0].Split('|');
                                string[] responses = split[1].Split('|');
                                int index = 0;
                                for (int x = 0; x <= triggers.GetUpperBound(0); x++)
                                {
                                    string[] terms = triggers[x].Split(trigger_split, StringSplitOptions.RemoveEmptyEntries);
                                    for (int y = 0; y <= terms.GetUpperBound(0); y++)
                                    {
                                        triggered = false;
                                        terms[y] = terms[y].ToLowerInvariant();
                                        if (triggers[x].StartsWith("*") == false && triggers[x].EndsWith("*") == false && terms.GetUpperBound(0) == 0)
                                        {
                                            if (new_line.Equals(terms[y]) == true)
                                            {
                                                triggered = true;
                                            }
                                            else
                                            {
                                                triggered = false;
                                                break;
                                            }
                                        }
                                        else if (triggers[x].StartsWith("*") == false && y == 0)
                                        {
                                            if (new_line.StartsWith(terms[y]) == true && index <= new_line.IndexOf(terms[y]))
                                            {
                                                triggered = true;
                                                index = new_line.IndexOf(terms[y]);
                                            }
                                            else
                                            {
                                                triggered = false;
                                                break;
                                            }
                                        }
                                        else if (triggers[x].EndsWith("*") == false && y == terms.GetUpperBound(0))
                                        {
                                            if (new_line.EndsWith(terms[y]) == true && index <= new_line.IndexOf(terms[y]))
                                            {
                                                triggered = true;
                                                index = new_line.IndexOf(terms[y]);
                                            }
                                            else
                                            {
                                                triggered = false;
                                                break;
                                            }
                                        }
                                        else
                                        {
                                            if (new_line.Contains(terms[y]) == true && index <= new_line.IndexOf(terms[y]))
                                            {
                                                triggered = true;
                                                index = new_line.IndexOf(terms[y]);
                                            }
                                            else
                                            {
                                                triggered = false;
                                                break;
                                            }
                                        }
                                    }
                                    if (triggered == true)
                                    {
                                        break;
                                    }
                                }
                                if (triggered == true)
                                {
                                    ircbot.add_spam_count(channel);
                                    int number_of_responses = responses.GetUpperBound(0) + 1;
                                    Random random = new Random();
                                    index = random.Next(0, number_of_responses);
                                    string[] events = responses[index].Split(triggered_split, StringSplitOptions.RemoveEmptyEntries);
                                    for (int y = 0; y <= events.GetUpperBound(0); y++)
                                    {
                                        if (events[y].StartsWith("<action>") == true)
                                        {
                                            ircbot.sendData("PRIVMSG", channel + " :\u0001ACTION " + events[y].Remove(0, 8) + "\u0001");
                                        }
                                        else if (events[y].StartsWith("<delay>") == true)
                                        {
                                            Thread.Sleep(Convert.ToInt32(events[y].Remove(0, 7)));
                                        }
                                        else if (events[y].StartsWith("<part>") == true)
                                        {
                                            ircbot.sendData("PART", channel);
                                        }
                                        else if (events[y].StartsWith("<join>") == true)
                                        {
                                            ircbot.sendData("JOIN", channel);
                                        }
                                        else if (events[y].StartsWith("<kick>") == true)
                                        {
                                            if (events[y].Length > 6)
                                            {
                                                ircbot.sendData("KICK", channel + " " + nick + " :" + events[y].Remove(0, 6));
                                            }
                                            else
                                            {
                                                ircbot.sendData("KICK", channel + " " + nick + " :No Reason");
                                            }
                                        }
                                        else if (events[y].StartsWith("<ban>") == true)
                                        {
                                            string target_host = ircbot.get_user_host(nick);
                                            string ban = "*!*@" + target_host;
                                            if (target_host.Equals("was"))
                                            {
                                                ban = nick + "!*@*";
                                            }
                                            if (events[y].Length > 6)
                                            {
                                                ircbot.sendData("MODE", channel + " +b " + ban + " :" + events[y].Remove(0, 6));
                                            }
                                            else
                                            {
                                                ircbot.sendData("MODE", channel + " +b " + ban + " :No Reason");
                                            }
                                        }
                                        else if (events[y].StartsWith("<kickban>") == true)
                                        {
                                            string target_host = ircbot.get_user_host(nick);
                                            string ban = "*!*@" + target_host;
                                            if (target_host.Equals("was"))
                                            {
                                                ban = nick + "!*@*";
                                            }
                                            if (events[y].Length > 6)
                                            {
                                                ircbot.sendData("MODE", channel + " +b " + ban + " :" + events[y].Remove(0, 6));
                                                ircbot.sendData("KICK", channel + " " + nick + " :" + events[y].Remove(0, 6));
                                            }
                                            else
                                            {
                                                ircbot.sendData("MODE", channel + " +b " + ban + " :No Reason");
                                                ircbot.sendData("KICK", channel + " " + nick + " :No Reason");
                                            }
                                        }
                                        else if (events[y].StartsWith("<timeban>") == true)
                                        {
                                            string[] mod_line = new string[] { conf.nick, "0", channel, ":tb", events[y].Remove(0, 9) };
                                            Modules.moderation mod = new Modules.moderation();
                                            mod.control(ircbot, ref conf, module_id, mod_line, "tb", conf.owner_level, nick, channel, true, "channel");
                                        }
                                        else if (events[y].StartsWith("<timekickban>") == true)
                                        {
                                            string[] mod_line = new string[] { conf.nick, "0", channel, ":tkb", events[y].Remove(0, 13) };
                                            Modules.moderation mod = new Modules.moderation();
                                            mod.control(ircbot, ref conf, module_id, mod_line, "tkb", conf.owner_level, nick, channel, true, "channel");
                                        }
                                        else
                                        {
                                            ircbot.sendData("PRIVMSG", channel + " :" + events[y]);
                                        }
                                    }
                                    break;
                                }
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        ircbot.sendData("PRIVMSG", channel + " :" + ex.ToString());
                    }
                }
            }
        }
Esempio n. 48
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);
                    }
                }
            }
        }
Esempio n. 49
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 "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;
                            }
                        }
                    }
                }
            }
        }
Esempio n. 50
0
        public override void control(bot ircbot, ref IRCConfig conf, int module_id, string[] line, string command, int nick_access, string nick, string channel, bool bot_command, string type)
        {
            access access = new access();

            char[] charS = new char[] { ' ' };
            string module_name = ircbot.conf.module_config[module_id][0];
            string disallowed_modes = ircbot.conf.module_config[module_id][3];
            if (type.Equals("channel") && bot_command == true)
            {
                foreach (List<string> tmp_command in conf.command_list)
                {
                    if (module_name.Equals(tmp_command[0]))
                    {
                        string[] triggers = tmp_command[3].Split('|');
                        int command_access = Convert.ToInt32(tmp_command[5]);
                        string[] blacklist = tmp_command[6].Split(',');
                        bool blocked = false;
                        bool cmd_found = false;
                        bool spam_check = Convert.ToBoolean(tmp_command[8]);
                        foreach (string bl_chan in blacklist)
                        {
                            if (bl_chan.Equals(channel))
                            {
                                blocked = true;
                                break;
                            }
                        }
                        if (spam_check == true)
                        {
                            blocked = ircbot.get_spam_status(channel, nick);
                        }
                        foreach (string trigger in triggers)
                        {
                            if (trigger.Equals(command))
                            {
                                cmd_found = true;
                                break;
                            }
                        }
                        if (blocked == true && cmd_found == true)
                        {
                            ircbot.sendData("NOTICE", nick + " :I am currently too busy to process that.");
                        }
                        if (blocked == false && cmd_found == true)
                        {
                            foreach (string trigger in triggers)
                            {
                                switch (trigger)
                                {
                                    case "founder":
                                        if (spam_check == true)
                                        {
                                            ircbot.add_spam_count(channel);
                                        }
                                        if (nick_access >= command_access)
                                        {
                                            if (line.GetUpperBound(0) > 3)
                                            {
                                                ircbot.sendData("MODE", line[2] + " +q " + line[4].ToLower());
                                                access.set_access_list(line[4].ToLower(), line[2], conf.founder_level.ToString(), ircbot);
                                            }
                                            else
                                            {
                                                ircbot.sendData("PRIVMSG", line[2] + " :" + nick + ", you need to include more info.");
                                            }
                                        }
                                        else
                                        {
                                            ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command.");
                                        }
                                        break;
                                    case "defounder":
                                        if (spam_check == true)
                                        {
                                            ircbot.add_spam_count(channel);
                                        }
                                        if (nick_access >= command_access)
                                        {
                                            if (line.GetUpperBound(0) > 3)
                                            {
                                                ircbot.sendData("MODE", line[2] + " -q " + line[4].ToLower());
                                                access.del_access_list(line[4].ToLower(), line[2], conf.founder_level.ToString(), ircbot);
                                            }
                                            else
                                            {
                                                ircbot.sendData("PRIVMSG", line[2] + " :" + nick + ", you need to include more info.");
                                            }
                                        }
                                        else
                                        {
                                            ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command.");
                                        }
                                        break;
                                    case "sop":
                                        if (spam_check == true)
                                        {
                                            ircbot.add_spam_count(channel);
                                        }
                                        if (nick_access >= command_access)
                                        {
                                            if (line.GetUpperBound(0) > 3)
                                            {
                                                ircbot.sendData("MODE", line[2] + " +a " + line[4].ToLower());
                                                access.set_access_list(line[4].ToLower(), line[2], conf.sop_level.ToString(), ircbot);
                                            }
                                            else
                                            {
                                                ircbot.sendData("PRIVMSG", line[2] + " :" + nick + ", you need to include more info.");
                                            }
                                        }
                                        else
                                        {
                                            ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command.");
                                        }
                                        break;
                                    case "asop":
                                        if (spam_check == true)
                                        {
                                            ircbot.add_spam_count(channel);
                                        }
                                        if (nick_access >= command_access)
                                        {
                                            if (line.GetUpperBound(0) > 3)
                                            {
                                                ircbot.sendData("MODE", line[2] + " +a " + line[4].ToLower());
                                                ircbot.sendData("PRIVMSG", "chanserv :SOP " + line[2] + " add " + line[4].ToLower());
                                                access.set_access_list(line[4].ToLower(), line[2], conf.sop_level.ToString(), ircbot);
                                            }
                                            else
                                            {
                                                ircbot.sendData("PRIVMSG", line[2] + " :" + nick + ", you need to include more info.");
                                            }
                                        }
                                        else
                                        {
                                            ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command.");
                                        }
                                        break;
                                    case "deasop":
                                        if (spam_check == true)
                                        {
                                            ircbot.add_spam_count(channel);
                                        }
                                        if (nick_access >= command_access)
                                        {
                                            if (line.GetUpperBound(0) > 3)
                                            {
                                                ircbot.sendData("MODE", line[2] + " -a " + line[4].ToLower());
                                                ircbot.sendData("PRIVMSG", "chanserv :SOP " + line[2] + " del " + line[4].ToLower());
                                                access.del_access_list(line[4].ToLower(), line[2], conf.sop_level.ToString(), ircbot);
                                            }
                                            else
                                            {
                                                ircbot.sendData("PRIVMSG", line[2] + " :" + nick + ", you need to include more info.");
                                            }
                                        }
                                        else
                                        {
                                            ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command.");
                                        }
                                        break;
                                    case "desop":
                                        if (spam_check == true)
                                        {
                                            ircbot.add_spam_count(channel);
                                        }
                                        if (nick_access >= command_access)
                                        {
                                            if (line.GetUpperBound(0) > 3)
                                            {
                                                ircbot.sendData("MODE", line[2] + " -a " + line[4].ToLower());
                                                access.del_access_list(line[4].ToLower(), line[2], conf.sop_level.ToString(), ircbot);
                                            }
                                            else
                                            {
                                                ircbot.sendData("PRIVMSG", line[2] + " :" + nick + ", you need to include more info.");
                                            }
                                        }
                                        else
                                        {
                                            ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command.");
                                        }
                                        break;
                                    case "op":
                                        if (spam_check == true)
                                        {
                                            ircbot.add_spam_count(channel);
                                        }
                                        if (nick_access >= command_access)
                                        {
                                            if (line.GetUpperBound(0) > 3)
                                            {
                                                ircbot.sendData("MODE", line[2] + " +o " + line[4].ToLower());
                                                access.set_access_list(line[4].ToLower(), line[2], conf.op_level.ToString(), ircbot);
                                            }
                                            else
                                            {
                                                ircbot.sendData("PRIVMSG", line[2] + " :" + nick + ", you need to include more info.");
                                            }
                                        }
                                        else
                                        {
                                            ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command.");
                                        }
                                        break;
                                    case "aop":
                                        if (spam_check == true)
                                        {
                                            ircbot.add_spam_count(channel);
                                        }
                                        if (nick_access >= command_access)
                                        {
                                            if (line.GetUpperBound(0) > 3)
                                            {
                                                ircbot.sendData("MODE", line[2] + " +o " + line[4].ToLower());
                                                ircbot.sendData("PRIVMSG", "chanserv :AOP " + line[2] + " add " + line[4].ToLower());
                                                access.set_access_list(line[4].ToLower(), line[2], conf.op_level.ToString(), ircbot);
                                            }
                                            else
                                            {
                                                ircbot.sendData("PRIVMSG", line[2] + " :" + nick + ", you need to include more info.");
                                            }
                                        }
                                        else
                                        {
                                            ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command.");
                                        }
                                        break;
                                    case "deaop":
                                        if (spam_check == true)
                                        {
                                            ircbot.add_spam_count(channel);
                                        }
                                        if (nick_access >= command_access)
                                        {
                                            if (line.GetUpperBound(0) > 3)
                                            {
                                                ircbot.sendData("MODE", line[2] + " -o " + line[4].ToLower());
                                                ircbot.sendData("PRIVMSG", "chanserv :AOP " + line[2] + " del " + line[4].ToLower());
                                                access.del_access_list(line[4].ToLower(), line[2], conf.op_level.ToString(), ircbot);
                                            }
                                            else
                                            {
                                                ircbot.sendData("PRIVMSG", line[2] + " :" + nick + ", you need to include more info.");
                                            }
                                        }
                                        else
                                        {
                                            ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command.");
                                        }
                                        break;
                                    case "deop":
                                        if (spam_check == true)
                                        {
                                            ircbot.add_spam_count(channel);
                                        }
                                        if (nick_access >= command_access)
                                        {
                                            if (line.GetUpperBound(0) > 3)
                                            {
                                                ircbot.sendData("MODE", line[2] + " -o " + line[4].ToLower());
                                                access.del_access_list(line[4].ToLower(), line[2], conf.op_level.ToString(), ircbot);
                                            }
                                            else
                                            {
                                                ircbot.sendData("PRIVMSG", line[2] + " :" + nick + ", you need to include more info.");
                                            }
                                        }
                                        else
                                        {
                                            ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command.");
                                        }
                                        break;
                                    case "ahop":
                                        if (spam_check == true)
                                        {
                                            ircbot.add_spam_count(channel);
                                        }
                                        if (nick_access >= command_access)
                                        {
                                            if (line.GetUpperBound(0) > 3)
                                            {
                                                ircbot.sendData("MODE", line[2] + " +h " + line[4].ToLower());
                                                ircbot.sendData("PRIVMSG", "chanserv :HOP " + line[2] + " add " + line[4].ToLower());
                                                access.set_access_list(line[4].ToLower(), line[2], conf.hop_level.ToString(), ircbot);
                                            }
                                            else
                                            {
                                                ircbot.sendData("PRIVMSG", line[2] + " :" + nick + ", you need to include more info.");
                                            }
                                        }
                                        else
                                        {
                                            ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command.");
                                        }
                                        break;
                                    case "deahop":
                                        if (spam_check == true)
                                        {
                                            ircbot.add_spam_count(channel);
                                        }
                                        if (nick_access >= command_access)
                                        {
                                            if (line.GetUpperBound(0) > 3)
                                            {
                                                ircbot.sendData("MODE", line[2] + " -h " + line[4].ToLower());
                                                ircbot.sendData("PRIVMSG", "chanserv :HOP " + line[2] + " del " + line[4].ToLower());
                                                access.del_access_list(line[4].ToLower(), line[2], conf.hop_level.ToString(), ircbot);
                                            }
                                            else
                                            {
                                                ircbot.sendData("PRIVMSG", line[2] + " :" + nick + ", you need to include more info.");
                                            }
                                        }
                                        else
                                        {
                                            ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command.");
                                        }
                                        break;
                                    case "hop":
                                        if (spam_check == true)
                                        {
                                            ircbot.add_spam_count(channel);
                                        }
                                        if (nick_access >= command_access)
                                        {
                                            if (line.GetUpperBound(0) > 3)
                                            {
                                                ircbot.sendData("MODE", line[2] + " +h " + line[4].ToLower());
                                                access.set_access_list(line[4].ToLower(), line[2], conf.hop_level.ToString(), ircbot);
                                            }
                                            else
                                            {
                                                ircbot.sendData("PRIVMSG", line[2] + " :" + nick + ", you need to include more info.");
                                            }
                                        }
                                        else
                                        {
                                            ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command.");
                                        }
                                        break;
                                    case "dehop":
                                        if (spam_check == true)
                                        {
                                            ircbot.add_spam_count(channel);
                                        }
                                        if (nick_access >= command_access)
                                        {
                                            if (line.GetUpperBound(0) > 3)
                                            {
                                                ircbot.sendData("MODE", line[2] + " -h " + line[4].ToLower());
                                                access.del_access_list(line[4].ToLower(), line[2], conf.hop_level.ToString(), ircbot);
                                            }
                                            else
                                            {
                                                ircbot.sendData("PRIVMSG", line[2] + " :" + nick + ", you need to include more info.");
                                            }
                                        }
                                        else
                                        {
                                            ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command.");
                                        }
                                        break;
                                    case "avoice":
                                        if (spam_check == true)
                                        {
                                            ircbot.add_spam_count(channel);
                                        }
                                        if (nick_access >= command_access)
                                        {
                                            if (line.GetUpperBound(0) > 3)
                                            {
                                                ircbot.sendData("MODE", line[2] + " +v " + line[4].ToLower());
                                                ircbot.sendData("PRIVMSG", "chanserv :VOP " + line[2] + " add " + line[4].ToLower());
                                                access.set_access_list(line[4].ToLower(), line[2], conf.voice_level.ToString(), ircbot);
                                            }
                                            else
                                            {
                                                ircbot.sendData("PRIVMSG", line[2] + " :" + nick + ", you need to include more info.");
                                            }
                                        }
                                        else
                                        {
                                            ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command.");
                                        }
                                        break;
                                    case "deavoice":
                                        if (spam_check == true)
                                        {
                                            ircbot.add_spam_count(channel);
                                        }
                                        if (nick_access >= command_access)
                                        {
                                            if (line.GetUpperBound(0) > 3)
                                            {
                                                ircbot.sendData("MODE", line[2] + " -v " + line[4].ToLower());
                                                ircbot.sendData("PRIVMSG", "chanserv :VOP " + line[2] + " del " + line[4].ToLower());
                                                access.del_access_list(line[4].ToLower(), line[2], conf.voice_level.ToString(), ircbot);
                                            }
                                            else
                                            {
                                                ircbot.sendData("PRIVMSG", line[2] + " :" + nick + ", you need to include more info.");
                                            }
                                        }
                                        else
                                        {
                                            ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command.");
                                        }
                                        break;
                                    case "voice":
                                        if (spam_check == true)
                                        {
                                            ircbot.add_spam_count(channel);
                                        }
                                        if (nick_access >= command_access)
                                        {
                                            if (line.GetUpperBound(0) > 3)
                                            {
                                                ircbot.sendData("MODE", line[2] + " +v " + line[4].ToLower());
                                                access.set_access_list(line[4].ToLower(), line[2], conf.voice_level.ToString(), ircbot);
                                            }
                                            else
                                            {
                                                ircbot.sendData("PRIVMSG", line[2] + " :" + nick + ", you need to include more info.");
                                            }
                                        }
                                        else
                                        {
                                            ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command.");
                                        }
                                        break;
                                    case "devoice":
                                        if (spam_check == true)
                                        {
                                            ircbot.add_spam_count(channel);
                                        }
                                        if (nick_access >= command_access)
                                        {
                                            if (line.GetUpperBound(0) > 3)
                                            {
                                                ircbot.sendData("MODE", line[2] + " -v " + line[4].ToLower());
                                                access.del_access_list(line[4].ToLower(), line[2], conf.voice_level.ToString(), ircbot);
                                            }
                                            else
                                            {
                                                ircbot.sendData("PRIVMSG", line[2] + " :" + nick + ", you need to include more info.");
                                            }
                                        }
                                        else
                                        {
                                            ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command.");
                                        }
                                        break;
                                    case "mode":
                                        if (spam_check == true)
                                        {
                                            ircbot.add_spam_count(channel);
                                        }
                                        if (nick_access >= command_access)
                                        {
                                            if (line.GetUpperBound(0) > 3)
                                            {
                                                string[] new_line = line[4].Split(charS, 2);
                                                char[] arr = new_line[0].ToCharArray();

                                                bool mode_allowed = true;
                                                bool positive = true;
                                                int mode_index = 0;
                                                foreach (char c in arr)
                                                {
                                                    if (!c.Equals('+') && !c.Equals('-'))
                                                    {
                                                        char[] modes_disallowed = disallowed_modes.ToCharArray();
                                                        foreach (char m in modes_disallowed)
                                                        {
                                                            if (m.Equals(c))
                                                            {
                                                                mode_allowed = false;
                                                                break;
                                                            }
                                                        }
                                                        if (mode_allowed == true)
                                                        {
                                                            if (c.Equals('q') || c.Equals('a') || c.Equals('o') || c.Equals('h') || c.Equals('v'))
                                                            {
                                                                int mode_access = ircbot.get_access_num(c.ToString(), true);
                                                                if (nick_access < mode_access)
                                                                {
                                                                    mode_allowed = false;
                                                                    break;
                                                                }
                                                            }
                                                        }
                                                        if (mode_allowed)
                                                        {
                                                            string leading_cmd = "";
                                                            if (positive)
                                                            {
                                                                leading_cmd = "+";
                                                            }
                                                            else
                                                            {
                                                                leading_cmd = "-";
                                                            }
                                                            bool nick_needed = false;
                                                            if (new_line.GetUpperBound(0) > 0)
                                                            {
                                                                string[] nicks = new_line[1].Split(charS);
                                                                if (nicks.GetUpperBound(0) >= mode_index)
                                                                {
                                                                    nick_needed = true;
                                                                }
                                                            }
                                                            if (nick_needed)
                                                            {
                                                                string[] nicks = new_line[1].Split(charS);
                                                                ircbot.sendData("MODE", line[2] + " " + leading_cmd + c.ToString() + " :" + nicks[mode_index]);
                                                            }
                                                            else
                                                            {
                                                                ircbot.sendData("MODE", line[2] + " " + leading_cmd + c.ToString());
                                                            }
                                                        }
                                                        mode_index++;
                                                    }
                                                    else if (c.Equals('+'))
                                                    {
                                                        positive = true;
                                                    }
                                                    else if (c.Equals('-'))
                                                    {
                                                        positive = false;
                                                    }
                                                }
                                                if (!mode_allowed)
                                                {
                                                    ircbot.sendData("PRIVMSG", line[2] + " :You do not have permission to use that command.");
                                                }
                                            }
                                            else
                                            {
                                                ircbot.sendData("PRIVMSG", line[2] + " :" + nick + ", you need to include more info.");
                                            }
                                        }
                                        else
                                        {
                                            ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command.");
                                        }
                                        break;
                                    case "topic":
                                        if (spam_check == true)
                                        {
                                            ircbot.add_spam_count(channel);
                                        }
                                        if (nick_access >= command_access)
                                        {
                                            if (line.GetUpperBound(0) > 3)
                                            {
                                                string[] new_line = line[4].Split(charS, 2);
                                                if (new_line.GetUpperBound(0) > 0)
                                                {
                                                    ircbot.sendData("TOPIC", line[2] + " :" + new_line[0] + " " + new_line[1]);
                                                }
                                                else
                                                {
                                                    ircbot.sendData("TOPIC", line[2] + " :" + new_line[0]);
                                                }
                                            }
                                            else
                                            {
                                                ircbot.sendData("PRIVMSG", line[2] + " :" + nick + ", you need to include more info.");
                                            }
                                        }
                                        else
                                        {
                                            ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command.");
                                        }
                                        break;
                                    case "invite":
                                        if (spam_check == true)
                                        {
                                            ircbot.add_spam_count(channel);
                                        }
                                        if (nick_access >= command_access)
                                        {
                                            if (line.GetUpperBound(0) > 3)
                                            {
                                                string[] new_line = line[4].ToLower().Split(charS, 2);
                                                if (new_line.GetUpperBound(0) > 0)
                                                {
                                                    ircbot.sendData("INVITE", new_line[0] + " " + new_line[1]);
                                                }
                                                else
                                                {
                                                    ircbot.sendData("INVITE", new_line[0] + " " + line[2]);
                                                }
                                            }
                                            else
                                            {
                                                ircbot.sendData("PRIVMSG", line[2] + " :" + nick + ", you need to include more info.");
                                            }
                                        }
                                        else
                                        {
                                            ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command.");
                                        }
                                        break;
                                    case "b":
                                        if (spam_check == true)
                                        {
                                            ircbot.add_spam_count(channel);
                                        }
                                        if (nick_access >= command_access)
                                        {
                                            if (line.GetUpperBound(0) > 3)
                                            {
                                                string[] new_line = line[4].ToLower().Split(charS, 2);
                                                string nicks = new_line[0].TrimStart(':');
                                                char[] charSep = new char[] { ',' };
                                                string[] total_nicks = new_line[0].Split(charSep, StringSplitOptions.RemoveEmptyEntries);
                                                int sent_nick_access = ircbot.get_user_access(total_nicks[0], line[2]);

                                                bool tmp_me = false;
                                                for (int y = 0; y <= total_nicks.GetUpperBound(0); y++)
                                                {
                                                    if (total_nicks[y].Equals(conf.name, StringComparison.OrdinalIgnoreCase))
                                                    {
                                                        tmp_me = true;
                                                    }
                                                }
                                                if (sent_nick_access == conf.owner_level)
                                                {
                                                    ircbot.sendData("PRIVMSG", line[2] + " :You can't ban my owner!");
                                                }
                                                else if (tmp_me == true)
                                                {
                                                    ircbot.sendData("PRIVMSG", line[2] + " :You can't ban me!");
                                                }
                                                else
                                                {
                                                    if (nick_access >= sent_nick_access)
                                                    {
                                                        string target_host = ircbot.get_user_host(total_nicks[0]);
                                                        string ban = "*!*@" + target_host;
                                                        if (target_host.Equals(""))
                                                        {
                                                            ban = new_line[0] + "!*@*";
                                                        }
                                                        if (new_line.GetUpperBound(0) > 0)
                                                        {
                                                            ircbot.sendData("MODE", line[2] + " +b " + ban + " :" + new_line[1]);
                                                        }
                                                        else
                                                        {
                                                            ircbot.sendData("MODE", line[2] + " +b " + ban + " :No Reason");
                                                        }
                                                    }
                                                    else
                                                    {
                                                        ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command.");
                                                    }
                                                }
                                            }
                                            else
                                            {
                                                ircbot.sendData("PRIVMSG", line[2] + " :" + nick + ", you need to include more info.");
                                            }
                                        }
                                        else
                                        {
                                            ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command.");
                                        }
                                        break;
                                    case "ub":
                                        if (spam_check == true)
                                        {
                                            ircbot.add_spam_count(channel);
                                        }
                                        if (nick_access >= command_access)
                                        {
                                            if (line.GetUpperBound(0) > 3)
                                            {
                                                string[] new_line = line[4].ToLower().Split(charS, 2);
                                                char[] charSep = new char[] { ',' };
                                                string[] total_nicks = new_line[0].Split(charSep, StringSplitOptions.RemoveEmptyEntries);
                                                int sent_nick_access = ircbot.get_user_access(total_nicks[0].TrimStart(':'), line[2]);

                                                if (nick_access >= sent_nick_access)
                                                {
                                                    string target_host = ircbot.get_user_host(total_nicks[0]);
                                                    string ban = "*!*@" + target_host;
                                                    if (target_host.Equals(""))
                                                    {
                                                        ban = new_line[0] + "!*@*";
                                                    }
                                                    if (new_line.GetUpperBound(0) > 0)
                                                    {
                                                        ircbot.sendData("MODE", line[2] + " -b " + ban + " :" + new_line[1]);
                                                    }
                                                    else
                                                    {
                                                        ircbot.sendData("MODE", line[2] + " -b " + ban + " :No Reason");
                                                    }
                                                }
                                                else
                                                {
                                                    ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command.");
                                                }
                                            }
                                            else
                                            {
                                                ircbot.sendData("PRIVMSG", line[2] + " :" + nick + ", you need to include more info.");
                                            }
                                        }
                                        else
                                        {
                                            ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command.");
                                        }
                                        break;
                                    case "clearban":
                                        if (spam_check == true)
                                        {
                                            ircbot.add_spam_count(channel);
                                        }
                                        if (nick_access >= command_access)
                                        {
                                            ircbot.sendData("PRIVMSG", "chanserv :clear " + channel + " bans");
                                        }
                                        else
                                        {
                                            ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command.");
                                        }
                                        break;
                                    case "kb":
                                        if (spam_check == true)
                                        {
                                            ircbot.add_spam_count(channel);
                                        }
                                        if (nick_access >= command_access)
                                        {
                                            if (line.GetUpperBound(0) > 3)
                                            {
                                                string[] new_line = line[4].ToLower().Split(charS, 2);
                                                string nicks = new_line[0].TrimStart(':');
                                                char[] charSep = new char[] { ',' };
                                                string[] total_nicks = nicks.Split(charSep, StringSplitOptions.RemoveEmptyEntries);
                                                int sent_nick_access = ircbot.get_user_access(total_nicks[0], line[2]);

                                                bool tmp_me = false;
                                                for (int y = 0; y <= total_nicks.GetUpperBound(0); y++)
                                                {
                                                    if (total_nicks[y].Equals(conf.name, StringComparison.OrdinalIgnoreCase))
                                                    {
                                                        tmp_me = true;
                                                    }
                                                }
                                                if (sent_nick_access == conf.owner_level)
                                                {
                                                    ircbot.sendData("PRIVMSG", line[2] + " :You can't kick-ban my owner!");
                                                }
                                                else if (tmp_me == true)
                                                {
                                                    ircbot.sendData("PRIVMSG", line[2] + " :You can't kick-ban me!");
                                                }
                                                else
                                                {
                                                    if (nick_access >= sent_nick_access)
                                                    {
                                                        string target_host = ircbot.get_user_host(total_nicks[0]);
                                                        string ban = "*!*@" + target_host;
                                                        if (target_host.Equals(""))
                                                        {
                                                            ban = new_line[0] + "!*@*";
                                                        }
                                                        if (new_line.GetUpperBound(0) > 0)
                                                        {
                                                            ircbot.sendData("MODE", line[2] + " +b " + ban + " :" + new_line[1]);
                                                            ircbot.sendData("KICK", line[2] + " " + total_nicks[0] + " :" + new_line[1]);
                                                        }
                                                        else
                                                        {
                                                            ircbot.sendData("MODE", line[2] + " +b " + ban + " :No Reason");
                                                            ircbot.sendData("KICK", line[2] + " " + total_nicks[0] + " :No Reason");
                                                        }
                                                    }
                                                    else
                                                    {
                                                        ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command.");
                                                    }
                                                }
                                            }
                                            else
                                            {
                                                ircbot.sendData("PRIVMSG", line[2] + " :" + nick + ", you need to include more info.");
                                            }
                                        }
                                        else
                                        {
                                            ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command.");
                                        }
                                        break;
                                    case "tb":
                                        if (spam_check == true)
                                        {
                                            ircbot.add_spam_count(channel);
                                        }
                                        if (nick_access >= command_access)
                                        {
                                            if (line.GetUpperBound(0) > 3)
                                            {
                                                string[] new_line = line[4].ToLower().Split(charS, 3, StringSplitOptions.RemoveEmptyEntries);
                                                if (new_line.GetUpperBound(0) > 0)
                                                {
                                                    int time = Convert.ToInt32(new_line[0].TrimStart(':'));
                                                    string nicks = new_line[1];
                                                    char[] charSep = new char[] { ',' };
                                                    string[] total_nicks = nicks.Split(charSep, StringSplitOptions.RemoveEmptyEntries);
                                                    string target_host = ircbot.get_user_host(total_nicks[0]);
                                                    int sent_nick_access = ircbot.get_user_access(total_nicks[0], line[2]);

                                                    bool tmp_me = false;
                                                    for (int y = 0; y <= total_nicks.GetUpperBound(0); y++)
                                                    {
                                                        if (total_nicks[y].Equals(conf.name, StringComparison.OrdinalIgnoreCase))
                                                        {
                                                            tmp_me = true;
                                                        }
                                                    }
                                                    if (sent_nick_access == conf.owner_level)
                                                    {
                                                        ircbot.sendData("PRIVMSG", line[2] + " :You can't ban my owner!");
                                                    }
                                                    else if (tmp_me == true)
                                                    {
                                                        ircbot.sendData("PRIVMSG", line[2] + " :You can't ban me!");
                                                    }
                                                    else
                                                    {
                                                        if (nick_access >= sent_nick_access)
                                                        {
                                                            string ban = "*!*@" + target_host;
                                                            if (target_host.Equals(""))
                                                            {
                                                                ban = total_nicks[0] + "!*@*";
                                                            }
                                                            if (new_line.GetUpperBound(0) > 1)
                                                            {
                                                                ircbot.sendData("MODE", line[2] + " +b " + ban + " :" + new_line[2]);
                                                            }
                                                            else
                                                            {
                                                                ircbot.sendData("MODE", line[2] + " +b " + ban + " :No Reason");
                                                            }
                                                            Timer unban_trigger = new Timer();
                                                            unban_trigger.Interval = (Convert.ToInt32(new_line[0]) * 1000);
                                                            unban_trigger.Enabled = true;
                                                            unban_trigger.AutoReset = false;
                                                            unban_trigger.Elapsed += (sender, e) => unban_nick(sender, e, total_nicks[0], target_host, line[2]);
                                                            unban_triggers.Add(unban_trigger);
                                                            main = ircbot;
                                                        }
                                                        else
                                                        {
                                                            ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command.");
                                                        }
                                                    }
                                                }
                                                else
                                                {
                                                    ircbot.sendData("PRIVMSG", line[2] + " :" + nick + ", you need to include more info.");
                                                }
                                            }
                                            else
                                            {
                                                ircbot.sendData("PRIVMSG", line[2] + " :" + nick + ", you need to include more info.");
                                            }
                                        }
                                        else
                                        {
                                            ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command.");
                                        }
                                        break;
                                    case "tkb":
                                        if (spam_check == true)
                                        {
                                            ircbot.add_spam_count(channel);
                                        }
                                        if (nick_access >= command_access)
                                        {
                                            if (line.GetUpperBound(0) > 3)
                                            {
                                                string[] new_line = line[4].ToLower().Split(charS, 3, StringSplitOptions.RemoveEmptyEntries);
                                                if (new_line.GetUpperBound(0) > 0)
                                                {
                                                    int time = Convert.ToInt32(new_line[0].TrimStart(':'));
                                                    string nicks = new_line[1];
                                                    char[] charSep = new char[] { ',' };
                                                    string[] total_nicks = nicks.Split(charSep, StringSplitOptions.RemoveEmptyEntries);
                                                    int sent_nick_access = ircbot.get_user_access(total_nicks[0], line[2]);
                                                    string target_host = ircbot.get_user_host(total_nicks[0]);

                                                    bool tmp_me = false;
                                                    for (int y = 0; y <= total_nicks.GetUpperBound(0); y++)
                                                    {
                                                        if (total_nicks[y].Equals(conf.name, StringComparison.OrdinalIgnoreCase))
                                                        {
                                                            tmp_me = true;
                                                        }
                                                    }
                                                    if (sent_nick_access == conf.owner_level)
                                                    {
                                                        ircbot.sendData("PRIVMSG", line[2] + " :You can't kick-ban my owner!");
                                                    }
                                                    else if (tmp_me == true)
                                                    {
                                                        ircbot.sendData("PRIVMSG", line[2] + " :You can't kick-ban me!");
                                                    }
                                                    else
                                                    {
                                                        if (nick_access >= sent_nick_access)
                                                        {
                                                            string ban = "*!*@" + target_host;
                                                            if (target_host.Equals(""))
                                                            {
                                                                ban = new_line[1] + "!*@*";
                                                            }
                                                            if (new_line.GetUpperBound(0) > 1)
                                                            {
                                                                ircbot.sendData("MODE", line[2] + " +b " + ban + " :" + new_line[2]);
                                                                ircbot.sendData("KICK", line[2] + " " + total_nicks[0] + " :" + new_line[2]);
                                                            }
                                                            else
                                                            {
                                                                ircbot.sendData("MODE", line[2] + " +b " + ban + " :No Reason");
                                                                ircbot.sendData("KICK", line[2] + " " + total_nicks[0] + " :No Reason");
                                                            }
                                                            System.Timers.Timer unban_trigger = new System.Timers.Timer();
                                                            unban_trigger.Interval = (Convert.ToInt32(new_line[0]) * 1000);
                                                            unban_trigger.Enabled = true;
                                                            unban_trigger.AutoReset = false;
                                                            unban_trigger.Elapsed += (sender, e) => unban_nick(sender, e, total_nicks[0], target_host, line[2]);
                                                            unban_triggers.Add(unban_trigger);
                                                            main = ircbot;
                                                        }
                                                        else
                                                        {
                                                            ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command.");
                                                        }
                                                    }
                                                }
                                                else
                                                {
                                                    ircbot.sendData("PRIVMSG", line[2] + " :" + nick + ", you need to include more info.");
                                                }
                                            }
                                            else
                                            {
                                                ircbot.sendData("PRIVMSG", line[2] + " :" + nick + ", you need to include more info.");
                                            }
                                        }
                                        else
                                        {
                                            ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command.");
                                        }
                                        break;
                                    case "ak":
                                        if (spam_check == true)
                                        {
                                            ircbot.add_spam_count(channel);
                                        }
                                        if (nick_access >= command_access)
                                        {
                                            if (line.GetUpperBound(0) > 3)
                                            {
                                                string[] new_line = line[4].ToLower().Split(charS, 2);
                                                string nicks = new_line[0].TrimStart(':');
                                                char[] charSep = new char[] { ',' };
                                                string[] total_nicks = nicks.Split(charSep, StringSplitOptions.RemoveEmptyEntries);
                                                int sent_nick_access = ircbot.get_user_access(total_nicks[0], line[2]);
                                                bool tmp_me = false;
                                                for (int y = 0; y <= total_nicks.GetUpperBound(0); y++)
                                                {
                                                    if (total_nicks[y].Equals(conf.name, StringComparison.OrdinalIgnoreCase))
                                                    {
                                                        tmp_me = true;
                                                    }
                                                }
                                                if (sent_nick_access == conf.owner_level)
                                                {
                                                    ircbot.sendData("PRIVMSG", line[2] + " :You can't kick my owner!");
                                                }
                                                else if (tmp_me == true)
                                                {
                                                    ircbot.sendData("PRIVMSG", line[2] + " :You can't kick me!");
                                                }
                                                else
                                                {
                                                    if (nick_access >= sent_nick_access)
                                                    {
                                                        string target_host = ircbot.get_user_host(total_nicks[0]);
                                                        if (new_line.GetUpperBound(0) > 0)
                                                        {
                                                            add_auto(total_nicks[0], line[2], target_host, "k", new_line[1], ircbot);
                                                        }
                                                        else
                                                        {
                                                            add_auto(total_nicks[0], line[2], target_host, "k", "No Reason", ircbot);
                                                        }
                                                    }
                                                    else
                                                    {
                                                        ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command.");
                                                    }
                                                }
                                            }
                                            else
                                            {
                                                ircbot.sendData("PRIVMSG", line[2] + " :" + nick + ", you need to include more info.");
                                            }
                                        }
                                        else
                                        {
                                            ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command.");
                                        }
                                        break;
                                    case "ab":
                                        if (spam_check == true)
                                        {
                                            ircbot.add_spam_count(channel);
                                        }
                                        if (nick_access >= command_access)
                                        {
                                            if (line.GetUpperBound(0) > 3)
                                            {
                                                string[] new_line = line[4].ToLower().Split(charS, 2);
                                                string target_host = ircbot.get_user_host(new_line[0]);
                                                string nicks = new_line[0].TrimStart(':');
                                                char[] charSep = new char[] { ',' };
                                                string[] total_nicks = nicks.Split(charSep, StringSplitOptions.RemoveEmptyEntries);
                                                int sent_nick_access = ircbot.get_user_access(total_nicks[0], line[2]);
                                                bool tmp_me = false;
                                                for (int y = 0; y <= total_nicks.GetUpperBound(0); y++)
                                                {
                                                    if (total_nicks[y].Equals(conf.name, StringComparison.OrdinalIgnoreCase))
                                                    {
                                                        tmp_me = true;
                                                    }
                                                }
                                                if (sent_nick_access == conf.owner_level)
                                                {
                                                    ircbot.sendData("PRIVMSG", line[2] + " :You can't ban my owner!");
                                                }
                                                else if (tmp_me == true)
                                                {
                                                    ircbot.sendData("PRIVMSG", line[2] + " :You can't ban me!");
                                                }
                                                else
                                                {
                                                    if (nick_access >= sent_nick_access)
                                                    {
                                                        if (new_line.GetUpperBound(0) > 0)
                                                        {
                                                            add_auto(total_nicks[0], line[2], target_host, "b", new_line[1], ircbot);
                                                        }
                                                        else
                                                        {
                                                            add_auto(total_nicks[0], line[2], target_host, "b", "No Reason", ircbot);
                                                        }
                                                    }
                                                    else
                                                    {
                                                        ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command.");
                                                    }
                                                }
                                            }
                                            else
                                            {
                                                ircbot.sendData("PRIVMSG", line[2] + " :" + nick + ", you need to include more info.");
                                            }
                                        }
                                        else
                                        {
                                            ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command.");
                                        }
                                        break;
                                    case "akb":
                                        if (spam_check == true)
                                        {
                                            ircbot.add_spam_count(channel);
                                        }
                                        if (nick_access >= command_access)
                                        {
                                            if (line.GetUpperBound(0) > 3)
                                            {
                                                string[] new_line = line[4].ToLower().Split(charS, 2);
                                                string target_host = ircbot.get_user_host(new_line[0]);
                                                string nicks = new_line[0].TrimStart(':');
                                                char[] charSep = new char[] { ',' };
                                                string[] total_nicks = nicks.Split(charSep, StringSplitOptions.RemoveEmptyEntries);
                                                int sent_nick_access = ircbot.get_user_access(total_nicks[0], line[2]);
                                                bool tmp_me = false;
                                                for (int y = 0; y <= total_nicks.GetUpperBound(0); y++)
                                                {
                                                    if (total_nicks[y].Equals(conf.name, StringComparison.OrdinalIgnoreCase))
                                                    {
                                                        tmp_me = true;
                                                    }
                                                }
                                                if (sent_nick_access == conf.owner_level)
                                                {
                                                    ircbot.sendData("PRIVMSG", line[2] + " :You can't kick-ban my owner!");
                                                }
                                                else if (tmp_me == true)
                                                {
                                                    ircbot.sendData("PRIVMSG", line[2] + " :You can't kick-ban me!");
                                                }
                                                else
                                                {
                                                    if (nick_access >= sent_nick_access)
                                                    {
                                                        if (new_line.GetUpperBound(0) > 0)
                                                        {
                                                            add_auto(total_nicks[0], line[2], target_host, "kb", new_line[1], ircbot);
                                                        }
                                                        else
                                                        {
                                                            add_auto(total_nicks[0], line[2], target_host, "kb", "No Reason", ircbot);
                                                        }
                                                    }
                                                    else
                                                    {
                                                        ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command.");
                                                    }
                                                }
                                            }
                                            else
                                            {
                                                ircbot.sendData("PRIVMSG", line[2] + " :" + nick + ", you need to include more info.");
                                            }
                                        }
                                        else
                                        {
                                            ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command.");
                                        }
                                        break;
                                    case "deak":
                                        if (spam_check == true)
                                        {
                                            ircbot.add_spam_count(channel);
                                        }
                                        if (nick_access >= command_access)
                                        {
                                            if (line.GetUpperBound(0) > 3)
                                            {
                                                string target_host = ircbot.get_user_host(line[4].ToLower());
                                                del_auto(line[4].ToLower(), line[2], target_host, "k", ircbot);
                                            }
                                            else
                                            {
                                                ircbot.sendData("PRIVMSG", line[2] + " :" + nick + ", you need to include more info.");
                                            }
                                        }
                                        else
                                        {
                                            ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command.");
                                        }
                                        break;
                                    case "deab":
                                        if (spam_check == true)
                                        {
                                            ircbot.add_spam_count(channel);
                                        }
                                        if (nick_access >= command_access)
                                        {
                                            if (line.GetUpperBound(0) > 3)
                                            {
                                                string target_host = ircbot.get_user_host(line[4].ToLower());
                                                del_auto(line[4].ToLower(), line[2], target_host, "b", ircbot);
                                            }
                                            else
                                            {
                                                ircbot.sendData("PRIVMSG", line[2] + " :" + nick + ", you need to include more info.");
                                            }
                                        }
                                        else
                                        {
                                            ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command.");
                                        }
                                        break;
                                    case "deakb":
                                        if (spam_check == true)
                                        {
                                            ircbot.add_spam_count(channel);
                                        }
                                        if (nick_access >= command_access)
                                        {
                                            if (line.GetUpperBound(0) > 3)
                                            {
                                                string target_host = ircbot.get_user_host(line[4].ToLower());
                                                del_auto(line[4].ToLower(), line[2], target_host, "kb", ircbot);
                                            }
                                            else
                                            {
                                                ircbot.sendData("PRIVMSG", line[2] + " :" + nick + ", you need to include more info.");
                                            }
                                        }
                                        else
                                        {
                                            ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command.");
                                        }
                                        break;
                                    case "k":
                                        if (spam_check == true)
                                        {
                                            ircbot.add_spam_count(channel);
                                        }
                                        if (nick_access >= command_access)
                                        {
                                            if (line.GetUpperBound(0) > 3)
                                            {
                                                string[] new_line = line[4].ToLower().Split(charS, 2);
                                                string nicks = new_line[0].TrimStart(':');
                                                char[] charSep = new char[] { ',' };
                                                string[] total_nicks = nicks.Split(charSep, StringSplitOptions.RemoveEmptyEntries);
                                                int sent_nick_access = ircbot.get_user_access(total_nicks[0], line[2]);
                                                bool tmp_me = false;
                                                for (int y = 0; y <= total_nicks.GetUpperBound(0); y++)
                                                {
                                                    if (total_nicks[y].Equals(conf.name, StringComparison.OrdinalIgnoreCase))
                                                    {
                                                        tmp_me = true;
                                                    }
                                                }
                                                if (sent_nick_access == conf.owner_level)
                                                {
                                                    ircbot.sendData("PRIVMSG", line[2] + " :You can't kick my owner!");
                                                }
                                                else if (tmp_me == true)
                                                {
                                                    ircbot.sendData("PRIVMSG", line[2] + " :You can't kick me!");
                                                }
                                                else
                                                {
                                                    if (nick_access >= sent_nick_access)
                                                    {
                                                        if (new_line.GetUpperBound(0) > 0)
                                                        {
                                                            ircbot.sendData("KICK", line[2] + " " + total_nicks[0] + " :" + new_line[1]);
                                                        }
                                                        else
                                                        {
                                                            ircbot.sendData("KICK", line[2] + " " + total_nicks[0] + " :No Reason");
                                                        }
                                                    }
                                                    else
                                                    {
                                                        ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command.");
                                                    }
                                                }
                                            }
                                            else
                                            {
                                                ircbot.sendData("PRIVMSG", line[2] + " :" + nick + ", you need to include more info.");
                                            }
                                        }
                                        else
                                        {
                                            ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command.");
                                        }
                                        break;
                                    case "kme":
                                        if (spam_check == true)
                                        {
                                            ircbot.add_spam_count(channel);
                                        }
                                        if (nick_access >= command_access)
                                        {
                                            if (line.GetUpperBound(0) > 3)
                                            {
                                                ircbot.sendData("KICK", line[2] + " " + nick + " :" + line[4]);
                                            }
                                            else
                                            {
                                                ircbot.sendData("KICK", line[2] + " " + nick + " :No Reason");
                                            }
                                        }
                                        break;
                                }
                            }
                        }
                    }
                }
            }
            if (type.Equals("join"))
            {
                string[] user_info = line[0].Split('@');
                string nick_host = user_info[1];
                check_auto(nick, channel.TrimStart(':'), nick_host, ircbot);
            }
        }
Esempio n. 51
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") && 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 "trivia":
                                if (spam_check == true)
                                {
                                    ircbot.add_spam_count(channel);
                                }
                                if (nick_access >= tmp_command.Access)
                                {
                                    bool score_found = false;
                                    lock (trivialock)
                                    {
                                        foreach (trivia_info trivia in trivias)
                                        {
                                            if (trivia.channel.Equals(channel, StringComparison.InvariantCultureIgnoreCase) && trivia.running)
                                            {
                                                score_found = true;
                                                break;
                                            }
                                        }
                                    }
                                    if (!score_found)
                                    {
                                        ircbot.sendData("PRIVMSG", channel + " :Lets play some Trivia!");
                                        new_question(channel, ircbot);
                                    }
                                    else
                                    {
                                        ircbot.sendData("PRIVMSG", channel + " :There is already a trivia game started!");
                                    }
                                }
                                break;

                            case "scores":
                                if (spam_check == true)
                                {
                                    ircbot.add_spam_count(channel);
                                }
                                if (nick_access >= tmp_command.Access)
                                {
                                    bool score_found = false;
                                    lock (trivialock)
                                    {
                                        foreach (trivia_info trivia in trivias)
                                        {
                                            if (trivia.channel.Equals(channel, StringComparison.InvariantCultureIgnoreCase))
                                            {
                                                score_found = true;
                                                int    index = 1;
                                                string msg   = "";
                                                foreach (List <string> score in trivia.scores)
                                                {
                                                    if (index <= 10)
                                                    {
                                                        msg += "[" + index + "] " + score[0] + ": " + score[1] + " points | ";
                                                    }
                                                    else
                                                    {
                                                        break;
                                                    }
                                                    index++;
                                                }
                                                if (!String.IsNullOrEmpty(msg))
                                                {
                                                    ircbot.sendData("PRIVMSG", channel + " :" + msg.Trim().TrimEnd('|').Trim());
                                                }
                                                else
                                                {
                                                    ircbot.sendData("PRIVMSG", channel + " :No scores are available.");
                                                }
                                                break;
                                            }
                                        }
                                    }
                                    if (!score_found)
                                    {
                                        ircbot.sendData("PRIVMSG", channel + " :No scores are available.");
                                    }
                                }
                                break;

                            case "score":
                                if (spam_check == true)
                                {
                                    ircbot.add_spam_count(channel);
                                }
                                if (nick_access >= tmp_command.Access)
                                {
                                    bool score_found = false;
                                    lock (trivialock)
                                    {
                                        foreach (trivia_info trivia in trivias)
                                        {
                                            if (trivia.channel.Equals(channel, StringComparison.InvariantCultureIgnoreCase))
                                            {
                                                score_found = true;
                                                int  index      = 0;
                                                bool nick_found = false;
                                                foreach (List <string> score in trivia.scores)
                                                {
                                                    if (score[0].Equals(nick, StringComparison.InvariantCultureIgnoreCase))
                                                    {
                                                        ircbot.sendData("PRIVMSG", channel + " :You are rank " + (index + 1).ToString() + " out of " + trivia.scores.Count + " with " + score[1] + " points");
                                                        nick_found = true;
                                                        break;
                                                    }
                                                    index++;
                                                }
                                                if (!nick_found)
                                                {
                                                    ircbot.sendData("NOTICE", nick + " :You are not currently ranked.  Try answering some questions to earn points!");
                                                }
                                                break;
                                            }
                                        }
                                    }
                                    if (!score_found)
                                    {
                                        ircbot.sendData("PRIVMSG", channel + " :No scores are available.");
                                    }
                                }
                                break;

                            case "stoptrivia":
                                if (spam_check == true)
                                {
                                    ircbot.add_spam_count(channel);
                                }
                                if (nick_access >= tmp_command.Access)
                                {
                                    bool trivia_found = false;
                                    lock (trivialock)
                                    {
                                        foreach (trivia_info trivia in trivias)
                                        {
                                            if (trivia.channel.Equals(channel, StringComparison.InvariantCultureIgnoreCase))
                                            {
                                                trivia_found = true;
                                                trivia.answer_timer.Stop();
                                                trivia.running = false;
                                                ircbot.sendData("PRIVMSG", channel + " :Trivia has been stopped!");
                                                int index = 1;
                                                List <List <string> > sorted = new List <List <string> >();
                                                string msg = "";
                                                foreach (List <string> score in trivia.scores)
                                                {
                                                    if (index <= 10)
                                                    {
                                                        msg += "[" + index + "] " + score[0] + ": " + score[1] + " points | ";
                                                    }
                                                    else
                                                    {
                                                        break;
                                                    }
                                                    index++;
                                                }
                                                if (!String.IsNullOrEmpty(msg))
                                                {
                                                    ircbot.sendData("PRIVMSG", channel + " :" + msg.Trim().TrimEnd('|').Trim());
                                                }
                                                trivia.scores = new List <List <string> >();
                                                break;
                                            }
                                        }
                                    }
                                    if (!trivia_found)
                                    {
                                        ircbot.sendData("PRIVMSG", channel + " :There isn't a trivia game running here.");
                                    }
                                }
                                break;

                            default:
                                break;
                            }
                        }
                    }
                }
            }
            if (type.Equals("channel") && !bot_command)
            {
                bool won = false;
                lock (trivialock)
                {
                    foreach (trivia_info trivia in trivias)
                    {
                        if (trivia.channel.Equals(channel, StringComparison.InvariantCultureIgnoreCase) && trivia.running)
                        {
                            string response = "";
                            if (line.GetUpperBound(0) > 3)
                            {
                                response = line[3].TrimStart(':') + " " + line[4];
                            }
                            else
                            {
                                response = line[3].TrimStart(':');
                            }
                            string[] answers = trivia.answer.Split('*');
                            foreach (string answer in answers)
                            {
                                if (response.Equals(answer, StringComparison.InvariantCultureIgnoreCase))
                                {
                                    int points = 0;
                                    int index  = 0;
                                    won = true;
                                    foreach (List <string> score in trivia.scores)
                                    {
                                        if (score[0].Equals(nick, StringComparison.InvariantCultureIgnoreCase))
                                        {
                                            int old_points = Convert.ToInt32(score[1]);
                                            points   = old_points + 1;
                                            score[1] = points.ToString();
                                            break;
                                        }
                                        index++;
                                    }
                                    if (points > 0)
                                    {
                                        ircbot.sendData("PRIVMSG", channel + " :\"" + response + "\" is correct! " + nick + " now has " + points + " points!");
                                    }
                                    else
                                    {
                                        List <string> tmp_score = new List <string>();
                                        tmp_score.Add(nick);
                                        tmp_score.Add("1");
                                        trivia.scores.Add(tmp_score);
                                        points = 1;
                                        ircbot.sendData("PRIVMSG", channel + " :\"" + response + "\" is correct! " + nick + " now has " + points + " point!");
                                    }
                                    trivia.questions_answered++;
                                    trivia.answer_timer.Stop();

                                    List <List <string> > top     = new List <List <string> >();
                                    List <List <string> > tmp_top = new List <List <string> >();
                                    tmp_top = trivia.scores;
                                    for (int x = 0; x < trivia.scores.Count; x++)
                                    {
                                        if (tmp_top.Count > 0)
                                        {
                                            int  score_index     = 0;
                                            int  tmp_top_score   = 0;
                                            int  top_score_index = 0;
                                            bool found           = false;
                                            foreach (List <string> top_score in tmp_top)
                                            {
                                                if (Convert.ToInt32(top_score[1]) > tmp_top_score)
                                                {
                                                    found           = true;
                                                    tmp_top_score   = Convert.ToInt32(top_score[1]);
                                                    top_score_index = score_index;
                                                }
                                                score_index++;
                                            }
                                            if (found)
                                            {
                                                top.Add(tmp_top[top_score_index]);
                                                tmp_top.RemoveAt(top_score_index);
                                                x--;
                                            }
                                        }
                                        else
                                        {
                                            break;
                                        }
                                    }
                                    trivia.scores = top;
                                }
                                break;
                            }
                            break;
                        }
                    }
                }
                if (won)
                {
                    new_question(channel, ircbot);
                }
            }
        }
Esempio n. 52
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);
                 }
             }
         }
     }
 }
Esempio n. 53
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 "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;
                     }
                 }
             }
         }
     }
 }
Esempio n. 54
0
        public override void control(bot ircbot, ref IRCConfig conf, int module_id, string[] line, string command, int nick_access, string nick, string channel, bool bot_command, string type)
        {
            string module_name = ircbot.conf.module_config[module_id][0];

            if (type.Equals("channel") && bot_command == true)
            {
                foreach (List <string> tmp_command in conf.command_list)
                {
                    if (module_name.Equals(tmp_command[0]))
                    {
                        string[] triggers       = tmp_command[3].Split('|');
                        int      command_access = Convert.ToInt32(tmp_command[5]);
                        string[] blacklist      = tmp_command[6].Split(',');
                        bool     blocked        = false;
                        bool     cmd_found      = false;
                        bool     spam_check     = Convert.ToBoolean(tmp_command[8]);
                        foreach (string bl_chan in blacklist)
                        {
                            if (bl_chan.Equals(channel))
                            {
                                blocked = true;
                                break;
                            }
                        }
                        if (spam_check == true)
                        {
                            blocked = ircbot.get_spam_status(channel, nick);
                        }
                        foreach (string trigger in triggers)
                        {
                            if (trigger.Equals(command))
                            {
                                cmd_found = true;
                                break;
                            }
                        }
                        if (blocked == true && cmd_found == true)
                        {
                            ircbot.sendData("NOTICE", nick + " :I am currently too busy to process that.");
                        }
                        if (blocked == false && cmd_found == true)
                        {
                            foreach (string trigger in triggers)
                            {
                                switch (trigger)
                                {
                                case "hbomb":
                                    if (spam_check == true)
                                    {
                                        ircbot.add_spam_count(channel);
                                    }
                                    if (nick_access >= command_access)
                                    {
                                        int module_index = 0;
                                        foreach (Modules.Module module in ircbot.module_list)
                                        {
                                            string module_type = module.GetType().ToString();
                                            if (module_type.Equals("IRCBot.Modules.idle"))
                                            {
                                                break;
                                            }
                                            else
                                            {
                                                module_index++;
                                            }
                                        }
                                        Modules.idle idle;
                                        if (module_index < ircbot.module_list.Count())
                                        {
                                            idle = (Modules.idle)ircbot.module_list[module_index];
                                        }
                                        else
                                        {
                                            idle = new Modules.idle();
                                        }
                                        if (idle.check_idle(nick) == false)
                                        {
                                            bool       hbomb_active = false;
                                            hbomb_info tmp_info     = new hbomb_info();
                                            foreach (hbomb_info bomb in hbombs)
                                            {
                                                if (bomb.bomb_channel.Equals(channel))
                                                {
                                                    tmp_info     = bomb;
                                                    hbomb_active = true;
                                                    break;
                                                }
                                            }
                                            if (hbomb_active == false)
                                            {
                                                tmp_info.bomb_locked  = false;
                                                tmp_info.bomb_trigger = new System.Timers.Timer();
                                                tmp_info.wire_colors  = ircbot.conf.module_config[module_id][3].Split(',');
                                                tmp_info.bomb_channel = channel;

                                                Random random_color = new Random();
                                                int    color_index  = random_color.Next(0, tmp_info.wire_colors.GetUpperBound(0) + 1);
                                                tmp_info.wire_color = tmp_info.wire_colors[color_index];

                                                Random random = new Random();
                                                int    index  = random.Next(10, 60);

                                                tmp_info.bomb_trigger.Elapsed  += (System, EventArgs) => activate_bomb(channel);
                                                tmp_info.bomb_trigger.Interval  = (index * 1000);
                                                tmp_info.bomb_trigger.Enabled   = true;
                                                tmp_info.bomb_trigger.AutoReset = false;

                                                main = ircbot;

                                                tmp_info.previous_bomb_holder = nick;
                                                tmp_info.bomb_holder          = nick;

                                                ircbot.sendData("PRIVMSG", channel + " :" + nick + " has started the timer!  If the bomb gets passed to you, type " + conf.command + "pass <nick> to pass it to someone else, or type " + conf.command + "defuse <color> to try to defuse it.");
                                                string colors = "";
                                                foreach (string wire in tmp_info.wire_colors)
                                                {
                                                    colors += wire + ",";
                                                }
                                                ircbot.sendData("NOTICE", nick + " :You need to hurry and pass the bomb before it blows up!  Or you can try to defuse it yourself.  The colors are: " + colors.TrimEnd(','));
                                                hbombs.Add(tmp_info);
                                            }
                                            else
                                            {
                                                if (tmp_info.bomb_channel.Equals(channel))
                                                {
                                                    ircbot.sendData("PRIVMSG", channel + " :There is already a bomb counting down.");
                                                }
                                                else
                                                {
                                                    ircbot.sendData("PRIVMSG", line[2] + " :There is already a bomb counting down in " + tmp_info.bomb_channel + ".");
                                                }
                                            }
                                        }
                                        else
                                        {
                                            ircbot.sendData("PRIVMSG", channel + " :You can not start a HBomb when you are idle.");
                                        }
                                    }
                                    else
                                    {
                                        ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command.");
                                    }
                                    break;

                                case "pass":
                                    if (spam_check == true)
                                    {
                                        ircbot.add_spam_count(channel);
                                    }
                                    if (nick_access >= command_access)
                                    {
                                        int        index        = 0;
                                        bool       hbomb_active = false;
                                        hbomb_info tmp_info     = new hbomb_info();
                                        foreach (hbomb_info bomb in hbombs)
                                        {
                                            if (bomb.bomb_channel.Equals(channel))
                                            {
                                                tmp_info     = bomb;
                                                hbomb_active = true;
                                                break;
                                            }
                                            index++;
                                        }
                                        if (hbomb_active == true)
                                        {
                                            if (!tmp_info.bomb_locked)
                                            {
                                                int module_index = 0;
                                                foreach (Modules.Module module in ircbot.module_list)
                                                {
                                                    string module_type = module.GetType().ToString();
                                                    if (module_type.Equals("IRCBot.Modules.idle"))
                                                    {
                                                        break;
                                                    }
                                                    else
                                                    {
                                                        module_index++;
                                                    }
                                                }
                                                Modules.idle idle;
                                                if (module_index < ircbot.module_list.Count())
                                                {
                                                    idle = (Modules.idle)ircbot.module_list[module_index];
                                                }
                                                else
                                                {
                                                    idle = new Modules.idle();
                                                }
                                                if (idle.check_idle(nick) == false)
                                                {
                                                    if (tmp_info.bomb_holder.Equals(nick))
                                                    {
                                                        if (line.GetUpperBound(0) > 3)
                                                        {
                                                            if (line[4].TrimEnd(' ').ToLower().Equals(conf.nick.ToLower()))
                                                            {
                                                                ircbot.sendData("PRIVMSG", channel + " :" + nick + ", you can't pass it to me!");
                                                            }
                                                            else
                                                            {
                                                                int user_access = ircbot.get_user_access(line[4].TrimEnd(' ').ToLower(), channel);
                                                                if (user_access > 0 && idle.check_idle(line[4].TrimEnd(' ').ToLower()) == false)
                                                                {
                                                                    pass_hbomb(line[4].TrimEnd(' ').ToLower(), channel, nick, ircbot, conf, ref tmp_info, index);
                                                                }
                                                                else
                                                                {
                                                                    ircbot.sendData("PRIVMSG", channel + " :" + nick + ", you can't pass to them!");
                                                                }
                                                            }
                                                        }
                                                        else
                                                        {
                                                            ircbot.sendData("PRIVMSG", channel + " :" + nick + ", you need to pass the bomb to someone.");
                                                        }
                                                    }
                                                    else
                                                    {
                                                        ircbot.sendData("PRIVMSG", channel + " :You don't have the bomb!");
                                                    }
                                                }
                                                else
                                                {
                                                    ircbot.sendData("PRIVMSG", channel + " :You can not pass the HBomb when you are idle.");
                                                }
                                            }
                                            else
                                            {
                                                ircbot.sendData("PRIVMSG", channel + " :You can not pass a locked bomb.");
                                            }
                                        }
                                        else
                                        {
                                            ircbot.sendData("PRIVMSG", channel + " :There isn't a bomb to pass!");
                                        }
                                    }
                                    else
                                    {
                                        ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command.");
                                    }
                                    break;

                                case "set_bomb":
                                    if (spam_check == true)
                                    {
                                        ircbot.add_spam_count(channel);
                                    }
                                    if (nick_access >= command_access)
                                    {
                                        int        index        = 0;
                                        bool       hbomb_active = false;
                                        hbomb_info tmp_info     = new hbomb_info();
                                        foreach (hbomb_info bomb in hbombs)
                                        {
                                            if (bomb.bomb_channel.Equals(channel))
                                            {
                                                tmp_info     = bomb;
                                                hbomb_active = true;
                                                break;
                                            }
                                            index++;
                                        }
                                        if (hbomb_active == true)
                                        {
                                            if (line.GetUpperBound(0) > 3)
                                            {
                                                if (line[4].TrimEnd(' ').ToLower().Equals(conf.nick.ToLower()))
                                                {
                                                    ircbot.sendData("PRIVMSG", channel + " :" + nick + ", you can't pass it to me!");
                                                }
                                                else
                                                {
                                                    int user_access = ircbot.get_user_access(line[4].TrimEnd(' ').ToLower(), channel);
                                                    if (user_access > 0)
                                                    {
                                                        pass_hbomb(line[4].TrimEnd(' ').ToLower(), channel, nick, ircbot, conf, ref tmp_info, index);
                                                    }
                                                    else
                                                    {
                                                        ircbot.sendData("PRIVMSG", channel + " :" + nick + ", that user isn't online!");
                                                    }
                                                }
                                            }
                                            else
                                            {
                                                ircbot.sendData("PRIVMSG", channel + " :" + nick + ", you need to pass the bomb to someone.");
                                            }
                                        }
                                        else
                                        {
                                            ircbot.sendData("PRIVMSG", channel + " :There isn't a bomb to pass!");
                                        }
                                    }
                                    else
                                    {
                                        ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command.");
                                    }
                                    break;

                                case "lock_bomb":
                                    if (spam_check == true)
                                    {
                                        ircbot.add_spam_count(channel);
                                    }
                                    if (nick_access >= command_access)
                                    {
                                        int        index        = 0;
                                        bool       hbomb_active = false;
                                        hbomb_info tmp_info     = new hbomb_info();
                                        foreach (hbomb_info bomb in hbombs)
                                        {
                                            if (bomb.bomb_channel.Equals(channel))
                                            {
                                                tmp_info     = bomb;
                                                hbomb_active = true;
                                                break;
                                            }
                                            index++;
                                        }
                                        if (hbomb_active == true)
                                        {
                                            if (line.GetUpperBound(0) > 3)
                                            {
                                                if (line[4].TrimEnd(' ').ToLower().Equals(conf.nick.ToLower()))
                                                {
                                                    ircbot.sendData("PRIVMSG", channel + " :" + nick + ", you can't pass it to me!");
                                                }
                                                else
                                                {
                                                    int user_access = ircbot.get_user_access(line[4].TrimEnd(' ').ToLower(), channel);
                                                    if (user_access > 0)
                                                    {
                                                        pass_hbomb(line[4].TrimEnd(' ').ToLower(), channel, nick, ircbot, conf, ref tmp_info, index);
                                                        tmp_info.bomb_locked = true;
                                                    }
                                                    else
                                                    {
                                                        ircbot.sendData("PRIVMSG", channel + " :" + nick + ", that user isn't online!");
                                                    }
                                                }
                                            }
                                            else
                                            {
                                                tmp_info.bomb_locked = true;
                                            }
                                        }
                                        else
                                        {
                                            ircbot.sendData("PRIVMSG", channel + " :There isn't a bomb to lock!");
                                        }
                                    }
                                    else
                                    {
                                        ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command.");
                                    }
                                    break;

                                case "unlock_bomb":
                                    if (spam_check == true)
                                    {
                                        ircbot.add_spam_count(channel);
                                    }
                                    if (nick_access >= command_access)
                                    {
                                        int        index        = 0;
                                        bool       hbomb_active = false;
                                        hbomb_info tmp_info     = new hbomb_info();
                                        foreach (hbomb_info bomb in hbombs)
                                        {
                                            if (bomb.bomb_channel.Equals(channel))
                                            {
                                                tmp_info     = bomb;
                                                hbomb_active = true;
                                                break;
                                            }
                                            index++;
                                        }
                                        if (hbomb_active == true)
                                        {
                                            tmp_info.bomb_locked = false;
                                            hbombs[index]        = tmp_info;
                                        }
                                        else
                                        {
                                            ircbot.sendData("PRIVMSG", channel + " :There isn't a bomb to unlock!");
                                        }
                                    }
                                    else
                                    {
                                        ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command.");
                                    }
                                    break;

                                case "detonate":
                                    if (spam_check == true)
                                    {
                                        ircbot.add_spam_count(channel);
                                    }
                                    if (nick_access >= command_access)
                                    {
                                        bool hbomb_active = false;
                                        foreach (hbomb_info bomb in hbombs)
                                        {
                                            if (bomb.bomb_channel.Equals(channel))
                                            {
                                                hbomb_active = true;
                                                break;
                                            }
                                        }
                                        if (hbomb_active == true)
                                        {
                                            main = ircbot;
                                            activate_bomb(channel);
                                        }
                                        else
                                        {
                                            ircbot.sendData("PRIVMSG", channel + " :There isn't a bomb to blow up!");
                                        }
                                    }
                                    else
                                    {
                                        ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command.");
                                    }
                                    break;

                                case "stop_bomb":
                                    if (spam_check == true)
                                    {
                                        ircbot.add_spam_count(channel);
                                    }
                                    if (nick_access >= command_access)
                                    {
                                        int        index        = 0;
                                        bool       hbomb_active = false;
                                        hbomb_info tmp_info     = new hbomb_info();
                                        foreach (hbomb_info bomb in hbombs)
                                        {
                                            if (bomb.bomb_channel.Equals(channel))
                                            {
                                                tmp_info     = bomb;
                                                hbomb_active = true;
                                                break;
                                            }
                                            index++;
                                        }
                                        if (hbomb_active == true)
                                        {
                                            hbombs.RemoveAt(index);
                                            ircbot.sendData("PRIVMSG", channel + " :Bomb has been defused and thrown away.");
                                        }
                                        else
                                        {
                                            ircbot.sendData("PRIVMSG", channel + " :There isn't a bomb to stop!");
                                        }
                                    }
                                    else
                                    {
                                        ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command.");
                                    }
                                    break;

                                case "defuse":
                                    if (spam_check == true)
                                    {
                                        ircbot.add_spam_count(channel);
                                    }
                                    if (nick_access >= command_access)
                                    {
                                        int        index        = 0;
                                        bool       hbomb_active = false;
                                        hbomb_info tmp_info     = new hbomb_info();
                                        foreach (hbomb_info bomb in hbombs)
                                        {
                                            if (bomb.bomb_channel.Equals(channel))
                                            {
                                                tmp_info     = bomb;
                                                hbomb_active = true;
                                                break;
                                            }
                                            index++;
                                        }
                                        if (hbomb_active == true)
                                        {
                                            if (!tmp_info.bomb_locked)
                                            {
                                                int module_index = 0;
                                                foreach (Modules.Module module in ircbot.module_list)
                                                {
                                                    string module_type = module.GetType().ToString();
                                                    if (module_type.Equals("IRCBot.Modules.idle"))
                                                    {
                                                        break;
                                                    }
                                                    else
                                                    {
                                                        module_index++;
                                                    }
                                                }
                                                Modules.idle idle;
                                                if (module_index < ircbot.module_list.Count())
                                                {
                                                    idle = (Modules.idle)ircbot.module_list[module_index];
                                                }
                                                else
                                                {
                                                    idle = new Modules.idle();
                                                }
                                                if (idle.check_idle(nick) == false)
                                                {
                                                    if (tmp_info.bomb_holder.Equals(nick))
                                                    {
                                                        if (line.GetUpperBound(0) > 3)
                                                        {
                                                            if (line[4].ToLower().Equals(tmp_info.wire_color.ToLower()))
                                                            {
                                                                ircbot.sendData("PRIVMSG", channel + " :You have successfully defused the bomb!");
                                                                if (tmp_info.previous_bomb_holder.Equals(tmp_info.bomb_holder))
                                                                {
                                                                }
                                                                else
                                                                {
                                                                    ircbot.sendData("KICK", tmp_info.bomb_channel + " " + tmp_info.previous_bomb_holder + " :BOOM!!!");
                                                                }
                                                                hbombs.RemoveAt(index);
                                                            }
                                                            else
                                                            {
                                                                main = ircbot;
                                                                activate_bomb(channel);
                                                            }
                                                        }
                                                        else
                                                        {
                                                            ircbot.sendData("PRIVMSG", channel + " :" + nick + ", you need to cut a wire.");
                                                        }
                                                    }
                                                    else
                                                    {
                                                        ircbot.sendData("PRIVMSG", channel + " :You don't have the bomb!");
                                                    }
                                                }
                                                else
                                                {
                                                    ircbot.sendData("PRIVMSG", channel + " :You can not defuse the HBomb when you are idle.");
                                                }
                                            }
                                            else
                                            {
                                                ircbot.sendData("PRIVMSG", channel + " :You can not defuse the HBomb when it is locked.");
                                            }
                                        }
                                        else
                                        {
                                            ircbot.sendData("PRIVMSG", channel + " :There isn't a bomb to defuse!");
                                        }
                                    }
                                    else
                                    {
                                        ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command.");
                                    }
                                    break;
                                }
                            }
                        }
                    }
                }
            }
        }
Esempio n. 55
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 "weather":
                                if (this.Options["allow_weather"])
                                {
                                    if (spam_check == true)
                                    {
                                        ircbot.add_spam_count(channel);
                                    }
                                    if (nick_access >= tmp_command.Access)
                                    {
                                        if (line.GetUpperBound(0) > 3)
                                        {
                                            // Add introduction
                                            get_weather(line[4], channel, ircbot);
                                        }
                                        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 "forecast":
                                if (this.Options["allow_forecast"])
                                {
                                    if (spam_check == true)
                                    {
                                        ircbot.add_spam_count(channel);
                                    }
                                    if (nick_access >= tmp_command.Access)
                                    {
                                        if (line.GetUpperBound(0) > 3)
                                        {
                                            // Add introduction
                                            get_forecast(line[4], channel, ircbot, Convert.ToInt32(this.Options["forecast_days"]));
                                        }
                                        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;
                            }
                        }
                    }
                }
            }
        }
Esempio n. 56
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") && 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);
            }
        }
Esempio n. 57
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") && 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;
                            }
                        }
                    }
                }
            }
        }
Esempio n. 58
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 "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;
                            }
                        }
                    }
                }
            }
        }
Esempio n. 59
0
        public override void control(bot ircbot, ref IRCConfig conf, int module_id, string[] line, string command, int nick_access, string nick, string channel, bool bot_command, string type)
        {
            string module_name = ircbot.conf.module_config[module_id][0];

            if (type.Equals("channel") || type.Equals("query") && bot_command == true)
            {
                foreach (List <string> tmp_command in conf.command_list)
                {
                    if (module_name.Equals(tmp_command[0]))
                    {
                        string[] triggers       = tmp_command[3].Split('|');
                        int      command_access = Convert.ToInt32(tmp_command[5]);
                        string[] blacklist      = tmp_command[6].Split(',');
                        bool     blocked        = false;
                        bool     cmd_found      = false;
                        bool     spam_check     = Convert.ToBoolean(tmp_command[8]);
                        foreach (string bl_chan in blacklist)
                        {
                            if (bl_chan.Equals(channel))
                            {
                                blocked = true;
                                break;
                            }
                        }
                        if (spam_check == true)
                        {
                            blocked = ircbot.get_spam_status(channel, nick);
                        }
                        foreach (string trigger in triggers)
                        {
                            if (trigger.Equals(command))
                            {
                                cmd_found = true;
                                break;
                            }
                        }
                        if (blocked == true && cmd_found == true)
                        {
                            ircbot.sendData("NOTICE", nick + " :I am currently too busy to process that.");
                        }
                        if (blocked == false && cmd_found == true)
                        {
                            foreach (string trigger in triggers)
                            {
                                switch (trigger)
                                {
                                case "addresponse":
                                    if (spam_check == true)
                                    {
                                        ircbot.add_spam_count(channel);
                                    }
                                    if (nick_access >= command_access)
                                    {
                                        if (line.GetUpperBound(0) > 3)
                                        {
                                            string list_file = ircbot.cur_dir + Path.DirectorySeparatorChar + "modules" + Path.DirectorySeparatorChar + "Response" + Path.DirectorySeparatorChar + "dictionary.txt";
                                            if (Directory.Exists(ircbot.cur_dir + Path.DirectorySeparatorChar + "modules" + Path.DirectorySeparatorChar + "Response" + Path.DirectorySeparatorChar + "") == false)
                                            {
                                                Directory.CreateDirectory(ircbot.cur_dir + Path.DirectorySeparatorChar + "modules" + Path.DirectorySeparatorChar + "Response");
                                            }
                                            if (File.Exists(ircbot.cur_dir + Path.DirectorySeparatorChar + "modules" + Path.DirectorySeparatorChar + "Response" + Path.DirectorySeparatorChar + "dictionary.txt"))
                                            {
                                                StreamWriter log = File.AppendText(ircbot.cur_dir + Path.DirectorySeparatorChar + "modules" + Path.DirectorySeparatorChar + "Response" + Path.DirectorySeparatorChar + "dictionary.txt");
                                                log.WriteLine(line[4]);
                                                log.Close();
                                            }
                                            else
                                            {
                                                StreamWriter log_file = File.CreateText(ircbot.cur_dir + Path.DirectorySeparatorChar + "modules" + Path.DirectorySeparatorChar + "Response" + Path.DirectorySeparatorChar + "dictionary.txt");
                                                log_file.WriteLine(line[4]);
                                                log_file.Close();
                                            }
                                            ircbot.sendData("PRIVMSG", channel + " :Response added successfully");
                                        }
                                        else
                                        {
                                            ircbot.sendData("NOTICE", nick + " :" + nick + ", you need to include more info.");
                                        }
                                    }
                                    else
                                    {
                                        ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command.");
                                    }
                                    break;
                                }
                            }
                        }
                    }
                }
            }
            if (type.Equals("channel") && bot_command == false)
            {
                if (nick != conf.nick)
                {
                    try
                    {
                        string[] file;
                        string   list_file = ircbot.cur_dir + Path.DirectorySeparatorChar + "modules" + Path.DirectorySeparatorChar + "Response" + Path.DirectorySeparatorChar + "dictionary.txt";
                        if (File.Exists(list_file))
                        {
                            file = System.IO.File.ReadAllLines(list_file);
                        }
                        else
                        {
                            file = null;
                        }

                        string tmp_line = line[3];
                        if (line.GetUpperBound(0) > 3)
                        {
                            tmp_line += " " + line[4];
                        }
                        tmp_line = tmp_line.Remove(0, 1);
                        string new_line  = tmp_line.ToLowerInvariant();
                        bool   triggered = false;
                        if (file.GetUpperBound(0) >= 0)
                        {
                            foreach (string tmp_new_line in file)
                            {
                                string file_line = tmp_new_line.Replace("<nick>", nick);
                                file_line = file_line.Replace("<me>", conf.nick);
                                char[]   split_type      = new char[] { ':' };
                                char[]   trigger_split   = new char[] { '*' };
                                char[]   triggered_split = new char[] { '&' };
                                string[] split           = file_line.Split(split_type, 2);
                                string[] triggers        = split[0].Split('|');
                                string[] responses       = split[1].Split('|');
                                int      index           = 0;
                                for (int x = 0; x <= triggers.GetUpperBound(0); x++)
                                {
                                    string[] terms = triggers[x].Split(trigger_split, StringSplitOptions.RemoveEmptyEntries);
                                    for (int y = 0; y <= terms.GetUpperBound(0); y++)
                                    {
                                        triggered = false;
                                        terms[y]  = terms[y].ToLowerInvariant();
                                        if (triggers[x].StartsWith("*") == false && triggers[x].EndsWith("*") == false && terms.GetUpperBound(0) == 0)
                                        {
                                            if (new_line.Equals(terms[y]) == true)
                                            {
                                                triggered = true;
                                            }
                                            else
                                            {
                                                triggered = false;
                                                break;
                                            }
                                        }
                                        else if (triggers[x].StartsWith("*") == false && y == 0)
                                        {
                                            if (new_line.StartsWith(terms[y]) == true && index <= new_line.IndexOf(terms[y]))
                                            {
                                                triggered = true;
                                                index     = new_line.IndexOf(terms[y]);
                                            }
                                            else
                                            {
                                                triggered = false;
                                                break;
                                            }
                                        }
                                        else if (triggers[x].EndsWith("*") == false && y == terms.GetUpperBound(0))
                                        {
                                            if (new_line.EndsWith(terms[y]) == true && index <= new_line.IndexOf(terms[y]))
                                            {
                                                triggered = true;
                                                index     = new_line.IndexOf(terms[y]);
                                            }
                                            else
                                            {
                                                triggered = false;
                                                break;
                                            }
                                        }
                                        else
                                        {
                                            if (new_line.Contains(terms[y]) == true && index <= new_line.IndexOf(terms[y]))
                                            {
                                                triggered = true;
                                                index     = new_line.IndexOf(terms[y]);
                                            }
                                            else
                                            {
                                                triggered = false;
                                                break;
                                            }
                                        }
                                    }
                                    if (triggered == true)
                                    {
                                        break;
                                    }
                                }
                                if (triggered == true)
                                {
                                    ircbot.add_spam_count(channel);
                                    int    number_of_responses = responses.GetUpperBound(0) + 1;
                                    Random random = new Random();
                                    index = random.Next(0, number_of_responses);
                                    string[] events = responses[index].Split(triggered_split, StringSplitOptions.RemoveEmptyEntries);
                                    for (int y = 0; y <= events.GetUpperBound(0); y++)
                                    {
                                        if (events[y].StartsWith("<action>") == true)
                                        {
                                            ircbot.sendData("PRIVMSG", channel + " :\u0001ACTION " + events[y].Remove(0, 8) + "\u0001");
                                        }
                                        else if (events[y].StartsWith("<delay>") == true)
                                        {
                                            Thread.Sleep(Convert.ToInt32(events[y].Remove(0, 7)));
                                        }
                                        else if (events[y].StartsWith("<part>") == true)
                                        {
                                            ircbot.sendData("PART", channel);
                                        }
                                        else if (events[y].StartsWith("<join>") == true)
                                        {
                                            ircbot.sendData("JOIN", channel);
                                        }
                                        else if (events[y].StartsWith("<kick>") == true)
                                        {
                                            if (events[y].Length > 6)
                                            {
                                                ircbot.sendData("KICK", channel + " " + nick + " :" + events[y].Remove(0, 6));
                                            }
                                            else
                                            {
                                                ircbot.sendData("KICK", channel + " " + nick + " :No Reason");
                                            }
                                        }
                                        else if (events[y].StartsWith("<ban>") == true)
                                        {
                                            string target_host = ircbot.get_user_host(nick);
                                            string ban         = "*!*@" + target_host;
                                            if (target_host.Equals("was"))
                                            {
                                                ban = nick + "!*@*";
                                            }
                                            if (events[y].Length > 6)
                                            {
                                                ircbot.sendData("MODE", channel + " +b " + ban + " :" + events[y].Remove(0, 6));
                                            }
                                            else
                                            {
                                                ircbot.sendData("MODE", channel + " +b " + ban + " :No Reason");
                                            }
                                        }
                                        else if (events[y].StartsWith("<kickban>") == true)
                                        {
                                            string target_host = ircbot.get_user_host(nick);
                                            string ban         = "*!*@" + target_host;
                                            if (target_host.Equals("was"))
                                            {
                                                ban = nick + "!*@*";
                                            }
                                            if (events[y].Length > 6)
                                            {
                                                ircbot.sendData("MODE", channel + " +b " + ban + " :" + events[y].Remove(0, 6));
                                                ircbot.sendData("KICK", channel + " " + nick + " :" + events[y].Remove(0, 6));
                                            }
                                            else
                                            {
                                                ircbot.sendData("MODE", channel + " +b " + ban + " :No Reason");
                                                ircbot.sendData("KICK", channel + " " + nick + " :No Reason");
                                            }
                                        }
                                        else if (events[y].StartsWith("<timeban>") == true)
                                        {
                                            string[]           mod_line = new string[] { conf.nick, "0", channel, ":tb", events[y].Remove(0, 9) };
                                            Modules.moderation mod      = new Modules.moderation();
                                            mod.control(ircbot, ref conf, module_id, mod_line, "tb", conf.owner_level, nick, channel, true, "channel");
                                        }
                                        else if (events[y].StartsWith("<timekickban>") == true)
                                        {
                                            string[]           mod_line = new string[] { conf.nick, "0", channel, ":tkb", events[y].Remove(0, 13) };
                                            Modules.moderation mod      = new Modules.moderation();
                                            mod.control(ircbot, ref conf, module_id, mod_line, "tkb", conf.owner_level, nick, channel, true, "channel");
                                        }
                                        else
                                        {
                                            ircbot.sendData("PRIVMSG", channel + " :" + events[y]);
                                        }
                                    }
                                    break;
                                }
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        ircbot.sendData("PRIVMSG", channel + " :" + ex.ToString());
                    }
                }
            }
        }
Esempio n. 60
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 "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;
                     }
                 }
             }
         }
     }
 }