catch all exceptions around self.do, and log to console

as much as i find this uncouth, it is handy, and also it seems
that the megahal brain gets corrupted/unusable when an exception
isn't caught and the bot dies. this should cover most of the
cases
This commit is contained in:
Brian S. Stephan 2010-12-24 13:16:09 -06:00
parent f590daf5cd
commit 377d2145fa
1 changed files with 8 additions and 2 deletions

View File

@ -158,7 +158,10 @@ class Module(object):
elif strip_bot_name_from_input:
what = addressed_re.sub('', what)
self.do(connection, event, nick, userhost, replypath, what, admin_unlocked)
try:
self.do(connection, event, nick, userhost, replypath, what, admin_unlocked)
except Exception as e:
print('EXCEPTION: ' + str(e))
def on_privmsg(self, connection, event):
"""
@ -190,7 +193,10 @@ class Module(object):
if internal_only and replypath is not None:
return
self.do(connection, event, nick, userhost, replypath, what, admin_unlocked)
try:
self.do(connection, event, nick, userhost, replypath, what, admin_unlocked)
except Exception as e:
print('EXCEPTION: ' + str(e))
def reload(self):
"""Reload this module's code and then create a new object of it, removing the old."""