From a57c8da72a6a88d3b278162d9056978acbf078fb Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Tue, 8 Nov 2022 20:28:44 +0100 Subject: [PATCH] Added logic to call statistics #46 --- kdb-bot/cpl-workspace.json | 3 ++- kdb-bot/src/bot/module_list.py | 2 ++ kdb-bot/src/bot_api/abc/__init__.py | 2 +- kdb-bot/src/bot_core/abc/__init__.py | 2 +- .../configuration/feature_flags_enum.py | 2 +- .../configuration/feature_flags_settings.py | 1 + kdb-bot/src/bot_data/abc/__init__.py | 2 +- kdb-bot/src/modules/base/abc/__init__.py | 2 +- .../src/modules/permission/abc/__init__.py | 2 +- kdb-bot/src/modules/stats/stats_module.py | 24 +++++++++++++++++++ kdb-bot/src/modules/stats/test/__init__.py | 0 11 files changed, 35 insertions(+), 7 deletions(-) create mode 100644 kdb-bot/src/modules/stats/stats_module.py create mode 100644 kdb-bot/src/modules/stats/test/__init__.py diff --git a/kdb-bot/cpl-workspace.json b/kdb-bot/cpl-workspace.json index fa9a4332ee..6587cbf66d 100644 --- a/kdb-bot/cpl-workspace.json +++ b/kdb-bot/cpl-workspace.json @@ -3,6 +3,7 @@ "DefaultProject": "bot", "Projects": { "bot": "src/bot/bot.json", + "bot-api": "src/bot_api/bot-api.json", "bot-core": "src/bot_core/bot-core.json", "bot-data": "src/bot_data/bot-data.json", "auto-role": "src/modules/auto_role/auto-role.json", @@ -11,7 +12,7 @@ "database": "src/modules/database/database.json", "level": "src/modules/level/level.json", "permission": "src/modules/permission/permission.json", - "bot-api": "src/bot_api/bot-api.json", + "stats": "src/modules/stats/stats.json", "get-version": "tools/get_version/get-version.json", "post-build": "tools/post_build/post-build.json", "set-version": "tools/set_version/set-version.json" diff --git a/kdb-bot/src/bot/module_list.py b/kdb-bot/src/bot/module_list.py index 575824f3c4..3eb60cd3e1 100644 --- a/kdb-bot/src/bot/module_list.py +++ b/kdb-bot/src/bot/module_list.py @@ -10,6 +10,7 @@ from modules.boot_log.boot_log_module import BootLogModule from modules.database.database_module import DatabaseModule from modules.level.level_module import LevelModule from modules.permission.permission_module import PermissionModule +from modules.stats.stats_module import StatsModule class ModuleList: @@ -26,6 +27,7 @@ class ModuleList: LevelModule, PermissionModule, ApiModule, + StatsModule, # has to be last! BootLogModule, CoreExtensionModule, diff --git a/kdb-bot/src/bot_api/abc/__init__.py b/kdb-bot/src/bot_api/abc/__init__.py index 20368eb69a..ad4cf62626 100644 --- a/kdb-bot/src/bot_api/abc/__init__.py +++ b/kdb-bot/src/bot_api/abc/__init__.py @@ -11,7 +11,7 @@ Discord bot for the Keksdose discord Server """ -__title__ = 'bot_api.abc' +__title__ = 'bot_api.service' __author__ = 'Sven Heidemann' __license__ = 'MIT' __copyright__ = 'Copyright (c) 2022 sh-edraft.de' diff --git a/kdb-bot/src/bot_core/abc/__init__.py b/kdb-bot/src/bot_core/abc/__init__.py index 4056210a9a..1266f4f1ea 100644 --- a/kdb-bot/src/bot_core/abc/__init__.py +++ b/kdb-bot/src/bot_core/abc/__init__.py @@ -11,7 +11,7 @@ Discord bot for the Keksdose discord Server """ -__title__ = 'bot_core.abc' +__title__ = 'bot_core.service' __author__ = 'Sven Heidemann' __license__ = 'MIT' __copyright__ = 'Copyright (c) 2022 sh-edraft.de' diff --git a/kdb-bot/src/bot_core/configuration/feature_flags_enum.py b/kdb-bot/src/bot_core/configuration/feature_flags_enum.py index 226ca1d8e0..f04e5ca7b9 100644 --- a/kdb-bot/src/bot_core/configuration/feature_flags_enum.py +++ b/kdb-bot/src/bot_core/configuration/feature_flags_enum.py @@ -2,7 +2,6 @@ from enum import Enum class FeatureFlagsEnum(Enum): - # modules api_module = 'ApiModule' admin_module = 'AdminModule' @@ -16,6 +15,7 @@ class FeatureFlagsEnum(Enum): level_module = 'LevelModule' moderator_module = 'ModeratorModule' permission_module = 'PermissionModule' + stats_module = 'StatsModule' # features api_only = 'ApiOnly' presence = 'Presence' diff --git a/kdb-bot/src/bot_core/configuration/feature_flags_settings.py b/kdb-bot/src/bot_core/configuration/feature_flags_settings.py index 1861f9a115..dff28c6ed0 100644 --- a/kdb-bot/src/bot_core/configuration/feature_flags_settings.py +++ b/kdb-bot/src/bot_core/configuration/feature_flags_settings.py @@ -25,6 +25,7 @@ class FeatureFlagsSettings(ConfigurationModelABC): 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 + FeatureFlagsEnum.stats_module.value: True, # 08.11.2022 #46 # features FeatureFlagsEnum.api_only.value: False, # 13.10.2022 #70 FeatureFlagsEnum.presence.value: True, # 03.10.2022 #56 diff --git a/kdb-bot/src/bot_data/abc/__init__.py b/kdb-bot/src/bot_data/abc/__init__.py index 7209be452e..c2b4323a57 100644 --- a/kdb-bot/src/bot_data/abc/__init__.py +++ b/kdb-bot/src/bot_data/abc/__init__.py @@ -11,7 +11,7 @@ Discord bot for the Keksdose discord Server """ -__title__ = 'bot_data.abc' +__title__ = 'bot_data.service' __author__ = 'Sven Heidemann' __license__ = 'MIT' __copyright__ = 'Copyright (c) 2022 sh-edraft.de' diff --git a/kdb-bot/src/modules/base/abc/__init__.py b/kdb-bot/src/modules/base/abc/__init__.py index ccc3e98a76..411815170a 100644 --- a/kdb-bot/src/modules/base/abc/__init__.py +++ b/kdb-bot/src/modules/base/abc/__init__.py @@ -11,7 +11,7 @@ Discord bot for the Keksdose discord Server """ -__title__ = 'modules.base.abc' +__title__ = 'modules.base.service' __author__ = 'Sven Heidemann' __license__ = 'MIT' __copyright__ = 'Copyright (c) 2022 sh-edraft.de' diff --git a/kdb-bot/src/modules/permission/abc/__init__.py b/kdb-bot/src/modules/permission/abc/__init__.py index 294d277c41..930246c113 100644 --- a/kdb-bot/src/modules/permission/abc/__init__.py +++ b/kdb-bot/src/modules/permission/abc/__init__.py @@ -11,7 +11,7 @@ Discord bot for the Keksdose discord Server """ -__title__ = 'modules.permission.abc' +__title__ = 'modules.permission.service' __author__ = 'Sven Heidemann' __license__ = 'MIT' __copyright__ = 'Copyright (c) 2022 sh-edraft.de' diff --git a/kdb-bot/src/modules/stats/stats_module.py b/kdb-bot/src/modules/stats/stats_module.py new file mode 100644 index 0000000000..4c60b02a98 --- /dev/null +++ b/kdb-bot/src/modules/stats/stats_module.py @@ -0,0 +1,24 @@ +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_core.configuration.feature_flags_enum import FeatureFlagsEnum +from modules.stats.command.stats_group import StatsGroup +from modules.stats.service.statistic_service import StatisticService + + +class StatsModule(ModuleABC): + + def __init__(self, dc: DiscordCollectionABC): + ModuleABC.__init__(self, dc, FeatureFlagsEnum.stats_module) + + def configure_configuration(self, config: ConfigurationABC, env: ApplicationEnvironmentABC): + pass + + def configure_services(self, services: ServiceCollectionABC, env: ApplicationEnvironmentABC): + services.add_transient(StatisticService) + # commands + self._dc.add_command(StatsGroup) + # events diff --git a/kdb-bot/src/modules/stats/test/__init__.py b/kdb-bot/src/modules/stats/test/__init__.py new file mode 100644 index 0000000000..e69de29bb2