def robocop(self, message): # Call back a hooked robocop module command = message.get_command() # Check we have a callback stored for this command, if self.robocops.has_key(command): callback = self.robocops[command] # and call it, passing in the message try: callback.robocop(message) except (MerlinSystemCall, socket.error): raise except Exception, e: # Error while executing a callback/mod/hook message.alert(False) log(Config.get("Misc","errorlog"), "%s - RoboCop Callback Error: %s\n%s\n" % (time.asctime(),str(e),message,)) finally:
def reload(self): from Core.config import Config from Core.string import log # If the reload succeeds, this Loader instance will be # replaced, so this .success is only tested if it fails. self.success = False try: # Reload this module, which will instantiate a new # Loader, which in turn will do all the main loading. self.load_module("Core.loader") # Check the new loader has a successful status if sys.modules["Core.loader"].Loader.success is not True: raise ImportError except Exception, e: # If the new Loader fails, catch the error and restore everything print "%s Reload failed, reverting to previous." % (time.asctime(),) log(Config.get("Misc","errorlog"), "%s - Loader Reload Error: %s\n" % (time.asctime(),str(e),)) self.restore(sys)
def callback(self, message): # Call back a hooked module event = message.get_command() # Check we have some callbacks stored for this event, if self.callbacks.has_key(event): # cycle through them for callback in self.callbacks[event]: # and call each one, passing in the message try: callback(message) except (MerlinSystemCall, socket.error): raise except Exception, e: # Error while executing a callback/mod/hook message.alert("Error in module '%s'. Please report the command you used to the bot owner as soon as possible." % (callback.name,)) log(Config.get("Misc","errorlog"), "%s - IRC Callback Error: %s\n%s\n" % (time.asctime(),str(e),message,)) finally: # Remove any uncommitted or unrolled-back state session.remove()
def process_exception(self, request, exception): log(Config.get("Misc", "arthurlog"), "%s - Arthur Error: %s\n" % (time.asctime(), str(exception)))