File tree Expand file tree Collapse file tree 1 file changed +14
-15
lines changed Expand file tree Collapse file tree 1 file changed +14
-15
lines changed Original file line number Diff line number Diff line change @@ -6,34 +6,33 @@ if ($DAYOFWEEK -eq 6 -or $DAYOFWEEK -eq 7) {
6
6
}
7
7
8
8
# Exit early if no sessions with my username are found
9
- if ((QWINSTA $env: USERNAME | measure).Count -gt 0 ) {
9
+ if (-not (QWINSTA | FINDSTR $env: USERNAME )) {
10
10
return
11
11
}
12
12
13
13
# Phone numbers
14
14
$MY_NUMBER = ' +xxx'
15
15
$HER_NUMBER = ' +xxx'
16
16
17
- $TWILIO_ACCOUNT_SID = ' xxx'
18
- $TWILIO_AUTH_TOKEN = ' xxx'
19
-
20
- $REASONS =
17
+ $REASONS =
21
18
' Working hard' ,
22
19
' Gotta ship this feature' ,
23
20
' Someone fucked the system again'
21
+ $reason = $REASONS | Get-Random
22
+ $message = " Late at work. $reason ."
23
+
24
+ $API_URL = " https://api.twilio.com/2010-04-01/Accounts/$env: TWILIO_ACCOUNT_SID /Messages"
25
+ $BASE64AUTHINFO = [Convert ]::ToBase64String([Text.Encoding ]::ASCII.GetBytes((" {0}:{1}" -f $env: TWILIO_ACCOUNT_SID , $env: TWILIO_AUTH_TOKEN )))
26
+ $body = @ {
27
+ From = $MY_NUMBER ;
28
+ To = $HER_NUMBER ;
29
+ Body = $message ;
30
+ }
24
31
25
- $RAND = Get-Random - Maximum $REASONS.Count
26
-
27
- $MSG = " Late at work. $REASONS [$RAND ]"
28
-
29
-
30
- $BASE64AUTHINFO = [Convert ]::ToBase64String([Text.Encoding ]::ASCII.GetBytes((" {0}:{1}" -f $TWILIO_ACCOUNT_SID , $TWILIO_AUTH_TOKEN )))
31
-
32
- # Send a text messag and Log errors
32
+ # Send a text message and Log errors
33
33
try {
34
- 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
34
+ Invoke-RestMethod - Method Post - Headers @ {Authorization = (" Basic {0}" -f $BASE64AUTHINFO )} $API_URL - Body $body > $null
35
35
}
36
36
catch {
37
37
Write-Host " Failed to send SMS: $_ "
38
38
}
39
-
You can’t perform that action at this time.
0 commit comments