Using newly added Python decorator for hook registration

This commit is contained in:
nemunaire 2014-08-12 20:10:19 +02:00
commit fe0f120038
19 changed files with 119 additions and 147 deletions

View file

@ -5,15 +5,12 @@ import sys
from datetime import datetime
from datetime import date
from hooks import hook
from xmlparser.node import ModuleState
nemubotversion = 3.3
def load(context):
from hooks import Hook
add_hook("cmd_hook", Hook(cmd_anniv, "anniv"))
add_hook("cmd_hook", Hook(cmd_age, "age"))
global DATAS
DATAS.setIndex("name", "birthday")
@ -44,6 +41,7 @@ def findName(msg):
return (matches, name)
@hook("cmd_hook", "anniv")
def cmd_anniv(msg):
(matches, name) = findName(msg)
if len(matches) == 1:
@ -71,6 +69,7 @@ def cmd_anniv(msg):
" de %s. Quand est-il né ?" % name,
msg.channel, msg.nick)
@hook("cmd_hook", "age")
def cmd_age(msg):
(matches, name) = findName(msg)
if len(matches) == 1: