From 1c3ec3c7e77a1f661c5d41d0513e1630ab2dc71f Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Mon, 3 Oct 2022 12:42:42 +0200 Subject: [PATCH 1/3] Added presence #56 --- src/bot/application.py | 16 +---- src/bot/bot.json | 2 +- src/bot/config/appsettings.development.json | 3 +- .../config/appsettings.edrafts-pc-ubuntu.json | 3 +- src/bot/config/appsettings.production.json | 3 +- src/bot/config/appsettings.staging.json | 3 +- src/bot/module_list.py | 29 ++++++++++ src/bot/startup.py | 58 +------------------ src/bot/startup_module_extension.py | 17 +----- src/bot/translation/de.json | 6 ++ src/bot_core/abc/client_utils_service_abc.py | 3 + src/bot_core/configuration/bot_settings.py | 15 +++-- src/bot_core/core_extension/__init__.py | 0 .../core_extension/core_extension_module.py | 20 +++++++ .../core_extension_on_ready_event.py | 32 ++++++++++ src/bot_core/core_module.py | 46 +++++++++++++++ src/bot_core/events/__init__.py | 0 src/bot_core/events/core_on_ready_event.py | 32 ++++++++++ src/bot_core/service/client_utils_service.py | 7 +++ src/bot_data/data_module.py | 35 +++++++++++ src/modules/admin/admin_module.py | 2 +- src/modules/admin/command/restart_command.py | 8 +++ src/modules/admin/command/shutdown_command.py | 8 +++ src/modules/base/base_module.py | 5 +- src/modules/base/command/info_command.py | 4 +- src/modules/boot_log/boot_log_module.py | 2 +- src/modules/database/database_module.py | 2 +- src/modules/moderator/moderator_module.py | 2 +- src/modules/permission/permission_module.py | 5 +- 29 files changed, 266 insertions(+), 102 deletions(-) create mode 100644 src/bot/module_list.py create mode 100644 src/bot_core/core_extension/__init__.py create mode 100644 src/bot_core/core_extension/core_extension_module.py create mode 100644 src/bot_core/core_extension/core_extension_on_ready_event.py create mode 100644 src/bot_core/core_module.py create mode 100644 src/bot_core/events/__init__.py create mode 100644 src/bot_core/events/core_on_ready_event.py create mode 100644 src/bot_data/data_module.py diff --git a/src/bot/application.py b/src/bot/application.py index aec07e03..14ce439d 100644 --- a/src/bot/application.py +++ b/src/bot/application.py @@ -1,5 +1,3 @@ -from typing import Optional, Type, Callable - from cpl_core.configuration import ConfigurationABC from cpl_core.console import Console from cpl_core.dependency_injection import ServiceProviderABC @@ -9,14 +7,6 @@ from cpl_discord.configuration import DiscordBotSettings from cpl_discord.service import DiscordBotServiceABC, DiscordBotService from cpl_translation import TranslatePipe, TranslationServiceABC, TranslationSettings -from bot_core.configuration.bot_logging_settings import BotLoggingSettings -from bot_core.configuration.bot_settings import BotSettings -from bot_core.logging.command_logger import CommandLogger -from bot_core.logging.database_logger import DatabaseLogger -from modules.base.configuration.base_settings import BaseSettings -from modules.boot_log.configuration.boot_log_settings import BootLogSettings -from modules.permission.configuration.permission_settings import PermissionSettings - class Application(DiscordBotApplicationABC): @@ -32,7 +22,7 @@ class Application(DiscordBotApplicationABC): self._bot_settings: DiscordBotSettings = config.get_configuration(DiscordBotSettings) # cpl-translation self._translation: TranslationServiceABC = services.get_service(TranslationServiceABC) - self._translate: TranslatePipe = services.get_service(TranslatePipe) + self._t: TranslatePipe = services.get_service(TranslatePipe) self._is_stopping = False @@ -41,7 +31,7 @@ class Application(DiscordBotApplicationABC): async def main(self): try: - self._logger.debug(__name__, f'Starting...\n') + self._logger.debug(__name__, f'Starting...') self._logger.trace(__name__, f'Try to start {DiscordBotService.__name__}') await self._bot.start_async() await self._bot.stop_async() @@ -63,4 +53,4 @@ class Application(DiscordBotApplicationABC): 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# diff --git a/src/bot/bot.json b/src/bot/bot.json index 1ebf34f1..9554e15c 100644 --- a/src/bot/bot.json +++ b/src/bot/bot.json @@ -4,7 +4,7 @@ "Version": { "Major": "0", "Minor": "2", - "Micro": "0" + "Micro": "1" }, "Author": "Sven Heidemann", "AuthorEmail": "sven.heidemann@sh-edraft.de", diff --git a/src/bot/config/appsettings.development.json b/src/bot/config/appsettings.development.json index 3278dcd7..1b3dfa6d 100644 --- a/src/bot/config/appsettings.development.json +++ b/src/bot/config/appsettings.development.json @@ -57,7 +57,8 @@ 240160344557879316, 236592458664902657 ], - "DeployFilesPath": "../../deploy" + "WaitForRestart": 4, + "WaitForShutdown": 4 }, "Base": { "910199451145076828": { diff --git a/src/bot/config/appsettings.edrafts-pc-ubuntu.json b/src/bot/config/appsettings.edrafts-pc-ubuntu.json index 7afbf20d..62c82eaa 100644 --- a/src/bot/config/appsettings.edrafts-pc-ubuntu.json +++ b/src/bot/config/appsettings.edrafts-pc-ubuntu.json @@ -54,7 +54,8 @@ "Technicians": [ 240160344557879316 ], - "DeployFilesPath": "../../deploy" + "WaitForRestart": 4, + "WaitForShutdown": 4 }, "Base": { "910199451145076828": { diff --git a/src/bot/config/appsettings.production.json b/src/bot/config/appsettings.production.json index 4ee87356..8b195269 100644 --- a/src/bot/config/appsettings.production.json +++ b/src/bot/config/appsettings.production.json @@ -67,7 +67,8 @@ 240160344557879316, 236592458664902657 ], - "DeployFilesPath": "../../" + "WaitForRestart": 4, + "WaitForShutdown": 4 }, "Base": { "650366049023295514": { diff --git a/src/bot/config/appsettings.staging.json b/src/bot/config/appsettings.staging.json index 72fb76c1..7ccbbcb8 100644 --- a/src/bot/config/appsettings.staging.json +++ b/src/bot/config/appsettings.staging.json @@ -64,7 +64,8 @@ 240160344557879316, 236592458664902657 ], - "DeployFilesPath": "../../" + "WaitForRestart": 4, + "WaitForShutdown": 4 }, "Base": { "910199451145076828": { diff --git a/src/bot/module_list.py b/src/bot/module_list.py new file mode 100644 index 00000000..f7690033 --- /dev/null +++ b/src/bot/module_list.py @@ -0,0 +1,29 @@ +from cpl_query.extension import List + +from bot_core.core_extension.core_extension_module import CoreExtensionModule +from bot_core.core_module import CoreModule +from bot_data.data_module import DataModule +from modules.admin.admin_module import AdminModule +from modules.base.base_module import BaseModule +from modules.boot_log.boot_log_module import BootLogModule +from modules.database.database_module import DatabaseModule +from modules.moderator.moderator_module import ModeratorModule +from modules.permission.permission_module import PermissionModule + + +class ModuleList: + + @staticmethod + def get_modules(): + # core modules (modules out of modules folder) should be loaded first! + return List(type, [ + CoreModule, # has to be first! + DataModule, + AdminModule, + BaseModule, + DatabaseModule, + ModeratorModule, + PermissionModule, + CoreExtensionModule, + BootLogModule # has to be last! + ]) diff --git a/src/bot/startup.py b/src/bot/startup.py index 55df0788..6a1fa559 100644 --- a/src/bot/startup.py +++ b/src/bot/startup.py @@ -1,4 +1,3 @@ -import os from datetime import datetime from typing import Optional @@ -7,35 +6,8 @@ from cpl_core.configuration import ConfigurationABC from cpl_core.database import DatabaseSettings from cpl_core.dependency_injection import ServiceProviderABC, ServiceCollectionABC from cpl_core.environment import ApplicationEnvironment -from cpl_core.logging import LoggerABC -from cpl_discord import get_discord_collection -from bot_core.abc.client_utils_service_abc import ClientUtilsServiceABC -from bot_core.abc.custom_file_logger_abc import CustomFileLoggerABC -from bot_core.abc.message_service_abc import MessageServiceABC -from bot_core.logging.command_logger import CommandLogger -from bot_core.logging.database_logger import DatabaseLogger -from bot_core.logging.message_logger import MessageLogger -from bot_core.pipes.date_time_offset_pipe import DateTimeOffsetPipe -from bot_core.service.client_utils_service import ClientUtilsService -from bot_core.service.message_service import MessageService -from bot_data.abc.client_repository_abc import ClientRepositoryABC -from bot_data.abc.known_user_repository_abc import KnownUserRepositoryABC -from bot_data.abc.server_repository_abc import ServerRepositoryABC -from bot_data.abc.user_joined_server_repository_abc import UserJoinedServerRepositoryABC -from bot_data.abc.user_joined_voice_channel_abc import UserJoinedVoiceChannelRepositoryABC -from bot_data.abc.user_repository_abc import UserRepositoryABC from bot_data.db_context import DBContext -from bot_data.service.client_repository_service import ClientRepositoryService -from bot_data.service.known_user_repository_service import KnownUserRepositoryService -from bot_data.service.server_repository_service import ServerRepositoryService -from bot_data.service.user_joined_server_repository_service import UserJoinedServerRepositoryService -from bot_data.service.user_joined_voice_channel_service import UserJoinedVoiceChannelRepositoryService -from bot_data.service.user_repository_service import UserRepositoryService -from modules.base.abc.base_helper_abc import BaseHelperABC -from modules.base.service.base_helper_service import BaseHelperService -from modules.permission.abc.permission_service_abc import PermissionServiceABC -from modules.permission.service.permission_service import PermissionService class Startup(StartupABC): @@ -52,36 +24,8 @@ class Startup(StartupABC): def configure_services(self, services: ServiceCollectionABC, environment: ApplicationEnvironment) -> ServiceProviderABC: services.add_logging() - # custom logging - services.add_singleton(LoggerABC, CommandLogger) - services.add_singleton(LoggerABC, DatabaseLogger) - services.add_singleton(LoggerABC, MessageLogger) services.add_translation() services.add_db_context(DBContext, self._config.get_configuration(DatabaseSettings)) - # general services - services.add_transient(BaseHelperABC, BaseHelperService) - services.add_transient(MessageServiceABC, MessageService) - services.add_transient(ClientUtilsServiceABC, ClientUtilsService) - - # pipes - services.add_transient(DateTimeOffsetPipe) - - # module services - services.add_singleton(PermissionServiceABC, PermissionService) - - # data services - services.add_transient(ServerRepositoryABC, ServerRepositoryService) - services.add_transient(UserRepositoryABC, UserRepositoryService) - services.add_transient(ClientRepositoryABC, ClientRepositoryService) - services.add_transient(KnownUserRepositoryABC, KnownUserRepositoryService) - services.add_transient(UserJoinedServerRepositoryABC, UserJoinedServerRepositoryService) - services.add_transient(UserJoinedVoiceChannelRepositoryABC, UserJoinedVoiceChannelRepositoryService) - - provider = services.build_service_provider() - # instantiate custom logger - for c in CustomFileLoggerABC.__subclasses__(): - i: LoggerABC = provider.get_service(c) - - return provider + return services.build_service_provider() diff --git a/src/bot/startup_module_extension.py b/src/bot/startup_module_extension.py index c93ff29c..2bf73699 100644 --- a/src/bot/startup_module_extension.py +++ b/src/bot/startup_module_extension.py @@ -6,15 +6,9 @@ from cpl_core.console import Console, ForegroundColorEnum from cpl_core.dependency_injection import ServiceCollectionABC from cpl_core.environment import ApplicationEnvironmentABC from cpl_discord.service.discord_collection_abc import DiscordCollectionABC -from cpl_query.extension import List +from bot.module_list import ModuleList from bot_core.configuration.feature_flags_settings import FeatureFlagsSettings -from modules.admin.admin_module import AdminModule -from modules.base.base_module import BaseModule -from modules.boot_log.boot_log_module import BootLogModule -from modules.database.database_module import DatabaseModule -from modules.moderator.moderator_module import ModeratorModule -from modules.permission.permission_module import PermissionModule class StartupModuleExtension(StartupExtensionABC): @@ -23,14 +17,7 @@ class StartupModuleExtension(StartupExtensionABC): self._config: Optional[ConfigurationABC] = None self._feature_flags: Optional[FeatureFlagsSettings] = None - self._modules = List(type, [ - AdminModule, - BaseModule, - DatabaseModule, - ModeratorModule, - PermissionModule, - BootLogModule # has to be last! - ]) + self._modules = ModuleList.get_modules() def configure_configuration(self, config: ConfigurationABC, env: ApplicationEnvironmentABC): self._config = config diff --git a/src/bot/translation/de.json b/src/bot/translation/de.json index 655d5d67..02da2823 100644 --- a/src/bot/translation/de.json +++ b/src/bot/translation/de.json @@ -4,6 +4,12 @@ "bot_has_no_permission_message": "Ey!!!\nWas soll das?\nIch habe keine Berechtigungen :(\nScheiß System...", "no_permission_message": "Nein!\nIch höre nicht auf dich ¯\\_(ツ)_/¯", "not_implemented_yet": "Ey Alter, das kann ich noch nicht...", + "presence": { + "booting": "{} Ich fahre gerade hoch...", + "running": "{} Behalte Ruhe und iss Kekse :D", + "restart": "{} Muss neue Kekse holen...", + "shutdown": "{} Ich werde bestimmt wieder kommen..." + }, "errors": { "error": "Es gab einen Fehler. Meld dich bitte bei einem Admin.", "command_error": "Es gab einen Fehler beim bearbeiten des Befehls. Meld dich bitte bei einem Admin.", diff --git a/src/bot_core/abc/client_utils_service_abc.py b/src/bot_core/abc/client_utils_service_abc.py index 570e0431..0345ba36 100644 --- a/src/bot_core/abc/client_utils_service_abc.py +++ b/src/bot_core/abc/client_utils_service_abc.py @@ -19,3 +19,6 @@ class ClientUtilsServiceABC(ABC): @abstractmethod async def check_if_bot_is_ready_yet_and_respond(self, ctx: Context) -> bool: pass + + @abstractmethod + async def presence_game(self, t_key: str): pass diff --git a/src/bot_core/configuration/bot_settings.py b/src/bot_core/configuration/bot_settings.py index 21036f49..fbac1dfc 100644 --- a/src/bot_core/configuration/bot_settings.py +++ b/src/bot_core/configuration/bot_settings.py @@ -14,7 +14,6 @@ class BotSettings(ConfigurationModelABC): self._servers: List[ServerSettings] = List(ServerSettings) self._technicians: List[int] = List(int) - self._deploy_file_path = './' self._wait_for_restart = 2 self._wait_for_shutdown = 2 @@ -27,15 +26,21 @@ class BotSettings(ConfigurationModelABC): return self._technicians @property - def deploy_file_path(self) -> str: - return self._deploy_file_path + def wait_for_restart(self) -> int: + return self._wait_for_restart + + @property + def wait_for_shutdown(self) -> int: + return self._wait_for_shutdown def from_dict(self, settings: dict): try: self._technicians = settings["Technicians"] - self._deploy_file_path = settings["DeployFilesPath"] + self._wait_for_restart = settings["WaitForRestart"] + self._wait_for_shutdown = settings["WaitForShutdown"] settings.pop("Technicians") - settings.pop("DeployFilesPath") + settings.pop("WaitForRestart") + settings.pop("WaitForShutdown") servers = List(ServerSettings) for s in settings: st = ServerSettings() diff --git a/src/bot_core/core_extension/__init__.py b/src/bot_core/core_extension/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/src/bot_core/core_extension/core_extension_module.py b/src/bot_core/core_extension/core_extension_module.py new file mode 100644 index 00000000..198e0b33 --- /dev/null +++ b/src/bot_core/core_extension/core_extension_module.py @@ -0,0 +1,20 @@ +from cpl_core.configuration import ConfigurationABC +from cpl_core.dependency_injection import ServiceCollectionABC +from cpl_core.environment import ApplicationEnvironmentABC +from cpl_discord.discord_event_types_enum import DiscordEventTypesEnum +from cpl_discord.service.discord_collection_abc import DiscordCollectionABC + +from bot_core.abc.module_abc import ModuleABC +from bot_core.core_extension.core_extension_on_ready_event import CoreExtensionOnReadyEvent + + +class CoreExtensionModule(ModuleABC): + + def __init__(self, dc: DiscordCollectionABC): + ModuleABC.__init__(self, dc, lambda x: x.base_module) + + def configure_configuration(self, config: ConfigurationABC, env: ApplicationEnvironmentABC): + pass + + def configure_services(self, services: ServiceCollectionABC, env: ApplicationEnvironmentABC): + self._dc.add_event(DiscordEventTypesEnum.on_ready.value, CoreExtensionOnReadyEvent) diff --git a/src/bot_core/core_extension/core_extension_on_ready_event.py b/src/bot_core/core_extension/core_extension_on_ready_event.py new file mode 100644 index 00000000..fd1f42c6 --- /dev/null +++ b/src/bot_core/core_extension/core_extension_on_ready_event.py @@ -0,0 +1,32 @@ +import asyncio + +from cpl_core.logging import LoggerABC +from cpl_discord.events import OnReadyABC +from cpl_discord.service import DiscordBotServiceABC +from cpl_translation import TranslatePipe + +from bot_core.abc.client_utils_service_abc import ClientUtilsServiceABC + + +class CoreExtensionOnReadyEvent(OnReadyABC): + + def __init__( + self, + logger: LoggerABC, + bot: DiscordBotServiceABC, + client_utils: ClientUtilsServiceABC, + t: TranslatePipe + ): + OnReadyABC.__init__(self) + + self._logger = logger + self._bot = bot + self._client_utils = client_utils + self._t = t + + self._logger.info(__name__, f'Module {type(self)} loaded') + + async def on_ready(self): + self._logger.debug(__name__, f'Module {type(self)} started') + await self._client_utils.presence_game('common.presence.running') + self._logger.trace(__name__, f'Module {type(self)} stopped') diff --git a/src/bot_core/core_module.py b/src/bot_core/core_module.py new file mode 100644 index 00000000..f8320d6b --- /dev/null +++ b/src/bot_core/core_module.py @@ -0,0 +1,46 @@ +from cpl_core.configuration import ConfigurationABC +from cpl_core.dependency_injection import ServiceCollectionABC +from cpl_core.environment import ApplicationEnvironmentABC +from cpl_core.logging import LoggerABC +from cpl_discord.discord_event_types_enum import DiscordEventTypesEnum +from cpl_discord.service.discord_collection_abc import DiscordCollectionABC + +from bot_core.abc.client_utils_service_abc import ClientUtilsServiceABC +from bot_core.abc.custom_file_logger_abc import CustomFileLoggerABC +from bot_core.abc.message_service_abc import MessageServiceABC +from bot_core.abc.module_abc import ModuleABC +from bot_core.events.core_on_ready_event import CoreOnReadyEvent +from bot_core.logging.command_logger import CommandLogger +from bot_core.logging.database_logger import DatabaseLogger +from bot_core.logging.message_logger import MessageLogger +from bot_core.pipes.date_time_offset_pipe import DateTimeOffsetPipe +from bot_core.service.client_utils_service import ClientUtilsService +from bot_core.service.message_service import MessageService + + +class CoreModule(ModuleABC): + + def __init__(self, dc: DiscordCollectionABC): + ModuleABC.__init__(self, dc, lambda x: x.base_module) + + def configure_configuration(self, config: ConfigurationABC, env: ApplicationEnvironmentABC): + pass + + def configure_services(self, services: ServiceCollectionABC, env: ApplicationEnvironmentABC): + # custom logging + services.add_singleton(CustomFileLoggerABC, CommandLogger) + services.add_singleton(CustomFileLoggerABC, DatabaseLogger) + services.add_singleton(CustomFileLoggerABC, MessageLogger) + + services.add_transient(MessageServiceABC, MessageService) + services.add_transient(ClientUtilsServiceABC, ClientUtilsService) + + # pipes + services.add_transient(DateTimeOffsetPipe) + + self._dc.add_event(DiscordEventTypesEnum.on_ready.value, CoreOnReadyEvent) + + provider = services.build_service_provider() + # instantiate custom logger + for c in CustomFileLoggerABC.__subclasses__(): + i: LoggerABC = provider.get_service(c) diff --git a/src/bot_core/events/__init__.py b/src/bot_core/events/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/src/bot_core/events/core_on_ready_event.py b/src/bot_core/events/core_on_ready_event.py new file mode 100644 index 00000000..f438884f --- /dev/null +++ b/src/bot_core/events/core_on_ready_event.py @@ -0,0 +1,32 @@ +import asyncio + +from cpl_core.logging import LoggerABC +from cpl_discord.events import OnReadyABC +from cpl_discord.service import DiscordBotServiceABC +from cpl_translation import TranslatePipe + +from bot_core.abc.client_utils_service_abc import ClientUtilsServiceABC + + +class CoreOnReadyEvent(OnReadyABC): + + def __init__( + self, + logger: LoggerABC, + bot: DiscordBotServiceABC, + client_utils: ClientUtilsServiceABC, + t: TranslatePipe + ): + OnReadyABC.__init__(self) + + self._logger = logger + self._bot = bot + self._client_utils = client_utils + self._t = t + + self._logger.info(__name__, f'Module {type(self)} loaded') + + async def on_ready(self): + self._logger.debug(__name__, f'Module {type(self)} started') + await self._client_utils.presence_game('common.presence.booting') + self._logger.trace(__name__, f'Module {type(self)} stopped') diff --git a/src/bot_core/service/client_utils_service.py b/src/bot_core/service/client_utils_service.py index 1a0d9d79..2adfb289 100644 --- a/src/bot_core/service/client_utils_service.py +++ b/src/bot_core/service/client_utils_service.py @@ -1,3 +1,4 @@ +import discord from cpl_core.configuration import ConfigurationABC from cpl_core.database.context import DatabaseContextABC from cpl_core.logging import LoggerABC @@ -61,3 +62,9 @@ class ClientUtilsService(ClientUtilsServiceABC): self._logger.debug(__name__, f'Bot is not ready yet {self._t.transform("common.errors.bot_not_ready_yet")}') await self._message_service.send_ctx_msg(ctx, self._t.transform('common.errors.bot_not_ready_yet'), without_tracking=True) return False + + async def presence_game(self, t_key: str): + import bot + name = self._t.transform(t_key).format(bot.__version__) + await self._bot.change_presence(activity=discord.Game(name=name)) + self._logger.info(__name__, f'Set presence {name}') diff --git a/src/bot_data/data_module.py b/src/bot_data/data_module.py new file mode 100644 index 00000000..cbceaa4e --- /dev/null +++ b/src/bot_data/data_module.py @@ -0,0 +1,35 @@ +from cpl_core.configuration import ConfigurationABC +from cpl_core.dependency_injection import ServiceCollectionABC +from cpl_core.environment import ApplicationEnvironmentABC +from cpl_discord.service.discord_collection_abc import DiscordCollectionABC + +from bot_core.abc.module_abc import ModuleABC +from bot_data.abc.client_repository_abc import ClientRepositoryABC +from bot_data.abc.known_user_repository_abc import KnownUserRepositoryABC +from bot_data.abc.server_repository_abc import ServerRepositoryABC +from bot_data.abc.user_joined_server_repository_abc import UserJoinedServerRepositoryABC +from bot_data.abc.user_joined_voice_channel_abc import UserJoinedVoiceChannelRepositoryABC +from bot_data.abc.user_repository_abc import UserRepositoryABC +from bot_data.service.client_repository_service import ClientRepositoryService +from bot_data.service.known_user_repository_service import KnownUserRepositoryService +from bot_data.service.server_repository_service import ServerRepositoryService +from bot_data.service.user_joined_server_repository_service import UserJoinedServerRepositoryService +from bot_data.service.user_joined_voice_channel_service import UserJoinedVoiceChannelRepositoryService +from bot_data.service.user_repository_service import UserRepositoryService + + +class DataModule(ModuleABC): + + def __init__(self, dc: DiscordCollectionABC): + ModuleABC.__init__(self, dc, lambda x: x.base_module) + + def configure_configuration(self, config: ConfigurationABC, env: ApplicationEnvironmentABC): + pass + + def configure_services(self, services: ServiceCollectionABC, env: ApplicationEnvironmentABC): + services.add_transient(ServerRepositoryABC, ServerRepositoryService) + services.add_transient(UserRepositoryABC, UserRepositoryService) + services.add_transient(ClientRepositoryABC, ClientRepositoryService) + services.add_transient(KnownUserRepositoryABC, KnownUserRepositoryService) + services.add_transient(UserJoinedServerRepositoryABC, UserJoinedServerRepositoryService) + services.add_transient(UserJoinedVoiceChannelRepositoryABC, UserJoinedVoiceChannelRepositoryService) \ No newline at end of file diff --git a/src/modules/admin/admin_module.py b/src/modules/admin/admin_module.py index ae6c86a8..6df25d17 100644 --- a/src/modules/admin/admin_module.py +++ b/src/modules/admin/admin_module.py @@ -16,7 +16,7 @@ class AdminModule(ModuleABC): def configure_configuration(self, config: ConfigurationABC, env: ApplicationEnvironmentABC): pass - def configure_services(self, service: ServiceCollectionABC, env: ApplicationEnvironmentABC): + def configure_services(self, services: ServiceCollectionABC, env: ApplicationEnvironmentABC): # commands self._dc.add_command(RestartCommand) self._dc.add_command(ShutdownCommand) diff --git a/src/modules/admin/command/restart_command.py b/src/modules/admin/command/restart_command.py index 3cd78694..179eeceb 100644 --- a/src/modules/admin/command/restart_command.py +++ b/src/modules/admin/command/restart_command.py @@ -1,3 +1,6 @@ +import asyncio + +import discord from cpl_core.configuration import ConfigurationABC from cpl_discord.command import DiscordCommandABC from cpl_discord.service import DiscordBotServiceABC @@ -7,6 +10,7 @@ from discord.ext.commands import Context from bot_core.abc.client_utils_service_abc import ClientUtilsServiceABC from bot_core.abc.message_service_abc import MessageServiceABC +from bot_core.configuration.bot_settings import BotSettings from bot_core.logging.command_logger import CommandLogger from modules.permission.abc.permission_service_abc import PermissionServiceABC @@ -22,6 +26,7 @@ class RestartCommand(DiscordCommandABC): client_utils: ClientUtilsServiceABC, translate: TranslatePipe, permissions: PermissionServiceABC, + settings: BotSettings ): DiscordCommandABC.__init__(self) @@ -32,6 +37,7 @@ class RestartCommand(DiscordCommandABC): self._client_utils = client_utils self._t = translate self._permissions = permissions + self._settings = settings self._logger.trace(__name__, f'Loaded command service: {type(self).__name__}') @@ -50,6 +56,8 @@ class RestartCommand(DiscordCommandABC): return self._config.add_configuration('IS_RESTART', 'true') + await self._client_utils.presence_game('common.presence.restart') + await asyncio.sleep(self._settings.wait_for_restart) await self._message_service.send_ctx_msg(ctx, self._t.transform('modules.admin.restart_message')) await self._bot.stop_async() diff --git a/src/modules/admin/command/shutdown_command.py b/src/modules/admin/command/shutdown_command.py index f63de698..b4177c54 100644 --- a/src/modules/admin/command/shutdown_command.py +++ b/src/modules/admin/command/shutdown_command.py @@ -1,3 +1,6 @@ +import asyncio + +import discord from cpl_core.configuration import ConfigurationABC from cpl_discord.command import DiscordCommandABC from cpl_discord.service import DiscordBotServiceABC @@ -7,6 +10,7 @@ from discord.ext.commands import Context from bot_core.abc.client_utils_service_abc import ClientUtilsServiceABC from bot_core.abc.message_service_abc import MessageServiceABC +from bot_core.configuration.bot_settings import BotSettings from bot_core.logging.command_logger import CommandLogger from modules.permission.abc.permission_service_abc import PermissionServiceABC @@ -22,6 +26,7 @@ class ShutdownCommand(DiscordCommandABC): client_utils: ClientUtilsServiceABC, translate: TranslatePipe, permissions: PermissionServiceABC, + settings: BotSettings ): DiscordCommandABC.__init__(self) @@ -32,6 +37,7 @@ class ShutdownCommand(DiscordCommandABC): self._client_utils = client_utils self._t = translate self._permissions = permissions + self._settings = settings self._logger.trace(__name__, f'Loaded command service: {type(self).__name__}') @@ -49,6 +55,8 @@ class ShutdownCommand(DiscordCommandABC): self._logger.trace(__name__, f'Finished shutdown command') return + await self._client_utils.presence_game('common.presence.shutdown') + await asyncio.sleep(self._settings.wait_for_shutdown) await self._message_service.send_ctx_msg(ctx, self._t.transform('modules.admin.shutdown_message')) await self._bot.stop_async() diff --git a/src/modules/base/base_module.py b/src/modules/base/base_module.py index 08d43748..d666a823 100644 --- a/src/modules/base/base_module.py +++ b/src/modules/base/base_module.py @@ -5,6 +5,7 @@ from cpl_discord.discord_event_types_enum import DiscordEventTypesEnum from cpl_discord.service.discord_collection_abc import DiscordCollectionABC from bot_core.abc.module_abc import ModuleABC +from modules.base.abc.base_helper_abc import BaseHelperABC from modules.base.command.afk_command import AFKCommand from modules.base.command.help_command import HelpCommand from modules.base.command.info_command import InfoCommand @@ -16,6 +17,7 @@ from modules.base.events.base_on_member_join_event import BaseOnMemberJoinEvent from modules.base.events.base_on_member_remove_event import BaseOnMemberRemoveEvent from modules.base.events.base_on_message_event import BaseOnMessageEvent from modules.base.events.base_on_voice_state_update_event import BaseOnVoiceStateUpdateEvent +from modules.base.service.base_helper_service import BaseHelperService class BaseModule(ModuleABC): @@ -26,7 +28,8 @@ class BaseModule(ModuleABC): def configure_configuration(self, config: ConfigurationABC, env: ApplicationEnvironmentABC): pass - def configure_services(self, service: ServiceCollectionABC, env: ApplicationEnvironmentABC): + def configure_services(self, services: ServiceCollectionABC, env: ApplicationEnvironmentABC): + services.add_transient(BaseHelperABC, BaseHelperService) # commands self._dc.add_command(AFKCommand) self._dc.add_command(HelpCommand) diff --git a/src/modules/base/command/info_command.py b/src/modules/base/command/info_command.py index 2b517aa2..f7183cde 100644 --- a/src/modules/base/command/info_command.py +++ b/src/modules/base/command/info_command.py @@ -60,7 +60,9 @@ class InfoCommand(DiscordCommandABC): embed.add_field(name=self._t.transform('modules.base.info.fields.deleted_message_count'), value=client.deleted_message_count, inline=False) embed.add_field(name=self._t.transform('modules.base.info.fields.received_command_count'), value=client.received_command_count) embed.add_field(name=self._t.transform('modules.base.info.fields.moved_users_count'), value=client.moved_users_count) - modules = ['Admin', 'Base', 'BootLog', 'Database', 'Moderator', 'Permission'] + from bot.module_list import ModuleList + modules = ModuleList.get_modules() + modules = modules.select(lambda x: x.replace('Module', '')) embed.add_field(name=self._t.transform('modules.base.info.fields.modules'), value='\n'.join(modules), inline=False) await self._message_service.send_ctx_msg(ctx, embed, wait_before_delete=wait) diff --git a/src/modules/boot_log/boot_log_module.py b/src/modules/boot_log/boot_log_module.py index 7f533ce1..3ce3ca13 100644 --- a/src/modules/boot_log/boot_log_module.py +++ b/src/modules/boot_log/boot_log_module.py @@ -16,7 +16,7 @@ class BootLogModule(ModuleABC): def configure_configuration(self, config: ConfigurationABC, env: ApplicationEnvironmentABC): pass - def configure_services(self, service: ServiceCollectionABC, env: ApplicationEnvironmentABC): + def configure_services(self, services: ServiceCollectionABC, env: ApplicationEnvironmentABC): # commands # events self._dc.add_event(DiscordEventTypesEnum.on_ready.value, BootLogOnReadyEvent) diff --git a/src/modules/database/database_module.py b/src/modules/database/database_module.py index 4deedcbf..3234ab18 100644 --- a/src/modules/database/database_module.py +++ b/src/modules/database/database_module.py @@ -16,7 +16,7 @@ class DatabaseModule(ModuleABC): def configure_configuration(self, config: ConfigurationABC, env: ApplicationEnvironmentABC): pass - def configure_services(self, service: ServiceCollectionABC, env: ApplicationEnvironmentABC): + def configure_services(self, services: ServiceCollectionABC, env: ApplicationEnvironmentABC): # commands # events self._dc.add_event(DiscordEventTypesEnum.on_ready.value, DatabaseOnReadyEvent) diff --git a/src/modules/moderator/moderator_module.py b/src/modules/moderator/moderator_module.py index 6f0d6013..d5240ac1 100644 --- a/src/modules/moderator/moderator_module.py +++ b/src/modules/moderator/moderator_module.py @@ -15,7 +15,7 @@ class ModeratorModule(ModuleABC): def configure_configuration(self, config: ConfigurationABC, env: ApplicationEnvironmentABC): pass - def configure_services(self, service: ServiceCollectionABC, env: ApplicationEnvironmentABC): + def configure_services(self, services: ServiceCollectionABC, env: ApplicationEnvironmentABC): # commands self._dc.add_command(PurgeCommand) # events diff --git a/src/modules/permission/permission_module.py b/src/modules/permission/permission_module.py index a5f0b5a7..7284b99c 100644 --- a/src/modules/permission/permission_module.py +++ b/src/modules/permission/permission_module.py @@ -5,8 +5,10 @@ from cpl_discord.discord_event_types_enum import DiscordEventTypesEnum from cpl_discord.service.discord_collection_abc import DiscordCollectionABC from bot_core.abc.module_abc import ModuleABC +from modules.permission.abc.permission_service_abc import PermissionServiceABC from modules.permission.events.permission_on_member_update_event import PermissionOnMemberUpdateEvent from modules.permission.events.permission_on_ready_event import PermissionOnReadyEvent +from modules.permission.service.permission_service import PermissionService class PermissionModule(ModuleABC): @@ -17,7 +19,8 @@ class PermissionModule(ModuleABC): def configure_configuration(self, config: ConfigurationABC, env: ApplicationEnvironmentABC): pass - def configure_services(self, service: ServiceCollectionABC, env: ApplicationEnvironmentABC): + def configure_services(self, services: ServiceCollectionABC, env: ApplicationEnvironmentABC): + services.add_singleton(PermissionServiceABC, PermissionService) # commands # events self._dc.add_event(DiscordEventTypesEnum.on_ready.value, PermissionOnReadyEvent) From 04e8e6400311607478427603ea998325465304ff Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Mon, 3 Oct 2022 13:39:09 +0200 Subject: [PATCH 2/3] Improved feature-flags & fixed logging --- src/bot/config/appsettings.development.json | 8 --- .../config/appsettings.edrafts-pc-ubuntu.json | 8 --- src/bot/config/appsettings.production.json | 8 --- src/bot/config/appsettings.staging.json | 8 --- src/bot/config/feature-flags.json | 13 ++++ src/bot/main.py | 5 +- src/bot/startup.py | 29 +++++++- src/bot/startup_module_extension.py | 2 +- src/bot/startup_settings_extension.py | 5 +- src/bot_core/abc/module_abc.py | 7 +- .../configuration/feature_flags_enum.py | 17 +++++ .../configuration/feature_flags_settings.py | 72 +++++++------------ .../core_extension/core_extension_module.py | 3 +- src/bot_core/core_module.py | 18 +---- src/bot_core/events/core_on_ready_event.py | 4 +- src/bot_core/service/client_utils_service.py | 9 ++- src/bot_data/data_module.py | 3 +- src/modules/admin/admin_module.py | 3 +- src/modules/base/base_module.py | 3 +- src/modules/boot_log/boot_log_extension.py | 3 +- src/modules/boot_log/boot_log_module.py | 3 +- src/modules/database/database_extension.py | 3 +- src/modules/database/database_module.py | 3 +- src/modules/moderator/moderator_module.py | 3 +- src/modules/permission/permission_module.py | 3 +- 25 files changed, 125 insertions(+), 118 deletions(-) create mode 100644 src/bot/config/feature-flags.json create mode 100644 src/bot_core/configuration/feature_flags_enum.py diff --git a/src/bot/config/appsettings.development.json b/src/bot/config/appsettings.development.json index 1b3dfa6d..84e61a33 100644 --- a/src/bot/config/appsettings.development.json +++ b/src/bot/config/appsettings.development.json @@ -37,14 +37,6 @@ "de" ] }, - "FeatureFlags": { - "AdminModule": true, - "BaseModule": true, - "BootLogModule": true, - "DatabaseModule": true, - "ModeratorModule": true, - "PermissionModule": true - }, "DiscordBot": { "Token": "OTk4MTU5NjczODkzMDYwNzM4.GN3QyA.yvWO6L7Eu36gXQ7ARDs0Jg2J1VqIDnHLou5lT4", "Prefix": "!kd " diff --git a/src/bot/config/appsettings.edrafts-pc-ubuntu.json b/src/bot/config/appsettings.edrafts-pc-ubuntu.json index 62c82eaa..076ae8d8 100644 --- a/src/bot/config/appsettings.edrafts-pc-ubuntu.json +++ b/src/bot/config/appsettings.edrafts-pc-ubuntu.json @@ -39,14 +39,6 @@ "Token": "OTk4MTYwNDI3Njg5MTgxMjM3.GI7h67.BqD6Lu1Tz0MuG8iktYrcLnHi1pNozyMiWFGTKI", "Prefix": "!ke " }, - "FeatureFlags": { - "AdminModule": true, - "BaseModule": true, - "BootLogModule": true, - "DatabaseModule": true, - "ModeratorModule": true, - "PermissionModule": true - }, "Bot": { "910199451145076828": { "MessageDeleteTimer": 2 diff --git a/src/bot/config/appsettings.production.json b/src/bot/config/appsettings.production.json index 8b195269..346fff41 100644 --- a/src/bot/config/appsettings.production.json +++ b/src/bot/config/appsettings.production.json @@ -48,14 +48,6 @@ "Buffered": "true", "AuthPlugin": "mysql_native_password" }, - "FeatureFlags": { - "AdminModule": true, - "BaseModule": true, - "BootLogModule": true, - "DatabaseModule": true, - "ModeratorModule": true, - "PermissionModule": true - }, "Bot": { "650366049023295514": { "MessageDeleteTimer": 2 diff --git a/src/bot/config/appsettings.staging.json b/src/bot/config/appsettings.staging.json index 7ccbbcb8..c8a9d88b 100644 --- a/src/bot/config/appsettings.staging.json +++ b/src/bot/config/appsettings.staging.json @@ -48,14 +48,6 @@ "Buffered": "true", "AuthPlugin": "mysql_native_password" }, - "FeatureFlags": { - "AdminModule": true, - "BaseModule": true, - "BootLogModule": true, - "DatabaseModule": true, - "ModeratorModule": true, - "PermissionModule": true - }, "Bot": { "910199451145076828": { "MessageDeleteTimer": 4 diff --git a/src/bot/config/feature-flags.json b/src/bot/config/feature-flags.json new file mode 100644 index 00000000..5c347644 --- /dev/null +++ b/src/bot/config/feature-flags.json @@ -0,0 +1,13 @@ +{ + "FeatureFlags": { + "AdminModule": true, + "BaseModule": true, + "BootLogModule": true, + "CoreModule": true, + "CoreExtensionModule": true, + "DatabaseModule": true, + "ModeratorModule": true, + "PermissionModule": true, + "PresenceModule": true + } +} diff --git a/src/bot/main.py b/src/bot/main.py index b00c9418..d2bbdb5a 100644 --- a/src/bot/main.py +++ b/src/bot/main.py @@ -1,4 +1,5 @@ import asyncio +import traceback from typing import Optional from cpl_core.application import ApplicationBuilder @@ -45,12 +46,12 @@ def main(): except KeyboardInterrupt: asyncio.run(program.stop()) except Exception as e: - Console.error(f'[ ERROR ] [ {__name__} ]: Cannot start the bot', str(e)) + Console.error(f'[ ERROR ] [ {__name__} ]: Cannot start the bot', f'{e} -> {traceback.format_exc()}') finally: try: asyncio.run(program.stop()) except Exception as e: - Console.error(f'[ ERROR ] [ {__name__} ]: Cannot stop the bot', str(e)) + Console.error(f'[ ERROR ] [ {__name__} ]: Cannot stop the bot', f'{e} -> {traceback.format_exc()}') if program.app is not None and program.app.is_restart(): del program diff --git a/src/bot/startup.py b/src/bot/startup.py index 6a1fa559..f1c123c5 100644 --- a/src/bot/startup.py +++ b/src/bot/startup.py @@ -4,9 +4,17 @@ from typing import Optional from cpl_core.application import StartupABC from cpl_core.configuration import ConfigurationABC from cpl_core.database import DatabaseSettings -from cpl_core.dependency_injection import ServiceProviderABC, ServiceCollectionABC +from cpl_core.dependency_injection import ServiceCollectionABC +from cpl_core.dependency_injection import ServiceProviderABC from cpl_core.environment import ApplicationEnvironment +from cpl_core.logging import LoggerABC +from bot_core.abc.custom_file_logger_abc import CustomFileLoggerABC +from bot_core.configuration.feature_flags_enum import FeatureFlagsEnum +from bot_core.configuration.feature_flags_settings import FeatureFlagsSettings +from bot_core.logging.command_logger import CommandLogger +from bot_core.logging.database_logger import DatabaseLogger +from bot_core.logging.message_logger import MessageLogger from bot_data.db_context import DBContext @@ -17,15 +25,32 @@ class Startup(StartupABC): self._start_time = datetime.now() self._config: Optional[ConfigurationABC] = None + self._feature_flags: Optional[FeatureFlagsSettings] = None def configure_configuration(self, configuration: ConfigurationABC, environment: ApplicationEnvironment) -> ConfigurationABC: self._config = configuration + self._feature_flags = configuration.get_configuration(FeatureFlagsSettings) return configuration def configure_services(self, services: ServiceCollectionABC, environment: ApplicationEnvironment) -> ServiceProviderABC: services.add_logging() + if self._feature_flags.get_flag(FeatureFlagsEnum.core_module): + # custom logging + services.add_singleton(CustomFileLoggerABC, CommandLogger) + services.add_singleton(CustomFileLoggerABC, DatabaseLogger) + services.add_singleton(CustomFileLoggerABC, MessageLogger) services.add_translation() services.add_db_context(DBContext, self._config.get_configuration(DatabaseSettings)) - return services.build_service_provider() + provider = services.build_service_provider() + # instantiate custom logger + for c in CustomFileLoggerABC.__subclasses__(): + i: LoggerABC = provider.get_service(c) + + + logger: LoggerABC = provider.get_service(LoggerABC) + for flag in [f for f in FeatureFlagsEnum]: + logger.debug(__name__, f'Loaded feature-flag: {flag} = {self._feature_flags.get_flag(flag)}') + + return provider diff --git a/src/bot/startup_module_extension.py b/src/bot/startup_module_extension.py index 2bf73699..70f1b184 100644 --- a/src/bot/startup_module_extension.py +++ b/src/bot/startup_module_extension.py @@ -29,7 +29,7 @@ class StartupModuleExtension(StartupExtensionABC): for module_type in self._modules: module = module_type(dc_collection) - if not module.feature_flag(self._feature_flags): + if not self._feature_flags.get_flag(module.feature_flag): continue Console.set_foreground_color(ForegroundColorEnum.green) diff --git a/src/bot/startup_settings_extension.py b/src/bot/startup_settings_extension.py index 0a9b8091..4dcee8bf 100644 --- a/src/bot/startup_settings_extension.py +++ b/src/bot/startup_settings_extension.py @@ -6,12 +6,9 @@ from cpl_core.application import StartupExtensionABC from cpl_core.configuration import ConfigurationABC from cpl_core.dependency_injection import ServiceCollectionABC from cpl_core.environment import ApplicationEnvironmentABC -from cpl_core.logging import LoggerABC from bot_core.configuration.bot_logging_settings import BotLoggingSettings from bot_core.configuration.bot_settings import BotSettings -from bot_core.logging.command_logger import CommandLogger -from bot_core.logging.database_logger import DatabaseLogger from modules.base.configuration.base_settings import BaseSettings from modules.boot_log.configuration.boot_log_settings import BootLogSettings from modules.permission.configuration.permission_settings import PermissionSettings @@ -31,6 +28,8 @@ class StartupSettingsExtension(StartupExtensionABC): configuration.add_json_file(f'config/appsettings.json', optional=False) configuration.add_json_file(f'config/appsettings.{environment.environment_name}.json', optional=True) configuration.add_json_file(f'config/appsettings.{environment.host_name}.json', optional=True) + # load feature-flags + configuration.add_json_file(f'config/feature-flags.json', optional=False) configuration.add_configuration('Startup_StartTime', str(self._start_time)) self._configure_settings_with_sub_settings(configuration, BotSettings, lambda x: x.servers, lambda x: x.id) diff --git a/src/bot_core/abc/module_abc.py b/src/bot_core/abc/module_abc.py index af52acf0..45f5f5b2 100644 --- a/src/bot_core/abc/module_abc.py +++ b/src/bot_core/abc/module_abc.py @@ -1,19 +1,20 @@ from abc import abstractmethod -from typing import Callable from cpl_core.application import StartupExtensionABC from cpl_discord.service.discord_collection_abc import DiscordCollectionABC +from bot_core.configuration.feature_flags_enum import FeatureFlagsEnum + class ModuleABC(StartupExtensionABC): @abstractmethod - def __init__(self, dc: DiscordCollectionABC, feature_flag: Callable = None): + def __init__(self, dc: DiscordCollectionABC, feature_flag: FeatureFlagsEnum): StartupExtensionABC.__init__(self) self._dc = dc self._feature_flag = feature_flag @property - def feature_flag(self) -> Callable: + def feature_flag(self) -> FeatureFlagsEnum: return self._feature_flag diff --git a/src/bot_core/configuration/feature_flags_enum.py b/src/bot_core/configuration/feature_flags_enum.py new file mode 100644 index 00000000..91e2ca91 --- /dev/null +++ b/src/bot_core/configuration/feature_flags_enum.py @@ -0,0 +1,17 @@ +from enum import Enum + + +class FeatureFlagsEnum(Enum): + + # modules + admin_module = 'AdminModule' + base_module = 'BaseModule' + boot_log_module = 'BootLogModule' + core_module = 'CoreModule' + core_extension_module = 'CoreExtensionModule' + data_module = 'DataModule', + database_module = 'DatabaseModule', + moderator_module = 'ModeratorModule' + permission_module = 'PermissionModule' + # features + presence = 'Presence' diff --git a/src/bot_core/configuration/feature_flags_settings.py b/src/bot_core/configuration/feature_flags_settings.py index 8d280744..8fb815f7 100644 --- a/src/bot_core/configuration/feature_flags_settings.py +++ b/src/bot_core/configuration/feature_flags_settings.py @@ -1,65 +1,47 @@ import traceback -from typing import Optional +from typing import Optional, Callable from cpl_core.configuration.configuration_model_abc import ConfigurationModelABC from cpl_core.console import Console +from bot_core.configuration.feature_flags_enum import FeatureFlagsEnum + class FeatureFlagsSettings(ConfigurationModelABC): def __init__(self): ConfigurationModelABC.__init__(self) - self._admin_module = False # 02.10.2022 #48 - self._base_module = True # 02.10.2022 #48 - self._boot_log_module = True # 02.10.2022 #48 - self._database_module = True # 02.10.2022 #48 - self._moderator_module = False # 02.10.2022 #48 - self._permission_module = True # 02.10.2022 #48 + self._flags = { + # modules + FeatureFlagsEnum.admin_module.value: False, # 02.10.2022 #48 + FeatureFlagsEnum.base_module.value: True, # 02.10.2022 #48 + FeatureFlagsEnum.boot_log_module.value: True, # 02.10.2022 #48 + FeatureFlagsEnum.core_module.value: True, # 03.10.2022 #56 + FeatureFlagsEnum.core_extension_module.value: True, # 03.10.2022 #56 + FeatureFlagsEnum.data_module.value: True, # 03.10.2022 #56 + FeatureFlagsEnum.database_module.value: True, # 02.10.2022 #48 + FeatureFlagsEnum.moderator_module.value: False, # 02.10.2022 #48 + FeatureFlagsEnum.permission_module.value: True, # 02.10.2022 #48 + # features + FeatureFlagsEnum.presence.value: True, # 03.10.2022 #56 + } - @property - def admin_module(self) -> bool: - return self._admin_module + def get_flag(self, key: FeatureFlagsEnum) -> bool: + if key.value not in self._flags: + return False + return self._flags[key.value] - @property - def base_module(self) -> bool: - return self._base_module + def _load_flag(self, settings: dict, key: FeatureFlagsEnum): + if key.value not in settings: + return - @property - def boot_log_module(self) -> bool: - return self._boot_log_module - - @property - def database_module(self) -> bool: - return self._database_module - - @property - def moderator_module(self) -> bool: - return self._moderator_module - - @property - def permission_module(self) -> bool: - return self._permission_module + self._flags[key.value] = bool(settings[key.value]) def from_dict(self, settings: dict): try: - if 'AdminModule' in settings: - self._admin_module = settings['AdminModule'] - - if 'BaseModule' in settings: - self._base_module = settings['BaseModule'] - - if 'BootLogModule' in settings: - self._boot_log_module = settings['BootLogModule'] - - if 'DatabaseModule' in settings: - self._database_module = settings['DatabaseModule'] - - if 'ModeratorModule' in settings: - self._moderator_module = settings['ModeratorModule'] - - if 'PermissionModule' in settings: - self._permission_module = settings['PermissionModule'] + for flag in [f.value for f in FeatureFlagsEnum]: + self._load_flag(settings, FeatureFlagsEnum(flag)) except Exception as e: Console.error(f'[ ERROR ] [ {__name__} ]: Reading error in {type(self).__name__} settings') Console.error(f'[ EXCEPTION ] [ {__name__} ]: {e} -> {traceback.format_exc()}') diff --git a/src/bot_core/core_extension/core_extension_module.py b/src/bot_core/core_extension/core_extension_module.py index 198e0b33..26f1a063 100644 --- a/src/bot_core/core_extension/core_extension_module.py +++ b/src/bot_core/core_extension/core_extension_module.py @@ -5,13 +5,14 @@ from cpl_discord.discord_event_types_enum import DiscordEventTypesEnum from cpl_discord.service.discord_collection_abc import DiscordCollectionABC from bot_core.abc.module_abc import ModuleABC +from bot_core.configuration.feature_flags_enum import FeatureFlagsEnum from bot_core.core_extension.core_extension_on_ready_event import CoreExtensionOnReadyEvent class CoreExtensionModule(ModuleABC): def __init__(self, dc: DiscordCollectionABC): - ModuleABC.__init__(self, dc, lambda x: x.base_module) + ModuleABC.__init__(self, dc, FeatureFlagsEnum.core_extension_module) def configure_configuration(self, config: ConfigurationABC, env: ApplicationEnvironmentABC): pass diff --git a/src/bot_core/core_module.py b/src/bot_core/core_module.py index f8320d6b..60d4337a 100644 --- a/src/bot_core/core_module.py +++ b/src/bot_core/core_module.py @@ -1,18 +1,14 @@ from cpl_core.configuration import ConfigurationABC from cpl_core.dependency_injection import ServiceCollectionABC from cpl_core.environment import ApplicationEnvironmentABC -from cpl_core.logging import LoggerABC from cpl_discord.discord_event_types_enum import DiscordEventTypesEnum from cpl_discord.service.discord_collection_abc import DiscordCollectionABC from bot_core.abc.client_utils_service_abc import ClientUtilsServiceABC -from bot_core.abc.custom_file_logger_abc import CustomFileLoggerABC from bot_core.abc.message_service_abc import MessageServiceABC from bot_core.abc.module_abc import ModuleABC +from bot_core.configuration.feature_flags_enum import FeatureFlagsEnum from bot_core.events.core_on_ready_event import CoreOnReadyEvent -from bot_core.logging.command_logger import CommandLogger -from bot_core.logging.database_logger import DatabaseLogger -from bot_core.logging.message_logger import MessageLogger from bot_core.pipes.date_time_offset_pipe import DateTimeOffsetPipe from bot_core.service.client_utils_service import ClientUtilsService from bot_core.service.message_service import MessageService @@ -21,17 +17,12 @@ from bot_core.service.message_service import MessageService class CoreModule(ModuleABC): def __init__(self, dc: DiscordCollectionABC): - ModuleABC.__init__(self, dc, lambda x: x.base_module) + ModuleABC.__init__(self, dc, FeatureFlagsEnum.core_module) def configure_configuration(self, config: ConfigurationABC, env: ApplicationEnvironmentABC): pass def configure_services(self, services: ServiceCollectionABC, env: ApplicationEnvironmentABC): - # custom logging - services.add_singleton(CustomFileLoggerABC, CommandLogger) - services.add_singleton(CustomFileLoggerABC, DatabaseLogger) - services.add_singleton(CustomFileLoggerABC, MessageLogger) - services.add_transient(MessageServiceABC, MessageService) services.add_transient(ClientUtilsServiceABC, ClientUtilsService) @@ -39,8 +30,3 @@ class CoreModule(ModuleABC): services.add_transient(DateTimeOffsetPipe) self._dc.add_event(DiscordEventTypesEnum.on_ready.value, CoreOnReadyEvent) - - provider = services.build_service_provider() - # instantiate custom logger - for c in CustomFileLoggerABC.__subclasses__(): - i: LoggerABC = provider.get_service(c) diff --git a/src/bot_core/events/core_on_ready_event.py b/src/bot_core/events/core_on_ready_event.py index f438884f..540f9d1f 100644 --- a/src/bot_core/events/core_on_ready_event.py +++ b/src/bot_core/events/core_on_ready_event.py @@ -1,5 +1,3 @@ -import asyncio - from cpl_core.logging import LoggerABC from cpl_discord.events import OnReadyABC from cpl_discord.service import DiscordBotServiceABC @@ -15,7 +13,7 @@ class CoreOnReadyEvent(OnReadyABC): logger: LoggerABC, bot: DiscordBotServiceABC, client_utils: ClientUtilsServiceABC, - t: TranslatePipe + t: TranslatePipe, ): OnReadyABC.__init__(self) diff --git a/src/bot_core/service/client_utils_service.py b/src/bot_core/service/client_utils_service.py index 2adfb289..733e3903 100644 --- a/src/bot_core/service/client_utils_service.py +++ b/src/bot_core/service/client_utils_service.py @@ -9,6 +9,8 @@ from discord.ext.commands import Context from bot_core.abc.client_utils_service_abc import ClientUtilsServiceABC from bot_core.abc.message_service_abc import MessageServiceABC +from bot_core.configuration.feature_flags_enum import FeatureFlagsEnum +from bot_core.configuration.feature_flags_settings import FeatureFlagsSettings from bot_data.abc.client_repository_abc import ClientRepositoryABC from bot_data.abc.server_repository_abc import ServerRepositoryABC @@ -24,7 +26,8 @@ class ClientUtilsService(ClientUtilsServiceABC): clients: ClientRepositoryABC, message_service: MessageServiceABC, db: DatabaseContextABC, - t: TranslatePipe + t: TranslatePipe, + feature_flags: FeatureFlagsSettings ): ClientUtilsServiceABC.__init__(self) self._config = config @@ -35,6 +38,7 @@ class ClientUtilsService(ClientUtilsServiceABC): self._message_service = message_service self._db = db self._t = t + self._feature_flags = feature_flags def received_command(self, guild_id: int): server = self._servers.get_server_by_discord_id(guild_id) @@ -64,6 +68,9 @@ class ClientUtilsService(ClientUtilsServiceABC): return False async def presence_game(self, t_key: str): + if not self._feature_flags.get_flag(FeatureFlagsEnum.presence): + return + import bot name = self._t.transform(t_key).format(bot.__version__) await self._bot.change_presence(activity=discord.Game(name=name)) diff --git a/src/bot_data/data_module.py b/src/bot_data/data_module.py index cbceaa4e..099ba2fd 100644 --- a/src/bot_data/data_module.py +++ b/src/bot_data/data_module.py @@ -4,6 +4,7 @@ from cpl_core.environment import ApplicationEnvironmentABC from cpl_discord.service.discord_collection_abc import DiscordCollectionABC from bot_core.abc.module_abc import ModuleABC +from bot_core.configuration.feature_flags_enum import FeatureFlagsEnum from bot_data.abc.client_repository_abc import ClientRepositoryABC from bot_data.abc.known_user_repository_abc import KnownUserRepositoryABC from bot_data.abc.server_repository_abc import ServerRepositoryABC @@ -21,7 +22,7 @@ from bot_data.service.user_repository_service import UserRepositoryService class DataModule(ModuleABC): def __init__(self, dc: DiscordCollectionABC): - ModuleABC.__init__(self, dc, lambda x: x.base_module) + ModuleABC.__init__(self, dc, FeatureFlagsEnum.data_module) def configure_configuration(self, config: ConfigurationABC, env: ApplicationEnvironmentABC): pass diff --git a/src/modules/admin/admin_module.py b/src/modules/admin/admin_module.py index 6df25d17..48f76afa 100644 --- a/src/modules/admin/admin_module.py +++ b/src/modules/admin/admin_module.py @@ -4,6 +4,7 @@ from cpl_core.environment import ApplicationEnvironmentABC from cpl_discord.service.discord_collection_abc import DiscordCollectionABC from bot_core.abc.module_abc import ModuleABC +from bot_core.configuration.feature_flags_enum import FeatureFlagsEnum from modules.admin.command.restart_command import RestartCommand from modules.admin.command.shutdown_command import ShutdownCommand @@ -11,7 +12,7 @@ from modules.admin.command.shutdown_command import ShutdownCommand class AdminModule(ModuleABC): def __init__(self, dc: DiscordCollectionABC): - ModuleABC.__init__(self, dc, lambda x: x.admin_module) + ModuleABC.__init__(self, dc, FeatureFlagsEnum.admin_module) def configure_configuration(self, config: ConfigurationABC, env: ApplicationEnvironmentABC): pass diff --git a/src/modules/base/base_module.py b/src/modules/base/base_module.py index d666a823..ef52df05 100644 --- a/src/modules/base/base_module.py +++ b/src/modules/base/base_module.py @@ -5,6 +5,7 @@ from cpl_discord.discord_event_types_enum import DiscordEventTypesEnum from cpl_discord.service.discord_collection_abc import DiscordCollectionABC from bot_core.abc.module_abc import ModuleABC +from bot_core.configuration.feature_flags_enum import FeatureFlagsEnum from modules.base.abc.base_helper_abc import BaseHelperABC from modules.base.command.afk_command import AFKCommand from modules.base.command.help_command import HelpCommand @@ -23,7 +24,7 @@ from modules.base.service.base_helper_service import BaseHelperService class BaseModule(ModuleABC): def __init__(self, dc: DiscordCollectionABC): - ModuleABC.__init__(self, dc, lambda x: x.base_module) + ModuleABC.__init__(self, dc, FeatureFlagsEnum.base_module) def configure_configuration(self, config: ConfigurationABC, env: ApplicationEnvironmentABC): pass diff --git a/src/modules/boot_log/boot_log_extension.py b/src/modules/boot_log/boot_log_extension.py index 42db4b8e..bec9f1f7 100644 --- a/src/modules/boot_log/boot_log_extension.py +++ b/src/modules/boot_log/boot_log_extension.py @@ -5,6 +5,7 @@ from cpl_core.configuration import ConfigurationABC from cpl_core.dependency_injection import ServiceProviderABC from cpl_core.logging import LoggerABC +from bot_core.configuration.feature_flags_enum import FeatureFlagsEnum from bot_core.configuration.feature_flags_settings import FeatureFlagsSettings @@ -15,7 +16,7 @@ class BootLogExtension(ApplicationExtensionABC): async def run(self, config: ConfigurationABC, services: ServiceProviderABC): feature_flags: FeatureFlagsSettings = config.get_configuration(FeatureFlagsSettings) - if not feature_flags.boot_log_module: + if not feature_flags.get_flag(FeatureFlagsEnum.boot_log_module): return logger: LoggerABC = services.get_service(LoggerABC) logger.debug(__name__, 'BootLog extension started') diff --git a/src/modules/boot_log/boot_log_module.py b/src/modules/boot_log/boot_log_module.py index 3ce3ca13..ac7ae4bb 100644 --- a/src/modules/boot_log/boot_log_module.py +++ b/src/modules/boot_log/boot_log_module.py @@ -5,13 +5,14 @@ from cpl_discord.discord_event_types_enum import DiscordEventTypesEnum from cpl_discord.service.discord_collection_abc import DiscordCollectionABC from bot_core.abc.module_abc import ModuleABC +from bot_core.configuration.feature_flags_enum import FeatureFlagsEnum from modules.boot_log.boot_log_on_ready_event import BootLogOnReadyEvent class BootLogModule(ModuleABC): def __init__(self, dc: DiscordCollectionABC): - ModuleABC.__init__(self, dc, lambda x: x.boot_log_module) + ModuleABC.__init__(self, dc, FeatureFlagsEnum.boot_log_module) def configure_configuration(self, config: ConfigurationABC, env: ApplicationEnvironmentABC): pass diff --git a/src/modules/database/database_extension.py b/src/modules/database/database_extension.py index f5d4a492..8bc111e9 100644 --- a/src/modules/database/database_extension.py +++ b/src/modules/database/database_extension.py @@ -5,6 +5,7 @@ from cpl_core.configuration import ConfigurationABC from cpl_core.dependency_injection import ServiceProviderABC from cpl_core.logging import LoggerABC +from bot_core.configuration.feature_flags_enum import FeatureFlagsEnum from bot_core.configuration.feature_flags_settings import FeatureFlagsSettings from bot_core.logging.database_logger import DatabaseLogger from bot_data.service.migration_service import MigrationService @@ -17,7 +18,7 @@ class DatabaseExtension(ApplicationExtensionABC): async def run(self, config: ConfigurationABC, services: ServiceProviderABC): feature_flags: FeatureFlagsSettings = config.get_configuration(FeatureFlagsSettings) - if not feature_flags.database_module: + if not feature_flags.get_flag(FeatureFlagsEnum.data_module): return logger: LoggerABC = services.get_service(DatabaseLogger) logger.debug(__name__, 'Database extension started') diff --git a/src/modules/database/database_module.py b/src/modules/database/database_module.py index 3234ab18..52fdac9c 100644 --- a/src/modules/database/database_module.py +++ b/src/modules/database/database_module.py @@ -5,13 +5,14 @@ from cpl_discord.discord_event_types_enum import DiscordEventTypesEnum from cpl_discord.service.discord_collection_abc import DiscordCollectionABC from bot_core.abc.module_abc import ModuleABC +from bot_core.configuration.feature_flags_enum import FeatureFlagsEnum from modules.database.database_on_ready_event import DatabaseOnReadyEvent class DatabaseModule(ModuleABC): def __init__(self, dc: DiscordCollectionABC): - ModuleABC.__init__(self, dc, lambda x: x.database_module) + ModuleABC.__init__(self, dc, FeatureFlagsEnum.database_module) def configure_configuration(self, config: ConfigurationABC, env: ApplicationEnvironmentABC): pass diff --git a/src/modules/moderator/moderator_module.py b/src/modules/moderator/moderator_module.py index d5240ac1..e47d994d 100644 --- a/src/modules/moderator/moderator_module.py +++ b/src/modules/moderator/moderator_module.py @@ -4,13 +4,14 @@ from cpl_core.environment import ApplicationEnvironmentABC from cpl_discord.service.discord_collection_abc import DiscordCollectionABC from bot_core.abc.module_abc import ModuleABC +from bot_core.configuration.feature_flags_enum import FeatureFlagsEnum from modules.moderator.command.purge_command import PurgeCommand class ModeratorModule(ModuleABC): def __init__(self, dc: DiscordCollectionABC): - ModuleABC.__init__(self, dc, lambda x: x.moderator_module) + ModuleABC.__init__(self, dc, FeatureFlagsEnum.moderator_module) def configure_configuration(self, config: ConfigurationABC, env: ApplicationEnvironmentABC): pass diff --git a/src/modules/permission/permission_module.py b/src/modules/permission/permission_module.py index 7284b99c..63615b55 100644 --- a/src/modules/permission/permission_module.py +++ b/src/modules/permission/permission_module.py @@ -5,6 +5,7 @@ from cpl_discord.discord_event_types_enum import DiscordEventTypesEnum from cpl_discord.service.discord_collection_abc import DiscordCollectionABC from bot_core.abc.module_abc import ModuleABC +from bot_core.configuration.feature_flags_enum import FeatureFlagsEnum from modules.permission.abc.permission_service_abc import PermissionServiceABC from modules.permission.events.permission_on_member_update_event import PermissionOnMemberUpdateEvent from modules.permission.events.permission_on_ready_event import PermissionOnReadyEvent @@ -14,7 +15,7 @@ from modules.permission.service.permission_service import PermissionService class PermissionModule(ModuleABC): def __init__(self, dc: DiscordCollectionABC): - ModuleABC.__init__(self, dc, lambda x: x.permission_module) + ModuleABC.__init__(self, dc, FeatureFlagsEnum.permission_module) def configure_configuration(self, config: ConfigurationABC, env: ApplicationEnvironmentABC): pass From 9f4c6d45c677ce89684f5e8c45314692c1d914d9 Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Mon, 3 Oct 2022 13:44:12 +0200 Subject: [PATCH 3/3] Build --- src/bot/__init__.py | 4 +-- src/bot_core/__init__.py | 4 +-- src/bot_core/abc/__init__.py | 4 +-- src/bot_core/configuration/__init__.py | 4 +-- src/bot_core/core_extension/__init__.py | 26 +++++++++++++++++++ src/bot_core/events/__init__.py | 26 +++++++++++++++++++ src/bot_core/helper/__init__.py | 4 +-- src/bot_core/logging/__init__.py | 4 +-- src/bot_core/pipes/__init__.py | 4 +-- src/bot_core/service/__init__.py | 4 +-- src/bot_data/__init__.py | 4 +-- src/bot_data/abc/__init__.py | 4 +-- src/bot_data/migration/__init__.py | 4 +-- src/bot_data/model/__init__.py | 4 +-- src/bot_data/service/__init__.py | 4 +-- src/modules/admin/__init__.py | 4 +-- src/modules/admin/command/__init__.py | 4 +-- src/modules/base/__init__.py | 4 +-- src/modules/base/abc/__init__.py | 4 +-- src/modules/base/command/__init__.py | 4 +-- src/modules/base/configuration/__init__.py | 4 +-- src/modules/base/events/__init__.py | 4 +-- src/modules/base/service/__init__.py | 4 +-- src/modules/boot_log/__init__.py | 4 +-- .../boot_log/configuration/__init__.py | 4 +-- src/modules/database/__init__.py | 4 +-- src/modules/moderator/__init__.py | 4 +-- src/modules/moderator/command/__init__.py | 4 +-- src/modules/permission/__init__.py | 4 +-- src/modules/permission/abc/__init__.py | 4 +-- .../permission/configuration/__init__.py | 4 +-- src/modules/permission/events/__init__.py | 4 +-- src/modules/permission/service/__init__.py | 4 +-- 33 files changed, 114 insertions(+), 62 deletions(-) diff --git a/src/bot/__init__.py b/src/bot/__init__.py index 30520581..db32fd91 100644 --- a/src/bot/__init__.py +++ b/src/bot/__init__.py @@ -15,7 +15,7 @@ __title__ = 'bot' __author__ = 'Sven Heidemann' __license__ = 'MIT' __copyright__ = 'Copyright (c) 2022 sh-edraft.de' -__version__ = '0.2.0' +__version__ = '0.2.1' from collections import namedtuple @@ -23,4 +23,4 @@ from collections import namedtuple # imports: VersionInfo = namedtuple('VersionInfo', 'major minor micro') -version_info = VersionInfo(major='0', minor='2', micro='0') +version_info = VersionInfo(major='0', minor='2', micro='1') diff --git a/src/bot_core/__init__.py b/src/bot_core/__init__.py index 6ba98ff0..e323ced5 100644 --- a/src/bot_core/__init__.py +++ b/src/bot_core/__init__.py @@ -15,7 +15,7 @@ __title__ = 'bot_core' __author__ = 'Sven Heidemann' __license__ = 'MIT' __copyright__ = 'Copyright (c) 2022 sh-edraft.de' -__version__ = '0.2.0' +__version__ = '0.2.1' from collections import namedtuple @@ -23,4 +23,4 @@ from collections import namedtuple # imports VersionInfo = namedtuple('VersionInfo', 'major minor micro') -version_info = VersionInfo(major='0', minor='2', micro='0') +version_info = VersionInfo(major='0', minor='2', micro='1') diff --git a/src/bot_core/abc/__init__.py b/src/bot_core/abc/__init__.py index aac72ca3..d95795f2 100644 --- a/src/bot_core/abc/__init__.py +++ b/src/bot_core/abc/__init__.py @@ -15,7 +15,7 @@ __title__ = 'bot_core.abc' __author__ = 'Sven Heidemann' __license__ = 'MIT' __copyright__ = 'Copyright (c) 2022 sh-edraft.de' -__version__ = '0.2.0' +__version__ = '0.2.1' from collections import namedtuple @@ -23,4 +23,4 @@ from collections import namedtuple # imports: VersionInfo = namedtuple('VersionInfo', 'major minor micro') -version_info = VersionInfo(major='0', minor='2', micro='0') +version_info = VersionInfo(major='0', minor='2', micro='1') diff --git a/src/bot_core/configuration/__init__.py b/src/bot_core/configuration/__init__.py index 5c540e04..1aa8c319 100644 --- a/src/bot_core/configuration/__init__.py +++ b/src/bot_core/configuration/__init__.py @@ -15,7 +15,7 @@ __title__ = 'bot_core.configuration' __author__ = 'Sven Heidemann' __license__ = 'MIT' __copyright__ = 'Copyright (c) 2022 sh-edraft.de' -__version__ = '0.2.0' +__version__ = '0.2.1' from collections import namedtuple @@ -23,4 +23,4 @@ from collections import namedtuple # imports: VersionInfo = namedtuple('VersionInfo', 'major minor micro') -version_info = VersionInfo(major='0', minor='2', micro='0') +version_info = VersionInfo(major='0', minor='2', micro='1') diff --git a/src/bot_core/core_extension/__init__.py b/src/bot_core/core_extension/__init__.py index e69de29b..fe0762bd 100644 --- a/src/bot_core/core_extension/__init__.py +++ b/src/bot_core/core_extension/__init__.py @@ -0,0 +1,26 @@ +# -*- coding: utf-8 -*- + +""" +bot Keksdose bot +~~~~~~~~~~~~~~~~~~~ + +Discord bot for the Keksdose discord Server + +:copyright: (c) 2022 sh-edraft.de +:license: MIT, see LICENSE for more details. + +""" + +__title__ = 'bot_core.core_extension' +__author__ = 'Sven Heidemann' +__license__ = 'MIT' +__copyright__ = 'Copyright (c) 2022 sh-edraft.de' +__version__ = '0.2.1' + +from collections import namedtuple + + +# imports: + +VersionInfo = namedtuple('VersionInfo', 'major minor micro') +version_info = VersionInfo(major='0', minor='2', micro='1') diff --git a/src/bot_core/events/__init__.py b/src/bot_core/events/__init__.py index e69de29b..7cf3da4a 100644 --- a/src/bot_core/events/__init__.py +++ b/src/bot_core/events/__init__.py @@ -0,0 +1,26 @@ +# -*- coding: utf-8 -*- + +""" +bot Keksdose bot +~~~~~~~~~~~~~~~~~~~ + +Discord bot for the Keksdose discord Server + +:copyright: (c) 2022 sh-edraft.de +:license: MIT, see LICENSE for more details. + +""" + +__title__ = 'bot_core.events' +__author__ = 'Sven Heidemann' +__license__ = 'MIT' +__copyright__ = 'Copyright (c) 2022 sh-edraft.de' +__version__ = '0.2.1' + +from collections import namedtuple + + +# imports: + +VersionInfo = namedtuple('VersionInfo', 'major minor micro') +version_info = VersionInfo(major='0', minor='2', micro='1') diff --git a/src/bot_core/helper/__init__.py b/src/bot_core/helper/__init__.py index ca4ef715..85871fad 100644 --- a/src/bot_core/helper/__init__.py +++ b/src/bot_core/helper/__init__.py @@ -15,7 +15,7 @@ __title__ = 'bot_core.helper' __author__ = 'Sven Heidemann' __license__ = 'MIT' __copyright__ = 'Copyright (c) 2022 sh-edraft.de' -__version__ = '0.2.0' +__version__ = '0.2.1' from collections import namedtuple @@ -23,4 +23,4 @@ from collections import namedtuple # imports: VersionInfo = namedtuple('VersionInfo', 'major minor micro') -version_info = VersionInfo(major='0', minor='2', micro='0') +version_info = VersionInfo(major='0', minor='2', micro='1') diff --git a/src/bot_core/logging/__init__.py b/src/bot_core/logging/__init__.py index eafee46f..55630861 100644 --- a/src/bot_core/logging/__init__.py +++ b/src/bot_core/logging/__init__.py @@ -15,7 +15,7 @@ __title__ = 'bot_core.logging' __author__ = 'Sven Heidemann' __license__ = 'MIT' __copyright__ = 'Copyright (c) 2022 sh-edraft.de' -__version__ = '0.2.0' +__version__ = '0.2.1' from collections import namedtuple @@ -23,4 +23,4 @@ from collections import namedtuple # imports VersionInfo = namedtuple('VersionInfo', 'major minor micro') -version_info = VersionInfo(major='0', minor='2', micro='0') +version_info = VersionInfo(major='0', minor='2', micro='1') diff --git a/src/bot_core/pipes/__init__.py b/src/bot_core/pipes/__init__.py index 381e147f..77bb114e 100644 --- a/src/bot_core/pipes/__init__.py +++ b/src/bot_core/pipes/__init__.py @@ -15,7 +15,7 @@ __title__ = 'bot_core.pipes' __author__ = 'Sven Heidemann' __license__ = 'MIT' __copyright__ = 'Copyright (c) 2022 sh-edraft.de' -__version__ = '0.2.0' +__version__ = '0.2.1' from collections import namedtuple @@ -23,4 +23,4 @@ from collections import namedtuple # imports VersionInfo = namedtuple('VersionInfo', 'major minor micro') -version_info = VersionInfo(major='0', minor='2', micro='0') +version_info = VersionInfo(major='0', minor='2', micro='1') diff --git a/src/bot_core/service/__init__.py b/src/bot_core/service/__init__.py index 1775598a..280d2658 100644 --- a/src/bot_core/service/__init__.py +++ b/src/bot_core/service/__init__.py @@ -15,7 +15,7 @@ __title__ = 'bot_core.service' __author__ = 'Sven Heidemann' __license__ = 'MIT' __copyright__ = 'Copyright (c) 2022 sh-edraft.de' -__version__ = '0.2.0' +__version__ = '0.2.1' from collections import namedtuple @@ -23,4 +23,4 @@ from collections import namedtuple # imports: VersionInfo = namedtuple('VersionInfo', 'major minor micro') -version_info = VersionInfo(major='0', minor='2', micro='0') +version_info = VersionInfo(major='0', minor='2', micro='1') diff --git a/src/bot_data/__init__.py b/src/bot_data/__init__.py index 526ef397..354d9d03 100644 --- a/src/bot_data/__init__.py +++ b/src/bot_data/__init__.py @@ -15,7 +15,7 @@ __title__ = 'bot_data' __author__ = 'Sven Heidemann' __license__ = 'MIT' __copyright__ = 'Copyright (c) 2022 sh-edraft.de' -__version__ = '0.2.0' +__version__ = '0.2.1' from collections import namedtuple @@ -23,4 +23,4 @@ from collections import namedtuple # imports VersionInfo = namedtuple('VersionInfo', 'major minor micro') -version_info = VersionInfo(major='0', minor='2', micro='0') +version_info = VersionInfo(major='0', minor='2', micro='1') diff --git a/src/bot_data/abc/__init__.py b/src/bot_data/abc/__init__.py index 6d4ca870..d475ce09 100644 --- a/src/bot_data/abc/__init__.py +++ b/src/bot_data/abc/__init__.py @@ -15,7 +15,7 @@ __title__ = 'bot_data.abc' __author__ = 'Sven Heidemann' __license__ = 'MIT' __copyright__ = 'Copyright (c) 2022 sh-edraft.de' -__version__ = '0.2.0' +__version__ = '0.2.1' from collections import namedtuple @@ -23,4 +23,4 @@ from collections import namedtuple # imports VersionInfo = namedtuple('VersionInfo', 'major minor micro') -version_info = VersionInfo(major='0', minor='2', micro='0') +version_info = VersionInfo(major='0', minor='2', micro='1') diff --git a/src/bot_data/migration/__init__.py b/src/bot_data/migration/__init__.py index 40311e46..cb7f0409 100644 --- a/src/bot_data/migration/__init__.py +++ b/src/bot_data/migration/__init__.py @@ -15,7 +15,7 @@ __title__ = 'bot_data.migration' __author__ = 'Sven Heidemann' __license__ = 'MIT' __copyright__ = 'Copyright (c) 2022 sh-edraft.de' -__version__ = '0.2.0' +__version__ = '0.2.1' from collections import namedtuple @@ -23,4 +23,4 @@ from collections import namedtuple # imports VersionInfo = namedtuple('VersionInfo', 'major minor micro') -version_info = VersionInfo(major='0', minor='2', micro='0') +version_info = VersionInfo(major='0', minor='2', micro='1') diff --git a/src/bot_data/model/__init__.py b/src/bot_data/model/__init__.py index 35cd1af1..45bf4225 100644 --- a/src/bot_data/model/__init__.py +++ b/src/bot_data/model/__init__.py @@ -15,7 +15,7 @@ __title__ = 'bot_data.model' __author__ = 'Sven Heidemann' __license__ = 'MIT' __copyright__ = 'Copyright (c) 2022 sh-edraft.de' -__version__ = '0.2.0' +__version__ = '0.2.1' from collections import namedtuple @@ -23,4 +23,4 @@ from collections import namedtuple # imports VersionInfo = namedtuple('VersionInfo', 'major minor micro') -version_info = VersionInfo(major='0', minor='2', micro='0') +version_info = VersionInfo(major='0', minor='2', micro='1') diff --git a/src/bot_data/service/__init__.py b/src/bot_data/service/__init__.py index f268cc0a..0224b585 100644 --- a/src/bot_data/service/__init__.py +++ b/src/bot_data/service/__init__.py @@ -15,7 +15,7 @@ __title__ = 'bot_data.service' __author__ = 'Sven Heidemann' __license__ = 'MIT' __copyright__ = 'Copyright (c) 2022 sh-edraft.de' -__version__ = '0.2.0' +__version__ = '0.2.1' from collections import namedtuple @@ -23,4 +23,4 @@ from collections import namedtuple # imports VersionInfo = namedtuple('VersionInfo', 'major minor micro') -version_info = VersionInfo(major='0', minor='2', micro='0') +version_info = VersionInfo(major='0', minor='2', micro='1') diff --git a/src/modules/admin/__init__.py b/src/modules/admin/__init__.py index daf704dd..fc1dc7f9 100644 --- a/src/modules/admin/__init__.py +++ b/src/modules/admin/__init__.py @@ -15,7 +15,7 @@ __title__ = 'modules.admin' __author__ = 'Sven Heidemann' __license__ = 'MIT' __copyright__ = 'Copyright (c) 2022 sh-edraft.de' -__version__ = '0.2.0' +__version__ = '0.2.1' from collections import namedtuple @@ -23,4 +23,4 @@ from collections import namedtuple # imports: VersionInfo = namedtuple('VersionInfo', 'major minor micro') -version_info = VersionInfo(major='0', minor='2', micro='0') +version_info = VersionInfo(major='0', minor='2', micro='1') diff --git a/src/modules/admin/command/__init__.py b/src/modules/admin/command/__init__.py index 6ebd80ad..81fe7473 100644 --- a/src/modules/admin/command/__init__.py +++ b/src/modules/admin/command/__init__.py @@ -15,7 +15,7 @@ __title__ = 'modules.admin.command' __author__ = 'Sven Heidemann' __license__ = 'MIT' __copyright__ = 'Copyright (c) 2022 sh-edraft.de' -__version__ = '0.2.0' +__version__ = '0.2.1' from collections import namedtuple @@ -23,4 +23,4 @@ from collections import namedtuple # imports: VersionInfo = namedtuple('VersionInfo', 'major minor micro') -version_info = VersionInfo(major='0', minor='2', micro='0') +version_info = VersionInfo(major='0', minor='2', micro='1') diff --git a/src/modules/base/__init__.py b/src/modules/base/__init__.py index b89988ff..9c96d601 100644 --- a/src/modules/base/__init__.py +++ b/src/modules/base/__init__.py @@ -15,7 +15,7 @@ __title__ = 'modules.base' __author__ = 'Sven Heidemann' __license__ = 'MIT' __copyright__ = 'Copyright (c) 2022 sh-edraft.de' -__version__ = '0.2.0' +__version__ = '0.2.1' from collections import namedtuple @@ -23,4 +23,4 @@ from collections import namedtuple # imports VersionInfo = namedtuple('VersionInfo', 'major minor micro') -version_info = VersionInfo(major='0', minor='2', micro='0') +version_info = VersionInfo(major='0', minor='2', micro='1') diff --git a/src/modules/base/abc/__init__.py b/src/modules/base/abc/__init__.py index ac238cec..f2360753 100644 --- a/src/modules/base/abc/__init__.py +++ b/src/modules/base/abc/__init__.py @@ -15,7 +15,7 @@ __title__ = 'modules.base.abc' __author__ = 'Sven Heidemann' __license__ = 'MIT' __copyright__ = 'Copyright (c) 2022 sh-edraft.de' -__version__ = '0.2.0' +__version__ = '0.2.1' from collections import namedtuple @@ -23,4 +23,4 @@ from collections import namedtuple # imports: VersionInfo = namedtuple('VersionInfo', 'major minor micro') -version_info = VersionInfo(major='0', minor='2', micro='0') +version_info = VersionInfo(major='0', minor='2', micro='1') diff --git a/src/modules/base/command/__init__.py b/src/modules/base/command/__init__.py index c38e8b4e..12373318 100644 --- a/src/modules/base/command/__init__.py +++ b/src/modules/base/command/__init__.py @@ -15,7 +15,7 @@ __title__ = 'modules.base.command' __author__ = 'Sven Heidemann' __license__ = 'MIT' __copyright__ = 'Copyright (c) 2022 sh-edraft.de' -__version__ = '0.2.0' +__version__ = '0.2.1' from collections import namedtuple @@ -23,4 +23,4 @@ from collections import namedtuple # imports VersionInfo = namedtuple('VersionInfo', 'major minor micro') -version_info = VersionInfo(major='0', minor='2', micro='0') +version_info = VersionInfo(major='0', minor='2', micro='1') diff --git a/src/modules/base/configuration/__init__.py b/src/modules/base/configuration/__init__.py index 973a4814..f45bccda 100644 --- a/src/modules/base/configuration/__init__.py +++ b/src/modules/base/configuration/__init__.py @@ -15,7 +15,7 @@ __title__ = 'modules.base.configuration' __author__ = 'Sven Heidemann' __license__ = 'MIT' __copyright__ = 'Copyright (c) 2022 sh-edraft.de' -__version__ = '0.2.0' +__version__ = '0.2.1' from collections import namedtuple @@ -23,4 +23,4 @@ from collections import namedtuple # imports: VersionInfo = namedtuple('VersionInfo', 'major minor micro') -version_info = VersionInfo(major='0', minor='2', micro='0') +version_info = VersionInfo(major='0', minor='2', micro='1') diff --git a/src/modules/base/events/__init__.py b/src/modules/base/events/__init__.py index 5d993630..260ba442 100644 --- a/src/modules/base/events/__init__.py +++ b/src/modules/base/events/__init__.py @@ -15,7 +15,7 @@ __title__ = 'modules.base.events' __author__ = 'Sven Heidemann' __license__ = 'MIT' __copyright__ = 'Copyright (c) 2022 sh-edraft.de' -__version__ = '0.2.0' +__version__ = '0.2.1' from collections import namedtuple @@ -23,4 +23,4 @@ from collections import namedtuple # imports: VersionInfo = namedtuple('VersionInfo', 'major minor micro') -version_info = VersionInfo(major='0', minor='2', micro='0') +version_info = VersionInfo(major='0', minor='2', micro='1') diff --git a/src/modules/base/service/__init__.py b/src/modules/base/service/__init__.py index 24e4a38c..c1e5ee4b 100644 --- a/src/modules/base/service/__init__.py +++ b/src/modules/base/service/__init__.py @@ -15,7 +15,7 @@ __title__ = 'modules.base.service' __author__ = 'Sven Heidemann' __license__ = 'MIT' __copyright__ = 'Copyright (c) 2022 sh-edraft.de' -__version__ = '0.2.0' +__version__ = '0.2.1' from collections import namedtuple @@ -23,4 +23,4 @@ from collections import namedtuple # imports VersionInfo = namedtuple('VersionInfo', 'major minor micro') -version_info = VersionInfo(major='0', minor='2', micro='0') +version_info = VersionInfo(major='0', minor='2', micro='1') diff --git a/src/modules/boot_log/__init__.py b/src/modules/boot_log/__init__.py index 4cb82f60..51d3bcd6 100644 --- a/src/modules/boot_log/__init__.py +++ b/src/modules/boot_log/__init__.py @@ -15,7 +15,7 @@ __title__ = 'modules.boot_log' __author__ = 'Sven Heidemann' __license__ = 'MIT' __copyright__ = 'Copyright (c) 2022 sh-edraft.de' -__version__ = '0.2.0' +__version__ = '0.2.1' from collections import namedtuple @@ -23,4 +23,4 @@ from collections import namedtuple # imports: VersionInfo = namedtuple('VersionInfo', 'major minor micro') -version_info = VersionInfo(major='0', minor='2', micro='0') +version_info = VersionInfo(major='0', minor='2', micro='1') diff --git a/src/modules/boot_log/configuration/__init__.py b/src/modules/boot_log/configuration/__init__.py index 307f52fb..272c31fe 100644 --- a/src/modules/boot_log/configuration/__init__.py +++ b/src/modules/boot_log/configuration/__init__.py @@ -15,7 +15,7 @@ __title__ = 'modules.boot_log.configuration' __author__ = 'Sven Heidemann' __license__ = 'MIT' __copyright__ = 'Copyright (c) 2022 sh-edraft.de' -__version__ = '0.2.0' +__version__ = '0.2.1' from collections import namedtuple @@ -23,4 +23,4 @@ from collections import namedtuple # imports: VersionInfo = namedtuple('VersionInfo', 'major minor micro') -version_info = VersionInfo(major='0', minor='2', micro='0') +version_info = VersionInfo(major='0', minor='2', micro='1') diff --git a/src/modules/database/__init__.py b/src/modules/database/__init__.py index 5ffb50d2..60ccad62 100644 --- a/src/modules/database/__init__.py +++ b/src/modules/database/__init__.py @@ -15,7 +15,7 @@ __title__ = 'modules.database' __author__ = 'Sven Heidemann' __license__ = 'MIT' __copyright__ = 'Copyright (c) 2022 sh-edraft.de' -__version__ = '0.2.0' +__version__ = '0.2.1' from collections import namedtuple @@ -23,4 +23,4 @@ from collections import namedtuple # imports: VersionInfo = namedtuple('VersionInfo', 'major minor micro') -version_info = VersionInfo(major='0', minor='2', micro='0') +version_info = VersionInfo(major='0', minor='2', micro='1') diff --git a/src/modules/moderator/__init__.py b/src/modules/moderator/__init__.py index 613869fb..e87f4143 100644 --- a/src/modules/moderator/__init__.py +++ b/src/modules/moderator/__init__.py @@ -15,7 +15,7 @@ __title__ = 'modules.moderator' __author__ = 'Sven Heidemann' __license__ = 'MIT' __copyright__ = 'Copyright (c) 2022 sh-edraft.de' -__version__ = '0.2.0' +__version__ = '0.2.1' from collections import namedtuple @@ -23,4 +23,4 @@ from collections import namedtuple # imports: VersionInfo = namedtuple('VersionInfo', 'major minor micro') -version_info = VersionInfo(major='0', minor='2', micro='0') +version_info = VersionInfo(major='0', minor='2', micro='1') diff --git a/src/modules/moderator/command/__init__.py b/src/modules/moderator/command/__init__.py index 17bf6f16..eab82f4c 100644 --- a/src/modules/moderator/command/__init__.py +++ b/src/modules/moderator/command/__init__.py @@ -15,7 +15,7 @@ __title__ = 'modules.moderator.command' __author__ = 'Sven Heidemann' __license__ = 'MIT' __copyright__ = 'Copyright (c) 2022 sh-edraft.de' -__version__ = '0.2.0' +__version__ = '0.2.1' from collections import namedtuple @@ -23,4 +23,4 @@ from collections import namedtuple # imports: VersionInfo = namedtuple('VersionInfo', 'major minor micro') -version_info = VersionInfo(major='0', minor='2', micro='0') +version_info = VersionInfo(major='0', minor='2', micro='1') diff --git a/src/modules/permission/__init__.py b/src/modules/permission/__init__.py index 58467172..cf6a319d 100644 --- a/src/modules/permission/__init__.py +++ b/src/modules/permission/__init__.py @@ -15,7 +15,7 @@ __title__ = 'modules.permission' __author__ = 'Sven Heidemann' __license__ = 'MIT' __copyright__ = 'Copyright (c) 2022 sh-edraft.de' -__version__ = '0.2.0' +__version__ = '0.2.1' from collections import namedtuple @@ -23,4 +23,4 @@ from collections import namedtuple # imports: VersionInfo = namedtuple('VersionInfo', 'major minor micro') -version_info = VersionInfo(major='0', minor='2', micro='0') +version_info = VersionInfo(major='0', minor='2', micro='1') diff --git a/src/modules/permission/abc/__init__.py b/src/modules/permission/abc/__init__.py index c78ae287..60564ef0 100644 --- a/src/modules/permission/abc/__init__.py +++ b/src/modules/permission/abc/__init__.py @@ -15,7 +15,7 @@ __title__ = 'modules.permission.abc' __author__ = 'Sven Heidemann' __license__ = 'MIT' __copyright__ = 'Copyright (c) 2022 sh-edraft.de' -__version__ = '0.2.0' +__version__ = '0.2.1' from collections import namedtuple @@ -23,4 +23,4 @@ from collections import namedtuple # imports VersionInfo = namedtuple('VersionInfo', 'major minor micro') -version_info = VersionInfo(major='0', minor='2', micro='0') +version_info = VersionInfo(major='0', minor='2', micro='1') diff --git a/src/modules/permission/configuration/__init__.py b/src/modules/permission/configuration/__init__.py index aab3d9e0..38130ee2 100644 --- a/src/modules/permission/configuration/__init__.py +++ b/src/modules/permission/configuration/__init__.py @@ -15,7 +15,7 @@ __title__ = 'modules.permission.configuration' __author__ = 'Sven Heidemann' __license__ = 'MIT' __copyright__ = 'Copyright (c) 2022 sh-edraft.de' -__version__ = '0.2.0' +__version__ = '0.2.1' from collections import namedtuple @@ -23,4 +23,4 @@ from collections import namedtuple # imports VersionInfo = namedtuple('VersionInfo', 'major minor micro') -version_info = VersionInfo(major='0', minor='2', micro='0') +version_info = VersionInfo(major='0', minor='2', micro='1') diff --git a/src/modules/permission/events/__init__.py b/src/modules/permission/events/__init__.py index 3cad9c9d..787bc5d4 100644 --- a/src/modules/permission/events/__init__.py +++ b/src/modules/permission/events/__init__.py @@ -15,7 +15,7 @@ __title__ = 'modules.permission.events' __author__ = 'Sven Heidemann' __license__ = 'MIT' __copyright__ = 'Copyright (c) 2022 sh-edraft.de' -__version__ = '0.2.0' +__version__ = '0.2.1' from collections import namedtuple @@ -23,4 +23,4 @@ from collections import namedtuple # imports: VersionInfo = namedtuple('VersionInfo', 'major minor micro') -version_info = VersionInfo(major='0', minor='2', micro='0') +version_info = VersionInfo(major='0', minor='2', micro='1') diff --git a/src/modules/permission/service/__init__.py b/src/modules/permission/service/__init__.py index d3071613..d01084e6 100644 --- a/src/modules/permission/service/__init__.py +++ b/src/modules/permission/service/__init__.py @@ -15,7 +15,7 @@ __title__ = 'modules.permission.service' __author__ = 'Sven Heidemann' __license__ = 'MIT' __copyright__ = 'Copyright (c) 2022 sh-edraft.de' -__version__ = '0.2.0' +__version__ = '0.2.1' from collections import namedtuple @@ -23,4 +23,4 @@ from collections import namedtuple # imports VersionInfo = namedtuple('VersionInfo', 'major minor micro') -version_info = VersionInfo(major='0', minor='2', micro='0') +version_info = VersionInfo(major='0', minor='2', micro='1')