Exemplo n.º 1
0
    def __init__(self):
        super().__init__(command_prefix=None)  # implemented in `get_prefix`
        self._session = None
        self._api = None
        self.metadata_loop = None
        self.formatter = SafeFormatter()
        self.loaded_cogs = ["cogs.modmail", "cogs.plugins", "cogs.utility"]
        self._connected = asyncio.Event()
        self.start_time = datetime.utcnow()

        self.config = ConfigManager(self)
        self.config.populate_cache()

        self.threads = ThreadManager(self)

        self.log_file_name = os.path.join(temp_dir, f"{self.token.split('.')[0]}.log")
        self._configure_logging()

        mongo_uri = self.config["mongo_uri"]
        if mongo_uri is None:
            logger.critical("A Mongo URI is necessary for the bot to function.")
            raise RuntimeError

        try:
            self.db = AsyncIOMotorClient(mongo_uri).modmail_bot
        except ConfigurationError as e:
            logger.critical(
                "Your MONGO_URI might be copied wrong, try re-copying from the source again. "
                "Otherwise noted in the following message:"
            )
            logger.critical(e)
            sys.exit(0)

        self.plugin_db = PluginDatabaseClient(self)
        self.startup()
Exemplo n.º 2
0
 def __init__(self):
     super().__init__(command_prefix=self.get_pre)
     self.version = __version__
     self.start_time = datetime.datetime.utcnow()
     self.threads = ThreadManager(self)
     self.session = aiohttp.ClientSession(loop=self.loop)
     self.config = ConfigManager(self)
     self.modmail_api = ModmailApiClient(self)
     self.data_task = self.loop.create_task(self.data_loop())
     self.autoupdate_task = self.loop.create_task(self.autoupdate_loop())
     self._add_commands()
Exemplo n.º 3
0
 def __init__(self):
     super().__init__(command_prefix=self.get_pre)
     self.version = __version__
     self.start_time = datetime.datetime.utcnow()
     self.threads = ThreadManager(self)
     self.session = aiohttp.ClientSession(loop=self.loop)
     self.config = ConfigManager(self)
     self.selfhosted = bool(self.config.get('mongo_uri'))
     if self.selfhosted:
         self.db = AsyncIOMotorClient(self.config.mongo_uri).modmail_bot
     self.modmail_api = SelfhostedClient(self) if self.selfhosted else ModmailApiClient(self)
     self.data_task = self.loop.create_task(self.data_loop())
     self.autoupdate_task = self.loop.create_task(self.autoupdate_loop())
     self._add_commands()
Exemplo n.º 4
0
    def __init__(self):
        super().__init__(command_prefix=None)  # implemented in `get_prefix`
        self._session = None
        self._api = None
        self.metadata_loop = None
        self.formatter = SafeFormatter()

        self._connected = asyncio.Event()
        self.start_time = datetime.utcnow()

        self.config = ConfigManager(self)
        self.config.populate_cache()

        self.threads = ThreadManager(self)

        self._configure_logging()

        mongo_uri = self.config["mongo_uri"]
        if mongo_uri is None:
            logger.critical(
                "A Mongo URI is necessary for the bot to function.")
            raise RuntimeError

        try:
            self.db = AsyncIOMotorClient(mongo_uri).modmail_bot
        except ConfigurationError as e:
            logger.critical(
                "Your MONGO_URI might be copied wrong, try re-copying from the source again. "
                "Otherwise noted in the following message:")
            logger.critical(str(e))
            sys.exit(0)

        self.plugin_db = PluginDatabaseClient(self)

        logger.line()
        logger.info("┌┬┐┌─┐┌┬┐┌┬┐┌─┐┬┬")
        logger.info("││││ │ │││││├─┤││")
        logger.info("┴ ┴└─┘─┴┘┴ ┴┴ ┴┴┴─┘")
        logger.info("v%s", __version__)
        logger.info("Author: OhlookitsVeld")
        logger.line()

        self._load_extensions()
        logger.line()
Exemplo n.º 5
0
    def __init__(self):
        super().__init__(command_prefix=None)  # implemented in `get_prefix`
        self._session = None
        self._api = None
        self.metadata_loop = None
        self.formatter = SafeFormatter()
        self.loaded_cogs = ["cogs.modmail", "cogs.plugins", "cogs.utility"]
        self._connected = asyncio.Event()
        self.start_time = datetime.utcnow()

        self.config = ConfigManager(self)
        self.config.populate_cache()

        self.threads = ThreadManager(self)

        self.log_file_name = os.path.join(temp_dir, f"{self.token.split('.')[0]}.log")
        self._configure_logging()

        self.plugin_db = PluginDatabaseClient(self)  # Deprecated
        self.startup()
Exemplo n.º 6
0
    def __init__(self, args):
        super(Main, self).__init__(None)
        self.logger = logging.getLogger(self.__class__.__name__)
        self.start_gui = not args.nogui

        self.gui = None
        self.builder = ClientBuilder()
        self.gui_server = GUIServer()
        self.c2server = C2Server()

        self.config_manager = ConfigManager()

        if args.reset:
            self.config_manager.delete_config()

        if args.remote:
            self.gui = MainWindow()
            self.gui.setup_connect_dialog()
        else:
            config = self.config_manager.load()
            if config:
                self.read_config_file(config)
            else:
                self.start_first_setup()
Exemplo n.º 7
0
    def __init__(self):
        super().__init__(command_prefix=None)  # implemented in `get_prefix`
        self._session = None
        self._api = None
        self.metadata_loop = None
        self.formatter = SafeFormatter()
        self.loaded_cogs = ["cogs.modmail", "cogs.plugin", "cogs.utilita"]
        self._connected = asyncio.Event()
        self.start_time = datetime.utcnow()

        self.config = ConfigManager(self)
        self.config.populate_cache()

        self.threads = ThreadManager(self)

        self.log_file_name = os.path.join(temp_dir,
                                          f"{self.token.split('.')[0]}.log")
        self._configure_logging()

        mongo_uri = self.config["mongo_uri"]
        if mongo_uri is None:
            logger.critical(
                "Un Mongo URI è necessario per il funzionamento del bot.")
            raise RuntimeError

        try:
            self.db = AsyncIOMotorClient(mongo_uri).modmail_bot
        except ConfigurationError as e:
            logger.critical(
                "Il tuo MONGO_URI potrebbe essere copiato male, prova a ri-copiarlo dalla sorgente. "
                "Otherwise noted in the following message:")
            logger.critical(e)
            sys.exit(0)

        self.plugin_db = PluginDatabaseClient(self)
        self.startup()
Exemplo n.º 8
0
 def config(self) -> ConfigManager:
     if self._config is None:
         self._config = ConfigManager(self)
     return self._config
Exemplo n.º 9
0
    exit(0)


def parse_options():
    if '-h' in sys.argv:
        usage()
    elif '-v' in sys.argv:
        version()
    try:
        opts, args = getopt.getopt(sys.argv[1:], "h:v")
    except getopt.GetoptError as e:
        om.error("Invalid parameter({})\n".format(str(e)))
        exit(1)
    return args


if __name__ == '__main__':
    os.chdir(os.path.dirname(os.path.abspath(__file__)))

    builtins.config = ConfigManager()
    builtins.om = OutputManager()
    builtins.em = ExploitsManager()

    banner()
    options = parse_options()

    manager = Manager()
    manager.run()

    exit(0)