コード例 #1
0
        public IEnumerable <string> Get(ChannelInfo channel, DateTime time)
        {
            MatchingThread matchingThread = threadResolver.Resolve(channel);

            if (matchingThread == null)
            {
                return(new string[0]);
            }

            IEnumerable <string> keywords = matchingThread.ThreadTitleKeywords.Select(x => x.ToLower().Normalize(NormalizationForm.FormKD));

            Nichan.Board board = Nichan.BoardParser.ParseFromUri(matchingThread.BoardUri.ToString());

            return(board.Threads.Select(x => { x.Title = x.Title.ToLower().Normalize(NormalizationForm.FormKD); return x; })
                   .Where(x => x.ResCount <= 1000 && keywords.All(keyword => x.Title.Contains(keyword))).OrderByDescending(x => x.ResCount).Take(3).Select(x => x.Uri.ToString()));
        }
コード例 #2
0
        public async Task <IEnumerable <string> > Get(
            ChannelInfo channel, DateTimeOffset time, CancellationToken cancellationToken
            )
        {
            MatchingThread matchingThread = threadResolver.Resolve(channel, false);

            if (matchingThread == null)
            {
                return(new string[0]);
            }

            IEnumerable <string> keywords = matchingThread.ThreadTitleKeywords.Select(
                x => x.ToLower().Normalize(NormalizationForm.FormKD)
                );

            string boardUri  = matchingThread.BoardUri.ToString();
            var    uri       = new Uri(boardUri);
            string boardHost = $"{uri.Scheme}://{uri.Host}";
            string boardName = uri.Segments[1];

            if (boardName.EndsWith('/'))
            {
                boardName = boardName[..^ 1];