Skip to content

Commit 480bb62

Browse files
committed
R version: smack_my_bitch_up.R
1 parent f46cd2d commit 480bb62

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

R/smack_my_bitch_up.R

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
library(httr)
2+
3+
today = Sys.Date()
4+
5+
# skip weekends
6+
if( weekdays(today) %in% c('Saturday','Sunday') ){
7+
quit()
8+
}
9+
10+
# exit if no sessions with my username are found
11+
output = system("who", intern = TRUE)
12+
if( !( grep('^my_user_name', output) ) ){
13+
quit()
14+
}
15+
16+
# returns 'None' if the key doesn't exist
17+
TWILIO_ACCOUNT_SID = Sys.getenv('TWILIO_ACCOUNT_SID')
18+
TWILIO_AUTH_TOKEN = Sys.getenv('TWILIO_AUTH_TOKEN')
19+
20+
# Phone numbers
21+
my_number = '+xxx'
22+
her_number = '+xxx'
23+
24+
reasons = c(
25+
'Working hard',
26+
'Gotta ship this feature',
27+
'Someone fucked the system again'
28+
)
29+
30+
POST(paste("https://api.twilio.com/2010-04-01/Accounts/",TWILIO_ACCOUNT_SID,"/Messages.json",sep=""),
31+
body = list(From=my_number,To=her_number,Body=sample(reasons,1) ),
32+
authenticate(TWILIO_ACCOUNT_SID,TWILIO_AUTH_TOKEN) )
33+
34+
print( paste("Message sent at",Sys.time()) )

0 commit comments

Comments
 (0)