From c5a9a419356270026eba95efcab8fcfd77762acf Mon Sep 17 00:00:00 2001 From: Jacob Henry Date: Mon, 12 Nov 2018 13:35:04 -0500 Subject: [PATCH] Added reply callback procedure? --- job_commands.py | 7 +++++-- main.py | 6 ++---- slack_util.py | 2 +- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/job_commands.py b/job_commands.py index ce7ea8f..8da42ff 100644 --- a/job_commands.py +++ b/job_commands.py @@ -4,6 +4,7 @@ from fuzzywuzzy import fuzz from slackclient import SlackClient import channel_util +import client_wrapper import house_management import identifier import scroll_util @@ -66,7 +67,8 @@ def do_signoff(slack: SlackClient, msg: dict, on_assign_index: int, by_brother: slack_util.reply(slack, msg, "{} signed off {} for {}".format(on_assign.signer.name, on_assign.assignee.name, on_assign.job.pretty_fmt())) - alert_user(slack, on_assign.assignee, "Your house job was signed off") + alert_user(slack, on_assign.assignee, "{} signed you off for {}.".format(on_assign.signer.name, + on_assign.job.pretty_fmt())) async def signoff_callback(slack: SlackClient, msg: dict, match: Match) -> None: @@ -145,7 +147,8 @@ async def signoff_callback(slack: SlackClient, msg: dict, match: Match) -> None: "signoff step.") # Make a listener hook - slack_util.ReplyWaiter(foc, pattern, msg["ts"], 60) + new_hook = slack_util.ReplyWaiter(foc, pattern, msg["ts"], 60) + client_wrapper.get_client_wrapper().add_hook(new_hook) # noinspection PyUnusedLocal diff --git a/main.py b/main.py index b6110f3..2b2db43 100644 --- a/main.py +++ b/main.py @@ -7,13 +7,11 @@ import management_commands import periodicals import scroll_util import slavestothemachine - -# Read api token from file -from client_wrapper import ClientWrapper +import client_wrapper def main() -> None: - wrap = ClientWrapper() + wrap = client_wrapper.get_client_wrapper() # Add scroll handling wrap.add_hook(scroll_util.scroll_hook) diff --git a/slack_util.py b/slack_util.py index 585c2b5..7fae433 100644 --- a/slack_util.py +++ b/slack_util.py @@ -158,7 +158,7 @@ class ReplyWaiter(AbsHook): def try_apply(self, slack: SlackClient, msg: dict) -> Optional[Coroutine[None, None, None]]: # First check: are we dead of age yet? time_alive = time() - self.start_time - should_expire = time_alive < self.lifetime + should_expire = time_alive > self.lifetime # If so, give up the ghost if self.dead or should_expire: