示例#1
0
        public async Task Whois([Remainder][Summary("Der Name des WoW-Charakters")]
                                string name)
        {
            using (var repository = _repositoryFactory.Invoke())
            {
                var characters = repository.Characters
                                 .Where(c => _memberConfiguration.ShowNonGuildCharacters || c.GuildMembershipHistory.OrderByDescending(m => m.Timestamp).FirstOrDefault().State != GuildMemberState.Left)
                                 .ToList()
                                 .Where(c => _distanceCalculator.Distance(c.Name.ToLowerInvariant(), name.ToLowerInvariant()) < name.Length / 2.0);

                var messages = characters.Select(c => _messageBuilder.BuildMessage(c));

                await Task.WhenAll(messages.Select(m => ReplyAsync("", false, m)));
            }
        }
示例#2
0
 public int GetDistance(string word1, string word2)
 {
     return((int)_levenshtein.Distance(word1, word2));
 }