private bool IsImportantMessageProc(string message) { var importantWordsConfig = ConfigurationManager.AppSettings["Important_Words"]; if (string.IsNullOrEmpty(importantWordsConfig)) { return(false); } if (string.IsNullOrEmpty(message)) { return(false); } var importantWords = new HashSet <string>(importantWordsConfig.ToLower().Split('|').Distinct()); var words = new WordParser().Parse(message) .Where(x => !string.IsNullOrEmpty(x)) .Select(x => x.ToLower()) .Distinct() .ToList(); if (words.Any(x => importantWords.Contains(x))) { return(true); } return(false); }
public static bool IsImportantMessageProc(ChatMessage message, string[] importantWords) { if (importantWords == null) { return(false); } if (string.IsNullOrEmpty(message.Message)) { return(false); } var dict = new HashSet <string>(importantWords.Select(x => x.ToLower()).Distinct()); var words = new WordParser().Parse(message.Message) .Where(x => !string.IsNullOrEmpty(x)) .Select(x => x.ToLower()) .Distinct() .ToList(); if (words.Any(x => dict.Contains(x))) { return(true); } return(false); }