Merge branch 'refresh' of https://github.com/ClouDev/CloudBot into refresh

This commit is contained in:
Luke Rogers 2014-03-25 14:47:01 +13:00
commit ef63c2321a

View file

@ -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):