Exemplo n.º 1
0
        public Task <string> HandleMessage(string message)
        {
            var swears = _swearingProvider.GetSwearing();

            foreach (string word in swears)
            {
                string pattern = MakeRegex(word);
                Match  match   = Regex.Match(message, pattern, RegexOptions.IgnoreCase);
                if (match.Length != 0)
                {
                    message = Regex.Replace(message, match.Value, new string('*', match.Length));
                }
            }
            return(Task.FromResult(message));
        }
Exemplo n.º 2
0
        public async Task <string> HandleMessageAsync(string message)
        {
            _logger.LogMethodCallingWithObject(new { message });

            var swears = _swearingProvider.GetSwearing();

            foreach (string word in swears)
            {
                string pattern = MakeRegex(word);
                Match  match   = Regex.Match(message, pattern, RegexOptions.IgnoreCase);
                if (match.Length != 0)
                {
                    message = Regex.Replace(message, match.Value, new string('*', match.Length));
                }
            }
            return(await Task.FromResult(message));
        }