protected override IEnumerable <NumberParsingResult> GetMatchedNumbers(string message) { // This can be simplified when the codebase is migrated to C# 8 / .NET Standard 2.1 var matchCollectionForPattern = RegexMatchPatterns.Select(regexMatchPattern => Regex.Matches(message, regexMatchPattern, RegexOptions)); foreach (var matchCollection in matchCollectionForPattern) { foreach (Match match in matchCollection) { var split = match.Groups[match.Groups.Count - 1].Value.Split('#'); yield return(new NumberParsingResult(split[0], int.Parse(split[1]))); } } }
public override bool CanHandle(SocketUserMessage message) { // This can be simplified when the codebase is migrated to C# 8 / .NET Standard 2.1 var matchCollectionForPattern = RegexMatchPatterns.Select(regexMatchPattern => Regex.Matches(message.Content, regexMatchPattern, RegexOptions)); foreach (var matchCollection in matchCollectionForPattern) { foreach (Match match in matchCollection) { var split = match.Groups[match.Groups.Count - 1].Value.Split('#'); var keyword = split[0]; if (int.TryParse(split[1], out var number) && MinimumHandledNumberPerKeyword[keyword] <= number) { return(true); } } } return(false); }
public bool CanHandle(SocketUserMessage message) { return(RegexMatchPatterns.Any(regexMatchPattern => Regex.IsMatch(message.Content, regexMatchPattern, _regexOptions))); }