Merge branch 'refresh' of https://github.com/ClouDev/CloudBot into refresh
This commit is contained in:
commit
ef63c2321a
1 changed files with 7 additions and 6 deletions
13
util/hook.py
13
util/hook.py
|
@ -45,8 +45,9 @@ def sieve(func):
|
||||||
_hook_add(func, ['sieve', (func,)])
|
_hook_add(func, ['sieve', (func,)])
|
||||||
return func
|
return func
|
||||||
|
|
||||||
|
# TODO: Add support for multiple commands in one hook
|
||||||
def command(arg=None, **kwargs):
|
# EG: @hook.command(["command1", "command2"], **args)
|
||||||
|
def command(name=None, **kwargs):
|
||||||
args = {}
|
args = {}
|
||||||
|
|
||||||
def command_wrapper(func):
|
def command_wrapper(func):
|
||||||
|
@ -54,13 +55,13 @@ def command(arg=None, **kwargs):
|
||||||
_hook_add(func, ['command', (func, args)], 'command')
|
_hook_add(func, ['command', (func, args)], 'command')
|
||||||
return func
|
return func
|
||||||
|
|
||||||
if kwargs or not inspect.isfunction(arg):
|
if kwargs or not inspect.isfunction(name):
|
||||||
if arg is not None:
|
if name is not None:
|
||||||
args['name'] = arg
|
args['name'] = name
|
||||||
args.update(kwargs)
|
args.update(kwargs)
|
||||||
return command_wrapper
|
return command_wrapper
|
||||||
else:
|
else:
|
||||||
return command_wrapper(arg)
|
return command_wrapper(name)
|
||||||
|
|
||||||
|
|
||||||
def event(arg=None, **kwargs):
|
def event(arg=None, **kwargs):
|
||||||
|
|
Reference in a new issue