Using newly added Python decorator for hook registration

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

View file

@ -2,12 +2,11 @@
import random
from hooks import hook
nemubotversion = 3.3
def load(context):
from hooks import Hook
add_hook("cmd_hook", Hook(cmd_choice, "choice"))
@hook("cmd_hook", "choice")
def cmd_choice(msg):
if len(msg.cmds) > 1:
return Response(msg.sender, random.choice(msg.cmds[1:]), channel=msg.channel, nick=msg.nick)