Beispiel #1
0
        static async Task MainAsync(string[] args)
        {
            var    login     = File.ReadAllLines(args[0]);
            string subreddit = args[1];

            var    wa     = new BotWebAgent(login[0], login[1], login[2], login[3], login[4]);
            Reddit reddit = new Reddit(wa, true);

            ChapterDictionary dict = new ChapterDictionary(subreddit + ".json");

            Console.WriteLine("Current State: ");
            dict.PrintState();

            while (true)
            {
                await AddNewPostsAsync(dict, reddit, subreddit);

                dict.Save();

                await UpdateChaptersAsync(dict, reddit, subreddit);

                dict.Save();

                await UpdatePoisonedChaptersAsync(dict, reddit, subreddit);

                dict.Save();


                Console.WriteLine("Sleeping.");
                Thread.Sleep(2000);
            }
        }
Beispiel #2
0
        private static async Task UpdatePoisonedChaptersAsync(ChapterDictionary dict, Reddit reddit, string subreddit)
        {
            Console.WriteLine($"Updating chapters in { subreddit }.");
            foreach (var chapter in dict.Chapters.Values)
            {
                if (chapter.IsPoisoned)
                {
                    try
                    {
                        await chapter.UpdateOrCreateComment(reddit, dict);

                        dict.Save();
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine("Exception when updating comment of" + chapter.Id + ": " + e.ToString());
                    }
                }
            }
        }