Improved module, event and settings loading

This commit is contained in:
2022-01-15 11:47:59 +01:00
parent 9eef94baf2
commit 234a9a382a
10 changed files with 91 additions and 61 deletions

View File

@@ -5,6 +5,9 @@ from cpl_core.dependency_injection import ServiceProviderABC
from cpl_core.logging import LoggerABC
from gismo_core.abc.bot_service_abc import BotServiceABC
from gismo_core.abc.module_service_abc import ModuleServiceABC
from gismo_core.configuration.bot_settings import BotSettings
from gismo_core.configuration.server_settings import ServerSettings
from gismo_core.service.bot_service import BotService
from gismo_data.service.migration_service import MigrationService
@@ -16,14 +19,18 @@ class Gismo(ApplicationABC):
self._bot: BotService = services.get_service(BotServiceABC)
self._logger: LoggerABC = services.get_service(LoggerABC)
self._migrations: MigrationService = services.get_service(MigrationService)
self._bot_settings: BotSettings = config.get_configuration(BotSettings)
async def configure(self):
pass
self._logger.debug(__name__, 'Try to load discord server configs')
for server in self._bot_settings.servers:
server: ServerSettings = server
self._logger.trace(__name__, f'Try to load config for server: {server.id}')
self._configuration.add_configuration(f'DSERVER_{server.id}', server)
self._logger.trace(__name__, f'Loaded config for server: {server.id}')
async def main(self):
try:
self._migrations.migrate()
self._logger.trace(__name__, f'Try to start {BotService}')
await self._bot.start_async()
except Exception as e: