Exemplo n.º 1
0
 static void Main(string[] args)
 {
     var client = new IrcClient("irc.freenode.net", new IrcUser("ChatSharp", "ChatSharp"));
     client.NetworkError += (s, e) => Console.WriteLine("Error: " + e.SocketError);
     client.RawMessageRecieved += (s, e) => Console.WriteLine("<< {0}", e.Message);
     client.RawMessageSent += (s, e) => Console.WriteLine(">> {0}", e.Message);
     client.UserMessageRecieved += (s, e) =>
         {
             if (e.PrivateMessage.Message.StartsWith(".join "))
                 client.Channels.Join(e.PrivateMessage.Message.Substring(6));
             else if (e.PrivateMessage.Message.StartsWith(".list "))
             {
                 var channel = client.Channels[e.PrivateMessage.Message.Substring(6)];
                 var list = channel.Users.Select(u => u.Nick).Aggregate((a, b) => a + "," + b);
                 client.SendMessage(list, e.PrivateMessage.User.Nick);
             }
             else if (e.PrivateMessage.Message.StartsWith(".whois "))
                 client.WhoIs(e.PrivateMessage.Message.Substring(7), null);
             else if (e.PrivateMessage.Message.StartsWith(".raw "))
                 client.SendRawMessage(e.PrivateMessage.Message.Substring(5));
             else if (e.PrivateMessage.Message.StartsWith(".mode "))
             {
                 var parts = e.PrivateMessage.Message.Split(' ');
                 client.ChangeMode(parts[1], parts[2]);
             }
         };
     client.ChannelMessageRecieved += (s, e) =>
         {
             Console.WriteLine("<{0}> {1}", e.PrivateMessage.User.Nick, e.PrivateMessage.Message);
         };
     client.ConnectAsync();
     while (true) ;
 }
Exemplo n.º 2
0
 public static void SendNotice(IrcClient client, string message, params string[] destinations)
 {
     const string illegalCharacters = "\r\n\0";
     if (!destinations.Any()) throw new InvalidOperationException("Message must have at least one target.");
     if (illegalCharacters.Any(message.Contains)) throw new ArgumentException("Illegal characters are present in message.", "message");
     var to = string.Join(",", destinations);
     client.SendRawMessage("NOTICE {0} :{1}", to, message);
 }
Exemplo n.º 3
0
 static void Main(string[] args)
 {
     var client = new IrcClient("irc.freenode.net", new IrcUser("ChatSharp", "ChatSharp"));
     client.NetworkError += (s, e) => Console.WriteLine("Error: " + e.SocketError);
     client.RawMessageRecieved += (s, e) => Console.WriteLine("<< {0}", e.Message);
     client.RawMessageSent += (s, e) => Console.WriteLine(">> {0}", e.Message);
     client.UserMessageRecieved += (s, e) =>
         {
             if (e.PrivateMessage.Message.StartsWith(".join "))
                 client.Channels.Join(e.PrivateMessage.Message.Substring(6));
             else if (e.PrivateMessage.Message.StartsWith(".list "))
             {
                 var channel = client.Channels[e.PrivateMessage.Message.Substring(6)];
                 var list = channel.Users.Select(u => u.Nick).Aggregate((a, b) => a + "," + b);
                 client.SendMessage(list, e.PrivateMessage.User.Nick);
             }
             else if (e.PrivateMessage.Message.StartsWith(".whois "))
                 client.WhoIs(e.PrivateMessage.Message.Substring(7), null);
             else if (e.PrivateMessage.Message.StartsWith(".raw "))
                 client.SendRawMessage(e.PrivateMessage.Message.Substring(5));
             else if (e.PrivateMessage.Message.StartsWith(".mode "))
             {
                 var parts = e.PrivateMessage.Message.Split(' ');
                 client.ChangeMode(parts[1], parts[2]);
             }
             else if (e.PrivateMessage.Message.StartsWith(".topic "))
             {
                 string messageArgs = e.PrivateMessage.Message.Substring(7);
                 if (messageArgs.Contains(" "))
                 {
                     string channel = messageArgs.Substring(0, messageArgs.IndexOf(" "));
                     string topic = messageArgs.Substring(messageArgs.IndexOf(" ") + 1);
                     client.Channels[channel].SetTopic(topic);
                 }
                 else
                 {
                     string channel = messageArgs.Substring(messageArgs.IndexOf("#"));
                     client.GetTopic(channel);
                 }
             }
         };
     client.ChannelMessageRecieved += (s, e) =>
         {
             Console.WriteLine("<{0}> {1}", e.PrivateMessage.User.Nick, e.PrivateMessage.Message);
         };
     client.ChannelTopicReceived += (s, e) =>
         {
             Console.WriteLine("Received topic for channel {0}: {1}", e.Channel.Name, e.Topic);
         };
     client.ConnectAsync();
     while (true) ;
 }
Exemplo n.º 4
0
 static void Main(string[] args)
 {
     var client = new IrcClient("irc.freenode.net", new IrcUser("ChatSharp", "ChatSharp"));
     client.NetworkError += (s, e) => Console.WriteLine("Error: " + e.SocketError);
     client.RawMessageRecieved += (s, e) => Console.WriteLine("<< {0}", e.Message);
     client.RawMessageSent += (s, e) => Console.WriteLine(">> {0}", e.Message);
     client.UserMessageRecieved += (s, e) =>
         {
             if (e.PrivateMessage.Message.StartsWith(".join "))
                 client.Channels.Join(e.PrivateMessage.Message.Substring(6));
             else if (e.PrivateMessage.Message.StartsWith(".list "))
             {
                 var channel = client.Channels[e.PrivateMessage.Message.Substring(6)];
                 var list = channel.Users.Select(u => u.Nick).Aggregate((a, b) => a + "," + b);
                 client.SendMessage(list, e.PrivateMessage.User.Nick);
             }
             else if (e.PrivateMessage.Message.StartsWith(".whois "))
                 client.WhoIs(e.PrivateMessage.Message.Substring(7), null);
             else if (e.PrivateMessage.Message.StartsWith(".raw "))
                 client.SendRawMessage(e.PrivateMessage.Message.Substring(5));
             else if (e.PrivateMessage.Message.StartsWith(".bans "))
             {
                 client.GetBanList(e.PrivateMessage.Message.Substring(6), bans =>
                     {
                         client.SendMessage(string.Join(",", bans.Select(b =>
                             string.Format("{0} by {1} at {2}", b.Value, b.Creator, b.CreationTime)
                             ).ToArray()), e.PrivateMessage.User.Nick);
                     });
             }
             else if (e.PrivateMessage.Message.StartsWith(".exceptions "))
             {
                 client.GetExceptionList(e.PrivateMessage.Message.Substring(12), exceptions =>
                 {
                     client.SendMessage(string.Join(",", exceptions.Select(ex =>
                             string.Format("{0} by {1} at {2}", ex.Value, ex.Creator, ex.CreationTime)
                             ).ToArray()), e.PrivateMessage.User.Nick);
                 });
             }
         };
     client.ChannelMessageRecieved += (s, e) =>
         {
             Console.WriteLine("<{0}> {1}", e.PrivateMessage.User.Nick, e.PrivateMessage.Message);
         };
     client.ConnectAsync();
     while (true) ;
 }
Exemplo n.º 5
0
        private static void RunBotTest()
        {
            Console.ForegroundColor = ConsoleColor.Green;
            Console.WriteLine ("Connecting...");
            Console.ForegroundColor = ConsoleColor.White;

            client = new IrcClient (ProgramSettings.settings.LastJoinedServer, new IrcUser (ProgramSettings.settings.LastUsedNick, "luigibot-oss"));
            client.ConnectionComplete += (s, e) =>
            {
                Console.ForegroundColor = ConsoleColor.Green;
                Console.WriteLine ("Connected! Joining {0}..", ProgramSettings.settings.LastJoinedChannel);
                Console.ForegroundColor = ConsoleColor.White;

                Console.ForegroundColor = ConsoleColor.Green;
                client.JoinChannel (ProgramSettings.settings.LastJoinedChannel);
                Console.WriteLine ("Connected!");
                Console.ForegroundColor = ConsoleColor.White;

                Console.ForegroundColor = ConsoleColor.Yellow;
                Console.WriteLine("Attempting NickServ authentication..");
                Console.ForegroundColor = ConsoleColor.White;
                if (ProgramSettings.settings.NickServPass.Trim() != "")
                {
                    client.SendRawMessage("PRIVMSG NickServ :IDENTIFY {0}", encrypter.DecryptString(ProgramSettings.settings.NickServPass));
                }
                else
                    Console.WriteLine("No NickServ password set! Set using /setnickservpass`");

                Console.ForegroundColor = ConsoleColor.Green;
                Console.WriteLine ("Loading database..");
                Console.ForegroundColor = ConsoleColor.White;
                UsersSeenDatabase.LoadDatabase (client);

                Console.ForegroundColor = ConsoleColor.Green;
                Console.WriteLine ("Success!");
                Console.ForegroundColor = ConsoleColor.White;

                updateUsersListThread.Start ();
            };
            client.UserPartedChannel += (s, e) =>
            {
                DateTime now = DateTime.Now;
                foreach (IrcUserAndSeen u in UsersSeenDatabase.UsersSeenDatabase)
                {
                    if (u.User.Nick.ToLower() == e.User.Nick.ToLower())
                    {
                        UsersSeenDatabase.UsersSeenDatabase.Remove (u);
                        break;
                    }
                }
                UsersSeenDatabase.UsersSeenDatabase.Add (new IrcUserAndSeen (e.User, now));

                //Console.Beep(4400, 1000);
                Console.WriteLine ("Added new user to database {0} left at {1}", e.User.Nick, now.ToString ());
            };
            client.UserJoinedChannel += (s, e) =>
            {
                if (e.User.Nick.ToLower () == "axiom")
                {
                    client.SendAction ("welcomes daddy!", client.Channels [0].Name);
                    return;
                }
                if (ProgramSettings.settings.WelcomeUserEnabled)
                {
                    if (e.User.Nick != client.User.Nick)
                    {
                        if (ProgramSettings.settings.WelcomeMessage.Contains("/me"))
                        {
                            //set substring 4 to account for "/me" and the space after
                            client.SendAction(String.Format(ProgramSettings.settings.WelcomeMessage.Substring(4), e.User.Nick), client.Channels[0].Name);
                        }
                        else
                        {
                            client.SendRawMessage("PRIVMSG {0} :{1}",
                                client.Channels[0].Name,
                                String.Format(ProgramSettings.settings.WelcomeMessage, e.User.Nick));
                        }
                    }
                }
            };
            client.NoticeRecieved += (s, e) =>
            {
                Console.WriteLine ("NOTICE FROM {0}: {1}", e.Source, e.Notice.ToString ());
            };
            bool checkForNextHighfive = false;
            string firstuser = "";
            client.ChannelMessageRecieved += (s, e) =>
            {
                if (checkForNextHighfive)
                {
                    if (e.PrivateMessage.Message.Trim() == "\\o")
                    {
                        if(e.PrivateMessage.User.Nick != firstuser)
                            client.SendRawMessage("PRIVMSG {0} :{1} o/ *HIGHFIVED* \\o {2}!", client.Channels[0].Name, firstuser, e.PrivateMessage.User.Nick);
                    }
                    checkForNextHighfive = false;
                }

                var channel = client.Channels [e.PrivateMessage.Source];
                Console.WriteLine ("{0} - {1}: {2}", e.PrivateMessage.Source, e.PrivateMessage.User, e.PrivateMessage.Message); //just output the stuff boss

                if (e.PrivateMessage.Message.StartsWith(ProgramSettings.settings.CommandPrefix.ToString()))
                {
                    InterpretCommand(e.PrivateMessage.Message, e.PrivateMessage.User, client);
                }
                else if(e.PrivateMessage.Message.Contains("http://") || e.PrivateMessage.Message.Contains("https://"))
                {
                    if(ProgramSettings.settings.UrlParsingEnabled)
                            UrlSubmitted(e);
                }
                else if (e.PrivateMessage.Message.StartsWith(client.User.Nick))
                {
                    if (e.PrivateMessage.Message.Contains("help"))
                    {
                        client.SendRawMessage("PRIVMSG {0} :The current command prefix is: '{1}'. You can also find a list of my commands here: https://github.com/Luigifan/Luigibot/wiki/Luigibot-Commands",
                            client.Channels[0].Name, ProgramSettings.settings.CommandPrefix);
                    }
                }
                else if (e.PrivateMessage.Message.Trim() == "o/")
                {
                    checkForNextHighfive = true;
                    firstuser = e.PrivateMessage.User.Nick;
                }

            };
            client.ModeChanged += (s, e) =>
            {
                if (e.User.Nick == client.User.Nick)
                {
                    Console.ForegroundColor = ConsoleColor.Yellow;
                    Console.WriteLine("Mode changed, added: " + e.Change);
                    //string[] split = e.Change.Split(new char[] { ' ' }, 2);
                    //client.User.Mode += split[0].Trim('+');
                    Console.WriteLine("New mode: " + client.User.Mode);
                    Console.ForegroundColor = ConsoleColor.White;
                }
            };
            client.RawMessageRecieved += (s, e) =>
            {
                //:[email protected] QUIT :Client Quit
                string rawMessage = e.Message.ToString ();
                string[] split = rawMessage.Split (new char[] { ' ' }, 3);
                if (split.Length > 0)
                {
                    if (split [1] == "QUIT")
                    {
                        string[] username = split [0].Split (new char[] { '!' }, 2);
                        IrcUser ee = new IrcUser (username [0].ToString ().Trim (':'), username [1].ToString ().Trim ('~'));
                        DateTime now = DateTime.Now;
                        foreach (IrcUserAndSeen u in UsersSeenDatabase.UsersSeenDatabase)
                        {
                            if (u.User.Nick.ToLower() == ee.Nick.ToLower())
                            {
                                UsersSeenDatabase.UsersSeenDatabase.Remove (u);
                                break;
                            }
                        }
                        UsersSeenDatabase.UsersSeenDatabase.Add (new IrcUserAndSeen (ee, now));
                        Console.WriteLine ("Added new user to database {0} left at {1} (Quit)", ee.Nick, now.ToString ());
                    }
                }

            };
            client.ConnectAsync ();

            while (true)
                ; //just keeps everything going
        }
Exemplo n.º 6
0
        /// <summary>
        /// Interprets commands
        /// </summary>
        /// <param name="command">The full message</param>
        /// <param name="sender">The full sender</param>
        /// <param name="recipient">The full recipient</param>
        private static void InterpretCommand(string command, IrcUser sender, IrcClient client)
        {
            command = command.TrimStart(ProgramSettings.settings.CommandPrefix); //simply removes the prefix

            if (command.StartsWith ("slap"))
            {
                if (ProgramSettings.settings.SlapEnabled)
                {
                    string[] splitCommand = command.Split (new char[] { ' ' }, 2);
                    if (splitCommand.Length > 1)
                    {
                        var listCopy = UsersList;
                        bool foundUser = false;
                        try
                        {
                            foreach (IrcUserAndSeen user in listCopy)
                            {
                                if (user.User.Nick.ToLower () == splitCommand [1].ToLower ().Trim ())
                                {
                                    if (user.User.Nick == client.User.Nick)
                                        client.SendRawMessage ("PRIVMSG {0} :What'd I do? :(", client.Channels [0].Name);
                                    else
                                        client.SendRawMessage ("PRIVMSG {0} :" + "\x01" + "ACTION slaps {1} with a giant fish.\x01", client.Channels [0].Name, user.User.Nick);
                                    foundUser = true;
                                    break;
                                }
                            }
                            if (!foundUser)
                                client.SendRawMessage ("PRIVMSG {0} :User not found!");
                        }
                        catch{}
                    } else
                        client.SendRawMessage ("PRIVMSG {0} :Slap who?", client.Channels [0].Name);
                }
            }
            if (command.StartsWith("removeuser"))
            {
                string[] split = command.Split(new char[]{' '}, 2);
                Console.ForegroundColor = ConsoleColor.Yellow;
                if (split.Length > 1)
                {
                    bool removed = false;
                    for(int i = 0; i < ProgramSettings.settings.UsersAllowedToDisable.Count; i++)
                    {
                        if (ProgramSettings.settings.UsersAllowedToDisable[i] == split[1].ToLower())
                        {
                            ProgramSettings.settings.UsersAllowedToDisable.RemoveAt(i);
                            removed = true;
                        }
                    }
                    if (removed)
                    {
                        Console.WriteLine("Removed user \"{0}\" successfully!", split[1].ToLower());
                        client.SendRawMessage("PRIVMSG {0} :Removed user \"{1}\" successfully!", client.Channels[0].Name, split[1].ToLower());
                    }
                    else
                    {
                        Console.WriteLine("User doesn't exist!");
                        client.SendRawMessage("PRIVMSG {0} :That user never existed in the database!", client.Channels[0].Name);
                    }
                }
                else
                {
                    Console.WriteLine("Remove who?");
                }
                Console.ForegroundColor = ConsoleColor.White;
            }
            if (command.StartsWith("adduser"))
            {
                string[] split = command.Split(new char[]{' '}, 2);
                Console.ForegroundColor = ConsoleColor.Yellow;
                if (split.Length > 1)
                {
                    ProgramSettings.settings.UsersAllowedToDisable.Add(split[1].ToLower());
                    Console.WriteLine("Added user \"{0}\" to the VIP list", split[1].ToLower());
                    client.SendRawMessage("PRIVMSG {0} :Added user \"{1}\" to the VIP list.?", client.Channels[0].Name, split[1].ToLower());
                }
                else
                {
                    Console.WriteLine("Who?");
                    client.SendRawMessage("PRIVMSG {0} :Add who?", client.Channels[0].Name);
                }
                Console.ForegroundColor = ConsoleColor.White;
            }
            if (command.StartsWith("disableseen"))
            {
                foreach (string user in ProgramSettings.settings.UsersAllowedToDisable)
                {
                    if (user.ToLower() == sender.Nick.ToLower())
                    {
                        ProgramSettings.settings.SeenEnabled = false;

                        Console.ForegroundColor = ConsoleColor.Yellow;
                        Console.WriteLine ("Seen Command Disabled");
                        Console.ForegroundColor = ConsoleColor.White;
                        client.SendRawMessage ("PRIVMSG {0} :Disabled seen command!", client.Channels[0].Name);
                    }
                }
            }
            if (command.StartsWith("enableseen"))
            {
                foreach (string user in ProgramSettings.settings.UsersAllowedToDisable)
                {
                    if (user.ToLower() == sender.Nick.ToLower())
                    {
                        ProgramSettings.settings.SeenEnabled = true;

                        Console.ForegroundColor = ConsoleColor.Yellow;
                        Console.WriteLine ("Seen Command Enabled");
                        Console.ForegroundColor = ConsoleColor.White;
                        client.SendRawMessage ("PRIVMSG {0} :Enabled seen command!", client.Channels[0].Name);
                    }
                }
            }
            if (command.StartsWith ("enableurlparse"))
            {
                foreach (string user in ProgramSettings.settings.UsersAllowedToDisable)
                {
                    if (user.ToLower () == sender.Nick.ToLower ())
                    {
                        ProgramSettings.settings.UrlParsingEnabled = true;

                        Console.ForegroundColor = ConsoleColor.Yellow;
                        Console.WriteLine ("URL Parsing Enabled");
                        Console.ForegroundColor = ConsoleColor.White;
                        client.SendRawMessage ("PRIVMSG {0} :Enabling URL parsing!", client.Channels[0].Name);
                    }
                }
            }
            if (command.StartsWith ("disableurlparse"))
            {
                foreach (string user in ProgramSettings.settings.UsersAllowedToDisable)
                {
                    if (user.ToLower () == sender.Nick.ToLower ())
                    {
                        ProgramSettings.settings.UrlParsingEnabled = false;

                        Console.ForegroundColor = ConsoleColor.Yellow;
                        Console.WriteLine ("URL Parsing Disabled");
                        Console.ForegroundColor = ConsoleColor.White;
                        client.SendRawMessage ("PRIVMSG {0} :Disabling URL parsing!", client.Channels[0].Name);
                    }
                }
            }
            if (command.StartsWith ("nick") || command.StartsWith ("name"))
            {
                string[] splitCommand = command.Split (new char[]{ ' ' }, 2);
                if (splitCommand.Length > 1)
                {
                    foreach (string user in ProgramSettings.settings.UsersAllowedToDisable)
                    {
                        if (user.ToLower () == sender.Nick.ToLower ())
                        {
                            string cleanNick = CleanInput (splitCommand [1]);
                            client.Nick (cleanNick);
                            ProgramSettings.settings.LastUsedNick = client.User.Nick;
                        }
                    }
                }
            }
            if(command.StartsWith("motto") || command.StartsWith("slogan"))
            {
                client.SendRawMessage("PRIVMSG {0} :Luigibot does what Reta don't \u00a9", client.Channels[0].Name);
            }
            if(command.StartsWith("version"))
            {
                #if __MONOCS__
                client.SendRawMessage("PRIVMSG {0} :Luigibot v{1} - http://www.github.com/Luigifan/Luigibot - Running under Mono", client.Channels[0].Name, ProgramVersion.ToString());
                #else
                client.SendRawMessage("PRIVMSG {0} :Luigibot v{1} - http://www.github.com/Luigifan/Luigibot", client.Channels[0].Name, ProgramVersion.ToString());
                #endif
            }
            if(command.StartsWith("changeprefix"))
            {
                string[] splitCommand = command.Split(new char[] { ' ' }, 2);
                if (splitCommand.Length > 1)
                {
                    foreach (string user in ProgramSettings.settings.UsersAllowedToDisable)
                    {
                        if(user.ToLower() == sender.Nick.ToLower())
                        {
                            if (splitCommand[1].Length == 1)
                            {
                                if (splitCommand[1] == "/")
                                {
                                    client.SendRawMessage("PRIVMSG {0} :oi u cheeky c**t ill bash ur ead in i swear on me mum", client.Channels[0].Name);
                                    return;
                                }
                                try
                                {
                                    char newPrefix = char.Parse(splitCommand[1]);
                                    ProgramSettings.settings.CommandPrefix = newPrefix;

                                    Console.ForegroundColor = ConsoleColor.Yellow;
                                    Console.WriteLine("Command prefix changed to '{0}' successfully!", newPrefix.ToString());
                                    Console.ForegroundColor = ConsoleColor.White;

                                    client.SendRawMessage("PRIVMSG {0} :Command prefix changed to '{1}' successfully!", client.Channels[0].Name, newPrefix.ToString());
                                    return;
                                }
                                catch (Exception ex)
                                {
                                    client.SendRawMessage("PRIVMSG {0} :Uh-oh! Luigibot encountered an error. Email Luigifan @ [email protected]",
                                        client.Channels[0].Name);

                                    Console.ForegroundColor = ConsoleColor.Red;
                                    Console.WriteLine("UH OH BIG ERROR\nUH OH BIG ERROR");
                                    Console.ForegroundColor = ConsoleColor.White;
                                    Console.WriteLine(ex.Message + "\n");
                                }
                            }
                            else
                            {
                                client.SendRawMessage("PRIVMSG {0} :The prefix must be a single character!", client.Channels[0].Name);
                            }
                        }
                    }
                }
                else
                    client.SendRawMessage("PRIVMSG {0} :What character will prefix my commands?", client.Channels[0].Name);
            }
            if(command.StartsWith("kick"))
            {
                //0: command
                //1: user
                //2: reason
                string[] splitCommand = command.Split(new char[] { ' ' }, 3);
                foreach (string user in ProgramSettings.settings.UsersAllowedToDisable)
                {
                    if(user.ToLower() == sender.Nick.ToLower())
                    {
                        try
                        {
                            if (splitCommand.Length > 2)
                            {
                                client.KickUser(client.Channels[0].Name, splitCommand[1], splitCommand[2]);
                            }
                            else
                                client.KickUser(client.Channels[0].Name, splitCommand[1]);
                        }
                        catch (Exception ex)
                        {
                            Console.ForegroundColor = ConsoleColor.Red;
                            Console.WriteLine("ERROR: {0}", ex.Message);
                            Console.ForegroundColor = ConsoleColor.White;
                        }
                    }
                }
            }
            if(command.StartsWith("getmodes"))
            {
                client.SendMessage("Modes: " + client.User.Mode, client.Channels[0].Name);
            }
            if (command.StartsWith ("ann"))
            {
                string[] splitCommand = command.Split (new char[]{ ' ' }, 2);
                if (splitCommand.Length > 1)
                {
                    foreach (var nick in ProgramSettings.settings.UsersAllowedToDisable)
                    {
                        if (sender.Nick.ToLower () == nick)
                        {
                            if (splitCommand [1] == "test")
                            {
                                if (ProgramSettings.settings.WelcomeMessage.Contains ("/me"))
                                {
                                    client.SendAction (String.Format (ProgramSettings.settings.WelcomeMessage.Substring (4), sender.Nick), client.Channels [0].Name);
                                } else
                                {
                                    client.SendRawMessage ("PRIVMSG {0} :{1}",
                                        client.Channels [0].Name,
                                        String.Format (ProgramSettings.settings.WelcomeMessage, sender.Nick));
                                }
                            }
                            else
                            {
                                if(splitCommand[1].Contains("{") && splitCommand[1].Contains("}"))
                                {
                                    string[] tester = splitCommand[1].Split(new char[] { '{', '}' }, 3);
                                    foreach(string x in tester)
                                    {
                                        int xf = -1;
                                        bool parsed = false;
                                        try
                                        {
                                            xf = int.Parse(x.ToString());
                                            parsed = true;
                                        }
                                        catch{parsed = false;}

                                        if (parsed)
                                        {
                                            if (xf > 0 || xf < 0)
                                            {
                                                client.SendRawMessage("PRIVMSG {0} :ERROR: Index numbers can't be bigger than 0 or less than 0. MUST BE 0!", client.Channels[0].Name);
                                                return;
                                            }
                                        }
                                    }
                                }
                                ProgramSettings.settings.WelcomeMessage = splitCommand [1];
                                client.SendRawMessage ("PRIVMSG {0} :Welcome message set!", client.Channels [0].Name);
                                Console.ForegroundColor = ConsoleColor.Yellow;
                                Console.WriteLine ("New welcome message set: " + splitCommand [1]);
                                Console.ForegroundColor = ConsoleColor.White;
                            }
                        }
                    }
                }
                else
                {
                    client.SendRawMessage ("PRIVMSG {0} :What message do I set?", client.Channels[0].Name);
                }
            }
            if (command.StartsWith ("enableslap"))
            {
                foreach (var nick in ProgramSettings.settings.UsersAllowedToDisable)
                {
                    if (sender.Nick.ToLower () == nick)
                    {
                        ProgramSettings.settings.SlapEnabled = true;

                        Console.ForegroundColor = ConsoleColor.Yellow;
                        Console.WriteLine ("Enabling slap");
                        Console.ForegroundColor = ConsoleColor.White;

                        break;
                    }
                }
            }
            if (command.StartsWith ("enablewelcome"))
            {
                foreach (var nick in ProgramSettings.settings.UsersAllowedToDisable)
                {
                    if (sender.Nick.ToLower () == nick)
                    {
                        ProgramSettings.settings.WelcomeUserEnabled = true;

                        Console.ForegroundColor = ConsoleColor.Yellow;
                        Console.WriteLine ("Enabling welcome messages");
                        Console.ForegroundColor = ConsoleColor.White;

                        break;
                    }
                }
            }
            if (command.StartsWith ("disablewelcome"))
            {
                foreach (var nick in ProgramSettings.settings.UsersAllowedToDisable)
                {
                    if (sender.Nick.ToLower () == nick)
                    {
                        ProgramSettings.settings.WelcomeUserEnabled = false;

                        Console.ForegroundColor = ConsoleColor.Yellow;
                        Console.WriteLine ("Disabling welcome messages");
                        Console.ForegroundColor = ConsoleColor.White;

                        break;
                    }
                }
            }
            if (command.StartsWith ("disableslap"))
            {
                foreach (var nick in ProgramSettings.settings.UsersAllowedToDisable)
                {
                    if (sender.Nick.ToLower () == nick)
                    {
                        ProgramSettings.settings.SlapEnabled = false;

                        Console.ForegroundColor = ConsoleColor.Yellow;
                        Console.WriteLine ("Disabling slap");
                        Console.ForegroundColor = ConsoleColor.White;

                        break;
                    }
                }
            }
            if (command.StartsWith ("eightball") || command.StartsWith ("8ball") || command.StartsWith ("fortune"))
            {
                if (ProgramSettings.settings.EightballEnabled)
                {
                    int ranMessage = random.Next (EightballMessages.Length - 1);
                    if (command.ToLower ().Contains ("waluigibot1337") || command.ToLower ().Contains ("waluigibot") || command.ToLower ().Contains ("waluigi bot"))
                        client.SendRawMessage ("PRIVMSG {0} :Waluigibot is a tool and will never come to fruition.", client.Channels [0].Name);
                    else if (command.ToLower ().Contains ("bot") && !command.ToLower ().Contains ("luigi"))
                        client.SendRawMessage ("PRIVMSG {0} :Your bot is inadequate for the job.", client.Channels [0].Name);
                    else
                        client.SendRawMessage ("PRIVMSG {0} :{1}", client.Channels [0].Name, EightballMessages [ranMessage]);
                }
            }
            if (command.StartsWith ("status"))
            {
                client.SendRawMessage ("PRIVMSG {0} :Slap Enabled: {1}. Eight Ball Enabled: {2}. Welcome Enabled: {3}. Command Prefix: {4}. URL Parsing: {5}",
                    client.Channels [0].Name,
                    ProgramSettings.settings.SlapEnabled,
                    ProgramSettings.settings.EightballEnabled,
                    ProgramSettings.settings.WelcomeUserEnabled,
                    ProgramSettings.settings.CommandPrefix.ToString(),
                    ProgramSettings.settings.UrlParsingEnabled);
            }
            if (command.StartsWith ("lastfm"))
            {
                #if __MONOCS__
                client.SendRawMessage("PRIVMSG {0} :The Last.FM API we use isn't available on Mono.", client.Channels[0].Name);
                #elif __MSCS__
                string[] split = command.Split (new char[] { ' ' }, 2);
                if (split.Length > 1)
                {
                    client.SendRawMessage("PRIVMSG {0} :Sending LastFM request, this may take a few seconds..", client.Channels[0].Name);
                    try
                    {
                        var lastfmClient = new LastfmClient ("4de0532fe30150ee7a553e160fbbe0e0", "0686c5e41f20d2dc80b64958f2df0f0c");
                        var response = lastfmClient.User.GetRecentScrobbles (split [1].ToString ().Trim (), null, 0, 1);
                        LastTrack lastTrack = response.Result.Content [0];
                        client.SendRawMessage ("PRIVMSG {0} :{1} last listened to {2} by {3}.", client.Channels [0].Name, split [1].Trim (), lastTrack.Name, lastTrack.ArtistName);
                    }
                    catch (ArgumentOutOfRangeException iex)
                    {
                        client.SendRawMessage ("PRIVMSG {0} :That user doesn't exist or hasn't scrobbled anything yet!",
                            client.Channels [0].Name);
                    }
                    catch (Exception ex)
                    {
                        client.SendRawMessage ("PRIVMSG {0} :Uh-oh! Luigibot encountered an error. Email Luigifan @ [email protected]",
                            client.Channels [0].Name);

                        Console.ForegroundColor = ConsoleColor.Red;
                        Console.WriteLine ("UH OH BIG ERROR\nUH OH BIG ERROR");
                        Console.ForegroundColor = ConsoleColor.White;
                        Console.WriteLine (ex.Message + "\n");
                    }
                }
                #endif
            }
            if (command.StartsWith ("enable8ball") || command.StartsWith ("enableeightball"))
            {
                foreach (var nick in ProgramSettings.settings.UsersAllowedToDisable)
                {
                    if (sender.Nick.ToLower () == nick)
                    {
                        ProgramSettings.settings.EightballEnabled = true;

                        Console.ForegroundColor = ConsoleColor.Yellow;
                        Console.WriteLine ("Enabling eight ball");
                        Console.ForegroundColor = ConsoleColor.White;

                        break;
                    }
                }
            }
            if (command.StartsWith ("disable8ball") || command.StartsWith ("disableeightball"))
            {
                foreach (var nick in ProgramSettings.settings.UsersAllowedToDisable)
                {
                    if (sender.Nick.ToLower () == nick)
                    {
                        ProgramSettings.settings.EightballEnabled = false;

                        Console.ForegroundColor = ConsoleColor.Yellow;
                        Console.WriteLine ("Disabling eight ball");
                        Console.ForegroundColor = ConsoleColor.White;

                        break;
                    }
                }
            }
            if (command.StartsWith ("selfdestruct"))
            {
                foreach (var nick in ProgramSettings.settings.UsersAllowedToDisable)
                {
                    if (sender.Nick.ToLower () == nick)
                    {
                        ExitSafely ();
                        break;
                    }
                }
            }
            if (command.StartsWith ("42"))
            {
                client.SendRawMessage ("PRIVMSG {0} :The Answer to Life, the Universe, and Everything.", client.Channels [0].Name);
            }
            if (command.StartsWith ("commands"))
            {
                client.SendRawMessage ("PRIVMSG {0} :You can find a list of my commands here: https://github.com/Luigifan/Luigibot/wiki/Luigibot-Commands", client.Channels [0].Name);
            }
            if (command.StartsWith ("seen"))
            {
                string[] splitCommand = command.Split (new char[] { ' ' }, 2);
                if (splitCommand.Length > 1)
                {
                    if (splitCommand [1].ToLower () == "knux" || splitCommand [1].ToLower () == "knuckles" || splitCommand [1].ToLower () == "knuckles96")
                    {
                        client.SendRawMessage ("PRIVMSG {0} :Never.", client.Channels [0].Name);
                        return;
                    }
                    var UsersListCopy = UsersList;
                    var UserDatabaseCopy = UsersSeenDatabase.UsersSeenDatabase;
                    //First, check to see if the user is on now
                    bool foundInOnline = false;
                    foreach (IrcUserAndSeen user in UsersListCopy)
                    {
                        if (user.User.Nick.ToLower () == splitCommand [1].ToLower ().Trim ())
                        {
                            foundInOnline = true;
                            if (user.User.Nick == client.User.Nick)
                                client.SendRawMessage ("PRIVMSG {0} :I'm always online c:", client.Channels [0].Name);
                            else
                                client.SendRawMessage ("PRIVMSG {0} :That user is online now!", client.Channels [0].Name);
                            foundInOnline = true;
                            break;
                        }
                    }
                    //Then, we'll check the database
                    bool foundInDatabase = false;
                    List<IrcUserAndSeen> removeLater = new List<IrcUserAndSeen>();
                    if (!foundInOnline)
                    {
                        foreach (IrcUserAndSeen user in UserDatabaseCopy)
                        {
                            if (user.User.Nick == null)
                            {
                                Console.WriteLine("Adding null entry to be removed later");
                                removeLater.Add(user);
                            }
                            else
                            {
                                if (user.User.Nick.ToLower() == splitCommand[1].ToLower().Trim())
                                {
                                    foundInDatabase = true;
                                    client.SendRawMessage("PRIVMSG {0} :{1} was last seen at {2} (EST)", client.Channels[0].Name, user.User.Nick, user.LastSeen.ToString());
                                    break;
                                }
                            }
                        }
                        if (!foundInDatabase && !foundInOnline)
                            client.SendRawMessage ("PRIVMSG {0} :I'm not sure :(", client.Channels [0].Name);
                    }
                } else
                    client.SendRawMessage ("PRIVMSG {0} :Last seen who?", client.Channels [0].Name);
            }
        }
Exemplo n.º 7
0
        private void StartIrc()
        {
            var user = new IrcUser("");
            if (Properties.Settings.Default.nickserv == string.Empty)
                user = new IrcUser("twitchplaysagame", "twitchplaysagame");
            else
                user = new IrcUser(Properties.Settings.Default.user, Properties.Settings.Default.user);
            client = new IrcClient(Properties.Settings.Default.server, user);
            client.NetworkError += (s, e) => WriteConsole("Error: " + e.SocketError);

            client.ChannelMessageRecieved += (s, e) =>
            {
                ParseInput(e.PrivateMessage.User.Nick + ":" + e.PrivateMessage.Message);
            };
            client.ConnectionComplete += (s, e) =>
            {
                client.SendRawMessage("PRIVMSG {0} :{1}", "nickserv", "identify " + Properties.Settings.Default.nickserv);
                client.Channels.Join(Properties.Settings.Default.room);
                WriteConsole("Connected");
            };
            client.ConnectAsync();

            this.WriteConsole("Starting irc service");
            started = true;
            buttonStart.Text = "Stop";
        }
Exemplo n.º 8
0
        private static void RunBot(string nick, string server, string channel)
        {
            Console.ForegroundColor = ConsoleColor.Green;
            Console.Write("\nConnecting to " + ProgramSettings.settings.LastJoinedServer + " on port 6667....");
            Console.ForegroundColor = ConsoleColor.White;

            client = new IrcClient(ProgramSettings.settings.LastJoinedServer, new IrcUser(ProgramSettings.settings.LastUsedNick, "RetaSharp", "V54swg3!", "RetaReta"));
            client.NetworkError += (s, e) => Console.WriteLine("Error: " + e.SocketError);
            client.ConnectionComplete += (s, e) =>
            {
                Console.ForegroundColor = ConsoleColor.Green;
                Console.Write("\nConnected! Joining " + ProgramSettings.settings.LastJoinedChannel + "...");
                Console.ForegroundColor = ConsoleColor.White;
                client.JoinChannel(ProgramSettings.settings.LastJoinedChannel);
                Console.ForegroundColor = ConsoleColor.Green;
                Console.Write("\nSuccessfully joined " + ProgramSettings.settings.LastJoinedChannel + "\n");
                Console.ForegroundColor = ConsoleColor.White;

            };
            client.ConnectAsync();
            InputThread.Start();

            client.NoticeRecieved += (s, e) =>
            {
                Console.WriteLine("\nNOTICE FROM {0}: {1}", e.Source, e.Notice.ToString());
            };

            client.ChannelMessageRecieved += (s, e) =>
            {

                var channels = client.Channels[e.PrivateMessage.Source];
                Console.ForegroundColor = ConsoleColor.Gray;
                Console.WriteLine("{0} - {1}: {2}", e.PrivateMessage.Source, e.PrivateMessage.User, e.PrivateMessage.Message); //just output the stuff boss
                Console.ForegroundColor = ConsoleColor.White;

                if (e.PrivateMessage.Message.StartsWith(ProgramSettings.settings.Prefix.ToString()))
                {
                    ircCommands(e.PrivateMessage.Message, e.PrivateMessage.User, client);
                }
                else if (e.PrivateMessage.Message.Contains(client.User.Nick))
                {
                    if (e.PrivateMessage.Message.Contains("help"))
                    {
                        char commandpre = ProgramSettings.settings.Prefix;
                        client.SendRawMessage("PRIVMSG {0} :Hi! I'm a bot! The current prefix is {1}. You can get a list of my commands with {1}commands!", client.Channels[0].Name, commandpre);
                    }
                    if (e.PrivateMessage.Message.Contains("Hello".ToLower()) || e.PrivateMessage.Message.Contains("Hi".ToLower()) || e.PrivateMessage.Message.Contains("Hey".ToLower()) || e.PrivateMessage.Message.Contains("Howdy".ToLower()) || e.PrivateMessage.Message.Contains("Hola".ToLower()) || e.PrivateMessage.Message.Contains("Bonjour".ToLower()))
                    {

                        client.SendRawMessage("PRIVMSG {0} :Hello there!", client.Channels[0].Name);
                    }
                    if (e.PrivateMessage.Message.Contains("time"))
                    {
                        string time = DateTime.Now.ToString("h:mm:ss tt");
                        client.SendRawMessage("PRIVMSG {0} :The time is currently {1} UTC-8 (PST).", client.Channels[0].Name, time);
                    }
                    if (e.PrivateMessage.Message.Contains("how") && e.PrivateMessage.Message.Contains("are") || e.PrivateMessage.Message.Contains("you"))
                    {
                        int feels = random.Next(0,6);
                        string imfeeling = feeling[feels];
                        client.SendRawMessage("PRIVMSG {0} :{1}.", client.Channels[0].Name, imfeeling);
                    }

                    if (e.PrivateMessage.Message.Contains("hug") || e.PrivateMessage.Message.Contains("hugs"))
                    {
                        client.SendRawMessage("PRIVMSG {0} :" + "\x01" + "ACTION hugs {1} back.\x01", client.Channels[0].Name, e.PrivateMessage.User.Nick);
                    }

                    if (e.PrivateMessage.Message.Contains("kiss") || e.PrivateMessage.Message.Contains("kisses") || e.PrivateMessage.Message.Contains("makes out"))
                    {
                        client.SendRawMessage("PRIVMSG {0} :" + "\x01" + "ACTION pushes {1} away.\x01", client.Channels[0].Name, e.PrivateMessage.User.Nick);
                        client.SendRawMessage("PRIVMSG {0} :Uhm...no kissing me, {1}.", client.Channels[0].Name, e.PrivateMessage.User.Nick);
                    }
                    if (e.PrivateMessage.Message.Contains("sex") || e.PrivateMessage.Message.Contains("f**k") || e.PrivateMessage.Message.Contains("f***s") || e.PrivateMessage.Message.Contains("humps") || e.PrivateMessage.Message.Contains("rapes") || e.PrivateMessage.Message.Contains("inappropriate") && e.PrivateMessage.Message.Contains("place") || e.PrivateMessage.Message.Contains("places"))
                    {
                        client.SendRawMessage("PRIVMSG {0} :" + "\x01" + "ACTION punches {1}.\x01", client.Channels[0].Name, e.PrivateMessage.User.Nick);
                        client.SendRawMessage("PRIVMSG {0} :DON'T TOUCH ME, {1}!", client.Channels[0].Name, e.PrivateMessage.User.Nick.ToUpper());
                        try
                        {
                            client.SendRawMessage("PRIVMSG CHANSERV :op");
                            try
                            {
                                client.KickUser(client.Channels[0].Name, e.PrivateMessage.User.Nick, "EXPLOIT!");
                            }
                            catch
                            {
                                client.SendRawMessage("PRIVMSG {0} :IF ONLY I COULD KICK YOU...!", client.Channels[0].Name);
                            }
                            client.SendRawMessage("PRIVMSG CHANSERV :deop");
                        }
                        catch
                        {
                            client.SendRawMessage("PRIVMSG {0} :I NEED AN ADMIN!", client.Channels[0].Name);
                        }
                    }

                    if (e.PrivateMessage.Message.Contains("joke"))
                    {
                        Jokes.Joke();
                        client.SendRawMessage("PRIVMSG {0} :{1}", client.Channels[0].Name, Jokes.thisjoke);
                        Console.WriteLine("The joke was " + Jokes.randJoke);
                    }

                }
                else
                {

                    if (e.PrivateMessage.Message.Contains("http://") || e.PrivateMessage.Message.Contains("https://") || e.PrivateMessage.Message.Contains("www.") || e.PrivateMessage.Message.Contains(".com") || e.PrivateMessage.Message.Contains(".net") || e.PrivateMessage.Message.Contains(".org") || e.PrivateMessage.Message.Contains(".ca") || e.PrivateMessage.Message.Contains(".us") || e.PrivateMessage.Message.Contains(".io") || e.PrivateMessage.Message.Contains(".mx") && !e.PrivateMessage.Message.Contains("dnp"))
                    {

                            try
                            {
                                string privatemessage = e.PrivateMessage.Message;
                                WebClient x = new WebClient();
                                client.SendRawMessage("NOTICE {0} :{0} Hold on, grabbing link title...", e.PrivateMessage.User.Nick);
                                string url = e.PrivateMessage.Message.Substring(e.PrivateMessage.Message.LastIndexOf("http://"));
                                string[] cleaned = url.Split(new char[] { ' ' }, 2);
                                if (e.PrivateMessage.Message.Contains(".xxx") || e.PrivateMessage.Message.Contains("p**n"))
                                {
                                    client.SendRawMessage("PRIVMSG {0} :Thanks for posting p**n here, {1}", client.Channels[0].Name, e.PrivateMessage.User.Nick);
                                    return;
                                }
                                string source = x.DownloadString(cleaned[0]);
                                string title = Regex.Match(source, @"\<title\b[^>]*\>\s*(?<Title>[\s\S]*?)\</title\>", RegexOptions.IgnoreCase).Groups["Title"].Value;
                                client.SendRawMessage("PRIVMSG {0} :{3} submitted a link : [ {1} ] - {2}.", client.Channels[0].Name, title, cleaned[0], e.PrivateMessage.User.Nick);
                            }
                            catch
                            {
                                //Do nothing.
                            }
                    }

                    }

            };

            while (true)
                ; //just keeps everything going
        }
Exemplo n.º 9
0
        private static void RunBotTest()
        {
            Console.ForegroundColor = ConsoleColor.Green;
            Console.WriteLine ("Connecting...");
            Console.ForegroundColor = ConsoleColor.White;

            client = new IrcClient (ProgramSettings.settings.LastJoinedServer, new IrcUser (ProgramSettings.settings.LastUsedNick, "luigibot-oss"));
            client.ConnectionComplete += (s, e) =>
            {
                Console.ForegroundColor = ConsoleColor.Green;
                Console.WriteLine ("Connected! Joining {0}..", ProgramSettings.settings.LastJoinedChannel);
                Console.ForegroundColor = ConsoleColor.White;

                Console.ForegroundColor = ConsoleColor.Green;
                client.JoinChannel (ProgramSettings.settings.LastJoinedChannel);
                Console.WriteLine ("Connected!");
                Console.ForegroundColor = ConsoleColor.White;

                Console.ForegroundColor = ConsoleColor.Green;
                Console.WriteLine ("Loading database..");
                Console.ForegroundColor = ConsoleColor.White;
                UsersSeenDatabase.LoadDatabase (client);

                Console.ForegroundColor = ConsoleColor.Green;
                Console.WriteLine ("Success!");
                Console.ForegroundColor = ConsoleColor.White;

                updateUsersListThread.Start ();
            };
            client.UserPartedChannel += (s, e) =>
            {
                DateTime now = DateTime.Now;
                foreach (IrcUserAndSeen u in UsersSeenDatabase.UsersSeenDatabase)
                {
                    if (u.User == e.User)
                        UsersSeenDatabase.UsersSeenDatabase.Remove (u);
                }
                UsersSeenDatabase.UsersSeenDatabase.Add (new IrcUserAndSeen (e.User, now));

                //Console.Beep(4400, 1000);
                Console.WriteLine ("Added new user to database {0} left at {1}", e.User.Nick, now.ToString ());
            };
            client.UserJoinedChannel += (s, e) =>
            {
                if (e.User.Nick.ToLower () == "luigifan2010")
                {
                    client.SendAction ("welcomes daddy!", client.Channels [0].Name);
                    return;
                }
                if (ProgramSettings.settings.WelcomeUserEnabled)
                {
                    if(ProgramSettings.settings.WelcomeMessage.Contains("/me"))
                    {
                        //set substring 4 to account for "/me" and the space after
                        client.SendAction(String.Format(ProgramSettings.settings.WelcomeMessage.Substring(4), e.User.Nick), client.Channels[0].Name);
                    }
                    else
                    {
                        client.SendRawMessage("PRIVMSG {0} :{1}",
                            client.Channels[0].Name,
                            String.Format(ProgramSettings.settings.WelcomeMessage, e.User.Nick));
                    }
                }
            };
            client.NoticeRecieved += (s, e) =>
            {
                Console.WriteLine ("NOTICE FROM {0}: {1}", e.Source, e.Notice.ToString ());
            };
            client.ChannelMessageRecieved += (s, e) =>
            {
                var channel = client.Channels [e.PrivateMessage.Source];
                Console.WriteLine ("{0} - {1}: {2}", e.PrivateMessage.Source, e.PrivateMessage.User, e.PrivateMessage.Message); //just output the stuff boss

                if (e.PrivateMessage.Message.StartsWith ("!"))
                {
                    client.SendRawMessage("PRIVMSG {0} :Commands are now prefixed with a ? instead of an !.", client.Channels[0].Name);
                    InterpretCommand (e.PrivateMessage.Message, e.PrivateMessage.User, client);
                }
                else if (e.PrivateMessage.Message.StartsWith ("?"))
                {
                    InterpretCommand (e.PrivateMessage.Message, e.PrivateMessage.User, client);
                }
            };
            client.RawMessageRecieved += (s, e) =>
            {
                //:[email protected] QUIT :Client Quit
                string rawMessage = e.Message.ToString ();
                string[] split = rawMessage.Split (new char[] { ' ' }, 3);
                if (split.Length > 0)
                {
                    if (split [1] == "QUIT")
                    {
                        string[] username = split [0].Split (new char[] { '!' }, 2);
                        IrcUser ee = new IrcUser (username [0].ToString ().Trim (':'), username [1].ToString ().Trim ('~'));
                        DateTime now = DateTime.Now;
                        foreach (IrcUserAndSeen u in UsersSeenDatabase.UsersSeenDatabase)
                        {
                            if (u.User == ee)
                                UsersSeenDatabase.UsersSeenDatabase.Remove (u);
                        }
                        UsersSeenDatabase.UsersSeenDatabase.Add (new IrcUserAndSeen (ee, now));
                        Console.WriteLine ("Added new user to database {0} left at {1} (Quit)", ee.Nick, now.ToString ());
                    }
                }

            };
            client.ConnectAsync ();

            while (true)
                ; //just keeps everything going
        }
Exemplo n.º 10
0
        /// <summary>
        /// Interprets commands
        /// </summary>
        /// <param name="command">The full message</param>
        /// <param name="sender">The full sender</param>
        /// <param name="recipient">The full recipient</param>
        private static void InterpretCommand(string command, IrcUser sender, IrcClient client)
        {
            if (command.StartsWith ("?slap"))
            {
                if (ProgramSettings.settings.SlapEnabled)
                {
                    string[] splitCommand = command.Split (new char[] { ' ' }, 2);
                    if (splitCommand.Length > 1)
                    {
                        var listCopy = UsersList;
                        bool foundUser = false;
                        try
                        {
                            foreach (IrcUserAndSeen user in listCopy)
                            {
                                if (user.User.Nick.ToLower () == splitCommand [1].ToLower ().Trim ())
                                {
                                    if (user.User.Nick == client.User.Nick)
                                        client.SendRawMessage ("PRIVMSG {0} :What'd I do? :(", client.Channels [0].Name);
                                    else
                                        client.SendRawMessage ("PRIVMSG {0} :" + "\x01" + "ACTION slaps {1} with a giant fish.\x01", client.Channels [0].Name, user.User.Nick);
                                    foundUser = true;
                                    break;
                                }
                            }
                            if (!foundUser)
                                client.SendRawMessage ("PRIVMSG {0} :User not found!");
                        } catch (Exception ex)
                        {
                        }
                    } else
                        client.SendRawMessage ("PRIVMSG {0} :Slap who?", client.Channels [0].Name);
                }
            }
            if (command.StartsWith ("?ann"))
            {
                string[] splitCommand = command.Split (new char[]{ ' ' }, 2);
                if (splitCommand.Length > 1)
                {
                    foreach (var nick in ProgramSettings.settings.UsersAllowedToDisable)
                    {
                        if (sender.Nick.ToLower () == nick)
                        {
                            if (splitCommand [1] == "test")
                            {
                                if (ProgramSettings.settings.WelcomeMessage.Contains ("/me"))
                                {
                                    client.SendAction (String.Format (ProgramSettings.settings.WelcomeMessage.Substring (4), sender), client.Channels [0].Name);
                                } else
                                {
                                    client.SendRawMessage ("PRIVMSG {0} :{1}",
                                        client.Channels [0].Name,
                                        String.Format (ProgramSettings.settings.WelcomeMessage, sender));
                                }
                            } else
                            {
                                ProgramSettings.settings.WelcomeMessage = splitCommand [1];
                                client.SendRawMessage ("PRIVMSG {0} :Welcome message set!", client.Channels [0].Name);
                                Console.ForegroundColor = ConsoleColor.Yellow;
                                Console.WriteLine ("New welcome message set: " + splitCommand [1]);
                                Console.BackgroundColor = ConsoleColor.White;
                            }
                        }
                    }
                }
                else
                {
                    client.SendRawMessage ("PRIVMSG {0} :What message do I set?", client.Channels[0].Name);
                }
            }
            if (command.StartsWith ("?enableslap"))
            {
                foreach (var nick in ProgramSettings.settings.UsersAllowedToDisable)
                {
                    if (sender.Nick.ToLower () == nick)
                    {
                        ProgramSettings.settings.SlapEnabled = true;

                        Console.ForegroundColor = ConsoleColor.Yellow;
                        Console.WriteLine ("Enabling slap");
                        Console.ForegroundColor = ConsoleColor.White;

                        break;
                    }
                }
            }
            if (command.StartsWith ("?enablewelcome"))
            {
                foreach (var nick in ProgramSettings.settings.UsersAllowedToDisable)
                {
                    if (sender.Nick.ToLower () == nick)
                    {
                        ProgramSettings.settings.WelcomeUserEnabled = true;

                        Console.ForegroundColor = ConsoleColor.Yellow;
                        Console.WriteLine ("Enabling welcome messages");
                        Console.ForegroundColor = ConsoleColor.White;

                        break;
                    }
                }
            }
            if (command.StartsWith ("?disablewelcome"))
            {
                foreach (var nick in ProgramSettings.settings.UsersAllowedToDisable)
                {
                    if (sender.Nick.ToLower () == nick)
                    {
                        ProgramSettings.settings.WelcomeUserEnabled = false;

                        Console.ForegroundColor = ConsoleColor.Yellow;
                        Console.WriteLine ("Disabling welcome messages");
                        Console.ForegroundColor = ConsoleColor.White;

                        break;
                    }
                }
            }
            if (command.StartsWith ("?disableslap"))
            {
                foreach (var nick in ProgramSettings.settings.UsersAllowedToDisable)
                {
                    if (sender.Nick.ToLower () == nick)
                    {
                        ProgramSettings.settings.SlapEnabled = false;

                        Console.ForegroundColor = ConsoleColor.Yellow;
                        Console.WriteLine ("Disabling slap");
                        Console.ForegroundColor = ConsoleColor.White;

                        break;
                    }
                }
            }
            if (command.StartsWith ("?eightball") || command.StartsWith ("!8ball") || command.StartsWith ("!fortune"))
            {
                if (ProgramSettings.settings.EightballEnabled)
                {
                    int ranMessage = random.Next (EightballMessages.Length - 1);
                    if (command.ToLower ().Contains ("waluigibot1337") || command.ToLower ().Contains ("waluigibot") || command.ToLower ().Contains ("waluigi bot"))
                        client.SendRawMessage ("PRIVMSG {0} :Waluigibot is a tool and will never come to fruition.", client.Channels [0].Name);
                    else if (command.ToLower ().Contains ("bot") && !command.ToLower ().Contains ("luigi"))
                        client.SendRawMessage ("PRIVMSG {0} :Your bot is inadequate for the job.", client.Channels [0].Name);
                    else
                        client.SendRawMessage ("PRIVMSG {0} :{1}", client.Channels [0].Name, EightballMessages [ranMessage]);
                }
            }
            if (command.StartsWith ("?status"))
            {
                client.SendRawMessage ("PRIVMSG {0} :Slap Enabled: {1}. Eight Ball Enabled: {2}. Welcome Enabled: {3}",
                    client.Channels [0].Name,
                    ProgramSettings.settings.SlapEnabled,
                    ProgramSettings.settings.EightballEnabled,
                    ProgramSettings.settings.WelcomeUserEnabled);
            }
            if (command.StartsWith ("?lastfm"))
            {
                string[] split = command.Split (new char[] { ' ' }, 2);
                if (split.Length > 1)
                {
                    try
                    {
                        var lastfmClient = new LastfmClient ("4de0532fe30150ee7a553e160fbbe0e0", "0686c5e41f20d2dc80b64958f2df0f0c");
                        var response = lastfmClient.User.GetRecentScrobbles (split [1].ToString ().Trim (), null, 0, 1);
                        LastTrack lastTrack = response.Result.Content [0];
                        client.SendRawMessage ("PRIVMSG {0} :{1} last listened to {2} by {3}.", client.Channels [0].Name, split [1].Trim (), lastTrack.Name, lastTrack.ArtistName);
                    } catch (ArgumentOutOfRangeException iex)
                    {
                        client.SendRawMessage ("PRIVMSG {0} :That user doesn't exist or hasn't scrobbled anything yet!",
                            client.Channels [0].Name);
                    } catch (Exception ex)
                    {
                        client.SendRawMessage ("PRIVMSG {0} :Uh-oh! Luigibot encountered an error. Email Luigifan @ [email protected]",
                            client.Channels [0].Name);

                        Console.ForegroundColor = ConsoleColor.Red;
                        Console.WriteLine ("UH OH BIG ERROR\nUH OH BIG ERROR");
                        Console.ForegroundColor = ConsoleColor.White;
                        Console.WriteLine (ex.Message + "\n");
                    }
                }
            }
            if (command.StartsWith ("?enable8ball") || command.StartsWith ("!enableeightball"))
            {
                foreach (var nick in ProgramSettings.settings.UsersAllowedToDisable)
                {
                    if (sender.Nick.ToLower () == nick)
                    {
                        ProgramSettings.settings.EightballEnabled = true;

                        Console.ForegroundColor = ConsoleColor.Yellow;
                        Console.WriteLine ("Enabling eight ball");
                        Console.ForegroundColor = ConsoleColor.White;

                        break;
                    }
                }
            }
            if (command.StartsWith ("?disable8ball") || command.StartsWith ("!disableeightball"))
            {
                foreach (var nick in ProgramSettings.settings.UsersAllowedToDisable)
                {
                    if (sender.Nick.ToLower () == nick)
                    {
                        ProgramSettings.settings.EightballEnabled = false;

                        Console.ForegroundColor = ConsoleColor.Yellow;
                        Console.WriteLine ("Disabling eight ball");
                        Console.ForegroundColor = ConsoleColor.White;

                        break;
                    }
                }
            }
            if (command.StartsWith ("?selfdestruct"))
            {
                foreach (var nick in ProgramSettings.settings.UsersAllowedToDisable)
                {
                    if (sender.Nick.ToLower () == nick)
                    {
                        ExitSafely ();
                        break;
                    }
                }
            }
            if (command.StartsWith ("?42"))
            {
                client.SendRawMessage ("PRIVMSG {0} :The Answer to Life, the Universe, and Everything.", client.Channels [0].Name);
            }
            if (command.StartsWith ("?commands"))
            {
                client.SendRawMessage ("PRIVMSG {0} :You can find a list of my commands here: https://github.com/Luigifan/Luigibot/wiki/Luigibot-Commands", client.Channels [0].Name);
            }
            if (command.StartsWith ("?seen"))
            {
                string[] splitCommand = command.Split (new char[] { ' ' }, 2);
                if (splitCommand.Length > 1)
                {
                    if (splitCommand [1].ToLower () == "knux" || splitCommand [1].ToLower () == "knuckles" || splitCommand [1].ToLower () == "knuckles96")
                    {
                        client.SendRawMessage ("PRIVMSG {0} :Never.", client.Channels [0].Name);
                        return;
                    }
                    var UsersListCopy = UsersList;
                    var UserDatabaseCopy = UsersSeenDatabase.UsersSeenDatabase;
                    //First, check to see if the user is on now
                    bool foundInOnline = false;
                    foreach (IrcUserAndSeen user in UsersListCopy)
                    {
                        if (user.User.Nick.ToLower () == splitCommand [1].ToLower ().Trim ())
                        {
                            foundInOnline = true;
                            if (user.User.Nick == client.User.Nick)
                                client.SendRawMessage ("PRIVMSG {0} :I'm always online c:", client.Channels [0].Name);
                            else
                                client.SendRawMessage ("PRIVMSG {0} :That user is online now!", client.Channels [0].Name);
                            foundInOnline = true;
                            break;
                        }
                    }
                    //Then, we'll check the database
                    bool foundInDatabase = false;
                    if (!foundInOnline)
                    {
                        foreach (IrcUserAndSeen user in UserDatabaseCopy)
                        {
                            if (user.User.Nick.ToLower () == splitCommand [1].ToLower ().Trim ())
                            {
                                foundInDatabase = true;
                                client.SendRawMessage ("PRIVMSG {0} :{1} was last seen at {2} (EST)", client.Channels [0].Name, user.User.Nick, user.LastSeen.ToString ());
                                break;
                            }
                        }
                        if (!foundInDatabase && !foundInOnline)
                            client.SendRawMessage ("PRIVMSG {0} :I'm not sure :(", client.Channels [0].Name);
                    }
                } else
                    client.SendRawMessage ("PRIVMSG {0} :Last seen who?", client.Channels [0].Name);
            }
        }