예제 #1
0
파일: neubot.py 프로젝트: blejdfist/NeuBot
class NeuBot:
    """NeuBot"""
    def __init__(self):
        self.eventcontroller   = EventController()
        self.plugincontroller  = PluginController()
        self.ircnetscontroller = IRCNetsController()

        self.config = ConfigController()
        self.config.reload()

        self.quit_event = threading.Event()
        self.eventcontroller.register_system_event("BOT_QUIT", self.system_quit)

    def system_quit(self, params):
        self.quit_event.set()

    def start(self):
        # Initialize data store
        DatastoreController().set_driver(self.config.get('datastore'))

        Logger.set_loglevel(self.config.get('log.level'))

        for plugin in self.config.get('coreplugins'):
            Logger.info("Loading core plugin '%s'" % plugin)
            self.plugincontroller.load_plugin(plugin, 'core')

        for plugin in self.config.get('plugins'):
            Logger.info("Loading plugin '%s'" % plugin)
            self.plugincontroller.load_plugin(plugin)

        if len(self.config.get('ircnets')) == 0:
            raise Exception("There has to be at least one ircnet to connect to")

        for net in self.config.get('ircnets'):
            irc = IRCController(self.eventcontroller)
            irc.set_configuration(net)

            Logger.info("Connecting to %s..." % irc.get_ircnet_name())
            irc.connect()

            self.ircnetscontroller.add_ircnet(irc.get_ircnet_name(), irc)

    def stop(self):
        self.ircnetscontroller.disconnect_all()
        self.plugincontroller.unload_all()
예제 #2
0
파일: neubot.py 프로젝트: blejdfist/NeuBot
    def __init__(self):
        self.eventcontroller   = EventController()
        self.plugincontroller  = PluginController()
        self.ircnetscontroller = IRCNetsController()

        self.config = ConfigController()
        self.config.reload()

        self.quit_event = threading.Event()
        self.eventcontroller.register_system_event("BOT_QUIT", self.system_quit)