Added logic to load api after bot #70
This commit is contained in:
parent
f634ad552e
commit
90bfee23b4
@ -43,10 +43,9 @@ class Application(DiscordBotApplicationABC):
|
||||
async def main(self):
|
||||
try:
|
||||
self._logger.debug(__name__, f'Starting...')
|
||||
if self._feature_flags.get_flag(FeatureFlagsEnum.api_module):
|
||||
self._api.start()
|
||||
|
||||
if 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
|
||||
|
||||
|
@ -21,13 +21,13 @@ class ModuleList:
|
||||
return List(type, [
|
||||
CoreModule, # has to be first!
|
||||
DataModule,
|
||||
ApiModule,
|
||||
AdminModule,
|
||||
AutoRoleModule,
|
||||
BaseModule,
|
||||
DatabaseModule,
|
||||
ModeratorModule,
|
||||
PermissionModule,
|
||||
ApiModule,
|
||||
# has to be last!
|
||||
BootLogModule,
|
||||
CoreExtensionModule,
|
||||
|
@ -5,7 +5,7 @@ from cpl_core.database import TableABC
|
||||
from bot_api.abc.dto_abc import DtoABC
|
||||
|
||||
|
||||
class AuthUserTransformerABC:
|
||||
class TransformerABC:
|
||||
|
||||
@staticmethod
|
||||
@abstractmethod
|
@ -4,6 +4,7 @@ from cpl_core.configuration import ConfigurationABC
|
||||
from cpl_core.dependency_injection import ServiceCollectionABC
|
||||
from cpl_core.environment import ApplicationEnvironmentABC
|
||||
from cpl_core.mailing import EMailClientABC, EMailClient
|
||||
from cpl_discord.discord_event_types_enum import DiscordEventTypesEnum
|
||||
from cpl_discord.service.discord_collection_abc import DiscordCollectionABC
|
||||
from flask import Flask
|
||||
|
||||
@ -12,6 +13,7 @@ from bot_api.api import Api
|
||||
from bot_api.api_thread import ApiThread
|
||||
from bot_api.controller.gui_controller import GuiController
|
||||
from bot_api.controller.auth_controller import AuthController
|
||||
from bot_api.event.bot_api_on_ready_event import BotApiOnReadyEvent
|
||||
from bot_api.service.auth_service import AuthService
|
||||
from bot_core.abc.module_abc import ModuleABC
|
||||
from bot_core.configuration.feature_flags_enum import FeatureFlagsEnum
|
||||
@ -39,3 +41,6 @@ class ApiModule(ModuleABC):
|
||||
services.add_transient(AuthServiceABC, AuthService)
|
||||
services.add_transient(AuthController)
|
||||
services.add_transient(GuiController)
|
||||
|
||||
# cpl-discord
|
||||
self._dc.add_event(DiscordEventTypesEnum.on_ready.value, BotApiOnReadyEvent)
|
||||
|
13
kdb-bot/src/bot_api/event/bot_api_on_ready_event.py
Normal file
13
kdb-bot/src/bot_api/event/bot_api_on_ready_event.py
Normal file
@ -0,0 +1,13 @@
|
||||
from cpl_discord.events import OnReadyABC
|
||||
|
||||
from bot_api.api_thread import ApiThread
|
||||
|
||||
|
||||
class BotApiOnReadyEvent(OnReadyABC):
|
||||
|
||||
def __init__(self, api: ApiThread):
|
||||
OnReadyABC.__init__(self)
|
||||
self._api = api
|
||||
|
||||
async def on_ready(self):
|
||||
self._api.start()
|
@ -1,12 +1,12 @@
|
||||
from datetime import datetime, timezone
|
||||
|
||||
from bot_api.abc.auth_user_transformer_abc import AuthUserTransformerABC
|
||||
from bot_api.abc.transformer_abc import TransformerABC
|
||||
from bot_api.model.auth_user_dto import AuthUserDTO
|
||||
from bot_data.model.auth_role_enum import AuthRoleEnum
|
||||
from bot_data.model.auth_user import AuthUser
|
||||
|
||||
|
||||
class AuthUserTransformer(AuthUserTransformerABC):
|
||||
class AuthUserTransformer(TransformerABC):
|
||||
|
||||
@staticmethod
|
||||
def to_db(dto: AuthUser) -> AuthUser:
|
||||
|
Loading…
Reference in New Issue
Block a user