+ func.cmd = cmd
+ func.module = func.__module__.split('.')[1]
+
+ for c in cmd:
+ self.hooks[c] = func
+ if self.parent is not None:
+ self.parent.hook(c, func)
+ self.parent.hook("%s.%s" % (self.name, c), func)
+ return func
+ return realhook
+
+ def mod(self, modname):
+ if self.parent is not None:
+ return self.parent.module(modname)
+ else:
+ return error('unknown parent')
+
+ def argsEQ(self, num):
+ def realhook(func):
+ def checkargs(bot, user, chan, realtarget, *args):
+ if len(args) == num:
+ return func(bot, user, chan, realtarget, *args)
+ else:
+ bot.msg(user, self.WRONGARGS)
+ checkargs.__name__ = func.__name__
+ checkargs.__module__ = func.__module__
+ return checkargs
+ return realhook
+
+ def argsGE(self, num):
+ def realhook(func):
+ def checkargs(bot, user, chan, realtarget, *args):
+ if len(args) >= num:
+ return func(bot, user, chan, realtarget, *args)
+ else:
+ bot.msg(user, self.WRONGARGS)
+ checkargs.__name__ = func.__name__
+ checkargs.__module__ = func.__module__
+ return checkargs
+ return realhook