--- /dev/null
+class modlib(object):
+ hooks = {}
+ parent = None
+
+ def __init__(self, name):
+ self.name = name
+
+ def modstart(self, parent):
+ self.parent = parent
+ for cmd, func in self.hooks.iteritems():
+ self.parent.hook(cmd, func)
+
+ def hook(self, cmd):
+ def realhook(func):
+ self.hooks[cmd] = func
+ if self.parent is not None:
+ self.parent.hook(cmd, func)
+ return func
+ return realhook
--- /dev/null
+# preamble
+import modlib
+lib = modlib.modlib(__name__)
+modstart = lib.modstart
+
+#module code
+@lib.hook('test')
+def cmd_test(bot, user, chan, *args):
+ bot.msg(chan, "You said: !test %s" % (' '.join([str(arg) for arg in args])))