A-0.1 - Modularer Aufbau #13

Merged
edraft merged 118 commits from 0.1 into Alpha 2021-11-25 21:02:12 +01:00
2 changed files with 22 additions and 19 deletions
Showing only changes of commit a5f710177e - Show all commits

View File

@ -1,8 +1,9 @@
import discord import discord
from discord.ext import commands
from cpl_core.configuration import ConfigurationABC from cpl_core.configuration import ConfigurationABC
from cpl_core.logging import LoggerABC from cpl_core.console import Console
from cpl_core.environment import ApplicationEnvironmentABC
from cpl_core.logging import LoggerABC, LoggingLevelEnum, LoggingSettings
from discord.ext import commands
from gismo_core.abc.bot_service_abc import BotServiceABC from gismo_core.abc.bot_service_abc import BotServiceABC
from gismo_core.configuration.bot_settings import BotSettings from gismo_core.configuration.bot_settings import BotSettings
from gismo_core.configuration.discord_settings import DiscordSettings from gismo_core.configuration.discord_settings import DiscordSettings
@ -13,11 +14,22 @@ from modules_core.service.module_service import ModuleService
class BotService(BotServiceABC, commands.Bot): class BotService(BotServiceABC, commands.Bot):
def __init__(self, config: ConfigurationABC, logger: LoggerABC, modules: ModuleService, discord_settings: DiscordSettings, bot_settings: BotSettings): def __init__(
self,
config: ConfigurationABC,
logger: LoggerABC,
modules: ModuleService,
discord_settings: DiscordSettings,
bot_settings: BotSettings,
env: ApplicationEnvironmentABC,
logging_st: LoggingSettings,
):
# services # services
self._config = config self._config = config
self._logger = logger self._logger = logger
self._modules = modules self._modules = modules
self._env = env
self._logging_st = logging_st
# settings # settings
self._discord_settings = discord_settings self._discord_settings = discord_settings
@ -52,5 +64,8 @@ class BotService(BotServiceABC, commands.Bot):
self._config.add_configuration(f'DSERVER_{server.id}', server) self._config.add_configuration(f'DSERVER_{server.id}', server)
self._logger.trace(__name__, f'Loaded config for server: {server.id}') self._logger.trace(__name__, f'Loaded config for server: {server.id}')
self._logger.header(f'{self.user.name}:')
if self._logging_st.console.value >= LoggingLevelEnum.INFO.value:
Console.banner(self._env.application_name if self._env.application_name != '' else 'Gismo')
await self._modules.on_ready() await self._modules.on_ready()

View File

@ -1,17 +1,13 @@
from datetime import datetime from datetime import datetime
import discord
from discord import guild
from async_timeout import asyncio
from cpl_core.configuration import ConfigurationABC from cpl_core.configuration import ConfigurationABC
from cpl_core.console import Console from cpl_core.logging import LoggerABC
from cpl_core.environment import ApplicationEnvironmentABC from discord import guild
from cpl_core.logging import LoggerABC, LoggingLevelEnum, LoggingSettings
from gismo_core.abc.bot_service_abc import BotServiceABC from gismo_core.abc.bot_service_abc import BotServiceABC
from gismo_core.abc.message_service_abc import MessageServiceABC from gismo_core.abc.message_service_abc import MessageServiceABC
from gismo_core.configuration.server_settings import ServerSettings from gismo_core.configuration.server_settings import ServerSettings
from modules_core.abc.module_abc import ModuleABC
from modules_core.abc.events.on_ready_abc import OnReadyABC from modules_core.abc.events.on_ready_abc import OnReadyABC
from modules_core.abc.module_abc import ModuleABC
class BootLog(ModuleABC, OnReadyABC): class BootLog(ModuleABC, OnReadyABC):
@ -19,15 +15,11 @@ class BootLog(ModuleABC, OnReadyABC):
def __init__( def __init__(
self, self,
config: ConfigurationABC, config: ConfigurationABC,
env: ApplicationEnvironmentABC,
logging_st: LoggingSettings,
logger: LoggerABC, logger: LoggerABC,
bot: BotServiceABC, bot: BotServiceABC,
message_service: MessageServiceABC message_service: MessageServiceABC
): ):
self._config = config self._config = config
self._env = env
self._logging_st = logging_st
self._logger = logger self._logger = logger
self._bot = bot self._bot = bot
@ -62,10 +54,6 @@ class BootLog(ModuleABC, OnReadyABC):
self._logger.error(__name__, 'Init time calculation failed', e) self._logger.error(__name__, 'Init time calculation failed', e)
return return
self._logger.header(f'{self._bot.user.name}:')
if self._logging_st.console.value >= LoggingLevelEnum.INFO.value:
Console.banner(self._env.application_name if self._env.application_name != '' else 'Gismo')
for g in self._bot.guilds: for g in self._bot.guilds:
g: guild = g g: guild = g
self._logger.debug(__name__, f'Server detected: {g.id}') self._logger.debug(__name__, f'Server detected: {g.id}')