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); }
public async Task <bool> Process(BaseController baseController) { var post = baseController as Post; if (post == null) { return(false); } var linkFlairId = post.Listing.LinkFlairTemplateId; if (linkFlairId != null && linkFlairId.Equals(_knifePicsFlair.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); } if (!DryRun) { var replyComment = post .Reply( $"Please ensure you fulfill Rule #5 by **posting a top level comment (reply to your own post)** with a description within {_timeLimitMinutes} minutes. " + $"Any post not in compliance will be removed. [See Rule #5 for more information](https://www.reddit.com/r/chefknives/about/rules).\n\n" + "**DO NOT REPLY TO THIS COMMENT!** Replying to this comment instead of your own post will result in your post being removed by the bot!\n\n" + $"*This message will self destruct in {_timeLimitMinutes} minutes.*") .Distinguish("yes", true); _service.SelfCommentDatabase.Upsert(replyComment.ToSelfComment(post.Id, RedditThingType.Post, post.Listing.LinkFlairTemplateId)); ScheduleDelayedCheck(post, replyComment); } _logger.Information($"[{nameof(KnifePicsPostHandler)}]: Commented with rule five warning on post by {post.Author}"); return(true); } return(false); }
public async Task <bool> Process(BaseController baseController) { var post = baseController as Post; if (post == null) { return(false); } var linkFlairId = post.Listing.LinkFlairTemplateId; if (linkFlairId != null && linkFlairId.Equals(_flair.Id)) { var existing = await _service.SelfCommentDatabase.GetAny(nameof(SelfComment.ParentId), post.Id); if (SelfPostUtilities.PostHasExistingResponse(existing, linkFlairId)) { return(false); } if (!DryRun) { var message = $"Please ensure you have filled out the Questionnaire and consider reviewing our Getting Started guide: \n\n" + $"* Questionnaire: {_questionnaireUrl}\n" + $"* Getting Started guide: {_gettingStartedUrl}\n\n" + $"Low effort posts may be removed."; var replyComment = post .Reply(message) .Distinguish("yes", true); _service.SelfCommentDatabase.Upsert(replyComment.ToSelfComment(post.Id, RedditThingType.Post, post.Listing.LinkFlairTemplateId)); } _logger.Information($"[{nameof(RecommendMePostHandler)}]: Commented with recommend me details on post by {post.Author}"); return(true); } return(false); }