コード例 #1
0
        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])));
                }
            }
        }
コード例 #2
0
        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);
        }
コード例 #3
0
 public bool CanHandle(SocketUserMessage message)
 {
     return(RegexMatchPatterns.Any(regexMatchPattern => Regex.IsMatch(message.Content, regexMatchPattern, _regexOptions)));
 }