private void btnSubmitToken_Click(object sender, EventArgs e) { if (txtAccessToken.Text == "") { rctConsoleOutput.Text = "Token entered is blank! Try again."; return; } BotPost validate = new BotPost(); FB_TOKEN = txtAccessToken.Text.Trim(); bool validation = validate.validateToken(FB_TOKEN); if (validation == true) { lblValidToken.Visible = true; btnRandomSim.Enabled = true; btnStop.Enabled = true; btnBeginSims.Enabled = true; rctConsoleOutput.Text = $"{apiResponse} \n\n Token Accepted UwU!"; } else { rctConsoleOutput.Text = $"Token entered is invalid! - Try again."; btnRandomSim.Enabled = false; btnStop.Enabled = false; btnBeginSims.Enabled = false; } }
void postToFbText(string token, string caption) { try { BotPost post = new BotPost(); post.FB_ACCESS_TOKEN = token; Task.Run(async() => { await post.PublishMessage(caption); }).GetAwaiter().GetResult(); rctConsoleOutput.AppendText(Environment.NewLine + "DDCBot6000 - Post completed succesfully! uwu"); } catch (Exception) { rctConsoleOutput.AppendText(Environment.NewLine + "An error ocurred, try again or try another token! UnU"); } }
private async Task RandSim(string token) { string caption; string imagePath; List <Team> teamList = new List <Team>(); MatchSimulation newMatch = new MatchSimulation(); ArrayList roster = new ArrayList(); delUpdateTextBox dlu = new delUpdateTextBox(updateTextBox); BotPost newPost = new BotPost(); teamList.Add(new Team() { TeamName = "Monarcas Morelia", TeamLeague = "Liga MX", TeamStrength = 65, TeamRoster = roster }); teamList.Add(new Team() { TeamName = "Real Madrid", TeamLeague = "La Liga", TeamStrength = 92, TeamRoster = roster }); teamList.Add(new Team() { TeamName = "LA FC", TeamLeague = "MLS", TeamStrength = 69, TeamRoster = roster }); teamList.Add(new Team() { TeamName = "Puntarenas FC", TeamLeague = "Liga FPD", TeamStrength = 99, TeamRoster = roster }); teamList.Add(new Team() { TeamName = "C.D. Olimpia", TeamLeague = "LNFPH", TeamStrength = 60, TeamRoster = roster }); teamList.Add(new Team() { TeamName = "Juventus", TeamLeague = "Serie A", TeamStrength = 91, TeamRoster = roster }); for (int i = 0; i < 5; i++) { rctConsoleOutput.BeginInvoke(dlu, Environment.NewLine + $"\n---Now simulating {teamList[i].TeamName} v. {teamList[i + 1].TeamName}---"); rctConsoleOutput.BeginInvoke(dlu, Environment.NewLine + $"\n---Now simulating {teamList[i].TeamName} v. {teamList[i + 1].TeamName}---"); caption = newMatch.simulateMatch(teamList[i].TeamName, teamList[i + 1].TeamName, teamList[i].TeamStrength, teamList[i + 1].TeamStrength); rctConsoleOutput.BeginInvoke(dlu, Environment.NewLine + "Match Result: " + caption); rctConsoleOutput.BeginInvoke(dlu, Environment.NewLine + "Attempting to post to Facebook..."); //postToFbText(token, caption); imagePath = newMatch.generateImage(i, i + 1, MatchSimulation.team1Score, MatchSimulation.team2Score, teamList[i].TeamName, teamList[i + 1].TeamName); imagePath = newMatch.generateImage(i, i + 1, MatchSimulation.team1Score, MatchSimulation.team2Score, teamList[i].TeamName, teamList[i + 1].TeamName); newPost.postToFbImage(BotPost.FB_PAGE_ID, token, imagePath, caption); string time = DateTime.Now.ToString("h:mm:ss:ffff tt"); rctConsoleOutput.BeginInvoke(dlu, Environment.NewLine + $"Match simulation has been posted to Facebook @ {time}. Next simulation will be run in 5 minute(s)..."); if (i == 5) { break; } Stopwatch timer = new Stopwatch(); timer.Start(); while (timer.Elapsed.TotalSeconds < 300) { } timer.Stop(); //await Task.Delay(10000); if (simStop == true) { rctConsoleOutput.BeginInvoke(dlu, $"\n\nSimulation Terminated @{DateTime.Now.ToString("h:mm:ss:ff tt")}"); btnRandomSim.Enabled = true; break; } } rctConsoleOutput.BeginInvoke(dlu, Environment.NewLine + "\n---All simulations completed---"); btnRandomSim.Enabled = true; }