示例#1
0
        public void DeleteUserFromDatabase()
        {
            Console.WriteLine("Please enter the handle of the user you want to delete.");
            Console.Write("@");
            string wantedname = Console.ReadLine();
            long   wantedId   = TwitterHelper.GetUserIdFromUsername(service, wantedname).Id;

            foreach (User user in userList.List)
            {
                if (user.Name == wantedname || user.UserId == wantedId)
                {
                    userList.List.Remove(user);
                    Console.WriteLine("User removed.");
                    userList.Save();
                    return;
                }
            }
            Console.WriteLine("No user called " + wantedname + " was found.");
        }
示例#2
0
        public void AddUserToDatabase()
        {
            Console.WriteLine("Please enter the handle of the user you want to add.");
            Console.Write("@");
            string      username = Console.ReadLine();
            TwitterUser user     = TwitterHelper.GetUserIdFromUsername(service, username);

            if (user == null)
            {
                Console.WriteLine("Unknown user! Please retry!");
                return;
            }
            Console.WriteLine("What type of messages do you want to send to this user?");
            Console.WriteLine("'0' for random messages.");
            Console.WriteLine("'1' for hate messages.");
            Console.WriteLine("'2' for neutral messages.");
            Console.WriteLine("'3' for nice messages.");
            Console.Write("> ");

            char pressedkey = Char.ToUpper(Console.ReadKey().KeyChar);
            byte mode;

            if (Byte.TryParse(pressedkey.ToString(), out mode) == false)
            {
                Console.WriteLine("Not a number, please try again!");
                return;
            }
            Console.WriteLine("");
            List <byte> validModes = new List <byte> {
                0, 1, 2, 3
            };

            if (validModes.IndexOf(mode) == -1)
            {
                Console.WriteLine("Unknown mode, please try again!");
                return;
            }
            userList.List.Add(new User(user.Id, (TextLists.TextCategory)mode, user.ScreenName));
            Console.WriteLine("Added user '" + user.ScreenName + "' with ID '" + user.Id + "' to the database!");
            userList.Save();
        }