예제 #1
0
        private static void Unfollow()
        {
            Cutil.Line("<Unfollow> - Start");
            while (isRunning)
            {
                int             count    = 0;
                int             interval = 60;     //60 minutes per interval
                List <Follower> tempList = new List <Follower>(Session.followed);


                foreach (Follower f in tempList)
                {
                    DateTime now = DateTime.Now;
                    double   age = (now - f.Time).TotalSeconds;
                    if (age > Session.waitTime * 86400)
                    {
                        Cutil.Line("<Unfollow> - " + f.ScreenName + " is of age." + " (" + age + ")", ConsoleColor.Cyan);
                        try
                        {
                            var friendships = Util.FindFriendship(Session.screenname, f.ScreenName);
                            count++;
                            if (count > 30)
                            {
                                Cutil.Line("<Unfollow> - Internal limit reached", ConsoleColor.DarkCyan);
                                break;
                            }
                            if (friendships != null)
                            {
                                foreach (Friendship friend in friendships.Result)
                                {
                                    if (friend.SourceRelationship.FollowedBy)
                                    {
                                        Cutil.Line("<Unfollow> - " + f.ScreenName + " follows me.", ConsoleColor.DarkCyan);
                                        Session.followed.Remove(Session.followed.SingleOrDefault(x => x.ScreenName == f.ScreenName));
                                        Futil.SaveFollowers(Session.followed, "following.log");
                                    }
                                    else
                                    {
                                        Cutil.Line("<Unfollow> - User, " + f.ScreenName + ", not followed back", ConsoleColor.DarkCyan);
                                        Futil.LogUnfollow(f.ScreenName);
                                        Util.UnfollowUserByScreenname(f.ScreenName);
                                    }
                                }
                            }
                        }
                        catch (Exception ex)
                        {
                            Cutil.Error("<Unfollow> - " + ex.Message);
                        }
                    }
                    else
                    {
                        Cutil.Line("<Unfollow> - " + f.ScreenName + " is not of age.".PadRight(20), ConsoleColor.Cyan);
                    }
                }

                Cutil.Line("<Unfollow> - Waiting " + interval + " minutes");
                Thread.Sleep(interval * 60000);
            }
        }
예제 #2
0
        public static void Main(string[] args)
        {
            Session.Initialize();
            Session.Login();


            Session.followed   = Futil.LoadFollowers("following.log");
            Session.unfollowed = Futil.LoadFollowers("unfollowed.log");

            if (Session.followed == null)
            {
                Cutil.Line("<Main> - Initializing");
                Cutil.Line("<Main> - If are following 0 users, then this bot will not work.");
                try
                {
                    Futil.FirstRun();
                }
                catch (Exception ex)
                {
                    Cutil.Error("<Main> - " + ex.Message);
                }
            }
            else
            {
                Thread botMatrix = new Thread(BotMatrix);
                botMatrix.Start();
                Thread unfollow = new Thread(Unfollow);
                unfollow.Start();
                Thread prompts = new Thread(Prompts);
                prompts.Start();
                Thread followFriday = new Thread(FollowFriday);
                followFriday.Start();
            }
            Console.ReadLine();
        }
예제 #3
0
        public async static void FollowUserByStatus(Status status)
        {
            try
            {
                //check if we have unfollowed them before, then abort if needed
                if (CheckUnfollowed(status))
                {
                    string screenname = status.User.ScreenNameResponse;

                    Cutil.Line("<Followe user by status> - Screenname: " + screenname + " Attempting follow.", ConsoleColor.Yellow);

                    if (FollowFilter(status))
                    {
                        //Followe user:

                        var user = await Session.service.CreateFriendshipAsync(screenname, true, default(CancellationToken));                         // <- Thats the bastard!


                        if (user != null && Session.followed.Any(x => x.ScreenName == screenname) == false)
                        {
                            Cutil.Line("<Follow user by status> - " + screenname + "success", ConsoleColor.Yellow);

                            Session.followed.Add(new Follower(screenname, DateTime.Now));
                            Futil.SaveFollowers(Session.followed, "following.log");
                        }
                        else
                        {
                            Cutil.Line("<Followuser by status> - User is null, or already followed.", ConsoleColor.Yellow);
                        }
                    }
                    else
                    {
                        Cutil.Line("<Follow user by status> - Rejected user, " + screenname + ", did not meet criteria.", ConsoleColor.DarkYellow);
                    }
                }
                else
                {
                    Cutil.Line("<Follow user by status> - Already followed and unfollowed this user: "******"<Follow user by status> - " + ex.Message);
            }
        }
예제 #4
0
        public async static void UnfollowUserByScreenname(string screenname)
        {
            try
            {
                Cutil.Line("<Unfollow user by ScreenName> - Screenname: " + screenname, ConsoleColor.DarkCyan);

                var user = await Session.service.DestroyFriendshipAsync(screenname, default(CancellationToken));

                if (user != null)
                {
                    Cutil.Line("<Unfollow user by ScreenName> - user unfollowed.", ConsoleColor.DarkCyan);

                    Session.followed.Remove(Session.followed.SingleOrDefault(x => x.ScreenName == screenname));
                    Session.unfollowed.Add(new Follower(screenname, DateTime.Now));
                    Futil.SaveFollowers(Session.unfollowed, "unfollowed.log");
                    Futil.SaveFollowers(Session.followed, "following.log");
                }
            }
            catch (Exception ex)
            {
                Cutil.Error("Unfollow user by ScreenName> " + ex);
            }
        }