Beispiel #1
0
 public void GetThreadPage()
 {
     try
     {
         ThreadRootObject thread = Chan.GetThreadPage("a", 1);
         Assert.NotNull(thread);
     }
     catch (Exception e)
     {
         Assert.Fail(e.Message);
     }
 }
Beispiel #2
0
        public async void GetThreadPageAsync()
        {
            try
            {
                ThreadRootObject thread = await Chan.GetThreadPageAsync("a", 1);

                Assert.AreNotEqual(thread, null);
            }
            catch (Exception e)
            {
                Assert.Fail(e.Message);
            }
        }
            public async Task RandomThread(CommandContext ctx, string boardName = null)
            {
                await ctx.TriggerTypingAsync();

                BoardRootObject boardRootObject = await Chan.GetBoardAsync();

                Board board;

                if (!string.IsNullOrWhiteSpace(boardName))
                {
                    int index = boardRootObject.Boards.FindIndex(b => b.BoardName == boardName.ToLower());
                    if (index == -1)
                    {
                        _ = await ctx.RespondAsync($"Couldn't find board /{boardName.ToLower()}/!");

                        return;
                    }
                    else
                    {
                        board = boardRootObject.Boards[index];
                    }
                }
                else
                {
                    board = Helper.RandomItem.GetRandomItem(boardRootObject.Boards);
                }

                var posts = new List <Post>();

                for (int i = 1; i < board.Pages; i++)
                {
                    ThreadRootObject page = await Chan.GetThreadPageAsync(board.BoardName, i);

                    foreach (Thread thread in page.Threads)
                    {
                        posts.Add(thread.Posts[0]);
                    }
                }

                Post post = posts[Plugin.Random.Next(0, posts.Count - 1)];

                await this.GetThread(ctx, post.Board, post.PostNumber);
            }
Beispiel #4
0
        public void GetAllThread()
        {
            try
            {
                ThreadRootObject thread = Chan.GetThreadPage("a", 1);

                Assert.NotNull(thread);

                foreach (var item in thread.Threads)
                {
                    Assert.NotNull(item);

                    foreach (var post in item.Posts)
                    {
                        Assert.NotNull(post);
                        Assert.AreNotEqual(post.PostNumber, 0);
                    }
                }
            }
            catch (Exception e)
            {
                Assert.Fail(e.Message);
            }
        }