+# Erebus IRC bot - Author: Erebus Team
+# vim: fileencoding=utf-8
+# This file is released into the public domain; see http://unlicense.org/
+
+# module info
+modinfo = {
+ 'author': 'Erebus Team',
+ 'license': 'public domain',
+ 'compatible': [0], # compatible module API versions
+ 'depends': [], # other modules required to work properly?
+ 'softdeps': [], # modules which are preferred but not required
+}
+
+# preamble
+import modlib
+lib = modlib.modlib(__name__)
+modstart = lib.modstart
+modstop = lib.modstop
+
+# module code
+import traceback
+
+@lib.hookexception(Exception)
+def got_exception(bot, exc, source, *args, **kwargs):
+ dest = lib.parent.cfg.get('exception_hook', 'destination')
+ if dest is not None:
+ bot.msg(dest, '%s exception: %r %r' % (source, args, kwargs))
+ for line in traceback.format_exc(limit=lib.parent.cfg.getint('exception_hook', 'limit', 5)).split("\n"):
+ bot.msg(dest, (' '*4) + line)