add hashtag option (#1)
This commit is contained in:
parent
ec233810d2
commit
c091d0cdd0
3 changed files with 15 additions and 7 deletions
|
@ -20,6 +20,7 @@ services:
|
|||
- TWITTER_PASSWORD=yourpassword # take care, you need to double $ signs in your password
|
||||
- TWITTER_TOTP=yourseed # optional if you don't have 2fa
|
||||
- PUSK_DEBUG=FALSE # optional
|
||||
- PUSK_HASHTAG=TRUE # optional, will add an hashtag to tweets
|
||||
restart: unless-stopped
|
||||
```
|
||||
|
||||
|
|
14
bin/main.ml
14
bin/main.ml
|
@ -45,10 +45,12 @@ let rec check ctx =
|
|||
if 0 = timeout
|
||||
then (
|
||||
if ctx.debug then print_endline "Tweeting...";
|
||||
let message =
|
||||
"This tweet is for the Twitter's CTO: don't suspend my account for inactivity."
|
||||
^ if ctx.hashtag then "#puskbot" else ""
|
||||
in
|
||||
(* Tweet *)
|
||||
tweet
|
||||
ctx
|
||||
"This tweet is for the Twitter's CTO: don't suspend my account for inactivity.";
|
||||
tweet ctx message;
|
||||
(* Returns to profile page *)
|
||||
go_to_profile ctx;
|
||||
(* Wait the maximum time since we just tweeted *)
|
||||
|
@ -87,10 +89,8 @@ let () =
|
|||
load_dotenv;
|
||||
let ctx =
|
||||
{ session_id = snd data
|
||||
; debug =
|
||||
(match Sys.getenv_opt "PUSK_DEBUG" with
|
||||
| Some boolean -> if String.lowercase_ascii boolean = "true" then true else false
|
||||
| None -> false)
|
||||
; debug = boolean_env "PUSK_DEBUG"
|
||||
; hashtag = boolean_env "PUSK_HASHTAG"
|
||||
}
|
||||
in
|
||||
if ctx.debug then print_endline "Logging is enabled";
|
||||
|
|
|
@ -5,6 +5,7 @@ let fmt = Printf.sprintf
|
|||
type context =
|
||||
{ session_id : string
|
||||
; debug : bool
|
||||
; hashtag : bool
|
||||
}
|
||||
|
||||
let load_dotenv =
|
||||
|
@ -13,6 +14,12 @@ let load_dotenv =
|
|||
if Sys.file_exists path then Dotenv.export ~path ()
|
||||
;;
|
||||
|
||||
let boolean_env variable =
|
||||
match Sys.getenv_opt variable with
|
||||
| Some boolean -> String.lowercase_ascii boolean = "true"
|
||||
| None -> false
|
||||
;;
|
||||
|
||||
let keys_to_typing str =
|
||||
let rec aux acc = function
|
||||
| 0 -> acc
|
||||
|
|
Loading…
Reference in a new issue