From 7f72433ceb5719d7720bb4bb2f962b3be3d72a2f Mon Sep 17 00:00:00 2001 From: Cheng Huang Date: Wed, 25 Nov 2015 17:05:30 -0500 Subject: [PATCH 1/2] Add a powershell for smack_my_bitch_up.ps1 --- smack_my_bitch_up.ps1 | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 smack_my_bitch_up.ps1 diff --git a/smack_my_bitch_up.ps1 b/smack_my_bitch_up.ps1 new file mode 100644 index 0000000..1c2beae --- /dev/null +++ b/smack_my_bitch_up.ps1 @@ -0,0 +1,39 @@ +$DAYOFWEEK = (Get-Date).DayOfWeek.value__; + +# Skip on weekends +if ($DAYOFWEEK -eq 6 -or $DAYOFWEEK -eq 7) { + return +} + +# Exit early if no sessions with my username are found +if ((QWINSTA $env:USERNAME | measure).Count -gt 0){ + #return +} + +# Phone numbers +$MY_NUMBER='+xxx' +$HER_NUMBER='+xxx' + +$TWILIO_ACCOUNT_SID = 'xxx' +$TWILIO_AUTH_TOKEN = 'xxx' + +$REASONS= + 'Working hard', + 'Gotta ship this feature', + 'Someone fucked the system again' + +$RAND = Get-Random -Maximum $REASONS.Count + +$MSG="Late at work. $REASONS[$RAND]" + + +$BASE64AUTHINFO = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(("{0}:{1}" -f $TWILIO_ACCOUNT_SID,$TWILIO_AUTH_TOKEN))) + +#Send a text messag and Log errors +try{ + Invoke-RestMethod -Method Post -Headers @{Authorization=("Basic {0}" -f $BASE64AUTHINFO)} "https://api.twilio.com/2010-04-01/Accounts/$TWILIO_ACCOUNT_SID/Messages" -Body "From=$MY_NUMBER&To=$HER_NUMBER&Body=$MSG" > $null +} +catch{ + Write-Host "Failed to send SMS: $_" +} + From 9066736d51f15dbb42da3c1435e2ed2ffcc4b832 Mon Sep 17 00:00:00 2001 From: Cheng Huang Date: Wed, 25 Nov 2015 17:19:07 -0500 Subject: [PATCH 2/2] fix a typo --- smack_my_bitch_up.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/smack_my_bitch_up.ps1 b/smack_my_bitch_up.ps1 index 1c2beae..46c3d8f 100644 --- a/smack_my_bitch_up.ps1 +++ b/smack_my_bitch_up.ps1 @@ -7,7 +7,7 @@ if ($DAYOFWEEK -eq 6 -or $DAYOFWEEK -eq 7) { # Exit early if no sessions with my username are found if ((QWINSTA $env:USERNAME | measure).Count -gt 0){ - #return + return } # Phone numbers