예제 #1
0
        private IEnumerable<ITabResult> GetVisibleUsersResults(IClient client, ITabQuery query)
        {
            var nickname = query.Keyword.ToLowerInvariant();

            return client.Users
                .Where(user => user.IsUserVisible && user.Nickname.ToLowerInvariant().StartsWith(nickname) && user.Nickname != user.Network.LocalUser.Nickname )
                .Select(match =>
                    {
                        var text = query.ReplaceKeyword(match.Nickname);
                        return new TabResult
                        {
                            Text = text,
                            Channel = match.Channels.FirstOrDefault(), //TODO change this to the last channel the user spoke in
                            CursorIndex = query.GetCursorIndexAtEndOfKeyword(text)
                        };
                    }
                );
        }
예제 #2
0
        public IEnumerable<ITabResult> GetTabResults(Models.IClient client, ITabQuery query)
        {
            string keyword = query.Keyword.ToLowerInvariant();

            return client.Channels
                .Where(channel => channel.Name.ToLowerInvariant().StartsWith(keyword))
                .Select(match =>
                    {
                        var text = query.ReplaceKeyword(match.Name);

                        return new TabResult
                        {
                            Text = text,
                            SelectedText = !text.Contains(' ') ? new Range { LowerBound = 0, UpperBound = text.Length } : null,
                            Channel = match,
                            CursorIndex = query.GetCursorIndexAtEndOfKeyword(text),
                        };
                    }
                );
        }
예제 #3
0
 public IEnumerable<ITabResult> GetTabResults(IClient client, ITabQuery query)
 {
     string firstWord = query.Text.Split(' ').First();
     if (!string.IsNullOrWhiteSpace(firstWord) && firstWord.StartsWith("/") && firstWord.Count() > 1 &&
        (firstWord.Count() >= query.CursorLocation))
     {
         string commandText = firstWord.Substring(1).ToUpperInvariant();
         IEnumerable<string> matchedCommands = this.availableCommands.Where(command => command.ToUpperInvariant().StartsWith(commandText));
         return matchedCommands.Select(match =>
             {
                 var text = query.ReplaceKeyword(match.ToLowerInvariant());
                 return new TabResult
                 {
                     Text = text,
                     CursorIndex = query.GetCursorIndexAtEndOfKeyword(text),
                 };
             }
         );
     }
     return new Collection<ITabResult>();
 }
예제 #4
0
        private IEnumerable<ITabResult> GetLogResults(IClient client, ITabQuery query)
        {
            var nickname = query.Keyword.ToLowerInvariant();

            return client.Log
                .Where(entry => entry.IsUserVisible && entry is IUserEvent)
                .Select(entry => entry as IUserEvent)
                .Where(entry => entry.Network.LocalUser.Nickname != entry.User.Nickname && entry.User.Nickname.ToLowerInvariant().StartsWith(nickname))
                .OrderBy(match => match.ReceivedAt)
                .Select(match =>
                    {
                        var text = query.ReplaceKeyword(match.User.Nickname);
                        return new TabResult
                        {
                            Text = text,
                            Channel = match.Source as IChannel,
                            CursorIndex = query.GetCursorIndexAtEndOfKeyword(text)
                        };
                    }
                );
        }