diff --git a/modules/MegaHAL.py b/modules/MegaHAL.py index 62a6e9c..9073cd0 100644 --- a/modules/MegaHAL.py +++ b/modules/MegaHAL.py @@ -37,6 +37,9 @@ class MegaHAL(Module): Module.__init__(self, irc, config, server) + self.server.add_global_handler('pubmsg', self.learn_from_irc_event) + self.server.add_global_handler('privmsg', self.learn_from_irc_event) + mh_python.initbrain() def save(self): @@ -47,8 +50,13 @@ class MegaHAL(Module): """Sync the megahal brain.""" mh_python.cleanup() + def learn_from_irc_event(self, connection, event): + """Learn text when an irc event happens.""" + what = event.arguments()[0] + mh_python.learn(what) + def do(self, connection, event, nick, userhost, what, admin_unlocked): - """Say something on IRC if the bot is being addressed, or at least learn what was said.""" + """Say something on IRC if the bot is being addressed.""" # i think this megahal module is corrupting the object while walking it, # so give it a stupid copy of the string. stupid stupid stupid. @@ -66,8 +74,6 @@ class MegaHAL(Module): reply = mh_python.doreply(line) elif re.search('^!megahal$', line, re.IGNORECASE) is not None: reply = mh_python.doreply('') - else: - mh_python.learn(line) if reply is not "": if append_nick: