コード例 #1
0
        public async void GetBoardAync()
        {
            try
            {
                BoardRootObject board = await Chan.GetBoardAsync();

                Assert.NotNull(board);
            }
            catch (Exception e)
            {
                Assert.Fail(e.Message);
            }
        }
コード例 #2
0
            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);
            }
コード例 #3
0
        public async void GetBoardAsync()
        {
            var board = await Chan.GetBoardAsync();

            NotNull(board);
        }