Using newly added Python decorator for hook registration
This commit is contained in:
parent
23bc61cce0
commit
fe0f120038
19 changed files with 119 additions and 147 deletions
|
|
@ -5,21 +5,18 @@ import imp
|
|||
from datetime import datetime
|
||||
from datetime import timedelta
|
||||
|
||||
from hooks import hook
|
||||
|
||||
nemubotversion = 3.3
|
||||
|
||||
def help_tiny ():
|
||||
def help_tiny():
|
||||
"""Line inserted in the response to the command !help"""
|
||||
return "as http://sleepyti.me/, give you the best time to go to bed"
|
||||
|
||||
def help_full ():
|
||||
def help_full():
|
||||
return "If you would like to sleep soon, use !sleepytime to know the best time to wake up; use !sleepytime hh:mm if you want to wake up at hh:mm"
|
||||
|
||||
def load(context):
|
||||
from hooks import Hook
|
||||
add_hook("cmd_hook", Hook(cmd_sleep, "sleeptime"))
|
||||
add_hook("cmd_hook", Hook(cmd_sleep, "sleepytime"))
|
||||
|
||||
|
||||
@hook("cmd_hook", "sleepytime", help="If you would like to sleep soon, use !sleepytime to know the best time to wake up; use !sleepytime hh:mm if you want to wake up at hh:mm")
|
||||
def cmd_sleep(msg):
|
||||
if len (msg.cmds) > 1 and re.match("[0-9]{1,2}[h':.,-]([0-9]{1,2})?[m'\":.,-]?",
|
||||
msg.cmds[1]) is not None:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue