Formatted files with black
This commit is contained in:
@@ -13,7 +13,6 @@ from bot_core.configuration.feature_flags_settings import FeatureFlagsSettings
|
||||
|
||||
|
||||
class Application(DiscordBotApplicationABC):
|
||||
|
||||
def __init__(self, config: ConfigurationABC, services: ServiceProviderABC):
|
||||
DiscordBotApplicationABC.__init__(self, config, services)
|
||||
|
||||
@@ -24,12 +23,18 @@ class Application(DiscordBotApplicationABC):
|
||||
self._logger: LoggerABC = services.get_service(LoggerABC)
|
||||
# cpl-discord
|
||||
self._bot: DiscordBotServiceABC = services.get_service(DiscordBotServiceABC)
|
||||
self._bot_settings: DiscordBotSettings = config.get_configuration(DiscordBotSettings)
|
||||
self._bot_settings: DiscordBotSettings = config.get_configuration(
|
||||
DiscordBotSettings
|
||||
)
|
||||
# cpl-translation
|
||||
self._translation: TranslationServiceABC = services.get_service(TranslationServiceABC)
|
||||
self._translation: TranslationServiceABC = services.get_service(
|
||||
TranslationServiceABC
|
||||
)
|
||||
self._t: TranslatePipe = services.get_service(TranslatePipe)
|
||||
|
||||
self._feature_flags: FeatureFlagsSettings = config.get_configuration(FeatureFlagsSettings)
|
||||
self._feature_flags: FeatureFlagsSettings = config.get_configuration(
|
||||
FeatureFlagsSettings
|
||||
)
|
||||
|
||||
# api
|
||||
if self._feature_flags.get_flag(FeatureFlagsEnum.api_module):
|
||||
@@ -38,24 +43,28 @@ class Application(DiscordBotApplicationABC):
|
||||
self._is_stopping = False
|
||||
|
||||
async def configure(self):
|
||||
self._translation.load_by_settings(self._configuration.get_configuration(TranslationSettings))
|
||||
self._translation.load_by_settings(
|
||||
self._configuration.get_configuration(TranslationSettings)
|
||||
)
|
||||
|
||||
async def main(self):
|
||||
try:
|
||||
self._logger.debug(__name__, f'Starting...')
|
||||
self._logger.debug(__name__, f"Starting...")
|
||||
|
||||
if self._feature_flags.get_flag(FeatureFlagsEnum.api_module) and \
|
||||
self._feature_flags.get_flag(FeatureFlagsEnum.api_only) and \
|
||||
self._environment.environment_name == 'development':
|
||||
if (
|
||||
self._feature_flags.get_flag(FeatureFlagsEnum.api_module)
|
||||
and self._feature_flags.get_flag(FeatureFlagsEnum.api_only)
|
||||
and self._environment.environment_name == "development"
|
||||
):
|
||||
self._api.start()
|
||||
self._api.join()
|
||||
return
|
||||
|
||||
self._logger.trace(__name__, f'Try to start {DiscordBotService.__name__}')
|
||||
self._logger.trace(__name__, f"Try to start {DiscordBotService.__name__}")
|
||||
await self._bot.start_async()
|
||||
await self._bot.stop_async()
|
||||
except Exception as e:
|
||||
self._logger.error(__name__, 'Start failed', e)
|
||||
self._logger.error(__name__, "Start failed", e)
|
||||
|
||||
async def stop_async(self):
|
||||
if self._is_stopping:
|
||||
@@ -63,13 +72,17 @@ class Application(DiscordBotApplicationABC):
|
||||
|
||||
self._is_stopping = True
|
||||
try:
|
||||
self._logger.trace(__name__, f'Try to stop {DiscordBotService.__name__}')
|
||||
self._logger.trace(__name__, f"Try to stop {DiscordBotService.__name__}")
|
||||
await self._bot.close()
|
||||
self._logger.trace(__name__, f'Stopped {DiscordBotService.__name__}')
|
||||
self._logger.trace(__name__, f"Stopped {DiscordBotService.__name__}")
|
||||
except Exception as e:
|
||||
self._logger.error(__name__, 'stop failed', e)
|
||||
self._logger.error(__name__, "stop failed", e)
|
||||
|
||||
Console.write_line()
|
||||
|
||||
def is_restart(self):
|
||||
return True if self._configuration.get_configuration('IS_RESTART') == 'true' else False #
|
||||
return (
|
||||
True
|
||||
if self._configuration.get_configuration("IS_RESTART") == "true"
|
||||
else False
|
||||
) #
|
||||
|
Reference in New Issue
Block a user