X-Git-Url: https://jfr.im/git/erebus.git/blobdiff_plain/7500b48cb6a524ac7d22b9174aa62bc58489c1b7..f91b0ad4d11283464257fee1522284a4c4b33211:/modlib.py diff --git a/modlib.py b/modlib.py index 6962881..4c349c0 100644 --- a/modlib.py +++ b/modlib.py @@ -33,6 +33,7 @@ class modlib(object): def __init__(self, name): self.hooks = {} + self.numhooks = {} self.parent = None self.name = name @@ -41,12 +42,24 @@ class modlib(object): self.parent = parent for cmd, func in self.hooks.iteritems(): self.parent.hook(cmd, func) + for num, func in self.numhooks.iteritems(): + self.parent.hooknum(num, func) return True def modstop(self, parent): for cmd, func in self.hooks.iteritems(): self.parent.unhook(cmd, func) + for num, func in self.numhooks.iteritems(): + self.parent.unhooknum(num, func) return True + def hooknum(self, num): + def realhook(func): + self.numhooks[num] = func + if self.parent is not None: + self.parent.hooknum(num, func) + return func + return realhook + def hook(self, cmd, needchan=True, glevel=ANYONE, clevel=PUBLIC): def realhook(func): func.needchan = needchan