From e456fa5bda7ab48d13080b92824d067f9d61382f Mon Sep 17 00:00:00 2001 From: Mylloon Date: Tue, 16 May 2023 02:48:48 +0200 Subject: [PATCH] double all sleep --- bin/main.ml | 2 +- bin/twitter.ml | 18 +++++++++--------- lib/drivers.ml | 2 +- lib/net.ml | 2 +- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/bin/main.ml b/bin/main.ml index df9af38..35b2559 100644 --- a/bin/main.ml +++ b/bin/main.ml @@ -24,7 +24,7 @@ let rec check ctx = Unix.sleep timeout; if ctx.debug then print_endline "Refresh profile page..."; refresh_page ctx.session_id; - Unix.sleep 4; + Unix.sleep 8; check ctx in (* Time to wait until next check *) diff --git a/bin/twitter.ml b/bin/twitter.ml index cc6041b..e8eb9e0 100644 --- a/bin/twitter.ml +++ b/bin/twitter.ml @@ -19,9 +19,9 @@ let inject_username session_id creds = in (* Insert the username *) send_keys session_id input_username creds.username; - Unix.sleep 1; + Unix.sleep 2; send_keys session_id input_username Keys.return; - Unix.sleep 3 + Unix.sleep 6 ;; let rec _inject_password session_id creds try_count = @@ -47,9 +47,9 @@ let rec _inject_password session_id creds try_count = | Some input -> (* Insert password *) send_keys session_id input creds.password; - Unix.sleep 1; + Unix.sleep 2; send_keys session_id input Keys.return; - Unix.sleep 3 + Unix.sleep 6 | None -> () ;; @@ -63,9 +63,9 @@ let inject_2fa session_id secret input = in (* Insert 2FA code *) send_keys session_id input code; - Unix.sleep 1; + Unix.sleep 2; send_keys session_id input Keys.return; - Unix.sleep 5 + Unix.sleep 10 ;; let login_twitter ctx username password secret = @@ -108,7 +108,7 @@ let go_to_profile ctx = (fmt "https://twitter.com%s/with_replies" (get_attribute ctx.session_id profile_button "href"))); - Unix.sleep 4 + Unix.sleep 8 ;; let find_latest_tweet ctx = @@ -160,7 +160,7 @@ let tweet ctx msg = else List.nth l 0 in send_keys ctx.session_id tweet_area msg; - Unix.sleep 1; + Unix.sleep 2; let send_tweet_button = match find ctx.session_id (XPath "//div[@data-testid='tweetButton']") with | [] -> raise (Any (fmt "Send-tweet button not found")) @@ -170,5 +170,5 @@ let tweet ctx msg = else List.nth l 0 in click ctx.session_id send_tweet_button; - Unix.sleep 4 + Unix.sleep 8 ;; diff --git a/lib/drivers.ml b/lib/drivers.ml index 5b58fb0..3b16e4c 100644 --- a/lib/drivers.ml +++ b/lib/drivers.ml @@ -66,7 +66,7 @@ let run_process path args = let pid = Unix.create_process command (Array.of_list args) output_fd output_fd output_fd in - Unix.sleepf 0.5; + Unix.sleep 1; out_channel, pid ;; diff --git a/lib/net.ml b/lib/net.ml index 87183ba..f386746 100644 --- a/lib/net.ml +++ b/lib/net.ml @@ -70,7 +70,7 @@ let rec wait_for_load session_id = | `String res -> if not (res = "complete") then ( - Unix.sleep 1; + Unix.sleep 2; wait_for_load session_id) | _ -> raise (Any "Error when waiting for page to load")) | _ -> raise (Any "wait_for_load | Invalid JSON")