Exemplo n.º 1
0
        public async void ReadThread(CancellationToken Token)
        {
            DateTimeOffset BeforeCheckTime = DateTimeOffset.Now;

            ApiResponse <Thread> ThreadResponse = await MakeApiCall <Thread>(new Uri($"https://a.4cdn.org/{Board}/thread/{ThreadNumber}.json"), LastTimeChecked, Token);

            if (ThreadResponse.ResponseType == YotsubaResponseType.Ok)
            {
                if (PostCount == 0)
                {
                    ThreadArchiver.WriteAll(Board, ThreadNumber, ThreadResponse.Reponse.Posts);
                }
                else
                {
                    ThreadArchiver.AppendAll(Board, ThreadNumber, PostCount, ThreadResponse.Reponse.Posts);
                }

                PostCount = ThreadResponse.Reponse.Posts.Length;
            }
            else if (ThreadResponse.ResponseType == YotsubaResponseType.NotFound)
            {
                ThreadArchiver.Archive(Board, ThreadNumber);
                IsAlive = false;
            }

            LastTimeChecked = BeforeCheckTime;
        }