Пример #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;
                     }
                 }
             }
         }
     }
 }
Пример #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;
                     }
                 }
             }
         }
     }
 }
Пример #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;
                     }
                 }
             }
         }
     }
 }
Пример #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);
     }
 }
Пример #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);
     }
 }
Пример #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;
                     }
                 }
             }
         }
     }
 }
Пример #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;
                     }
                 }
             }
         }
     }
 }
Пример #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;
                     }
                 }
             }
         }
     }
 }
Пример #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") || 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 "idle":
                             if (spam_check == true)
                             {
                                 ircbot.add_spam_count(channel);
                             }
                             if (nick_access >= tmp_command.Access)
                             {
                                 if (check_idle(nick) == false)
                                 {
                                     idle_list.Add(nick);
                                     ircbot.sendData("NOTICE", nick + " :You are now set as idle.  Type " + ircbot.Conf.Command + "deidle to come back.");
                                 }
                                 else
                                 {
                                     ircbot.sendData("NOTICE", nick + " :You are already idle.  Type " + ircbot.Conf.Command + "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 >= tmp_command.Access)
                             {
                                 if (check_idle(nick) == true)
                                 {
                                     idle_list.Remove(nick);
                                     ircbot.sendData("NOTICE", nick + " :Welcome back!");
                                 }
                                 else
                                 {
                                     ircbot.sendData("NOTICE", nick + " :You aren't idle.  Type " + ircbot.Conf.Command + "idle to be set idle.");
                                 }
                             }
                             else
                             {
                                 ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command.");
                             }
                             break;
                     }
                 }
             }
         }
     }
 }
Пример #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 "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);
            }
        }
Пример #11
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;
                     }
                 }
             }
         }
     }
 }
Пример #12
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;
                            }
                        }
                    }
                }
            }
        }
Пример #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") && 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);
     }
 }
Пример #14
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);
                 }
             }
         }
     }
 }
Пример #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 "roll":
                         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].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(this.Options["max_dice"]))
                                     {
                                         num_dice = Convert.ToInt32(this.Options["max_dice"]);
                                     }
                                     if (num_sides > Convert.ToInt32(this.Options["max_sides"]))
                                     {
                                         num_sides = Convert.ToInt32(this.Options["max_sides"]);
                                     }
                                     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(this.Options["max_dice"]))
                                     {
                                         num_dice = Convert.ToInt32(this.Options["max_dice"]);
                                     }
                                     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;
                     }
                 }
             }
         }
     }
 }
Пример #16
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;
                            }
                        }
                    }
                }
            }
        }
Пример #17
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;
                            }
                        }
                    }
                }
            }
        }
Пример #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;
                     }
                 }
             }
         }
     }
 }
Пример #19
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 "stopchat":
                         if (spam_check == true)
                         {
                             ircbot.add_spam_count(channel);
                         }
                         if (nick_access >= tmp_command.Access)
                         {
                             foreach (string chat_nick in chatting_nick)
                             {
                                 if (chat_nick.Equals(nick, StringComparison.InvariantCultureIgnoreCase))
                                 {
                                     still_chatting = false;
                                     chatting_nick.Clear();
                                     chat_time.Enabled = false;
                                     chat_time.Stop();
                                     ircbot.sendData("PRIVMSG", line[2] + " :Ok, I will stop.");
                                     break;
                                 }
                             }
                             if (still_chatting == true)
                             {
                                 ircbot.sendData("PRIVMSG", line[2] + " :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") || type.Equals("query")) && bot_command == false)
     {
         chat_time.Interval = Convert.ToInt32(this.Options["chat_timeout"]) * 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.Contains(Conf.Nick))
                 {
                     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, StringComparison.InvariantCultureIgnoreCase))
                     {
                         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);
                     string  owners = "";
                     foreach (string own in Conf.Owners)
                     {
                         owners += Conf.Owners + ",";
                     }
                     owners = owners.TrimEnd(',').Replace(",", " and ");
                     ircbot.sendData("PRIVMSG", line[2] + " :" + res.Output.Replace("[nick]", nick).Replace("[me]", Conf.Nick).Replace("[owner]", owners).Replace("[version]", Assembly.GetExecutingAssembly().GetName().Version.ToString()).Replace("\n", " "));
                     chat_time.Start();
                     still_chatting = true;
                 }
             }
         }
     }
 }
Пример #20
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 "poll":
                                if (spam_check == true)
                                {
                                    ircbot.add_spam_count(channel);
                                }
                                if (nick_access >= tmp_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)
                                        {
                                            string[] lines = line[4].Split('|');
                                            if (lines.GetUpperBound(0) > 0)
                                            {
                                                poll_info temp_poll = new poll_info();
                                                poll_active              = true;
                                                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 " + ircbot.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", 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 " + ircbot.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 >= tmp_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, StringComparison.InvariantCultureIgnoreCase))
                                        {
                                            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 >= tmp_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, StringComparison.InvariantCultureIgnoreCase))
                                        {
                                            if (line.GetUpperBound(0) > 3)
                                            {
                                                for (int x = 0; x < cur_poll.answers.Count(); x++)
                                                {
                                                    if (x == (Convert.ToInt32(line[4]) - 1))
                                                    {
                                                        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 >= tmp_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, StringComparison.InvariantCultureIgnoreCase) || nick_access > Convert.ToInt32(ircbot.get_nick_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 >= tmp_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 >= tmp_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_nick_host(nick);
                                                    if (String.IsNullOrEmpty(nick_host))
                                                    {
                                                        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;
                            }
                        }
                    }
                }
            }
        }
Пример #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") || 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);
                    }
                }
            }
        }
Пример #22
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;
                            }
                        }
                    }
                }
            }
        }
Пример #23
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);
            }
        }
Пример #24
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)
        {
            access access = new access();

            char[] charS = new char[] { ' ' };
            string disallowed_modes = this.Options["disallowed_modes"];
            if (type.Equals("channel") && bot_command == true)
            {
                foreach (Command tmp_command in this.Commands)
                {
                    bool blocked = tmp_command.Blacklist.Contains(channel) || tmp_command.Blacklist.Contains(nick);
                    bool cmd_found = false;
                    bool spam_check = ircbot.get_spam_check(channel, nick, tmp_command.Spam_Check);
                    if (spam_check == true)
                    {
                        blocked = blocked || ircbot.get_spam_status(channel);
                    }
                    cmd_found = tmp_command.Triggers.Contains(command);
                    if (blocked == true && cmd_found == true)
                    {
                        ircbot.sendData("NOTICE", nick + " :I am currently too busy to process that.");
                    }
                    if (blocked == false && cmd_found == true)
                    {
                        foreach (string trigger in tmp_command.Triggers)
                        {
                            switch (trigger)
                            {
                                case "founder":
                                    if (spam_check == true)
                                    {
                                        ircbot.add_spam_count(channel);
                                    }
                                    if (nick_access >= tmp_command.Access)
                                    {
                                        if (line.GetUpperBound(0) > 3)
                                        {
                                            ircbot.sendData("MODE", line[2] + " +q " + line[4]);
                                            access.set_access_list(line[4], line[2], Conf.Founder_Level.ToString(), ircbot);
                                        }
                                        else
                                        {
                                            ircbot.sendData("PRIVMSG", line[2] + " :" + nick + ", you need to include more info.");
                                        }
                                    }
                                    else
                                    {
                                        ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command.");
                                    }
                                    break;
                                case "defounder":
                                    if (spam_check == true)
                                    {
                                        ircbot.add_spam_count(channel);
                                    }
                                    if (nick_access >= tmp_command.Access)
                                    {
                                        if (line.GetUpperBound(0) > 3)
                                        {
                                            ircbot.sendData("MODE", line[2] + " -q " + line[4]);
                                            access.del_access_list(line[4], line[2], Conf.Founder_Level.ToString(), ircbot);
                                        }
                                        else
                                        {
                                            ircbot.sendData("PRIVMSG", line[2] + " :" + nick + ", you need to include more info.");
                                        }
                                    }
                                    else
                                    {
                                        ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command.");
                                    }
                                    break;
                                case "sop":
                                    if (spam_check == true)
                                    {
                                        ircbot.add_spam_count(channel);
                                    }
                                    if (nick_access >= tmp_command.Access)
                                    {
                                        if (line.GetUpperBound(0) > 3)
                                        {
                                            ircbot.sendData("MODE", line[2] + " +a " + line[4]);
                                            access.set_access_list(line[4], line[2], Conf.Sop_Level.ToString(), ircbot);
                                        }
                                        else
                                        {
                                            ircbot.sendData("PRIVMSG", line[2] + " :" + nick + ", you need to include more info.");
                                        }
                                    }
                                    else
                                    {
                                        ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command.");
                                    }
                                    break;
                                case "asop":
                                    if (spam_check == true)
                                    {
                                        ircbot.add_spam_count(channel);
                                    }
                                    if (nick_access >= tmp_command.Access)
                                    {
                                        if (line.GetUpperBound(0) > 3)
                                        {
                                            ircbot.sendData("MODE", line[2] + " +a " + line[4]);
                                            ircbot.sendData("PRIVMSG", "chanserv :SOP " + line[2] + " add " + line[4]);
                                            access.set_access_list(line[4], line[2], Conf.Sop_Level.ToString(), ircbot);
                                        }
                                        else
                                        {
                                            ircbot.sendData("PRIVMSG", line[2] + " :" + nick + ", you need to include more info.");
                                        }
                                    }
                                    else
                                    {
                                        ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command.");
                                    }
                                    break;
                                case "deasop":
                                    if (spam_check == true)
                                    {
                                        ircbot.add_spam_count(channel);
                                    }
                                    if (nick_access >= tmp_command.Access)
                                    {
                                        if (line.GetUpperBound(0) > 3)
                                        {
                                            ircbot.sendData("MODE", line[2] + " -a " + line[4]);
                                            ircbot.sendData("PRIVMSG", "chanserv :SOP " + line[2] + " del " + line[4]);
                                            access.del_access_list(line[4], line[2], Conf.Sop_Level.ToString(), ircbot);
                                        }
                                        else
                                        {
                                            ircbot.sendData("PRIVMSG", line[2] + " :" + nick + ", you need to include more info.");
                                        }
                                    }
                                    else
                                    {
                                        ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command.");
                                    }
                                    break;
                                case "desop":
                                    if (spam_check == true)
                                    {
                                        ircbot.add_spam_count(channel);
                                    }
                                    if (nick_access >= tmp_command.Access)
                                    {
                                        if (line.GetUpperBound(0) > 3)
                                        {
                                            ircbot.sendData("MODE", line[2] + " -a " + line[4]);
                                            access.del_access_list(line[4], line[2], Conf.Sop_Level.ToString(), ircbot);
                                        }
                                        else
                                        {
                                            ircbot.sendData("PRIVMSG", line[2] + " :" + nick + ", you need to include more info.");
                                        }
                                    }
                                    else
                                    {
                                        ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command.");
                                    }
                                    break;
                                case "op":
                                    if (spam_check == true)
                                    {
                                        ircbot.add_spam_count(channel);
                                    }
                                    if (nick_access >= tmp_command.Access)
                                    {
                                        if (line.GetUpperBound(0) > 3)
                                        {
                                            ircbot.sendData("MODE", line[2] + " +o " + line[4]);
                                            access.set_access_list(line[4], line[2], Conf.Op_Level.ToString(), ircbot);
                                        }
                                        else
                                        {
                                            ircbot.sendData("PRIVMSG", line[2] + " :" + nick + ", you need to include more info.");
                                        }
                                    }
                                    else
                                    {
                                        ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command.");
                                    }
                                    break;
                                case "aop":
                                    if (spam_check == true)
                                    {
                                        ircbot.add_spam_count(channel);
                                    }
                                    if (nick_access >= tmp_command.Access)
                                    {
                                        if (line.GetUpperBound(0) > 3)
                                        {
                                            ircbot.sendData("MODE", line[2] + " +o " + line[4]);
                                            if (!ircbot.get_nick_auto("SOP", line[2], line[4]))
                                            {
                                                ircbot.sendData("PRIVMSG", "chanserv :AOP " + line[2] + " add " + line[4]);
                                            }
                                            access.set_access_list(line[4], line[2], Conf.Op_Level.ToString(), ircbot);
                                        }
                                        else
                                        {
                                            ircbot.sendData("PRIVMSG", line[2] + " :" + nick + ", you need to include more info.");
                                        }
                                    }
                                    else
                                    {
                                        ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command.");
                                    }
                                    break;
                                case "deaop":
                                    if (spam_check == true)
                                    {
                                        ircbot.add_spam_count(channel);
                                    }
                                    if (nick_access >= tmp_command.Access)
                                    {
                                        if (line.GetUpperBound(0) > 3)
                                        {
                                            ircbot.sendData("MODE", line[2] + " -o " + line[4]);
                                            ircbot.sendData("PRIVMSG", "chanserv :AOP " + line[2] + " del " + line[4]);
                                            access.del_access_list(line[4], line[2], Conf.Op_Level.ToString(), ircbot);
                                        }
                                        else
                                        {
                                            ircbot.sendData("PRIVMSG", line[2] + " :" + nick + ", you need to include more info.");
                                        }
                                    }
                                    else
                                    {
                                        ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command.");
                                    }
                                    break;
                                case "deop":
                                    if (spam_check == true)
                                    {
                                        ircbot.add_spam_count(channel);
                                    }
                                    if (nick_access >= tmp_command.Access)
                                    {
                                        if (line.GetUpperBound(0) > 3)
                                        {
                                            ircbot.sendData("MODE", line[2] + " -o " + line[4]);
                                            access.del_access_list(line[4], line[2], Conf.Op_Level.ToString(), ircbot);
                                        }
                                        else
                                        {
                                            ircbot.sendData("PRIVMSG", line[2] + " :" + nick + ", you need to include more info.");
                                        }
                                    }
                                    else
                                    {
                                        ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command.");
                                    }
                                    break;
                                case "ahop":
                                    if (spam_check == true)
                                    {
                                        ircbot.add_spam_count(channel);
                                    }
                                    if (nick_access >= tmp_command.Access)
                                    {
                                        if (line.GetUpperBound(0) > 3)
                                        {
                                            ircbot.sendData("MODE", line[2] + " +h " + line[4]);
                                            if (!ircbot.get_nick_auto("AOP", line[2], line[4]) && !ircbot.get_nick_auto("SOP", line[2], line[4]))
                                            {
                                                ircbot.sendData("PRIVMSG", "chanserv :HOP " + line[2] + " add " + line[4]);
                                            }
                                            access.set_access_list(line[4], line[2], Conf.Hop_Level.ToString(), ircbot);
                                        }
                                        else
                                        {
                                            ircbot.sendData("PRIVMSG", line[2] + " :" + nick + ", you need to include more info.");
                                        }
                                    }
                                    else
                                    {
                                        ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command.");
                                    }
                                    break;
                                case "deahop":
                                    if (spam_check == true)
                                    {
                                        ircbot.add_spam_count(channel);
                                    }
                                    if (nick_access >= tmp_command.Access)
                                    {
                                        if (line.GetUpperBound(0) > 3)
                                        {
                                            ircbot.sendData("MODE", line[2] + " -h " + line[4]);
                                            ircbot.sendData("PRIVMSG", "chanserv :HOP " + line[2] + " del " + line[4]);
                                            access.del_access_list(line[4], line[2], Conf.Hop_Level.ToString(), ircbot);
                                        }
                                        else
                                        {
                                            ircbot.sendData("PRIVMSG", line[2] + " :" + nick + ", you need to include more info.");
                                        }
                                    }
                                    else
                                    {
                                        ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command.");
                                    }
                                    break;
                                case "hop":
                                    if (spam_check == true)
                                    {
                                        ircbot.add_spam_count(channel);
                                    }
                                    if (nick_access >= tmp_command.Access)
                                    {
                                        if (line.GetUpperBound(0) > 3)
                                        {
                                            ircbot.sendData("MODE", line[2] + " +h " + line[4]);
                                            access.set_access_list(line[4], line[2], Conf.Hop_Level.ToString(), ircbot);
                                        }
                                        else
                                        {
                                            ircbot.sendData("PRIVMSG", line[2] + " :" + nick + ", you need to include more info.");
                                        }
                                    }
                                    else
                                    {
                                        ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command.");
                                    }
                                    break;
                                case "dehop":
                                    if (spam_check == true)
                                    {
                                        ircbot.add_spam_count(channel);
                                    }
                                    if (nick_access >= tmp_command.Access)
                                    {
                                        if (line.GetUpperBound(0) > 3)
                                        {
                                            ircbot.sendData("MODE", line[2] + " -h " + line[4]);
                                            access.del_access_list(line[4], line[2], Conf.Hop_Level.ToString(), ircbot);
                                        }
                                        else
                                        {
                                            ircbot.sendData("PRIVMSG", line[2] + " :" + nick + ", you need to include more info.");
                                        }
                                    }
                                    else
                                    {
                                        ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command.");
                                    }
                                    break;
                                case "avoice":
                                    if (spam_check == true)
                                    {
                                        ircbot.add_spam_count(channel);
                                    }
                                    if (nick_access >= tmp_command.Access)
                                    {
                                        if (line.GetUpperBound(0) > 3)
                                        {
                                            ircbot.sendData("MODE", line[2] + " +v " + line[4]);
                                            if (!ircbot.get_nick_auto("AOP", line[2], line[4]) && !ircbot.get_nick_auto("SOP", line[2], line[4]) && !ircbot.get_nick_auto("VOP", line[2], line[4]))
                                            {
                                                ircbot.sendData("PRIVMSG", "chanserv :VOP " + line[2] + " add " + line[4]);
                                            }
                                            access.set_access_list(line[4], line[2], Conf.Voice_Level.ToString(), ircbot);
                                        }
                                        else
                                        {
                                            ircbot.sendData("PRIVMSG", line[2] + " :" + nick + ", you need to include more info.");
                                        }
                                    }
                                    else
                                    {
                                        ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command.");
                                    }
                                    break;
                                case "deavoice":
                                    if (spam_check == true)
                                    {
                                        ircbot.add_spam_count(channel);
                                    }
                                    if (nick_access >= tmp_command.Access)
                                    {
                                        if (line.GetUpperBound(0) > 3)
                                        {
                                            ircbot.sendData("MODE", line[2] + " -v " + line[4]);
                                            ircbot.sendData("PRIVMSG", "chanserv :VOP " + line[2] + " del " + line[4]);
                                            access.del_access_list(line[4], line[2], Conf.Voice_Level.ToString(), ircbot);
                                        }
                                        else
                                        {
                                            ircbot.sendData("PRIVMSG", line[2] + " :" + nick + ", you need to include more info.");
                                        }
                                    }
                                    else
                                    {
                                        ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command.");
                                    }
                                    break;
                                case "voice":
                                    if (spam_check == true)
                                    {
                                        ircbot.add_spam_count(channel);
                                    }
                                    if (nick_access >= tmp_command.Access)
                                    {
                                        if (line.GetUpperBound(0) > 3)
                                        {
                                            ircbot.sendData("MODE", line[2] + " +v " + line[4]);
                                            access.set_access_list(line[4], line[2], Conf.Voice_Level.ToString(), ircbot);
                                        }
                                        else
                                        {
                                            ircbot.sendData("PRIVMSG", line[2] + " :" + nick + ", you need to include more info.");
                                        }
                                    }
                                    else
                                    {
                                        ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command.");
                                    }
                                    break;
                                case "devoice":
                                    if (spam_check == true)
                                    {
                                        ircbot.add_spam_count(channel);
                                    }
                                    if (nick_access >= tmp_command.Access)
                                    {
                                        if (line.GetUpperBound(0) > 3)
                                        {
                                            ircbot.sendData("MODE", line[2] + " -v " + line[4]);
                                            access.del_access_list(line[4], line[2], Conf.Voice_Level.ToString(), ircbot);
                                        }
                                        else
                                        {
                                            ircbot.sendData("PRIVMSG", line[2] + " :" + nick + ", you need to include more info.");
                                        }
                                    }
                                    else
                                    {
                                        ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command.");
                                    }
                                    break;
                                case "mode":
                                    if (spam_check == true)
                                    {
                                        ircbot.add_spam_count(channel);
                                    }
                                    if (nick_access >= tmp_command.Access)
                                    {
                                        if (line.GetUpperBound(0) > 3)
                                        {
                                            string[] new_line = line[4].Split(charS, 2);
                                            char[] arr = new_line[0].ToCharArray();

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

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

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

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

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

                                                bool tmp_me = false;
                                                for (int y = 0; y <= total_nicks.GetUpperBound(0); y++)
                                                {
                                                    if (total_nicks[y].Trim().Equals(Conf.Name, StringComparison.InvariantCultureIgnoreCase))
                                                    {
                                                        tmp_me = true;
                                                    }
                                                }
                                                if (sent_nick_access == Conf.Owner_Level)
                                                {
                                                    ircbot.sendData("PRIVMSG", line[2] + " :You can't kick-ban my owner!");
                                                }
                                                else if (tmp_me == true)
                                                {
                                                    ircbot.sendData("PRIVMSG", line[2] + " :You can't kick-ban me!");
                                                }
                                                else
                                                {
                                                    if (nick_access >= sent_nick_access)
                                                    {
                                                        string ban = "*!*@" + target_host;
                                                        if (String.IsNullOrEmpty(target_host))
                                                        {
                                                            ban = new_line[1] + "!*@*";
                                                        }
                                                        if (new_line.GetUpperBound(0) > 1)
                                                        {
                                                            ircbot.sendData("MODE", line[2] + " +b " + ban + " :" + new_line[2]);
                                                            ircbot.sendData("KICK", line[2] + " " + total_nicks[0] + " :" + new_line[2]);
                                                        }
                                                        else
                                                        {
                                                            ircbot.sendData("MODE", line[2] + " +b " + ban + " :No Reason");
                                                            ircbot.sendData("KICK", line[2] + " " + total_nicks[0] + " :No Reason");
                                                        }
                                                        System.Timers.Timer unban_trigger = new System.Timers.Timer();
                                                        unban_trigger.Interval = (Convert.ToInt32(new_line[0]) * 1000);
                                                        unban_trigger.Enabled = true;
                                                        unban_trigger.AutoReset = false;
                                                        unban_trigger.Elapsed += (sender, e) => unban_nick(sender, e, total_nicks[0], target_host, line[2]);
                                                        unban_triggers.Add(unban_trigger);
                                                        main = ircbot;
                                                    }
                                                    else
                                                    {
                                                        ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command.");
                                                    }
                                                }
                                            }
                                            else
                                            {
                                                ircbot.sendData("PRIVMSG", line[2] + " :" + nick + ", you need to include more info.");
                                            }
                                        }
                                        else
                                        {
                                            ircbot.sendData("PRIVMSG", line[2] + " :" + nick + ", you need to include more info.");
                                        }
                                    }
                                    else
                                    {
                                        ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command.");
                                    }
                                    break;
                                case "ak":
                                    if (spam_check == true)
                                    {
                                        ircbot.add_spam_count(channel);
                                    }
                                    if (nick_access >= tmp_command.Access)
                                    {
                                        if (line.GetUpperBound(0) > 3)
                                        {
                                            string[] new_line = line[4].Split(charS, 2);
                                            string nicks = new_line[0].TrimStart(':');
                                            char[] charSep = new char[] { ',' };
                                            string[] total_nicks = nicks.Split(charSep, StringSplitOptions.RemoveEmptyEntries);
                                            int sent_nick_access = ircbot.get_nick_access(total_nicks[0], line[2]);
                                            bool tmp_me = false;
                                            for (int y = 0; y <= total_nicks.GetUpperBound(0); y++)
                                            {
                                                if (total_nicks[y].Trim().Equals(Conf.Name, StringComparison.InvariantCultureIgnoreCase))
                                                {
                                                    tmp_me = true;
                                                }
                                            }
                                            if (sent_nick_access == Conf.Owner_Level)
                                            {
                                                ircbot.sendData("PRIVMSG", line[2] + " :You can't kick my owner!");
                                            }
                                            else if (tmp_me == true)
                                            {
                                                ircbot.sendData("PRIVMSG", line[2] + " :You can't kick me!");
                                            }
                                            else
                                            {
                                                if (nick_access >= sent_nick_access)
                                                {
                                                    string target_host = ircbot.get_nick_host(total_nicks[0]);
                                                    if (new_line.GetUpperBound(0) > 0)
                                                    {
                                                        add_auto(total_nicks[0], line[2], target_host, "k", new_line[1], ircbot);
                                                    }
                                                    else
                                                    {
                                                        add_auto(total_nicks[0], line[2], target_host, "k", "No Reason", ircbot);
                                                    }
                                                }
                                                else
                                                {
                                                    ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command.");
                                                }
                                            }
                                        }
                                        else
                                        {
                                            ircbot.sendData("PRIVMSG", line[2] + " :" + nick + ", you need to include more info.");
                                        }
                                    }
                                    else
                                    {
                                        ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command.");
                                    }
                                    break;
                                case "ab":
                                    if (spam_check == true)
                                    {
                                        ircbot.add_spam_count(channel);
                                    }
                                    if (nick_access >= tmp_command.Access)
                                    {
                                        if (line.GetUpperBound(0) > 3)
                                        {
                                            string[] new_line = line[4].Split(charS, 2);
                                            string target_host = ircbot.get_nick_host(new_line[0]);
                                            string nicks = new_line[0].TrimStart(':');
                                            char[] charSep = new char[] { ',' };
                                            string[] total_nicks = nicks.Split(charSep, StringSplitOptions.RemoveEmptyEntries);
                                            int sent_nick_access = ircbot.get_nick_access(total_nicks[0], line[2]);
                                            bool tmp_me = false;
                                            for (int y = 0; y <= total_nicks.GetUpperBound(0); y++)
                                            {
                                                if (total_nicks[y].Trim().Equals(Conf.Name, StringComparison.InvariantCultureIgnoreCase))
                                                {
                                                    tmp_me = true;
                                                }
                                            }
                                            if (sent_nick_access == Conf.Owner_Level)
                                            {
                                                ircbot.sendData("PRIVMSG", line[2] + " :You can't ban my owner!");
                                            }
                                            else if (tmp_me == true)
                                            {
                                                ircbot.sendData("PRIVMSG", line[2] + " :You can't ban me!");
                                            }
                                            else
                                            {
                                                if (nick_access >= sent_nick_access)
                                                {
                                                    if (new_line.GetUpperBound(0) > 0)
                                                    {
                                                        add_auto(total_nicks[0], line[2], target_host, "b", new_line[1], ircbot);
                                                    }
                                                    else
                                                    {
                                                        add_auto(total_nicks[0], line[2], target_host, "b", "No Reason", ircbot);
                                                    }
                                                }
                                                else
                                                {
                                                    ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command.");
                                                }
                                            }
                                        }
                                        else
                                        {
                                            ircbot.sendData("PRIVMSG", line[2] + " :" + nick + ", you need to include more info.");
                                        }
                                    }
                                    else
                                    {
                                        ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command.");
                                    }
                                    break;
                                case "akb":
                                    if (spam_check == true)
                                    {
                                        ircbot.add_spam_count(channel);
                                    }
                                    if (nick_access >= tmp_command.Access)
                                    {
                                        if (line.GetUpperBound(0) > 3)
                                        {
                                            string[] new_line = line[4].Split(charS, 2);
                                            string target_host = ircbot.get_nick_host(new_line[0]);
                                            string nicks = new_line[0].TrimStart(':');
                                            char[] charSep = new char[] { ',' };
                                            string[] total_nicks = nicks.Split(charSep, StringSplitOptions.RemoveEmptyEntries);
                                            int sent_nick_access = ircbot.get_nick_access(total_nicks[0], line[2]);
                                            bool tmp_me = false;
                                            for (int y = 0; y <= total_nicks.GetUpperBound(0); y++)
                                            {
                                                if (total_nicks[y].Trim().Equals(Conf.Name, StringComparison.InvariantCultureIgnoreCase))
                                                {
                                                    tmp_me = true;
                                                }
                                            }
                                            if (sent_nick_access == Conf.Owner_Level)
                                            {
                                                ircbot.sendData("PRIVMSG", line[2] + " :You can't kick-ban my owner!");
                                            }
                                            else if (tmp_me == true)
                                            {
                                                ircbot.sendData("PRIVMSG", line[2] + " :You can't kick-ban me!");
                                            }
                                            else
                                            {
                                                if (nick_access >= sent_nick_access)
                                                {
                                                    if (new_line.GetUpperBound(0) > 0)
                                                    {
                                                        add_auto(total_nicks[0], line[2], target_host, "kb", new_line[1], ircbot);
                                                    }
                                                    else
                                                    {
                                                        add_auto(total_nicks[0], line[2], target_host, "kb", "No Reason", ircbot);
                                                    }
                                                }
                                                else
                                                {
                                                    ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command.");
                                                }
                                            }
                                        }
                                        else
                                        {
                                            ircbot.sendData("PRIVMSG", line[2] + " :" + nick + ", you need to include more info.");
                                        }
                                    }
                                    else
                                    {
                                        ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command.");
                                    }
                                    break;
                                case "deak":
                                    if (spam_check == true)
                                    {
                                        ircbot.add_spam_count(channel);
                                    }
                                    if (nick_access >= tmp_command.Access)
                                    {
                                        if (line.GetUpperBound(0) > 3)
                                        {
                                            string target_host = ircbot.get_nick_host(line[4]);
                                            del_auto(line[4], line[2], target_host, "k", ircbot);
                                        }
                                        else
                                        {
                                            ircbot.sendData("PRIVMSG", line[2] + " :" + nick + ", you need to include more info.");
                                        }
                                    }
                                    else
                                    {
                                        ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command.");
                                    }
                                    break;
                                case "deab":
                                    if (spam_check == true)
                                    {
                                        ircbot.add_spam_count(channel);
                                    }
                                    if (nick_access >= tmp_command.Access)
                                    {
                                        if (line.GetUpperBound(0) > 3)
                                        {
                                            string target_host = ircbot.get_nick_host(line[4]);
                                            del_auto(line[4], line[2], target_host, "b", ircbot);
                                        }
                                        else
                                        {
                                            ircbot.sendData("PRIVMSG", line[2] + " :" + nick + ", you need to include more info.");
                                        }
                                    }
                                    else
                                    {
                                        ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command.");
                                    }
                                    break;
                                case "deakb":
                                    if (spam_check == true)
                                    {
                                        ircbot.add_spam_count(channel);
                                    }
                                    if (nick_access >= tmp_command.Access)
                                    {
                                        if (line.GetUpperBound(0) > 3)
                                        {
                                            string target_host = ircbot.get_nick_host(line[4]);
                                            del_auto(line[4], line[2], target_host, "kb", ircbot);
                                        }
                                        else
                                        {
                                            ircbot.sendData("PRIVMSG", line[2] + " :" + nick + ", you need to include more info.");
                                        }
                                    }
                                    else
                                    {
                                        ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command.");
                                    }
                                    break;
                                case "k":
                                    if (spam_check == true)
                                    {
                                        ircbot.add_spam_count(channel);
                                    }
                                    if (nick_access >= tmp_command.Access)
                                    {
                                        if (line.GetUpperBound(0) > 3)
                                        {
                                            string[] new_line = line[4].Split(charS, 2);
                                            string nicks = new_line[0].TrimStart(':');
                                            char[] charSep = new char[] { ',' };
                                            string[] total_nicks = nicks.Split(charSep, StringSplitOptions.RemoveEmptyEntries);
                                            int sent_nick_access = ircbot.get_nick_access(total_nicks[0], line[2]);
                                            bool tmp_me = false;
                                            for (int y = 0; y <= total_nicks.GetUpperBound(0); y++)
                                            {
                                                if (total_nicks[y].Trim().Equals(Conf.Name, StringComparison.InvariantCultureIgnoreCase))
                                                {
                                                    tmp_me = true;
                                                }
                                            }
                                            if (sent_nick_access == Conf.Owner_Level)
                                            {
                                                ircbot.sendData("PRIVMSG", line[2] + " :You can't kick my owner!");
                                            }
                                            else if (tmp_me == true)
                                            {
                                                ircbot.sendData("PRIVMSG", line[2] + " :You can't kick me!");
                                            }
                                            else
                                            {
                                                if (nick_access >= sent_nick_access)
                                                {
                                                    if (new_line.GetUpperBound(0) > 0)
                                                    {
                                                        ircbot.sendData("KICK", line[2] + " " + total_nicks[0] + " :" + new_line[1]);
                                                    }
                                                    else
                                                    {
                                                        ircbot.sendData("KICK", line[2] + " " + total_nicks[0] + " :No Reason");
                                                    }
                                                }
                                                else
                                                {
                                                    ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command.");
                                                }
                                            }
                                        }
                                        else
                                        {
                                            ircbot.sendData("PRIVMSG", line[2] + " :" + nick + ", you need to include more info.");
                                        }
                                    }
                                    else
                                    {
                                        ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command.");
                                    }
                                    break;
                                case "kme":
                                    if (spam_check == true)
                                    {
                                        ircbot.add_spam_count(channel);
                                    }
                                    if (nick_access >= tmp_command.Access)
                                    {
                                        if (line.GetUpperBound(0) > 3)
                                        {
                                            ircbot.sendData("KICK", line[2] + " " + nick + " :" + line[4]);
                                        }
                                        else
                                        {
                                            ircbot.sendData("KICK", line[2] + " " + nick + " :No Reason");
                                        }
                                    }
                                    break;
                            }
                        }
                    }
                }
            }
            if (type.Equals("join"))
            {
                string[] user_info = line[0].Split('@');
                string nick_host = user_info[1];
                check_auto(nick, channel.TrimStart(':'), nick_host, ircbot);
            }
        }
Пример #25
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);
            }
        }
Пример #26
0
 public override void control(bot ircbot, BotConfig Conf, string[] line, string command, int nick_access, string nick, string channel, bool bot_command, string type)
 {
     if ((type.Equals("channel") || type.Equals("query")) && bot_command == true)
     {
         foreach (Command tmp_command in this.Commands)
         {
             bool blocked = tmp_command.Blacklist.Contains(channel) || tmp_command.Blacklist.Contains(nick);
             bool cmd_found = false;
             bool spam_check = ircbot.get_spam_check(channel, nick, tmp_command.Spam_Check);
             if (spam_check == true)
             {
                 blocked = blocked || ircbot.get_spam_status(channel);
             }
             cmd_found = tmp_command.Triggers.Contains(command);
             if (blocked == true && cmd_found == true)
             {
                 ircbot.sendData("NOTICE", nick + " :I am currently too busy to process that.");
             }
             if (blocked == false && cmd_found == true)
             {
                 foreach (string trigger in tmp_command.Triggers)
                 {
                     switch (trigger)
                     {
                         case "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;
                     }
                 }
             }
         }
     }
 }
Пример #27
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);
     }
 }
Пример #28
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);
                }
            }
        }
Пример #29
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;
                     }
                 }
             }
         }
     }
 }
Пример #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 "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;
                            }
                        }
                    }
                }
            }
        }
Пример #31
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);
                    }
                }
            }
        }
Пример #32
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;
                            }
                        }
                    }
                }
            }
        }
Пример #33
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;
                            }
                        }
                    }
                }
            }
        }
Пример #34
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 "owner":
                                    if (spam_check == true)
                                    {
                                        ircbot.add_spam_count(channel);
                                    }
                                    if (nick_access >= tmp_command.Access)
                                    {
                                        if (line.GetUpperBound(0) > 3)
                                        {
                                            if (line[4].Equals(Conf.Pass))
                                            {
                                                add_owner(nick, ircbot, Conf);
                                                ircbot.sendData("NOTICE", nick + " :You are now identified as an owner!");
                                            }
                                            else
                                            {
                                                ircbot.sendData("NOTICE", nick + " :Invalid Password");
                                            }
                                        }
                                        else
                                        {
                                            ircbot.sendData("NOTICE", nick + " :" + nick + ", you need to include more info.");
                                        }
                                    }
                                    else
                                    {
                                        ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command.");
                                    }
                                    break;
                                case "addowner":
                                    if (spam_check == true)
                                    {
                                        ircbot.add_spam_count(channel);
                                    }
                                    if (nick_access >= tmp_command.Access)
                                    {
                                        if (line.GetUpperBound(0) > 3)
                                        {
                                            add_owner(line[4], ircbot, Conf);
                                            ircbot.sendData("NOTICE", nick + " :" + line[4] + " has been added as an owner.");
                                        }
                                        else
                                        {
                                            ircbot.sendData("NOTICE", nick + " :You need to include more info.");
                                        }
                                    }
                                    else
                                    {
                                        ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command.");
                                    }
                                    break;
                                case "delowner":
                                    if (spam_check == true)
                                    {
                                        ircbot.add_spam_count(channel);
                                    }
                                    if (nick_access >= tmp_command.Access)
                                    {
                                        if (line.GetUpperBound(0) > 3)
                                        {
                                            del_owner(line[4], ircbot, Conf);
                                            ircbot.sendData("NOTICE", nick + " :" + line[4] + " has been removed as an owner.");
                                        }
                                        else
                                        {
                                            ircbot.sendData("NOTICE", nick + " :You need to include more info.");
                                        }
                                    }
                                    else
                                    {
                                        ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command.");
                                    }
                                    break;
                                case "nick":
                                    if (spam_check == true)
                                    {
                                        ircbot.add_spam_count(channel);
                                    }
                                    if (nick_access >= tmp_command.Access)
                                    {
                                        if (line.GetUpperBound(0) > 3)
                                        {
                                            ircbot.sendData("NICK", line[4]);
                                            ircbot.Nick = line[4];
                                        }
                                        else
                                        {
                                            ircbot.sendData("NOTICE", nick + " :" + nick + ", you need to include more info.");
                                        }
                                    }
                                    else
                                    {
                                        ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command.");
                                    }
                                    break;
                                case "id":
                                    if (spam_check == true)
                                    {
                                        ircbot.add_spam_count(channel);
                                    }
                                    if (nick_access >= tmp_command.Access)
                                    {
                                        ircbot.sendData("PRIVMSG", "NickServ :Identify " + Conf.Pass);
                                        ircbot.sendData("NOTICE", nick + " :I have identified.");
                                    }
                                    else
                                    {
                                        ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command.");
                                    }
                                    break;
                                case "join":
                                    if (spam_check == true)
                                    {
                                        ircbot.add_spam_count(channel);
                                    }
                                    if (nick_access >= tmp_command.Access)
                                    {
                                        if (line.GetUpperBound(0) > 3)
                                        {
                                            string[] chan_list = line[4].Replace(' ', ',').Split(',');
                                            foreach (string chan in chan_list)
                                            {
                                                ircbot.sendData("JOIN", chan);
                                            }
                                        }
                                        else
                                        {
                                            ircbot.sendData("NOTICE", nick + " :" + nick + ", you need to include more info.");
                                        }
                                    }
                                    else
                                    {
                                        ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command.");
                                    }
                                    break;
                                case "part":
                                    if (spam_check == true)
                                    {
                                        ircbot.add_spam_count(channel);
                                    }
                                    if (nick_access >= tmp_command.Access)
                                    {
                                        if (line.GetUpperBound(0) > 3)
                                        {
                                            string[] channels = line[4].Split(' ');
                                            bool chan_found = false;
                                            foreach (string tmp_chan in channels)
                                            {
                                                Channel_Info chan_info = ircbot.get_chan_info(tmp_chan);
                                                if (chan_info != null)
                                                {
                                                    chan_found = true;
                                                    ircbot.sendData("PART", tmp_chan);
                                                    ircbot.del_chan_info(tmp_chan);
                                                }
                                            }
                                            if (chan_found == false)
                                            {
                                                ircbot.sendData("NOTICE", nick + " :I am not in that channel.");
                                            }
                                        }
                                        else if (type.Equals("channel"))
                                        {
                                            Channel_Info chan_info = ircbot.get_chan_info(channel);
                                            if (chan_info != null)
                                            {
                                                ircbot.sendData("PART", channel);
                                                ircbot.del_chan_info(channel);
                                            }
                                            else
                                            {
                                                ircbot.sendData("NOTICE", nick + " :I am not in that channel.");
                                            }
                                        }
                                        else
                                        {
                                            ircbot.sendData("NOTICE", nick + " :" + nick + ", you need to include more info.");
                                        }
                                    }
                                    else
                                    {
                                        ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command.");
                                    }
                                    break;
                                case "say":
                                    if (spam_check == true)
                                    {
                                        ircbot.add_spam_count(channel);
                                    }
                                    if (nick_access >= tmp_command.Access)
                                    {
                                        if (line.GetUpperBound(0) > 3)
                                        {
                                            string[] new_line = line[4].Split(charS, 2);
                                            if (new_line[0].StartsWith("#") == true && new_line.GetUpperBound(0) > 0)
                                            {
                                                ircbot.sendData("PRIVMSG", new_line[0] + " :" + new_line[1]);
                                            }
                                            else
                                            {
                                                ircbot.sendData("PRIVMSG", channel + " :" + line[4]);
                                            }
                                        }
                                        else
                                        {
                                            ircbot.sendData("NOTICE", nick + " :" + nick + ", you need to include more info.");
                                        }
                                    }
                                    else
                                    {
                                        ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command.");
                                    }
                                    break;
                                case "action":
                                    if (spam_check == true)
                                    {
                                        ircbot.add_spam_count(channel);
                                    }
                                    if (nick_access >= tmp_command.Access)
                                    {
                                        if (line.GetUpperBound(0) > 3)
                                        {
                                            string[] new_line = line[4].Split(charS, 2);
                                            if (new_line[0].StartsWith("#") == true && new_line.GetUpperBound(0) > 0)
                                            {
                                                ircbot.sendData("PRIVMSG", new_line[0] + " :\u0001ACTION " + new_line[1] + "\u0001");
                                            }
                                            else
                                            {
                                                ircbot.sendData("PRIVMSG", channel + " :\u0001ACTION " + line[4] + "\u0001");
                                            }
                                        }
                                        else
                                        {
                                            ircbot.sendData("NOTICE", nick + " :" + nick + ", you need to include more info.");
                                        }
                                    }
                                    else
                                    {
                                        ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command.");
                                    }
                                    break;
                                case "query":
                                    if (spam_check == true)
                                    {
                                        ircbot.add_spam_count(channel);
                                    }
                                    if (nick_access >= tmp_command.Access)
                                    {
                                        if (line.GetUpperBound(0) > 3)
                                        {
                                            string[] new_line = line[4].Split(charS, 2);
                                            if (new_line.GetUpperBound(0) > 0)
                                            {
                                                ircbot.sendData("PRIVMSG", new_line[0] + " :" + new_line[1]);
                                            }
                                            else
                                            {
                                                ircbot.sendData("NOTICE", nick + " :" + nick + ", you need to include more info.");
                                            }
                                        }
                                        else
                                        {
                                            ircbot.sendData("NOTICE", nick + " :" + nick + ", you need to include more info.");
                                        }
                                    }
                                    else
                                    {
                                        ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command.");
                                    }
                                    break;
                                case "quit":
                                    if (spam_check == true)
                                    {
                                        ircbot.add_spam_count(channel);
                                    }
                                    if (nick_access >= tmp_command.Access)
                                    {
                                        if (line.GetUpperBound(0) <= 3)
                                        {
                                            ircbot.sendData("QUIT", "Leaving");
                                        }
                                        else
                                        {
                                            ircbot.sendData("QUIT", ":" + line[4]); //if the command is quit, send the QUIT command to the server with a quit message
                                        }
                                        ircbot.worker.CancelAsync();
                                    }
                                    else
                                    {
                                        ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command.");
                                    }
                                    break;
                                case "quitall":
                                    if (spam_check == true)
                                    {
                                        ircbot.add_spam_count(channel);
                                    }
                                    if (nick_access >= tmp_command.Access)
                                    {
                                        foreach (var bot in ircbot.controller.bot_instances)
                                        {
                                            if (line.GetUpperBound(0) <= 3)
                                            {
                                                bot.sendData("QUIT", "Leaving");
                                            }
                                            else
                                            {
                                                bot.sendData("QUIT", ":" + line[4]);
                                            }
                                            bot.worker.CancelAsync();
                                        }
                                    }
                                    else
                                    {
                                        ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command.");
                                    }
                                    break;
                                case "cycle":
                                    if (spam_check == true)
                                    {
                                        ircbot.add_spam_count(channel);
                                    }
                                    if (nick_access >= tmp_command.Access)
                                    {
                                        ircbot.restart = true;
                                        ircbot.worker.CancelAsync();
                                    }
                                    else
                                    {
                                        ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command.");
                                    }
                                    break;
                                case "cycleall":
                                    if (spam_check == true)
                                    {
                                        ircbot.add_spam_count(channel);
                                    }
                                    if (nick_access >= tmp_command.Access)
                                    {
                                        foreach (var bot in ircbot.controller.bot_instances)
                                        {
                                            bot.restart = true;
                                            bot.worker.CancelAsync();
                                        }
                                    }
                                    else
                                    {
                                        ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command.");
                                    }
                                    break;
                                case "exit":
                                    if (spam_check == true)
                                    {
                                        ircbot.add_spam_count(channel);
                                    }
                                    if (nick_access >= tmp_command.Access)
                                    {
                                        Environment.Exit(0);
                                    }
                                    else
                                    {
                                        ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command.");
                                    }
                                    break;
                                case "restart":
                                    if (spam_check == true)
                                    {
                                        ircbot.add_spam_count(channel);
                                    }
                                    if (nick_access >= tmp_command.Access)
                                    {
                                        System.Diagnostics.Process.Start(Assembly.GetEntryAssembly().Location); // to start new instance of application
                                        Environment.Exit(0);
                                    }
                                    else
                                    {
                                        ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command.");
                                    }
                                    break;
                                case "ignore":
                                    if (spam_check == true)
                                    {
                                        ircbot.add_spam_count(channel);
                                    }
                                    if (nick_access >= tmp_command.Access)
                                    {
                                        if (line.GetUpperBound(0) > 3)
                                        {
                                            ignore(line[4], nick, ircbot, Conf);
                                        }
                                        else
                                        {
                                            ircbot.sendData("NOTICE", nick + " :" + nick + ", you need to include more info.");
                                        }
                                    }
                                    else
                                    {
                                        ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command.");
                                    }
                                    break;
                                case "unignore":
                                    if (spam_check == true)
                                    {
                                        ircbot.add_spam_count(channel);
                                    }
                                    if (nick_access >= tmp_command.Access)
                                    {
                                        if (line.GetUpperBound(0) > 3)
                                        {
                                            unignore(line[4], nick, ircbot, Conf);
                                        }
                                        else
                                        {
                                            ircbot.sendData("NOTICE", nick + " :" + nick + ", you need to include more info.");
                                        }
                                    }
                                    else
                                    {
                                        ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command.");
                                    }
                                    break;
                                case "ignorecmd":
                                    if (spam_check == true)
                                    {
                                        ircbot.add_spam_count(channel);
                                    }
                                    if (nick_access >= tmp_command.Access)
                                    {
                                        if (line.GetUpperBound(0) > 3)
                                        {
                                            string[] new_line = line[4].Split(charS, 2);
                                            if (new_line.GetUpperBound(0) > 0)
                                            {
                                                ignorecmd(new_line[0], new_line[1], nick, ircbot, Conf);
                                            }
                                            else
                                            {
                                                ircbot.sendData("NOTICE", nick + " :" + nick + ", you need to include more info.");
                                            }
                                        }
                                        else
                                        {
                                            ircbot.sendData("NOTICE", nick + " :" + nick + ", you need to include more info.");
                                        }
                                    }
                                    else
                                    {
                                        ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command.");
                                    }
                                    break;
                                case "unignorecmd":
                                    if (spam_check == true)
                                    {
                                        ircbot.add_spam_count(channel);
                                    }
                                    if (nick_access >= tmp_command.Access)
                                    {
                                        if (line.GetUpperBound(0) > 3)
                                        {
                                            string[] new_line = line[4].Split(charS, 2);
                                            if (new_line.GetUpperBound(0) > 0)
                                            {
                                                unignorecmd(new_line[0], new_line[1], nick, ircbot, Conf);
                                            }
                                            else
                                            {
                                                ircbot.sendData("NOTICE", nick + " :" + nick + ", you need to include more info.");
                                            }
                                        }
                                        else
                                        {
                                            ircbot.sendData("NOTICE", nick + " :" + nick + ", you need to include more info.");
                                        }
                                    }
                                    else
                                    {
                                        ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command.");
                                    }
                                    break;
                                case "ignoremodule":
                                    if (spam_check == true)
                                    {
                                        ircbot.add_spam_count(channel);
                                    }
                                    if (nick_access >= tmp_command.Access)
                                    {
                                        if (line.GetUpperBound(0) > 3)
                                        {
                                            string[] new_line = line[4].Split(charS, 2);
                                            if (new_line.GetUpperBound(0) > 0)
                                            {
                                                ignoremodule(new_line[0], new_line[1], nick, ircbot, Conf);
                                            }
                                            else
                                            {
                                                ircbot.sendData("NOTICE", nick + " :" + nick + ", you need to include more info.");
                                            }
                                        }
                                        else
                                        {
                                            ircbot.sendData("NOTICE", nick + " :" + nick + ", you need to include more info.");
                                        }
                                    }
                                    else
                                    {
                                        ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command.");
                                    }
                                    break;
                                case "unignoremodule":
                                    if (spam_check == true)
                                    {
                                        ircbot.add_spam_count(channel);
                                    }
                                    if (nick_access >= tmp_command.Access)
                                    {
                                        if (line.GetUpperBound(0) > 3)
                                        {
                                            string[] new_line = line[4].Split(charS, 2);
                                            if (new_line.GetUpperBound(0) > 0)
                                            {
                                                unignoremodule(new_line[0], new_line[1], nick, ircbot, Conf);
                                            }
                                            else
                                            {
                                                ircbot.sendData("NOTICE", nick + " :" + nick + ", you need to include more info.");
                                            }
                                        }
                                        else
                                        {
                                            ircbot.sendData("NOTICE", nick + " :" + nick + ", you need to include more info.");
                                        }
                                    }
                                    else
                                    {
                                        ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command.");
                                    }
                                    break;
                                case "blacklist":
                                    if (spam_check == true)
                                    {
                                        ircbot.add_spam_count(channel);
                                    }
                                    if (nick_access >= tmp_command.Access)
                                    {
                                        if (line.GetUpperBound(0) > 3)
                                        {
                                            add_blacklist(line[4], nick, ircbot, Conf);
                                        }
                                        else
                                        {
                                            ircbot.sendData("NOTICE", nick + " :" + nick + ", you need to include more info.");
                                        }
                                    }
                                    else
                                    {
                                        ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command.");
                                    }
                                    break;
                                case "unblacklist":
                                    if (spam_check == true)
                                    {
                                        ircbot.add_spam_count(channel);
                                    }
                                    if (nick_access >= tmp_command.Access)
                                    {
                                        if (line.GetUpperBound(0) > 3)
                                        {
                                            unblacklist(line[4], nick, ircbot, Conf);
                                        }
                                        else
                                        {
                                            ircbot.sendData("NOTICE", nick + " :" + nick + ", you need to include more info.");
                                        }
                                    }
                                    else
                                    {
                                        ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command.");
                                    }
                                    break;
                                case "update":
                                    if (spam_check == true)
                                    {
                                        ircbot.add_spam_count(channel);
                                    }
                                    if (nick_access >= tmp_command.Access)
                                    {
                                        ircbot.controller.update_conf();
                                    }
                                    else
                                    {
                                        ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command.");
                                    }
                                    break;
                                case "modules":
                                    if (spam_check == true)
                                    {
                                        ircbot.add_spam_count(channel);
                                    }
                                    if (nick_access >= tmp_command.Access)
                                    {
                                        string msg = "";
                                        foreach (Module module in ircbot.Conf.Modules)
                                        {
                                            msg += ", " + module.ToString().Remove(0, 12);
                                        }
                                        if (!String.IsNullOrEmpty(msg))
                                        {
                                            ircbot.sendData("NOTICE", nick + " :" + msg.TrimStart(',').Trim());
                                        }
                                        else
                                        {
                                            ircbot.sendData("NOTICE", nick + " :No Modules are loaded.");
                                        }
                                    }
                                    else
                                    {
                                        ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command.");
                                    }
                                    break;
                                case "loadmodule":
                                    if (spam_check == true)
                                    {
                                        ircbot.add_spam_count(channel);
                                    }
                                    if (nick_access >= tmp_command.Access)
                                    {
                                        if (line.GetUpperBound(0) > 3)
                                        {
                                            bool module_found = ircbot.load_module(line[4]);
                                            if (module_found == true)
                                            {
                                                if (type.Equals("channel"))
                                                {
                                                    ircbot.sendData("PRIVMSG", channel + " :Module Loaded Successfully");
                                                }
                                                else
                                                {
                                                    ircbot.sendData("NOTICE", nick + " :Module Loaded Successfully");
                                                }
                                            }
                                            else
                                            {
                                                if (type.Equals("channel"))
                                                {
                                                    ircbot.sendData("PRIVMSG", channel + " :Error loading Module");
                                                }
                                                else
                                                {
                                                    ircbot.sendData("NOTICE", nick + " :Error loading Module");
                                                }
                                            }
                                        }
                                        else
                                        {
                                            if (type.Equals("channel"))
                                            {
                                                ircbot.sendData("PRIVMSG", channel + " :" + nick + ", you need to include more info.");
                                            }
                                            else
                                            {
                                                ircbot.sendData("NOTICE", nick + " :" + nick + ", you need to include more info.");
                                            }
                                        }
                                    }
                                    else
                                    {
                                        ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command.");
                                    }
                                    break;
                                case "delmodule":
                                    if (spam_check == true)
                                    {
                                        ircbot.add_spam_count(channel);
                                    }
                                    if (nick_access >= tmp_command.Access)
                                    {

                                        if (line.GetUpperBound(0) > 3)
                                        {
                                            bool module_found = ircbot.unload_module(line[4]);
                                            if (module_found == true)
                                            {
                                                if (type.Equals("channel"))
                                                {
                                                    ircbot.sendData("PRIVMSG", channel + " :Module Unloaded Successfully");
                                                }
                                                else
                                                {
                                                    ircbot.sendData("NOTICE", nick + " :Module Unloaded Successfully");
                                                }
                                            }
                                            else
                                            {
                                                if (type.Equals("channel"))
                                                {
                                                    ircbot.sendData("PRIVMSG", channel + " :No Module found");
                                                }
                                                else
                                                {
                                                    ircbot.sendData("NOTICE", nick + " :No Module found");
                                                }
                                            }
                                        }
                                        else
                                        {
                                            if (type.Equals("channel"))
                                            {
                                                ircbot.sendData("PRIVMSG", channel + " :" + nick + ", you need to include more info.");
                                            }
                                            else
                                            {
                                                ircbot.sendData("NOTICE", nick + " :" + nick + ", you need to include more info.");
                                            }
                                        }
                                    }
                                    else
                                    {
                                        ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command.");
                                    }
                                    break;
                                case "addchan":
                                    if (spam_check == true)
                                    {
                                        ircbot.add_spam_count(channel);
                                    }
                                    if (nick_access >= tmp_command.Access)
                                    {
                                        if (line.GetUpperBound(0) > 3)
                                        {
                                            bool chan_allowed = true;
                                            foreach (string chan in ircbot.Conf.Chan_Blacklist.Split(','))
                                            {
                                                if (chan.Equals(line[4]))
                                                {
                                                    chan_allowed = false;
                                                    break;
                                                }
                                            }
                                            if (chan_allowed == true)
                                            {
                                                Channel_Info chan_info = ircbot.get_chan_info(line[4]);
                                                if (chan_info == null)
                                                {
                                                    if (nick_access != Conf.Owner_Level)
                                                    {
                                                        foreach (string owner_nick in Conf.Owners)
                                                        {
                                                            ircbot.sendData("NOTICE", owner_nick + " :" + nick + " has invited me to join " + line[4]);
                                                            ircbot.sendData("NOTICE", owner_nick + " :If you would like to permanently add this channel, please type " + ircbot.Conf.Command + "addchanlist " + line[4]);
                                                        }
                                                    }
                                                    ircbot.sendData("JOIN", line[4]);
                                                }
                                                else
                                                {
                                                    ircbot.sendData("NOTICE", nick + " :I'm already in that channel!");
                                                }
                                            }
                                            else
                                            {
                                                ircbot.sendData("NOTICE", nick + " :I am not allowed to join that channel.");
                                            }
                                        }
                                        else
                                        {
                                            ircbot.sendData("NOTICE", nick + " :" + nick + ", you need to include more info.");
                                        }
                                    }
                                    else
                                    {
                                        ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command.");
                                    }
                                    break;
                                case "addchanlist":
                                    if (spam_check == true)
                                    {
                                        ircbot.add_spam_count(channel);
                                    }
                                    if (nick_access >= tmp_command.Access)
                                    {
                                        if (line.GetUpperBound(0) > 3)
                                        {
                                            Channel_Info chan_info = ircbot.get_chan_info(line[4]);
                                            if (chan_info == null)
                                            {
                                                ircbot.sendData("JOIN", line[4]);
                                            }
                                            add_channel_list(line[4], ircbot, Conf);
                                            ircbot.sendData("NOTICE", nick + " :" + line[4] + " successfully added to auto-join list.");
                                        }
                                        else
                                        {
                                            ircbot.sendData("NOTICE", nick + " :" + nick + ", you need to include more info.");
                                        }
                                    }
                                    else
                                    {
                                        ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command.");
                                    }
                                    break;
                                case "delchanlist":
                                    if (spam_check == true)
                                    {
                                        ircbot.add_spam_count(channel);
                                    }
                                    if (nick_access >= tmp_command.Access)
                                    {
                                        if (line.GetUpperBound(0) > 3)
                                        {
                                            del_channel_list(line[4], ircbot, Conf);
                                            ircbot.sendData("NOTICE", nick + " :" + line[4] + " successfully removed from auto-join list.");
                                        }
                                        else
                                        {
                                            ircbot.sendData("NOTICE", nick + " :" + nick + ", you need to include more info.");
                                        }
                                    }
                                    else
                                    {
                                        ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command.");
                                    }
                                    break;
                                case "nicklist":
                                    if (spam_check == true)
                                    {
                                        ircbot.add_spam_count(channel);
                                    }
                                    if (nick_access >= tmp_command.Access)
                                    {
                                        if (type.Equals("channel"))
                                        {
                                            if (line.GetUpperBound(0) > 3)
                                            {
                                                bool nick_found = false;
                                                string nick_list = "";
                                                Channel_Info chan_info = ircbot.get_chan_info(line[4]);
                                                if (chan_info != null)
                                                {
                                                    foreach (Nick_Info nick_info in chan_info.Nicks)
                                                    {
                                                        nick_list += nick_info.Nick + ", ";
                                                        nick_found = true;
                                                    }
                                                }
                                                if (nick_found)
                                                {
                                                    ircbot.sendData("NOTICE", nick + " :" + line[4] + ": " + nick_list.Trim().TrimEnd(','));
                                                }
                                                else
                                                {
                                                    ircbot.sendData("NOTICE", nick + " :No nicks in " + line[4]);
                                                }
                                            }
                                            else
                                            {
                                                bool nick_found = false;
                                                string nick_list = "";
                                                Channel_Info chan_info = ircbot.get_chan_info(channel);
                                                if (chan_info != null)
                                                {
                                                    foreach (Nick_Info nick_info in chan_info.Nicks)
                                                    {
                                                        nick_list += nick_info.Nick + ", ";
                                                        nick_found = true;
                                                    }
                                                }
                                                if (nick_found)
                                                {
                                                    ircbot.sendData("NOTICE", nick + " :" + channel + ": " + nick_list.Trim().TrimEnd(','));
                                                }
                                                else
                                                {
                                                    ircbot.sendData("NOTICE", nick + " :No nicks in " + channel);
                                                }
                                            }
                                        }
                                        else
                                        {
                                            if (line.GetUpperBound(0) > 3)
                                            {
                                                bool nick_found = false;
                                                string nick_list = "";
                                                Channel_Info chan_info = ircbot.get_chan_info(line[4]);
                                                if (chan_info != null)
                                                {
                                                    foreach (Nick_Info nick_info in chan_info.Nicks)
                                                    {
                                                        nick_list += nick_info.Nick + ", ";
                                                        nick_found = true;
                                                    }
                                                }
                                                if (nick_found)
                                                {
                                                    ircbot.sendData("NOTICE", nick + " :" + line[4] + ": " + nick_list.Trim().TrimEnd(','));
                                                }
                                                else
                                                {
                                                    ircbot.sendData("NOTICE", nick + " :No nicks in " + line[4]);
                                                }
                                            }
                                            else
                                            {
                                                ircbot.sendData("NOTICE", nick + " :" + nick + ", you need to include more info.");
                                            }
                                        }
                                    }
                                    else
                                    {
                                        ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command.");
                                    }
                                    break;
                                case "channels":
                                    if (spam_check == true)
                                    {
                                        ircbot.add_spam_count(channel);
                                    }
                                    if (nick_access >= tmp_command.Access)
                                    {
                                        bool chan_found = false;
                                        string chan_list = "";
                                        foreach (Channel_Info chan_info in ircbot.Conf.Channel_List)
                                        {
                                            if (!this.Options["hide_private"] || nick_access == Conf.Owner_Level) // if "hide on private/secret" is false
                                            {
                                                chan_list += chan_info.Channel + ", ";
                                                chan_found = true;
                                            }
                                            else
                                            {
                                                if (chan_info.Show || ircbot.get_nick_info(nick, chan_info.Channel) != null)
                                                {
                                                    chan_list += chan_info.Channel + ", ";
                                                    chan_found = true;
                                                }
                                            }
                                        }
                                        if (chan_found == true)
                                        {
                                            if (type.Equals("channel"))
                                            {
                                                if (nick_access == Conf.Owner_Level)
                                                {
                                                    ircbot.sendData("NOTICE", nick + " :I am currently in the following channels: " + chan_list.Trim().TrimEnd(','));
                                                }
                                                else
                                                {
                                                    ircbot.sendData("PRIVMSG", channel + " :I am currently in the following channels: " + chan_list.Trim().TrimEnd(','));
                                                }
                                            }
                                            else
                                            {
                                                ircbot.sendData("NOTICE", nick + " :I am currently in the following channels: " + chan_list.Trim().TrimEnd(','));
                                            }
                                        }
                                        else
                                        {
                                            if (type.Equals("channel"))
                                            {
                                                ircbot.sendData("PRIVMSG", channel + " :I'm in no channels.");
                                            }
                                            else
                                            {
                                                ircbot.sendData("NOTICE", nick + " :I'm in no channels.");
                                            }
                                        }
                                    }
                                    else
                                    {
                                        ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command.");
                                    }
                                    break;
                                case "servers":
                                    if (spam_check == true)
                                    {
                                        ircbot.add_spam_count(channel);
                                    }
                                    if (nick_access >= tmp_command.Access)
                                    {
                                        string server_list = "";
                                        foreach (bot bot in ircbot.controller.bot_instances)
                                        {
                                            if (bot.connected)
                                            {
                                                server_list += bot.Conf.Server_Address + ", ";
                                            }
                                        }
                                        if (type.Equals("channel"))
                                        {
                                            ircbot.sendData("PRIVMSG", channel + " :I am currently in the following servers: " + server_list.Trim().TrimEnd(','));
                                        }
                                        else
                                        {
                                            ircbot.sendData("NOTICE", nick + " :I am currently in the following servers: " + server_list.Trim().TrimEnd(','));
                                        }
                                    }
                                    else
                                    {
                                        ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command.");
                                    }
                                    break;
                                case "conf":
                                    if (spam_check == true)
                                    {
                                        ircbot.add_spam_count(channel);
                                    }
                                    if (nick_access >= tmp_command.Access)
                                    {
                                        if (line.GetUpperBound(0) > 3)
                                        {
                                            BotConfig myObjectType = new BotConfig();
                                            var fields = myObjectType.GetType().GetFields(BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance);
                                            switch (line[4])
                                            {
                                                case "modules":
                                                    foreach (System.Reflection.FieldInfo info in fields)
                                                    {
                                                        if (info.Name.Equals("modules"))
                                                        {
                                                            List<Bot.Modules.Module> tmp_list = (List<Bot.Modules.Module>)info.GetValue(Conf);
                                                            foreach (Bot.Modules.Module list in tmp_list)
                                                            {
                                                                string msg = "";
                                                                msg += "Class: " + list.Class_Name + " | ";
                                                                msg += "Name: " + list.Name + " | ";
                                                                string blacklist = "";
                                                                foreach (string black in list.Blacklist)
                                                                {
                                                                    blacklist += black + ", ";
                                                                }
                                                                msg += "Blacklist: " + blacklist.Trim().TrimEnd(',') + " | ";
                                                                ircbot.sendData("NOTICE", nick + " :" + msg.Trim().TrimEnd('|').TrimEnd(',').Trim());
                                                            }
                                                        }
                                                    }
                                                    break;
                                                default:
                                                    ircbot.sendData("NOTICE", nick + " :" + nick + ", I do not understand your request.");
                                                    break;
                                            }
                                        }
                                        else
                                        {
                                            BotConfig myObjectType = new BotConfig();
                                            var fields = myObjectType.GetType().GetFields(BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance);
                                            foreach (var info in fields)
                                            {
                                                if (info.GetValue(Conf) == null)
                                                {
                                                    ircbot.sendData("NOTICE", nick + " :" + info.Name + ": NULL");
                                                }
                                                else if (info.GetValue(Conf).ToString().Equals("System.Net.IPAddress[]"))
                                                {
                                                    System.Net.IPAddress[] tmp_list = (System.Net.IPAddress[])info.GetValue(Conf);
                                                    int index = 0;
                                                    foreach (System.Net.IPAddress list in tmp_list)
                                                    {
                                                        ircbot.sendData("NOTICE", nick + " :" + info.Name.Replace("k__BackingField", "") + "[" + index.ToString() + "]: " + list.ToString());
                                                        index++;
                                                    }
                                                }
                                                else if (info.GetValue(Conf).ToString().Equals("System.Collections.Generic.List`1[System.String]"))
                                                {
                                                    List<string> tmp_list = (List<string>)info.GetValue(Conf);
                                                    string response = "";
                                                    if (tmp_list.Count > 1)
                                                    {
                                                        int index = 1;
                                                        foreach (string item in tmp_list)
                                                        {
                                                            response += item;
                                                            if (index < tmp_list.Count)
                                                            {
                                                                response += ", ";
                                                            }
                                                            index++;
                                                        }
                                                    }
                                                    else
                                                    {
                                                        response += tmp_list[0];
                                                    }
                                                    ircbot.sendData("NOTICE", nick + " :" + info.Name + ": " + response);
                                                }
                                                else if (info.Name.Equals("modules"))
                                                {
                                                    List<Bot.Modules.Module> tmp_list = (List<Bot.Modules.Module>)info.GetValue(Conf);
                                                    ircbot.sendData("NOTICE", nick + " :" + info.Name + ": " + tmp_list.Count().ToString());
                                                }
                                                else if (info.Name.Equals("spam_check"))
                                                {
                                                    List<Bot.spam_info> tmp_list = (List<Bot.spam_info>)info.GetValue(Conf);
                                                    ircbot.sendData("NOTICE", nick + " :" + info.Name + ": " + tmp_list.Count().ToString());
                                                }
                                                else if (info.Name.Equals("channel_list"))
                                                {
                                                    List<Bot.Channel_Info> tmp_list = (List<Bot.Channel_Info>)info.GetValue(Conf);
                                                    ircbot.sendData("NOTICE", nick + " :" + info.Name + ": " + tmp_list.Count().ToString());
                                                }
                                                else
                                                {
                                                    ircbot.sendData("NOTICE", nick + " :" + info.Name.Replace("k__BackingField", "") + ": " + info.GetValue(Conf).ToString());
                                                }
                                            }
                                        }
                                    }
                                    else
                                    {
                                        ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command.");
                                    }
                                    break;
                                case "resources":
                                    if (spam_check == true)
                                    {
                                        ircbot.add_spam_count(channel);
                                    }
                                    if (nick_access >= tmp_command.Access)
                                    {
                                        Process currentProcess = System.Diagnostics.Process.GetCurrentProcess();
                                        float totalBytesOfMemoryUsed = (currentProcess.WorkingSet64 / 1024f) / 1024f;
                                        PerformanceCounter pc1 = new PerformanceCounter();
                                        pc1.CategoryName = "Processor";
                                        pc1.CounterName = "% Processor Time";
                                        pc1.InstanceName = "_Total";
                                        pc1.NextValue();
                                        Thread.Sleep(1000);
                                        float totalCPUUsage = pc1.NextValue();
                                        if (type.Equals("channel"))
                                        {
                                            ircbot.sendData("PRIVMSG", channel + " :CPU: " + totalCPUUsage + "%");
                                            ircbot.sendData("PRIVMSG", channel + " :RAM: " + totalBytesOfMemoryUsed + "MB");
                                        }
                                        else
                                        {
                                            ircbot.sendData("NOTICE", nick + " :CPU: " + totalCPUUsage + "%");
                                            ircbot.sendData("NOTICE", nick + " :RAM: " + totalBytesOfMemoryUsed + "MB");
                                        }
                                    }
                                    else
                                    {
                                        ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command.");
                                    }
                                    break;
                                case "clear":
                                    if (spam_check == true)
                                    {
                                        ircbot.add_spam_count(channel);
                                    }
                                    if (nick_access >= tmp_command.Access)
                                    {
                                        if (type.Equals("channel"))
                                        {
                                            if (line.GetUpperBound(0) > 3)
                                            {
                                                Channel_Info chan_info = ircbot.get_chan_info(line[4]);
                                                if (chan_info != null)
                                                {
                                                    foreach (Nick_Info nick_info in chan_info.Nicks)
                                                    {
                                                        if (!nick_info.Nick.Equals(nick, StringComparison.InvariantCultureIgnoreCase) && !nick_info.Nick.Equals(ircbot.Nick, StringComparison.InvariantCultureIgnoreCase))
                                                        {
                                                            ircbot.sendData("KICK", line[4] + " :" + nick_info.Nick);
                                                            Thread.Sleep(100);
                                                        }
                                                    }
                                                }
                                            }
                                            else
                                            {
                                                Channel_Info chan_info = ircbot.get_chan_info(channel);
                                                if (chan_info != null)
                                                {
                                                    foreach (Nick_Info nick_info in chan_info.Nicks)
                                                    {
                                                        if (!nick_info.Nick.Equals(nick, StringComparison.InvariantCultureIgnoreCase) && !nick_info.Nick.Equals(ircbot.Nick, StringComparison.InvariantCultureIgnoreCase))
                                                        {
                                                            ircbot.sendData("KICK", line[4] + " :" + nick_info.Nick);
                                                            Thread.Sleep(100);
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                        else
                                        {
                                            if (line.GetUpperBound(0) > 3)
                                            {
                                                Channel_Info chan_info = ircbot.get_chan_info(line[4]);
                                                if (chan_info != null)
                                                {
                                                    foreach (Nick_Info nick_info in chan_info.Nicks)
                                                    {
                                                        if (!nick_info.Nick.Equals(nick, StringComparison.InvariantCultureIgnoreCase) && !nick_info.Nick.Equals(ircbot.Nick, StringComparison.InvariantCultureIgnoreCase))
                                                        {
                                                            ircbot.sendData("KICK", line[4] + " :" + nick_info.Nick);
                                                            Thread.Sleep(100);
                                                        }
                                                    }
                                                }
                                            }
                                            else
                                            {
                                                ircbot.sendData("NOTICE", nick + " :" + nick + ", you need to include more info.");
                                            }
                                        }
                                    }
                                    else
                                    {
                                        ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command.");
                                    }
                                    break;
                            }
                        }
                    }
                }
            }
        }
Пример #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 "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;
                     }
                 }
             }
         }
     }
 }
Пример #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)
        {
            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;
                            }
                        }
                    }
                }
            }
        }
Пример #37
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;
                            }
                        }
                    }
                }
            }
        }
Пример #38
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);
     }
 }
Пример #39
0
        public override void control(bot ircbot, BotConfig Conf, string[] line, string command, int nick_access, string nick, string channel, bool bot_command, string type)
        {
            if ((type.Equals("channel") || type.Equals("query")) && bot_command == true)
            {
                foreach (Command tmp_command in this.Commands)
                {
                    bool blocked    = tmp_command.Blacklist.Contains(channel) || tmp_command.Blacklist.Contains(nick);
                    bool cmd_found  = false;
                    bool spam_check = ircbot.get_spam_check(channel, nick, tmp_command.Spam_Check);
                    if (spam_check == true)
                    {
                        blocked = blocked || ircbot.get_spam_status(channel);
                    }
                    cmd_found = tmp_command.Triggers.Contains(command);
                    if (blocked == true && cmd_found == true)
                    {
                        ircbot.sendData("NOTICE", nick + " :I am currently too busy to process that.");
                    }
                    if (blocked == false && cmd_found == true)
                    {
                        foreach (string trigger in tmp_command.Triggers)
                        {
                            switch (trigger)
                            {
                            case "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;
                            }
                        }
                    }
                }
            }
        }
Пример #40
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 "idle":
                                if (spam_check == true)
                                {
                                    ircbot.add_spam_count(channel);
                                }
                                if (nick_access >= tmp_command.Access)
                                {
                                    if (check_idle(nick) == false)
                                    {
                                        idle_list.Add(nick);
                                        ircbot.sendData("NOTICE", nick + " :You are now set as idle.  Type " + ircbot.Conf.Command + "deidle to come back.");
                                    }
                                    else
                                    {
                                        ircbot.sendData("NOTICE", nick + " :You are already idle.  Type " + ircbot.Conf.Command + "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 >= tmp_command.Access)
                                {
                                    if (check_idle(nick) == true)
                                    {
                                        idle_list.Remove(nick);
                                        ircbot.sendData("NOTICE", nick + " :Welcome back!");
                                    }
                                    else
                                    {
                                        ircbot.sendData("NOTICE", nick + " :You aren't idle.  Type " + ircbot.Conf.Command + "idle to be set idle.");
                                    }
                                }
                                else
                                {
                                    ircbot.sendData("NOTICE", nick + " :You do not have permission to use that command.");
                                }
                                break;
                            }
                        }
                    }
                }
            }
        }