Esempio n. 1
0
        static void client_PrivateMessage(Client sender, PrivateMessage privateMessage)
        {
            string user = privateMessage.User.Split('!')[0];
            string rcpt = privateMessage.Recipient;
            if (privateMessage.Recipient == sender.Config.Nickname)
            {
                rcpt = user;
            }

            if (privateMessage.Message.StartsWith("."))
            {

                string cmd = privateMessage.Message;
                string msg = "";

                if (privateMessage.Message.Contains(' '))
                {
                    cmd = privateMessage.Message.Substring(0, privateMessage.Message.IndexOf(' '));
                    msg = privateMessage.Message.Substring(cmd.Length + 1, privateMessage.Message.Length - cmd.Length - 1);
                }

                switch (cmd.ToUpper())
                {
                    case ".JOIN":
                        if (msg.Contains(' '))
                        {
                            msg = msg.Split(' ')[0];
                        }
                        sender.Join(msg);
                        break;
                    case ".PART":
                        if (msg.Contains(' '))
                        {
                            sender.Leave(msg.Split(' ')[0]);
                        }
                        else
                        {
                            if (rcpt.StartsWith("#"))
                            {
                                sender.Leave(rcpt);
                            }
                        }
                        break;
                    case ".WAVE":
                        sender.Send(rcpt, "o/");
                        break;

                    case ".SEEN":

                        break;
                }
            }
        }
Esempio n. 2
0
        static void c_PrivateMessage(Client sender, Iris.Irc.ServerMessages.PrivateMessage privateMessage)
        {
            ircSettings i = iSettings[sender];
            string user = privateMessage.User.Split('!')[0];
            string rcpt = privateMessage.Recipient;
            if (privateMessage.Recipient == sender.Config.Nickname)
            {
                rcpt = user;
            }

            update_seen(sender, user, rcpt, privateMessage.Message);

            if (privateMessage.Message.StartsWith("."))
            {

                string cmd = privateMessage.Message;
                string msg = "";

                if (privateMessage.Message.Contains(' '))
                {
                    cmd = privateMessage.Message.Substring(0, privateMessage.Message.IndexOf(' '));
                    msg = privateMessage.Message.Substring(cmd.Length + 1, privateMessage.Message.Length - cmd.Length - 1);
                }
                if (check_auth(sender, user))
                {
                    switch (cmd.ToUpper())
                    {
                        case ".JOIN":
                            if (msg.Contains(' '))
                            {
                                msg = msg.Split(' ')[0];
                            }
                            sender.Join(msg);
                            break;
                        case ".PART":
                            if (msg.Contains(' '))
                            {
                                sender.Leave(msg.Split(' ')[0]);
                            }
                            else
                            {
                                if (rcpt.StartsWith("#"))
                                {
                                    sender.Leave(rcpt);
                                }
                            }
                            break;
                        case ".GOOGLE":
                            sender.Send(rcpt, "https://www.google.com.au/search?q=" + msg.Replace(' ', '+'));
                            break;
                        case ".WAVE":
                            sender.Send(rcpt, "o/");
                            break;

                        case ".SEEN":
                            if (check_auth(sender, user))
                            {
                                find_seen(sender, user, rcpt, msg);
                            }
                            break;
                        case ".INFO":
                            sender.Send(rcpt, "An IRC BOT Written by Nishtown, Based off IRIS by Banane9");
                            break;

                        case ".ADDAUTH":
                            if (check_auth(sender, user))
                            {

                                if (msg.Contains(' '))
                                {
                                    msg = msg.Split(' ')[0];
                                }
                                i.auth.Add(msg);
                                iSettings[sender] = i;
                            }
                            break;

                    }
                }
            }
        }
Esempio n. 3
0
        static void find_seen(Client sender, string user, string rcpt, string msg)
        {
            ircSettings i = iSettings[sender];

            string db = i.server.Split('.')[1] + ".db";

            if (File.Exists(db))
            {
                if (msg.Contains(' '))
                {
                    msg = msg.Split(' ')[0];
                }
                msg = msg.Replace("\'", "");
                SQLiteConnection sql = new SQLiteConnection("data source=" + db);
                sql.Open();
                using (SQLiteCommand com = new SQLiteCommand(sql))
                {
                    com.CommandText = "SELECT * FROM seen WHERE UPPER(sUSER)='" + msg.ToUpper() + "'";
                    using (SQLiteDataReader res = com.ExecuteReader())
                    {
                        if (res.HasRows)
                        {
                            while (res.Read())
                            {
                                string sUser = res["sUSER"].ToString();
                                string sChannel = res["sCHANNEL"].ToString();
                                string sMsg = res["sMSG"].ToString();
                                string sDate = res["sDATE"].ToString();
                                if (sChannel.StartsWith("#") == false)
                                {
                                    sChannel = "PRIVATE";
                                }
                                sMsg = sMsg.Replace("'", "\'");
                                sender.Send(rcpt, "Last seen " + sUser + " in " + sChannel + " at " + sDate + " saying: '" + sMsg + "'");
                            }
                        }
                        else
                        {
                            sender.Send(rcpt, msg + " has not been seen :(");
                        }
                    }
                }
                sql.Close();
                sql.Dispose();
            }
            else
            {
                sender.Send(rcpt, msg + " has not been seen :(");
            }
        }