From f8bb72f9f24b1de1960afc70387463335a578744 Mon Sep 17 00:00:00 2001 From: Ben Kurtovic Date: Wed, 16 Dec 2015 03:35:01 -0600 Subject: [PATCH] Send a message when an IRC-initiated task completes. --- earwigbot/commands/threads.py | 3 +++ earwigbot/managers.py | 2 ++ 2 files changed, 5 insertions(+) diff --git a/earwigbot/commands/threads.py b/earwigbot/commands/threads.py index 30751fe..d877792 100644 --- a/earwigbot/commands/threads.py +++ b/earwigbot/commands/threads.py @@ -142,6 +142,9 @@ class Threads(Command): return data.kwargs["fromIRC"] = True + data.kwargs["_IRCCallback"] = lambda: self.reply( + data, "Task \x0302{0}\x0F finished.".format(task_name)) + self.bot.tasks.start(task_name, **data.kwargs) msg = "Task \x0302{0}\x0F started.".format(task_name) self.reply(data, msg) diff --git a/earwigbot/managers.py b/earwigbot/managers.py index 7605139..c980f7a 100644 --- a/earwigbot/managers.py +++ b/earwigbot/managers.py @@ -247,6 +247,8 @@ class TaskManager(_ResourceManager): else: msg = "Task '{0}' finished successfully" self.logger.info(msg.format(task.name)) + if kwargs.get("fromIRC"): + kwargs.get("_IRCCallback")() def start(self, task_name, **kwargs): """Start a given task in a new daemon thread, and return the thread.