From: zonidjan Date: Fri, 24 Jan 2014 08:36:02 +0000 (-0600) Subject: Added hooknum in modlib X-Git-Url: https://jfr.im/git/erebus.git/commitdiff_plain/61b67f0f5502c4e6fbecfb54a8cf51af877edf93 Added hooknum in modlib --- 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