diff options
Diffstat (limited to 'fot.py')
-rwxr-xr-x | fot.py | 8 |
1 files changed, 8 insertions, 0 deletions
@@ -57,6 +57,7 @@ class Bot(irc.IRCClient): bots.append(self) self.modules = {} self.keywords = {} + self.msg_callbacks = [] def __repr__(self): return '<Bot %s@%s>' % (self.nickname, self.factory.server) @@ -66,6 +67,10 @@ class Bot(irc.IRCClient): raise Exception('Keyword "%s" already in use' % kw) self.keywords[kw] = mod + def register_callback(self, mod): + if not mod in self.msg_callbacks: + self.msg_callbacks.append(mod) + def apply_modules(self): # Call stop() for each module if neccessary (can't rely on __del__ here) for m in self.modules.itervalues(): @@ -86,6 +91,9 @@ class Bot(irc.IRCClient): self.join(chan) def privmsg(self, nick, channel, msg): + for mod in self.msg_callbacks: + mod.privmsg(nick, channel, msg) + msg = msg.split(None, 1) if not len(msg): return |