Job nagging now shows house #. Disabled debug mode default

This commit is contained in:
Jacob Henry 2018-09-13 00:42:24 -04:00
parent 5443b72d71
commit 1c42f81a39
2 changed files with 13 additions and 9 deletions

View File

@ -8,8 +8,8 @@ nag_pattern = r"nagjobs (tuesday|thursday)"
SHEET_ID = "1lPj9GjB00BuIq9GelOWh5GmiGsheLlowPnHLnWBvMOM" SHEET_ID = "1lPj9GjB00BuIq9GelOWh5GmiGsheLlowPnHLnWBvMOM"
eight_jobs = "House Jobs!A2:C25" # Format: Job Day Bro eight_job_range = "House Jobs!A2:C25" # Format: Job Day Bro
fiftythree_jobs = "House Jobs!E2:G6" fiftythree_job_range = "House Jobs!E2:G6"
# For matching purposes # For matching purposes
tuesday = "tuesday" tuesday = "tuesday"
@ -17,8 +17,8 @@ thursday = "thursday"
class Job(object): class Job(object):
def __init__(self, row): def __init__(self, house, job_name, day, brother_name):
self.job_name, self.day, self.brother_name = row self.house, self.job_name, self.day, self.brother_name = house, job_name, day, brother_name
self.day = self.day.lower().strip() self.day = self.day.lower().strip()
def lookup_brother_slack_id(self): def lookup_brother_slack_id(self):
@ -35,9 +35,13 @@ def nag_callback(slack, msg, match):
day = match.group(1).lower() day = match.group(1).lower()
# Get the spreadsheet section # Get the spreadsheet section
jobs = google_api.get_sheet_range(SHEET_ID, eight_jobs) eight_jobs = google_api.get_sheet_range(SHEET_ID, eight_job_range)
jobs = jobs + google_api.get_sheet_range(SHEET_ID, fiftythree_jobs) ft_jobs = google_api.get_sheet_range(SHEET_ID, fiftythree_job_range)
jobs = [Job(r) for r in jobs]
# Turn to job objects
eight_jobs = [Job("8", *r) for r in eight_jobs]
ft_jobs = [Job("53", *r) for r in ft_jobs]
jobs = eight_jobs + ft_jobs
# Filter to day # Filter to day
jobs = [j for j in jobs if j.day == day] jobs = [j for j in jobs if j.day == day]
@ -45,7 +49,7 @@ def nag_callback(slack, msg, match):
# Nag each # Nag each
response = "Do your jobs! They are as follows:\n" response = "Do your jobs! They are as follows:\n"
for job in jobs: for job in jobs:
response += "{} -- ".format(job.job_name) response += "({}) {} -- ".format(job.house, job.job_name)
ids = job.lookup_brother_slack_id() ids = job.lookup_brother_slack_id()
if ids: if ids:
for id in ids: for id in ids:

View File

@ -22,7 +22,7 @@ kill_switch = next(kill_switch_file).strip()
kill_switch_file.close() kill_switch_file.close()
# Enable to use dummy # Enable to use dummy
DEBUG_MODE = True DEBUG_MODE = False
def main(): def main():