A-0.1 - Modularer Aufbau #13
| @@ -1,7 +1,9 @@ | ||||
| from abc import ABC, abstractmethod | ||||
|  | ||||
| from discord.ext import commands | ||||
|  | ||||
| class BotServiceABC(ABC): | ||||
|  | ||||
| class BotServiceABC(ABC, commands.Bot): | ||||
|  | ||||
|     @abstractmethod | ||||
|     def __init__(self): pass | ||||
|   | ||||
| @@ -1,22 +1,40 @@ | ||||
| from datetime import datetime | ||||
|  | ||||
| from cpl_core.configuration.configuration_abc import ConfigurationABC | ||||
| from cpl_core.logging import LoggerABC | ||||
| from cpl_core.console import Console | ||||
| from cpl_core.logging import LoggerABC, LoggingLevelEnum | ||||
| from cpl_core.logging.logging_settings import LoggingSettings | ||||
|  | ||||
| from gismo_core.abc.bot_service_abc import BotServiceABC | ||||
| from modules_core.abc.module_abc import ModuleABC | ||||
| from modules_core.abc.module_service_abc import ModuleServiceABC | ||||
|  | ||||
|  | ||||
| class BootLog(ModuleABC): | ||||
|  | ||||
|     def __init__(self, config: ConfigurationABC, logger: LoggerABC): | ||||
|     def __init__(self, config: ConfigurationABC, logging_st: LoggingSettings, logger: LoggerABC, bot: BotServiceABC): | ||||
|         self._config = config | ||||
|         self._logging_st = logging_st | ||||
|         self._logger = logger | ||||
|         self._bot = bot | ||||
|         ModuleABC.__init__(self) | ||||
|  | ||||
|     async def on_ready(self): | ||||
|         self._logger.info(__name__, f'Bot started') | ||||
|         start_time = self._config.get_configuration('StartTime') | ||||
|         init_time = round((datetime.now() - start_time).total_seconds(), 2) | ||||
|         self._logger.debug(__name__, f'InitTime:  {init_time}s') | ||||
|         try: | ||||
|             start_time = self._config.get_configuration('StartTime') | ||||
|             init_time = round((datetime.now() - start_time).total_seconds(), 2) | ||||
|             self._logger.info(__name__, f'Init time:  {init_time}s') | ||||
|             # print warning if initialisation took too long | ||||
|             if init_time >= 30: | ||||
|                 self._logger.warn(__name__, 'It takes long time to start the bot!') | ||||
|              | ||||
|             # print error if initialisation took way too long | ||||
|             elif init_time >= 90: | ||||
|                 self._logger.error(__name__, 'It takes very long time to start the bot!!!') | ||||
|         except Exception as e: | ||||
|             self._logger.error(__name__, 'Init time calculation failed', e) | ||||
|             return | ||||
|          | ||||
|         self._logger.header(f'{self._bot.user.name}:') | ||||
|         if self._logging_st.console.value >= LoggingLevelEnum.INFO.value: | ||||
|             Console.banner(self._bot.user.name) | ||||
		Reference in New Issue
	
	Block a user