Browse Source

Send a message when an IRC-initiated task completes.

tags/v0.3
Ben Kurtovic 9 years ago
parent
commit
f8bb72f9f2
2 changed files with 5 additions and 0 deletions
  1. +3
    -0
      earwigbot/commands/threads.py
  2. +2
    -0
      earwigbot/managers.py

+ 3
- 0
earwigbot/commands/threads.py View File

@@ -142,6 +142,9 @@ class Threads(Command):
return return


data.kwargs["fromIRC"] = True 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) self.bot.tasks.start(task_name, **data.kwargs)
msg = "Task \x0302{0}\x0F started.".format(task_name) msg = "Task \x0302{0}\x0F started.".format(task_name)
self.reply(data, msg) self.reply(data, msg)

+ 2
- 0
earwigbot/managers.py View File

@@ -247,6 +247,8 @@ class TaskManager(_ResourceManager):
else: else:
msg = "Task '{0}' finished successfully" msg = "Task '{0}' finished successfully"
self.logger.info(msg.format(task.name)) self.logger.info(msg.format(task.name))
if kwargs.get("fromIRC"):
kwargs.get("_IRCCallback")()


def start(self, task_name, **kwargs): def start(self, task_name, **kwargs):
"""Start a given task in a new daemon thread, and return the thread. """Start a given task in a new daemon thread, and return the thread.


Loading…
Cancel
Save