Beispiel #1
0
        /// <summary>
        /// This method get the list of Following Users IDs
        /// </summary>
        /// <returns></returns>
        public static List <long> getFollowingIds()
        {
            List <long> auxIds = new List <long>();

            foreach (var user in Jarvis.getFollowingUsers())
            {
                auxIds.Add(user.Id);
            }
            return(auxIds);
        }
Beispiel #2
0
        /// <summary>
        /// List all mentioning tweets in a colection.
        /// </summary>
        /// <returns>String</returns>
        public static string getMentionsString()
        {
            StringBuilder aux = new StringBuilder();

            foreach (var item in Jarvis.getMentions())
            {
                aux.Append("\nAUTOR:" + item.Author.ScreenName + "\nTEXT: " + item.Text);
            }
            return(aux.ToString());
        }
Beispiel #3
0
        /// <summary>
        /// Básicamente retorna la lista de usuarios que publicaron cosas en la Timeline (Generalmente la mayoría son Retweets por lo tanto son usuarios que no sigo.
        /// </summary>
        /// <returns>List of twitter users</returns>
        public static List <TwitterUser> getUsersToFollow()
        {
            Jarvis.auxUserList = new List <TwitterUser>();
            var collection = Jarvis.getTimeLine();

            foreach (var item in collection)
            {
                auxUserList.Add(item.User);
            }
            return(Jarvis.auxUserList);
        }
Beispiel #4
0
        /// <summary>
        /// This method return a String with de list of followers
        /// </summary>
        /// <returns></returns>
        public static string getFollowersString()
        {
            StringBuilder aux = new StringBuilder();

            Jarvis.getFollowers();
            aux.Append("FOLLOWERS\n");
            foreach (var follower in Jarvis.auxUserList)
            {
                aux.Append("NAME: " + follower.Name + " ID: " + follower.Id + " FOLLOWERS: " + follower.FollowersCount);
                aux.AppendLine("\n");
            }
            // Retornamos la colección.
            return(aux.ToString());
        }
Beispiel #5
0
        /// <summary>
        /// Obtains the list of users to follow
        /// </summary>
        /// <returns>List of twitter users</returns>
        public static List <long> getTimelineIds()
        {
            List <long> aux        = new List <long>();
            var         collection = Jarvis.getTimeLine(30);

            foreach (var post in collection)
            {
                if (post.RetweetedStatus != null)
                {
                    aux.Add(post.RetweetedStatus.User.Id);
                }
            }
            return(aux);
        }
Beispiel #6
0
        /// <summary>
        /// This method GETS a collection of "Following" users and unfollow them if the user isnt in a Friendship
        /// </summary>
        /// <returns>JarvisResponse - This method returns a JarvisResponse Object with a Message and Counting info.</returns>
        public static JarvisResponse autoUnfollowNoFriendshipsUsers()
        {
            StringBuilder aux = new StringBuilder();

            Jarvis.jResponse = new JarvisResponse();
            jResponse.count  = 0;
            aux.AppendLine("Unfollowed Users:");
            // Collection with all followers.
            var colectionOfFollowers = Jarvis.getAllFollowingUsers();

            // Travel all collection

            // Append message footer.
            aux.AppendLine("Users: " + jResponse.count + "/" + colectionOfFollowers.Count);
            jResponse.message = aux.ToString();
            return(jResponse);
        }
Beispiel #7
0
        /// <summary>
        /// Like all timeline tweets.
        /// </summary>
        /// <returns>int Count of likes</returns>
        public static int autoLikeTimeline()
        {
            int count = 0;

            var collection = Jarvis.getTimeLine(20);

            foreach (var tweet in collection)
            {
                // En caso de que el Tweet en cuestión no esté Likeado, lo likeamos.
                if (tweet.IsFavorited == false)
                {
                    mainService.FavoriteTweet(new FavoriteTweetOptions {
                        Id = tweet.Id
                    });
                    // Aumentamos la cantidad de Likes dados en la instancia de procesamiento actual.
                    count++;
                }
            }
            return(count);
        }
Beispiel #8
0
        /// <summary>
        /// Like all mentioning tweets.
        /// </summary>
        /// <returns>int Count of likes</returns>
        public static int autoLikeMentions()
        {
            int count = 0;

            // Recorremos la colecion de Menciones
            foreach (var tweet in Jarvis.getMentions())
            {
                // En caso de que el Tweet en cuestión no esté Likeado, lo likeamos.
                if (tweet.IsFavorited == false)
                {
                    mainService.FavoriteTweet(new FavoriteTweetOptions {
                        Id = tweet.Id
                    });
                    count++;
                }
            }

            Jarvis.likeCount += count;
            return(count);
        }
Beispiel #9
0
        /// <summary>
        /// Método invocado periodicamente encargado de Procesar.
        /// </summary>
        /// <param name="stateInfo"></param>
        public void Procesar(Object stateInfo)
        {
            try
            {
                // Si la fecha actual es superior a la fecha del nuevo periodo.
                if (DateTime.Now >= fechaProximoPeriodo)
                {
                    // Comenzamos un nuevo periodo.
                    fechaProximoPeriodo   = DateTime.Now.AddHours(6);
                    fechaProximaInstancia = DateTime.Now.AddMinutes(15);
                    // Reiniciamos los indicadores
                    Instancia  = 0;
                    LikesDados = 0;
                    AlmacenarEstados();

                    using (StreamWriter temp = new StreamWriter("operaciones.txt"))
                    {
                        temp.WriteLine($"|Jarvis - {DateTime.Now}| Periodo siguiente: {fechaProximoPeriodo} -=- NUEVO PERIODO INICIADO.\n");
                    }
                }
                else
                {
                    if (DateTime.Now >= fechaProximaInstancia)
                    {
                        if (LikesDados < 490 && Instancia < 25)
                        {
                            fechaProximaInstancia = DateTime.Now.AddMinutes(15);
                            Instancia++;

                            LikesDados += Jarvis.autoLikeTimeline();
                            AlmacenarEstados();

                            using (StreamWriter temp = new StreamWriter("operaciones.txt"))
                            {
                                temp.WriteLine($"|Jarvis - {DateTime.Now}| Periodo siguiente: {fechaProximoPeriodo} - Instancia: {Instancia} - Likes dados: {LikesDados}\n");
                            }
                        }
                        else
                        {
                            using (StreamWriter temp = new StreamWriter("operaciones.txt"))
                            {
                                temp.WriteLine($"|Jarvis - {DateTime.Now}| Periodo siguiente: {fechaProximoPeriodo} - Instancia: {Instancia} - Likes dados: {LikesDados}");
                                temp.WriteLine($"|Jarvis - {DateTime.Now}| Se llegó al limite de Likes dados, esperando el próximo periodo.\n\n");
                            }
                        }
                    }
                }
            }
            catch (Exception e)
            {
                using (StreamWriter temp = new StreamWriter("logs.txt"))
                {
                    temp.WriteLine($"{DateTime.Now} - {e.Message}\n\n");
                }
            }
            finally
            {
                relojControlador.Change(0, 1000);
                ActualizarVista();
            }
        }