Exemplo n.º 1
0
        private void ReviewUser(ReviewModel model)
        {
            var reviewTask = MakerCommentsReviewUtility.Review(model.Username, Program.ChefKnivesService.RedditPostDatabase, Program.ChefKnivesService.RedditCommentDatabase);
            var result     = reviewTask.GetAwaiter().GetResult();

            model.Message  = $"Reviewed {model.Username} in {result.ReviewTime} (ms). Found {result.MakerPosts.Count()} maker posts and {result.Comments.Count() - result.MakerComments.Count()} total non-maker comments.";
            model.Comments = result.Comments.OrderByDescending(o => o.CreateDate).ToList();
            model.Comments.ForEach(c => c.Permalink = $"{urlRoot}{c.Permalink}");

            model.Posts = result.Posts.OrderByDescending(o => o.CreateDate).ToList();
            model.Posts.ForEach(p => p.Permalink = $"{urlRoot}{p.Permalink}");
        }
Exemplo n.º 2
0
        public async Task <bool> Process(BaseController baseController)
        {
            var post = baseController as Post;

            if (post == null)
            {
                return(false);
            }

            var linkFlairId = post.Listing.LinkFlairTemplateId;

            // Check that the tile contains [maker post] or that the link flair matches the maker post flair (does the work for updates? i don't know yet)
            if (post.Title.Contains("[maker post]", StringComparison.OrdinalIgnoreCase) ||
                (linkFlairId != null && linkFlairId.Equals(_makerPostFlair.Id)))
            {
                // Set the flair
                post.SetFlair(_makerPostFlair.Text, _makerPostFlair.Id);

                // Check if we already commented on this post
                var existing = await _service.SelfCommentDatabase.GetAny(nameof(SelfComment.ParentId), post.Id);

                if (SelfPostUtilities.PostHasExistingResponse(existing, linkFlairId))
                {
                    return(false);
                }

                var result = MakerCommentsReviewUtility.Review(post.Author, _service.RedditPostDatabase, _service.RedditCommentDatabase).Result;
                var nonMakerCommentCount = result.Comments.Count() - result.MakerComments.Count();
                var makerPostCount       = result.MakerPosts.Count();

                if (nonMakerCommentCount < 2)
                {
                    SendNeverContributedWarningMessage(post);
                }
                else if (nonMakerCommentCount < makerPostCount * 3)
                {
                    SendTenToOneWarningMessage(post, nonMakerCommentCount, makerPostCount);
                }
                else
                {
                    SendMakerPostSticky(post);
                }

                return(true);
            }

            return(false);
        }