Esempio n. 1
0
 public void LogoutUser(User user)
 {
     if (loggedin.Contains(user))
     {
         loggedin.Remove(user);
     }
 }
Esempio n. 2
0
        /// <summary>
        /// Confirm identity of logging in user
        /// </summary>
        /// <param name="n"></param>
        /// <param name="e"></param>
        protected void loginconf(Network n, Irc.IrcEventArgs e)
        {
            if (IsMatch("^everify (?<nonce>.*?)$", e.Data.Message.Substring(BOT_CONTROL_SEQ.Length)))
            {
                string[] temp = Matches["nonce"].Value.Split(':');
                string name = temp[0];
                SQLiteDatabase db = new SQLiteDatabase();
                System.Data.DataTable accounts;
                String query = "SELECT id \"ID\", name \"NAME\", email \"EMAIL\", gpgkey \"key\", verify \"VERIFY\" FROM accounts;";
                accounts = db.GetDataTable(query);
                bool registered = false;
                int id = 0;
                foreach (DataRow account in accounts.Rows)
                {
                    id++;
                    if (account["NAME"] as string == name)
                    {
                        Answer(n, e, "Name from verify string:   " + name);
                        Answer(n, e, "Verify string from db:     " + account["VERIFY"].ToString());
                        Answer(n, e, "Verify string from irc:    " + Matches["nonce"].Value);

                        if (account["VERIFY"].ToString().ToLower() == Matches["nonce"].Value.ToLower() + "\n")
                        {
                            User u = new User();
                            u.nick = e.Data.Nick;
                            u.user = name;
                            u.kid = account["key"] as string;
                            loggedin.Add(u);

                            //LOGIN THE USER AT THE BOT LEVEL SO OTHER PLUGINS CAN SEE
                            Bot.LoginUser(u);

                            //JUST ANOTHER WAY TO REPLY TO THE USER
                            Answer(n, e, e.Data.Nick + ": You are now logged in.");
                            registered = true;
                        }
                        else
                        {
                            Answer(n, e, e.Data.Nick + ": Invalid login.");
                        }
                    }
                }

                if (!registered)
                {
                    Answer(n, e, e.Data.Nick + ": Your not registered.");
                }
            }
        }
Esempio n. 3
0
 public void LoginUser(User user)
 {
     if (!loggedin.Contains(user))
     {
         loggedin.Add(user);
     }
 }