forked from NARKOZ/hacker-scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhangover.py
More file actions
executable file
·57 lines (46 loc) · 1.17 KB
/
hangover.py
File metadata and controls
executable file
·57 lines (46 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/usr/bin/env python
import datetime
import os
import random
from twilio.rest import TwilioRestClient
from time import strftime
import subprocess
today = datetime.date.today()
# skip weekends
if today.strftime('%A') in ('Saturday', 'Sunday'):
sys.exit()
# exit if sessions with my username are found
output = subprocess.check_output('who')
if 'my_username' in output:
sys.exit()
# returns 'None' if the key doesn't exist
TWILIO_ACCOUNT_SID = os.environ.get('TWILIO_ACCOUNT_SID')
TWILIO_AUTH_TOKEN = os.environ.get('TWILIO_AUTH_TOKEN')
# Phone numbers
my_number = '+xxx'
number_of_boss = '+xxx'
excuses = [
'Locked out',
'Pipes broke',
'Food poisoning',
'Not feeling well'
]
client = TwilioRestClient(TWILIO_ACCOUNT_SID, TWILIO_AUTH_TOKEN)
client.messages.create(
to=number_of_boss,
from_=my_number,
body="Gonna work from home. " + random.choice(excuses)
)
try:
f = open('logs/file.txt', 'a')
except IOError as e:
# dir & file don't exist; create them
os.mkdir('logs')
f = open('logs/file.txt', 'a')
except Exception as e:
print e
else:
pass
# log it
f.write("Message sent at " + strftime("%a, %d %b %Y %H:%M:%S") + "\n")
f.close()