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
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue