From 66d694ce87cffa648399740668227f5202996ec4 Mon Sep 17 00:00:00 2001 From: matthew-z Date: Fri, 22 Jan 2016 05:11:13 +0900 Subject: [PATCH] added hangout.R, improved smack-my-bitch-up.R --- R/hangover.R | 35 +++++++++++++++++++++++++++++++++++ R/smack_my_bitch_up.R | 2 +- 2 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 R/hangover.R diff --git a/R/hangover.R b/R/hangover.R new file mode 100644 index 0000000..44123c0 --- /dev/null +++ b/R/hangover.R @@ -0,0 +1,35 @@ +library(httr) + +today = Sys.Date() + +# skip weekends +if( weekdays(today) %in% c('Saturday','Sunday') ){ + quit() + } + +# exit if no sessions with my username are found +output = system("who", intern = TRUE) +if( !( grep('^my_user_name', output) ) ){ + quit() + } + +# returns 'None' if the key doesn't exist +TWILIO_ACCOUNT_SID = Sys.getenv('TWILIO_ACCOUNT_SID') +TWILIO_AUTH_TOKEN = Sys.getenv('TWILIO_AUTH_TOKEN') + +# Phone numbers +my_number = '+xxx' +number_of_boss= '+xxx' + +excuse = c( + 'Locked out', + 'Pipes broke', + 'Food poisoning', + 'Not feeling well' + ) + +POST(paste("https://api.twilio.com/2010-04-01/Accounts/",TWILIO_ACCOUNT_SID,"/Messages.json",sep=""), + body = list(From=my_number,To=number_of_boss,Body=paste("Gonna work from home. ", sample(excuse,1))), + authenticate(TWILIO_ACCOUNT_SID,TWILIO_AUTH_TOKEN) ) + +print( paste("Message sent at",Sys.time()) ) diff --git a/R/smack_my_bitch_up.R b/R/smack_my_bitch_up.R index 7257f88..28fd286 100644 --- a/R/smack_my_bitch_up.R +++ b/R/smack_my_bitch_up.R @@ -28,7 +28,7 @@ reasons = c( ) POST(paste("https://api.twilio.com/2010-04-01/Accounts/",TWILIO_ACCOUNT_SID,"/Messages.json",sep=""), - body = list(From=my_number,To=her_number,Body=sample(reasons,1) ), + body = list(From=my_number,To=her_number,Body=paste("Late at work. ", sample(reasons,1))), authenticate(TWILIO_ACCOUNT_SID,TWILIO_AUTH_TOKEN) ) print( paste("Message sent at",Sys.time()) )