Example #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.");
        }
Example #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();
        }
Example #3
0
 public void Execute()
 {
     if (textLists.Hate.Count == 0 || textLists.Neutral.Count == 0 || textLists.Nice.Count == 0)
     {
         Console.WriteLine("WARNING!!!! One or more of the text lists are empty. The program may not work correctly.");
         Thread.Sleep(2000);
     }
     if (userList.List.Count == 0)
     {
         Console.WriteLine("No user in database! Please add one first!");
     }
     foreach (var user in userList.List)
     {
         Console.WriteLine(user.UserId + " - " + user.Name);
         var tweets = TwitterHelper.GetUserTimeline(service, user.UserId, false, true);
         foreach (var tweet in tweets)
         {
             if (!tweetList.List.Contains(tweet.Id.ToString()))
             {
                 string tweetText = "@" + tweet.User.ScreenName + " " + textLists.getRandomString(user.Category) + " #ReplyBot (" + DateTime.Now.Ticks + ")";
                 if (!Debug)
                 {
                     Console.WriteLine("Sending tweet...");
                     TwitterHelper.SendTweet(service, tweetText, tweet.Id);
                     tweetList.List.Add(tweet.Id.ToString());
                 }
                 else
                 {
                     Console.WriteLine("Not sending tweet because in debug mode.");
                     Console.WriteLine(tweetText);
                 }
             }
             else
             {
                 Console.WriteLine("Tweet already sent.");
             }
         }
     }
     tweetList.Save();
 }