Пример #1
0
        public static string GetUsernameIn(this ParsedRequest request, BotBitsClient client, int index)
        {
            var query = request.Args[index];
            PlayerSearchFilter filter;

            query = MatchHelper.TrimFilterPrefix(query, out filter);

            try
            {
                var list = request
                           .GetPlayersIn(client, index)
                           .Select(p => p.Username)
                           .Distinct()
                           .ToArray();

                if (!filter.HasFlag(PlayerSearchFilter.FirstResult) && list.Length >= 2)
                {
                    throw new CommandException("More than one username was found.");
                }

                return(list.First());
            }
            catch (UnknownPlayerCommandException)
            {
                return(query);
            }
        }
Пример #2
0
        public static Player[] GetPlayersIn(this ParsedRequest request, BotBitsClient client, int index)
        {
            var query = request.Args[index];
            PlayerSearchFilter filter;

            query = MatchHelper.TrimFilterPrefix(query, out filter);
            return(MatchPlayers(client, query, filter));
        }
Пример #3
0
        public static Player GetPlayerIn(this ParsedRequest request, BotBitsClient client, int index)
        {
            var query = request.Args[index];
            PlayerSearchFilter filter;

            query = MatchHelper.TrimFilterPrefix(query, out filter);
            var list = MatchPlayers(client, query, filter);

            if (!filter.HasFlag(PlayerSearchFilter.FirstResult) && list.Length >= 2)
            {
                throw new CommandException("More than one player was found.");
            }

            return(list.First());
        }
Пример #4
0
        public static string[] GetUsernamesIn(this ParsedRequest request, BotBitsClient client, int index)
        {
            var query = request.Args[index];
            PlayerSearchFilter filter;

            query = MatchHelper.TrimFilterPrefix(query, out filter);

            try
            {
                return(request
                       .GetPlayersIn(client, index)
                       .Select(p => p.Username)
                       .Distinct()
                       .ToArray());
            }
            catch (UnknownPlayerCommandException)
            {
                return(new [] { query });
            }
        }