Beispiel #1
0
        private static void tweet(long rantId)
        {
            devRant dr = new devRant();

            if (goodRant(rantId) == false)
            {
                return;
            }

            if (checkImage(rantId) == false)
            {
                Tweet.PublishTweet(dr.GetRantAsync(Convert.ToInt32(rantId)).Result.text);
                return;
            }

            Tweet.PublishTweet(dr.GetRantAsync(Convert.ToInt32(rantId)).Result.text, new Tweetinvi.Parameters.PublishTweetOptionalParameters
            {
                Medias = new List <Tweetinvi.Models.IMedia> {
                    downloadImg(rantId)
                }
            });

            using (StreamWriter outputFile = new StreamWriter(Config.path, append: true))
            {
                Console.WriteLine("Current rant id writing to file is {0}", rantId);
                outputFile.WriteLineAsync(Convert.ToString(rantId));
            }
        }
Beispiel #2
0
        private static bool checkImage(long rantId)
        {
            devRant dr  = new devRant();
            string  img = dr.GetRantAsync(Convert.ToInt32(rantId)).Result.attachedImageUrl;

            if (img != null)
            {
                return(true);
            }

            return(false);
        }
Beispiel #3
0
 static void Main(string[] args)
 {
     //getAllRants();
     //getSearchResults("px06");
     //getSingleRant(448369);
     //getUserProfile(getUserId("px06").Result);
     using (var api = new devRant())
     {
         Console.WriteLine(api.GetUserIdAsync("px06").Result);
     }
     Console.ReadLine();
 }
Beispiel #4
0
        private static List <devRantDotNet.Source.Models.Rant> getRecentTopRants(int recentsCount = 25)
        {
            List <devRantDotNet.Source.Models.Rant> recentRants;

            using (devRant dr = new devRant())
            {
                recentRants = dr.GetRantsAsync(devRant.SortType.recent, recentsCount).Result;
                recentRants.Sort((firstObj, secondObj) =>
                {
                    return(secondObj.score - firstObj.score);
                }
                                 );
            }
            return(recentRants);
        }
Beispiel #5
0
        private static int getHighScore()
        {
            List <int> rantsScores = new List <int>();

            using (devRant dr = new devRant())
            {
                List <devRantDotNet.Source.Models.Rant> getRants = dr.GetRantsAsync(devRant.SortType.recent, 25).Result;
                getRants.ForEach((rant) => {
                    rantsScores.Add(rant.score);

                    Console.WriteLine(rant.score);
                });
            }
            rantsScores.Sort();

            return(rantsScores.Last());
        }
Beispiel #6
0
        private static Tweetinvi.Models.IMedia downloadImg(long runtId)
        {
            devRant dr     = new devRant();
            string  imgUrl = dr.GetRantAsync(Convert.ToInt32(runtId)).Result.attachedImageUrl;

            using (WebClient client = new WebClient())
            {
                client.DownloadFile(new Uri(imgUrl), Config.fileName);
            }

            var image = File.ReadAllBytes(Config.fileName);

            File.Delete(Config.fileName);
            var media = Upload.UploadImage(image);

            return(media);
        }
Beispiel #7
0
        private static bool goodRant(long rantId)
        {
            devRant dr = new devRant();

            int rantLength = dr.GetRantAsync(Convert.ToInt32(rantId)).Result.text.Length; //ToDo

            if (rantLength > 280)
            {
                return(false);
            }

            using (StreamReader sr = File.OpenText(Config.path))
            {
                string currentRantId;
                while ((currentRantId = sr.ReadLine()) != null)
                {
                    if (Convert.ToInt64(currentRantId) == rantId)
                    {
                        return(false);
                    }
                }
            }
            return(true);
        }