public static ChattyThread DetectCortexThread(ChattyThread thread) { var op = thread.Posts[0]; op.IsCortex = m_cortex_regex.IsMatch(op.Body); return(thread); }
private static Dictionary <int, PostModel> GetPostModelsById( ChattyThread thread, ChattyLolCounts lolCounts) { var threadLolCounts = lolCounts.GetThreadLolCounts(thread.ThreadId); return(PostModel.CreateList(thread, threadLolCounts).ToDictionary(x => x.Id)); }
public async Task <ThreadLolCounts> DownloadThreadLolCounts(ChattyThread thread) { var query = _downloadService.NewQuery(); foreach (var post in thread.Posts) { query.Add("ids[]", $"{post.Id}"); } var json = await _downloadService.DownloadWithSharedLogin( "https://www.shacknews.com/api2/api-index.php?action2=get_all_tags_for_posts", verifyLoginStatus : false, postBody : query); var response = JsonSerializer.Deserialize <TagsForPosts>(json, new JsonSerializerOptions { PropertyNamingPolicy = JsonNamingPolicy.CamelCase }); return (new ThreadLolCounts { CountsByPostId = ( from tag in response.Data group tag by int.Parse(tag.ThreadId) into post_group let postLols = ( from x in post_group select new LolModel { Tag = GetTagName(x.Tag), Count = int.Parse(x.Total) } ).ToList() select(PostId: post_group.Key, Tags: postLols) ).ToDictionary(x => x.PostId, x => x.Tags) });