Ejemplo n.º 1
0
        /// <summary>
        /// Analyze a single post and post comment to it if needed
        /// </summary>
        /// <param name="post">Post to be analyzed</param>
        public async Task AnalyzePostAsync(Post post)
        {
            if (AlreadyAnalyzedDatabase.Contains(post.id))
            {
                logger.LogDebug("Ignoring post {0} because already analyzed", post.id);
                return;
            }

            AlreadyAnalyzedDatabase.Add(post.id);
            SaveAlreadyAnalyzed();

            if (IgnorePost(post))
            {
                logger.LogDebug("Ignoring post {0} because of blacklist", post.id);
                return;
            }

            logger.LogInformation("Analyzing post {0}", post.id);
            var problems = postAnalyzer.Analyze(post);

            if (problems.Count > 0)
            {
                logger.LogInformation("Found problems in post {0}\n{1}", post.id, post.url);
                foreach (var item in problems)
                {
                    logger.LogDebug(item.ToString());

                    if (PostComments)
                    {
                        logger.LogInformation("Posting comment");
                        await coyoteHandler.PostComment(post, string.Format(NagMessage, item.Probability)).ConfigureAwait(false);
                    }
                }
            }
        }
Ejemplo n.º 2
0
        private static async Task AnalyzePost(Post post)
        {
            if (analyzed.Contains(post.id))
            {
                return;
            }

            analyzed.Add(post.id);
            if (IgnorePost(post))
            {
                return;
            }

            logger.LogDebug("Analyzing post {0}", post.id);
            var problems = pa.Analyze(post);

            if (problems.Count > 0)
            {
                logger.LogInformation("Found problems in post {0}\n{1}\n{2}", post.id, post.url, post.text.Length < 50 ? post.text : post.text.Substring(0, 50));
                foreach (var item in problems)
                {
                    logger.LogInformation(item.ToString());

                    if (postComments)
                    {
                        logger.LogDebug("Posting comment");
                        await ch.PostComment(post, string.Format(nagMessage, item.Probability));
                    }
                }
            }
        }