This commit is contained in:
Vladimir Riznic 2022-09-30 00:21:50 -04:00 committed by GitHub
commit 0e90bf469b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 47 additions and 37 deletions

17
python/config.py Normal file
View File

@ -0,0 +1,17 @@
SYSTEM_USERNAME = 'your system username'
GMAIL_USERNAME = 'username'
GMAIL_PASSWORD = 'pass'
TWILIO_ACCOUNT_SID = 'YOUR TWILIO ACCOUNT SID'
TWILIO_AUTH_TOKEN = 'YOUR TWILIO ACCOUNT TOKEN'
PHONEBOOK = {
'ME': 'YOUR PHONE NUM',
'WIFE': 'WIFE\'S PHONE NUM',
'BOSS': 'BOSS\' PHONE NUM',
}
EMAIL_CONTACTS = {
'KUMAR': 'KUMAR\'S EMAIL',
}

View File

@ -5,6 +5,8 @@ import subprocess
import telnetlib
import time
import config
# exit if no sessions with my username are found
output = subprocess.check_output('who')
if 'my_username' not in output:
@ -26,4 +28,4 @@ time.sleep(24)
# love the smell!
con.write("sys pour\n")
con.close()
con.close()

View File

@ -6,31 +6,25 @@ from twilio.rest import TwilioRestClient
from time import strftime
import subprocess
import config
# exit if sessions with my username are found
output = subprocess.check_output('who')
if 'my_username' in output:
if config.SYSTEM_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'
'Locked out',
'Pipes broke',
'Food poisoning',
'Not feeling well'
]
client = TwilioRestClient(TWILIO_ACCOUNT_SID, TWILIO_AUTH_TOKEN)
client = TwilioRestClient(config.TWILIO_ACCOUNT_SID, config.TWILIO_AUTH_TOKEN)
client.messages.create(
to=number_of_boss,
from_=my_number,
to=config.PHONEBOOK['BOSS'],
from_=config.PHONEBOOK['ME'],
body="Gonna work from home. " + random.choice(excuses)
)

View File

@ -4,19 +4,22 @@ import gmail
import sys
import re
GMAIL_USERNAME = ENV['GMAIL_USERNAME']
GMAIL_PASSWORD = ENV['GMAIL_PASSWORD']
import config
g = gmail.login(GMAIL_USERNAME, GMAIL_PASSWORD)
g = gmail.login(config.GMAIL_USERNAME, config.GMAIL_PASSWORD)
if not g.logged_in:
sys.exit()
msgs = g.inbox().mail(sender="kumar.a@example.com", unread=True, prefetch=True)
msgs = g.inbox().mail(
sender=config.EMAIL_CONTACTS['KUMAR'],
unread=True,
prefetch=True
)
pattern = re.compile("\bsorry\b | \bhelp\b | \bwrong\b ", flags=re.I)
for msg in msgs:
if pattern.match(msg.body):
msg.label("Database fixes")
msg.reply("No problem. I've fixed it. \n\n Please be careful next time.")
msg.reply("No problem. I've fixed it.\n\nPlease be careful next time.")

View File

@ -7,30 +7,24 @@ import subprocess
import sys
from time import strftime
import config
# exit if no sessions with my username are found
output = subprocess.check_output('who')
if 'my_username' not in output:
if config.SYSTEM_USERNAME not 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'
her_number = '+xxx'
reasons = [
'Working hard',
'Gotta ship this feature',
'Someone fucked the system again'
'Working hard',
'Gotta ship this feature',
'Someone fucked the system again',
]
client = TwilioRestClient(TWILIO_ACCOUNT_SID, TWILIO_AUTH_TOKEN)
client = TwilioRestClient(config.TWILIO_ACCOUNT_SID, config.TWILIO_AUTH_TOKEN)
client.messages.create(
to=her_number,
from_=my_number,
to=config.EMAIL_CONTACTS['WIFE'],
from_=config.EMAIL_CONTACTS['ME'],
body="Late at work. " + random.choice(reasons)
)