Skip to content

refactored to support single config file #141

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions python/config.py
Original file line number Diff line number Diff line change
@@ -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',
}
4 changes: 3 additions & 1 deletion python/fucking_coffee.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
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:
Expand All @@ -24,4 +26,4 @@

# love the smell!
con.write("sys pour\n")
con.close()
con.close()
26 changes: 10 additions & 16 deletions python/hangover.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,31 +6,25 @@
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)
)

Expand Down
13 changes: 8 additions & 5 deletions python/kumar_asshole.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,22 @@
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="[email protected]", 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.")
24 changes: 9 additions & 15 deletions python/smack_my_bitch_up.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,30 +7,24 @@
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)
)

Expand Down