2
0
mirror of https://github.com/narkoz/hacker-scripts synced 2025-08-23 10:57:13 +00:00
hacker-scripts/python/hangover.py
Julio Ordonez Viales b9c6dad2c5 Update cron job to be executed on weekdays only
Updated the cron job so that it only executes the scripts on weekdays, that way there is not need to check for this condition inside the scripts, updated the scripts as well
2015-11-26 19:26:15 -06:00

38 lines
832 B
Python
Executable File

#!/usr/bin/env python
import os
import random
from twilio.rest import TwilioRestClient
from time import strftime
import subprocess
# 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)
)
print "Message sent at " + strftime("%a, %d %b %Y %H:%M:%S")