Ejemplo n.º 1
0
        public async Task StartCommentLoopAsync()
        {
            Console.WriteLine("Starting comment loop...");
            while (true)
            {
                try
                {
                    List <Comment> comments = new List <Comment>();
                    await r.GetListing <Comment>("/r/mod/comments", -1, 100).ForEachAsync(c =>
                    {
                        if (IsUnbannable(c) || (c.BannedBy != null || c.BannedBy == r.User.Name))
                        {
                            return;
                        }
                        comments.Add(c);
                    });

                    foreach (Comment c in comments)
                    {
                        if (await CheckShouldBanAsync(c))
                        {
                            await Task.WhenAll(c.RemoveSpamAsync(), SrLookup[c.Subreddit].BanUserAsync(c.AuthorName, "spam", "botterminator banned", 0, String.Empty));
                        }
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.ToString());
                }
                await Task.Delay(5000);
            }
        }