Exemplo n.º 1
0
 def die(self):
     """ Kills the bot.
     """
     PlugBot.stop(self)
     CommandBot.stop(self)
     self.rooms = {}
     logging.info("Disconnecting bot")
     self.disconnect()
Exemplo n.º 2
0
    def rehash(self):
        """ Re-reads the config file, making appropriate runtime changes.
            Causes all plugins to be reloaded (or unloaded).
            The XMPP stream and MUC rooms will not be disconnected.
        """
        logging.info("Rehashing started")
        modules = self.cmd_plugins.get_modules()
        CommandBot.pause(self)
        PlugBot.stop(self)

        logging.info("Reloading config file")
        self.botconfig = self.load_config(self.config_file)
        for module in modules:
            reload(module)
        CommandBot.reset(self)

        PlugBot.start(self)
        CommandBot.resume(self)
        self.join_rooms()
Exemplo n.º 3
0
 def __init__(self, config_file, ssl=False, plugin_config = {}):
     """ Initializes the bot
             config_file -- string pointing to an xml configuration file
     """
     self.config_file = config_file
     self.botconfig = self.load_config(config_file)
     auth = self.botconfig.find('auth')
     logging.info("Logging in as %s" % auth.attrib['jid'])
     sleekxmpp.ClientXMPP.__init__(self, auth.attrib['jid'], auth.attrib['pass'], auth.get('ssl', True), plugin_config)
     storageXml = self.botconfig.find('storage')
     if storageXml is not None:
         self.store = store(storageXml.attrib['file'])
     else:
         logging.warning("No storage element found in config file - proceeding with no persistent storage, plugin behaviour may be undefined.")
     self.rooms = {}
     self.add_event_handler("session_start", self.handle_session_start, threaded=True)
     self.register_xmpp_plugins()
     CommandBot.__init__(self)
     PlugBot.__init__(self, default_package = 'sleekbot.plugins')
     self.register_adhocs()