Ejemplo n.º 1
0
    def __init__(self):
        # basic variables
        self.start_time = time.time()
        self.running = True
        self.do_restart = False

        # stores all queued messages from all connections
        self.queued_messages = queue.Queue()
        # format: [{
        #   "conn": BotConnection, "raw": str, "prefix": str, "command": str, "params": str, "nick": str,
        #   "user": str, "host": str, "mask": str, "paramlist": list[str], "lastparam": str
        # }]

        # stores each bot server connection
        self.connections = []

        # set up logging
        self.logger = get_logger()
        self.logger.debug("Logging system initialised.")

        # declare and create data folder
        self.data_dir = os.path.abspath('data')
        if not os.path.exists(self.data_dir):
            self.logger.debug("Data folder not found, creating.")
            os.mkdir(self.data_dir)

        # set up config
        self.config = config.Config(self)
        self.logger.debug("Config system initialised.")

        # setup db
        db_path = self.config.get('database', 'sqlite:///cloudbot.db')
        self.db_engine = create_engine(db_path)
        self.db_factory = sessionmaker(bind=self.db_engine)
        self.db_session = scoped_session(self.db_factory)
        self.db_metadata = MetaData()
        # set botvars.metadata so plugins can access when loading
        botvars.metadata = self.db_metadata
        self.logger.debug("Database system initialised.")

        # Bot initialisation complete
        self.logger.debug("Bot setup completed.")

        self.threads = {}

        # create bot connections
        self.create_connections()

        # run plugin loader
        self.plugin_manager = PluginManager(self)

        self.loader = PluginLoader(self)
Ejemplo n.º 2
0
    for saip in options.server_accepted:
        try:
            ipy_saip = IPy.IP(saip)
            for saip in ipy_saip:
                server_accepted.append(saip.strNormal(0))
        except Exception, e:
            logWarn("Invalid Accepted IP [%s]" % (saip), TAG_NAME)
            pass

connection_address = (ip.strNormal(0), port)

# load and parse config file
config = parseConfigs(options.config_file)

# istantiate PluginLoader class
loader = PluginLoader(config)

try:
    common_messages = loader.callPlugin('common')
except Exception, e:
    logErr("COMMON_MESSAGES_ERROR: %s" % (e), TAG_NAME)
    sys.exit(1)

msgs = []
app_id_conf = config['interface'].lower()

try:
    msgs = loader.callPlugin('%s_3gpp' % (app_id_conf))
except Exception, e:
    logErr("Unknown interface %s [%s]" % (app_id_conf, e), TAG_NAME)
    sys.exit(1)