Hook factorisation ; add new hooks : default (same comportement has previous version) and one hook before any parsing

When calling a hook, passed parameters change according to associated data variable
This commit is contained in:
Némunaire 2012-08-22 21:05:33 +02:00
commit 7e20368c10
8 changed files with 109 additions and 63 deletions

View file

@ -20,7 +20,7 @@ def load(context):
context.hooks.add_hook(context.hooks.cmd_hook, Hook(cmd_sleep, "sleepytime"))
def cmd_sleep(data, msg):
def cmd_sleep(msg):
if len (msg.cmd) > 1 and re.match("[0-9]{1,2}[h':.,-]([0-9]{1,2})?[m'\":.,-]?",
msg.cmd[1]) is not None:
# First, parse the hour