public void GetBoard() { try { BoardRootObject board = Chan.GetBoard(); Assert.NotNull(board); } catch (Exception e) { Assert.Fail(e.Message); } }
public async void GetBoardAync() { try { BoardRootObject board = await Chan.GetBoardAsync(); Assert.NotNull(board); } 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); }
/// <summary> /// Gets all of the boards /// </summary> public void StartRunningBot() { //////////////////////////////////////////// //Test Code //AwardPost("CdEG5wxA93h7jj2BjBunLWgZy1pdfPoHAN", "22323232", 0.1); //////////////////////////////////////////// WriteToLog("Starting up"); logger.Info("Starting up"); BoardRootObject BoardsRootObject = FourChinCore.GetBoard(); //for each board, parse it. foreach (Board board in BoardsRootObject.Boards) { ParseBoard(board.BoardName); } lastRun = (ulong)(DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1))).TotalSeconds; Properties.Settings.Default.LastRun = lastRun; Properties.Settings.Default.Save(); }