diff --git a/main.py b/main.py index 55619ad..21ffd70 100644 --- a/main.py +++ b/main.py @@ -9,6 +9,7 @@ import client_wrapper import identifier import job_commands import management_commands +import periodicals import scroll_util import slack_util import slavestothemachine @@ -49,6 +50,9 @@ def main() -> None: # Add boozebot # wrap.add_passive(periodicals.ItsTenPM()) + # Add nagloop + wrap.add_passive(periodicals.RemindJobs()) + event_loop = asyncio.get_event_loop() event_loop.set_debug(True) message_handling = wrap.respond_messages() diff --git a/periodicals.py b/periodicals.py index 74d8277..159abee 100644 --- a/periodicals.py +++ b/periodicals.py @@ -36,8 +36,8 @@ class ItsTenPM(slack_util.Passive): class RemindJobs(slack_util.Passive): async def run(self, slack: SlackClient) -> None: while True: - # Get the end of the current day (Say, 9PM) - today_remind_time = datetime.now().replace(hour=22, minute=0, second=0) + # Get the end of the current day (Say, 10PM) + today_remind_time = datetime.now().replace(hour=22, minute=00, second=0) # Get the current day of week dow = ["Monday", @@ -77,15 +77,23 @@ class RemindJobs(slack_util.Passive): assigns: List[house_management.JobAssignment] = [a for a in assigns if valid_filter(a)] # Now, we want to nag each person. If we don't actually know who they are, so be it. + print("Nagging!") for a in assigns: # Get the relevant slack ids assignee_ids = identifier.lookup_brother_userids(a.assignee) # For each, send them a DM + success = False for slack_id in assignee_ids: dm_id = slack_util.im_channel_for_id(slack, slack_id) - msg = "Your job ({}) is currently not signed off. Don't forget!".format(a.job.pretty_fmt()) - slack_util.send_message(slack, msg, dm_id) + msg = "{}, you still need to do {}".format(a.assignee.name, a.job.pretty_fmt()) + if dm_id: + success = True + slack_util.send_message(slack, msg, dm_id) + + # Warn on failure + if not success: + print("Tried to nag {} but couldn't find their slack id".format(a.assignee.name)) # Take a break to ensure no double-shots await asyncio.sleep(10)