update tweet strategy
All checks were successful
ci/woodpecker/push/publish Pipeline was successful

* now use the home page to tweet, instead of relying of clicking on tweet page
This commit is contained in:
Mylloon 2023-05-16 13:32:50 +02:00
parent 2518fca99d
commit 3f415cf9e1
Signed by: Anri
GPG key ID: A82D63DFF8D1317F
2 changed files with 6 additions and 12 deletions

View file

@ -45,10 +45,12 @@ let rec check ctx =
if 0 = timeout
then (
if ctx.debug then print_endline "Tweeting...";
(* Tweet and returns to profile page *)
(* Tweet *)
tweet
ctx
"This tweet is for the Twitter's CTO: don't suspend my account for inactivity.";
(* Returns to profile page *)
go_to_profile ctx;
(* Wait the maximum time since we just tweeted *)
recheck max_time)
else (* Wait the amount of time calculated from the post *)

View file

@ -142,16 +142,8 @@ let find_latest_tweet ctx =
;;
let tweet ctx msg =
let tweet_button =
match find ctx.session_id (XPath "//a[@data-testid='SideNav_NewTweet_Button']") with
| [] -> raise (Any (fmt "Tweet button not found"))
| _ as l ->
if List.length l > 1
then raise (Any "Too many tweet button found")
else List.nth l 0
in
click ctx.session_id tweet_button;
Unix.sleep 2;
ignore (navigate ctx.session_id "https://twitter.com/home");
Unix.sleep 4;
let tweet_area =
match find ctx.session_id (CSS "div[data-testid='tweetTextarea_0']") with
| [] -> raise (Any (fmt "Tweet area not found"))
@ -161,7 +153,7 @@ let tweet ctx msg =
send_keys ctx.session_id tweet_area msg;
Unix.sleep 2;
let send_tweet_button =
match find ctx.session_id (XPath "//div[@data-testid='tweetButton']") with
match find ctx.session_id (XPath "//div[@data-testid='tweetButtonInline']") with
| [] -> raise (Any (fmt "Tweet button not found"))
| _ as l ->
if List.length l > 1