diff --git a/.gitea/workflows/deploy_dev.yaml b/.gitea/workflows/deploy_dev.yaml index 7d1db445..5b7485a1 100644 --- a/.gitea/workflows/deploy_dev.yaml +++ b/.gitea/workflows/deploy_dev.yaml @@ -24,17 +24,17 @@ jobs: uses: https://github.com/actions/checkout@v3 - name: Shutdown stack - run: docker stack rm kdb_staging + run: docker stack rm sdb_staging - name: Prepare bot build run: | - cd kdb-bot + cd bot pip install --extra-index-url https://pip.sh-edraft.de cpl-cli cpl i - name: Build docker bot run: | - cd kdb-bot + cd bot docker image prune -f cpl docker-build @@ -43,13 +43,13 @@ jobs: - name: Prepare web build run: | - cd kdb-web + cd web npm install -g ts-node npm i - name: Build docker web run: | - cd kdb-web + cd web docker image prune -f npm run docker-build @@ -60,6 +60,6 @@ jobs: portainer-username: "gitea_job" portainer-password: "${{ secrets.docker_job }}" portainer-endpoint: 2 - name: kdb_staging + name: sdb_staging file: ./docker-compose.staging.yml variables: '{}' diff --git a/.gitea/workflows/deploy_prod.yaml b/.gitea/workflows/deploy_prod.yaml index 08273018..bf530ed8 100644 --- a/.gitea/workflows/deploy_prod.yaml +++ b/.gitea/workflows/deploy_prod.yaml @@ -24,17 +24,17 @@ jobs: uses: https://github.com/actions/checkout@v3 - name: Shutdown stack - run: docker stack rm kdb_prod + run: docker stack rm sdb_prod - name: Prepare bot build run: | - cd kdb-bot + cd bot pip install --extra-index-url https://pip.sh-edraft.de cpl-cli cpl i - name: Build docker bot run: | - cd kdb-bot + cd bot docker image prune -f cpl docker-build @@ -43,13 +43,13 @@ jobs: - name: Prepare web build run: | - cd kdb-web + cd web npm install -g ts-node npm i - name: Build docker web run: | - cd kdb-web + cd web docker image prune -f npm run docker-build @@ -60,6 +60,6 @@ jobs: portainer-username: "gitea_job" portainer-password: "${{ secrets.docker_job }}" portainer-endpoint: 2 - name: kdb_prod + name: sdb_prod file: ./docker-compose.yml variables: '{}' diff --git a/.gitmodules b/.gitmodules index ca793c6c..f72ea2ba 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,9 +1,9 @@ -[submodule "kdb-bot/src/bot/config"] - path = kdb-bot/src/bot/config - url = https://git.sh-edraft.de/sh-edraft.de/kd_discord_bot.config.git -[submodule "kdb-bot/src/bot_api/config"] - path = kdb-bot/src/bot_api/config - url = https://git.sh-edraft.de/sh-edraft.de/kd_discord_bot.api.config.git -[submodule "kdb-bot/docker"] - path = kdb-bot/docker - url = https://git.sh-edraft.de/sh-edraft.de/kd_discord_bot.docker.git +[submodule "bot/src/bot/config"] + path = bot/src/bot/config + url = https://git.sh-edraft.de/sh-edraft.de/sh_discord_bot.config.git +[submodule "bot/src/bot_api/config"] + path = bot/src/bot_api/config + url = https://git.sh-edraft.de/sh-edraft.de/sh_discord_bot.api.config.git +[submodule "bot/docker"] + path = bot/docker + url = https://git.sh-edraft.de/sh-edraft.de/sh_discord_bot.docker.git diff --git a/kdb-bot/.cpl/schematic_db_table.py b/bot/.cpl/schematic_db_table.py similarity index 100% rename from kdb-bot/.cpl/schematic_db_table.py rename to bot/.cpl/schematic_db_table.py diff --git a/kdb-bot/.cpl/schematic_migration.py b/bot/.cpl/schematic_migration.py similarity index 100% rename from kdb-bot/.cpl/schematic_migration.py rename to bot/.cpl/schematic_migration.py diff --git a/kdb-bot/.cpl/schematic_query.py b/bot/.cpl/schematic_query.py similarity index 100% rename from kdb-bot/.cpl/schematic_query.py rename to bot/.cpl/schematic_query.py diff --git a/kdb-bot/LICENSE b/bot/LICENSE similarity index 100% rename from kdb-bot/LICENSE rename to bot/LICENSE diff --git a/kdb-bot/README.md b/bot/README.md similarity index 100% rename from kdb-bot/README.md rename to bot/README.md diff --git a/kdb-bot/cpl-workspace.json b/bot/cpl-workspace.json similarity index 83% rename from kdb-bot/cpl-workspace.json rename to bot/cpl-workspace.json index 8e010570..d08ceb87 100644 --- a/kdb-bot/cpl-workspace.json +++ b/bot/cpl-workspace.json @@ -17,6 +17,7 @@ "permission": "src/modules/permission/permission.json", "technician": "src/modules/technician/technician.json", "short-role-name": "src/modules/short_role_name/short-role-name.json", + "special-offers": "src/modules/special_offers/special-offers.json", "checks": "tools/checks/checks.json", "get-version": "tools/get_version/get-version.json", "post-build": "tools/post_build/post-build.json", @@ -31,12 +32,12 @@ "pre-build": "cpl set-version $ARGS; black ./;", "post-build": "cpl run post-build --dev; black ./;", "pre-prod": "cpl build", - "prod": "export KDB_ENVIRONMENT=production; export KDB_NAME=KDB-Prod; cpl start;", + "prod": "export SDB_ENVIRONMENT=production; export SDB_NAME=SDB-Prod; cpl start;", "pre-stage": "cpl build", - "stage": "export KDB_ENVIRONMENT=staging; export KDB_NAME=KDB-Stage; cpl start;", + "stage": "export SDB_ENVIRONMENT=staging; export SDB_NAME=SDB-Stage; cpl start;", "pre-dev": "cpl build", - "dev": "export KDB_ENVIRONMENT=development; export KDB_NAME=KDB-Dev; cpl start;", - "docker-build": "cpl build $ARGS; docker build -t sh-edraft.de/kdb-bot:$(cpl gv) .;", + "dev": "export SDB_ENVIRONMENT=development; export SDB_NAME=SDB-Dev; cpl start;", + "docker-build": "cpl build $ARGS; docker build -t sh-edraft.de/sdb-bot:$(cpl gv) .;", "dc-up": "docker-compose up -d", "dc-down": "docker-compose down", "docker": "cpl dc-down; cpl docker-build; cpl dc-up;" diff --git a/kdb-bot/dockerfile b/bot/dockerfile similarity index 94% rename from kdb-bot/dockerfile rename to bot/dockerfile index 478bf7e7..ad507c89 100644 --- a/kdb-bot/dockerfile +++ b/bot/dockerfile @@ -2,7 +2,7 @@ FROM python:3.10.4-alpine WORKDIR /app -COPY ./dist/bot/build/kdb-bot/ . +COPY ./dist/bot/build/bot/ . COPY ./dist/bot/build/requirements.txt . RUN python -m pip install --upgrade pip diff --git a/kdb-bot/pyproject.toml b/bot/pyproject.toml similarity index 100% rename from kdb-bot/pyproject.toml rename to bot/pyproject.toml diff --git a/kdb-bot/src/bot/__init__.py b/bot/src/bot/__init__.py similarity index 84% rename from kdb-bot/src/bot/__init__.py rename to bot/src/bot/__init__.py index 19b2ab5c..17f979c1 100644 --- a/kdb-bot/src/bot/__init__.py +++ b/bot/src/bot/__init__.py @@ -15,7 +15,7 @@ __title__ = "bot" __author__ = "Sven Heidemann" __license__ = "MIT" __copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de" -__version__ = "1.1.10" +__version__ = "1.2.0" from collections import namedtuple @@ -23,4 +23,4 @@ from collections import namedtuple # imports: VersionInfo = namedtuple("VersionInfo", "major minor micro") -version_info = VersionInfo(major="1", minor="1", micro="10") +version_info = VersionInfo(major="1", minor="2", micro="0") diff --git a/kdb-bot/src/bot/application.py b/bot/src/bot/application.py similarity index 94% rename from kdb-bot/src/bot/application.py rename to bot/src/bot/application.py index 13d46815..6d1e4dd9 100644 --- a/kdb-bot/src/bot/application.py +++ b/bot/src/bot/application.py @@ -8,6 +8,7 @@ from cpl_discord.service import DiscordBotServiceABC, DiscordBotService from cpl_translation import TranslatePipe, TranslationServiceABC, TranslationSettings from bot_api.api_thread import ApiThread +from bot_core.abc.task_abc import TaskABC from bot_core.configuration.feature_flags_enum import FeatureFlagsEnum from bot_core.configuration.feature_flags_settings import FeatureFlagsSettings from bot_core.service.data_integrity_service import DataIntegrityService @@ -29,6 +30,8 @@ class Application(DiscordBotApplicationABC): # cpl-translation self._translation: TranslationServiceABC = services.get_service(TranslationServiceABC) self._t: TranslatePipe = services.get_service(TranslatePipe) + # internal stuff + self._tasks = services.get_services(TaskABC) self._feature_flags: FeatureFlagsSettings = config.get_configuration(FeatureFlagsSettings) @@ -55,6 +58,9 @@ class Application(DiscordBotApplicationABC): return self._logger.info(__name__, f"Try to start {DiscordBotService.__name__}") + for task in self._tasks: + await self._bot.add_cog(task) + await self._bot.start_async() await self._bot.stop_async() except Exception as e: diff --git a/kdb-bot/src/bot/bot b/bot/src/bot/bot similarity index 100% rename from kdb-bot/src/bot/bot rename to bot/src/bot/bot diff --git a/kdb-bot/src/bot/bot.json b/bot/src/bot/bot.json similarity index 82% rename from kdb-bot/src/bot/bot.json rename to bot/src/bot/bot.json index 6cfefe9a..96b50f38 100644 --- a/kdb-bot/src/bot/bot.json +++ b/bot/src/bot/bot.json @@ -3,8 +3,8 @@ "Name": "bot", "Version": { "Major": "1", - "Minor": "1", - "Micro": "10" + "Minor": "2", + "Micro": "0" }, "Author": "Sven Heidemann", "AuthorEmail": "sven.heidemann@sh-edraft.de", @@ -16,22 +16,23 @@ "LicenseName": "MIT", "LicenseDescription": "MIT, see LICENSE for more details.", "Dependencies": [ - "cpl-core==2023.4.0.post5", + "cpl-core==2023.10.0", "cpl-translation==2023.4.0.post1", - "cpl-query==2023.4.0.post1", - "cpl-discord==2023.4.0.post3", - "Flask==2.3.2", - "Flask-Classful==0.14.2", + "cpl-query==2023.10.0", + "cpl-discord==2023.10.0.post1", + "Flask==3.0.0", + "Flask-Classful==0.16.0", "Flask-Cors==4.0.0", "PyJWT==2.8.0", "waitress==2.1.2", - "Flask-SocketIO==5.3.4", + "Flask-SocketIO==5.3.6", "eventlet==0.33.3", "requests-oauthlib==1.3.1", - "icmplib==3.0.3", + "icmplib==3.0.4", "ariadne==0.20.1", - "cryptography==41.0.2", - "discord>=2.3.2" + "cryptography==41.0.4", + "discord==2.3.2", + "bs4==0.0.1" ], "DevDependencies": [ "cpl-cli==2023.4.0.post3", @@ -69,6 +70,7 @@ "../modules/level/level.json", "../modules/permission/permission.json", "../modules/short_role_name/short-role-name.json", + "../modules/special_offers/special-offers.json", "../modules/technician/technician.json" ] } diff --git a/kdb-bot/src/bot/extension/__init__.py b/bot/src/bot/extension/__init__.py similarity index 84% rename from kdb-bot/src/bot/extension/__init__.py rename to bot/src/bot/extension/__init__.py index 613907d1..56d79a66 100644 --- a/kdb-bot/src/bot/extension/__init__.py +++ b/bot/src/bot/extension/__init__.py @@ -15,7 +15,7 @@ __title__ = "bot.extension" __author__ = "Sven Heidemann" __license__ = "MIT" __copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de" -__version__ = "1.1.10" +__version__ = "1.2.0" from collections import namedtuple @@ -23,4 +23,4 @@ from collections import namedtuple # imports: VersionInfo = namedtuple("VersionInfo", "major minor micro") -version_info = VersionInfo(major="1", minor="1", micro="10") +version_info = VersionInfo(major="1", minor="2", micro="0") diff --git a/kdb-bot/src/bot/extension/init_bot_extension.py b/bot/src/bot/extension/init_bot_extension.py similarity index 100% rename from kdb-bot/src/bot/extension/init_bot_extension.py rename to bot/src/bot/extension/init_bot_extension.py diff --git a/kdb-bot/src/bot/main.py b/bot/src/bot/main.py similarity index 100% rename from kdb-bot/src/bot/main.py rename to bot/src/bot/main.py diff --git a/kdb-bot/src/bot/module_list.py b/bot/src/bot/module_list.py similarity index 93% rename from kdb-bot/src/bot/module_list.py rename to bot/src/bot/module_list.py index 810a0851..88e99721 100644 --- a/kdb-bot/src/bot/module_list.py +++ b/bot/src/bot/module_list.py @@ -14,6 +14,7 @@ from modules.database.database_module import DatabaseModule from modules.level.level_module import LevelModule from modules.permission.permission_module import PermissionModule from modules.short_role_name.short_role_name_module import ShortRoleNameModule +from modules.special_offers.special_offers_module import SteamSpecialOffersModule from modules.technician.technician_module import TechnicianModule @@ -37,6 +38,7 @@ class ModuleList: TechnicianModule, AchievementsModule, ShortRoleNameModule, + SteamSpecialOffersModule, # has to be last! BootLogModule, CoreExtensionModule, diff --git a/kdb-bot/src/bot/startup.py b/bot/src/bot/startup.py similarity index 95% rename from kdb-bot/src/bot/startup.py rename to bot/src/bot/startup.py index 6895ddc8..0a5422d2 100644 --- a/kdb-bot/src/bot/startup.py +++ b/bot/src/bot/startup.py @@ -16,6 +16,7 @@ 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_core.logging.task_logger import TaskLogger from bot_data.db_context import DBContext @@ -43,6 +44,7 @@ class Startup(StartupABC): services.add_singleton(CustomFileLoggerABC, CommandLogger) services.add_singleton(CustomFileLoggerABC, DatabaseLogger) services.add_singleton(CustomFileLoggerABC, MessageLogger) + services.add_singleton(CustomFileLoggerABC, TaskLogger) if self._feature_flags.get_flag(FeatureFlagsEnum.api_module): services.add_singleton(CustomFileLoggerABC, ApiLogger) diff --git a/kdb-bot/src/bot/startup_discord_extension.py b/bot/src/bot/startup_discord_extension.py similarity index 100% rename from kdb-bot/src/bot/startup_discord_extension.py rename to bot/src/bot/startup_discord_extension.py diff --git a/kdb-bot/src/bot/startup_migration_extension.py b/bot/src/bot/startup_migration_extension.py similarity index 83% rename from kdb-bot/src/bot/startup_migration_extension.py rename to bot/src/bot/startup_migration_extension.py index bbf5f328..206262fb 100644 --- a/kdb-bot/src/bot/startup_migration_extension.py +++ b/bot/src/bot/startup_migration_extension.py @@ -9,18 +9,27 @@ from bot_data.migration.api_key_migration import ApiKeyMigration from bot_data.migration.api_migration import ApiMigration from bot_data.migration.auto_role_fix1_migration import AutoRoleFix1Migration from bot_data.migration.auto_role_migration import AutoRoleMigration -from bot_data.migration.config_feature_flags_migration import ConfigFeatureFlagsMigration +from bot_data.migration.birthday_migration import BirthdayMigration +from bot_data.migration.config_feature_flags_migration import ( + ConfigFeatureFlagsMigration, +) from bot_data.migration.config_migration import ConfigMigration from bot_data.migration.db_history_migration import DBHistoryMigration from bot_data.migration.default_role_migration import DefaultRoleMigration from bot_data.migration.fix_updates_migration import FixUpdatesMigration +from bot_data.migration.fix_user_history_migration import FixUserHistoryMigration from bot_data.migration.initial_migration import InitialMigration from bot_data.migration.level_migration import LevelMigration from bot_data.migration.remove_stats_migration import RemoveStatsMigration from bot_data.migration.short_role_name_migration import ShortRoleNameMigration -from bot_data.migration.short_role_name_only_highest_migration import ShortRoleNameOnlyHighestMigration +from bot_data.migration.short_role_name_only_highest_migration import ( + ShortRoleNameOnlyHighestMigration, +) from bot_data.migration.stats_migration import StatsMigration -from bot_data.migration.user_joined_game_server_migration import UserJoinedGameServerMigration +from bot_data.migration.steam_special_offer_migration import SteamSpecialOfferMigration +from bot_data.migration.user_joined_game_server_migration import ( + UserJoinedGameServerMigration, +) from bot_data.migration.user_message_count_per_hour_migration import ( UserMessageCountPerHourMigration, ) @@ -56,3 +65,6 @@ class StartupMigrationExtension(StartupExtensionABC): services.add_transient(MigrationABC, ShortRoleNameMigration) # 28.09.2023 #378 - 1.1.7 services.add_transient(MigrationABC, FixUpdatesMigration) # 28.09.2023 #378 - 1.1.7 services.add_transient(MigrationABC, ShortRoleNameOnlyHighestMigration) # 02.10.2023 #391 - 1.1.9 + services.add_transient(MigrationABC, FixUserHistoryMigration) # 10.10.2023 #401 - 1.2.0 + services.add_transient(MigrationABC, BirthdayMigration) # 10.10.2023 #401 - 1.2.0 + services.add_transient(MigrationABC, SteamSpecialOfferMigration) # 10.10.2023 #188 - 1.2.0 diff --git a/kdb-bot/src/bot/startup_module_extension.py b/bot/src/bot/startup_module_extension.py similarity index 100% rename from kdb-bot/src/bot/startup_module_extension.py rename to bot/src/bot/startup_module_extension.py diff --git a/kdb-bot/src/bot/startup_settings_extension.py b/bot/src/bot/startup_settings_extension.py similarity index 97% rename from kdb-bot/src/bot/startup_settings_extension.py rename to bot/src/bot/startup_settings_extension.py index caf34f19..ea5cfbca 100644 --- a/kdb-bot/src/bot/startup_settings_extension.py +++ b/bot/src/bot/startup_settings_extension.py @@ -17,7 +17,7 @@ class StartupSettingsExtension(StartupExtensionABC): def configure_configuration(self, configuration: ConfigurationABC, environment: ApplicationEnvironmentABC): # this shit has to be done here because we need settings in subsequent startup extensions environment.set_working_directory(os.path.dirname(os.path.realpath(__file__))) - configuration.add_environment_variables("KDB_") + configuration.add_environment_variables("SDB_") configuration.add_environment_variables("DISCORD_") configuration.add_json_file(f"config/appsettings.json", optional=False) diff --git a/kdb-bot/src/bot/translation/de.json b/bot/src/bot/translation/de.json similarity index 97% rename from kdb-bot/src/bot/translation/de.json rename to bot/src/bot/translation/de.json index c1390bdf..9f0a57fa 100644 --- a/kdb-bot/src/bot/translation/de.json +++ b/bot/src/bot/translation/de.json @@ -94,6 +94,11 @@ } }, "modules": { + "special_offers": { + "price": "Preis", + "discount": "Rabatt", + "discount_price": "Neuer Preis" + }, "achievements": { "commands": { "check": "Alles klar, ich schaue eben nach... nom nom" @@ -229,6 +234,11 @@ "success": "Verlinkung wurde entfernt :D" }, "user": { + "birthday": { + "has_birthday": "Alles Gute zum Geburtag {} :D", + "success": "Dein Geburtstag wurde eingetragen.", + "success_team": "{} hat seinen Geburtstag eingetragen: {}" + }, "add": { "xp": "Die {} von {} wurden um {} erhöht" }, diff --git a/kdb-bot/src/bot_api/__init__.py b/bot/src/bot_api/__init__.py similarity index 84% rename from kdb-bot/src/bot_api/__init__.py rename to bot/src/bot_api/__init__.py index bc48f01b..6a63c058 100644 --- a/kdb-bot/src/bot_api/__init__.py +++ b/bot/src/bot_api/__init__.py @@ -15,7 +15,7 @@ __title__ = "bot_api" __author__ = "Sven Heidemann" __license__ = "MIT" __copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de" -__version__ = "1.1.10" +__version__ = "1.2.0" from collections import namedtuple @@ -23,4 +23,4 @@ from collections import namedtuple # imports: VersionInfo = namedtuple("VersionInfo", "major minor micro") -version_info = VersionInfo(major="1", minor="1", micro="10") +version_info = VersionInfo(major="1", minor="2", micro="0") diff --git a/kdb-bot/src/bot_api/abc/__init__.py b/bot/src/bot_api/abc/__init__.py similarity index 84% rename from kdb-bot/src/bot_api/abc/__init__.py rename to bot/src/bot_api/abc/__init__.py index 6213503f..2133612b 100644 --- a/kdb-bot/src/bot_api/abc/__init__.py +++ b/bot/src/bot_api/abc/__init__.py @@ -15,7 +15,7 @@ __title__ = "bot_api.abc" __author__ = "Sven Heidemann" __license__ = "MIT" __copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de" -__version__ = "1.1.10" +__version__ = "1.2.0" from collections import namedtuple @@ -23,4 +23,4 @@ from collections import namedtuple # imports: VersionInfo = namedtuple("VersionInfo", "major minor micro") -version_info = VersionInfo(major="1", minor="1", micro="10") +version_info = VersionInfo(major="1", minor="2", micro="0") diff --git a/kdb-bot/src/bot_api/abc/auth_service_abc.py b/bot/src/bot_api/abc/auth_service_abc.py similarity index 100% rename from kdb-bot/src/bot_api/abc/auth_service_abc.py rename to bot/src/bot_api/abc/auth_service_abc.py diff --git a/kdb-bot/src/bot_api/abc/dto_abc.py b/bot/src/bot_api/abc/dto_abc.py similarity index 100% rename from kdb-bot/src/bot_api/abc/dto_abc.py rename to bot/src/bot_api/abc/dto_abc.py diff --git a/kdb-bot/src/bot_api/abc/select_criteria_abc.py b/bot/src/bot_api/abc/select_criteria_abc.py similarity index 100% rename from kdb-bot/src/bot_api/abc/select_criteria_abc.py rename to bot/src/bot_api/abc/select_criteria_abc.py diff --git a/kdb-bot/src/bot_api/abc/transformer_abc.py b/bot/src/bot_api/abc/transformer_abc.py similarity index 100% rename from kdb-bot/src/bot_api/abc/transformer_abc.py rename to bot/src/bot_api/abc/transformer_abc.py diff --git a/kdb-bot/src/bot_api/api.py b/bot/src/bot_api/api.py similarity index 97% rename from kdb-bot/src/bot_api/api.py rename to bot/src/bot_api/api.py index dd086b2d..84184695 100644 --- a/kdb-bot/src/bot_api/api.py +++ b/bot/src/bot_api/api.py @@ -149,7 +149,10 @@ class Api(Flask): return response def start(self): - self._logger.info(__name__, f"Starting API {self._api_settings.host}:{self._api_settings.port}") + self._logger.info( + __name__, + f"Starting API {self._api_settings.host}:{self._api_settings.port}", + ) self._register_routes() self.secret_key = CredentialManager.decrypt(self._auth_settings.secret_key) # from waitress import serve diff --git a/kdb-bot/src/bot_api/api_module.py b/bot/src/bot_api/api_module.py similarity index 96% rename from kdb-bot/src/bot_api/api_module.py rename to bot/src/bot_api/api_module.py index 8f40f95e..b2695e12 100644 --- a/kdb-bot/src/bot_api/api_module.py +++ b/bot/src/bot_api/api_module.py @@ -48,4 +48,4 @@ class ApiModule(ModuleABC): services.add_transient(GraphQLController) # cpl-discord - self._dc.add_event(DiscordEventTypesEnum.on_ready.value, BotApiOnReadyEvent) + services.add_transient(DiscordEventTypesEnum.on_ready.value, BotApiOnReadyEvent) diff --git a/kdb-bot/src/bot_api/api_thread.py b/bot/src/bot_api/api_thread.py similarity index 100% rename from kdb-bot/src/bot_api/api_thread.py rename to bot/src/bot_api/api_thread.py diff --git a/kdb-bot/src/bot_api/app_api_extension.py b/bot/src/bot_api/app_api_extension.py similarity index 100% rename from kdb-bot/src/bot_api/app_api_extension.py rename to bot/src/bot_api/app_api_extension.py diff --git a/kdb-bot/src/bot_api/bot-api.json b/bot/src/bot_api/bot-api.json similarity index 95% rename from kdb-bot/src/bot_api/bot-api.json rename to bot/src/bot_api/bot-api.json index cc6404cc..a4529c34 100644 --- a/kdb-bot/src/bot_api/bot-api.json +++ b/bot/src/bot_api/bot-api.json @@ -3,8 +3,8 @@ "Name": "bot-api", "Version": { "Major": "1", - "Minor": "1", - "Micro": "10" + "Minor": "2", + "Micro": "0" }, "Author": "", "AuthorEmail": "", diff --git a/kdb-bot/src/bot_api/configuration/__init__.py b/bot/src/bot_api/configuration/__init__.py similarity index 84% rename from kdb-bot/src/bot_api/configuration/__init__.py rename to bot/src/bot_api/configuration/__init__.py index f71552cc..36ddf985 100644 --- a/kdb-bot/src/bot_api/configuration/__init__.py +++ b/bot/src/bot_api/configuration/__init__.py @@ -15,7 +15,7 @@ __title__ = "bot_api.configuration" __author__ = "Sven Heidemann" __license__ = "MIT" __copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de" -__version__ = "1.1.10" +__version__ = "1.2.0" from collections import namedtuple @@ -23,4 +23,4 @@ from collections import namedtuple # imports VersionInfo = namedtuple("VersionInfo", "major minor micro") -version_info = VersionInfo(major="1", minor="1", micro="10") +version_info = VersionInfo(major="1", minor="2", micro="0") diff --git a/kdb-bot/src/bot_api/configuration/api_settings.py b/bot/src/bot_api/configuration/api_settings.py similarity index 100% rename from kdb-bot/src/bot_api/configuration/api_settings.py rename to bot/src/bot_api/configuration/api_settings.py diff --git a/kdb-bot/src/bot_api/configuration/authentication_settings.py b/bot/src/bot_api/configuration/authentication_settings.py similarity index 100% rename from kdb-bot/src/bot_api/configuration/authentication_settings.py rename to bot/src/bot_api/configuration/authentication_settings.py diff --git a/kdb-bot/src/bot_api/configuration/discord_authentication_settings.py b/bot/src/bot_api/configuration/discord_authentication_settings.py similarity index 100% rename from kdb-bot/src/bot_api/configuration/discord_authentication_settings.py rename to bot/src/bot_api/configuration/discord_authentication_settings.py diff --git a/kdb-bot/src/bot_api/configuration/frontend_settings.py b/bot/src/bot_api/configuration/frontend_settings.py similarity index 100% rename from kdb-bot/src/bot_api/configuration/frontend_settings.py rename to bot/src/bot_api/configuration/frontend_settings.py diff --git a/kdb-bot/src/bot_api/controller/__init__.py b/bot/src/bot_api/controller/__init__.py similarity index 84% rename from kdb-bot/src/bot_api/controller/__init__.py rename to bot/src/bot_api/controller/__init__.py index 7739be1a..71f6b6d6 100644 --- a/kdb-bot/src/bot_api/controller/__init__.py +++ b/bot/src/bot_api/controller/__init__.py @@ -15,7 +15,7 @@ __title__ = "bot_api.controller" __author__ = "Sven Heidemann" __license__ = "MIT" __copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de" -__version__ = "1.1.10" +__version__ = "1.2.0" from collections import namedtuple @@ -23,4 +23,4 @@ from collections import namedtuple # imports: VersionInfo = namedtuple("VersionInfo", "major minor micro") -version_info = VersionInfo(major="1", minor="1", micro="10") +version_info = VersionInfo(major="1", minor="2", micro="0") diff --git a/kdb-bot/src/bot_api/controller/auth_controller.py b/bot/src/bot_api/controller/auth_controller.py similarity index 100% rename from kdb-bot/src/bot_api/controller/auth_controller.py rename to bot/src/bot_api/controller/auth_controller.py diff --git a/kdb-bot/src/bot_api/controller/auth_discord_controller.py b/bot/src/bot_api/controller/auth_discord_controller.py similarity index 100% rename from kdb-bot/src/bot_api/controller/auth_discord_controller.py rename to bot/src/bot_api/controller/auth_discord_controller.py diff --git a/kdb-bot/src/bot_api/controller/graphql_controller.py b/bot/src/bot_api/controller/graphql_controller.py similarity index 100% rename from kdb-bot/src/bot_api/controller/graphql_controller.py rename to bot/src/bot_api/controller/graphql_controller.py diff --git a/kdb-bot/src/bot_api/controller/gui_controller.py b/bot/src/bot_api/controller/gui_controller.py similarity index 100% rename from kdb-bot/src/bot_api/controller/gui_controller.py rename to bot/src/bot_api/controller/gui_controller.py diff --git a/kdb-bot/src/bot_api/event/__init__.py b/bot/src/bot_api/event/__init__.py similarity index 84% rename from kdb-bot/src/bot_api/event/__init__.py rename to bot/src/bot_api/event/__init__.py index afcad881..9b08b3f9 100644 --- a/kdb-bot/src/bot_api/event/__init__.py +++ b/bot/src/bot_api/event/__init__.py @@ -15,7 +15,7 @@ __title__ = "bot_api.event" __author__ = "Sven Heidemann" __license__ = "MIT" __copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de" -__version__ = "1.1.10" +__version__ = "1.2.0" from collections import namedtuple @@ -23,4 +23,4 @@ from collections import namedtuple # imports: VersionInfo = namedtuple("VersionInfo", "major minor micro") -version_info = VersionInfo(major="1", minor="1", micro="10") +version_info = VersionInfo(major="1", minor="2", micro="0") diff --git a/kdb-bot/src/bot_api/event/bot_api_on_ready_event.py b/bot/src/bot_api/event/bot_api_on_ready_event.py similarity index 100% rename from kdb-bot/src/bot_api/event/bot_api_on_ready_event.py rename to bot/src/bot_api/event/bot_api_on_ready_event.py diff --git a/kdb-bot/src/bot_api/exception/__init__.py b/bot/src/bot_api/exception/__init__.py similarity index 84% rename from kdb-bot/src/bot_api/exception/__init__.py rename to bot/src/bot_api/exception/__init__.py index 2b9e3b21..472e48c6 100644 --- a/kdb-bot/src/bot_api/exception/__init__.py +++ b/bot/src/bot_api/exception/__init__.py @@ -15,7 +15,7 @@ __title__ = "bot_api.exception" __author__ = "Sven Heidemann" __license__ = "MIT" __copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de" -__version__ = "1.1.10" +__version__ = "1.2.0" from collections import namedtuple @@ -23,4 +23,4 @@ from collections import namedtuple # imports: VersionInfo = namedtuple("VersionInfo", "major minor micro") -version_info = VersionInfo(major="1", minor="1", micro="10") +version_info = VersionInfo(major="1", minor="2", micro="0") diff --git a/kdb-bot/src/bot_api/exception/service_error_code_enum.py b/bot/src/bot_api/exception/service_error_code_enum.py similarity index 100% rename from kdb-bot/src/bot_api/exception/service_error_code_enum.py rename to bot/src/bot_api/exception/service_error_code_enum.py diff --git a/kdb-bot/src/bot_api/exception/service_exception.py b/bot/src/bot_api/exception/service_exception.py similarity index 100% rename from kdb-bot/src/bot_api/exception/service_exception.py rename to bot/src/bot_api/exception/service_exception.py diff --git a/kdb-bot/src/bot_api/filter/__init__.py b/bot/src/bot_api/filter/__init__.py similarity index 84% rename from kdb-bot/src/bot_api/filter/__init__.py rename to bot/src/bot_api/filter/__init__.py index bf6ccb2e..4629177d 100644 --- a/kdb-bot/src/bot_api/filter/__init__.py +++ b/bot/src/bot_api/filter/__init__.py @@ -15,7 +15,7 @@ __title__ = "bot_api.filter" __author__ = "Sven Heidemann" __license__ = "MIT" __copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de" -__version__ = "1.1.10" +__version__ = "1.2.0" from collections import namedtuple @@ -23,4 +23,4 @@ from collections import namedtuple # imports: VersionInfo = namedtuple("VersionInfo", "major minor micro") -version_info = VersionInfo(major="1", minor="1", micro="10") +version_info = VersionInfo(major="1", minor="2", micro="0") diff --git a/kdb-bot/src/bot_api/filter/auth_user_select_criteria.py b/bot/src/bot_api/filter/auth_user_select_criteria.py similarity index 100% rename from kdb-bot/src/bot_api/filter/auth_user_select_criteria.py rename to bot/src/bot_api/filter/auth_user_select_criteria.py diff --git a/kdb-bot/src/bot_api/filter/discord/__init__.py b/bot/src/bot_api/filter/discord/__init__.py similarity index 84% rename from kdb-bot/src/bot_api/filter/discord/__init__.py rename to bot/src/bot_api/filter/discord/__init__.py index 4c116cef..81083cb5 100644 --- a/kdb-bot/src/bot_api/filter/discord/__init__.py +++ b/bot/src/bot_api/filter/discord/__init__.py @@ -15,7 +15,7 @@ __title__ = "bot_api.filter.discord" __author__ = "Sven Heidemann" __license__ = "MIT" __copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de" -__version__ = "1.1.10" +__version__ = "1.2.0" from collections import namedtuple @@ -23,4 +23,4 @@ from collections import namedtuple # imports: VersionInfo = namedtuple("VersionInfo", "major minor micro") -version_info = VersionInfo(major="1", minor="1", micro="10") +version_info = VersionInfo(major="1", minor="2", micro="0") diff --git a/kdb-bot/src/bot_api/filter/discord/server_select_criteria.py b/bot/src/bot_api/filter/discord/server_select_criteria.py similarity index 100% rename from kdb-bot/src/bot_api/filter/discord/server_select_criteria.py rename to bot/src/bot_api/filter/discord/server_select_criteria.py diff --git a/kdb-bot/src/bot_api/json_processor.py b/bot/src/bot_api/json_processor.py similarity index 100% rename from kdb-bot/src/bot_api/json_processor.py rename to bot/src/bot_api/json_processor.py diff --git a/kdb-bot/src/bot_api/logging/__init__.py b/bot/src/bot_api/logging/__init__.py similarity index 84% rename from kdb-bot/src/bot_api/logging/__init__.py rename to bot/src/bot_api/logging/__init__.py index de51a5e8..28229873 100644 --- a/kdb-bot/src/bot_api/logging/__init__.py +++ b/bot/src/bot_api/logging/__init__.py @@ -15,7 +15,7 @@ __title__ = "bot_api.logging" __author__ = "Sven Heidemann" __license__ = "MIT" __copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de" -__version__ = "1.1.10" +__version__ = "1.2.0" from collections import namedtuple @@ -23,4 +23,4 @@ from collections import namedtuple # imports: VersionInfo = namedtuple("VersionInfo", "major minor micro") -version_info = VersionInfo(major="1", minor="1", micro="10") +version_info = VersionInfo(major="1", minor="2", micro="0") diff --git a/kdb-bot/src/bot_api/logging/api_logger.py b/bot/src/bot_api/logging/api_logger.py similarity index 100% rename from kdb-bot/src/bot_api/logging/api_logger.py rename to bot/src/bot_api/logging/api_logger.py diff --git a/kdb-bot/src/bot_api/model/__init__.py b/bot/src/bot_api/model/__init__.py similarity index 84% rename from kdb-bot/src/bot_api/model/__init__.py rename to bot/src/bot_api/model/__init__.py index 6738fef5..428e3ced 100644 --- a/kdb-bot/src/bot_api/model/__init__.py +++ b/bot/src/bot_api/model/__init__.py @@ -15,7 +15,7 @@ __title__ = "bot_api.model" __author__ = "Sven Heidemann" __license__ = "MIT" __copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de" -__version__ = "1.1.10" +__version__ = "1.2.0" from collections import namedtuple @@ -23,4 +23,4 @@ from collections import namedtuple # imports: VersionInfo = namedtuple("VersionInfo", "major minor micro") -version_info = VersionInfo(major="1", minor="1", micro="10") +version_info = VersionInfo(major="1", minor="2", micro="0") diff --git a/kdb-bot/src/bot_api/model/auth_user_dto.py b/bot/src/bot_api/model/auth_user_dto.py similarity index 100% rename from kdb-bot/src/bot_api/model/auth_user_dto.py rename to bot/src/bot_api/model/auth_user_dto.py diff --git a/kdb-bot/src/bot_api/model/auth_user_filtered_result_dto.py b/bot/src/bot_api/model/auth_user_filtered_result_dto.py similarity index 100% rename from kdb-bot/src/bot_api/model/auth_user_filtered_result_dto.py rename to bot/src/bot_api/model/auth_user_filtered_result_dto.py diff --git a/kdb-bot/src/bot_api/model/discord/__init__.py b/bot/src/bot_api/model/discord/__init__.py similarity index 84% rename from kdb-bot/src/bot_api/model/discord/__init__.py rename to bot/src/bot_api/model/discord/__init__.py index cc131151..0b731ed3 100644 --- a/kdb-bot/src/bot_api/model/discord/__init__.py +++ b/bot/src/bot_api/model/discord/__init__.py @@ -15,7 +15,7 @@ __title__ = "bot_api.model.discord" __author__ = "Sven Heidemann" __license__ = "MIT" __copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de" -__version__ = "1.1.10" +__version__ = "1.2.0" from collections import namedtuple @@ -23,4 +23,4 @@ from collections import namedtuple # imports: VersionInfo = namedtuple("VersionInfo", "major minor micro") -version_info = VersionInfo(major="1", minor="1", micro="10") +version_info = VersionInfo(major="1", minor="2", micro="0") diff --git a/kdb-bot/src/bot_api/model/discord/server_dto.py b/bot/src/bot_api/model/discord/server_dto.py similarity index 100% rename from kdb-bot/src/bot_api/model/discord/server_dto.py rename to bot/src/bot_api/model/discord/server_dto.py diff --git a/kdb-bot/src/bot_api/model/discord/server_filtered_result_dto.py b/bot/src/bot_api/model/discord/server_filtered_result_dto.py similarity index 100% rename from kdb-bot/src/bot_api/model/discord/server_filtered_result_dto.py rename to bot/src/bot_api/model/discord/server_filtered_result_dto.py diff --git a/kdb-bot/src/bot_api/model/email_string_dto.py b/bot/src/bot_api/model/email_string_dto.py similarity index 100% rename from kdb-bot/src/bot_api/model/email_string_dto.py rename to bot/src/bot_api/model/email_string_dto.py diff --git a/kdb-bot/src/bot_api/model/error_dto.py b/bot/src/bot_api/model/error_dto.py similarity index 100% rename from kdb-bot/src/bot_api/model/error_dto.py rename to bot/src/bot_api/model/error_dto.py diff --git a/kdb-bot/src/bot_api/model/o_auth_dto.py b/bot/src/bot_api/model/o_auth_dto.py similarity index 100% rename from kdb-bot/src/bot_api/model/o_auth_dto.py rename to bot/src/bot_api/model/o_auth_dto.py diff --git a/kdb-bot/src/bot_api/model/reset_password_dto.py b/bot/src/bot_api/model/reset_password_dto.py similarity index 100% rename from kdb-bot/src/bot_api/model/reset_password_dto.py rename to bot/src/bot_api/model/reset_password_dto.py diff --git a/kdb-bot/src/bot_api/model/settings_dto.py b/bot/src/bot_api/model/settings_dto.py similarity index 100% rename from kdb-bot/src/bot_api/model/settings_dto.py rename to bot/src/bot_api/model/settings_dto.py diff --git a/kdb-bot/src/bot_api/model/token_dto.py b/bot/src/bot_api/model/token_dto.py similarity index 82% rename from kdb-bot/src/bot_api/model/token_dto.py rename to bot/src/bot_api/model/token_dto.py index 88ff8501..f8c98922 100644 --- a/kdb-bot/src/bot_api/model/token_dto.py +++ b/bot/src/bot_api/model/token_dto.py @@ -27,4 +27,8 @@ class TokenDTO(DtoABC): self._first_login = values["firstLogin"] def to_dict(self) -> dict: - return {"token": self._token, "refreshToken": self._refresh_token, "firstLogin": self._first_login} + return { + "token": self._token, + "refreshToken": self._refresh_token, + "firstLogin": self._first_login, + } diff --git a/kdb-bot/src/bot_api/model/update_auth_user_dto.py b/bot/src/bot_api/model/update_auth_user_dto.py similarity index 100% rename from kdb-bot/src/bot_api/model/update_auth_user_dto.py rename to bot/src/bot_api/model/update_auth_user_dto.py diff --git a/kdb-bot/src/bot_api/model/user_dto.py b/bot/src/bot_api/model/user_dto.py similarity index 100% rename from kdb-bot/src/bot_api/model/user_dto.py rename to bot/src/bot_api/model/user_dto.py diff --git a/kdb-bot/src/bot_api/model/version_dto.py b/bot/src/bot_api/model/version_dto.py similarity index 100% rename from kdb-bot/src/bot_api/model/version_dto.py rename to bot/src/bot_api/model/version_dto.py diff --git a/kdb-bot/src/bot_api/route/__init__.py b/bot/src/bot_api/route/__init__.py similarity index 84% rename from kdb-bot/src/bot_api/route/__init__.py rename to bot/src/bot_api/route/__init__.py index 388aa4b0..81792f2e 100644 --- a/kdb-bot/src/bot_api/route/__init__.py +++ b/bot/src/bot_api/route/__init__.py @@ -15,7 +15,7 @@ __title__ = "bot_api.route" __author__ = "Sven Heidemann" __license__ = "MIT" __copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de" -__version__ = "1.1.10" +__version__ = "1.2.0" from collections import namedtuple @@ -23,4 +23,4 @@ from collections import namedtuple # imports: VersionInfo = namedtuple("VersionInfo", "major minor micro") -version_info = VersionInfo(major="1", minor="1", micro="10") +version_info = VersionInfo(major="1", minor="2", micro="0") diff --git a/kdb-bot/src/bot_api/route/route.py b/bot/src/bot_api/route/route.py similarity index 94% rename from kdb-bot/src/bot_api/route/route.py rename to bot/src/bot_api/route/route.py index 74278f28..a72b28e3 100644 --- a/kdb-bot/src/bot_api/route/route.py +++ b/bot/src/bot_api/route/route.py @@ -25,7 +25,12 @@ class Route: @classmethod @ServiceProviderABC.inject - def init_authorize(cls, env: ApplicationEnvironmentABC, auth_users: AuthUserRepositoryABC, auth: AuthServiceABC): + def init_authorize( + cls, + env: ApplicationEnvironmentABC, + auth_users: AuthUserRepositoryABC, + auth: AuthServiceABC, + ): cls._auth_users = auth_users cls._auth = auth cls._env = env.environment_name @@ -52,7 +57,13 @@ class Route: return user @classmethod - def authorize(cls, f: Callable = None, role: AuthRoleEnum = None, skip_in_dev=False, by_api_key=False): + def authorize( + cls, + f: Callable = None, + role: AuthRoleEnum = None, + skip_in_dev=False, + by_api_key=False, + ): if f is None: return functools.partial(cls.authorize, role=role, skip_in_dev=skip_in_dev, by_api_key=by_api_key) diff --git a/kdb-bot/src/bot_api/service/__init__.py b/bot/src/bot_api/service/__init__.py similarity index 84% rename from kdb-bot/src/bot_api/service/__init__.py rename to bot/src/bot_api/service/__init__.py index 90c30c61..234af1ca 100644 --- a/kdb-bot/src/bot_api/service/__init__.py +++ b/bot/src/bot_api/service/__init__.py @@ -15,7 +15,7 @@ __title__ = "bot_api.service" __author__ = "Sven Heidemann" __license__ = "MIT" __copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de" -__version__ = "1.1.10" +__version__ = "1.2.0" from collections import namedtuple @@ -23,4 +23,4 @@ from collections import namedtuple # imports VersionInfo = namedtuple("VersionInfo", "major minor micro") -version_info = VersionInfo(major="1", minor="1", micro="10") +version_info = VersionInfo(major="1", minor="2", micro="0") diff --git a/kdb-bot/src/bot_api/service/auth_service.py b/bot/src/bot_api/service/auth_service.py similarity index 100% rename from kdb-bot/src/bot_api/service/auth_service.py rename to bot/src/bot_api/service/auth_service.py diff --git a/kdb-bot/src/bot_api/service/discord_service.py b/bot/src/bot_api/service/discord_service.py similarity index 100% rename from kdb-bot/src/bot_api/service/discord_service.py rename to bot/src/bot_api/service/discord_service.py diff --git a/kdb-bot/src/bot_api/transformer/__init__.py b/bot/src/bot_api/transformer/__init__.py similarity index 84% rename from kdb-bot/src/bot_api/transformer/__init__.py rename to bot/src/bot_api/transformer/__init__.py index 4e1c7916..f1f8e791 100644 --- a/kdb-bot/src/bot_api/transformer/__init__.py +++ b/bot/src/bot_api/transformer/__init__.py @@ -15,7 +15,7 @@ __title__ = "bot_api.transformer" __author__ = "Sven Heidemann" __license__ = "MIT" __copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de" -__version__ = "1.1.10" +__version__ = "1.2.0" from collections import namedtuple @@ -23,4 +23,4 @@ from collections import namedtuple # imports: VersionInfo = namedtuple("VersionInfo", "major minor micro") -version_info = VersionInfo(major="1", minor="1", micro="10") +version_info = VersionInfo(major="1", minor="2", micro="0") diff --git a/kdb-bot/src/bot_api/transformer/auth_user_transformer.py b/bot/src/bot_api/transformer/auth_user_transformer.py similarity index 100% rename from kdb-bot/src/bot_api/transformer/auth_user_transformer.py rename to bot/src/bot_api/transformer/auth_user_transformer.py diff --git a/kdb-bot/src/bot_api/transformer/server_transformer.py b/bot/src/bot_api/transformer/server_transformer.py similarity index 100% rename from kdb-bot/src/bot_api/transformer/server_transformer.py rename to bot/src/bot_api/transformer/server_transformer.py diff --git a/kdb-bot/src/bot_core/__init__.py b/bot/src/bot_core/__init__.py similarity index 84% rename from kdb-bot/src/bot_core/__init__.py rename to bot/src/bot_core/__init__.py index 805ee627..762b31f9 100644 --- a/kdb-bot/src/bot_core/__init__.py +++ b/bot/src/bot_core/__init__.py @@ -15,7 +15,7 @@ __title__ = "bot_core" __author__ = "Sven Heidemann" __license__ = "MIT" __copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de" -__version__ = "1.1.10" +__version__ = "1.2.0" from collections import namedtuple @@ -23,4 +23,4 @@ from collections import namedtuple # imports VersionInfo = namedtuple("VersionInfo", "major minor micro") -version_info = VersionInfo(major="1", minor="1", micro="10") +version_info = VersionInfo(major="1", minor="2", micro="0") diff --git a/kdb-bot/src/bot_core/abc/__init__.py b/bot/src/bot_core/abc/__init__.py similarity index 84% rename from kdb-bot/src/bot_core/abc/__init__.py rename to bot/src/bot_core/abc/__init__.py index f6eea2b3..09549563 100644 --- a/kdb-bot/src/bot_core/abc/__init__.py +++ b/bot/src/bot_core/abc/__init__.py @@ -15,7 +15,7 @@ __title__ = "bot_core.abc" __author__ = "Sven Heidemann" __license__ = "MIT" __copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de" -__version__ = "1.1.10" +__version__ = "1.2.0" from collections import namedtuple @@ -23,4 +23,4 @@ from collections import namedtuple # imports: VersionInfo = namedtuple("VersionInfo", "major minor micro") -version_info = VersionInfo(major="1", minor="1", micro="10") +version_info = VersionInfo(major="1", minor="2", micro="0") diff --git a/kdb-bot/src/bot_core/abc/client_utils_abc.py b/bot/src/bot_core/abc/client_utils_abc.py similarity index 92% rename from kdb-bot/src/bot_core/abc/client_utils_abc.py rename to bot/src/bot_core/abc/client_utils_abc.py index 045228cb..fdcf5118 100644 --- a/kdb-bot/src/bot_core/abc/client_utils_abc.py +++ b/bot/src/bot_core/abc/client_utils_abc.py @@ -64,7 +64,11 @@ class ClientUtilsABC(ABC): @abstractmethod async def react_to_message_by_auto_role_rule( - self, discord_channel_id: int, discord_message_id: int, rule: AutoRoleRule, guild: discord.Guild + self, + discord_channel_id: int, + discord_message_id: int, + rule: AutoRoleRule, + guild: discord.Guild, ): pass diff --git a/kdb-bot/src/bot_core/abc/custom_file_logger_abc.py b/bot/src/bot_core/abc/custom_file_logger_abc.py similarity index 100% rename from kdb-bot/src/bot_core/abc/custom_file_logger_abc.py rename to bot/src/bot_core/abc/custom_file_logger_abc.py diff --git a/kdb-bot/src/bot_core/abc/message_service_abc.py b/bot/src/bot_core/abc/message_service_abc.py similarity index 100% rename from kdb-bot/src/bot_core/abc/message_service_abc.py rename to bot/src/bot_core/abc/message_service_abc.py diff --git a/kdb-bot/src/bot_core/abc/module_abc.py b/bot/src/bot_core/abc/module_abc.py similarity index 100% rename from kdb-bot/src/bot_core/abc/module_abc.py rename to bot/src/bot_core/abc/module_abc.py diff --git a/bot/src/bot_core/abc/task_abc.py b/bot/src/bot_core/abc/task_abc.py new file mode 100644 index 00000000..d068fd37 --- /dev/null +++ b/bot/src/bot_core/abc/task_abc.py @@ -0,0 +1,28 @@ +import asyncio +from abc import abstractmethod + +from cpl_core.configuration import ConfigurationABC +from cpl_core.dependency_injection import ServiceProviderABC +from cpl_discord.service import DiscordBotServiceABC +from discord.ext import commands + +from bot_core.logging.task_logger import TaskLogger + + +class TaskABC(commands.Cog): + @abstractmethod + def __init__(self): + commands.Cog.__init__(self) + + @ServiceProviderABC.inject + async def _wait_until_ready(self, config: ConfigurationABC, logger: TaskLogger, bot: DiscordBotServiceABC): + logger.debug(__name__, f"Waiting before {type(self).__name__}") + await bot.wait_until_ready() + + async def wait(): + is_ready = config.get_configuration("IS_READY") + if is_ready != "true": + await asyncio.sleep(1) + await wait() + + await wait() diff --git a/kdb-bot/src/bot_core/bot-core.json b/bot/src/bot_core/bot-core.json similarity index 96% rename from kdb-bot/src/bot_core/bot-core.json rename to bot/src/bot_core/bot-core.json index c8a158d2..9cf7075d 100644 --- a/kdb-bot/src/bot_core/bot-core.json +++ b/bot/src/bot_core/bot-core.json @@ -3,8 +3,8 @@ "Name": "bot-core", "Version": { "Major": "1", - "Minor": "1", - "Micro": "10" + "Minor": "2", + "Micro": "0" }, "Author": "Sven Heidemann", "AuthorEmail": "sven.heidemann@sh-edraft.de", diff --git a/kdb-bot/src/bot_core/configuration/__init__.py b/bot/src/bot_core/configuration/__init__.py similarity index 84% rename from kdb-bot/src/bot_core/configuration/__init__.py rename to bot/src/bot_core/configuration/__init__.py index 5e342ba4..609f8642 100644 --- a/kdb-bot/src/bot_core/configuration/__init__.py +++ b/bot/src/bot_core/configuration/__init__.py @@ -15,7 +15,7 @@ __title__ = "bot_core.configuration" __author__ = "Sven Heidemann" __license__ = "MIT" __copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de" -__version__ = "1.1.10" +__version__ = "1.2.0" from collections import namedtuple @@ -23,4 +23,4 @@ from collections import namedtuple # imports: VersionInfo = namedtuple("VersionInfo", "major minor micro") -version_info = VersionInfo(major="1", minor="1", micro="10") +version_info = VersionInfo(major="1", minor="2", micro="0") diff --git a/kdb-bot/src/bot_core/configuration/bot_logging_settings.py b/bot/src/bot_core/configuration/bot_logging_settings.py similarity index 100% rename from kdb-bot/src/bot_core/configuration/bot_logging_settings.py rename to bot/src/bot_core/configuration/bot_logging_settings.py diff --git a/kdb-bot/src/bot_core/configuration/feature_flags_enum.py b/bot/src/bot_core/configuration/feature_flags_enum.py similarity index 88% rename from kdb-bot/src/bot_core/configuration/feature_flags_enum.py rename to bot/src/bot_core/configuration/feature_flags_enum.py index f56f06b0..6d051b0c 100644 --- a/kdb-bot/src/bot_core/configuration/feature_flags_enum.py +++ b/bot/src/bot_core/configuration/feature_flags_enum.py @@ -17,6 +17,7 @@ class FeatureFlagsEnum(Enum): moderator_module = "ModeratorModule" permission_module = "PermissionModule" short_role_name_module = "ShortRoleNameModule" + steam_special_offers_module = "SteamSpecialOffersModule" # features api_only = "ApiOnly" presence = "Presence" @@ -25,3 +26,4 @@ class FeatureFlagsEnum(Enum): sync_xp = "SyncXp" short_role_name = "ShortRoleName" technician_full_access = "TechnicianFullAccess" + steam_special_offers = "SteamSpecialOffers" diff --git a/kdb-bot/src/bot_core/configuration/feature_flags_settings.py b/bot/src/bot_core/configuration/feature_flags_settings.py similarity index 94% rename from kdb-bot/src/bot_core/configuration/feature_flags_settings.py rename to bot/src/bot_core/configuration/feature_flags_settings.py index 37c17483..0ed95e71 100644 --- a/kdb-bot/src/bot_core/configuration/feature_flags_settings.py +++ b/bot/src/bot_core/configuration/feature_flags_settings.py @@ -19,6 +19,7 @@ class FeatureFlagsSettings(ConfigurationModelABC): FeatureFlagsEnum.permission_module.value: True, # 02.10.2022 #48 FeatureFlagsEnum.config_module.value: True, # 19.07.2023 #127 FeatureFlagsEnum.short_role_name_module.value: True, # 28.09.2023 #378 + FeatureFlagsEnum.steam_special_offers_module.value: True, # 11.10.2023 #188 # features FeatureFlagsEnum.api_only.value: False, # 13.10.2022 #70 FeatureFlagsEnum.presence.value: True, # 03.10.2022 #56 @@ -27,6 +28,7 @@ class FeatureFlagsSettings(ConfigurationModelABC): FeatureFlagsEnum.sync_xp.value: False, # 25.09.2023 #366 FeatureFlagsEnum.short_role_name.value: False, # 28.09.2023 #378 FeatureFlagsEnum.technician_full_access.value: False, # 03.10.2023 #393 + FeatureFlagsEnum.steam_special_offers.value: False, # 11.10.2023 #188 } def __init__(self, **kwargs: dict): diff --git a/kdb-bot/src/bot_core/configuration/file_logging_settings.py b/bot/src/bot_core/configuration/file_logging_settings.py similarity index 100% rename from kdb-bot/src/bot_core/configuration/file_logging_settings.py rename to bot/src/bot_core/configuration/file_logging_settings.py diff --git a/kdb-bot/src/bot_core/core_extension/__init__.py b/bot/src/bot_core/core_extension/__init__.py similarity index 84% rename from kdb-bot/src/bot_core/core_extension/__init__.py rename to bot/src/bot_core/core_extension/__init__.py index 97f48599..3ce1acb8 100644 --- a/kdb-bot/src/bot_core/core_extension/__init__.py +++ b/bot/src/bot_core/core_extension/__init__.py @@ -15,7 +15,7 @@ __title__ = "bot_core.core_extension" __author__ = "Sven Heidemann" __license__ = "MIT" __copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de" -__version__ = "1.1.10" +__version__ = "1.2.0" from collections import namedtuple @@ -23,4 +23,4 @@ from collections import namedtuple # imports: VersionInfo = namedtuple("VersionInfo", "major minor micro") -version_info = VersionInfo(major="1", minor="1", micro="10") +version_info = VersionInfo(major="1", minor="2", micro="0") diff --git a/kdb-bot/src/bot_core/core_extension/core_extension.py b/bot/src/bot_core/core_extension/core_extension.py similarity index 100% rename from kdb-bot/src/bot_core/core_extension/core_extension.py rename to bot/src/bot_core/core_extension/core_extension.py diff --git a/kdb-bot/src/bot_core/core_extension/core_extension_module.py b/bot/src/bot_core/core_extension/core_extension_module.py similarity index 90% rename from kdb-bot/src/bot_core/core_extension/core_extension_module.py rename to bot/src/bot_core/core_extension/core_extension_module.py index d6cba99b..ef16529f 100644 --- a/kdb-bot/src/bot_core/core_extension/core_extension_module.py +++ b/bot/src/bot_core/core_extension/core_extension_module.py @@ -19,4 +19,4 @@ class CoreExtensionModule(ModuleABC): pass def configure_services(self, services: ServiceCollectionABC, env: ApplicationEnvironmentABC): - self._dc.add_event(DiscordEventTypesEnum.on_ready.value, CoreExtensionOnReadyEvent) + services.add_transient(DiscordEventTypesEnum.on_ready.value, CoreExtensionOnReadyEvent) diff --git a/kdb-bot/src/bot_core/core_extension/core_extension_on_ready_event.py b/bot/src/bot_core/core_extension/core_extension_on_ready_event.py similarity index 100% rename from kdb-bot/src/bot_core/core_extension/core_extension_on_ready_event.py rename to bot/src/bot_core/core_extension/core_extension_on_ready_event.py diff --git a/kdb-bot/src/bot_core/core_module.py b/bot/src/bot_core/core_module.py similarity index 94% rename from kdb-bot/src/bot_core/core_module.py rename to bot/src/bot_core/core_module.py index fcb06333..02611684 100644 --- a/kdb-bot/src/bot_core/core_module.py +++ b/bot/src/bot_core/core_module.py @@ -32,4 +32,4 @@ class CoreModule(ModuleABC): # pipes services.add_transient(DateTimeOffsetPipe) - self._dc.add_event(DiscordEventTypesEnum.on_ready.value, CoreOnReadyEvent) + services.add_transient(DiscordEventTypesEnum.on_ready.value, CoreOnReadyEvent) diff --git a/kdb-bot/src/bot_core/events/__init__.py b/bot/src/bot_core/events/__init__.py similarity index 84% rename from kdb-bot/src/bot_core/events/__init__.py rename to bot/src/bot_core/events/__init__.py index e5c7148f..a0543256 100644 --- a/kdb-bot/src/bot_core/events/__init__.py +++ b/bot/src/bot_core/events/__init__.py @@ -15,7 +15,7 @@ __title__ = "bot_core.events" __author__ = "Sven Heidemann" __license__ = "MIT" __copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de" -__version__ = "1.1.10" +__version__ = "1.2.0" from collections import namedtuple @@ -23,4 +23,4 @@ from collections import namedtuple # imports: VersionInfo = namedtuple("VersionInfo", "major minor micro") -version_info = VersionInfo(major="1", minor="1", micro="10") +version_info = VersionInfo(major="1", minor="2", micro="0") diff --git a/kdb-bot/src/bot_core/events/core_on_ready_event.py b/bot/src/bot_core/events/core_on_ready_event.py similarity index 100% rename from kdb-bot/src/bot_core/events/core_on_ready_event.py rename to bot/src/bot_core/events/core_on_ready_event.py diff --git a/kdb-bot/src/bot_core/exception/__init__.py b/bot/src/bot_core/exception/__init__.py similarity index 84% rename from kdb-bot/src/bot_core/exception/__init__.py rename to bot/src/bot_core/exception/__init__.py index 4b561eeb..8e7daf7e 100644 --- a/kdb-bot/src/bot_core/exception/__init__.py +++ b/bot/src/bot_core/exception/__init__.py @@ -15,7 +15,7 @@ __title__ = "bot_core.exception" __author__ = "Sven Heidemann" __license__ = "MIT" __copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de" -__version__ = "1.1.10" +__version__ = "1.2.0" from collections import namedtuple @@ -23,4 +23,4 @@ from collections import namedtuple # imports: VersionInfo = namedtuple("VersionInfo", "major minor micro") -version_info = VersionInfo(major="1", minor="1", micro="10") +version_info = VersionInfo(major="1", minor="2", micro="0") diff --git a/kdb-bot/src/bot_core/exception/check_error.py b/bot/src/bot_core/exception/check_error.py similarity index 100% rename from kdb-bot/src/bot_core/exception/check_error.py rename to bot/src/bot_core/exception/check_error.py diff --git a/kdb-bot/src/bot_core/helper/__init__.py b/bot/src/bot_core/helper/__init__.py similarity index 84% rename from kdb-bot/src/bot_core/helper/__init__.py rename to bot/src/bot_core/helper/__init__.py index cc9f6ade..b597c6fd 100644 --- a/kdb-bot/src/bot_core/helper/__init__.py +++ b/bot/src/bot_core/helper/__init__.py @@ -15,7 +15,7 @@ __title__ = "bot_core.helper" __author__ = "Sven Heidemann" __license__ = "MIT" __copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de" -__version__ = "1.1.10" +__version__ = "1.2.0" from collections import namedtuple @@ -23,4 +23,4 @@ from collections import namedtuple # imports: VersionInfo = namedtuple("VersionInfo", "major minor micro") -version_info = VersionInfo(major="1", minor="1", micro="10") +version_info = VersionInfo(major="1", minor="2", micro="0") diff --git a/kdb-bot/src/bot_core/helper/command_checks.py b/bot/src/bot_core/helper/command_checks.py similarity index 100% rename from kdb-bot/src/bot_core/helper/command_checks.py rename to bot/src/bot_core/helper/command_checks.py diff --git a/kdb-bot/src/bot_core/helper/event_checks.py b/bot/src/bot_core/helper/event_checks.py similarity index 100% rename from kdb-bot/src/bot_core/helper/event_checks.py rename to bot/src/bot_core/helper/event_checks.py diff --git a/kdb-bot/src/bot_core/helper/log_message_helper.py b/bot/src/bot_core/helper/log_message_helper.py similarity index 100% rename from kdb-bot/src/bot_core/helper/log_message_helper.py rename to bot/src/bot_core/helper/log_message_helper.py diff --git a/kdb-bot/src/bot_core/logging/__init__.py b/bot/src/bot_core/logging/__init__.py similarity index 84% rename from kdb-bot/src/bot_core/logging/__init__.py rename to bot/src/bot_core/logging/__init__.py index 8564fabb..1622cb57 100644 --- a/kdb-bot/src/bot_core/logging/__init__.py +++ b/bot/src/bot_core/logging/__init__.py @@ -15,7 +15,7 @@ __title__ = "bot_core.logging" __author__ = "Sven Heidemann" __license__ = "MIT" __copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de" -__version__ = "1.1.10" +__version__ = "1.2.0" from collections import namedtuple @@ -23,4 +23,4 @@ from collections import namedtuple # imports VersionInfo = namedtuple("VersionInfo", "major minor micro") -version_info = VersionInfo(major="1", minor="1", micro="10") +version_info = VersionInfo(major="1", minor="2", micro="0") diff --git a/kdb-bot/src/bot_core/logging/command_logger.py b/bot/src/bot_core/logging/command_logger.py similarity index 100% rename from kdb-bot/src/bot_core/logging/command_logger.py rename to bot/src/bot_core/logging/command_logger.py diff --git a/kdb-bot/src/bot_core/logging/database_logger.py b/bot/src/bot_core/logging/database_logger.py similarity index 100% rename from kdb-bot/src/bot_core/logging/database_logger.py rename to bot/src/bot_core/logging/database_logger.py diff --git a/kdb-bot/src/bot_core/logging/message_logger.py b/bot/src/bot_core/logging/message_logger.py similarity index 100% rename from kdb-bot/src/bot_core/logging/message_logger.py rename to bot/src/bot_core/logging/message_logger.py diff --git a/bot/src/bot_core/logging/task_logger.py b/bot/src/bot_core/logging/task_logger.py new file mode 100644 index 00000000..fc4a637c --- /dev/null +++ b/bot/src/bot_core/logging/task_logger.py @@ -0,0 +1,15 @@ +from cpl_core.configuration import ConfigurationABC +from cpl_core.environment import ApplicationEnvironmentABC +from cpl_core.time import TimeFormatSettings + +from bot_core.abc.custom_file_logger_abc import CustomFileLoggerABC + + +class TaskLogger(CustomFileLoggerABC): + def __init__( + self, + config: ConfigurationABC, + time_format: TimeFormatSettings, + env: ApplicationEnvironmentABC, + ): + CustomFileLoggerABC.__init__(self, "Task", config, time_format, env) diff --git a/kdb-bot/src/bot_core/pipes/__init__.py b/bot/src/bot_core/pipes/__init__.py similarity index 84% rename from kdb-bot/src/bot_core/pipes/__init__.py rename to bot/src/bot_core/pipes/__init__.py index 9bde3a5f..9b035bbb 100644 --- a/kdb-bot/src/bot_core/pipes/__init__.py +++ b/bot/src/bot_core/pipes/__init__.py @@ -15,7 +15,7 @@ __title__ = "bot_core.pipes" __author__ = "Sven Heidemann" __license__ = "MIT" __copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de" -__version__ = "1.1.10" +__version__ = "1.2.0" from collections import namedtuple @@ -23,4 +23,4 @@ from collections import namedtuple # imports VersionInfo = namedtuple("VersionInfo", "major minor micro") -version_info = VersionInfo(major="1", minor="1", micro="10") +version_info = VersionInfo(major="1", minor="2", micro="0") diff --git a/kdb-bot/src/bot_core/pipes/date_time_offset_pipe.py b/bot/src/bot_core/pipes/date_time_offset_pipe.py similarity index 100% rename from kdb-bot/src/bot_core/pipes/date_time_offset_pipe.py rename to bot/src/bot_core/pipes/date_time_offset_pipe.py diff --git a/kdb-bot/src/bot_core/service/__init__.py b/bot/src/bot_core/service/__init__.py similarity index 84% rename from kdb-bot/src/bot_core/service/__init__.py rename to bot/src/bot_core/service/__init__.py index 895cf293..74bbfed6 100644 --- a/kdb-bot/src/bot_core/service/__init__.py +++ b/bot/src/bot_core/service/__init__.py @@ -15,7 +15,7 @@ __title__ = "bot_core.service" __author__ = "Sven Heidemann" __license__ = "MIT" __copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de" -__version__ = "1.1.10" +__version__ = "1.2.0" from collections import namedtuple @@ -23,4 +23,4 @@ from collections import namedtuple # imports: VersionInfo = namedtuple("VersionInfo", "major minor micro") -version_info = VersionInfo(major="1", minor="1", micro="10") +version_info = VersionInfo(major="1", minor="2", micro="0") diff --git a/kdb-bot/src/bot_core/service/client_utils_service.py b/bot/src/bot_core/service/client_utils_service.py similarity index 97% rename from kdb-bot/src/bot_core/service/client_utils_service.py rename to bot/src/bot_core/service/client_utils_service.py index 24143dbb..e0272390 100644 --- a/kdb-bot/src/bot_core/service/client_utils_service.py +++ b/bot/src/bot_core/service/client_utils_service.py @@ -131,7 +131,7 @@ class ClientUtilsService(ClientUtilsABC): if current in sl: sl = sl.skip(sl.index_of(current)) - _l = _l.where(lambda x: x.name in sl) + _l = _l.where(lambda x: select(x) in sl) return _l.take(25) @@ -196,7 +196,11 @@ class ClientUtilsService(ClientUtilsABC): ) async def react_to_message_by_auto_role_rule( - self, discord_channel_id: int, discord_message_id: int, rule: AutoRoleRule, guild: discord.Guild + self, + discord_channel_id: int, + discord_message_id: int, + rule: AutoRoleRule, + guild: discord.Guild, ): try: guild: Guild = self._bot.guilds.where(lambda g: g == guild).single() diff --git a/kdb-bot/src/bot_core/service/config_service.py b/bot/src/bot_core/service/config_service.py similarity index 89% rename from kdb-bot/src/bot_core/service/config_service.py rename to bot/src/bot_core/service/config_service.py index 6aa29b83..657d972d 100644 --- a/kdb-bot/src/bot_core/service/config_service.py +++ b/bot/src/bot_core/service/config_service.py @@ -28,7 +28,10 @@ class ConfigService: def reload_technician_config(self): technician_config = self._technician_config_repo.get_technician_config() self._config.add_configuration(TechnicianConfig, technician_config) - self._config.add_configuration(FeatureFlagsSettings, FeatureFlagsSettings(**technician_config.feature_flags)) + self._config.add_configuration( + FeatureFlagsSettings, + FeatureFlagsSettings(**technician_config.feature_flags), + ) async def reload_server_config(self, server: Server): if not self._server_config_repo.does_server_config_exists(server.id): @@ -36,5 +39,6 @@ class ConfigService: server_config = self._server_config_repo.get_server_config_by_server(server.id) self._config.add_configuration( - f"{type(server_config).__name__}_{server_config.server.discord_id}", server_config + f"{type(server_config).__name__}_{server_config.server.discord_id}", + server_config, ) diff --git a/kdb-bot/src/bot_core/service/data_integrity_service.py b/bot/src/bot_core/service/data_integrity_service.py similarity index 99% rename from kdb-bot/src/bot_core/service/data_integrity_service.py rename to bot/src/bot_core/service/data_integrity_service.py index 9a2e613e..fc044a9d 100644 --- a/kdb-bot/src/bot_core/service/data_integrity_service.py +++ b/bot/src/bot_core/service/data_integrity_service.py @@ -11,7 +11,9 @@ from bot_core.logging.database_logger import DatabaseLogger from bot_core.pipes.date_time_offset_pipe import DateTimeOffsetPipe from bot_data.abc.client_repository_abc import ClientRepositoryABC from bot_data.abc.known_user_repository_abc import KnownUserRepositoryABC -from bot_data.abc.user_joined_game_server_repository_abc import UserJoinedGameServerRepositoryABC +from bot_data.abc.user_joined_game_server_repository_abc import ( + UserJoinedGameServerRepositoryABC, +) from bot_data.abc.user_joined_server_repository_abc import UserJoinedServerRepositoryABC from bot_data.abc.user_joined_voice_channel_repository_abc import ( UserJoinedVoiceChannelRepositoryABC, diff --git a/kdb-bot/src/bot_core/service/message_service.py b/bot/src/bot_core/service/message_service.py similarity index 97% rename from kdb-bot/src/bot_core/service/message_service.py rename to bot/src/bot_core/service/message_service.py index 71caa831..9140742f 100644 --- a/kdb-bot/src/bot_core/service/message_service.py +++ b/bot/src/bot_core/service/message_service.py @@ -71,7 +71,7 @@ class MessageService(MessageServiceABC): async def send_channel_message( self, channel: discord.TextChannel, - message: Union[str, discord.Embed], + message: Union[str, discord.Embed, list[discord.Embed]], is_persistent: bool = False, wait_before_delete: int = None, without_tracking=False, @@ -81,6 +81,8 @@ class MessageService(MessageServiceABC): try: if isinstance(message, discord.Embed): msg = await channel.send(embed=message) + elif isinstance(message, list): + msg = await channel.send(embeds=message) else: msg = await channel.send(message) except Exception as e: diff --git a/kdb-bot/src/bot_data/__init__.py b/bot/src/bot_data/__init__.py similarity index 84% rename from kdb-bot/src/bot_data/__init__.py rename to bot/src/bot_data/__init__.py index 7f7f0a26..dba7fc2c 100644 --- a/kdb-bot/src/bot_data/__init__.py +++ b/bot/src/bot_data/__init__.py @@ -15,7 +15,7 @@ __title__ = "bot_data" __author__ = "Sven Heidemann" __license__ = "MIT" __copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de" -__version__ = "1.1.10" +__version__ = "1.2.0" from collections import namedtuple @@ -23,4 +23,4 @@ from collections import namedtuple # imports VersionInfo = namedtuple("VersionInfo", "major minor micro") -version_info = VersionInfo(major="1", minor="1", micro="10") +version_info = VersionInfo(major="1", minor="2", micro="0") diff --git a/kdb-bot/src/bot_data/abc/__init__.py b/bot/src/bot_data/abc/__init__.py similarity index 84% rename from kdb-bot/src/bot_data/abc/__init__.py rename to bot/src/bot_data/abc/__init__.py index bcdb8b20..4341c756 100644 --- a/kdb-bot/src/bot_data/abc/__init__.py +++ b/bot/src/bot_data/abc/__init__.py @@ -15,7 +15,7 @@ __title__ = "bot_data.abc" __author__ = "Sven Heidemann" __license__ = "MIT" __copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de" -__version__ = "1.1.10" +__version__ = "1.2.0" from collections import namedtuple @@ -23,4 +23,4 @@ from collections import namedtuple # imports VersionInfo = namedtuple("VersionInfo", "major minor micro") -version_info = VersionInfo(major="1", minor="1", micro="10") +version_info = VersionInfo(major="1", minor="2", micro="0") diff --git a/kdb-bot/src/bot_data/abc/achievement_repository_abc.py b/bot/src/bot_data/abc/achievement_repository_abc.py similarity index 100% rename from kdb-bot/src/bot_data/abc/achievement_repository_abc.py rename to bot/src/bot_data/abc/achievement_repository_abc.py diff --git a/kdb-bot/src/bot_data/abc/api_key_repository_abc.py b/bot/src/bot_data/abc/api_key_repository_abc.py similarity index 100% rename from kdb-bot/src/bot_data/abc/api_key_repository_abc.py rename to bot/src/bot_data/abc/api_key_repository_abc.py diff --git a/kdb-bot/src/bot_data/abc/auth_user_repository_abc.py b/bot/src/bot_data/abc/auth_user_repository_abc.py similarity index 100% rename from kdb-bot/src/bot_data/abc/auth_user_repository_abc.py rename to bot/src/bot_data/abc/auth_user_repository_abc.py diff --git a/kdb-bot/src/bot_data/abc/auto_role_repository_abc.py b/bot/src/bot_data/abc/auto_role_repository_abc.py similarity index 100% rename from kdb-bot/src/bot_data/abc/auto_role_repository_abc.py rename to bot/src/bot_data/abc/auto_role_repository_abc.py diff --git a/kdb-bot/src/bot_data/abc/client_repository_abc.py b/bot/src/bot_data/abc/client_repository_abc.py similarity index 100% rename from kdb-bot/src/bot_data/abc/client_repository_abc.py rename to bot/src/bot_data/abc/client_repository_abc.py diff --git a/kdb-bot/src/bot_data/abc/data_seeder_abc.py b/bot/src/bot_data/abc/data_seeder_abc.py similarity index 100% rename from kdb-bot/src/bot_data/abc/data_seeder_abc.py rename to bot/src/bot_data/abc/data_seeder_abc.py diff --git a/kdb-bot/src/bot_data/abc/game_server_repository_abc.py b/bot/src/bot_data/abc/game_server_repository_abc.py similarity index 100% rename from kdb-bot/src/bot_data/abc/game_server_repository_abc.py rename to bot/src/bot_data/abc/game_server_repository_abc.py diff --git a/kdb-bot/src/bot_data/abc/history_table_abc.py b/bot/src/bot_data/abc/history_table_abc.py similarity index 100% rename from kdb-bot/src/bot_data/abc/history_table_abc.py rename to bot/src/bot_data/abc/history_table_abc.py diff --git a/kdb-bot/src/bot_data/abc/known_user_repository_abc.py b/bot/src/bot_data/abc/known_user_repository_abc.py similarity index 100% rename from kdb-bot/src/bot_data/abc/known_user_repository_abc.py rename to bot/src/bot_data/abc/known_user_repository_abc.py diff --git a/kdb-bot/src/bot_data/abc/level_repository_abc.py b/bot/src/bot_data/abc/level_repository_abc.py similarity index 100% rename from kdb-bot/src/bot_data/abc/level_repository_abc.py rename to bot/src/bot_data/abc/level_repository_abc.py diff --git a/kdb-bot/src/bot_data/abc/migration_abc.py b/bot/src/bot_data/abc/migration_abc.py similarity index 100% rename from kdb-bot/src/bot_data/abc/migration_abc.py rename to bot/src/bot_data/abc/migration_abc.py diff --git a/kdb-bot/src/bot_data/abc/server_config_repository_abc.py b/bot/src/bot_data/abc/server_config_repository_abc.py similarity index 100% rename from kdb-bot/src/bot_data/abc/server_config_repository_abc.py rename to bot/src/bot_data/abc/server_config_repository_abc.py diff --git a/kdb-bot/src/bot_data/abc/server_repository_abc.py b/bot/src/bot_data/abc/server_repository_abc.py similarity index 100% rename from kdb-bot/src/bot_data/abc/server_repository_abc.py rename to bot/src/bot_data/abc/server_repository_abc.py diff --git a/kdb-bot/src/bot_data/abc/short_role_name_repository_abc.py b/bot/src/bot_data/abc/short_role_name_repository_abc.py similarity index 100% rename from kdb-bot/src/bot_data/abc/short_role_name_repository_abc.py rename to bot/src/bot_data/abc/short_role_name_repository_abc.py diff --git a/bot/src/bot_data/abc/steam_special_offer_repository_abc.py b/bot/src/bot_data/abc/steam_special_offer_repository_abc.py new file mode 100644 index 00000000..7f412730 --- /dev/null +++ b/bot/src/bot_data/abc/steam_special_offer_repository_abc.py @@ -0,0 +1,32 @@ +from abc import ABC, abstractmethod +from typing import Optional + +from cpl_query.extension import List + +from bot_data.model.steam_special_offer import SteamSpecialOffer + + +class SteamSpecialOfferRepositoryABC(ABC): + @abstractmethod + def __init__(self): + pass + + @abstractmethod + def get_steam_special_offers(self) -> List[SteamSpecialOffer]: + pass + + @abstractmethod + def get_steam_special_offer_by_name(self, name: str) -> SteamSpecialOffer: + pass + + @abstractmethod + def add_steam_special_offer(self, steam_special_offer: SteamSpecialOffer): + pass + + @abstractmethod + def update_steam_special_offer(self, steam_special_offer: SteamSpecialOffer): + pass + + @abstractmethod + def delete_steam_special_offer(self, steam_special_offer: SteamSpecialOffer): + pass diff --git a/kdb-bot/src/bot_data/abc/table_with_id_abc.py b/bot/src/bot_data/abc/table_with_id_abc.py similarity index 100% rename from kdb-bot/src/bot_data/abc/table_with_id_abc.py rename to bot/src/bot_data/abc/table_with_id_abc.py diff --git a/kdb-bot/src/bot_data/abc/technician_config_repository_abc.py b/bot/src/bot_data/abc/technician_config_repository_abc.py similarity index 100% rename from kdb-bot/src/bot_data/abc/technician_config_repository_abc.py rename to bot/src/bot_data/abc/technician_config_repository_abc.py diff --git a/kdb-bot/src/bot_data/abc/user_game_ident_repository_abc.py b/bot/src/bot_data/abc/user_game_ident_repository_abc.py similarity index 100% rename from kdb-bot/src/bot_data/abc/user_game_ident_repository_abc.py rename to bot/src/bot_data/abc/user_game_ident_repository_abc.py diff --git a/kdb-bot/src/bot_data/abc/user_joined_game_server_repository_abc.py b/bot/src/bot_data/abc/user_joined_game_server_repository_abc.py similarity index 100% rename from kdb-bot/src/bot_data/abc/user_joined_game_server_repository_abc.py rename to bot/src/bot_data/abc/user_joined_game_server_repository_abc.py diff --git a/kdb-bot/src/bot_data/abc/user_joined_server_repository_abc.py b/bot/src/bot_data/abc/user_joined_server_repository_abc.py similarity index 100% rename from kdb-bot/src/bot_data/abc/user_joined_server_repository_abc.py rename to bot/src/bot_data/abc/user_joined_server_repository_abc.py diff --git a/kdb-bot/src/bot_data/abc/user_joined_voice_channel_repository_abc.py b/bot/src/bot_data/abc/user_joined_voice_channel_repository_abc.py similarity index 100% rename from kdb-bot/src/bot_data/abc/user_joined_voice_channel_repository_abc.py rename to bot/src/bot_data/abc/user_joined_voice_channel_repository_abc.py diff --git a/kdb-bot/src/bot_data/abc/user_message_count_per_hour_repository_abc.py b/bot/src/bot_data/abc/user_message_count_per_hour_repository_abc.py similarity index 100% rename from kdb-bot/src/bot_data/abc/user_message_count_per_hour_repository_abc.py rename to bot/src/bot_data/abc/user_message_count_per_hour_repository_abc.py diff --git a/kdb-bot/src/bot_data/abc/user_repository_abc.py b/bot/src/bot_data/abc/user_repository_abc.py similarity index 100% rename from kdb-bot/src/bot_data/abc/user_repository_abc.py rename to bot/src/bot_data/abc/user_repository_abc.py diff --git a/kdb-bot/src/bot_data/abc/user_warnings_repository_abc.py b/bot/src/bot_data/abc/user_warnings_repository_abc.py similarity index 100% rename from kdb-bot/src/bot_data/abc/user_warnings_repository_abc.py rename to bot/src/bot_data/abc/user_warnings_repository_abc.py diff --git a/kdb-bot/src/bot_data/bot-data.json b/bot/src/bot_data/bot-data.json similarity index 96% rename from kdb-bot/src/bot_data/bot-data.json rename to bot/src/bot_data/bot-data.json index 3e0dac07..8300b491 100644 --- a/kdb-bot/src/bot_data/bot-data.json +++ b/bot/src/bot_data/bot-data.json @@ -3,8 +3,8 @@ "Name": "bot-data", "Version": { "Major": "1", - "Minor": "1", - "Micro": "10" + "Minor": "2", + "Micro": "0" }, "Author": "Sven Heidemann", "AuthorEmail": "sven.heidemann@sh-edraft.de", diff --git a/kdb-bot/src/bot_data/data_module.py b/bot/src/bot_data/data_module.py similarity index 87% rename from kdb-bot/src/bot_data/data_module.py rename to bot/src/bot_data/data_module.py index 427c9cc6..cec9cb37 100644 --- a/kdb-bot/src/bot_data/data_module.py +++ b/bot/src/bot_data/data_module.py @@ -17,9 +17,14 @@ from bot_data.abc.level_repository_abc import LevelRepositoryABC from bot_data.abc.server_config_repository_abc import ServerConfigRepositoryABC from bot_data.abc.server_repository_abc import ServerRepositoryABC from bot_data.abc.short_role_name_repository_abc import ShortRoleNameRepositoryABC +from bot_data.abc.steam_special_offer_repository_abc import ( + SteamSpecialOfferRepositoryABC, +) from bot_data.abc.technician_config_repository_abc import TechnicianConfigRepositoryABC from bot_data.abc.user_game_ident_repository_abc import UserGameIdentRepositoryABC -from bot_data.abc.user_joined_game_server_repository_abc import UserJoinedGameServerRepositoryABC +from bot_data.abc.user_joined_game_server_repository_abc import ( + UserJoinedGameServerRepositoryABC, +) from bot_data.abc.user_joined_server_repository_abc import UserJoinedServerRepositoryABC from bot_data.abc.user_joined_voice_channel_repository_abc import ( UserJoinedVoiceChannelRepositoryABC, @@ -29,7 +34,9 @@ from bot_data.abc.user_message_count_per_hour_repository_abc import ( ) from bot_data.abc.user_repository_abc import UserRepositoryABC from bot_data.abc.user_warnings_repository_abc import UserWarningsRepositoryABC -from bot_data.service.achievements_repository_service import AchievementRepositoryService +from bot_data.service.achievements_repository_service import ( + AchievementRepositoryService, +) from bot_data.service.api_key_repository_service import ApiKeyRepositoryService from bot_data.service.auth_user_repository_service import AuthUserRepositoryService from bot_data.service.auto_role_repository_service import AutoRoleRepositoryService @@ -39,14 +46,27 @@ from bot_data.service.game_server_repository_service import GameServerRepository from bot_data.service.known_user_repository_service import KnownUserRepositoryService from bot_data.service.level_repository_service import LevelRepositoryService from bot_data.service.seeder_service import SeederService -from bot_data.service.server_config_repository_service import ServerConfigRepositoryService +from bot_data.service.server_config_repository_service import ( + ServerConfigRepositoryService, +) from bot_data.service.server_config_seeder import ServerConfigSeeder from bot_data.service.server_repository_service import ServerRepositoryService -from bot_data.service.short_role_name_repository_service import ShortRoleNameRepositoryService -from bot_data.service.technician_config_repository_service import TechnicianConfigRepositoryService +from bot_data.service.short_role_name_repository_service import ( + ShortRoleNameRepositoryService, +) +from bot_data.service.steam_special_offer_repository_service import ( + SteamSpecialOfferRepositoryService, +) +from bot_data.service.technician_config_repository_service import ( + TechnicianConfigRepositoryService, +) from bot_data.service.technician_config_seeder import TechnicianConfigSeeder -from bot_data.service.user_game_ident_repository_service import UserGameIdentRepositoryService -from bot_data.service.user_joined_game_server_repository_service import UserJoinedGameServerRepositoryService +from bot_data.service.user_game_ident_repository_service import ( + UserGameIdentRepositoryService, +) +from bot_data.service.user_joined_game_server_repository_service import ( + UserJoinedGameServerRepositoryService, +) from bot_data.service.user_joined_server_repository_service import ( UserJoinedServerRepositoryService, ) @@ -57,7 +77,9 @@ from bot_data.service.user_message_count_per_hour_repository_service import ( UserMessageCountPerHourRepositoryService, ) from bot_data.service.user_repository_service import UserRepositoryService -from bot_data.service.user_warnings_repository_service import UserWarningsRepositoryService +from bot_data.service.user_warnings_repository_service import ( + UserWarningsRepositoryService, +) class DataModule(ModuleABC): @@ -92,6 +114,7 @@ class DataModule(ModuleABC): services.add_transient(TechnicianConfigRepositoryABC, TechnicianConfigRepositoryService) services.add_transient(ServerConfigRepositoryABC, ServerConfigRepositoryService) services.add_transient(ShortRoleNameRepositoryABC, ShortRoleNameRepositoryService) + services.add_transient(SteamSpecialOfferRepositoryABC, SteamSpecialOfferRepositoryService) services.add_transient(SeederService) services.add_transient(DataSeederABC, TechnicianConfigSeeder) diff --git a/kdb-bot/src/bot_data/db_context.py b/bot/src/bot_data/db_context.py similarity index 100% rename from kdb-bot/src/bot_data/db_context.py rename to bot/src/bot_data/db_context.py diff --git a/kdb-bot/src/bot_data/filtered_result.py b/bot/src/bot_data/filtered_result.py similarity index 100% rename from kdb-bot/src/bot_data/filtered_result.py rename to bot/src/bot_data/filtered_result.py diff --git a/kdb-bot/src/bot_data/migration/__init__.py b/bot/src/bot_data/migration/__init__.py similarity index 84% rename from kdb-bot/src/bot_data/migration/__init__.py rename to bot/src/bot_data/migration/__init__.py index 2999899d..fb9a7c01 100644 --- a/kdb-bot/src/bot_data/migration/__init__.py +++ b/bot/src/bot_data/migration/__init__.py @@ -15,7 +15,7 @@ __title__ = "bot_data.migration" __author__ = "Sven Heidemann" __license__ = "MIT" __copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de" -__version__ = "1.1.10" +__version__ = "1.2.0" from collections import namedtuple @@ -23,4 +23,4 @@ from collections import namedtuple # imports VersionInfo = namedtuple("VersionInfo", "major minor micro") -version_info = VersionInfo(major="1", minor="1", micro="10") +version_info = VersionInfo(major="1", minor="2", micro="0") diff --git a/kdb-bot/src/bot_data/migration/achievements_migration.py b/bot/src/bot_data/migration/achievements_migration.py similarity index 100% rename from kdb-bot/src/bot_data/migration/achievements_migration.py rename to bot/src/bot_data/migration/achievements_migration.py diff --git a/kdb-bot/src/bot_data/migration/api_key_migration.py b/bot/src/bot_data/migration/api_key_migration.py similarity index 100% rename from kdb-bot/src/bot_data/migration/api_key_migration.py rename to bot/src/bot_data/migration/api_key_migration.py diff --git a/kdb-bot/src/bot_data/migration/api_migration.py b/bot/src/bot_data/migration/api_migration.py similarity index 100% rename from kdb-bot/src/bot_data/migration/api_migration.py rename to bot/src/bot_data/migration/api_migration.py diff --git a/kdb-bot/src/bot_data/migration/auto_role_fix1_migration.py b/bot/src/bot_data/migration/auto_role_fix1_migration.py similarity index 100% rename from kdb-bot/src/bot_data/migration/auto_role_fix1_migration.py rename to bot/src/bot_data/migration/auto_role_fix1_migration.py diff --git a/kdb-bot/src/bot_data/migration/auto_role_migration.py b/bot/src/bot_data/migration/auto_role_migration.py similarity index 100% rename from kdb-bot/src/bot_data/migration/auto_role_migration.py rename to bot/src/bot_data/migration/auto_role_migration.py diff --git a/bot/src/bot_data/migration/birthday_migration.py b/bot/src/bot_data/migration/birthday_migration.py new file mode 100644 index 00000000..607de4d3 --- /dev/null +++ b/bot/src/bot_data/migration/birthday_migration.py @@ -0,0 +1,84 @@ +from bot_core.logging.database_logger import DatabaseLogger +from bot_data.abc.migration_abc import MigrationABC +from bot_data.db_context import DBContext + + +class BirthdayMigration(MigrationABC): + name = "1.2.0_BirthdayMigration" + + def __init__(self, logger: DatabaseLogger, db: DBContext): + MigrationABC.__init__(self) + self._logger = logger + self._db = db + self._cursor = db.cursor + + def upgrade(self): + self._logger.debug(__name__, "Running upgrade") + + self._cursor.execute( + str( + f""" + ALTER TABLE Users + ADD Birthday DATE NULL AFTER MessageCount; + """ + ) + ) + + self._cursor.execute( + str( + f""" + ALTER TABLE UsersHistory + ADD Birthday DATE NULL AFTER MessageCount; + """ + ) + ) + self._exec(__file__, "users.sql") + + self._cursor.execute( + str( + f""" + ALTER TABLE CFG_Server + ADD XpForBirthday BIGINT(20) NOT NULL DEFAULT 0 AFTER XpPerAchievement; + """ + ) + ) + + self._cursor.execute( + str( + f""" + ALTER TABLE CFG_ServerHistory + ADD XpForBirthday BIGINT(20) NOT NULL DEFAULT 0 AFTER XpPerAchievement; + """ + ) + ) + self._exec(__file__, "config/server.sql") + + def downgrade(self): + self._cursor.execute( + str( + f""" + ALTER TABLE Users DROP COLUMN Birthday; + """ + ) + ) + self._cursor.execute( + str( + f""" + ALTER TABLE UsersHistory DROP COLUMN Birthday; + """ + ) + ) + self._cursor.execute( + str( + f""" + ALTER TABLE CFG_Server DROP COLUMN XpForBirthday; + """ + ) + ) + self._cursor.execute( + str( + f""" + ALTER TABLE CFG_ServerHistory DROP COLUMN XpForBirthday; + """ + ) + ) diff --git a/kdb-bot/src/bot_data/migration/config_feature_flags_migration.py b/bot/src/bot_data/migration/config_feature_flags_migration.py similarity index 100% rename from kdb-bot/src/bot_data/migration/config_feature_flags_migration.py rename to bot/src/bot_data/migration/config_feature_flags_migration.py diff --git a/kdb-bot/src/bot_data/migration/config_migration.py b/bot/src/bot_data/migration/config_migration.py similarity index 100% rename from kdb-bot/src/bot_data/migration/config_migration.py rename to bot/src/bot_data/migration/config_migration.py diff --git a/kdb-bot/src/bot_data/migration/db_history_migration.py b/bot/src/bot_data/migration/db_history_migration.py similarity index 100% rename from kdb-bot/src/bot_data/migration/db_history_migration.py rename to bot/src/bot_data/migration/db_history_migration.py diff --git a/kdb-bot/src/bot_data/migration/db_history_scripts/api_keys.sql b/bot/src/bot_data/migration/db_history_scripts/api_keys.sql similarity index 100% rename from kdb-bot/src/bot_data/migration/db_history_scripts/api_keys.sql rename to bot/src/bot_data/migration/db_history_scripts/api_keys.sql diff --git a/kdb-bot/src/bot_data/migration/db_history_scripts/auth_user_users_relation.sql b/bot/src/bot_data/migration/db_history_scripts/auth_user_users_relation.sql similarity index 100% rename from kdb-bot/src/bot_data/migration/db_history_scripts/auth_user_users_relation.sql rename to bot/src/bot_data/migration/db_history_scripts/auth_user_users_relation.sql diff --git a/kdb-bot/src/bot_data/migration/db_history_scripts/auth_users.sql b/bot/src/bot_data/migration/db_history_scripts/auth_users.sql similarity index 100% rename from kdb-bot/src/bot_data/migration/db_history_scripts/auth_users.sql rename to bot/src/bot_data/migration/db_history_scripts/auth_users.sql diff --git a/kdb-bot/src/bot_data/migration/db_history_scripts/auto_role_rules.sql b/bot/src/bot_data/migration/db_history_scripts/auto_role_rules.sql similarity index 100% rename from kdb-bot/src/bot_data/migration/db_history_scripts/auto_role_rules.sql rename to bot/src/bot_data/migration/db_history_scripts/auto_role_rules.sql diff --git a/kdb-bot/src/bot_data/migration/db_history_scripts/auto_roles.sql b/bot/src/bot_data/migration/db_history_scripts/auto_roles.sql similarity index 100% rename from kdb-bot/src/bot_data/migration/db_history_scripts/auto_roles.sql rename to bot/src/bot_data/migration/db_history_scripts/auto_roles.sql diff --git a/kdb-bot/src/bot_data/migration/db_history_scripts/clients.sql b/bot/src/bot_data/migration/db_history_scripts/clients.sql similarity index 100% rename from kdb-bot/src/bot_data/migration/db_history_scripts/clients.sql rename to bot/src/bot_data/migration/db_history_scripts/clients.sql diff --git a/kdb-bot/src/bot_data/migration/db_history_scripts/config/server.sql b/bot/src/bot_data/migration/db_history_scripts/config/server.sql similarity index 100% rename from kdb-bot/src/bot_data/migration/db_history_scripts/config/server.sql rename to bot/src/bot_data/migration/db_history_scripts/config/server.sql diff --git a/kdb-bot/src/bot_data/migration/db_history_scripts/config/server_afk_channels.sql b/bot/src/bot_data/migration/db_history_scripts/config/server_afk_channels.sql similarity index 100% rename from kdb-bot/src/bot_data/migration/db_history_scripts/config/server_afk_channels.sql rename to bot/src/bot_data/migration/db_history_scripts/config/server_afk_channels.sql diff --git a/kdb-bot/src/bot_data/migration/db_history_scripts/config/server_team_roles.sql b/bot/src/bot_data/migration/db_history_scripts/config/server_team_roles.sql similarity index 100% rename from kdb-bot/src/bot_data/migration/db_history_scripts/config/server_team_roles.sql rename to bot/src/bot_data/migration/db_history_scripts/config/server_team_roles.sql diff --git a/kdb-bot/src/bot_data/migration/db_history_scripts/config/technician.sql b/bot/src/bot_data/migration/db_history_scripts/config/technician.sql similarity index 100% rename from kdb-bot/src/bot_data/migration/db_history_scripts/config/technician.sql rename to bot/src/bot_data/migration/db_history_scripts/config/technician.sql diff --git a/kdb-bot/src/bot_data/migration/db_history_scripts/config/technician_ids.sql b/bot/src/bot_data/migration/db_history_scripts/config/technician_ids.sql similarity index 100% rename from kdb-bot/src/bot_data/migration/db_history_scripts/config/technician_ids.sql rename to bot/src/bot_data/migration/db_history_scripts/config/technician_ids.sql diff --git a/kdb-bot/src/bot_data/migration/db_history_scripts/config/technician_ping_urls.sql b/bot/src/bot_data/migration/db_history_scripts/config/technician_ping_urls.sql similarity index 100% rename from kdb-bot/src/bot_data/migration/db_history_scripts/config/technician_ping_urls.sql rename to bot/src/bot_data/migration/db_history_scripts/config/technician_ping_urls.sql diff --git a/kdb-bot/src/bot_data/migration/db_history_scripts/game_servers.sql b/bot/src/bot_data/migration/db_history_scripts/game_servers.sql similarity index 100% rename from kdb-bot/src/bot_data/migration/db_history_scripts/game_servers.sql rename to bot/src/bot_data/migration/db_history_scripts/game_servers.sql diff --git a/kdb-bot/src/bot_data/migration/db_history_scripts/known_users.sql b/bot/src/bot_data/migration/db_history_scripts/known_users.sql similarity index 100% rename from kdb-bot/src/bot_data/migration/db_history_scripts/known_users.sql rename to bot/src/bot_data/migration/db_history_scripts/known_users.sql diff --git a/kdb-bot/src/bot_data/migration/db_history_scripts/levels.sql b/bot/src/bot_data/migration/db_history_scripts/levels.sql similarity index 100% rename from kdb-bot/src/bot_data/migration/db_history_scripts/levels.sql rename to bot/src/bot_data/migration/db_history_scripts/levels.sql diff --git a/kdb-bot/src/bot_data/migration/db_history_scripts/servers.sql b/bot/src/bot_data/migration/db_history_scripts/servers.sql similarity index 100% rename from kdb-bot/src/bot_data/migration/db_history_scripts/servers.sql rename to bot/src/bot_data/migration/db_history_scripts/servers.sql diff --git a/kdb-bot/src/bot_data/migration/db_history_scripts/short_rule_names.sql b/bot/src/bot_data/migration/db_history_scripts/short_rule_names.sql similarity index 100% rename from kdb-bot/src/bot_data/migration/db_history_scripts/short_rule_names.sql rename to bot/src/bot_data/migration/db_history_scripts/short_rule_names.sql diff --git a/kdb-bot/src/bot_data/migration/db_history_scripts/user_game_idents.sql b/bot/src/bot_data/migration/db_history_scripts/user_game_idents.sql similarity index 100% rename from kdb-bot/src/bot_data/migration/db_history_scripts/user_game_idents.sql rename to bot/src/bot_data/migration/db_history_scripts/user_game_idents.sql diff --git a/kdb-bot/src/bot_data/migration/db_history_scripts/user_joined_game_servers.sql b/bot/src/bot_data/migration/db_history_scripts/user_joined_game_servers.sql similarity index 100% rename from kdb-bot/src/bot_data/migration/db_history_scripts/user_joined_game_servers.sql rename to bot/src/bot_data/migration/db_history_scripts/user_joined_game_servers.sql diff --git a/kdb-bot/src/bot_data/migration/db_history_scripts/user_joined_servers.sql b/bot/src/bot_data/migration/db_history_scripts/user_joined_servers.sql similarity index 100% rename from kdb-bot/src/bot_data/migration/db_history_scripts/user_joined_servers.sql rename to bot/src/bot_data/migration/db_history_scripts/user_joined_servers.sql diff --git a/kdb-bot/src/bot_data/migration/db_history_scripts/user_joined_voice_channel.sql b/bot/src/bot_data/migration/db_history_scripts/user_joined_voice_channel.sql similarity index 100% rename from kdb-bot/src/bot_data/migration/db_history_scripts/user_joined_voice_channel.sql rename to bot/src/bot_data/migration/db_history_scripts/user_joined_voice_channel.sql diff --git a/kdb-bot/src/bot_data/migration/db_history_scripts/user_message_count_per_hour.sql b/bot/src/bot_data/migration/db_history_scripts/user_message_count_per_hour.sql similarity index 100% rename from kdb-bot/src/bot_data/migration/db_history_scripts/user_message_count_per_hour.sql rename to bot/src/bot_data/migration/db_history_scripts/user_message_count_per_hour.sql diff --git a/kdb-bot/src/bot_data/migration/db_history_scripts/user_warnings.sql b/bot/src/bot_data/migration/db_history_scripts/user_warnings.sql similarity index 100% rename from kdb-bot/src/bot_data/migration/db_history_scripts/user_warnings.sql rename to bot/src/bot_data/migration/db_history_scripts/user_warnings.sql diff --git a/bot/src/bot_data/migration/db_history_scripts/users.sql b/bot/src/bot_data/migration/db_history_scripts/users.sql new file mode 100644 index 00000000..a91cf560 --- /dev/null +++ b/bot/src/bot_data/migration/db_history_scripts/users.sql @@ -0,0 +1,45 @@ +ALTER TABLE `Users` + CHANGE `CreatedAt` `CreatedAt` DATETIME(6) NULL DEFAULT CURRENT_TIMESTAMP(6); + +ALTER TABLE `Users` + CHANGE `LastModifiedAt` `LastModifiedAt` DATETIME(6) NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6); + +CREATE TABLE IF NOT EXISTS `UsersHistory` +( + `Id` BIGINT(20) NOT NULL, + `DiscordId` BIGINT(20) NOT NULL, + `XP` BIGINT(20) NOT NULL DEFAULT 0, + `ReactionCount` BIGINT(20) NOT NULL DEFAULT 0, + `MessageCount` BIGINT(20) NOT NULL DEFAULT 0, + `Birthday` DATE NULL, + `ServerId` BIGINT(20) DEFAULT NULL, + `Deleted` BOOL DEFAULT FALSE, + `DateFrom` DATETIME(6) NOT NULL, + `DateTo` DATETIME(6) NOT NULL +); + +DROP TRIGGER IF EXISTS `TR_UsersUpdate`; + +CREATE TRIGGER `TR_UsersUpdate` + AFTER UPDATE + ON `Users` + FOR EACH ROW +BEGIN + INSERT INTO `UsersHistory` (`Id`, `DiscordId`, `XP`, `ReactionCount`, `MessageCount`, `Birthday`, `ServerId`, + `DateFrom`, `DateTo`) + VALUES (OLD.UserId, OLD.DiscordId, OLD.XP, OLD.ReactionCount, OLD.MessageCount, OLD.Birthday, OLD.ServerId, + OLD.LastModifiedAt, CURRENT_TIMESTAMP(6)); +END; + +DROP TRIGGER IF EXISTS `TR_UsersDelete`; + +CREATE TRIGGER `TR_UsersDelete` + AFTER DELETE + ON `Users` + FOR EACH ROW +BEGIN + INSERT INTO `UsersHistory` (`Id`, `DiscordId`, `XP`, `ReactionCount`, `MessageCount`, `Birthday`, `ServerId`, + `Deleted`, `DateFrom`, `DateTo`) + VALUES (OLD.UserId, OLD.DiscordId, OLD.XP, OLD.ReactionCount, OLD.MessageCount, OLD.Birthday, OLD.ServerId, TRUE, + OLD.LastModifiedAt, CURRENT_TIMESTAMP(6)); +END; \ No newline at end of file diff --git a/kdb-bot/src/bot_data/migration/default_role_migration.py b/bot/src/bot_data/migration/default_role_migration.py similarity index 100% rename from kdb-bot/src/bot_data/migration/default_role_migration.py rename to bot/src/bot_data/migration/default_role_migration.py diff --git a/kdb-bot/src/bot_data/migration/fix_updates_migration.py b/bot/src/bot_data/migration/fix_updates_migration.py similarity index 100% rename from kdb-bot/src/bot_data/migration/fix_updates_migration.py rename to bot/src/bot_data/migration/fix_updates_migration.py diff --git a/bot/src/bot_data/migration/fix_user_history_migration.py b/bot/src/bot_data/migration/fix_user_history_migration.py new file mode 100644 index 00000000..b39ec429 --- /dev/null +++ b/bot/src/bot_data/migration/fix_user_history_migration.py @@ -0,0 +1,45 @@ +from bot_core.logging.database_logger import DatabaseLogger +from bot_data.abc.migration_abc import MigrationABC +from bot_data.db_context import DBContext + + +class FixUserHistoryMigration(MigrationABC): + name = "1.2.0_FixUserHistoryMigration" + + def __init__(self, logger: DatabaseLogger, db: DBContext): + MigrationABC.__init__(self) + self._logger = logger + self._db = db + self._cursor = db.cursor + + def upgrade(self): + self._logger.debug(__name__, "Running upgrade") + + # fix 1.1.0_AchievementsMigration + self._cursor.execute( + str( + f"""ALTER TABLE UsersHistory ADD COLUMN IF NOT EXISTS ReactionCount BIGINT NOT NULL DEFAULT 0 AFTER XP;""" + ) + ) + self._cursor.execute( + str( + f"""ALTER TABLE UsersHistory ADD COLUMN IF NOT EXISTS MessageCount BIGINT NOT NULL DEFAULT 0 AFTER ReactionCount;""" + ) + ) + self._exec(__file__, "users.sql") + + def downgrade(self): + self._cursor.execute( + str( + f""" + ALTER TABLE UsersHistory DROP COLUMN MessageCount; + """ + ) + ) + self._cursor.execute( + str( + f""" + ALTER TABLE UsersHistory DROP COLUMN ReactionCount; + """ + ) + ) diff --git a/kdb-bot/src/bot_data/migration/initial_migration.py b/bot/src/bot_data/migration/initial_migration.py similarity index 100% rename from kdb-bot/src/bot_data/migration/initial_migration.py rename to bot/src/bot_data/migration/initial_migration.py diff --git a/kdb-bot/src/bot_data/migration/level_migration.py b/bot/src/bot_data/migration/level_migration.py similarity index 100% rename from kdb-bot/src/bot_data/migration/level_migration.py rename to bot/src/bot_data/migration/level_migration.py diff --git a/kdb-bot/src/bot_data/migration/remove_stats_migration.py b/bot/src/bot_data/migration/remove_stats_migration.py similarity index 100% rename from kdb-bot/src/bot_data/migration/remove_stats_migration.py rename to bot/src/bot_data/migration/remove_stats_migration.py diff --git a/kdb-bot/src/bot_data/migration/short_role_name_migration.py b/bot/src/bot_data/migration/short_role_name_migration.py similarity index 100% rename from kdb-bot/src/bot_data/migration/short_role_name_migration.py rename to bot/src/bot_data/migration/short_role_name_migration.py diff --git a/kdb-bot/src/bot_data/migration/short_role_name_only_highest_migration.py b/bot/src/bot_data/migration/short_role_name_only_highest_migration.py similarity index 100% rename from kdb-bot/src/bot_data/migration/short_role_name_only_highest_migration.py rename to bot/src/bot_data/migration/short_role_name_only_highest_migration.py diff --git a/kdb-bot/src/bot_data/migration/stats_migration.py b/bot/src/bot_data/migration/stats_migration.py similarity index 100% rename from kdb-bot/src/bot_data/migration/stats_migration.py rename to bot/src/bot_data/migration/stats_migration.py diff --git a/bot/src/bot_data/migration/steam_special_offer_migration.py b/bot/src/bot_data/migration/steam_special_offer_migration.py new file mode 100644 index 00000000..18813ae7 --- /dev/null +++ b/bot/src/bot_data/migration/steam_special_offer_migration.py @@ -0,0 +1,68 @@ +from bot_core.logging.database_logger import DatabaseLogger +from bot_data.abc.migration_abc import MigrationABC +from bot_data.db_context import DBContext + + +class SteamSpecialOfferMigration(MigrationABC): + name = "1.2.0_SteamSpecialOfferMigration" + + def __init__(self, logger: DatabaseLogger, db: DBContext): + MigrationABC.__init__(self) + self._logger = logger + self._db = db + self._cursor = db.cursor + + def upgrade(self): + self._logger.debug(__name__, "Running upgrade") + + self._cursor.execute( + str( + f""" + CREATE TABLE IF NOT EXISTS `SteamSpecialOffers` ( + `Id` BIGINT NOT NULL AUTO_INCREMENT, + `Game` VARCHAR(255) NOT NULL, + `OriginalPrice` FLOAT NOT NULL, + `DiscountPrice` FLOAT NOT NULL, + `DiscountPct` BIGINT NOT NULL, + `CreatedAt` DATETIME(6) NULL DEFAULT CURRENT_TIMESTAMP(6), + `LastModifiedAt` DATETIME(6) NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6), + PRIMARY KEY(`Id`) + ); + """ + ) + ) + + self._cursor.execute( + str( + f""" + ALTER TABLE CFG_Server + ADD COLUMN IF NOT EXISTS GameOfferNotificationChatId BIGINT NULL AFTER ShortRoleNameSetOnlyHighest; + """ + ) + ) + + self._cursor.execute( + str( + f""" + ALTER TABLE CFG_ServerHistory + ADD COLUMN IF NOT EXISTS GameOfferNotificationChatId BIGINT NULL AFTER ShortRoleNameSetOnlyHighest; + """ + ) + ) + + def downgrade(self): + self._cursor.execute("DROP TABLE `SteamSpecialOffers`;") + self._cursor.execute( + str( + f""" + ALTER TABLE CFG_Server DROP COLUMN ShortRoleNameSetOnlyHighest; + """ + ) + ) + self._cursor.execute( + str( + f""" + ALTER TABLE CFG_ServerHistory DROP COLUMN ShortRoleNameSetOnlyHighest; + """ + ) + ) diff --git a/kdb-bot/src/bot_data/migration/user_joined_game_server_migration.py b/bot/src/bot_data/migration/user_joined_game_server_migration.py similarity index 100% rename from kdb-bot/src/bot_data/migration/user_joined_game_server_migration.py rename to bot/src/bot_data/migration/user_joined_game_server_migration.py diff --git a/kdb-bot/src/bot_data/migration/user_message_count_per_hour_migration.py b/bot/src/bot_data/migration/user_message_count_per_hour_migration.py similarity index 100% rename from kdb-bot/src/bot_data/migration/user_message_count_per_hour_migration.py rename to bot/src/bot_data/migration/user_message_count_per_hour_migration.py diff --git a/kdb-bot/src/bot_data/migration/user_warning_migration.py b/bot/src/bot_data/migration/user_warning_migration.py similarity index 100% rename from kdb-bot/src/bot_data/migration/user_warning_migration.py rename to bot/src/bot_data/migration/user_warning_migration.py diff --git a/kdb-bot/src/bot_data/model/__init__.py b/bot/src/bot_data/model/__init__.py similarity index 84% rename from kdb-bot/src/bot_data/model/__init__.py rename to bot/src/bot_data/model/__init__.py index c06c1f3e..fc71a463 100644 --- a/kdb-bot/src/bot_data/model/__init__.py +++ b/bot/src/bot_data/model/__init__.py @@ -15,7 +15,7 @@ __title__ = "bot_data.model" __author__ = "Sven Heidemann" __license__ = "MIT" __copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de" -__version__ = "1.1.10" +__version__ = "1.2.0" from collections import namedtuple @@ -23,4 +23,4 @@ from collections import namedtuple # imports VersionInfo = namedtuple("VersionInfo", "major minor micro") -version_info = VersionInfo(major="1", minor="1", micro="10") +version_info = VersionInfo(major="1", minor="2", micro="0") diff --git a/kdb-bot/src/bot_data/model/achievement.py b/bot/src/bot_data/model/achievement.py similarity index 100% rename from kdb-bot/src/bot_data/model/achievement.py rename to bot/src/bot_data/model/achievement.py diff --git a/kdb-bot/src/bot_data/model/achievement_history.py b/bot/src/bot_data/model/achievement_history.py similarity index 100% rename from kdb-bot/src/bot_data/model/achievement_history.py rename to bot/src/bot_data/model/achievement_history.py diff --git a/kdb-bot/src/bot_data/model/api_key.py b/bot/src/bot_data/model/api_key.py similarity index 100% rename from kdb-bot/src/bot_data/model/api_key.py rename to bot/src/bot_data/model/api_key.py diff --git a/kdb-bot/src/bot_data/model/auth_role_enum.py b/bot/src/bot_data/model/auth_role_enum.py similarity index 100% rename from kdb-bot/src/bot_data/model/auth_role_enum.py rename to bot/src/bot_data/model/auth_role_enum.py diff --git a/kdb-bot/src/bot_data/model/auth_user.py b/bot/src/bot_data/model/auth_user.py similarity index 100% rename from kdb-bot/src/bot_data/model/auth_user.py rename to bot/src/bot_data/model/auth_user.py diff --git a/kdb-bot/src/bot_data/model/auth_user_users_relation.py b/bot/src/bot_data/model/auth_user_users_relation.py similarity index 100% rename from kdb-bot/src/bot_data/model/auth_user_users_relation.py rename to bot/src/bot_data/model/auth_user_users_relation.py diff --git a/kdb-bot/src/bot_data/model/auto_role.py b/bot/src/bot_data/model/auto_role.py similarity index 100% rename from kdb-bot/src/bot_data/model/auto_role.py rename to bot/src/bot_data/model/auto_role.py diff --git a/kdb-bot/src/bot_data/model/auto_role_history.py b/bot/src/bot_data/model/auto_role_history.py similarity index 100% rename from kdb-bot/src/bot_data/model/auto_role_history.py rename to bot/src/bot_data/model/auto_role_history.py diff --git a/kdb-bot/src/bot_data/model/auto_role_rule.py b/bot/src/bot_data/model/auto_role_rule.py similarity index 100% rename from kdb-bot/src/bot_data/model/auto_role_rule.py rename to bot/src/bot_data/model/auto_role_rule.py diff --git a/kdb-bot/src/bot_data/model/auto_role_rule_history.py b/bot/src/bot_data/model/auto_role_rule_history.py similarity index 100% rename from kdb-bot/src/bot_data/model/auto_role_rule_history.py rename to bot/src/bot_data/model/auto_role_rule_history.py diff --git a/kdb-bot/src/bot_data/model/client.py b/bot/src/bot_data/model/client.py similarity index 100% rename from kdb-bot/src/bot_data/model/client.py rename to bot/src/bot_data/model/client.py diff --git a/kdb-bot/src/bot_data/model/client_history.py b/bot/src/bot_data/model/client_history.py similarity index 100% rename from kdb-bot/src/bot_data/model/client_history.py rename to bot/src/bot_data/model/client_history.py diff --git a/kdb-bot/src/bot_data/model/game_server.py b/bot/src/bot_data/model/game_server.py similarity index 100% rename from kdb-bot/src/bot_data/model/game_server.py rename to bot/src/bot_data/model/game_server.py diff --git a/kdb-bot/src/bot_data/model/known_user.py b/bot/src/bot_data/model/known_user.py similarity index 100% rename from kdb-bot/src/bot_data/model/known_user.py rename to bot/src/bot_data/model/known_user.py diff --git a/kdb-bot/src/bot_data/model/known_user_history.py b/bot/src/bot_data/model/known_user_history.py similarity index 100% rename from kdb-bot/src/bot_data/model/known_user_history.py rename to bot/src/bot_data/model/known_user_history.py diff --git a/kdb-bot/src/bot_data/model/level.py b/bot/src/bot_data/model/level.py similarity index 100% rename from kdb-bot/src/bot_data/model/level.py rename to bot/src/bot_data/model/level.py diff --git a/kdb-bot/src/bot_data/model/level_history.py b/bot/src/bot_data/model/level_history.py similarity index 100% rename from kdb-bot/src/bot_data/model/level_history.py rename to bot/src/bot_data/model/level_history.py diff --git a/kdb-bot/src/bot_data/model/migration_history.py b/bot/src/bot_data/model/migration_history.py similarity index 100% rename from kdb-bot/src/bot_data/model/migration_history.py rename to bot/src/bot_data/model/migration_history.py diff --git a/kdb-bot/src/bot_data/model/server.py b/bot/src/bot_data/model/server.py similarity index 100% rename from kdb-bot/src/bot_data/model/server.py rename to bot/src/bot_data/model/server.py diff --git a/kdb-bot/src/bot_data/model/server_afk_channel_ids_config.py b/bot/src/bot_data/model/server_afk_channel_ids_config.py similarity index 100% rename from kdb-bot/src/bot_data/model/server_afk_channel_ids_config.py rename to bot/src/bot_data/model/server_afk_channel_ids_config.py diff --git a/kdb-bot/src/bot_data/model/server_config.py b/bot/src/bot_data/model/server_config.py similarity index 91% rename from kdb-bot/src/bot_data/model/server_config.py rename to bot/src/bot_data/model/server_config.py index 8a36ac6f..cf220355 100644 --- a/kdb-bot/src/bot_data/model/server_config.py +++ b/bot/src/bot_data/model/server_config.py @@ -24,12 +24,14 @@ class ServerConfig(TableABC, ConfigurationModelABC): xp_per_ontime_hour: int, xp_per_event_participation: int, xp_per_achievement: int, + xp_for_birthday: int, afk_command_channel_id: int, help_voice_channel_id: int, team_channel_id: int, login_message_channel_id: int, default_role_id: Optional[int], short_role_name_only_set_highest_role: bool, + game_offer_notification_chat_id: int, feature_flags: dict[FeatureFlagsEnum], server: Server, afk_channel_ids: List[int], @@ -48,12 +50,14 @@ class ServerConfig(TableABC, ConfigurationModelABC): self._xp_per_ontime_hour = xp_per_ontime_hour self._xp_per_event_participation = xp_per_event_participation self._xp_per_achievement = xp_per_achievement + self._xp_for_birthday = xp_for_birthday self._afk_command_channel_id = afk_command_channel_id self._help_voice_channel_id = help_voice_channel_id self._team_channel_id = team_channel_id self._login_message_channel_id = login_message_channel_id self._default_role_id = default_role_id self._short_role_name_only_set_highest_role = short_role_name_only_set_highest_role + self._game_offer_notification_chat_id = game_offer_notification_chat_id self._feature_flags = feature_flags self._server = server @@ -76,12 +80,14 @@ class ServerConfig(TableABC, ConfigurationModelABC): 10, 10, 10, + 10, guild.system_channel.id, guild.system_channel.id, guild.system_channel.id, guild.system_channel.id, None, False, + guild.system_channel.id, {}, server, List(int), @@ -164,6 +170,14 @@ class ServerConfig(TableABC, ConfigurationModelABC): def xp_per_achievement(self, value: int): self._xp_per_achievement = value + @property + def xp_for_birthday(self) -> int: + return self._xp_for_birthday + + @xp_for_birthday.setter + def xp_for_birthday(self, value: int): + self._xp_for_birthday = value + @property def afk_command_channel_id(self) -> int: return self._afk_command_channel_id @@ -212,6 +226,14 @@ class ServerConfig(TableABC, ConfigurationModelABC): def short_role_name_only_set_highest_role(self, value: bool): self._short_role_name_only_set_highest_role = value + @property + def game_offer_notification_chat_id(self) -> int: + return self._game_offer_notification_chat_id + + @game_offer_notification_chat_id.setter + def game_offer_notification_chat_id(self, value: int): + self._game_offer_notification_chat_id = value + @property def feature_flags(self) -> dict[FeatureFlagsEnum]: return self._feature_flags @@ -280,12 +302,14 @@ class ServerConfig(TableABC, ConfigurationModelABC): `XpPerOntimeHour`, `XpPerEventParticipation`, `XpPerAchievement`, + `XpForBirthday`, `AFKCommandChannelId`, `HelpVoiceChannelId`, `TeamChannelId`, `LoginMessageChannelId`, `DefaultRoleId`, `ShortRoleNameSetOnlyHighest`, + `GameOfferNotificationChatId`, `FeatureFlags`, `ServerId` ) VALUES ( @@ -298,12 +322,14 @@ class ServerConfig(TableABC, ConfigurationModelABC): {self._xp_per_ontime_hour}, {self._xp_per_event_participation}, {self._xp_per_achievement}, + '{self._xp_for_birthday}', {self._afk_command_channel_id}, {self._help_voice_channel_id}, {self._team_channel_id}, {self._login_message_channel_id}, {"NULL" if self._default_role_id is None else self._default_role_id}, {self._short_role_name_only_set_highest_role}, + {self._game_offer_notification_chat_id}, '{json.dumps(self._feature_flags)}', {self._server.id} ); @@ -324,12 +350,14 @@ class ServerConfig(TableABC, ConfigurationModelABC): `XpPerOntimeHour` = {self._xp_per_ontime_hour}, `XpPerEventParticipation` = {self._xp_per_event_participation}, `XpPerAchievement` = {self._xp_per_achievement}, + `XpForBirthday` = {self._xp_for_birthday}, `AFKCommandChannelId` = {self._afk_command_channel_id}, `HelpVoiceChannelId` = {self._help_voice_channel_id}, `TeamChannelId` = {self._team_channel_id}, `LoginMessageChannelId` = {self._login_message_channel_id}, `DefaultRoleId` = {"NULL" if self._default_role_id is None else self._default_role_id}, `ShortRoleNameSetOnlyHighest` = {self._short_role_name_only_set_highest_role}, + `GameOfferNotificationChatId` = {self._game_offer_notification_chat_id}, `FeatureFlags` = '{json.dumps(self._feature_flags)}', `ServerId` = {self._server.id} WHERE `Id` = {self._id}; diff --git a/kdb-bot/src/bot_data/model/server_config_history.py b/bot/src/bot_data/model/server_config_history.py similarity index 100% rename from kdb-bot/src/bot_data/model/server_config_history.py rename to bot/src/bot_data/model/server_config_history.py diff --git a/kdb-bot/src/bot_data/model/server_history.py b/bot/src/bot_data/model/server_history.py similarity index 100% rename from kdb-bot/src/bot_data/model/server_history.py rename to bot/src/bot_data/model/server_history.py diff --git a/kdb-bot/src/bot_data/model/server_team_role_ids_config.py b/bot/src/bot_data/model/server_team_role_ids_config.py similarity index 100% rename from kdb-bot/src/bot_data/model/server_team_role_ids_config.py rename to bot/src/bot_data/model/server_team_role_ids_config.py diff --git a/kdb-bot/src/bot_data/model/short_role_name.py b/bot/src/bot_data/model/short_role_name.py similarity index 100% rename from kdb-bot/src/bot_data/model/short_role_name.py rename to bot/src/bot_data/model/short_role_name.py diff --git a/kdb-bot/src/bot_data/model/short_role_name_history.py b/bot/src/bot_data/model/short_role_name_history.py similarity index 100% rename from kdb-bot/src/bot_data/model/short_role_name_history.py rename to bot/src/bot_data/model/short_role_name_history.py diff --git a/kdb-bot/src/bot_data/model/short_role_name_position_enum.py b/bot/src/bot_data/model/short_role_name_position_enum.py similarity index 100% rename from kdb-bot/src/bot_data/model/short_role_name_position_enum.py rename to bot/src/bot_data/model/short_role_name_position_enum.py diff --git a/bot/src/bot_data/model/steam_special_offer.py b/bot/src/bot_data/model/steam_special_offer.py new file mode 100644 index 00000000..76301dc4 --- /dev/null +++ b/bot/src/bot_data/model/steam_special_offer.py @@ -0,0 +1,115 @@ +from datetime import datetime + +from cpl_core.database import TableABC + + +class SteamSpecialOffer(TableABC): + def __init__( + self, + name: str, + original_price: float, + discount_price: float, + discount_pct: int, + created_at: datetime = None, + modified_at: datetime = None, + id=0, + ): + self._id = id + self._name = name + self._original_price = original_price + self._discount_price = discount_price + self._discount_pct = discount_pct + + TableABC.__init__(self) + self._created_at = created_at if created_at is not None else self._created_at + self._modified_at = modified_at if modified_at is not None else self._modified_at + + @property + def id(self) -> int: + return self._id + + @property + def name(self) -> str: + return self._name + + @name.setter + def name(self, value: str): + self._name = value + + @property + def original_price(self) -> float: + return self._original_price + + @original_price.setter + def original_price(self, value: float): + self._original_price = value + + @property + def discount_price(self) -> float: + return self._discount_price + + @discount_price.setter + def discount_price(self, value: float): + self._discount_price = value + + @property + def discount_pct(self) -> int: + return self._discount_pct + + @discount_pct.setter + def discount_pct(self, value: int): + self._discount_pct = value + + @staticmethod + def get_select_all_string() -> str: + return str( + f""" + SELECT * FROM `SteamSpecialOffers`; + """ + ) + + @staticmethod + def get_select_by_name_string(name: str) -> str: + return str( + f""" + SELECT * FROM `SteamSpecialOffers` + WHERE `Game` = '{name}'; + """ + ) + + @property + def insert_string(self) -> str: + return str( + f""" + INSERT INTO `SteamSpecialOffers` ( + `Game`, `OriginalPrice`, `DiscountPrice`, `DiscountPct` + ) VALUES ( + '{self._name}', + {self._original_price}, + {self._discount_price}, + {self._discount_pct} + ); + """ + ) + + @property + def udpate_string(self) -> str: + return str( + f""" + UPDATE `SteamSpecialOffers` + SET `Game` = '{self._name}', + `OriginalPrice` = {self._original_price}, + `DiscountPrice` = {self._discount_price}, + `DiscountPct` = {self._discount_pct} + WHERE `Id` = {self._id}; + """ + ) + + @property + def delete_string(self) -> str: + return str( + f""" + DELETE FROM `SteamSpecialOffers` + WHERE `Id` = {self._id}; + """ + ) diff --git a/kdb-bot/src/bot_data/model/team_member_type_enum.py b/bot/src/bot_data/model/team_member_type_enum.py similarity index 100% rename from kdb-bot/src/bot_data/model/team_member_type_enum.py rename to bot/src/bot_data/model/team_member_type_enum.py diff --git a/kdb-bot/src/bot_data/model/technician_config.py b/bot/src/bot_data/model/technician_config.py similarity index 100% rename from kdb-bot/src/bot_data/model/technician_config.py rename to bot/src/bot_data/model/technician_config.py diff --git a/kdb-bot/src/bot_data/model/technician_config_history.py b/bot/src/bot_data/model/technician_config_history.py similarity index 100% rename from kdb-bot/src/bot_data/model/technician_config_history.py rename to bot/src/bot_data/model/technician_config_history.py diff --git a/kdb-bot/src/bot_data/model/technician_id_config.py b/bot/src/bot_data/model/technician_id_config.py similarity index 100% rename from kdb-bot/src/bot_data/model/technician_id_config.py rename to bot/src/bot_data/model/technician_id_config.py diff --git a/kdb-bot/src/bot_data/model/technician_id_config_history.py b/bot/src/bot_data/model/technician_id_config_history.py similarity index 100% rename from kdb-bot/src/bot_data/model/technician_id_config_history.py rename to bot/src/bot_data/model/technician_id_config_history.py diff --git a/kdb-bot/src/bot_data/model/technician_ping_url_config.py b/bot/src/bot_data/model/technician_ping_url_config.py similarity index 100% rename from kdb-bot/src/bot_data/model/technician_ping_url_config.py rename to bot/src/bot_data/model/technician_ping_url_config.py diff --git a/kdb-bot/src/bot_data/model/technician_ping_url_config_history.py b/bot/src/bot_data/model/technician_ping_url_config_history.py similarity index 100% rename from kdb-bot/src/bot_data/model/technician_ping_url_config_history.py rename to bot/src/bot_data/model/technician_ping_url_config_history.py diff --git a/kdb-bot/src/bot_data/model/user.py b/bot/src/bot_data/model/user.py similarity index 90% rename from kdb-bot/src/bot_data/model/user.py rename to bot/src/bot_data/model/user.py index 57e1cc67..ed44c58a 100644 --- a/kdb-bot/src/bot_data/model/user.py +++ b/bot/src/bot_data/model/user.py @@ -1,4 +1,4 @@ -from datetime import datetime +from datetime import datetime, date from typing import Optional from cpl_core.database import TableABC @@ -17,6 +17,7 @@ class User(TableABC): xp: int, reaction_count: int, message_count: int, + birthday: Optional[date], server: Optional[Server], created_at: datetime = None, modified_at: datetime = None, @@ -27,6 +28,7 @@ class User(TableABC): self._xp = xp self._reaction_count = reaction_count self._message_count = message_count + self._birthday = birthday self._server = server TableABC.__init__(self) @@ -79,6 +81,14 @@ class User(TableABC): def reaction_count(self, value: int): self._reaction_count = value + @property + def birthday(self) -> Optional[datetime]: + return self._birthday + + @birthday.setter + def birthday(self, value: Optional[datetime]): + self._birthday = value + @property @ServiceProviderABC.inject def ontime(self, services: ServiceProviderABC) -> float: @@ -105,7 +115,9 @@ class User(TableABC): self, services: ServiceProviderABC, ) -> bool: - from bot_data.abc.user_joined_server_repository_abc import UserJoinedServerRepositoryABC + from bot_data.abc.user_joined_server_repository_abc import ( + UserJoinedServerRepositoryABC, + ) ujs: UserJoinedServerRepositoryABC = services.get_service(UserJoinedServerRepositoryABC) return ujs.find_active_user_joined_server_by_user_id(self.id) is None @@ -116,7 +128,9 @@ class User(TableABC): self, services: ServiceProviderABC, ) -> List["UserGameIdent"]: - from bot_data.abc.user_game_ident_repository_abc import UserGameIdentRepositoryABC + from bot_data.abc.user_game_ident_repository_abc import ( + UserGameIdentRepositoryABC, + ) game_idents_repo: UserGameIdentRepositoryABC = services.get_service(UserGameIdentRepositoryABC) return game_idents_repo.get_user_game_idents_by_user_id(self.id) @@ -171,12 +185,13 @@ class User(TableABC): return str( f""" INSERT INTO `Users` ( - `DiscordId`, `XP`, `MessageCount`, `ReactionCount`, `ServerId` + `DiscordId`, `XP`, `MessageCount`, `ReactionCount`, `Birthday`, `ServerId` ) VALUES ( {self._discord_id}, {self._xp}, {self._message_count}, {self._reaction_count}, + '{self._birthday}', {self._server.id} ); """ @@ -189,7 +204,8 @@ class User(TableABC): UPDATE `Users` SET `XP` = {self._xp}, `MessageCount` = {self._message_count}, - `ReactionCount` = {self._reaction_count} + `ReactionCount` = {self._reaction_count}, + `Birthday` = '{self._birthday}' WHERE `UserId` = {self._user_id}; """ ) diff --git a/kdb-bot/src/bot_data/model/user_game_ident.py b/bot/src/bot_data/model/user_game_ident.py similarity index 100% rename from kdb-bot/src/bot_data/model/user_game_ident.py rename to bot/src/bot_data/model/user_game_ident.py diff --git a/kdb-bot/src/bot_data/model/user_got_achievement.py b/bot/src/bot_data/model/user_got_achievement.py similarity index 100% rename from kdb-bot/src/bot_data/model/user_got_achievement.py rename to bot/src/bot_data/model/user_got_achievement.py diff --git a/kdb-bot/src/bot_data/model/user_history.py b/bot/src/bot_data/model/user_history.py similarity index 94% rename from kdb-bot/src/bot_data/model/user_history.py rename to bot/src/bot_data/model/user_history.py index 2bf39954..357c854a 100644 --- a/kdb-bot/src/bot_data/model/user_history.py +++ b/bot/src/bot_data/model/user_history.py @@ -60,7 +60,9 @@ class UserHistory(HistoryTableABC): self, services: ServiceProviderABC, ) -> bool: - from bot_data.abc.user_joined_server_repository_abc import UserJoinedServerRepositoryABC + from bot_data.abc.user_joined_server_repository_abc import ( + UserJoinedServerRepositoryABC, + ) ujs: UserJoinedServerRepositoryABC = services.get_service(UserJoinedServerRepositoryABC) return ujs.find_active_user_joined_server_by_user_id(self.id) is None @@ -71,7 +73,9 @@ class UserHistory(HistoryTableABC): self, services: ServiceProviderABC, ) -> List["UserGameIdent"]: - from bot_data.abc.user_game_ident_repository_abc import UserGameIdentRepositoryABC + from bot_data.abc.user_game_ident_repository_abc import ( + UserGameIdentRepositoryABC, + ) game_idents_repo: UserGameIdentRepositoryABC = services.get_service(UserGameIdentRepositoryABC) return game_idents_repo.get_user_game_idents_by_user_id(self.id) diff --git a/kdb-bot/src/bot_data/model/user_joined_game_server.py b/bot/src/bot_data/model/user_joined_game_server.py similarity index 100% rename from kdb-bot/src/bot_data/model/user_joined_game_server.py rename to bot/src/bot_data/model/user_joined_game_server.py diff --git a/kdb-bot/src/bot_data/model/user_joined_game_server_history.py b/bot/src/bot_data/model/user_joined_game_server_history.py similarity index 100% rename from kdb-bot/src/bot_data/model/user_joined_game_server_history.py rename to bot/src/bot_data/model/user_joined_game_server_history.py diff --git a/kdb-bot/src/bot_data/model/user_joined_server.py b/bot/src/bot_data/model/user_joined_server.py similarity index 100% rename from kdb-bot/src/bot_data/model/user_joined_server.py rename to bot/src/bot_data/model/user_joined_server.py diff --git a/kdb-bot/src/bot_data/model/user_joined_server_history.py b/bot/src/bot_data/model/user_joined_server_history.py similarity index 100% rename from kdb-bot/src/bot_data/model/user_joined_server_history.py rename to bot/src/bot_data/model/user_joined_server_history.py diff --git a/kdb-bot/src/bot_data/model/user_joined_voice_channel.py b/bot/src/bot_data/model/user_joined_voice_channel.py similarity index 100% rename from kdb-bot/src/bot_data/model/user_joined_voice_channel.py rename to bot/src/bot_data/model/user_joined_voice_channel.py diff --git a/kdb-bot/src/bot_data/model/user_joined_voice_channel_history.py b/bot/src/bot_data/model/user_joined_voice_channel_history.py similarity index 100% rename from kdb-bot/src/bot_data/model/user_joined_voice_channel_history.py rename to bot/src/bot_data/model/user_joined_voice_channel_history.py diff --git a/kdb-bot/src/bot_data/model/user_message_count_per_hour.py b/bot/src/bot_data/model/user_message_count_per_hour.py similarity index 100% rename from kdb-bot/src/bot_data/model/user_message_count_per_hour.py rename to bot/src/bot_data/model/user_message_count_per_hour.py diff --git a/kdb-bot/src/bot_data/model/user_role_enum.py b/bot/src/bot_data/model/user_role_enum.py similarity index 100% rename from kdb-bot/src/bot_data/model/user_role_enum.py rename to bot/src/bot_data/model/user_role_enum.py diff --git a/kdb-bot/src/bot_data/model/user_warnings.py b/bot/src/bot_data/model/user_warnings.py similarity index 100% rename from kdb-bot/src/bot_data/model/user_warnings.py rename to bot/src/bot_data/model/user_warnings.py diff --git a/bot/src/bot_data/model/user_warnings_history.py b/bot/src/bot_data/model/user_warnings_history.py new file mode 100644 index 00000000..a0ddef24 --- /dev/null +++ b/bot/src/bot_data/model/user_warnings_history.py @@ -0,0 +1,43 @@ +from typing import Optional + +from bot_data.abc.history_table_abc import HistoryTableABC + + +# had to name it UserWarnings instead of UserWarning because UserWarning is a builtin class +class UserWarningsHistory(HistoryTableABC): + def __init__( + self, + description: str, + user: int, + author: Optional[int], + deleted: bool, + date_from: str, + date_to: str, + id=0, + ): + HistoryTableABC.__init__(self) + + self._id = id + self._description = description + self._user = user + self._author = author + + self._deleted = deleted + self._date_from = date_from + self._date_to = date_to + + @property + def id(self) -> int: + return self._id + + @property + def description(self) -> str: + return self._description + + @property + def user(self) -> int: + return self._user + + @property + def author(self) -> Optional[int]: + return self._author diff --git a/kdb-bot/src/bot_data/service/__init__.py b/bot/src/bot_data/service/__init__.py similarity index 84% rename from kdb-bot/src/bot_data/service/__init__.py rename to bot/src/bot_data/service/__init__.py index da13a82b..d393f1f1 100644 --- a/kdb-bot/src/bot_data/service/__init__.py +++ b/bot/src/bot_data/service/__init__.py @@ -15,7 +15,7 @@ __title__ = "bot_data.service" __author__ = "Sven Heidemann" __license__ = "MIT" __copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de" -__version__ = "1.1.10" +__version__ = "1.2.0" from collections import namedtuple @@ -23,4 +23,4 @@ from collections import namedtuple # imports VersionInfo = namedtuple("VersionInfo", "major minor micro") -version_info = VersionInfo(major="1", minor="1", micro="10") +version_info = VersionInfo(major="1", minor="2", micro="0") diff --git a/kdb-bot/src/bot_data/service/achievements_repository_service.py b/bot/src/bot_data/service/achievements_repository_service.py similarity index 92% rename from kdb-bot/src/bot_data/service/achievements_repository_service.py rename to bot/src/bot_data/service/achievements_repository_service.py index b848fb5a..d8923db5 100644 --- a/kdb-bot/src/bot_data/service/achievements_repository_service.py +++ b/bot/src/bot_data/service/achievements_repository_service.py @@ -65,7 +65,10 @@ class AchievementRepositoryService(AchievementRepositoryABC): def get_achievements_by_server_id(self, server_id: int) -> List[Achievement]: achievements = List(Achievement) - self._logger.trace(__name__, f"Send SQL command: {Achievement.get_select_by_server_id_string(server_id)}") + self._logger.trace( + __name__, + f"Send SQL command: {Achievement.get_select_by_server_id_string(server_id)}", + ) results = self._context.select(Achievement.get_select_by_server_id_string(server_id)) for result in results: self._logger.trace(__name__, f"Get user with id {result[0]}") @@ -76,7 +79,10 @@ class AchievementRepositoryService(AchievementRepositoryABC): def get_achievements_by_user_id(self, user_id: int) -> List[Achievement]: achievements = List(Achievement) achievements_joins = List(UserGotAchievement) - self._logger.trace(__name__, f"Send SQL command: {UserGotAchievement.get_select_by_user_id_string(user_id)}") + self._logger.trace( + __name__, + f"Send SQL command: {UserGotAchievement.get_select_by_user_id_string(user_id)}", + ) results = self._context.select(UserGotAchievement.get_select_by_user_id_string(user_id)) for result in results: self._logger.trace(__name__, f"Got UserGotAchievement with id {result[0]}") @@ -93,7 +99,8 @@ class AchievementRepositoryService(AchievementRepositoryABC): def get_user_got_achievements_by_achievement_id(self, achievement_id: int) -> List[Achievement]: achievements_joins = List(UserGotAchievement) self._logger.trace( - __name__, f"Send SQL command: {UserGotAchievement.get_select_by_achievement_id_string(achievement_id)}" + __name__, + f"Send SQL command: {UserGotAchievement.get_select_by_achievement_id_string(achievement_id)}", ) results = self._context.select(UserGotAchievement.get_select_by_achievement_id_string(achievement_id)) for result in results: diff --git a/kdb-bot/src/bot_data/service/api_key_repository_service.py b/bot/src/bot_data/service/api_key_repository_service.py similarity index 100% rename from kdb-bot/src/bot_data/service/api_key_repository_service.py rename to bot/src/bot_data/service/api_key_repository_service.py diff --git a/kdb-bot/src/bot_data/service/auth_user_repository_service.py b/bot/src/bot_data/service/auth_user_repository_service.py similarity index 100% rename from kdb-bot/src/bot_data/service/auth_user_repository_service.py rename to bot/src/bot_data/service/auth_user_repository_service.py diff --git a/kdb-bot/src/bot_data/service/auto_role_repository_service.py b/bot/src/bot_data/service/auto_role_repository_service.py similarity index 74% rename from kdb-bot/src/bot_data/service/auto_role_repository_service.py rename to bot/src/bot_data/service/auto_role_repository_service.py index d1599341..bf0d781a 100644 --- a/kdb-bot/src/bot_data/service/auto_role_repository_service.py +++ b/bot/src/bot_data/service/auto_role_repository_service.py @@ -11,7 +11,12 @@ from bot_data.model.auto_role_rule import AutoRoleRule class AutoRoleRepositoryService(AutoRoleRepositoryABC): - def __init__(self, logger: DatabaseLogger, db_context: DatabaseContextABC, servers: ServerRepositoryABC): + def __init__( + self, + logger: DatabaseLogger, + db_context: DatabaseContextABC, + servers: ServerRepositoryABC, + ): self._logger = logger self._context = db_context self._servers = servers @@ -25,7 +30,12 @@ class AutoRoleRepositoryService(AutoRoleRepositoryABC): for result in results: auto_roles.append( AutoRole( - self._servers.get_server_by_id(result[1]), result[2], result[3], result[4], result[5], id=result[0] + self._servers.get_server_by_id(result[1]), + result[2], + result[3], + result[4], + result[5], + id=result[0], ) ) @@ -35,7 +45,12 @@ class AutoRoleRepositoryService(AutoRoleRepositoryABC): self._logger.trace(__name__, f"Send SQL command: {AutoRole.get_select_by_id_string(id)}") result = self._context.select(AutoRole.get_select_by_id_string(id))[0] return AutoRole( - self._servers.get_server_by_id(result[1]), result[2], result[3], result[4], result[5], id=result[0] + self._servers.get_server_by_id(result[1]), + result[2], + result[3], + result[4], + result[5], + id=result[0], ) def find_auto_role_by_id(self, id: int) -> Optional[AutoRole]: @@ -47,7 +62,12 @@ class AutoRoleRepositoryService(AutoRoleRepositoryABC): result = result[0] return AutoRole( - self._servers.get_server_by_id(result[1]), result[2], result[3], result[4], result[5], id=result[0] + self._servers.get_server_by_id(result[1]), + result[2], + result[3], + result[4], + result[5], + id=result[0], ) def get_auto_roles_by_server_id(self, id: int) -> List[AutoRole]: @@ -57,7 +77,12 @@ class AutoRoleRepositoryService(AutoRoleRepositoryABC): for result in results: auto_roles.append( AutoRole( - self._servers.get_server_by_id(result[1]), result[2], result[3], result[4], result[5], id=result[0] + self._servers.get_server_by_id(result[1]), + result[2], + result[3], + result[4], + result[5], + id=result[0], ) ) @@ -70,7 +95,12 @@ class AutoRoleRepositoryService(AutoRoleRepositoryABC): ) result = self._context.select(AutoRole.get_select_by_message_id_string(id))[0] return AutoRole( - self._servers.get_server_by_id(result[1]), result[2], result[3], result[4], result[5], id=result[0] + self._servers.get_server_by_id(result[1]), + result[2], + result[3], + result[4], + result[5], + id=result[0], ) def find_auto_role_by_message_id(self, id: int) -> Optional[AutoRole]: @@ -85,7 +115,12 @@ class AutoRoleRepositoryService(AutoRoleRepositoryABC): result = result[0] return AutoRole( - self._servers.get_server_by_id(result[1]), result[2], result[3], result[4], result[5], id=result[0] + self._servers.get_server_by_id(result[1]), + result[2], + result[3], + result[4], + result[5], + id=result[0], ) def add_auto_role(self, auto_role: AutoRole): @@ -107,7 +142,12 @@ class AutoRoleRepositoryService(AutoRoleRepositoryABC): for result in results: auto_role_rules.append( AutoRoleRule( - self.get_auto_role_by_id(result[1]), result[2], result[3], result[4], result[5], id=result[0] + self.get_auto_role_by_id(result[1]), + result[2], + result[3], + result[4], + result[5], + id=result[0], ) ) @@ -117,7 +157,12 @@ class AutoRoleRepositoryService(AutoRoleRepositoryABC): self._logger.trace(__name__, f"Send SQL command: {AutoRoleRule.get_select_by_id_string(id)}") result = self._context.select(AutoRoleRule.get_select_by_id_string(id))[0] return AutoRoleRule( - self.get_auto_role_by_id(result[1]), result[2], result[3], result[4], result[5], id=result[0] + self.get_auto_role_by_id(result[1]), + result[2], + result[3], + result[4], + result[5], + id=result[0], ) def get_auto_role_rules_by_auto_role_id(self, id: int) -> List[AutoRoleRule]: @@ -130,7 +175,12 @@ class AutoRoleRepositoryService(AutoRoleRepositoryABC): for result in results: auto_role_rules.append( AutoRoleRule( - self.get_auto_role_by_id(result[1]), result[2], result[3], result[4], result[5], id=result[0] + self.get_auto_role_by_id(result[1]), + result[2], + result[3], + result[4], + result[5], + id=result[0], ) ) diff --git a/kdb-bot/src/bot_data/service/cache_service.py b/bot/src/bot_data/service/cache_service.py similarity index 100% rename from kdb-bot/src/bot_data/service/cache_service.py rename to bot/src/bot_data/service/cache_service.py diff --git a/kdb-bot/src/bot_data/service/client_repository_service.py b/bot/src/bot_data/service/client_repository_service.py similarity index 98% rename from kdb-bot/src/bot_data/service/client_repository_service.py rename to bot/src/bot_data/service/client_repository_service.py index 587569a0..e3d08ad3 100644 --- a/kdb-bot/src/bot_data/service/client_repository_service.py +++ b/bot/src/bot_data/service/client_repository_service.py @@ -64,7 +64,10 @@ class ClientRepositoryService(ClientRepositoryABC): def get_clients_by_server_id(self, server_id: int) -> List[Client]: clients = List(Client) - self._logger.trace(__name__, f"Send SQL command: {Client.get_select_by_server_id_string(server_id)}") + self._logger.trace( + __name__, + f"Send SQL command: {Client.get_select_by_server_id_string(server_id)}", + ) results = self._context.select(Client.get_select_by_server_id_string(server_id)) for result in results: clients.append( diff --git a/kdb-bot/src/bot_data/service/game_server_repository_service.py b/bot/src/bot_data/service/game_server_repository_service.py similarity index 100% rename from kdb-bot/src/bot_data/service/game_server_repository_service.py rename to bot/src/bot_data/service/game_server_repository_service.py diff --git a/kdb-bot/src/bot_data/service/known_user_repository_service.py b/bot/src/bot_data/service/known_user_repository_service.py similarity index 100% rename from kdb-bot/src/bot_data/service/known_user_repository_service.py rename to bot/src/bot_data/service/known_user_repository_service.py diff --git a/kdb-bot/src/bot_data/service/level_repository_service.py b/bot/src/bot_data/service/level_repository_service.py similarity index 100% rename from kdb-bot/src/bot_data/service/level_repository_service.py rename to bot/src/bot_data/service/level_repository_service.py diff --git a/kdb-bot/src/bot_data/service/migration_service.py b/bot/src/bot_data/service/migration_service.py similarity index 100% rename from kdb-bot/src/bot_data/service/migration_service.py rename to bot/src/bot_data/service/migration_service.py diff --git a/kdb-bot/src/bot_data/service/seeder_service.py b/bot/src/bot_data/service/seeder_service.py similarity index 91% rename from kdb-bot/src/bot_data/service/seeder_service.py rename to bot/src/bot_data/service/seeder_service.py index feada479..69982c09 100644 --- a/kdb-bot/src/bot_data/service/seeder_service.py +++ b/bot/src/bot_data/service/seeder_service.py @@ -19,7 +19,7 @@ class SeederService: async def seed(self): self._logger.info(__name__, f"Seed data") - for seeder in self._services.get_services(list[DataSeederABC]): + for seeder in self._services.get_services(DataSeederABC): seeder: DataSeederABC = seeder self._logger.debug(__name__, f"Starting seeder {type(seeder).__name__}") await seeder.seed() diff --git a/kdb-bot/src/bot_data/service/server_config_repository_service.py b/bot/src/bot_data/service/server_config_repository_service.py similarity index 80% rename from kdb-bot/src/bot_data/service/server_config_repository_service.py rename to bot/src/bot_data/service/server_config_repository_service.py index 4e5d3dcd..45d1aeaa 100644 --- a/kdb-bot/src/bot_data/service/server_config_repository_service.py +++ b/bot/src/bot_data/service/server_config_repository_service.py @@ -13,7 +13,12 @@ from bot_data.model.team_member_type_enum import TeamMemberTypeEnum class ServerConfigRepositoryService(ServerConfigRepositoryABC): - def __init__(self, logger: DatabaseLogger, db_context: DatabaseContextABC, servers: ServerRepositoryABC): + def __init__( + self, + logger: DatabaseLogger, + db_context: DatabaseContextABC, + servers: ServerRepositoryABC, + ): ServerConfigRepositoryABC.__init__(self) self._logger = logger @@ -23,14 +28,20 @@ class ServerConfigRepositoryService(ServerConfigRepositoryABC): def _get_team_role_ids(self, server_id: int) -> List[ServerTeamRoleIdsConfig]: ids = List(ServerTeamRoleIdsConfig) self._logger.trace( - __name__, f"Send SQL command: {ServerTeamRoleIdsConfig.get_select_by_server_id_string(server_id)}" + __name__, + f"Send SQL command: {ServerTeamRoleIdsConfig.get_select_by_server_id_string(server_id)}", ) results = self._context.select(ServerTeamRoleIdsConfig.get_select_by_server_id_string(server_id)) for result in results: self._logger.trace(__name__, f"Got ServerTeamRoleIdsConfig with id {result[0]}") ids.append( ServerTeamRoleIdsConfig( - result[1], TeamMemberTypeEnum(result[2]), result[3], result[4], result[5], id=result[0] + result[1], + TeamMemberTypeEnum(result[2]), + result[3], + result[4], + result[5], + id=result[0], ) ) @@ -66,29 +77,40 @@ class ServerConfigRepositoryService(ServerConfigRepositoryABC): result[13], result[14], result[15], - json.loads(result[16]), - self._servers.get_server_by_id(result[17]), - self._get_afk_channel_ids(result[17]), - self._get_team_role_ids(result[17]), - result[18], - result[19], + result[16], + result[17], + json.loads(result[18]), + self._servers.get_server_by_id(result[19]), + self._get_afk_channel_ids(result[19]), + self._get_team_role_ids(result[19]), + result[20], + result[21], id=result[0], ) def does_server_config_exists(self, server_id: int) -> bool: - self._logger.trace(__name__, f"Send SQL command: {ServerConfig.get_select_by_server_id_string(server_id)}") + self._logger.trace( + __name__, + f"Send SQL command: {ServerConfig.get_select_by_server_id_string(server_id)}", + ) result = self._context.select(ServerConfig.get_select_by_server_id_string(server_id)) return len(result) > 0 def get_server_config_by_server(self, server_id: int) -> ServerConfig: - self._logger.trace(__name__, f"Send SQL command: {ServerConfig.get_select_by_server_id_string(server_id)}") + self._logger.trace( + __name__, + f"Send SQL command: {ServerConfig.get_select_by_server_id_string(server_id)}", + ) result = self._context.select(ServerConfig.get_select_by_server_id_string(server_id))[0] return self._from_result(result) def get_server_config_by_id(self, config_id: int) -> ServerConfig: - self._logger.trace(__name__, f"Send SQL command: {ServerConfig.get_select_by_id_string(config_id)}") + self._logger.trace( + __name__, + f"Send SQL command: {ServerConfig.get_select_by_id_string(config_id)}", + ) result = self._context.select(ServerConfig.get_select_by_id_string(config_id))[0] return self._from_result(result) diff --git a/kdb-bot/src/bot_data/service/server_config_seeder.py b/bot/src/bot_data/service/server_config_seeder.py similarity index 100% rename from kdb-bot/src/bot_data/service/server_config_seeder.py rename to bot/src/bot_data/service/server_config_seeder.py diff --git a/kdb-bot/src/bot_data/service/server_repository_service.py b/bot/src/bot_data/service/server_repository_service.py similarity index 96% rename from kdb-bot/src/bot_data/service/server_repository_service.py rename to bot/src/bot_data/service/server_repository_service.py index 924cc036..5817d7dc 100644 --- a/kdb-bot/src/bot_data/service/server_repository_service.py +++ b/bot/src/bot_data/service/server_repository_service.py @@ -12,7 +12,12 @@ from bot_data.service.cache_service import CacheService class ServerRepositoryService(ServerRepositoryABC): - def __init__(self, logger: DatabaseLogger, db_context: DatabaseContextABC, cache: CacheService): + def __init__( + self, + logger: DatabaseLogger, + db_context: DatabaseContextABC, + cache: CacheService, + ): self._logger = logger self._context = db_context self._cache = cache diff --git a/kdb-bot/src/bot_data/service/short_role_name_repository_service.py b/bot/src/bot_data/service/short_role_name_repository_service.py similarity index 96% rename from kdb-bot/src/bot_data/service/short_role_name_repository_service.py rename to bot/src/bot_data/service/short_role_name_repository_service.py index fa65077e..3c4bed64 100644 --- a/kdb-bot/src/bot_data/service/short_role_name_repository_service.py +++ b/bot/src/bot_data/service/short_role_name_repository_service.py @@ -60,7 +60,10 @@ class ShortRoleNameRepositoryService(ShortRoleNameRepositoryABC): def find_short_role_names_by_role_id(self, role_id: int) -> List[ShortRoleName]: short_role_names = List(ShortRoleName) - self._logger.trace(__name__, f"Send SQL command: {ShortRoleName.get_select_by_role_id_string(role_id)}") + self._logger.trace( + __name__, + f"Send SQL command: {ShortRoleName.get_select_by_role_id_string(role_id)}", + ) results = self._context.select(ShortRoleName.get_select_by_role_id_string(role_id)) for result in results: self._logger.trace(__name__, f"Get short_role_name with id {result[0]}") diff --git a/bot/src/bot_data/service/steam_special_offer_repository_service.py b/bot/src/bot_data/service/steam_special_offer_repository_service.py new file mode 100644 index 00000000..dfd0e7ee --- /dev/null +++ b/bot/src/bot_data/service/steam_special_offer_repository_service.py @@ -0,0 +1,73 @@ +from typing import Optional + +from cpl_core.database.context import DatabaseContextABC +from cpl_query.extension import List + +from bot_core.logging.database_logger import DatabaseLogger +from bot_data.abc.server_repository_abc import ServerRepositoryABC +from bot_data.abc.steam_special_offer_repository_abc import ( + SteamSpecialOfferRepositoryABC, +) +from bot_data.model.steam_special_offer import SteamSpecialOffer + + +class SteamSpecialOfferRepositoryService(SteamSpecialOfferRepositoryABC): + def __init__( + self, + logger: DatabaseLogger, + db_context: DatabaseContextABC, + servers: ServerRepositoryABC, + ): + self._logger = logger + self._context = db_context + + self._servers = servers + + SteamSpecialOfferRepositoryABC.__init__(self) + + @staticmethod + def _get_value_from_result(value: any) -> Optional[any]: + if isinstance(value, str) and "NULL" in value: + return None + + return value + + def _steam_special_offer_from_result(self, sql_result: tuple) -> SteamSpecialOffer: + return SteamSpecialOffer( + self._get_value_from_result(sql_result[1]), # name + float(self._get_value_from_result(sql_result[2])), # original_price + float(self._get_value_from_result(sql_result[3])), # discount_price + int(self._get_value_from_result(sql_result[4])), # discount_pct + id=self._get_value_from_result(sql_result[0]), # id + ) + + def get_steam_special_offers(self) -> List[SteamSpecialOffer]: + steam_special_offers = List(SteamSpecialOffer) + self._logger.trace(__name__, f"Send SQL command: {SteamSpecialOffer.get_select_all_string()}") + results = self._context.select(SteamSpecialOffer.get_select_all_string()) + for result in results: + self._logger.trace(__name__, f"Get steam_special_offer with id {result[0]}") + steam_special_offers.append(self._steam_special_offer_from_result(result)) + + return steam_special_offers + + def get_steam_special_offer_by_name(self, name: str) -> SteamSpecialOffer: + self._logger.trace( + __name__, + f"Send SQL command: {SteamSpecialOffer.get_select_by_name_string(name)}", + ) + result = self._context.select(SteamSpecialOffer.get_select_by_name_string(name))[0] + + return self._steam_special_offer_from_result(result) + + def add_steam_special_offer(self, steam_special_offer: SteamSpecialOffer): + self._logger.trace(__name__, f"Send SQL command: {steam_special_offer.insert_string}") + self._context.cursor.execute(steam_special_offer.insert_string) + + def update_steam_special_offer(self, steam_special_offer: SteamSpecialOffer): + self._logger.trace(__name__, f"Send SQL command: {steam_special_offer.udpate_string}") + self._context.cursor.execute(steam_special_offer.udpate_string) + + def delete_steam_special_offer(self, steam_special_offer: SteamSpecialOffer): + self._logger.trace(__name__, f"Send SQL command: {steam_special_offer.delete_string}") + self._context.cursor.execute(steam_special_offer.delete_string) diff --git a/kdb-bot/src/bot_data/service/technician_config_repository_service.py b/bot/src/bot_data/service/technician_config_repository_service.py similarity index 96% rename from kdb-bot/src/bot_data/service/technician_config_repository_service.py rename to bot/src/bot_data/service/technician_config_repository_service.py index fe32eded..3500bbde 100644 --- a/kdb-bot/src/bot_data/service/technician_config_repository_service.py +++ b/bot/src/bot_data/service/technician_config_repository_service.py @@ -29,7 +29,10 @@ class TechnicianConfigRepositoryService(TechnicianConfigRepositoryABC): def _get_technician_ping_urls(self) -> List[str]: urls = List(str) - self._logger.trace(__name__, f"Send SQL command: {TechnicianPingUrlConfig.get_select_all_string()}") + self._logger.trace( + __name__, + f"Send SQL command: {TechnicianPingUrlConfig.get_select_all_string()}", + ) results = self._context.select(TechnicianPingUrlConfig.get_select_all_string()) for result in results: self._logger.trace(__name__, f"Got TechnicianPingUrl with id {result[0]}") diff --git a/kdb-bot/src/bot_data/service/technician_config_seeder.py b/bot/src/bot_data/service/technician_config_seeder.py similarity index 92% rename from kdb-bot/src/bot_data/service/technician_config_seeder.py rename to bot/src/bot_data/service/technician_config_seeder.py index 209b3e02..3107db0a 100644 --- a/kdb-bot/src/bot_data/service/technician_config_seeder.py +++ b/bot/src/bot_data/service/technician_config_seeder.py @@ -34,7 +34,10 @@ class TechnicianConfigSeeder(DataSeederABC): 1000000, {}, List(int, [240160344557879316]), - List(str, ["www.google.com", "www.sh-edraft.de", "www.keksdose-gaming.de"]), + List( + str, + ["www.google.com", "www.sh-edraft.de", "www.keksdose-gaming.de"], + ), ) self._technician_config.add_technician_config(config) diff --git a/kdb-bot/src/bot_data/service/user_game_ident_repository_service.py b/bot/src/bot_data/service/user_game_ident_repository_service.py similarity index 100% rename from kdb-bot/src/bot_data/service/user_game_ident_repository_service.py rename to bot/src/bot_data/service/user_game_ident_repository_service.py diff --git a/kdb-bot/src/bot_data/service/user_joined_game_server_repository_service.py b/bot/src/bot_data/service/user_joined_game_server_repository_service.py similarity index 100% rename from kdb-bot/src/bot_data/service/user_joined_game_server_repository_service.py rename to bot/src/bot_data/service/user_joined_game_server_repository_service.py diff --git a/kdb-bot/src/bot_data/service/user_joined_server_repository_service.py b/bot/src/bot_data/service/user_joined_server_repository_service.py similarity index 100% rename from kdb-bot/src/bot_data/service/user_joined_server_repository_service.py rename to bot/src/bot_data/service/user_joined_server_repository_service.py diff --git a/kdb-bot/src/bot_data/service/user_joined_voice_channel_repository_service.py b/bot/src/bot_data/service/user_joined_voice_channel_repository_service.py similarity index 100% rename from kdb-bot/src/bot_data/service/user_joined_voice_channel_repository_service.py rename to bot/src/bot_data/service/user_joined_voice_channel_repository_service.py diff --git a/kdb-bot/src/bot_data/service/user_message_count_per_hour_repository_service.py b/bot/src/bot_data/service/user_message_count_per_hour_repository_service.py similarity index 100% rename from kdb-bot/src/bot_data/service/user_message_count_per_hour_repository_service.py rename to bot/src/bot_data/service/user_message_count_per_hour_repository_service.py diff --git a/kdb-bot/src/bot_data/service/user_repository_service.py b/bot/src/bot_data/service/user_repository_service.py similarity index 97% rename from kdb-bot/src/bot_data/service/user_repository_service.py rename to bot/src/bot_data/service/user_repository_service.py index 73387908..940156a8 100644 --- a/kdb-bot/src/bot_data/service/user_repository_service.py +++ b/bot/src/bot_data/service/user_repository_service.py @@ -1,3 +1,4 @@ +import datetime from typing import Optional from cpl_core.database.context import DatabaseContextABC @@ -29,9 +30,10 @@ class UserRepositoryService(UserRepositoryABC): result[2], result[3], result[4], - self._servers.get_server_by_id(result[5]), - result[6], + result[5], + self._servers.get_server_by_id(result[6]), result[7], + result[8], id=result[0], ) diff --git a/kdb-bot/src/bot_data/service/user_warnings_repository_service.py b/bot/src/bot_data/service/user_warnings_repository_service.py similarity index 93% rename from kdb-bot/src/bot_data/service/user_warnings_repository_service.py rename to bot/src/bot_data/service/user_warnings_repository_service.py index ff19d61f..fbf7c4ee 100644 --- a/kdb-bot/src/bot_data/service/user_warnings_repository_service.py +++ b/bot/src/bot_data/service/user_warnings_repository_service.py @@ -32,7 +32,7 @@ class UserWarningsRepositoryService(UserWarningsRepositoryABC): def _from_result(self, sql_result: tuple) -> UserWarnings: user = self._users.get_user_by_id(self._get_value_from_result(sql_result[2])) author = None - author_id = self._get_value_from_result(sql_result[2]) + author_id = self._get_value_from_result(sql_result[3]) if author_id is not None: author = self._users.get_user_by_id(author_id) @@ -61,7 +61,10 @@ class UserWarningsRepositoryService(UserWarningsRepositoryABC): def get_user_warnings_by_user_id(self, user_id: int) -> List[UserWarnings]: warnings = List(UserWarnings) - self._logger.trace(__name__, f"Send SQL command: {UserWarnings.get_select_by_user_id_string(user_id)}") + self._logger.trace( + __name__, + f"Send SQL command: {UserWarnings.get_select_by_user_id_string(user_id)}", + ) results = self._context.select(UserWarnings.get_select_by_user_id_string(user_id)) for result in results: warnings.append(self._from_result(result)) diff --git a/kdb-bot/src/bot_graphql/__init__.py b/bot/src/bot_graphql/__init__.py similarity index 84% rename from kdb-bot/src/bot_graphql/__init__.py rename to bot/src/bot_graphql/__init__.py index c6369011..963709cb 100644 --- a/kdb-bot/src/bot_graphql/__init__.py +++ b/bot/src/bot_graphql/__init__.py @@ -15,7 +15,7 @@ __title__ = "bot_graphql" __author__ = "Sven Heidemann" __license__ = "MIT" __copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de" -__version__ = "1.1.10" +__version__ = "1.2.0" from collections import namedtuple @@ -23,4 +23,4 @@ from collections import namedtuple # imports VersionInfo = namedtuple("VersionInfo", "major minor micro") -version_info = VersionInfo(major="1", minor="1", micro="10") +version_info = VersionInfo(major="1", minor="2", micro="0") diff --git a/kdb-bot/src/bot_graphql/abc/__init__.py b/bot/src/bot_graphql/abc/__init__.py similarity index 84% rename from kdb-bot/src/bot_graphql/abc/__init__.py rename to bot/src/bot_graphql/abc/__init__.py index 4c6777fd..31668cc0 100644 --- a/kdb-bot/src/bot_graphql/abc/__init__.py +++ b/bot/src/bot_graphql/abc/__init__.py @@ -15,7 +15,7 @@ __title__ = "bot_graphql.abc" __author__ = "Sven Heidemann" __license__ = "MIT" __copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de" -__version__ = "1.1.10" +__version__ = "1.2.0" from collections import namedtuple @@ -23,4 +23,4 @@ from collections import namedtuple # imports: VersionInfo = namedtuple("VersionInfo", "major minor micro") -version_info = VersionInfo(major="1", minor="1", micro="10") +version_info = VersionInfo(major="1", minor="2", micro="0") diff --git a/kdb-bot/src/bot_graphql/abc/data_query_abc.py b/bot/src/bot_graphql/abc/data_query_abc.py similarity index 100% rename from kdb-bot/src/bot_graphql/abc/data_query_abc.py rename to bot/src/bot_graphql/abc/data_query_abc.py diff --git a/kdb-bot/src/bot_graphql/abc/data_query_with_history_abc.py b/bot/src/bot_graphql/abc/data_query_with_history_abc.py similarity index 100% rename from kdb-bot/src/bot_graphql/abc/data_query_with_history_abc.py rename to bot/src/bot_graphql/abc/data_query_with_history_abc.py diff --git a/kdb-bot/src/bot_graphql/abc/filter_abc.py b/bot/src/bot_graphql/abc/filter_abc.py similarity index 100% rename from kdb-bot/src/bot_graphql/abc/filter_abc.py rename to bot/src/bot_graphql/abc/filter_abc.py diff --git a/kdb-bot/src/bot_graphql/abc/history_query_abc.py b/bot/src/bot_graphql/abc/history_query_abc.py similarity index 100% rename from kdb-bot/src/bot_graphql/abc/history_query_abc.py rename to bot/src/bot_graphql/abc/history_query_abc.py diff --git a/kdb-bot/src/bot_graphql/abc/query_abc.py b/bot/src/bot_graphql/abc/query_abc.py similarity index 98% rename from kdb-bot/src/bot_graphql/abc/query_abc.py rename to bot/src/bot_graphql/abc/query_abc.py index 1a566a94..850fb22b 100644 --- a/kdb-bot/src/bot_graphql/abc/query_abc.py +++ b/bot/src/bot_graphql/abc/query_abc.py @@ -241,7 +241,14 @@ class QueryABC(ObjectType): raise ex # @FilterABC.resolve_filter_annotation - def _resolve_collection(self, collection: List, *_, filter: FilterABC = None, page: Page = None, sort: Sort = None): + def _resolve_collection( + self, + collection: List, + *_, + filter: FilterABC = None, + page: Page = None, + sort: Sort = None, + ): if filter is not None: collection = filter.filter(collection) diff --git a/kdb-bot/src/bot_graphql/bot-graphql.json b/bot/src/bot_graphql/bot-graphql.json similarity index 96% rename from kdb-bot/src/bot_graphql/bot-graphql.json rename to bot/src/bot_graphql/bot-graphql.json index 4a9505a7..552f4f7d 100644 --- a/kdb-bot/src/bot_graphql/bot-graphql.json +++ b/bot/src/bot_graphql/bot-graphql.json @@ -3,8 +3,8 @@ "Name": "bot-data", "Version": { "Major": "1", - "Minor": "1", - "Micro": "10" + "Minor": "2", + "Micro": "0" }, "Author": "Sven Heidemann", "AuthorEmail": "sven.heidemann@sh-edraft.de", diff --git a/kdb-bot/src/bot_graphql/filter/__init__.py b/bot/src/bot_graphql/filter/__init__.py similarity index 84% rename from kdb-bot/src/bot_graphql/filter/__init__.py rename to bot/src/bot_graphql/filter/__init__.py index 1d67bf12..0d5e9d05 100644 --- a/kdb-bot/src/bot_graphql/filter/__init__.py +++ b/bot/src/bot_graphql/filter/__init__.py @@ -15,7 +15,7 @@ __title__ = "bot_graphql.filter" __author__ = "Sven Heidemann" __license__ = "MIT" __copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de" -__version__ = "1.1.10" +__version__ = "1.2.0" from collections import namedtuple @@ -23,4 +23,4 @@ from collections import namedtuple # imports: VersionInfo = namedtuple("VersionInfo", "major minor micro") -version_info = VersionInfo(major="1", minor="1", micro="10") +version_info = VersionInfo(major="1", minor="2", micro="0") diff --git a/kdb-bot/src/bot_graphql/filter/achievement_filter.py b/bot/src/bot_graphql/filter/achievement_filter.py similarity index 92% rename from kdb-bot/src/bot_graphql/filter/achievement_filter.py rename to bot/src/bot_graphql/filter/achievement_filter.py index 674af502..b95e00c0 100644 --- a/kdb-bot/src/bot_graphql/filter/achievement_filter.py +++ b/bot/src/bot_graphql/filter/achievement_filter.py @@ -1,3 +1,4 @@ +from cpl_core.dependency_injection import ServiceProviderABC from cpl_query.extension import List from bot_data.model.user import User @@ -5,9 +6,14 @@ from bot_graphql.abc.filter_abc import FilterABC class AchievementFilter(FilterABC): - def __init__(self): + def __init__( + self, + services: ServiceProviderABC, + ): FilterABC.__init__(self) + self._services = services + self._id = None self._name = None self._description = None diff --git a/kdb-bot/src/bot_graphql/filter/auto_role_filter.py b/bot/src/bot_graphql/filter/auto_role_filter.py similarity index 100% rename from kdb-bot/src/bot_graphql/filter/auto_role_filter.py rename to bot/src/bot_graphql/filter/auto_role_filter.py diff --git a/kdb-bot/src/bot_graphql/filter/auto_role_rule_filter.py b/bot/src/bot_graphql/filter/auto_role_rule_filter.py similarity index 100% rename from kdb-bot/src/bot_graphql/filter/auto_role_rule_filter.py rename to bot/src/bot_graphql/filter/auto_role_rule_filter.py diff --git a/kdb-bot/src/bot_graphql/filter/client_filter.py b/bot/src/bot_graphql/filter/client_filter.py similarity index 100% rename from kdb-bot/src/bot_graphql/filter/client_filter.py rename to bot/src/bot_graphql/filter/client_filter.py diff --git a/kdb-bot/src/bot_graphql/filter/level_filter.py b/bot/src/bot_graphql/filter/level_filter.py similarity index 100% rename from kdb-bot/src/bot_graphql/filter/level_filter.py rename to bot/src/bot_graphql/filter/level_filter.py diff --git a/kdb-bot/src/bot_graphql/filter/page.py b/bot/src/bot_graphql/filter/page.py similarity index 100% rename from kdb-bot/src/bot_graphql/filter/page.py rename to bot/src/bot_graphql/filter/page.py diff --git a/kdb-bot/src/bot_graphql/filter/server_filter.py b/bot/src/bot_graphql/filter/server_filter.py similarity index 100% rename from kdb-bot/src/bot_graphql/filter/server_filter.py rename to bot/src/bot_graphql/filter/server_filter.py diff --git a/kdb-bot/src/bot_graphql/filter/short_role_name_filter.py b/bot/src/bot_graphql/filter/short_role_name_filter.py similarity index 100% rename from kdb-bot/src/bot_graphql/filter/short_role_name_filter.py rename to bot/src/bot_graphql/filter/short_role_name_filter.py diff --git a/kdb-bot/src/bot_graphql/filter/sort.py b/bot/src/bot_graphql/filter/sort.py similarity index 100% rename from kdb-bot/src/bot_graphql/filter/sort.py rename to bot/src/bot_graphql/filter/sort.py diff --git a/kdb-bot/src/bot_graphql/filter/user_filter.py b/bot/src/bot_graphql/filter/user_filter.py similarity index 100% rename from kdb-bot/src/bot_graphql/filter/user_filter.py rename to bot/src/bot_graphql/filter/user_filter.py diff --git a/kdb-bot/src/bot_graphql/filter/user_joined_game_server_filter.py b/bot/src/bot_graphql/filter/user_joined_game_server_filter.py similarity index 100% rename from kdb-bot/src/bot_graphql/filter/user_joined_game_server_filter.py rename to bot/src/bot_graphql/filter/user_joined_game_server_filter.py diff --git a/kdb-bot/src/bot_graphql/filter/user_joined_server_filter.py b/bot/src/bot_graphql/filter/user_joined_server_filter.py similarity index 100% rename from kdb-bot/src/bot_graphql/filter/user_joined_server_filter.py rename to bot/src/bot_graphql/filter/user_joined_server_filter.py diff --git a/kdb-bot/src/bot_graphql/filter/user_joined_voice_channel_filter.py b/bot/src/bot_graphql/filter/user_joined_voice_channel_filter.py similarity index 100% rename from kdb-bot/src/bot_graphql/filter/user_joined_voice_channel_filter.py rename to bot/src/bot_graphql/filter/user_joined_voice_channel_filter.py diff --git a/bot/src/bot_graphql/filter/user_warning_filter.py b/bot/src/bot_graphql/filter/user_warning_filter.py new file mode 100644 index 00000000..2c716c9e --- /dev/null +++ b/bot/src/bot_graphql/filter/user_warning_filter.py @@ -0,0 +1,56 @@ +from cpl_core.dependency_injection import ServiceProviderABC +from cpl_query.extension import List + +from bot_data.model.user_warnings import UserWarnings +from bot_graphql.abc.filter_abc import FilterABC + + +class UserWarningFilter(FilterABC): + def __init__( + self, + services: ServiceProviderABC, + ): + FilterABC.__init__(self) + + self._services = services + + self._id = None + self._user = None + self._description = None + self._author = None + + def from_dict(self, values: dict): + if "id" in values: + self._id = int(values["id"]) + + if "user" in values: + from bot_graphql.filter.user_filter import UserFilter + + self._user: UserFilter = self._services.get_service(UserFilter) + self._user.from_dict(values["user"]) + + if "description" in values: + self._description = values["description"] + + if "author" in values: + from bot_graphql.filter.user_filter import UserFilter + + self._author: UserFilter = self._services.get_service(UserFilter) + self._author.from_dict(values["author"]) + + def filter(self, query: List[UserWarnings]) -> List[UserWarnings]: + if self._id is not None: + query = query.where(lambda x: x.id == self._id) + + if self._user is not None: + users = self._user.filter(query.select(lambda x: x.user)).select(lambda x: x.id) + query = query.where(lambda x: x.id in users) + + if self._description is not None: + query = query.where(lambda x: x.description == self._description or self._description in x.description) + + if self._author is not None: + users = self._author.filter(query.select(lambda x: x.author)).select(lambda x: x.id) + query = query.where(lambda x: x.id in users) + + return query diff --git a/kdb-bot/src/bot_graphql/graphql/achievement.gql b/bot/src/bot_graphql/graphql/achievement.gql similarity index 100% rename from kdb-bot/src/bot_graphql/graphql/achievement.gql rename to bot/src/bot_graphql/graphql/achievement.gql diff --git a/kdb-bot/src/bot_graphql/graphql/autoRole.gql b/bot/src/bot_graphql/graphql/autoRole.gql similarity index 100% rename from kdb-bot/src/bot_graphql/graphql/autoRole.gql rename to bot/src/bot_graphql/graphql/autoRole.gql diff --git a/kdb-bot/src/bot_graphql/graphql/autoRoleRule.gql b/bot/src/bot_graphql/graphql/autoRoleRule.gql similarity index 100% rename from kdb-bot/src/bot_graphql/graphql/autoRoleRule.gql rename to bot/src/bot_graphql/graphql/autoRoleRule.gql diff --git a/kdb-bot/src/bot_graphql/graphql/base.gql b/bot/src/bot_graphql/graphql/base.gql similarity index 100% rename from kdb-bot/src/bot_graphql/graphql/base.gql rename to bot/src/bot_graphql/graphql/base.gql diff --git a/kdb-bot/src/bot_graphql/graphql/client.gql b/bot/src/bot_graphql/graphql/client.gql similarity index 100% rename from kdb-bot/src/bot_graphql/graphql/client.gql rename to bot/src/bot_graphql/graphql/client.gql diff --git a/kdb-bot/src/bot_graphql/graphql/discord.gql b/bot/src/bot_graphql/graphql/discord.gql similarity index 100% rename from kdb-bot/src/bot_graphql/graphql/discord.gql rename to bot/src/bot_graphql/graphql/discord.gql diff --git a/kdb-bot/src/bot_graphql/graphql/featureFlags.gql b/bot/src/bot_graphql/graphql/featureFlags.gql similarity index 100% rename from kdb-bot/src/bot_graphql/graphql/featureFlags.gql rename to bot/src/bot_graphql/graphql/featureFlags.gql diff --git a/kdb-bot/src/bot_graphql/graphql/knownUser.gql b/bot/src/bot_graphql/graphql/knownUser.gql similarity index 100% rename from kdb-bot/src/bot_graphql/graphql/knownUser.gql rename to bot/src/bot_graphql/graphql/knownUser.gql diff --git a/kdb-bot/src/bot_graphql/graphql/level.gql b/bot/src/bot_graphql/graphql/level.gql similarity index 100% rename from kdb-bot/src/bot_graphql/graphql/level.gql rename to bot/src/bot_graphql/graphql/level.gql diff --git a/kdb-bot/src/bot_graphql/graphql/mutation.gql b/bot/src/bot_graphql/graphql/mutation.gql similarity index 100% rename from kdb-bot/src/bot_graphql/graphql/mutation.gql rename to bot/src/bot_graphql/graphql/mutation.gql diff --git a/kdb-bot/src/bot_graphql/graphql/query.gql b/bot/src/bot_graphql/graphql/query.gql similarity index 93% rename from kdb-bot/src/bot_graphql/graphql/query.gql rename to bot/src/bot_graphql/graphql/query.gql index 8946e9a9..ffa3c21f 100644 --- a/kdb-bot/src/bot_graphql/graphql/query.gql +++ b/bot/src/bot_graphql/graphql/query.gql @@ -41,6 +41,9 @@ type Query { shortRoleNames(filter: ShortRoleNameFilter, page: Page, sort: Sort): [ShortRoleName] shortRoleNamePositions: [String] + userWarningCount: Int + userWarnings(filter: UserWarningFilter, page: Page, sort: Sort): [UserWarning] + technicianConfig: TechnicianConfig possibleFeatureFlags: [String] discord: Discord diff --git a/kdb-bot/src/bot_graphql/graphql/server.gql b/bot/src/bot_graphql/graphql/server.gql similarity index 100% rename from kdb-bot/src/bot_graphql/graphql/server.gql rename to bot/src/bot_graphql/graphql/server.gql diff --git a/kdb-bot/src/bot_graphql/graphql/serverConfig.gql b/bot/src/bot_graphql/graphql/serverConfig.gql similarity index 92% rename from kdb-bot/src/bot_graphql/graphql/serverConfig.gql rename to bot/src/bot_graphql/graphql/serverConfig.gql index 7683194c..bc2f1e24 100644 --- a/kdb-bot/src/bot_graphql/graphql/serverConfig.gql +++ b/bot/src/bot_graphql/graphql/serverConfig.gql @@ -9,12 +9,14 @@ type ServerConfig implements TableWithHistoryQuery { xpPerOntimeHour: Int xpPerEventParticipation: Int xpPerAchievement: Int + xpForBirthday: Int afkCommandChannelId: String helpVoiceChannelId: String teamChannelId: String loginMessageChannelId: String defaultRoleId: String shortRoleNameOnlySetHighestRole: Boolean + gameOfferNotificationChatId: String featureFlagCount: Int featureFlags: [FeatureFlag] @@ -41,12 +43,14 @@ type ServerConfigHistory implements HistoryTableQuery { xpPerOntimeHour: Int xpPerEventParticipation: Int xpPerAchievement: Int + xpForBirthday: Int afkCommandChannelId: String helpVoiceChannelId: String teamChannelId: String loginMessageChannelId: String defaultRoleId: String shortRoleNameOnlySetHighestRole: Boolean + gameOfferNotificationChatId: String featureFlagCount: Int featureFlags: [FeatureFlag] @@ -91,12 +95,14 @@ input ServerConfigInput { xpPerOntimeHour: Int xpPerEventParticipation: Int xpPerAchievement: Int + xpForBirthday: Int afkCommandChannelId: String helpVoiceChannelId: String teamChannelId: String loginMessageChannelId: String defaultRoleId: String shortRoleNameOnlySetHighestRole: Boolean + gameOfferNotificationChatId: String featureFlags: [FeatureFlagInput] afkChannelIds: [String] diff --git a/kdb-bot/src/bot_graphql/graphql/shortRoleName.gql b/bot/src/bot_graphql/graphql/shortRoleName.gql similarity index 100% rename from kdb-bot/src/bot_graphql/graphql/shortRoleName.gql rename to bot/src/bot_graphql/graphql/shortRoleName.gql diff --git a/kdb-bot/src/bot_graphql/graphql/technicianConfig.gql b/bot/src/bot_graphql/graphql/technicianConfig.gql similarity index 100% rename from kdb-bot/src/bot_graphql/graphql/technicianConfig.gql rename to bot/src/bot_graphql/graphql/technicianConfig.gql diff --git a/kdb-bot/src/bot_graphql/graphql/user.gql b/bot/src/bot_graphql/graphql/user.gql similarity index 87% rename from kdb-bot/src/bot_graphql/graphql/user.gql rename to bot/src/bot_graphql/graphql/user.gql index 38db3573..9ffff9a2 100644 --- a/kdb-bot/src/bot_graphql/graphql/user.gql +++ b/bot/src/bot_graphql/graphql/user.gql @@ -5,6 +5,7 @@ type User implements TableWithHistoryQuery { xp: Int messageCount: Int reactionCount: Int + birthday: String ontime: Float level: Level @@ -20,6 +21,9 @@ type User implements TableWithHistoryQuery { achievementCount: Int achievements(filter: AchievementFilter, page: Page, sort: Sort): [Achievement] + userWarningCount: Int + userWarnings(filter: UserWarningFilter, page: Page, sort: Sort): [UserWarning] + server: Server leftServer: Boolean @@ -59,5 +63,7 @@ type UserMutation { input UserInput { id: ID xp: Int + birthday: String levelId: ID + userWarnings: [UserWarningInput] } \ No newline at end of file diff --git a/kdb-bot/src/bot_graphql/graphql/userJoinedGameServer.gql b/bot/src/bot_graphql/graphql/userJoinedGameServer.gql similarity index 100% rename from kdb-bot/src/bot_graphql/graphql/userJoinedGameServer.gql rename to bot/src/bot_graphql/graphql/userJoinedGameServer.gql diff --git a/kdb-bot/src/bot_graphql/graphql/userJoinedServer.gql b/bot/src/bot_graphql/graphql/userJoinedServer.gql similarity index 100% rename from kdb-bot/src/bot_graphql/graphql/userJoinedServer.gql rename to bot/src/bot_graphql/graphql/userJoinedServer.gql diff --git a/kdb-bot/src/bot_graphql/graphql/userJoinedVoiceChannel.gql b/bot/src/bot_graphql/graphql/userJoinedVoiceChannel.gql similarity index 100% rename from kdb-bot/src/bot_graphql/graphql/userJoinedVoiceChannel.gql rename to bot/src/bot_graphql/graphql/userJoinedVoiceChannel.gql diff --git a/bot/src/bot_graphql/graphql/userWarning.gql b/bot/src/bot_graphql/graphql/userWarning.gql new file mode 100644 index 00000000..d36a9eeb --- /dev/null +++ b/bot/src/bot_graphql/graphql/userWarning.gql @@ -0,0 +1,34 @@ +type UserWarning implements TableWithHistoryQuery { + id: ID + user: User + description: String + author: User + + createdAt: String + modifiedAt: String + + history: [UserWarningHistory] +} + +type UserWarningHistory implements HistoryTableQuery { + id: ID + user: ID + description: String + author: ID + + deleted: Boolean + dateFrom: String + dateTo: String +} + +input UserWarningFilter { + id: ID + user: UserFilter +} + +input UserWarningInput { + id: ID + user: ID + description: String + author: ID +} \ No newline at end of file diff --git a/kdb-bot/src/bot_graphql/graphql_module.py b/bot/src/bot_graphql/graphql_module.py similarity index 91% rename from kdb-bot/src/bot_graphql/graphql_module.py rename to bot/src/bot_graphql/graphql_module.py index 96c72797..e15e0c35 100644 --- a/kdb-bot/src/bot_graphql/graphql_module.py +++ b/bot/src/bot_graphql/graphql_module.py @@ -17,7 +17,10 @@ from bot_graphql.filter.short_role_name_filter import ShortRoleNameFilter from bot_graphql.filter.user_filter import UserFilter from bot_graphql.filter.user_joined_game_server_filter import UserJoinedGameServerFilter from bot_graphql.filter.user_joined_server_filter import UserJoinedServerFilter -from bot_graphql.filter.user_joined_voice_channel_filter import UserJoinedVoiceChannelFilter +from bot_graphql.filter.user_joined_voice_channel_filter import ( + UserJoinedVoiceChannelFilter, +) +from bot_graphql.filter.user_warning_filter import UserWarningFilter from bot_graphql.graphql_service import GraphQLService from bot_graphql.mutation import Mutation from bot_graphql.mutations.achievement_mutation import AchievementMutation @@ -27,7 +30,9 @@ from bot_graphql.mutations.level_mutation import LevelMutation from bot_graphql.mutations.server_config_mutation import ServerConfigMutation from bot_graphql.mutations.short_role_name_mutation import ShortRoleNameMutation from bot_graphql.mutations.technician_config_mutation import TechnicianConfigMutation -from bot_graphql.mutations.user_joined_game_server_mutation import UserJoinedGameServerMutation +from bot_graphql.mutations.user_joined_game_server_mutation import ( + UserJoinedGameServerMutation, +) from bot_graphql.mutations.user_mutation import UserMutation from bot_graphql.queries.achievement_attribute_query import AchievementAttributeQuery from bot_graphql.queries.achievement_history_query import AchievementHistoryQuery @@ -54,18 +59,34 @@ from bot_graphql.queries.server_history_query import ServerHistoryQuery from bot_graphql.queries.server_query import ServerQuery from bot_graphql.queries.short_role_name_history_query import ShortRoleNameHistoryQuery from bot_graphql.queries.short_role_name_query import ShortRoleNameQuery -from bot_graphql.queries.technician_config_history_query import TechnicianConfigHistoryQuery +from bot_graphql.queries.technician_config_history_query import ( + TechnicianConfigHistoryQuery, +) from bot_graphql.queries.technician_config_query import TechnicianConfigQuery -from bot_graphql.queries.technician_id_config_history_query import TechnicianIdConfigHistoryQuery -from bot_graphql.queries.technician_ping_url_config_history_query import TechnicianPingUrlConfigHistoryQuery +from bot_graphql.queries.technician_id_config_history_query import ( + TechnicianIdConfigHistoryQuery, +) +from bot_graphql.queries.technician_ping_url_config_history_query import ( + TechnicianPingUrlConfigHistoryQuery, +) from bot_graphql.queries.user_history_query import UserHistoryQuery -from bot_graphql.queries.user_joined_game_server_history_query import UserJoinedGameServerHistoryQuery +from bot_graphql.queries.user_joined_game_server_history_query import ( + UserJoinedGameServerHistoryQuery, +) from bot_graphql.queries.user_joined_game_server_query import UserJoinedGameServerQuery -from bot_graphql.queries.user_joined_server_history_query import UserJoinedServerHistoryQuery +from bot_graphql.queries.user_joined_server_history_query import ( + UserJoinedServerHistoryQuery, +) from bot_graphql.queries.user_joined_server_query import UserJoinedServerQuery -from bot_graphql.queries.user_joined_voice_channel_history_query import UserJoinedVoiceChannelHistoryQuery -from bot_graphql.queries.user_joined_voice_channel_query import UserJoinedVoiceChannelQuery +from bot_graphql.queries.user_joined_voice_channel_history_query import ( + UserJoinedVoiceChannelHistoryQuery, +) +from bot_graphql.queries.user_joined_voice_channel_query import ( + UserJoinedVoiceChannelQuery, +) from bot_graphql.queries.user_query import UserQuery +from bot_graphql.queries.user_warning_history_query import UserWarningHistoryQuery +from bot_graphql.queries.user_warning_query import UserWarningQuery from bot_graphql.query import Query from bot_graphql.schema import Schema @@ -115,6 +136,8 @@ class GraphQLModule(ModuleABC): services.add_transient(QueryABC, UserJoinedGameServerQuery) services.add_transient(QueryABC, ShortRoleNameHistoryQuery) services.add_transient(QueryABC, ShortRoleNameQuery) + services.add_transient(QueryABC, UserWarningHistoryQuery) + services.add_transient(QueryABC, UserWarningQuery) services.add_transient(QueryABC, DiscordQuery) services.add_transient(QueryABC, GuildQuery) @@ -135,6 +158,7 @@ class GraphQLModule(ModuleABC): services.add_transient(FilterABC, UserJoinedVoiceChannelFilter) services.add_transient(FilterABC, UserJoinedGameServerFilter) services.add_transient(FilterABC, ShortRoleNameFilter) + services.add_transient(FilterABC, UserWarningFilter) # mutations services.add_transient(QueryABC, AutoRoleMutation) diff --git a/kdb-bot/src/bot_graphql/graphql_service.py b/bot/src/bot_graphql/graphql_service.py similarity index 100% rename from kdb-bot/src/bot_graphql/graphql_service.py rename to bot/src/bot_graphql/graphql_service.py diff --git a/kdb-bot/src/bot_graphql/model/__init__.py b/bot/src/bot_graphql/model/__init__.py similarity index 84% rename from kdb-bot/src/bot_graphql/model/__init__.py rename to bot/src/bot_graphql/model/__init__.py index bb404809..5ba9978f 100644 --- a/kdb-bot/src/bot_graphql/model/__init__.py +++ b/bot/src/bot_graphql/model/__init__.py @@ -15,7 +15,7 @@ __title__ = "bot_graphql.model" __author__ = "Sven Heidemann" __license__ = "MIT" __copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de" -__version__ = "1.1.10" +__version__ = "1.2.0" from collections import namedtuple @@ -23,4 +23,4 @@ from collections import namedtuple # imports VersionInfo = namedtuple("VersionInfo", "major minor micro") -version_info = VersionInfo(major="1", minor="1", micro="10") +version_info = VersionInfo(major="1", minor="2", micro="0") diff --git a/kdb-bot/src/bot_graphql/model/discord.py b/bot/src/bot_graphql/model/discord.py similarity index 100% rename from kdb-bot/src/bot_graphql/model/discord.py rename to bot/src/bot_graphql/model/discord.py diff --git a/kdb-bot/src/bot_graphql/mutation.py b/bot/src/bot_graphql/mutation.py similarity index 97% rename from kdb-bot/src/bot_graphql/mutation.py rename to bot/src/bot_graphql/mutation.py index 3dc7d599..39e38cc5 100644 --- a/kdb-bot/src/bot_graphql/mutation.py +++ b/bot/src/bot_graphql/mutation.py @@ -7,7 +7,9 @@ from bot_graphql.mutations.level_mutation import LevelMutation from bot_graphql.mutations.server_config_mutation import ServerConfigMutation from bot_graphql.mutations.short_role_name_mutation import ShortRoleNameMutation from bot_graphql.mutations.technician_config_mutation import TechnicianConfigMutation -from bot_graphql.mutations.user_joined_game_server_mutation import UserJoinedGameServerMutation +from bot_graphql.mutations.user_joined_game_server_mutation import ( + UserJoinedGameServerMutation, +) from bot_graphql.mutations.user_mutation import UserMutation diff --git a/kdb-bot/src/bot_graphql/mutations/__init__.py b/bot/src/bot_graphql/mutations/__init__.py similarity index 84% rename from kdb-bot/src/bot_graphql/mutations/__init__.py rename to bot/src/bot_graphql/mutations/__init__.py index 38c4b97b..180b6b7b 100644 --- a/kdb-bot/src/bot_graphql/mutations/__init__.py +++ b/bot/src/bot_graphql/mutations/__init__.py @@ -15,7 +15,7 @@ __title__ = "bot_graphql.mutations" __author__ = "Sven Heidemann" __license__ = "MIT" __copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de" -__version__ = "1.1.10" +__version__ = "1.2.0" from collections import namedtuple @@ -23,4 +23,4 @@ from collections import namedtuple # imports: VersionInfo = namedtuple("VersionInfo", "major minor micro") -version_info = VersionInfo(major="1", minor="1", micro="10") +version_info = VersionInfo(major="1", minor="2", micro="0") diff --git a/kdb-bot/src/bot_graphql/mutations/achievement_mutation.py b/bot/src/bot_graphql/mutations/achievement_mutation.py similarity index 100% rename from kdb-bot/src/bot_graphql/mutations/achievement_mutation.py rename to bot/src/bot_graphql/mutations/achievement_mutation.py diff --git a/kdb-bot/src/bot_graphql/mutations/auto_role_mutation.py b/bot/src/bot_graphql/mutations/auto_role_mutation.py similarity index 93% rename from kdb-bot/src/bot_graphql/mutations/auto_role_mutation.py rename to bot/src/bot_graphql/mutations/auto_role_mutation.py index d936fc6e..72ac1cf9 100644 --- a/kdb-bot/src/bot_graphql/mutations/auto_role_mutation.py +++ b/bot/src/bot_graphql/mutations/auto_role_mutation.py @@ -25,7 +25,11 @@ class AutoRoleMutation(QueryABC): self.set_field("deleteAutoRole", self.resolve_delete_auto_role) def resolve_create_auto_role(self, *_, input: dict): - auto_role = AutoRole(self._servers.get_server_by_id(input["serverId"]), input["channelId"], input["messageId"]) + auto_role = AutoRole( + self._servers.get_server_by_id(input["serverId"]), + input["channelId"], + input["messageId"], + ) self._can_user_mutate_data(auto_role.server, UserRoleEnum.moderator) self._auto_roles.add_auto_role(auto_role) diff --git a/kdb-bot/src/bot_graphql/mutations/auto_role_rule_mutation.py b/bot/src/bot_graphql/mutations/auto_role_rule_mutation.py similarity index 98% rename from kdb-bot/src/bot_graphql/mutations/auto_role_rule_mutation.py rename to bot/src/bot_graphql/mutations/auto_role_rule_mutation.py index 56681df9..ceafdd2d 100644 --- a/kdb-bot/src/bot_graphql/mutations/auto_role_rule_mutation.py +++ b/bot/src/bot_graphql/mutations/auto_role_rule_mutation.py @@ -32,7 +32,9 @@ class AutoRoleRuleMutation(QueryABC): def resolve_create_auto_role_rule(self, *_, input: dict): auto_role_rule = AutoRoleRule( - self._auto_roles.get_auto_role_by_id(input["autoRoleId"]), input["emojiName"], input["roleId"] + self._auto_roles.get_auto_role_by_id(input["autoRoleId"]), + input["emojiName"], + input["roleId"], ) self._can_user_mutate_data(auto_role_rule.auto_role.server, UserRoleEnum.moderator) diff --git a/kdb-bot/src/bot_graphql/mutations/level_mutation.py b/bot/src/bot_graphql/mutations/level_mutation.py similarity index 100% rename from kdb-bot/src/bot_graphql/mutations/level_mutation.py rename to bot/src/bot_graphql/mutations/level_mutation.py diff --git a/kdb-bot/src/bot_graphql/mutations/server_config_mutation.py b/bot/src/bot_graphql/mutations/server_config_mutation.py similarity index 92% rename from kdb-bot/src/bot_graphql/mutations/server_config_mutation.py rename to bot/src/bot_graphql/mutations/server_config_mutation.py index 044ec3be..6b2ff5eb 100644 --- a/kdb-bot/src/bot_graphql/mutations/server_config_mutation.py +++ b/bot/src/bot_graphql/mutations/server_config_mutation.py @@ -72,6 +72,9 @@ class ServerConfigMutation(QueryABC): server_config.xp_per_achievement = ( input["xpPerAchievement"] if "xpPerAchievement" in input else server_config.xp_per_achievement ) + server_config.xp_for_birthday = ( + input["xpForBirthday"] if "xpForBirthday" in input else server_config.xp_for_birthday + ) server_config.afk_command_channel_id = ( input["afkCommandChannelId"] if "afkCommandChannelId" in input else server_config.afk_command_channel_id ) @@ -94,8 +97,18 @@ class ServerConfigMutation(QueryABC): if "shortRoleNameOnlySetHighestRole" in input else server_config.short_role_name_only_set_highest_role ) + server_config.game_offer_notification_chat_id = ( + input["gameOfferNotificationChatId"] + if "gameOfferNotificationChatId" in input + else server_config.game_offer_notification_chat_id + ) server_config.feature_flags = ( - dict(zip([x["key"] for x in input["featureFlags"]], [x["value"] for x in input["featureFlags"]])) + dict( + zip( + [x["key"] for x in input["featureFlags"]], + [x["value"] for x in input["featureFlags"]], + ) + ) if "featureFlags" in input else server_config.feature_flags ) @@ -139,6 +152,7 @@ class ServerConfigMutation(QueryABC): self._update_team_role_ids(server_config) self._db.save_changes() + self._bot.loop.create_task(self._config_service.reload_server_config(server_config.server)) return server_config def _update_afk_channel_ids(self, new_config: ServerConfig): @@ -178,5 +192,3 @@ class ServerConfigMutation(QueryABC): continue self._server_configs.add_server_team_role_id_config(role_id) - - self._bot.loop.create_task(self._config_service.reload_server_config(new_config.server)) diff --git a/kdb-bot/src/bot_graphql/mutations/short_role_name_mutation.py b/bot/src/bot_graphql/mutations/short_role_name_mutation.py similarity index 100% rename from kdb-bot/src/bot_graphql/mutations/short_role_name_mutation.py rename to bot/src/bot_graphql/mutations/short_role_name_mutation.py diff --git a/kdb-bot/src/bot_graphql/mutations/technician_config_mutation.py b/bot/src/bot_graphql/mutations/technician_config_mutation.py similarity index 96% rename from kdb-bot/src/bot_graphql/mutations/technician_config_mutation.py rename to bot/src/bot_graphql/mutations/technician_config_mutation.py index 434856ee..f5dbbaa2 100644 --- a/kdb-bot/src/bot_graphql/mutations/technician_config_mutation.py +++ b/bot/src/bot_graphql/mutations/technician_config_mutation.py @@ -61,7 +61,12 @@ class TechnicianConfigMutation(QueryABC): ) old_feature_flags = technician_config.feature_flags technician_config.feature_flags = ( - dict(zip([x["key"] for x in input["featureFlags"]], [x["value"] for x in input["featureFlags"]])) + dict( + zip( + [x["key"] for x in input["featureFlags"]], + [x["value"] for x in input["featureFlags"]], + ) + ) if "featureFlags" in input else technician_config.feature_flags ) diff --git a/kdb-bot/src/bot_graphql/mutations/user_joined_game_server_mutation.py b/bot/src/bot_graphql/mutations/user_joined_game_server_mutation.py similarity index 99% rename from kdb-bot/src/bot_graphql/mutations/user_joined_game_server_mutation.py rename to bot/src/bot_graphql/mutations/user_joined_game_server_mutation.py index 9225299d..4f53a741 100644 --- a/kdb-bot/src/bot_graphql/mutations/user_joined_game_server_mutation.py +++ b/bot/src/bot_graphql/mutations/user_joined_game_server_mutation.py @@ -15,7 +15,9 @@ from bot_data.abc.api_key_repository_abc import ApiKeyRepositoryABC from bot_data.abc.game_server_repository_abc import GameServerRepositoryABC from bot_data.abc.server_repository_abc import ServerRepositoryABC from bot_data.abc.user_game_ident_repository_abc import UserGameIdentRepositoryABC -from bot_data.abc.user_joined_game_server_repository_abc import UserJoinedGameServerRepositoryABC +from bot_data.abc.user_joined_game_server_repository_abc import ( + UserJoinedGameServerRepositoryABC, +) from bot_data.abc.user_repository_abc import UserRepositoryABC from bot_data.model.api_key import ApiKey from bot_data.model.server_config import ServerConfig diff --git a/bot/src/bot_graphql/mutations/user_mutation.py b/bot/src/bot_graphql/mutations/user_mutation.py new file mode 100644 index 00000000..9ec5f4cc --- /dev/null +++ b/bot/src/bot_graphql/mutations/user_mutation.py @@ -0,0 +1,90 @@ +from datetime import datetime + +from cpl_core.database.context import DatabaseContextABC +from cpl_discord.service import DiscordBotServiceABC + +from bot_api.route.route import Route +from bot_data.abc.level_repository_abc import LevelRepositoryABC +from bot_data.abc.server_repository_abc import ServerRepositoryABC +from bot_data.abc.user_repository_abc import UserRepositoryABC +from bot_data.abc.user_warnings_repository_abc import UserWarningsRepositoryABC +from bot_data.model.user import User +from bot_data.model.user_role_enum import UserRoleEnum +from bot_graphql.abc.query_abc import QueryABC +from modules.base.service.user_warnings_service import UserWarningsService +from modules.level.service.level_service import LevelService +from modules.permission.service.permission_service import PermissionService + + +class UserMutation(QueryABC): + def __init__( + self, + servers: ServerRepositoryABC, + users: UserRepositoryABC, + bot: DiscordBotServiceABC, + db: DatabaseContextABC, + permissions: PermissionService, + levels: LevelRepositoryABC, + level_service: LevelService, + user_warnings: UserWarningsRepositoryABC, + user_warning_service: UserWarningsService, + ): + QueryABC.__init__(self, "UserMutation") + + self._servers = servers + self._users = users + self._bot = bot + self._db = db + self._permissions = permissions + self._levels = levels + self._level_service = level_service + self._user_warnings = user_warnings + self._user_warning_service = user_warning_service + + self.set_field("updateUser", self.resolve_update_user) + + def resolve_update_user(self, *_, input: dict): + user = self._users.get_user_by_id(input["id"]) + + auth_user = Route.get_user() + member = self._bot.get_guild(user.server.discord_id).get_member( + auth_user.users.where(lambda x: x.server.id == user.server.id).single().discord_id + ) + if member.id != user.discord_id: + self._can_user_mutate_data(user.server, UserRoleEnum.moderator) + + new_xp = None + if "levelId" in input: + level = self._levels.get_level_by_id(input["levelId"]) + if user.level.id != level.id: + new_xp = level.min_xp + + if "userWarnings" in input: + self._update_user_warning(user, input["userWarnings"]) + + user.xp = new_xp if new_xp is not None else input["xp"] if "xp" in input else user.xp + + user.birthday = datetime.strptime(input["birthday"], "%d.%m.%Y") if "birthday" in input else user.birthday + + self._users.update_user(user) + self._db.save_changes() + self._bot.loop.create_task(self._level_service.set_level(user)) + + user = self._users.get_user_by_id(input["id"]) + return user + + def _update_user_warning(self, user: User, new_warnings: dict): + old_warnings = self._user_warnings.get_user_warnings_by_user_id(user.id) + for warning in old_warnings: + if warning.id in [int(x["id"]) if "id" in x else None for x in new_warnings]: + continue + + self._user_warning_service.remove_warnings(warning.id) + + for warning in new_warnings: + if "id" in warning and int(warning["id"]) in old_warnings.select(lambda x: x.id): + continue + + member = self._bot.get_guild(user.server.discord_id).get_member(user.discord_id) + author = self._users.get_user_by_id(int(warning["author"])) + self._user_warning_service.add_warnings(member, warning["description"], author.discord_id) diff --git a/kdb-bot/src/bot_graphql/queries/__init__.py b/bot/src/bot_graphql/queries/__init__.py similarity index 84% rename from kdb-bot/src/bot_graphql/queries/__init__.py rename to bot/src/bot_graphql/queries/__init__.py index 6709693b..9cdf0a5a 100644 --- a/kdb-bot/src/bot_graphql/queries/__init__.py +++ b/bot/src/bot_graphql/queries/__init__.py @@ -15,7 +15,7 @@ __title__ = "bot_graphql.queries" __author__ = "Sven Heidemann" __license__ = "MIT" __copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de" -__version__ = "1.1.10" +__version__ = "1.2.0" from collections import namedtuple @@ -23,4 +23,4 @@ from collections import namedtuple # imports: VersionInfo = namedtuple("VersionInfo", "major minor micro") -version_info = VersionInfo(major="1", minor="1", micro="10") +version_info = VersionInfo(major="1", minor="2", micro="0") diff --git a/kdb-bot/src/bot_graphql/queries/achievement_attribute_query.py b/bot/src/bot_graphql/queries/achievement_attribute_query.py similarity index 100% rename from kdb-bot/src/bot_graphql/queries/achievement_attribute_query.py rename to bot/src/bot_graphql/queries/achievement_attribute_query.py diff --git a/kdb-bot/src/bot_graphql/queries/achievement_history_query.py b/bot/src/bot_graphql/queries/achievement_history_query.py similarity index 100% rename from kdb-bot/src/bot_graphql/queries/achievement_history_query.py rename to bot/src/bot_graphql/queries/achievement_history_query.py diff --git a/kdb-bot/src/bot_graphql/queries/achievement_query.py b/bot/src/bot_graphql/queries/achievement_query.py similarity index 100% rename from kdb-bot/src/bot_graphql/queries/achievement_query.py rename to bot/src/bot_graphql/queries/achievement_query.py diff --git a/kdb-bot/src/bot_graphql/queries/auto_role_history_query.py b/bot/src/bot_graphql/queries/auto_role_history_query.py similarity index 100% rename from kdb-bot/src/bot_graphql/queries/auto_role_history_query.py rename to bot/src/bot_graphql/queries/auto_role_history_query.py diff --git a/kdb-bot/src/bot_graphql/queries/auto_role_query.py b/bot/src/bot_graphql/queries/auto_role_query.py similarity index 100% rename from kdb-bot/src/bot_graphql/queries/auto_role_query.py rename to bot/src/bot_graphql/queries/auto_role_query.py diff --git a/kdb-bot/src/bot_graphql/queries/auto_role_rule_history_query.py b/bot/src/bot_graphql/queries/auto_role_rule_history_query.py similarity index 100% rename from kdb-bot/src/bot_graphql/queries/auto_role_rule_history_query.py rename to bot/src/bot_graphql/queries/auto_role_rule_history_query.py diff --git a/kdb-bot/src/bot_graphql/queries/auto_role_rule_query.py b/bot/src/bot_graphql/queries/auto_role_rule_query.py similarity index 90% rename from kdb-bot/src/bot_graphql/queries/auto_role_rule_query.py rename to bot/src/bot_graphql/queries/auto_role_rule_query.py index e847a605..0b6373dd 100644 --- a/kdb-bot/src/bot_graphql/queries/auto_role_rule_query.py +++ b/bot/src/bot_graphql/queries/auto_role_rule_query.py @@ -8,7 +8,12 @@ from bot_graphql.abc.data_query_with_history_abc import DataQueryWithHistoryABC class AutoRoleRuleQuery(DataQueryWithHistoryABC): - def __init__(self, bot: DiscordBotServiceABC, auto_roles: AutoRoleRepositoryABC, db: DatabaseContextABC): + def __init__( + self, + bot: DiscordBotServiceABC, + auto_roles: AutoRoleRepositoryABC, + db: DatabaseContextABC, + ): DataQueryWithHistoryABC.__init__(self, "AutoRoleRule", "AutoRoleRulesHistory", AutoRoleRuleHistory, db) self._bot = bot diff --git a/kdb-bot/src/bot_graphql/queries/client_history_query.py b/bot/src/bot_graphql/queries/client_history_query.py similarity index 100% rename from kdb-bot/src/bot_graphql/queries/client_history_query.py rename to bot/src/bot_graphql/queries/client_history_query.py diff --git a/kdb-bot/src/bot_graphql/queries/client_query.py b/bot/src/bot_graphql/queries/client_query.py similarity index 100% rename from kdb-bot/src/bot_graphql/queries/client_query.py rename to bot/src/bot_graphql/queries/client_query.py diff --git a/kdb-bot/src/bot_graphql/queries/discord/__init__.py b/bot/src/bot_graphql/queries/discord/__init__.py similarity index 84% rename from kdb-bot/src/bot_graphql/queries/discord/__init__.py rename to bot/src/bot_graphql/queries/discord/__init__.py index 813ca26f..662e0b21 100644 --- a/kdb-bot/src/bot_graphql/queries/discord/__init__.py +++ b/bot/src/bot_graphql/queries/discord/__init__.py @@ -15,7 +15,7 @@ __title__ = "bot_graphql.queries.discord" __author__ = "Sven Heidemann" __license__ = "MIT" __copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de" -__version__ = "1.1.10" +__version__ = "1.2.0" from collections import namedtuple @@ -23,4 +23,4 @@ from collections import namedtuple # imports: VersionInfo = namedtuple("VersionInfo", "major minor micro") -version_info = VersionInfo(major="1", minor="1", micro="10") +version_info = VersionInfo(major="1", minor="2", micro="0") diff --git a/kdb-bot/src/bot_graphql/queries/discord/channel_query.py b/bot/src/bot_graphql/queries/discord/channel_query.py similarity index 100% rename from kdb-bot/src/bot_graphql/queries/discord/channel_query.py rename to bot/src/bot_graphql/queries/discord/channel_query.py diff --git a/kdb-bot/src/bot_graphql/queries/discord/discord_query.py b/bot/src/bot_graphql/queries/discord/discord_query.py similarity index 100% rename from kdb-bot/src/bot_graphql/queries/discord/discord_query.py rename to bot/src/bot_graphql/queries/discord/discord_query.py diff --git a/kdb-bot/src/bot_graphql/queries/discord/discord_user_query.py b/bot/src/bot_graphql/queries/discord/discord_user_query.py similarity index 100% rename from kdb-bot/src/bot_graphql/queries/discord/discord_user_query.py rename to bot/src/bot_graphql/queries/discord/discord_user_query.py diff --git a/kdb-bot/src/bot_graphql/queries/discord/emoji_query.py b/bot/src/bot_graphql/queries/discord/emoji_query.py similarity index 100% rename from kdb-bot/src/bot_graphql/queries/discord/emoji_query.py rename to bot/src/bot_graphql/queries/discord/emoji_query.py diff --git a/kdb-bot/src/bot_graphql/queries/discord/guild_query.py b/bot/src/bot_graphql/queries/discord/guild_query.py similarity index 90% rename from kdb-bot/src/bot_graphql/queries/discord/guild_query.py rename to bot/src/bot_graphql/queries/discord/guild_query.py index 98f581f3..cf32e8d7 100644 --- a/kdb-bot/src/bot_graphql/queries/discord/guild_query.py +++ b/bot/src/bot_graphql/queries/discord/guild_query.py @@ -20,7 +20,8 @@ class GuildQuery(QueryABC): self.set_field("channels", self._resolve_channels) self.set_field("roles", lambda g, *_: g.roles.order_by(lambda x: x.position)) self.set_field( - "emojis", lambda g, *_: List(discord.Emoji, g.emojis).order_by_descending(lambda x: x.created_at) + "emojis", + lambda g, *_: List(discord.Emoji, g.emojis).order_by_descending(lambda x: x.created_at), ) def _resolve_channels(self, g: Guild, *_, filter=None): diff --git a/kdb-bot/src/bot_graphql/queries/discord/role_query.py b/bot/src/bot_graphql/queries/discord/role_query.py similarity index 100% rename from kdb-bot/src/bot_graphql/queries/discord/role_query.py rename to bot/src/bot_graphql/queries/discord/role_query.py diff --git a/kdb-bot/src/bot_graphql/queries/game_server_query.py b/bot/src/bot_graphql/queries/game_server_query.py similarity index 100% rename from kdb-bot/src/bot_graphql/queries/game_server_query.py rename to bot/src/bot_graphql/queries/game_server_query.py diff --git a/kdb-bot/src/bot_graphql/queries/known_user_history_query.py b/bot/src/bot_graphql/queries/known_user_history_query.py similarity index 100% rename from kdb-bot/src/bot_graphql/queries/known_user_history_query.py rename to bot/src/bot_graphql/queries/known_user_history_query.py diff --git a/kdb-bot/src/bot_graphql/queries/known_user_query.py b/bot/src/bot_graphql/queries/known_user_query.py similarity index 100% rename from kdb-bot/src/bot_graphql/queries/known_user_query.py rename to bot/src/bot_graphql/queries/known_user_query.py diff --git a/kdb-bot/src/bot_graphql/queries/level_history_query.py b/bot/src/bot_graphql/queries/level_history_query.py similarity index 100% rename from kdb-bot/src/bot_graphql/queries/level_history_query.py rename to bot/src/bot_graphql/queries/level_history_query.py diff --git a/kdb-bot/src/bot_graphql/queries/level_query.py b/bot/src/bot_graphql/queries/level_query.py similarity index 100% rename from kdb-bot/src/bot_graphql/queries/level_query.py rename to bot/src/bot_graphql/queries/level_query.py diff --git a/kdb-bot/src/bot_graphql/queries/server_config_query.py b/bot/src/bot_graphql/queries/server_config_query.py similarity index 79% rename from kdb-bot/src/bot_graphql/queries/server_config_query.py rename to bot/src/bot_graphql/queries/server_config_query.py index 5e580eca..3f45fdbf 100644 --- a/kdb-bot/src/bot_graphql/queries/server_config_query.py +++ b/bot/src/bot_graphql/queries/server_config_query.py @@ -18,19 +18,31 @@ class ServerConfigQuery(DataQueryWithHistoryABC): self.set_field("xpPerReaction", lambda config, *_: config.xp_per_reaction) self.set_field("maxMessageXpPerHour", lambda config, *_: config.max_message_xp_per_hour) self.set_field("xpPerOntimeHour", lambda config, *_: config.xp_per_ontime_hour) - self.set_field("xpPerEventParticipation", lambda config, *_: config.xp_per_event_participation) + self.set_field( + "xpPerEventParticipation", + lambda config, *_: config.xp_per_event_participation, + ) self.set_field("xpPerAchievement", lambda config, *_: config.xp_per_achievement) + self.set_field("xpForBirthday", lambda config, *_: config.xp_for_birthday) self.set_field("afkCommandChannelId", lambda config, *_: config.afk_command_channel_id) self.set_field("helpVoiceChannelId", lambda config, *_: config.help_voice_channel_id) self.set_field("teamChannelId", lambda config, *_: config.team_channel_id) self.set_field("loginMessageChannelId", lambda config, *_: config.login_message_channel_id) self.set_field("defaultRoleId", lambda config, *_: config.default_role_id) self.set_field( - "shortRoleNameOnlySetHighestRole", lambda config, *_: config.short_role_name_only_set_highest_role + "shortRoleNameOnlySetHighestRole", + lambda config, *_: config.short_role_name_only_set_highest_role, + ) + self.set_field( + "gameOfferNotificationChatId", + lambda config, *_: config.game_offer_notification_chat_id, ) self.add_collection( "featureFlag", - lambda config, *_: List(any, [{"key": x, "value": config.feature_flags[x]} for x in config.feature_flags]), + lambda config, *_: List( + any, + [{"key": x, "value": config.feature_flags[x]} for x in config.feature_flags], + ), ) self.set_field("afkChannelIds", lambda config, *_: config.afk_channel_ids) self.set_field( diff --git a/kdb-bot/src/bot_graphql/queries/server_history_query.py b/bot/src/bot_graphql/queries/server_history_query.py similarity index 100% rename from kdb-bot/src/bot_graphql/queries/server_history_query.py rename to bot/src/bot_graphql/queries/server_history_query.py diff --git a/kdb-bot/src/bot_graphql/queries/server_query.py b/bot/src/bot_graphql/queries/server_query.py similarity index 79% rename from kdb-bot/src/bot_graphql/queries/server_query.py rename to bot/src/bot_graphql/queries/server_query.py index 6ba77149..edd647cd 100644 --- a/kdb-bot/src/bot_graphql/queries/server_query.py +++ b/bot/src/bot_graphql/queries/server_query.py @@ -12,7 +12,9 @@ from bot_data.abc.level_repository_abc import LevelRepositoryABC from bot_data.abc.server_config_repository_abc import ServerConfigRepositoryABC from bot_data.abc.short_role_name_repository_abc import ShortRoleNameRepositoryABC from bot_data.abc.user_joined_server_repository_abc import UserJoinedServerRepositoryABC -from bot_data.abc.user_joined_voice_channel_repository_abc import UserJoinedVoiceChannelRepositoryABC +from bot_data.abc.user_joined_voice_channel_repository_abc import ( + UserJoinedVoiceChannelRepositoryABC, +) from bot_data.abc.user_repository_abc import UserRepositoryABC from bot_data.model.server import Server from bot_data.model.server_config import ServerConfig @@ -65,22 +67,41 @@ class ServerQuery(DataQueryWithHistoryABC): AutoRoleFilter, ) self.add_collection( - "client", lambda server, *_: self._clients.get_clients_by_server_id(server.id), ClientFilter + "client", + lambda server, *_: self._clients.get_clients_by_server_id(server.id), + ClientFilter, ) - self.add_collection("level", lambda server, *_: self._levels.get_levels_by_server_id(server.id), LevelFilter) - self.add_collection("user", lambda server, *_: self._users.get_users_by_server_id(server.id), UserFilter) - self.add_collection("gameServer", lambda server, *_: game_servers.get_game_servers_by_server_id(server.id)) self.add_collection( - "achievement", lambda server, *_: achievements.get_achievements_by_server_id(server.id), AchievementFilter + "level", + lambda server, *_: self._levels.get_levels_by_server_id(server.id), + LevelFilter, + ) + self.add_collection( + "user", + lambda server, *_: self._users.get_users_by_server_id(server.id), + UserFilter, + ) + self.add_collection( + "gameServer", + lambda server, *_: game_servers.get_game_servers_by_server_id(server.id), + ) + self.add_collection( + "achievement", + lambda server, *_: achievements.get_achievements_by_server_id(server.id), + AchievementFilter, ) self.add_collection( "shortRoleName", lambda server, *_: short_role_names.get_short_role_names_by_server_id(server.id), ShortRoleNameFilter, ) - self.set_field("config", lambda server, *_: server_configs.get_server_config_by_server(server.id)) self.set_field( - "hasFeatureFlag", lambda server, *_, **kwargs: self._resolve_has_feature_flag(server, *_, **kwargs) + "config", + lambda server, *_: server_configs.get_server_config_by_server(server.id), + ) + self.set_field( + "hasFeatureFlag", + lambda server, *_, **kwargs: self._resolve_has_feature_flag(server, *_, **kwargs), ) @staticmethod diff --git a/kdb-bot/src/bot_graphql/queries/short_role_name_history_query.py b/bot/src/bot_graphql/queries/short_role_name_history_query.py similarity index 100% rename from kdb-bot/src/bot_graphql/queries/short_role_name_history_query.py rename to bot/src/bot_graphql/queries/short_role_name_history_query.py diff --git a/kdb-bot/src/bot_graphql/queries/short_role_name_query.py b/bot/src/bot_graphql/queries/short_role_name_query.py similarity index 100% rename from kdb-bot/src/bot_graphql/queries/short_role_name_query.py rename to bot/src/bot_graphql/queries/short_role_name_query.py diff --git a/kdb-bot/src/bot_graphql/queries/technician_config_history_query.py b/bot/src/bot_graphql/queries/technician_config_history_query.py similarity index 64% rename from kdb-bot/src/bot_graphql/queries/technician_config_history_query.py rename to bot/src/bot_graphql/queries/technician_config_history_query.py index a63f88f8..fb35ff2f 100644 --- a/kdb-bot/src/bot_graphql/queries/technician_config_history_query.py +++ b/bot/src/bot_graphql/queries/technician_config_history_query.py @@ -7,11 +7,17 @@ class TechnicianConfigHistoryQuery(HistoryQueryABC): def __init__(self): HistoryQueryABC.__init__(self, "TechnicianConfig") - self.set_field("helpCommandReferenceUrl", lambda config, *_: config.help_command_reference_url) + self.set_field( + "helpCommandReferenceUrl", + lambda config, *_: config.help_command_reference_url, + ) self.set_field("waitForRestart", lambda config, *_: config.wait_for_restart) self.set_field("waitForShutdown", lambda config, *_: config.wait_for_shutdown) self.set_field("cacheMaxMessages", lambda config, *_: config.cache_max_messages) self.add_collection( "featureFlag", - lambda config, *_: List(any, [{"key": x, "value": config.feature_flags[x]} for x in config.feature_flags]), + lambda config, *_: List( + any, + [{"key": x, "value": config.feature_flags[x]} for x in config.feature_flags], + ), ) diff --git a/kdb-bot/src/bot_graphql/queries/technician_config_query.py b/bot/src/bot_graphql/queries/technician_config_query.py similarity index 77% rename from kdb-bot/src/bot_graphql/queries/technician_config_query.py rename to bot/src/bot_graphql/queries/technician_config_query.py index 2d8bb8f9..d44d66ad 100644 --- a/kdb-bot/src/bot_graphql/queries/technician_config_query.py +++ b/bot/src/bot_graphql/queries/technician_config_query.py @@ -4,21 +4,35 @@ from cpl_query.extension import List from bot_data.abc.table_with_id_abc import TableWithIdABC from bot_data.model.technician_config_history import TechnicianConfigHistory from bot_data.model.technician_id_config_history import TechnicianIdConfigHistory -from bot_data.model.technician_ping_url_config_history import TechnicianPingUrlConfigHistory +from bot_data.model.technician_ping_url_config_history import ( + TechnicianPingUrlConfigHistory, +) from bot_graphql.abc.data_query_with_history_abc import DataQueryWithHistoryABC class TechnicianConfigQuery(DataQueryWithHistoryABC): def __init__(self, db: DatabaseContextABC): - DataQueryWithHistoryABC.__init__(self, "TechnicianConfig", "CFG_TechnicianHistory", TechnicianConfigHistory, db) + DataQueryWithHistoryABC.__init__( + self, + "TechnicianConfig", + "CFG_TechnicianHistory", + TechnicianConfigHistory, + db, + ) - self.set_field("helpCommandReferenceUrl", lambda config, *_: config.help_command_reference_url) + self.set_field( + "helpCommandReferenceUrl", + lambda config, *_: config.help_command_reference_url, + ) self.set_field("waitForRestart", lambda config, *_: config.wait_for_restart) self.set_field("waitForShutdown", lambda config, *_: config.wait_for_shutdown) self.set_field("cacheMaxMessages", lambda config, *_: config.cache_max_messages) self.add_collection( "featureFlag", - lambda config, *_: List(any, [{"key": x, "value": config.feature_flags[x]} for x in config.feature_flags]), + lambda config, *_: List( + any, + [{"key": x, "value": config.feature_flags[x]} for x in config.feature_flags], + ), ) self.set_field("pingURLs", lambda config, *_: config.ping_urls) self.set_field("technicianIds", lambda config, *_: config.technician_ids) diff --git a/kdb-bot/src/bot_graphql/queries/technician_id_config_history_query.py b/bot/src/bot_graphql/queries/technician_id_config_history_query.py similarity index 100% rename from kdb-bot/src/bot_graphql/queries/technician_id_config_history_query.py rename to bot/src/bot_graphql/queries/technician_id_config_history_query.py diff --git a/kdb-bot/src/bot_graphql/queries/technician_ping_url_config_history_query.py b/bot/src/bot_graphql/queries/technician_ping_url_config_history_query.py similarity index 100% rename from kdb-bot/src/bot_graphql/queries/technician_ping_url_config_history_query.py rename to bot/src/bot_graphql/queries/technician_ping_url_config_history_query.py diff --git a/kdb-bot/src/bot_graphql/queries/user_history_query.py b/bot/src/bot_graphql/queries/user_history_query.py similarity index 100% rename from kdb-bot/src/bot_graphql/queries/user_history_query.py rename to bot/src/bot_graphql/queries/user_history_query.py diff --git a/kdb-bot/src/bot_graphql/queries/user_joined_game_server_history_query.py b/bot/src/bot_graphql/queries/user_joined_game_server_history_query.py similarity index 100% rename from kdb-bot/src/bot_graphql/queries/user_joined_game_server_history_query.py rename to bot/src/bot_graphql/queries/user_joined_game_server_history_query.py diff --git a/kdb-bot/src/bot_graphql/queries/user_joined_game_server_query.py b/bot/src/bot_graphql/queries/user_joined_game_server_query.py similarity index 90% rename from kdb-bot/src/bot_graphql/queries/user_joined_game_server_query.py rename to bot/src/bot_graphql/queries/user_joined_game_server_query.py index 6a5befaa..0ea7ceb3 100644 --- a/kdb-bot/src/bot_graphql/queries/user_joined_game_server_query.py +++ b/bot/src/bot_graphql/queries/user_joined_game_server_query.py @@ -9,7 +9,11 @@ from bot_graphql.abc.data_query_with_history_abc import DataQueryWithHistoryABC class UserJoinedGameServerQuery(DataQueryWithHistoryABC): def __init__(self, bot: DiscordBotServiceABC, db: DatabaseContextABC): DataQueryWithHistoryABC.__init__( - self, "UserJoinedGameServer", "UserJoinedGameServersHistory", UserJoinedGameServerHistory, db + self, + "UserJoinedGameServer", + "UserJoinedGameServersHistory", + UserJoinedGameServerHistory, + db, ) self._bot = bot diff --git a/kdb-bot/src/bot_graphql/queries/user_joined_server_history_query.py b/bot/src/bot_graphql/queries/user_joined_server_history_query.py similarity index 100% rename from kdb-bot/src/bot_graphql/queries/user_joined_server_history_query.py rename to bot/src/bot_graphql/queries/user_joined_server_history_query.py diff --git a/kdb-bot/src/bot_graphql/queries/user_joined_server_query.py b/bot/src/bot_graphql/queries/user_joined_server_query.py similarity index 87% rename from kdb-bot/src/bot_graphql/queries/user_joined_server_query.py rename to bot/src/bot_graphql/queries/user_joined_server_query.py index a8e236ff..db9967f4 100644 --- a/kdb-bot/src/bot_graphql/queries/user_joined_server_query.py +++ b/bot/src/bot_graphql/queries/user_joined_server_query.py @@ -8,7 +8,11 @@ from bot_graphql.abc.data_query_with_history_abc import DataQueryWithHistoryABC class UserJoinedServerQuery(DataQueryWithHistoryABC): def __init__(self, db: DatabaseContextABC): DataQueryWithHistoryABC.__init__( - self, "UserJoinedServer", "UserJoinedServersHistory", UserJoinedServerHistory, db + self, + "UserJoinedServer", + "UserJoinedServersHistory", + UserJoinedServerHistory, + db, ) self.set_field("id", self.resolve_id) diff --git a/kdb-bot/src/bot_graphql/queries/user_joined_voice_channel_history_query.py b/bot/src/bot_graphql/queries/user_joined_voice_channel_history_query.py similarity index 100% rename from kdb-bot/src/bot_graphql/queries/user_joined_voice_channel_history_query.py rename to bot/src/bot_graphql/queries/user_joined_voice_channel_history_query.py diff --git a/kdb-bot/src/bot_graphql/queries/user_joined_voice_channel_query.py b/bot/src/bot_graphql/queries/user_joined_voice_channel_query.py similarity index 85% rename from kdb-bot/src/bot_graphql/queries/user_joined_voice_channel_query.py rename to bot/src/bot_graphql/queries/user_joined_voice_channel_query.py index a5465581..15a8af9c 100644 --- a/kdb-bot/src/bot_graphql/queries/user_joined_voice_channel_query.py +++ b/bot/src/bot_graphql/queries/user_joined_voice_channel_query.py @@ -2,14 +2,20 @@ from cpl_core.database.context import DatabaseContextABC from cpl_discord.service import DiscordBotServiceABC from bot_data.model.user_joined_voice_channel import UserJoinedVoiceChannel -from bot_data.model.user_joined_voice_channel_history import UserJoinedVoiceChannelHistory +from bot_data.model.user_joined_voice_channel_history import ( + UserJoinedVoiceChannelHistory, +) from bot_graphql.abc.data_query_with_history_abc import DataQueryWithHistoryABC class UserJoinedVoiceChannelQuery(DataQueryWithHistoryABC): def __init__(self, bot: DiscordBotServiceABC, db: DatabaseContextABC): DataQueryWithHistoryABC.__init__( - self, "UserJoinedVoiceChannel", "UserJoinedVoiceChannelsHistory", UserJoinedVoiceChannelHistory, db + self, + "UserJoinedVoiceChannel", + "UserJoinedVoiceChannelsHistory", + UserJoinedVoiceChannelHistory, + db, ) self._bot = bot diff --git a/kdb-bot/src/bot_graphql/queries/user_query.py b/bot/src/bot_graphql/queries/user_query.py similarity index 84% rename from kdb-bot/src/bot_graphql/queries/user_query.py rename to bot/src/bot_graphql/queries/user_query.py index 9bb4a48b..ceeab6d4 100644 --- a/kdb-bot/src/bot_graphql/queries/user_query.py +++ b/bot/src/bot_graphql/queries/user_query.py @@ -3,16 +3,24 @@ from cpl_discord.service import DiscordBotServiceABC from bot_core.abc.client_utils_abc import ClientUtilsABC from bot_data.abc.achievement_repository_abc import AchievementRepositoryABC -from bot_data.abc.user_joined_game_server_repository_abc import UserJoinedGameServerRepositoryABC +from bot_data.abc.user_joined_game_server_repository_abc import ( + UserJoinedGameServerRepositoryABC, +) from bot_data.abc.user_joined_server_repository_abc import UserJoinedServerRepositoryABC -from bot_data.abc.user_joined_voice_channel_repository_abc import UserJoinedVoiceChannelRepositoryABC +from bot_data.abc.user_joined_voice_channel_repository_abc import ( + UserJoinedVoiceChannelRepositoryABC, +) +from bot_data.abc.user_warnings_repository_abc import UserWarningsRepositoryABC from bot_data.model.user import User from bot_data.model.user_history import UserHistory from bot_graphql.abc.data_query_with_history_abc import DataQueryWithHistoryABC from bot_graphql.filter.achievement_filter import AchievementFilter from bot_graphql.filter.user_joined_game_server_filter import UserJoinedGameServerFilter from bot_graphql.filter.user_joined_server_filter import UserJoinedServerFilter -from bot_graphql.filter.user_joined_voice_channel_filter import UserJoinedVoiceChannelFilter +from bot_graphql.filter.user_joined_voice_channel_filter import ( + UserJoinedVoiceChannelFilter, +) +from bot_graphql.filter.user_warning_filter import UserWarningFilter from modules.level.service.level_service import LevelService from modules.permission.abc.permission_service_abc import PermissionServiceABC @@ -29,6 +37,7 @@ class UserQuery(DataQueryWithHistoryABC): user_joined_game_server: UserJoinedGameServerRepositoryABC, permissions: PermissionServiceABC, achievements: AchievementRepositoryABC, + user_warnings: UserWarningsRepositoryABC, ): DataQueryWithHistoryABC.__init__(self, "User", "UsersHistory", UserHistory, db) @@ -47,6 +56,7 @@ class UserQuery(DataQueryWithHistoryABC): self.set_field("xp", self.resolve_xp) self.set_field("messageCount", lambda x, *_: x.message_count) self.set_field("reactionCount", lambda x, *_: x.reaction_count) + self.set_field("birthday", lambda x, *_: x.birthday) self.set_field("ontime", self.resolve_ontime) self.set_field("level", self.resolve_level) self.add_collection( @@ -65,7 +75,14 @@ class UserQuery(DataQueryWithHistoryABC): UserJoinedGameServerFilter, ) self.add_collection( - "achievement", lambda user, *_: achievements.get_achievements_by_user_id(user.id), AchievementFilter + "achievement", + lambda user, *_: achievements.get_achievements_by_user_id(user.id), + AchievementFilter, + ) + self.add_collection( + "userWarning", + lambda user, *_: user_warnings.get_user_warnings_by_user_id(user.id), + UserWarningFilter, ) self.set_field("server", self.resolve_server) diff --git a/bot/src/bot_graphql/queries/user_warning_history_query.py b/bot/src/bot_graphql/queries/user_warning_history_query.py new file mode 100644 index 00000000..c120e360 --- /dev/null +++ b/bot/src/bot_graphql/queries/user_warning_history_query.py @@ -0,0 +1,11 @@ +from bot_graphql.abc.history_query_abc import HistoryQueryABC + + +class UserWarningHistoryQuery(HistoryQueryABC): + def __init__(self): + HistoryQueryABC.__init__(self, "UserWarning") + + self.set_field("id", lambda x, *_: x.id) + self.set_field("user", lambda x, *_: x.user) + self.set_field("description", lambda x, *_: x.description) + self.set_field("author", lambda x, *_: x.author) diff --git a/bot/src/bot_graphql/queries/user_warning_query.py b/bot/src/bot_graphql/queries/user_warning_query.py new file mode 100644 index 00000000..f6243d5e --- /dev/null +++ b/bot/src/bot_graphql/queries/user_warning_query.py @@ -0,0 +1,17 @@ +from cpl_core.database.context import DatabaseContextABC + +from bot_data.model.user_warnings_history import UserWarningsHistory +from bot_graphql.abc.data_query_with_history_abc import DataQueryWithHistoryABC + + +class UserWarningQuery(DataQueryWithHistoryABC): + def __init__( + self, + db: DatabaseContextABC, + ): + DataQueryWithHistoryABC.__init__(self, "UserWarning", "UserWarningsHistory", UserWarningsHistory, db) + + self.set_field("id", lambda x, *_: x.id) + self.set_field("user", lambda x, *_: x.user) + self.set_field("description", lambda x, *_: x.description) + self.set_field("author", lambda x, *_: x.author) diff --git a/kdb-bot/src/bot_graphql/query.py b/bot/src/bot_graphql/query.py similarity index 80% rename from kdb-bot/src/bot_graphql/query.py rename to bot/src/bot_graphql/query.py index abde5cb0..41dafdf0 100644 --- a/kdb-bot/src/bot_graphql/query.py +++ b/bot/src/bot_graphql/query.py @@ -11,10 +11,15 @@ from bot_data.abc.level_repository_abc import LevelRepositoryABC from bot_data.abc.server_repository_abc import ServerRepositoryABC from bot_data.abc.short_role_name_repository_abc import ShortRoleNameRepositoryABC from bot_data.abc.technician_config_repository_abc import TechnicianConfigRepositoryABC -from bot_data.abc.user_joined_game_server_repository_abc import UserJoinedGameServerRepositoryABC +from bot_data.abc.user_joined_game_server_repository_abc import ( + UserJoinedGameServerRepositoryABC, +) from bot_data.abc.user_joined_server_repository_abc import UserJoinedServerRepositoryABC -from bot_data.abc.user_joined_voice_channel_repository_abc import UserJoinedVoiceChannelRepositoryABC +from bot_data.abc.user_joined_voice_channel_repository_abc import ( + UserJoinedVoiceChannelRepositoryABC, +) from bot_data.abc.user_repository_abc import UserRepositoryABC +from bot_data.abc.user_warnings_repository_abc import UserWarningsRepositoryABC from bot_data.model.short_role_name_position_enum import ShortRoleNamePositionEnum from bot_graphql.abc.query_abc import QueryABC from bot_graphql.filter.achievement_filter import AchievementFilter @@ -27,7 +32,10 @@ from bot_graphql.filter.short_role_name_filter import ShortRoleNameFilter from bot_graphql.filter.user_filter import UserFilter from bot_graphql.filter.user_joined_game_server_filter import UserJoinedGameServerFilter from bot_graphql.filter.user_joined_server_filter import UserJoinedServerFilter -from bot_graphql.filter.user_joined_voice_channel_filter import UserJoinedVoiceChannelFilter +from bot_graphql.filter.user_joined_voice_channel_filter import ( + UserJoinedVoiceChannelFilter, +) +from bot_graphql.filter.user_warning_filter import UserWarningFilter from bot_graphql.model.discord import Discord from modules.achievements.achievement_service import AchievementService @@ -48,20 +56,27 @@ class Query(QueryABC): users: UserRepositoryABC, achievements: AchievementRepositoryABC, short_role_names: ShortRoleNameRepositoryABC, + user_warnings: UserWarningsRepositoryABC, achievement_service: AchievementService, technician_config: TechnicianConfigRepositoryABC, ): QueryABC.__init__(self, "Query") self.add_collection("autoRole", lambda *_: auto_roles.get_auto_roles(), AutoRoleFilter) - self.add_collection("autoRoleRule", lambda *_: auto_roles.get_auto_role_rules(), AutoRoleRuleFilter) + self.add_collection( + "autoRoleRule", + lambda *_: auto_roles.get_auto_role_rules(), + AutoRoleRuleFilter, + ) self.add_collection("client", lambda *_: clients.get_clients(), ClientFilter) self.add_collection("knownUser", lambda *_: known_users.get_users()) self.add_collection("level", lambda *_: levels.get_levels(), LevelFilter) self.add_collection("server", lambda *_: servers.get_servers(), ServerFilter) self.add_collection("gameServer", lambda *_: game_servers.get_game_servers()) self.add_collection( - "userJoinedServer", lambda *_: user_joined_servers.get_user_joined_servers(), UserJoinedServerFilter + "userJoinedServer", + lambda *_: user_joined_servers.get_user_joined_servers(), + UserJoinedServerFilter, ) self.add_collection( "userJoinedVoiceChannel", @@ -75,12 +90,25 @@ class Query(QueryABC): ) self.add_collection("user", lambda *_: users.get_users(), UserFilter) self.add_collection("achievement", lambda *_: achievements.get_achievements(), AchievementFilter) - self.add_collection("shortRoleName", lambda *_: short_role_names.get_short_role_names(), ShortRoleNameFilter) + self.add_collection( + "shortRoleName", + lambda *_: short_role_names.get_short_role_names(), + ShortRoleNameFilter, + ) + self.add_collection( + "userWarning", + lambda *_: user_warnings.get_user_warnings(), + UserWarningFilter, + ) self.set_field("technicianConfig", lambda *_: technician_config.get_technician_config()) self.set_field("achievementAttributes", lambda *_: achievement_service.get_attributes()) self.set_field("achievementOperators", lambda *_: achievement_service.get_operators()) - self.set_field("shortRoleNamePositions", lambda *_: [x.value for x in ShortRoleNamePositionEnum]) + self.set_field( + "shortRoleNamePositions", + lambda *_: [x.value for x in ShortRoleNamePositionEnum], + ) + self.set_field("possibleFeatureFlags", lambda *_: [e.value for e in FeatureFlagsEnum]) self.set_field("discord", lambda *_: Discord(bot.guilds, List(any).extend(bot.users))) diff --git a/kdb-bot/src/bot_graphql/schema.py b/bot/src/bot_graphql/schema.py similarity index 100% rename from kdb-bot/src/bot_graphql/schema.py rename to bot/src/bot_graphql/schema.py diff --git a/kdb-bot/src/modules/__init__.py b/bot/src/modules/__init__.py similarity index 100% rename from kdb-bot/src/modules/__init__.py rename to bot/src/modules/__init__.py diff --git a/kdb-bot/src/modules/achievements/__init__.py b/bot/src/modules/achievements/__init__.py similarity index 84% rename from kdb-bot/src/modules/achievements/__init__.py rename to bot/src/modules/achievements/__init__.py index 4fe7a734..865470f0 100644 --- a/kdb-bot/src/modules/achievements/__init__.py +++ b/bot/src/modules/achievements/__init__.py @@ -15,7 +15,7 @@ __title__ = "modules.achievements" __author__ = "Sven Heidemann" __license__ = "MIT" __copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de" -__version__ = "1.1.10" +__version__ = "1.2.0" from collections import namedtuple @@ -23,4 +23,4 @@ from collections import namedtuple # imports VersionInfo = namedtuple("VersionInfo", "major minor micro") -version_info = VersionInfo(major="1", minor="1", micro="10") +version_info = VersionInfo(major="1", minor="2", micro="0") diff --git a/kdb-bot/src/modules/achievements/achievement_attribute_resolver.py b/bot/src/modules/achievements/achievement_attribute_resolver.py similarity index 96% rename from kdb-bot/src/modules/achievements/achievement_attribute_resolver.py rename to bot/src/modules/achievements/achievement_attribute_resolver.py index f08f1579..66f478f8 100644 --- a/kdb-bot/src/modules/achievements/achievement_attribute_resolver.py +++ b/bot/src/modules/achievements/achievement_attribute_resolver.py @@ -7,9 +7,13 @@ from bot_data.abc.game_server_repository_abc import GameServerRepositoryABC from bot_data.abc.known_user_repository_abc import KnownUserRepositoryABC from bot_data.abc.level_repository_abc import LevelRepositoryABC from bot_data.abc.server_repository_abc import ServerRepositoryABC -from bot_data.abc.user_joined_game_server_repository_abc import UserJoinedGameServerRepositoryABC +from bot_data.abc.user_joined_game_server_repository_abc import ( + UserJoinedGameServerRepositoryABC, +) from bot_data.abc.user_joined_server_repository_abc import UserJoinedServerRepositoryABC -from bot_data.abc.user_joined_voice_channel_repository_abc import UserJoinedVoiceChannelRepositoryABC +from bot_data.abc.user_joined_voice_channel_repository_abc import ( + UserJoinedVoiceChannelRepositoryABC, +) from bot_data.abc.user_repository_abc import UserRepositoryABC from bot_data.model.user import User diff --git a/kdb-bot/src/modules/achievements/achievement_service.py b/bot/src/modules/achievements/achievement_service.py similarity index 94% rename from kdb-bot/src/modules/achievements/achievement_service.py rename to bot/src/modules/achievements/achievement_service.py index d7b2a455..39b6cd47 100644 --- a/kdb-bot/src/modules/achievements/achievement_service.py +++ b/bot/src/modules/achievements/achievement_service.py @@ -12,7 +12,9 @@ from bot_data.model.achievement import Achievement from bot_data.model.server_config import ServerConfig from bot_data.model.user import User from bot_data.model.user_got_achievement import UserGotAchievement -from modules.achievements.achievement_attribute_resolver import AchievementAttributeResolver +from modules.achievements.achievement_attribute_resolver import ( + AchievementAttributeResolver, +) from modules.achievements.model.achievement_attribute import AchievementAttribute @@ -49,10 +51,14 @@ class AchievementService: AchievementAttribute("level", lambda user: user.level, "Level"), # special cases AchievementAttribute( - "played_on_game_server", lambda user: resolver.get_played_on_game_server(user), "GameServer" + "played_on_game_server", + lambda user: resolver.get_played_on_game_server(user), + "GameServer", ), AchievementAttribute( - "last_single_ontime_hours", lambda user: resolver.get_last_ontime_hours(user), "number" + "last_single_ontime_hours", + lambda user: resolver.get_last_ontime_hours(user), + "number", ), ] ) diff --git a/kdb-bot/src/modules/achievements/achievements.json b/bot/src/modules/achievements/achievements.json similarity index 92% rename from kdb-bot/src/modules/achievements/achievements.json rename to bot/src/modules/achievements/achievements.json index 033548c6..64851517 100644 --- a/kdb-bot/src/modules/achievements/achievements.json +++ b/bot/src/modules/achievements/achievements.json @@ -3,8 +3,8 @@ "Name": "achievements", "Version": { "Major": "1", - "Minor": "1", - "Micro": "10" + "Minor": "2", + "Micro": "0" }, "Author": "Sven Heidemann", "AuthorEmail": "sven.heidemann@sh-edraft.de", @@ -16,10 +16,10 @@ "LicenseName": "MIT", "LicenseDescription": "MIT, see LICENSE for more details.", "Dependencies": [ - "cpl-core>=1.1.7" + "cpl-core>=1.2.0" ], "DevDependencies": [ - "cpl-cli>=1.1.7" + "cpl-cli>=1.2.0" ], "PythonVersion": ">=3.10.4", "PythonPath": {}, diff --git a/kdb-bot/src/modules/achievements/achievements_module.py b/bot/src/modules/achievements/achievements_module.py similarity index 63% rename from kdb-bot/src/modules/achievements/achievements_module.py rename to bot/src/modules/achievements/achievements_module.py index 3860feac..4e1a53f4 100644 --- a/kdb-bot/src/modules/achievements/achievements_module.py +++ b/bot/src/modules/achievements/achievements_module.py @@ -6,13 +6,23 @@ 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.achievements.achievement_attribute_resolver import AchievementAttributeResolver +from modules.achievements.achievement_attribute_resolver import ( + AchievementAttributeResolver, +) from modules.achievements.achievement_service import AchievementService from modules.achievements.commands.achievements_group import AchievementGroup -from modules.achievements.events.achievement_on_message_event import AchievementOnMessageEvent -from modules.achievements.events.achievement_on_reaction_add_event import AchievementOnReactionAddEvent -from modules.achievements.events.achievement_on_reaction_remove_event import AchievementOnReactionRemoveEvent -from modules.achievements.events.achievement_on_voice_state_update_event import AchievementOnVoiceStateUpdateEvent +from modules.achievements.events.achievement_on_message_event import ( + AchievementOnMessageEvent, +) +from modules.achievements.events.achievement_on_reaction_add_event import ( + AchievementOnReactionAddEvent, +) +from modules.achievements.events.achievement_on_reaction_remove_event import ( + AchievementOnReactionRemoveEvent, +) +from modules.achievements.events.achievement_on_voice_state_update_event import ( + AchievementOnVoiceStateUpdateEvent, +) class AchievementsModule(ModuleABC): @@ -26,9 +36,15 @@ class AchievementsModule(ModuleABC): services.add_transient(AchievementAttributeResolver) services.add_transient(AchievementService) - self._dc.add_command(AchievementGroup) + services.add_transient(AchievementGroup) - self._dc.add_event(DiscordEventTypesEnum.on_message.value, AchievementOnMessageEvent) - self._dc.add_event(DiscordEventTypesEnum.on_reaction_add.value, AchievementOnReactionAddEvent) - self._dc.add_event(DiscordEventTypesEnum.on_reaction_remove.value, AchievementOnReactionRemoveEvent) - self._dc.add_event(DiscordEventTypesEnum.on_voice_state_update.value, AchievementOnVoiceStateUpdateEvent) + services.add_transient(DiscordEventTypesEnum.on_message.value, AchievementOnMessageEvent) + services.add_transient(DiscordEventTypesEnum.on_reaction_add.value, AchievementOnReactionAddEvent) + services.add_transient( + DiscordEventTypesEnum.on_reaction_remove.value, + AchievementOnReactionRemoveEvent, + ) + services.add_transient( + DiscordEventTypesEnum.on_voice_state_update.value, + AchievementOnVoiceStateUpdateEvent, + ) diff --git a/kdb-bot/src/modules/achievements/commands/__init__.py b/bot/src/modules/achievements/commands/__init__.py similarity index 84% rename from kdb-bot/src/modules/achievements/commands/__init__.py rename to bot/src/modules/achievements/commands/__init__.py index 9ad697ae..1294f61b 100644 --- a/kdb-bot/src/modules/achievements/commands/__init__.py +++ b/bot/src/modules/achievements/commands/__init__.py @@ -15,7 +15,7 @@ __title__ = "modules.achievements.commands" __author__ = "Sven Heidemann" __license__ = "MIT" __copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de" -__version__ = "1.1.10" +__version__ = "1.2.0" from collections import namedtuple @@ -23,4 +23,4 @@ from collections import namedtuple # imports VersionInfo = namedtuple("VersionInfo", "major minor micro") -version_info = VersionInfo(major="1", minor="1", micro="10") +version_info = VersionInfo(major="1", minor="2", micro="0") diff --git a/kdb-bot/src/modules/achievements/commands/achievements_group.py b/bot/src/modules/achievements/commands/achievements_group.py similarity index 100% rename from kdb-bot/src/modules/achievements/commands/achievements_group.py rename to bot/src/modules/achievements/commands/achievements_group.py diff --git a/kdb-bot/src/modules/achievements/events/__init__.py b/bot/src/modules/achievements/events/__init__.py similarity index 84% rename from kdb-bot/src/modules/achievements/events/__init__.py rename to bot/src/modules/achievements/events/__init__.py index d59751a8..a7e73387 100644 --- a/kdb-bot/src/modules/achievements/events/__init__.py +++ b/bot/src/modules/achievements/events/__init__.py @@ -15,7 +15,7 @@ __title__ = "modules.achievements.events" __author__ = "Sven Heidemann" __license__ = "MIT" __copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de" -__version__ = "1.1.10" +__version__ = "1.2.0" from collections import namedtuple @@ -23,4 +23,4 @@ from collections import namedtuple # imports VersionInfo = namedtuple("VersionInfo", "major minor micro") -version_info = VersionInfo(major="1", minor="1", micro="10") +version_info = VersionInfo(major="1", minor="2", micro="0") diff --git a/kdb-bot/src/modules/achievements/events/achievement_on_message_event.py b/bot/src/modules/achievements/events/achievement_on_message_event.py similarity index 100% rename from kdb-bot/src/modules/achievements/events/achievement_on_message_event.py rename to bot/src/modules/achievements/events/achievement_on_message_event.py diff --git a/kdb-bot/src/modules/achievements/events/achievement_on_reaction_add_event.py b/bot/src/modules/achievements/events/achievement_on_reaction_add_event.py similarity index 93% rename from kdb-bot/src/modules/achievements/events/achievement_on_reaction_add_event.py rename to bot/src/modules/achievements/events/achievement_on_reaction_add_event.py index b033b534..37959385 100644 --- a/kdb-bot/src/modules/achievements/events/achievement_on_reaction_add_event.py +++ b/bot/src/modules/achievements/events/achievement_on_reaction_add_event.py @@ -36,7 +36,11 @@ class AchievementOnReactionAddEvent(OnReactionAddABC): self._servers = servers self._users = users - async def on_reaction_add(self, reaction: discord.reaction.Reaction, user: Union[discord.Member, discord.User]): + async def on_reaction_add( + self, + reaction: discord.reaction.Reaction, + user: Union[discord.Member, discord.User], + ): if not isinstance(user, discord.Member): return diff --git a/kdb-bot/src/modules/achievements/events/achievement_on_reaction_remove_event.py b/bot/src/modules/achievements/events/achievement_on_reaction_remove_event.py similarity index 93% rename from kdb-bot/src/modules/achievements/events/achievement_on_reaction_remove_event.py rename to bot/src/modules/achievements/events/achievement_on_reaction_remove_event.py index bbb33f28..a25e1868 100644 --- a/kdb-bot/src/modules/achievements/events/achievement_on_reaction_remove_event.py +++ b/bot/src/modules/achievements/events/achievement_on_reaction_remove_event.py @@ -36,7 +36,11 @@ class AchievementOnReactionRemoveEvent(OnReactionRemoveABC): self._servers = servers self._users = users - async def on_reaction_remove(self, reaction: discord.reaction.Reaction, user: Union[discord.Member, discord.User]): + async def on_reaction_remove( + self, + reaction: discord.reaction.Reaction, + user: Union[discord.Member, discord.User], + ): if not isinstance(user, discord.Member): return diff --git a/kdb-bot/src/modules/achievements/events/achievement_on_voice_state_update_event.py b/bot/src/modules/achievements/events/achievement_on_voice_state_update_event.py similarity index 93% rename from kdb-bot/src/modules/achievements/events/achievement_on_voice_state_update_event.py rename to bot/src/modules/achievements/events/achievement_on_voice_state_update_event.py index 6f60e06e..b28d5f64 100644 --- a/kdb-bot/src/modules/achievements/events/achievement_on_voice_state_update_event.py +++ b/bot/src/modules/achievements/events/achievement_on_voice_state_update_event.py @@ -35,7 +35,10 @@ class AchievementOnVoiceStateUpdateEvent(OnVoiceStateUpdateABC): self._users = users async def on_voice_state_update( - self, member: discord.member.Member, before: discord.member.VoiceState, after: discord.member.VoiceState + self, + member: discord.member.Member, + before: discord.member.VoiceState, + after: discord.member.VoiceState, ): if member.guild is None: return diff --git a/kdb-bot/src/modules/achievements/model/__init__.py b/bot/src/modules/achievements/model/__init__.py similarity index 84% rename from kdb-bot/src/modules/achievements/model/__init__.py rename to bot/src/modules/achievements/model/__init__.py index 1166e952..3887011a 100644 --- a/kdb-bot/src/modules/achievements/model/__init__.py +++ b/bot/src/modules/achievements/model/__init__.py @@ -15,7 +15,7 @@ __title__ = "modules.achievements.model" __author__ = "Sven Heidemann" __license__ = "MIT" __copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de" -__version__ = "1.1.10" +__version__ = "1.2.0" from collections import namedtuple @@ -23,4 +23,4 @@ from collections import namedtuple # imports VersionInfo = namedtuple("VersionInfo", "major minor micro") -version_info = VersionInfo(major="1", minor="1", micro="10") +version_info = VersionInfo(major="1", minor="2", micro="0") diff --git a/kdb-bot/src/modules/achievements/model/achievement_attribute.py b/bot/src/modules/achievements/model/achievement_attribute.py similarity index 100% rename from kdb-bot/src/modules/achievements/model/achievement_attribute.py rename to bot/src/modules/achievements/model/achievement_attribute.py diff --git a/kdb-bot/src/modules/auto_role/__init__.py b/bot/src/modules/auto_role/__init__.py similarity index 84% rename from kdb-bot/src/modules/auto_role/__init__.py rename to bot/src/modules/auto_role/__init__.py index 4d641f35..17736b45 100644 --- a/kdb-bot/src/modules/auto_role/__init__.py +++ b/bot/src/modules/auto_role/__init__.py @@ -15,7 +15,7 @@ __title__ = "modules.auto_role" __author__ = "Sven Heidemann" __license__ = "MIT" __copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de" -__version__ = "1.1.10" +__version__ = "1.2.0" from collections import namedtuple @@ -23,4 +23,4 @@ from collections import namedtuple # imports: VersionInfo = namedtuple("VersionInfo", "major minor micro") -version_info = VersionInfo(major="1", minor="1", micro="10") +version_info = VersionInfo(major="1", minor="2", micro="0") diff --git a/kdb-bot/src/modules/auto_role/auto-role.json b/bot/src/modules/auto_role/auto-role.json similarity index 95% rename from kdb-bot/src/modules/auto_role/auto-role.json rename to bot/src/modules/auto_role/auto-role.json index 2a78346e..81afa64e 100644 --- a/kdb-bot/src/modules/auto_role/auto-role.json +++ b/bot/src/modules/auto_role/auto-role.json @@ -3,8 +3,8 @@ "Name": "auto-role", "Version": { "Major": "1", - "Minor": "1", - "Micro": "10" + "Minor": "2", + "Micro": "0" }, "Author": "", "AuthorEmail": "", diff --git a/kdb-bot/src/modules/auto_role/auto_role_module.py b/bot/src/modules/auto_role/auto_role_module.py similarity index 93% rename from kdb-bot/src/modules/auto_role/auto_role_module.py rename to bot/src/modules/auto_role/auto_role_module.py index e23085f3..07eba97e 100644 --- a/kdb-bot/src/modules/auto_role/auto_role_module.py +++ b/bot/src/modules/auto_role/auto_role_module.py @@ -26,13 +26,13 @@ class AutoRoleModule(ModuleABC): def configure_services(self, services: ServiceCollectionABC, env: ApplicationEnvironmentABC): services.add_transient(AutoRoleReactionHandler) # commands - self._dc.add_command(AutoRoleGroup) + services.add_transient(AutoRoleGroup) # events - self._dc.add_event( + services.add_transient( DiscordEventTypesEnum.on_raw_reaction_add.value, AutoRoleOnRawReactionAddEvent, ) - self._dc.add_event( + services.add_transient( DiscordEventTypesEnum.on_raw_reaction_remove.value, AutoRoleOnRawReactionRemoveEvent, ) diff --git a/kdb-bot/src/modules/auto_role/command/__init__.py b/bot/src/modules/auto_role/command/__init__.py similarity index 84% rename from kdb-bot/src/modules/auto_role/command/__init__.py rename to bot/src/modules/auto_role/command/__init__.py index 3a096291..8044c8a1 100644 --- a/kdb-bot/src/modules/auto_role/command/__init__.py +++ b/bot/src/modules/auto_role/command/__init__.py @@ -15,7 +15,7 @@ __title__ = "modules.auto_role.command" __author__ = "Sven Heidemann" __license__ = "MIT" __copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de" -__version__ = "1.1.10" +__version__ = "1.2.0" from collections import namedtuple @@ -23,4 +23,4 @@ from collections import namedtuple # imports: VersionInfo = namedtuple("VersionInfo", "major minor micro") -version_info = VersionInfo(major="1", minor="1", micro="10") +version_info = VersionInfo(major="1", minor="2", micro="0") diff --git a/kdb-bot/src/modules/auto_role/command/auto_role_group.py b/bot/src/modules/auto_role/command/auto_role_group.py similarity index 98% rename from kdb-bot/src/modules/auto_role/command/auto_role_group.py rename to bot/src/modules/auto_role/command/auto_role_group.py index bf1f7758..f8d48d4e 100644 --- a/kdb-bot/src/modules/auto_role/command/auto_role_group.py +++ b/bot/src/modules/auto_role/command/auto_role_group.py @@ -61,7 +61,7 @@ class AutoRoleGroup(DiscordCommandABC): auto_roles = self._auto_roles.get_auto_roles_by_server_id(server.id).select(lambda x: x.id) return [ app_commands.Choice(name=auto_role, value=auto_role) - for auto_role in self._client_utils.get_auto_complete_list(auto_roles, current) + for auto_role in self._client_utils.get_auto_complete_list(auto_roles, current, lambda x: x.name) ] @commands.hybrid_group(name="auto-role") @@ -245,7 +245,10 @@ class AutoRoleGroup(DiscordCommandABC): for rule in self._auto_roles.get_auto_role_rules_by_auto_role_id(auto_role_from_db.id): await self._client_utils.react_to_message_by_auto_role_rule( - auto_role_from_db.discord_channel_id, auto_role_from_db.discord_message_id, rule, ctx.guild + auto_role_from_db.discord_channel_id, + auto_role_from_db.discord_message_id, + rule, + ctx.guild, ) await self._message_service.send_ctx_msg( @@ -389,7 +392,10 @@ class AutoRoleGroup(DiscordCommandABC): # as task to run in background self._bot.loop.create_task( await self._client_utils.react_to_message_by_auto_role_rule( - auto_role_from_db.discord_channel_id, auto_role_from_db.discord_message_id, rule, ctx.guild + auto_role_from_db.discord_channel_id, + auto_role_from_db.discord_message_id, + rule, + ctx.guild, ) ) diff --git a/kdb-bot/src/modules/auto_role/events/__init__.py b/bot/src/modules/auto_role/events/__init__.py similarity index 84% rename from kdb-bot/src/modules/auto_role/events/__init__.py rename to bot/src/modules/auto_role/events/__init__.py index 30f60d27..9309ac26 100644 --- a/kdb-bot/src/modules/auto_role/events/__init__.py +++ b/bot/src/modules/auto_role/events/__init__.py @@ -15,7 +15,7 @@ __title__ = "modules.auto_role.events" __author__ = "Sven Heidemann" __license__ = "MIT" __copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de" -__version__ = "1.1.10" +__version__ = "1.2.0" from collections import namedtuple @@ -23,4 +23,4 @@ from collections import namedtuple # imports: VersionInfo = namedtuple("VersionInfo", "major minor micro") -version_info = VersionInfo(major="1", minor="1", micro="10") +version_info = VersionInfo(major="1", minor="2", micro="0") diff --git a/kdb-bot/src/modules/auto_role/events/auto_role_on_raw_reaction_add.py b/bot/src/modules/auto_role/events/auto_role_on_raw_reaction_add.py similarity index 100% rename from kdb-bot/src/modules/auto_role/events/auto_role_on_raw_reaction_add.py rename to bot/src/modules/auto_role/events/auto_role_on_raw_reaction_add.py diff --git a/kdb-bot/src/modules/auto_role/events/auto_role_on_raw_reaction_remove.py b/bot/src/modules/auto_role/events/auto_role_on_raw_reaction_remove.py similarity index 100% rename from kdb-bot/src/modules/auto_role/events/auto_role_on_raw_reaction_remove.py rename to bot/src/modules/auto_role/events/auto_role_on_raw_reaction_remove.py diff --git a/kdb-bot/src/modules/auto_role/helper/__init__.py b/bot/src/modules/auto_role/helper/__init__.py similarity index 84% rename from kdb-bot/src/modules/auto_role/helper/__init__.py rename to bot/src/modules/auto_role/helper/__init__.py index 3e020087..a35ecba7 100644 --- a/kdb-bot/src/modules/auto_role/helper/__init__.py +++ b/bot/src/modules/auto_role/helper/__init__.py @@ -15,7 +15,7 @@ __title__ = "modules.auto_role.helper" __author__ = "Sven Heidemann" __license__ = "MIT" __copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de" -__version__ = "1.1.10" +__version__ = "1.2.0" from collections import namedtuple @@ -23,4 +23,4 @@ from collections import namedtuple # imports: VersionInfo = namedtuple("VersionInfo", "major minor micro") -version_info = VersionInfo(major="1", minor="1", micro="10") +version_info = VersionInfo(major="1", minor="2", micro="0") diff --git a/kdb-bot/src/modules/auto_role/helper/auto_role_reaction_handler.py b/bot/src/modules/auto_role/helper/auto_role_reaction_handler.py similarity index 100% rename from kdb-bot/src/modules/auto_role/helper/auto_role_reaction_handler.py rename to bot/src/modules/auto_role/helper/auto_role_reaction_handler.py diff --git a/kdb-bot/src/modules/base/__init__.py b/bot/src/modules/base/__init__.py similarity index 84% rename from kdb-bot/src/modules/base/__init__.py rename to bot/src/modules/base/__init__.py index 3314d082..e21909e8 100644 --- a/kdb-bot/src/modules/base/__init__.py +++ b/bot/src/modules/base/__init__.py @@ -15,7 +15,7 @@ __title__ = "modules.base" __author__ = "Sven Heidemann" __license__ = "MIT" __copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de" -__version__ = "1.1.10" +__version__ = "1.2.0" from collections import namedtuple @@ -23,4 +23,4 @@ from collections import namedtuple # imports VersionInfo = namedtuple("VersionInfo", "major minor micro") -version_info = VersionInfo(major="1", minor="1", micro="10") +version_info = VersionInfo(major="1", minor="2", micro="0") diff --git a/kdb-bot/src/modules/base/base.json b/bot/src/modules/base/base.json similarity index 95% rename from kdb-bot/src/modules/base/base.json rename to bot/src/modules/base/base.json index e7f69ff0..18cc6283 100644 --- a/kdb-bot/src/modules/base/base.json +++ b/bot/src/modules/base/base.json @@ -3,8 +3,8 @@ "Name": "base", "Version": { "Major": "1", - "Minor": "1", - "Micro": "10" + "Minor": "2", + "Micro": "0" }, "Author": "", "AuthorEmail": "", diff --git a/kdb-bot/src/modules/base/base_module.py b/bot/src/modules/base/base_module.py similarity index 70% rename from kdb-bot/src/modules/base/base_module.py rename to bot/src/modules/base/base_module.py index 626ea4ef..fc04e55e 100644 --- a/kdb-bot/src/modules/base/base_module.py +++ b/bot/src/modules/base/base_module.py @@ -5,7 +5,9 @@ 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.abc.task_abc import TaskABC from bot_core.configuration.feature_flags_enum import FeatureFlagsEnum +from modules.base.birthday_watcher import BirthdayWatcher from modules.base.command.afk_command import AFKCommand from modules.base.command.game_server_group import GameServerGroup from modules.base.command.help_command import HelpCommand @@ -28,7 +30,9 @@ from modules.base.events.base_on_message_delete_event import BaseOnMessageDelete from modules.base.events.base_on_message_event import BaseOnMessageEvent from modules.base.events.base_on_raw_reaction_add import BaseOnRawReactionAddEvent from modules.base.events.base_on_raw_reaction_remove import BaseOnRawReactionRemoveEvent -from modules.base.events.base_on_scheduled_event_update_event import BaseOnScheduledEventUpdateEvent +from modules.base.events.base_on_scheduled_event_update_event import ( + BaseOnScheduledEventUpdateEvent, +) from modules.base.events.base_on_voice_state_update_event import ( BaseOnVoiceStateUpdateEvent, ) @@ -56,55 +60,56 @@ class BaseModule(ModuleABC): services.add_transient(BaseReactionHandler) services.add_singleton(EventService) services.add_transient(UserWarningsService) + services.add_singleton(TaskABC, BirthdayWatcher) # forms services.add_transient(BugReportForm) services.add_transient(ComplaintForm) # commands - self._dc.add_command(AFKCommand) - self._dc.add_command(SubmitGroup) - self._dc.add_command(HelpCommand) - self._dc.add_command(InfoCommand) - self._dc.add_command(MassMoveCommand) - self._dc.add_command(PingCommand) - self._dc.add_command(PresenceCommand) - self._dc.add_command(MakeCoffeeCommand) + services.add_transient(AFKCommand) + services.add_transient(SubmitGroup) + services.add_transient(HelpCommand) + services.add_transient(InfoCommand) + services.add_transient(MassMoveCommand) + services.add_transient(PingCommand) + services.add_transient(PresenceCommand) + services.add_transient(MakeCoffeeCommand) - self._dc.add_command(PurgeCommand) - self._dc.add_command(UserGroup) - self._dc.add_command(RegisterGroup) - self._dc.add_command(UnregisterGroup) - self._dc.add_command(GameServerGroup) + services.add_transient(PurgeCommand) + services.add_transient(UserGroup) + services.add_transient(RegisterGroup) + services.add_transient(UnregisterGroup) + services.add_transient(GameServerGroup) # events - self._dc.add_event(DiscordEventTypesEnum.on_command.value, BaseOnCommandEvent) - self._dc.add_event(DiscordEventTypesEnum.on_command_error.value, BaseOnCommandErrorEvent) - self._dc.add_event(DiscordEventTypesEnum.on_member_join.value, BaseOnMemberJoinEvent) - self._dc.add_event(DiscordEventTypesEnum.on_member_remove.value, BaseOnMemberRemoveEvent) - self._dc.add_event(DiscordEventTypesEnum.on_message.value, BaseOnMessageEvent) - self._dc.add_event(DiscordEventTypesEnum.on_message_delete.value, BaseOnMessageDeleteEvent) - self._dc.add_event(DiscordEventTypesEnum.on_raw_reaction_add.value, BaseOnRawReactionAddEvent) - self._dc.add_event( + services.add_transient(DiscordEventTypesEnum.on_command.value, BaseOnCommandEvent) + services.add_transient(DiscordEventTypesEnum.on_command_error.value, BaseOnCommandErrorEvent) + services.add_transient(DiscordEventTypesEnum.on_member_join.value, BaseOnMemberJoinEvent) + services.add_transient(DiscordEventTypesEnum.on_member_remove.value, BaseOnMemberRemoveEvent) + services.add_transient(DiscordEventTypesEnum.on_message.value, BaseOnMessageEvent) + services.add_transient(DiscordEventTypesEnum.on_message_delete.value, BaseOnMessageDeleteEvent) + services.add_transient(DiscordEventTypesEnum.on_raw_reaction_add.value, BaseOnRawReactionAddEvent) + services.add_transient( DiscordEventTypesEnum.on_raw_reaction_remove.value, BaseOnRawReactionRemoveEvent, ) - self._dc.add_event( + services.add_transient( DiscordEventTypesEnum.on_voice_state_update.value, BaseOnVoiceStateUpdateEvent, ) - self._dc.add_event( + services.add_transient( DiscordEventTypesEnum.on_voice_state_update.value, BaseOnVoiceStateUpdateEventHelpChannel, ) - self._dc.add_event( + services.add_transient( DiscordEventTypesEnum.on_voice_state_update.value, BaseOnVoiceStateUpdateEventScheduledEventBonus, ) - self._dc.add_event( + services.add_transient( DiscordEventTypesEnum.on_scheduled_event_update.value, BaseOnScheduledEventUpdateEvent, ) - self._dc.add_event( + services.add_transient( DiscordEventTypesEnum.on_guild_join.value, BaseOnGuildJoinEvent, ) diff --git a/bot/src/modules/base/birthday_watcher.py b/bot/src/modules/base/birthday_watcher.py new file mode 100644 index 00000000..7b19638a --- /dev/null +++ b/bot/src/modules/base/birthday_watcher.py @@ -0,0 +1,67 @@ +import datetime + +from cpl_core.configuration import ConfigurationABC +from cpl_core.database.context import DatabaseContextABC +from cpl_discord.service import DiscordBotServiceABC +from cpl_translation import TranslatePipe +from discord.ext import tasks + +from bot_core.abc.task_abc import TaskABC +from bot_core.logging.task_logger import TaskLogger +from bot_core.service.message_service import MessageService +from bot_data.abc.user_repository_abc import UserRepositoryABC +from bot_data.model.server_config import ServerConfig + + +class BirthdayWatcher(TaskABC): + def __init__( + self, + config: ConfigurationABC, + logger: TaskLogger, + bot: DiscordBotServiceABC, + db: DatabaseContextABC, + users: UserRepositoryABC, + message_service: MessageService, + t: TranslatePipe, + ): + TaskABC.__init__(self) + + self._config = config + self._logger = logger + self._bot = bot + self._db = db + self._users = users + self._message_service = message_service + self._t = t + + self.watch.start() + + @tasks.loop(time=datetime.time(hour=8, minute=0)) + async def watch(self): + self._logger.info(__name__, "Watching birthdays") + try: + today = datetime.date.today() + users = self._users.get_users().where(lambda x: x.birthday is not None) + for user in users: + if user.birthday.day != today.day or user.birthday.month != today.month: + continue + + settings: ServerConfig = self._config.get_configuration(f"ServerConfig_{user.server.discord_id}") + + user.xp += settings.xp_for_birthday + self._users.update_user(user) + self._db.save_changes() + + guild = self._bot.get_guild(user.server.discord_id) + member = guild.get_member(user.discord_id) + await self._message_service.send_channel_message( + self._bot.get_channel(settings.notification_chat_id), + self._t.transform("modules.base.user.birthday.has_birthday").format(member.mention), + is_persistent=True, + ) + except Exception as e: + self._logger.error(__name__, f"Watching birthdays failed", e) + + @watch.before_loop + async def wait(self): + await self._wait_until_ready() diff --git a/kdb-bot/src/modules/base/command/__init__.py b/bot/src/modules/base/command/__init__.py similarity index 84% rename from kdb-bot/src/modules/base/command/__init__.py rename to bot/src/modules/base/command/__init__.py index 68f7c289..f5ed1fc1 100644 --- a/kdb-bot/src/modules/base/command/__init__.py +++ b/bot/src/modules/base/command/__init__.py @@ -15,7 +15,7 @@ __title__ = "modules.base.command" __author__ = "Sven Heidemann" __license__ = "MIT" __copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de" -__version__ = "1.1.10" +__version__ = "1.2.0" from collections import namedtuple @@ -23,4 +23,4 @@ from collections import namedtuple # imports VersionInfo = namedtuple("VersionInfo", "major minor micro") -version_info = VersionInfo(major="1", minor="1", micro="10") +version_info = VersionInfo(major="1", minor="2", micro="0") diff --git a/kdb-bot/src/modules/base/command/afk_command.py b/bot/src/modules/base/command/afk_command.py similarity index 100% rename from kdb-bot/src/modules/base/command/afk_command.py rename to bot/src/modules/base/command/afk_command.py diff --git a/kdb-bot/src/modules/base/command/game_server_group.py b/bot/src/modules/base/command/game_server_group.py similarity index 96% rename from kdb-bot/src/modules/base/command/game_server_group.py rename to bot/src/modules/base/command/game_server_group.py index b822f3de..55d235e3 100644 --- a/kdb-bot/src/modules/base/command/game_server_group.py +++ b/bot/src/modules/base/command/game_server_group.py @@ -107,7 +107,11 @@ class GameServerGroup(DiscordCommandABC): value=game_server_name, inline=True, ) - embed.add_field(name=self._t.transform("modules.base.game_server.list.api_key"), value=api_key, inline=True) + embed.add_field( + name=self._t.transform("modules.base.game_server.list.api_key"), + value=api_key, + inline=True, + ) await self._message_service.send_ctx_msg(ctx, embed, wait_before_delete=wait) self._logger.trace(__name__, f"Finished command game_server list") @@ -209,7 +213,11 @@ class GameServerGroup(DiscordCommandABC): description=self._t.transform("modules.base.game_server.list_members.description"), color=int("ef9d0d", 16), ) - embed.add_field(name=self._t.transform("modules.base.game_server.list_members.users"), value=users, inline=True) + embed.add_field( + name=self._t.transform("modules.base.game_server.list_members.users"), + value=users, + inline=True, + ) await self._message_service.send_ctx_msg(ctx, embed, wait_before_delete=wait) self._logger.trace(__name__, f"Finished command game-server remove") diff --git a/kdb-bot/src/modules/base/command/help_command.py b/bot/src/modules/base/command/help_command.py similarity index 100% rename from kdb-bot/src/modules/base/command/help_command.py rename to bot/src/modules/base/command/help_command.py diff --git a/kdb-bot/src/modules/base/command/info_command.py b/bot/src/modules/base/command/info_command.py similarity index 100% rename from kdb-bot/src/modules/base/command/info_command.py rename to bot/src/modules/base/command/info_command.py diff --git a/kdb-bot/src/modules/base/command/make_coffee_command.py b/bot/src/modules/base/command/make_coffee_command.py similarity index 100% rename from kdb-bot/src/modules/base/command/make_coffee_command.py rename to bot/src/modules/base/command/make_coffee_command.py diff --git a/kdb-bot/src/modules/base/command/mass_move_command.py b/bot/src/modules/base/command/mass_move_command.py similarity index 100% rename from kdb-bot/src/modules/base/command/mass_move_command.py rename to bot/src/modules/base/command/mass_move_command.py diff --git a/kdb-bot/src/modules/base/command/ping_command.py b/bot/src/modules/base/command/ping_command.py similarity index 100% rename from kdb-bot/src/modules/base/command/ping_command.py rename to bot/src/modules/base/command/ping_command.py diff --git a/kdb-bot/src/modules/base/command/presence_command.py b/bot/src/modules/base/command/presence_command.py similarity index 100% rename from kdb-bot/src/modules/base/command/presence_command.py rename to bot/src/modules/base/command/presence_command.py diff --git a/kdb-bot/src/modules/base/command/purge_command.py b/bot/src/modules/base/command/purge_command.py similarity index 100% rename from kdb-bot/src/modules/base/command/purge_command.py rename to bot/src/modules/base/command/purge_command.py diff --git a/kdb-bot/src/modules/base/command/register_group.py b/bot/src/modules/base/command/register_group.py similarity index 97% rename from kdb-bot/src/modules/base/command/register_group.py rename to bot/src/modules/base/command/register_group.py index dc3fed15..a598b31e 100644 --- a/kdb-bot/src/modules/base/command/register_group.py +++ b/bot/src/modules/base/command/register_group.py @@ -68,7 +68,8 @@ class RegisterGroup(DiscordCommandABC): response = requests.get(url=f"https://api.mojang.com/users/profiles/minecraft/{name}") if len(response.content) == 0: await self._message_service.send_interaction_msg( - ctx.interaction, self._t.transform("modules.base.register.not_found") + ctx.interaction, + self._t.transform("modules.base.register.not_found"), ) return diff --git a/kdb-bot/src/modules/base/command/submit_group.py b/bot/src/modules/base/command/submit_group.py similarity index 100% rename from kdb-bot/src/modules/base/command/submit_group.py rename to bot/src/modules/base/command/submit_group.py diff --git a/kdb-bot/src/modules/base/command/unregister_group.py b/bot/src/modules/base/command/unregister_group.py similarity index 100% rename from kdb-bot/src/modules/base/command/unregister_group.py rename to bot/src/modules/base/command/unregister_group.py diff --git a/kdb-bot/src/modules/base/command/user_group.py b/bot/src/modules/base/command/user_group.py similarity index 81% rename from kdb-bot/src/modules/base/command/user_group.py rename to bot/src/modules/base/command/user_group.py index 37570a70..4f1df692 100644 --- a/kdb-bot/src/modules/base/command/user_group.py +++ b/bot/src/modules/base/command/user_group.py @@ -1,10 +1,12 @@ -from typing import Optional, List +import datetime +from typing import Optional, List as TList import discord from cpl_core.configuration import ConfigurationABC from cpl_core.database.context import DatabaseContextABC from cpl_discord.command import DiscordCommandABC from cpl_discord.service import DiscordBotServiceABC +from cpl_query.extension import List from cpl_translation import TranslatePipe from discord import app_commands from discord.ext import commands @@ -22,6 +24,7 @@ from bot_data.abc.user_joined_voice_channel_repository_abc import ( ) from bot_data.abc.user_repository_abc import UserRepositoryABC from bot_data.abc.user_warnings_repository_abc import UserWarningsRepositoryABC +from bot_data.model.server_config import ServerConfig from modules.base.service.user_warnings_service import UserWarningsService from modules.level.service.level_service import LevelService from modules.permission.abc.permission_service_abc import PermissionServiceABC @@ -73,7 +76,7 @@ class UserGroup(DiscordCommandABC): "ontime": self._t.transform("modules.base.user.atr.ontime"), } - self._atr_list = [(key, self._atr_dict[key]) for key in self._atr_dict] + self._atr_TList = [(key, self._atr_dict[key]) for key in self._atr_dict] async def _handle_atr_calc( self, @@ -116,6 +119,64 @@ class UserGroup(DiscordCommandABC): async def user(self, ctx: Context): pass + @user.command() + @commands.guild_only() + @CommandChecks.check_is_ready() + async def birthday(self, ctx: Context, day: int, month: int, year: int): + self._logger.debug( + __name__, + f"Received command user birthday {ctx}:{ctx.author},{day}:{month}:{year}", + ) + date = datetime.date(year, month, day) + server = self._servers.get_server_by_discord_id(ctx.guild.id) + user = self._users.get_user_by_discord_id_and_server_id(ctx.author.id, server.id) + user.birthday = date + self._users.update_user(user) + self._db.save_changes() + await self._message_service.send_interaction_msg( + ctx.interaction, self._t.transform("modules.base.user.birthday.success") + ) + # notify team to prevent multiple entries every day + settings: ServerConfig = self._config.get_configuration(f"ServerConfig_{ctx.guild.id}") + channel = ctx.guild.get_channel(settings.team_channel_id) + await self._message_service.send_channel_message( + channel, + self._t.transform("modules.base.user.birthday.success_team").format(ctx.author.mention, date), + is_persistent=True, + ) + self._logger.trace(__name__, f"Finished user-info command") + + @birthday.autocomplete("day") + async def birthday_autocomplete( + self, interaction: discord.Interaction, current: str + ) -> TList[app_commands.Choice[int]]: + days = List(int, range(0, 32)).select(lambda x: str(x)) + return [ + app_commands.Choice(name=date, value=date) + for date in self._client_utils.get_auto_complete_list(days, current) + ] + + @birthday.autocomplete("month") + async def birthday_autocomplete( + self, interaction: discord.Interaction, current: str + ) -> TList[app_commands.Choice[int]]: + days = List(int, range(0, 13)).select(lambda x: str(x)) + return [ + app_commands.Choice(name=date, value=date) + for date in self._client_utils.get_auto_complete_list(days, current) + ] + + @birthday.autocomplete("year") + async def birthday_autocomplete( + self, interaction: discord.Interaction, current: str + ) -> TList[app_commands.Choice[int]]: + today = datetime.date.today() + days = List(int, range(today.year - 75, today.year)).select(lambda x: str(x)) + return [ + app_commands.Choice(name=date, value=date) + for date in self._client_utils.get_auto_complete_list(days, current) + ] + @user.command() @commands.guild_only() @CommandChecks.check_is_ready() @@ -237,8 +298,8 @@ class UserGroup(DiscordCommandABC): ) @get.autocomplete("atr") - async def get_autocomplete(self, interaction: discord.Interaction, current: str) -> List[app_commands.Choice[str]]: - return [app_commands.Choice(name=value, value=key) for key, value in self._atr_list] + async def get_autocomplete(self, interaction: discord.Interaction, current: str) -> TList[app_commands.Choice[str]]: + return [app_commands.Choice(name=value, value=key) for key, value in self._atr_TList] @user.command() @commands.guild_only() @@ -281,9 +342,9 @@ class UserGroup(DiscordCommandABC): ) @set.autocomplete("atr") - async def set_autocomplete(self, interaction: discord.Interaction, current: str) -> List[app_commands.Choice[str]]: - atr_list = [("xp", self._atr_dict["xp"])] - return [app_commands.Choice(name=value, value=key) for key, value in atr_list] + async def set_autocomplete(self, interaction: discord.Interaction, current: str) -> TList[app_commands.Choice[str]]: + atr_TList = [("xp", self._atr_dict["xp"])] + return [app_commands.Choice(name=value, value=key) for key, value in atr_TList] @user.command() @commands.guild_only() @@ -294,9 +355,9 @@ class UserGroup(DiscordCommandABC): await self._handle_atr_calc(ctx, atr, value, member) @add.autocomplete("atr") - async def set_autocomplete(self, interaction: discord.Interaction, current: str) -> List[app_commands.Choice[str]]: - atr_list = [("xp", self._atr_dict["xp"])] - return [app_commands.Choice(name=value, value=key) for key, value in atr_list] + async def set_autocomplete(self, interaction: discord.Interaction, current: str) -> TList[app_commands.Choice[str]]: + atr_TList = [("xp", self._atr_dict["xp"])] + return [app_commands.Choice(name=value, value=key) for key, value in atr_TList] @user.command() @commands.guild_only() @@ -307,9 +368,9 @@ class UserGroup(DiscordCommandABC): await self._handle_atr_calc(ctx, atr, value, member, is_remove=True) @remove.autocomplete("atr") - async def set_autocomplete(self, interaction: discord.Interaction, current: str) -> List[app_commands.Choice[str]]: - atr_list = [("xp", self._atr_dict["xp"])] - return [app_commands.Choice(name=value, value=key) for key, value in atr_list] + async def set_autocomplete(self, interaction: discord.Interaction, current: str) -> TList[app_commands.Choice[str]]: + atr_TList = [("xp", self._atr_dict["xp"])] + return [app_commands.Choice(name=value, value=key) for key, value in atr_TList] @user.command() @commands.guild_only() @@ -349,8 +410,8 @@ class UserGroup(DiscordCommandABC): @reset.autocomplete("atr") async def reset_autocomplete( self, interaction: discord.Interaction, current: str - ) -> List[app_commands.Choice[str]]: - return [app_commands.Choice(name=value, value=key) for key, value in self._atr_list] + ) -> TList[app_commands.Choice[str]]: + return [app_commands.Choice(name=value, value=key) for key, value in self._atr_TList] @user.group() @commands.guild_only() @@ -368,7 +429,9 @@ class UserGroup(DiscordCommandABC): user = self._users.find_user_by_discord_id_and_server_id(member.id, server.id) embed = discord.Embed( - title=member.name, description=self._t.transform("modules.base.user.atr.warnings"), color=int("ef9d0d", 16) + title=member.name, + description=self._t.transform("modules.base.user.atr.warnings"), + color=int("ef9d0d", 16), ) warnings = self._user_warnings.get_user_warnings_by_user_id(user.id) @@ -400,7 +463,7 @@ class UserGroup(DiscordCommandABC): async def add(self, ctx: Context, member: discord.Member, description: str): self._logger.debug(__name__, f"Received command user warning add {ctx}:{member},{description}") try: - await self._user_warnings_service.add_warnings(member, description, ctx.author.id) + await self._user_warnings_service.add_warnings_async(member, description, ctx.author.id) await self._message_service.send_ctx_msg(ctx, self._t.transform("modules.base.warnings.add.success")) except Exception as e: self._logger.error(__name__, f"Adding user warning failed", e) @@ -414,7 +477,7 @@ class UserGroup(DiscordCommandABC): async def remove(self, ctx: Context, warning_id: int): self._logger.debug(__name__, f"Received command user warning remove {ctx}:{warning_id}") try: - await self._user_warnings_service.remove_warnings(warning_id) + await self._user_warnings_service.remove_warnings_async(warning_id) await self._message_service.send_ctx_msg(ctx, self._t.transform("modules.base.warnings.remove.success")) except Exception as e: self._logger.error(__name__, f"Removing user warning failed", e) diff --git a/kdb-bot/src/modules/base/events/__init__.py b/bot/src/modules/base/events/__init__.py similarity index 84% rename from kdb-bot/src/modules/base/events/__init__.py rename to bot/src/modules/base/events/__init__.py index 8a040853..b1bc682c 100644 --- a/kdb-bot/src/modules/base/events/__init__.py +++ b/bot/src/modules/base/events/__init__.py @@ -15,7 +15,7 @@ __title__ = "modules.base.events" __author__ = "Sven Heidemann" __license__ = "MIT" __copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de" -__version__ = "1.1.10" +__version__ = "1.2.0" from collections import namedtuple @@ -23,4 +23,4 @@ from collections import namedtuple # imports: VersionInfo = namedtuple("VersionInfo", "major minor micro") -version_info = VersionInfo(major="1", minor="1", micro="10") +version_info = VersionInfo(major="1", minor="2", micro="0") diff --git a/kdb-bot/src/modules/base/events/base_on_command_error_event.py b/bot/src/modules/base/events/base_on_command_error_event.py similarity index 100% rename from kdb-bot/src/modules/base/events/base_on_command_error_event.py rename to bot/src/modules/base/events/base_on_command_error_event.py diff --git a/kdb-bot/src/modules/base/events/base_on_command_event.py b/bot/src/modules/base/events/base_on_command_event.py similarity index 100% rename from kdb-bot/src/modules/base/events/base_on_command_event.py rename to bot/src/modules/base/events/base_on_command_event.py diff --git a/kdb-bot/src/modules/base/events/base_on_guild_join_event.py b/bot/src/modules/base/events/base_on_guild_join_event.py similarity index 100% rename from kdb-bot/src/modules/base/events/base_on_guild_join_event.py rename to bot/src/modules/base/events/base_on_guild_join_event.py diff --git a/kdb-bot/src/modules/base/events/base_on_member_join_event.py b/bot/src/modules/base/events/base_on_member_join_event.py similarity index 100% rename from kdb-bot/src/modules/base/events/base_on_member_join_event.py rename to bot/src/modules/base/events/base_on_member_join_event.py diff --git a/kdb-bot/src/modules/base/events/base_on_member_remove_event.py b/bot/src/modules/base/events/base_on_member_remove_event.py similarity index 100% rename from kdb-bot/src/modules/base/events/base_on_member_remove_event.py rename to bot/src/modules/base/events/base_on_member_remove_event.py diff --git a/kdb-bot/src/modules/base/events/base_on_message_delete_event.py b/bot/src/modules/base/events/base_on_message_delete_event.py similarity index 100% rename from kdb-bot/src/modules/base/events/base_on_message_delete_event.py rename to bot/src/modules/base/events/base_on_message_delete_event.py diff --git a/kdb-bot/src/modules/base/events/base_on_message_event.py b/bot/src/modules/base/events/base_on_message_event.py similarity index 100% rename from kdb-bot/src/modules/base/events/base_on_message_event.py rename to bot/src/modules/base/events/base_on_message_event.py diff --git a/kdb-bot/src/modules/base/events/base_on_raw_reaction_add.py b/bot/src/modules/base/events/base_on_raw_reaction_add.py similarity index 100% rename from kdb-bot/src/modules/base/events/base_on_raw_reaction_add.py rename to bot/src/modules/base/events/base_on_raw_reaction_add.py diff --git a/kdb-bot/src/modules/base/events/base_on_raw_reaction_remove.py b/bot/src/modules/base/events/base_on_raw_reaction_remove.py similarity index 100% rename from kdb-bot/src/modules/base/events/base_on_raw_reaction_remove.py rename to bot/src/modules/base/events/base_on_raw_reaction_remove.py diff --git a/kdb-bot/src/modules/base/events/base_on_scheduled_event_update_event.py b/bot/src/modules/base/events/base_on_scheduled_event_update_event.py similarity index 100% rename from kdb-bot/src/modules/base/events/base_on_scheduled_event_update_event.py rename to bot/src/modules/base/events/base_on_scheduled_event_update_event.py diff --git a/kdb-bot/src/modules/base/events/base_on_voice_state_update_event.py b/bot/src/modules/base/events/base_on_voice_state_update_event.py similarity index 100% rename from kdb-bot/src/modules/base/events/base_on_voice_state_update_event.py rename to bot/src/modules/base/events/base_on_voice_state_update_event.py diff --git a/kdb-bot/src/modules/base/events/base_on_voice_state_update_event_help_channel.py b/bot/src/modules/base/events/base_on_voice_state_update_event_help_channel.py similarity index 100% rename from kdb-bot/src/modules/base/events/base_on_voice_state_update_event_help_channel.py rename to bot/src/modules/base/events/base_on_voice_state_update_event_help_channel.py diff --git a/kdb-bot/src/modules/base/events/base_on_voice_state_update_event_scheduled_event_bonus.py b/bot/src/modules/base/events/base_on_voice_state_update_event_scheduled_event_bonus.py similarity index 100% rename from kdb-bot/src/modules/base/events/base_on_voice_state_update_event_scheduled_event_bonus.py rename to bot/src/modules/base/events/base_on_voice_state_update_event_scheduled_event_bonus.py diff --git a/kdb-bot/src/modules/base/forms/__init__.py b/bot/src/modules/base/forms/__init__.py similarity index 84% rename from kdb-bot/src/modules/base/forms/__init__.py rename to bot/src/modules/base/forms/__init__.py index ca431fb0..1c884422 100644 --- a/kdb-bot/src/modules/base/forms/__init__.py +++ b/bot/src/modules/base/forms/__init__.py @@ -15,7 +15,7 @@ __title__ = "modules.base.forms" __author__ = "Sven Heidemann" __license__ = "MIT" __copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de" -__version__ = "1.1.10" +__version__ = "1.2.0" from collections import namedtuple @@ -23,4 +23,4 @@ from collections import namedtuple # imports VersionInfo = namedtuple("VersionInfo", "major minor micro") -version_info = VersionInfo(major="1", minor="1", micro="10") +version_info = VersionInfo(major="1", minor="2", micro="0") diff --git a/kdb-bot/src/modules/base/forms/bug_report_form.py b/bot/src/modules/base/forms/bug_report_form.py similarity index 100% rename from kdb-bot/src/modules/base/forms/bug_report_form.py rename to bot/src/modules/base/forms/bug_report_form.py diff --git a/kdb-bot/src/modules/base/forms/complaint_form.py b/bot/src/modules/base/forms/complaint_form.py similarity index 100% rename from kdb-bot/src/modules/base/forms/complaint_form.py rename to bot/src/modules/base/forms/complaint_form.py diff --git a/kdb-bot/src/modules/base/helper/__init__.py b/bot/src/modules/base/helper/__init__.py similarity index 84% rename from kdb-bot/src/modules/base/helper/__init__.py rename to bot/src/modules/base/helper/__init__.py index 5cc98776..ebb8d084 100644 --- a/kdb-bot/src/modules/base/helper/__init__.py +++ b/bot/src/modules/base/helper/__init__.py @@ -15,7 +15,7 @@ __title__ = "modules.base.helper" __author__ = "Sven Heidemann" __license__ = "MIT" __copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de" -__version__ = "1.1.10" +__version__ = "1.2.0" from collections import namedtuple @@ -23,4 +23,4 @@ from collections import namedtuple # imports: VersionInfo = namedtuple("VersionInfo", "major minor micro") -version_info = VersionInfo(major="1", minor="1", micro="10") +version_info = VersionInfo(major="1", minor="2", micro="0") diff --git a/kdb-bot/src/modules/base/helper/base_reaction_handler.py b/bot/src/modules/base/helper/base_reaction_handler.py similarity index 100% rename from kdb-bot/src/modules/base/helper/base_reaction_handler.py rename to bot/src/modules/base/helper/base_reaction_handler.py diff --git a/kdb-bot/src/modules/base/helper/voice_channel_transformer.py b/bot/src/modules/base/helper/voice_channel_transformer.py similarity index 95% rename from kdb-bot/src/modules/base/helper/voice_channel_transformer.py rename to bot/src/modules/base/helper/voice_channel_transformer.py index a9ee5df0..a6056e58 100644 --- a/kdb-bot/src/modules/base/helper/voice_channel_transformer.py +++ b/bot/src/modules/base/helper/voice_channel_transformer.py @@ -24,7 +24,8 @@ class VoiceChannelTransformer(Transformer): voice_channels = List(discord.Role, interaction.guild.voice_channels).where(lambda x: len(x.members) > 0) return [ app_commands.Choice( - name=f"{vc.name}" if vc.category is None else f"{vc.name}: {vc.category.name}", value=vc.name + name=f"{vc.name}" if vc.category is None else f"{vc.name}: {vc.category.name}", + value=vc.name, ) for vc in get_client_utils().get_auto_complete_list(voice_channels, current, lambda x: x.name) ] diff --git a/kdb-bot/src/modules/base/model/__init__.py b/bot/src/modules/base/model/__init__.py similarity index 84% rename from kdb-bot/src/modules/base/model/__init__.py rename to bot/src/modules/base/model/__init__.py index 53cc22a8..55bb1b35 100644 --- a/kdb-bot/src/modules/base/model/__init__.py +++ b/bot/src/modules/base/model/__init__.py @@ -15,7 +15,7 @@ __title__ = "modules.base.model" __author__ = "Sven Heidemann" __license__ = "MIT" __copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de" -__version__ = "1.1.10" +__version__ = "1.2.0" from collections import namedtuple @@ -23,4 +23,4 @@ from collections import namedtuple # imports: VersionInfo = namedtuple("VersionInfo", "major minor micro") -version_info = VersionInfo(major="1", minor="1", micro="10") +version_info = VersionInfo(major="1", minor="2", micro="0") diff --git a/kdb-bot/src/modules/base/model/active_event.py b/bot/src/modules/base/model/active_event.py similarity index 100% rename from kdb-bot/src/modules/base/model/active_event.py rename to bot/src/modules/base/model/active_event.py diff --git a/kdb-bot/src/modules/base/service/__init__.py b/bot/src/modules/base/service/__init__.py similarity index 84% rename from kdb-bot/src/modules/base/service/__init__.py rename to bot/src/modules/base/service/__init__.py index d231bef4..6a949706 100644 --- a/kdb-bot/src/modules/base/service/__init__.py +++ b/bot/src/modules/base/service/__init__.py @@ -15,7 +15,7 @@ __title__ = "modules.base.service" __author__ = "Sven Heidemann" __license__ = "MIT" __copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de" -__version__ = "1.1.10" +__version__ = "1.2.0" from collections import namedtuple @@ -23,4 +23,4 @@ from collections import namedtuple # imports VersionInfo = namedtuple("VersionInfo", "major minor micro") -version_info = VersionInfo(major="1", minor="1", micro="10") +version_info = VersionInfo(major="1", minor="2", micro="0") diff --git a/kdb-bot/src/modules/base/service/event_service.py b/bot/src/modules/base/service/event_service.py similarity index 100% rename from kdb-bot/src/modules/base/service/event_service.py rename to bot/src/modules/base/service/event_service.py diff --git a/kdb-bot/src/modules/base/service/user_warnings_service.py b/bot/src/modules/base/service/user_warnings_service.py similarity index 76% rename from kdb-bot/src/modules/base/service/user_warnings_service.py rename to bot/src/modules/base/service/user_warnings_service.py index f3b0ab3f..eea9129a 100644 --- a/kdb-bot/src/modules/base/service/user_warnings_service.py +++ b/bot/src/modules/base/service/user_warnings_service.py @@ -105,10 +105,24 @@ class UserWarningsService: user.xp = 0 self._users.update_user(user) self._db.save_changes() - await self.notify_team(member, self._t.transform("modules.base.warnings.kick").format(member.mention)) + await self.notify_team( + member, + self._t.transform("modules.base.warnings.kick").format(member.mention), + ) await member.kick() - async def add_warnings(self, member: discord.Member, description: str, author_id: int = None): + async def _notify_after_add(self, member: discord.Member, warning: UserWarnings): + server = self._servers.get_server_by_discord_id(member.guild.id) + user = self._users.get_user_by_discord_id_and_server_id(member.id, server.id) + + await self.notify_user( + member, + self._t.transform("modules.base.warnings.warned").format(warning.description), + ) + await self.notify_team(member, warning.description) + await self.check_for_warnings(member, user) + + def _add_warnings(self, member: discord.Member, description: str, author_id: int = None): server = self._servers.get_server_by_discord_id(member.guild.id) user = self._users.get_user_by_discord_id_and_server_id(member.id, server.id) @@ -119,17 +133,35 @@ class UserWarningsService: warning = UserWarnings(description, user, author) self._warnings.add_user_warnings(warning) self._db.save_changes() - await self.notify_user(member, self._t.transform("modules.base.warnings.warned").format(warning.description)) - await self.notify_team(member, warning.description) - await self.check_for_warnings(member, user) + return warning - async def remove_warnings(self, id: int): + def add_warnings(self, member: discord.Member, description: str, author_id: int = None): + warning = self._add_warnings(member, description, author_id) + self._bot.loop.create_task(self._notify_after_add(member, warning)) + + async def add_warnings_async(self, member: discord.Member, description: str, author_id: int = None): + warning = self._add_warnings(member, description, author_id) + await self._notify_after_add(member, warning) + + async def _notify_after_remove(self, warning: UserWarnings): + guild = self._bot.get_guild(warning.user.server.discord_id) + member = guild.get_member(warning.user.discord_id) + await self.notify_user( + member, + self._t.transform("modules.base.warnings.removed").format(warning.description), + ) + await self.notify_team(member, warning.description, removed=True) + + def _remove_warnings(self, id: int): warning = self._warnings.get_user_warnings_by_id(id) self._warnings.delete_user_warnings(warning) self._db.save_changes() + return warning - guild = self._bot.get_guild(warning.user.server.discord_id) - member = guild.get_member(warning.user.discord_id) + def remove_warnings(self, id: int): + warning = self._remove_warnings(id) + self._bot.loop.create_task(self._notify_after_remove(warning)) - await self.notify_user(member, self._t.transform("modules.base.warnings.removed").format(warning.description)) - await self.notify_team(member, warning.description, removed=True) + async def remove_warnings_async(self, id: int): + warning = self._remove_warnings(id) + await self._notify_after_remove(warning) diff --git a/kdb-bot/src/modules/base/thread/__init__.py b/bot/src/modules/base/thread/__init__.py similarity index 84% rename from kdb-bot/src/modules/base/thread/__init__.py rename to bot/src/modules/base/thread/__init__.py index cc75ad70..df1ac34b 100644 --- a/kdb-bot/src/modules/base/thread/__init__.py +++ b/bot/src/modules/base/thread/__init__.py @@ -15,7 +15,7 @@ __title__ = "modules.base.thread" __author__ = "Sven Heidemann" __license__ = "MIT" __copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de" -__version__ = "1.1.10" +__version__ = "1.2.0" from collections import namedtuple @@ -23,4 +23,4 @@ from collections import namedtuple # imports VersionInfo = namedtuple("VersionInfo", "major minor micro") -version_info = VersionInfo(major="1", minor="1", micro="10") +version_info = VersionInfo(major="1", minor="2", micro="0") diff --git a/kdb-bot/src/modules/boot_log/__init__.py b/bot/src/modules/boot_log/__init__.py similarity index 84% rename from kdb-bot/src/modules/boot_log/__init__.py rename to bot/src/modules/boot_log/__init__.py index c1f30e96..f1a9cdf7 100644 --- a/kdb-bot/src/modules/boot_log/__init__.py +++ b/bot/src/modules/boot_log/__init__.py @@ -15,7 +15,7 @@ __title__ = "modules.boot_log" __author__ = "Sven Heidemann" __license__ = "MIT" __copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de" -__version__ = "1.1.10" +__version__ = "1.2.0" from collections import namedtuple @@ -23,4 +23,4 @@ from collections import namedtuple # imports: VersionInfo = namedtuple("VersionInfo", "major minor micro") -version_info = VersionInfo(major="1", minor="1", micro="10") +version_info = VersionInfo(major="1", minor="2", micro="0") diff --git a/kdb-bot/src/modules/boot_log/boot-log.json b/bot/src/modules/boot_log/boot-log.json similarity index 95% rename from kdb-bot/src/modules/boot_log/boot-log.json rename to bot/src/modules/boot_log/boot-log.json index 444f31fd..4a62d1ac 100644 --- a/kdb-bot/src/modules/boot_log/boot-log.json +++ b/bot/src/modules/boot_log/boot-log.json @@ -3,8 +3,8 @@ "Name": "boot-log", "Version": { "Major": "1", - "Minor": "1", - "Micro": "10" + "Minor": "2", + "Micro": "0" }, "Author": "", "AuthorEmail": "", diff --git a/kdb-bot/src/modules/boot_log/boot_log_extension.py b/bot/src/modules/boot_log/boot_log_extension.py similarity index 100% rename from kdb-bot/src/modules/boot_log/boot_log_extension.py rename to bot/src/modules/boot_log/boot_log_extension.py diff --git a/kdb-bot/src/modules/boot_log/boot_log_module.py b/bot/src/modules/boot_log/boot_log_module.py similarity index 91% rename from kdb-bot/src/modules/boot_log/boot_log_module.py rename to bot/src/modules/boot_log/boot_log_module.py index 94a1cc14..dde842f0 100644 --- a/kdb-bot/src/modules/boot_log/boot_log_module.py +++ b/bot/src/modules/boot_log/boot_log_module.py @@ -19,4 +19,4 @@ class BootLogModule(ModuleABC): def configure_services(self, services: ServiceCollectionABC, env: ApplicationEnvironmentABC): # commands # events - self._dc.add_event(DiscordEventTypesEnum.on_ready.value, BootLogOnReadyEvent) + services.add_transient(DiscordEventTypesEnum.on_ready.value, BootLogOnReadyEvent) diff --git a/kdb-bot/src/modules/boot_log/boot_log_on_ready_event.py b/bot/src/modules/boot_log/boot_log_on_ready_event.py similarity index 100% rename from kdb-bot/src/modules/boot_log/boot_log_on_ready_event.py rename to bot/src/modules/boot_log/boot_log_on_ready_event.py diff --git a/kdb-bot/src/modules/config/__init__.py b/bot/src/modules/config/__init__.py similarity index 84% rename from kdb-bot/src/modules/config/__init__.py rename to bot/src/modules/config/__init__.py index fcdb875f..af1aee22 100644 --- a/kdb-bot/src/modules/config/__init__.py +++ b/bot/src/modules/config/__init__.py @@ -15,7 +15,7 @@ __title__ = "modules.config" __author__ = "Sven Heidemann" __license__ = "MIT" __copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de" -__version__ = "1.1.10" +__version__ = "1.2.0" from collections import namedtuple @@ -23,4 +23,4 @@ from collections import namedtuple # imports VersionInfo = namedtuple("VersionInfo", "major minor micro") -version_info = VersionInfo(major="1", minor="1", micro="10") +version_info = VersionInfo(major="1", minor="2", micro="0") diff --git a/kdb-bot/src/modules/config/config.json b/bot/src/modules/config/config.json similarity index 90% rename from kdb-bot/src/modules/config/config.json rename to bot/src/modules/config/config.json index 5dcc1695..cd8a4e09 100644 --- a/kdb-bot/src/modules/config/config.json +++ b/bot/src/modules/config/config.json @@ -3,8 +3,8 @@ "Name": "config", "Version": { "Major": "1", - "Minor": "1", - "Micro": "10" + "Minor": "2", + "Micro": "0" }, "Author": "", "AuthorEmail": "", @@ -16,10 +16,10 @@ "LicenseName": "", "LicenseDescription": "", "Dependencies": [ - "cpl-core>=1.1.7" + "cpl-core>=1.2.0" ], "DevDependencies": [ - "cpl-cli>=1.1.7" + "cpl-cli>=1.2.0" ], "PythonVersion": ">=3.10.4", "PythonPath": { diff --git a/kdb-bot/src/modules/config/config_extension.py b/bot/src/modules/config/config_extension.py similarity index 100% rename from kdb-bot/src/modules/config/config_extension.py rename to bot/src/modules/config/config_extension.py diff --git a/kdb-bot/src/modules/config/config_module.py b/bot/src/modules/config/config_module.py similarity index 90% rename from kdb-bot/src/modules/config/config_module.py rename to bot/src/modules/config/config_module.py index c55b62d1..14c16263 100644 --- a/kdb-bot/src/modules/config/config_module.py +++ b/bot/src/modules/config/config_module.py @@ -17,4 +17,4 @@ class ConfigModule(ModuleABC): pass def configure_services(self, services: ServiceCollectionABC, env: ApplicationEnvironmentABC): - self._dc.add_event(DiscordEventTypesEnum.on_ready.value, ConfigOnReadyEvent) + services.add_transient(DiscordEventTypesEnum.on_ready.value, ConfigOnReadyEvent) diff --git a/kdb-bot/src/modules/config/events/__init__.py b/bot/src/modules/config/events/__init__.py similarity index 84% rename from kdb-bot/src/modules/config/events/__init__.py rename to bot/src/modules/config/events/__init__.py index 7596e849..81b9f17e 100644 --- a/kdb-bot/src/modules/config/events/__init__.py +++ b/bot/src/modules/config/events/__init__.py @@ -15,7 +15,7 @@ __title__ = "modules.config.events" __author__ = "Sven Heidemann" __license__ = "MIT" __copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de" -__version__ = "1.1.10" +__version__ = "1.2.0" from collections import namedtuple @@ -23,4 +23,4 @@ from collections import namedtuple # imports VersionInfo = namedtuple("VersionInfo", "major minor micro") -version_info = VersionInfo(major="1", minor="1", micro="10") +version_info = VersionInfo(major="1", minor="2", micro="0") diff --git a/kdb-bot/src/modules/config/events/config_on_ready_event.py b/bot/src/modules/config/events/config_on_ready_event.py similarity index 100% rename from kdb-bot/src/modules/config/events/config_on_ready_event.py rename to bot/src/modules/config/events/config_on_ready_event.py diff --git a/kdb-bot/src/modules/config/service/__init__.py b/bot/src/modules/config/service/__init__.py similarity index 84% rename from kdb-bot/src/modules/config/service/__init__.py rename to bot/src/modules/config/service/__init__.py index 61e61e9c..049525d1 100644 --- a/kdb-bot/src/modules/config/service/__init__.py +++ b/bot/src/modules/config/service/__init__.py @@ -15,7 +15,7 @@ __title__ = "modules.config.service" __author__ = "Sven Heidemann" __license__ = "MIT" __copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de" -__version__ = "1.1.10" +__version__ = "1.2.0" from collections import namedtuple @@ -23,4 +23,4 @@ from collections import namedtuple # imports: VersionInfo = namedtuple("VersionInfo", "major minor micro") -version_info = VersionInfo(major="1", minor="1", micro="10") +version_info = VersionInfo(major="1", minor="2", micro="0") diff --git a/kdb-bot/src/modules/database/__init__.py b/bot/src/modules/database/__init__.py similarity index 84% rename from kdb-bot/src/modules/database/__init__.py rename to bot/src/modules/database/__init__.py index 769f117f..fce928b7 100644 --- a/kdb-bot/src/modules/database/__init__.py +++ b/bot/src/modules/database/__init__.py @@ -15,7 +15,7 @@ __title__ = "modules.database" __author__ = "Sven Heidemann" __license__ = "MIT" __copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de" -__version__ = "1.1.10" +__version__ = "1.2.0" from collections import namedtuple @@ -23,4 +23,4 @@ from collections import namedtuple # imports: VersionInfo = namedtuple("VersionInfo", "major minor micro") -version_info = VersionInfo(major="1", minor="1", micro="10") +version_info = VersionInfo(major="1", minor="2", micro="0") diff --git a/kdb-bot/src/modules/database/database.json b/bot/src/modules/database/database.json similarity index 96% rename from kdb-bot/src/modules/database/database.json rename to bot/src/modules/database/database.json index c82f9f24..3c617eb0 100644 --- a/kdb-bot/src/modules/database/database.json +++ b/bot/src/modules/database/database.json @@ -3,8 +3,8 @@ "Name": "database", "Version": { "Major": "1", - "Minor": "1", - "Micro": "10" + "Minor": "2", + "Micro": "0" }, "Author": "Sven Heidemann", "AuthorEmail": "sven.heidemann@sh-edraft.de", diff --git a/kdb-bot/src/modules/database/database_extension.py b/bot/src/modules/database/database_extension.py similarity index 100% rename from kdb-bot/src/modules/database/database_extension.py rename to bot/src/modules/database/database_extension.py diff --git a/kdb-bot/src/modules/database/database_module.py b/bot/src/modules/database/database_module.py similarity index 90% rename from kdb-bot/src/modules/database/database_module.py rename to bot/src/modules/database/database_module.py index cf478645..bd7c6c6f 100644 --- a/kdb-bot/src/modules/database/database_module.py +++ b/bot/src/modules/database/database_module.py @@ -19,4 +19,4 @@ class DatabaseModule(ModuleABC): def configure_services(self, services: ServiceCollectionABC, env: ApplicationEnvironmentABC): # commands # events - self._dc.add_event(DiscordEventTypesEnum.on_ready.value, DatabaseOnReadyEvent) + services.add_transient(DiscordEventTypesEnum.on_ready.value, DatabaseOnReadyEvent) diff --git a/kdb-bot/src/modules/database/database_on_ready_event.py b/bot/src/modules/database/database_on_ready_event.py similarity index 100% rename from kdb-bot/src/modules/database/database_on_ready_event.py rename to bot/src/modules/database/database_on_ready_event.py diff --git a/kdb-bot/src/modules/level/__init__.py b/bot/src/modules/level/__init__.py similarity index 84% rename from kdb-bot/src/modules/level/__init__.py rename to bot/src/modules/level/__init__.py index 241d5bed..9a54c17e 100644 --- a/kdb-bot/src/modules/level/__init__.py +++ b/bot/src/modules/level/__init__.py @@ -15,7 +15,7 @@ __title__ = "modules.level" __author__ = "Sven Heidemann" __license__ = "MIT" __copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de" -__version__ = "1.1.10" +__version__ = "1.2.0" from collections import namedtuple @@ -23,4 +23,4 @@ from collections import namedtuple # imports: VersionInfo = namedtuple("VersionInfo", "major minor micro") -version_info = VersionInfo(major="1", minor="1", micro="10") +version_info = VersionInfo(major="1", minor="2", micro="0") diff --git a/kdb-bot/src/modules/level/command/__init__.py b/bot/src/modules/level/command/__init__.py similarity index 84% rename from kdb-bot/src/modules/level/command/__init__.py rename to bot/src/modules/level/command/__init__.py index b06b3010..f1e31901 100644 --- a/kdb-bot/src/modules/level/command/__init__.py +++ b/bot/src/modules/level/command/__init__.py @@ -15,7 +15,7 @@ __title__ = "modules.level.command" __author__ = "Sven Heidemann" __license__ = "MIT" __copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de" -__version__ = "1.1.10" +__version__ = "1.2.0" from collections import namedtuple @@ -23,4 +23,4 @@ from collections import namedtuple # imports VersionInfo = namedtuple("VersionInfo", "major minor micro") -version_info = VersionInfo(major="1", minor="1", micro="10") +version_info = VersionInfo(major="1", minor="2", micro="0") diff --git a/kdb-bot/src/modules/level/command/level_group.py b/bot/src/modules/level/command/level_group.py similarity index 100% rename from kdb-bot/src/modules/level/command/level_group.py rename to bot/src/modules/level/command/level_group.py diff --git a/kdb-bot/src/modules/level/configuration/__init__.py b/bot/src/modules/level/configuration/__init__.py similarity index 84% rename from kdb-bot/src/modules/level/configuration/__init__.py rename to bot/src/modules/level/configuration/__init__.py index d830fb2a..a7104b3f 100644 --- a/kdb-bot/src/modules/level/configuration/__init__.py +++ b/bot/src/modules/level/configuration/__init__.py @@ -15,7 +15,7 @@ __title__ = "modules.level.configuration" __author__ = "Sven Heidemann" __license__ = "MIT" __copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de" -__version__ = "1.1.10" +__version__ = "1.2.0" from collections import namedtuple @@ -23,4 +23,4 @@ from collections import namedtuple # imports VersionInfo = namedtuple("VersionInfo", "major minor micro") -version_info = VersionInfo(major="1", minor="1", micro="10") +version_info = VersionInfo(major="1", minor="2", micro="0") diff --git a/kdb-bot/src/modules/level/configuration/default_level_settings.py b/bot/src/modules/level/configuration/default_level_settings.py similarity index 100% rename from kdb-bot/src/modules/level/configuration/default_level_settings.py rename to bot/src/modules/level/configuration/default_level_settings.py diff --git a/kdb-bot/src/modules/level/default-level.json b/bot/src/modules/level/default-level.json similarity index 100% rename from kdb-bot/src/modules/level/default-level.json rename to bot/src/modules/level/default-level.json diff --git a/kdb-bot/src/modules/level/events/__init__.py b/bot/src/modules/level/events/__init__.py similarity index 84% rename from kdb-bot/src/modules/level/events/__init__.py rename to bot/src/modules/level/events/__init__.py index 97ebcf9c..e6c57145 100644 --- a/kdb-bot/src/modules/level/events/__init__.py +++ b/bot/src/modules/level/events/__init__.py @@ -15,7 +15,7 @@ __title__ = "modules.level.events" __author__ = "Sven Heidemann" __license__ = "MIT" __copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de" -__version__ = "1.1.10" +__version__ = "1.2.0" from collections import namedtuple @@ -23,4 +23,4 @@ from collections import namedtuple # imports: VersionInfo = namedtuple("VersionInfo", "major minor micro") -version_info = VersionInfo(major="1", minor="1", micro="10") +version_info = VersionInfo(major="1", minor="2", micro="0") diff --git a/kdb-bot/src/modules/level/events/level_on_member_join_event.py b/bot/src/modules/level/events/level_on_member_join_event.py similarity index 100% rename from kdb-bot/src/modules/level/events/level_on_member_join_event.py rename to bot/src/modules/level/events/level_on_member_join_event.py diff --git a/kdb-bot/src/modules/level/events/level_on_message_event.py b/bot/src/modules/level/events/level_on_message_event.py similarity index 100% rename from kdb-bot/src/modules/level/events/level_on_message_event.py rename to bot/src/modules/level/events/level_on_message_event.py diff --git a/kdb-bot/src/modules/level/events/level_on_raw_reaction_add_event.py b/bot/src/modules/level/events/level_on_raw_reaction_add_event.py similarity index 100% rename from kdb-bot/src/modules/level/events/level_on_raw_reaction_add_event.py rename to bot/src/modules/level/events/level_on_raw_reaction_add_event.py diff --git a/kdb-bot/src/modules/level/events/level_on_raw_reaction_remove_event.py b/bot/src/modules/level/events/level_on_raw_reaction_remove_event.py similarity index 100% rename from kdb-bot/src/modules/level/events/level_on_raw_reaction_remove_event.py rename to bot/src/modules/level/events/level_on_raw_reaction_remove_event.py diff --git a/kdb-bot/src/modules/level/events/level_on_voice_state_update_event.py b/bot/src/modules/level/events/level_on_voice_state_update_event.py similarity index 100% rename from kdb-bot/src/modules/level/events/level_on_voice_state_update_event.py rename to bot/src/modules/level/events/level_on_voice_state_update_event.py diff --git a/kdb-bot/src/modules/level/level.json b/bot/src/modules/level/level.json similarity index 95% rename from kdb-bot/src/modules/level/level.json rename to bot/src/modules/level/level.json index 01ca6ac4..f4d7e68f 100644 --- a/kdb-bot/src/modules/level/level.json +++ b/bot/src/modules/level/level.json @@ -3,8 +3,8 @@ "Name": "level", "Version": { "Major": "1", - "Minor": "1", - "Micro": "10" + "Minor": "2", + "Micro": "0" }, "Author": "", "AuthorEmail": "", diff --git a/kdb-bot/src/modules/level/level_module.py b/bot/src/modules/level/level_module.py similarity index 75% rename from kdb-bot/src/modules/level/level_module.py rename to bot/src/modules/level/level_module.py index 018377f9..500e4a01 100644 --- a/kdb-bot/src/modules/level/level_module.py +++ b/bot/src/modules/level/level_module.py @@ -12,8 +12,12 @@ from bot_data.abc.data_seeder_abc import DataSeederABC from modules.level.command.level_group import LevelGroup from modules.level.events.level_on_member_join_event import LevelOnMemberJoinEvent from modules.level.events.level_on_message_event import LevelOnMessageEvent -from modules.level.events.level_on_raw_reaction_add_event import LevelOnRawReactionAddEvent -from modules.level.events.level_on_raw_reaction_remove_event import LevelOnRawReactionRemoveEvent +from modules.level.events.level_on_raw_reaction_add_event import ( + LevelOnRawReactionAddEvent, +) +from modules.level.events.level_on_raw_reaction_remove_event import ( + LevelOnRawReactionRemoveEvent, +) from modules.level.events.level_on_voice_state_update_event import ( LevelOnVoiceStateUpdateEvent, ) @@ -36,14 +40,17 @@ class LevelModule(ModuleABC): services.add_transient(LevelService) # commands - self._dc.add_command(LevelGroup) + services.add_transient(LevelGroup) # events - self._dc.add_event(DiscordEventTypesEnum.on_message.value, LevelOnMessageEvent) - self._dc.add_event( + services.add_transient(DiscordEventTypesEnum.on_message.value, LevelOnMessageEvent) + services.add_transient( DiscordEventTypesEnum.on_voice_state_update.value, LevelOnVoiceStateUpdateEvent, ) - self._dc.add_event(DiscordEventTypesEnum.on_member_join.value, LevelOnMemberJoinEvent) - self._dc.add_event(DiscordEventTypesEnum.on_raw_reaction_add.value, LevelOnRawReactionAddEvent) - self._dc.add_event(DiscordEventTypesEnum.on_raw_reaction_remove.value, LevelOnRawReactionRemoveEvent) + services.add_transient(DiscordEventTypesEnum.on_member_join.value, LevelOnMemberJoinEvent) + services.add_transient(DiscordEventTypesEnum.on_raw_reaction_add.value, LevelOnRawReactionAddEvent) + services.add_transient( + DiscordEventTypesEnum.on_raw_reaction_remove.value, + LevelOnRawReactionRemoveEvent, + ) diff --git a/kdb-bot/src/modules/level/level_seeder.py b/bot/src/modules/level/level_seeder.py similarity index 100% rename from kdb-bot/src/modules/level/level_seeder.py rename to bot/src/modules/level/level_seeder.py diff --git a/kdb-bot/src/modules/level/service/__init__.py b/bot/src/modules/level/service/__init__.py similarity index 84% rename from kdb-bot/src/modules/level/service/__init__.py rename to bot/src/modules/level/service/__init__.py index 6c623e08..cda7dc5f 100644 --- a/kdb-bot/src/modules/level/service/__init__.py +++ b/bot/src/modules/level/service/__init__.py @@ -15,7 +15,7 @@ __title__ = "modules.level.service" __author__ = "Sven Heidemann" __license__ = "MIT" __copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de" -__version__ = "1.1.10" +__version__ = "1.2.0" from collections import namedtuple @@ -23,4 +23,4 @@ from collections import namedtuple # imports VersionInfo = namedtuple("VersionInfo", "major minor micro") -version_info = VersionInfo(major="1", minor="1", micro="10") +version_info = VersionInfo(major="1", minor="2", micro="0") diff --git a/kdb-bot/src/modules/level/service/level_service.py b/bot/src/modules/level/service/level_service.py similarity index 100% rename from kdb-bot/src/modules/level/service/level_service.py rename to bot/src/modules/level/service/level_service.py diff --git a/kdb-bot/src/modules/permission/__init__.py b/bot/src/modules/permission/__init__.py similarity index 84% rename from kdb-bot/src/modules/permission/__init__.py rename to bot/src/modules/permission/__init__.py index f722d617..a0fc4fc7 100644 --- a/kdb-bot/src/modules/permission/__init__.py +++ b/bot/src/modules/permission/__init__.py @@ -15,7 +15,7 @@ __title__ = "modules.permission" __author__ = "Sven Heidemann" __license__ = "MIT" __copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de" -__version__ = "1.1.10" +__version__ = "1.2.0" from collections import namedtuple @@ -23,4 +23,4 @@ from collections import namedtuple # imports: VersionInfo = namedtuple("VersionInfo", "major minor micro") -version_info = VersionInfo(major="1", minor="1", micro="10") +version_info = VersionInfo(major="1", minor="2", micro="0") diff --git a/kdb-bot/src/modules/permission/abc/__init__.py b/bot/src/modules/permission/abc/__init__.py similarity index 84% rename from kdb-bot/src/modules/permission/abc/__init__.py rename to bot/src/modules/permission/abc/__init__.py index f527d830..6379f88e 100644 --- a/kdb-bot/src/modules/permission/abc/__init__.py +++ b/bot/src/modules/permission/abc/__init__.py @@ -15,7 +15,7 @@ __title__ = "modules.permission.abc" __author__ = "Sven Heidemann" __license__ = "MIT" __copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de" -__version__ = "1.1.10" +__version__ = "1.2.0" from collections import namedtuple @@ -23,4 +23,4 @@ from collections import namedtuple # imports VersionInfo = namedtuple("VersionInfo", "major minor micro") -version_info = VersionInfo(major="1", minor="1", micro="10") +version_info = VersionInfo(major="1", minor="2", micro="0") diff --git a/kdb-bot/src/modules/permission/abc/permission_service_abc.py b/bot/src/modules/permission/abc/permission_service_abc.py similarity index 100% rename from kdb-bot/src/modules/permission/abc/permission_service_abc.py rename to bot/src/modules/permission/abc/permission_service_abc.py diff --git a/kdb-bot/src/modules/permission/permission.json b/bot/src/modules/permission/permission.json similarity index 95% rename from kdb-bot/src/modules/permission/permission.json rename to bot/src/modules/permission/permission.json index 2ea792a8..3a708347 100644 --- a/kdb-bot/src/modules/permission/permission.json +++ b/bot/src/modules/permission/permission.json @@ -3,8 +3,8 @@ "Name": "permission", "Version": { "Major": "1", - "Minor": "1", - "Micro": "10" + "Minor": "2", + "Micro": "0" }, "Author": "", "AuthorEmail": "", diff --git a/kdb-bot/src/modules/permission/permission_module.py b/bot/src/modules/permission/permission_module.py similarity index 100% rename from kdb-bot/src/modules/permission/permission_module.py rename to bot/src/modules/permission/permission_module.py diff --git a/kdb-bot/src/modules/permission/service/__init__.py b/bot/src/modules/permission/service/__init__.py similarity index 84% rename from kdb-bot/src/modules/permission/service/__init__.py rename to bot/src/modules/permission/service/__init__.py index 7518517d..db82db07 100644 --- a/kdb-bot/src/modules/permission/service/__init__.py +++ b/bot/src/modules/permission/service/__init__.py @@ -15,7 +15,7 @@ __title__ = "modules.permission.service" __author__ = "Sven Heidemann" __license__ = "MIT" __copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de" -__version__ = "1.1.10" +__version__ = "1.2.0" from collections import namedtuple @@ -23,4 +23,4 @@ from collections import namedtuple # imports VersionInfo = namedtuple("VersionInfo", "major minor micro") -version_info = VersionInfo(major="1", minor="1", micro="10") +version_info = VersionInfo(major="1", minor="2", micro="0") diff --git a/kdb-bot/src/modules/permission/service/permission_service.py b/bot/src/modules/permission/service/permission_service.py similarity index 100% rename from kdb-bot/src/modules/permission/service/permission_service.py rename to bot/src/modules/permission/service/permission_service.py diff --git a/kdb-bot/src/modules/short_role_name/__init__.py b/bot/src/modules/short_role_name/__init__.py similarity index 84% rename from kdb-bot/src/modules/short_role_name/__init__.py rename to bot/src/modules/short_role_name/__init__.py index 349e00ae..46278ac8 100644 --- a/kdb-bot/src/modules/short_role_name/__init__.py +++ b/bot/src/modules/short_role_name/__init__.py @@ -15,7 +15,7 @@ __title__ = "modules.short_role_name" __author__ = "Sven Heidemann" __license__ = "MIT" __copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de" -__version__ = "1.1.10" +__version__ = "1.2.0" from collections import namedtuple @@ -23,4 +23,4 @@ from collections import namedtuple # imports VersionInfo = namedtuple("VersionInfo", "major minor micro") -version_info = VersionInfo(major="1", minor="1", micro="10") +version_info = VersionInfo(major="1", minor="2", micro="0") diff --git a/kdb-bot/src/modules/short_role_name/events/__init__.py b/bot/src/modules/short_role_name/events/__init__.py similarity index 85% rename from kdb-bot/src/modules/short_role_name/events/__init__.py rename to bot/src/modules/short_role_name/events/__init__.py index 500818f9..eb81e544 100644 --- a/kdb-bot/src/modules/short_role_name/events/__init__.py +++ b/bot/src/modules/short_role_name/events/__init__.py @@ -15,7 +15,7 @@ __title__ = "modules.short_role_name.events" __author__ = "Sven Heidemann" __license__ = "MIT" __copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de" -__version__ = "1.1.10" +__version__ = "1.2.0" from collections import namedtuple @@ -23,4 +23,4 @@ from collections import namedtuple # imports VersionInfo = namedtuple("VersionInfo", "major minor micro") -version_info = VersionInfo(major="1", minor="1", micro="10") +version_info = VersionInfo(major="1", minor="2", micro="0") diff --git a/kdb-bot/src/modules/short_role_name/events/short_role_name_on_member_update_event.py b/bot/src/modules/short_role_name/events/short_role_name_on_member_update_event.py similarity index 100% rename from kdb-bot/src/modules/short_role_name/events/short_role_name_on_member_update_event.py rename to bot/src/modules/short_role_name/events/short_role_name_on_member_update_event.py diff --git a/kdb-bot/src/modules/short_role_name/service/__init__.py b/bot/src/modules/short_role_name/service/__init__.py similarity index 85% rename from kdb-bot/src/modules/short_role_name/service/__init__.py rename to bot/src/modules/short_role_name/service/__init__.py index 4f98c6a7..c5716cd3 100644 --- a/kdb-bot/src/modules/short_role_name/service/__init__.py +++ b/bot/src/modules/short_role_name/service/__init__.py @@ -15,7 +15,7 @@ __title__ = "modules.short_role_name.service" __author__ = "Sven Heidemann" __license__ = "MIT" __copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de" -__version__ = "1.1.10" +__version__ = "1.2.0" from collections import namedtuple @@ -23,4 +23,4 @@ from collections import namedtuple # imports VersionInfo = namedtuple("VersionInfo", "major minor micro") -version_info = VersionInfo(major="1", minor="1", micro="10") +version_info = VersionInfo(major="1", minor="2", micro="0") diff --git a/kdb-bot/src/modules/short_role_name/service/short_role_name_service.py b/bot/src/modules/short_role_name/service/short_role_name_service.py similarity index 100% rename from kdb-bot/src/modules/short_role_name/service/short_role_name_service.py rename to bot/src/modules/short_role_name/service/short_role_name_service.py diff --git a/kdb-bot/src/modules/short_role_name/short-role-name.json b/bot/src/modules/short_role_name/short-role-name.json similarity index 88% rename from kdb-bot/src/modules/short_role_name/short-role-name.json rename to bot/src/modules/short_role_name/short-role-name.json index 3cc5cce9..805e3d18 100644 --- a/kdb-bot/src/modules/short_role_name/short-role-name.json +++ b/bot/src/modules/short_role_name/short-role-name.json @@ -2,8 +2,8 @@ "ProjectSettings": { "Name": "short-role-name", "Version": { - "Major": "0", - "Minor": "0", + "Major": "1", + "Minor": "2", "Micro": "0" }, "Author": "", @@ -16,10 +16,10 @@ "LicenseName": "", "LicenseDescription": "", "Dependencies": [ - "cpl-core>=2023.4.0.post5" + "cpl-core>=1.2.0" ], "DevDependencies": [ - "cpl-cli>=2023.4.0.post3" + "cpl-cli>=1.2.0" ], "PythonVersion": ">=3.10.4", "PythonPath": { diff --git a/kdb-bot/src/modules/short_role_name/short_role_name_check_command.py b/bot/src/modules/short_role_name/short_role_name_check_command.py similarity index 100% rename from kdb-bot/src/modules/short_role_name/short_role_name_check_command.py rename to bot/src/modules/short_role_name/short_role_name_check_command.py diff --git a/kdb-bot/src/modules/short_role_name/short_role_name_module.py b/bot/src/modules/short_role_name/short_role_name_module.py similarity index 81% rename from kdb-bot/src/modules/short_role_name/short_role_name_module.py rename to bot/src/modules/short_role_name/short_role_name_module.py index 3a413eb1..19b732fe 100644 --- a/kdb-bot/src/modules/short_role_name/short_role_name_module.py +++ b/bot/src/modules/short_role_name/short_role_name_module.py @@ -7,9 +7,13 @@ 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.data_seeder_abc import DataSeederABC -from modules.short_role_name.events.short_role_name_on_member_update_event import ShortRoleNameOnMemberUpdateEvent +from modules.short_role_name.events.short_role_name_on_member_update_event import ( + ShortRoleNameOnMemberUpdateEvent, +) from modules.short_role_name.service.short_role_name_service import ShortRoleNameService -from modules.short_role_name.short_role_name_check_command import ShortRoleNameCheckCommand +from modules.short_role_name.short_role_name_check_command import ( + ShortRoleNameCheckCommand, +) from modules.short_role_name.short_role_name_seeder import ShortRoleNameSeeder @@ -25,6 +29,9 @@ class ShortRoleNameModule(ModuleABC): services.add_transient(ShortRoleNameService) # commands - self._dc.add_command(ShortRoleNameCheckCommand) + services.add_transient(ShortRoleNameCheckCommand) # events - self._dc.add_event(DiscordEventTypesEnum.on_member_update.value, ShortRoleNameOnMemberUpdateEvent) + services.add_transient( + DiscordEventTypesEnum.on_member_update.value, + ShortRoleNameOnMemberUpdateEvent, + ) diff --git a/kdb-bot/src/modules/short_role_name/short_role_name_seeder.py b/bot/src/modules/short_role_name/short_role_name_seeder.py similarity index 100% rename from kdb-bot/src/modules/short_role_name/short_role_name_seeder.py rename to bot/src/modules/short_role_name/short_role_name_seeder.py diff --git a/bot/src/modules/special_offers/__init__.py b/bot/src/modules/special_offers/__init__.py new file mode 100644 index 00000000..2470352b --- /dev/null +++ b/bot/src/modules/special_offers/__init__.py @@ -0,0 +1,26 @@ +# -*- coding: utf-8 -*- + +""" +bot sh-edraft.de Discord bot +~~~~~~~~~~~~~~~~~~~ + +Discord bot for customers of sh-edraft.de + +:copyright: (c) 2022 - 2023 sh-edraft.de +:license: MIT, see LICENSE for more details. + +""" + +__title__ = "modules.special_offers" +__author__ = "Sven Heidemann" +__license__ = "MIT" +__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de" +__version__ = "1.2.0" + +from collections import namedtuple + + +# imports + +VersionInfo = namedtuple("VersionInfo", "major minor micro") +version_info = VersionInfo(major="1", minor="2", micro="0") diff --git a/bot/src/modules/special_offers/special-offers.json b/bot/src/modules/special_offers/special-offers.json new file mode 100644 index 00000000..9d35ce51 --- /dev/null +++ b/bot/src/modules/special_offers/special-offers.json @@ -0,0 +1,46 @@ +{ + "ProjectSettings": { + "Name": "steam-special-offers", + "Version": { + "Major": "1", + "Minor": "2", + "Micro": "0" + }, + "Author": "", + "AuthorEmail": "", + "Description": "", + "LongDescription": "", + "URL": "", + "CopyrightDate": "", + "CopyrightName": "", + "LicenseName": "", + "LicenseDescription": "", + "Dependencies": [ + "cpl-core>=1.2.0" + ], + "DevDependencies": [ + "cpl-cli>=1.2.0" + ], + "PythonVersion": ">=3.10.4", + "PythonPath": { + "linux": "" + }, + "Classifiers": [] + }, + "BuildSettings": { + "ProjectType": "library", + "SourcePath": "", + "OutputPath": "../../dist", + "Main": "steam_special_offers.main", + "EntryPoint": "steam-special-offers", + "IncludePackageData": false, + "Included": [], + "Excluded": [ + "*/__pycache__", + "*/logs", + "*/tests" + ], + "PackageData": {}, + "ProjectReferences": [] + } +} \ No newline at end of file diff --git a/bot/src/modules/special_offers/special_offers_module.py b/bot/src/modules/special_offers/special_offers_module.py new file mode 100644 index 00000000..e64108b5 --- /dev/null +++ b/bot/src/modules/special_offers/special_offers_module.py @@ -0,0 +1,22 @@ +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.abc.task_abc import TaskABC +from bot_core.configuration.feature_flags_enum import FeatureFlagsEnum +from modules.special_offers.steam_offer_watcher import SteamOfferWatcher + + +class SteamSpecialOffersModule(ModuleABC): + def __init__(self, dc: DiscordCollectionABC): + ModuleABC.__init__(self, dc, FeatureFlagsEnum.steam_special_offers_module) + + def configure_configuration(self, config: ConfigurationABC, env: ApplicationEnvironmentABC): + pass + + def configure_services(self, services: ServiceCollectionABC, env: ApplicationEnvironmentABC): + services.add_singleton(TaskABC, SteamOfferWatcher) + # commands + # events diff --git a/bot/src/modules/special_offers/steam_offer_watcher.py b/bot/src/modules/special_offers/steam_offer_watcher.py new file mode 100644 index 00000000..d2cd2317 --- /dev/null +++ b/bot/src/modules/special_offers/steam_offer_watcher.py @@ -0,0 +1,214 @@ +import asyncio +import datetime + +import bs4 +import discord +import requests +from cpl_core.configuration import ConfigurationABC +from cpl_core.database.context import DatabaseContextABC +from cpl_discord.service import DiscordBotServiceABC +from cpl_query.extension import List +from cpl_translation import TranslatePipe +from discord.ext import tasks + +from bot_core.abc.task_abc import TaskABC +from bot_core.configuration.feature_flags_enum import FeatureFlagsEnum +from bot_core.configuration.feature_flags_settings import FeatureFlagsSettings +from bot_core.logging.task_logger import TaskLogger +from bot_core.service.message_service import MessageService +from bot_data.abc.steam_special_offer_repository_abc import ( + SteamSpecialOfferRepositoryABC, +) +from bot_data.model.server_config import ServerConfig +from bot_data.model.steam_special_offer import SteamSpecialOffer + + +class SteamOfferWatcher(TaskABC): + def __init__( + self, + config: ConfigurationABC, + bot: DiscordBotServiceABC, + logger: TaskLogger, + db: DatabaseContextABC, + offers: SteamSpecialOfferRepositoryABC, + message_service: MessageService, + t: TranslatePipe, + ): + TaskABC.__init__(self) + + self._config = config + self._logger = logger + self._db = db + self._offers = offers + self._bot = bot + self._message_service = message_service + self._t = t + + self._is_new = False + self._urls = {} + self._image_urls = {} + + self.watch.start() + + @staticmethod + def _get_max_count() -> int: + count = 0 + result = requests.get(f"https://store.steampowered.com/search/results?specials=1") + soup = bs4.BeautifulSoup(result.text, "lxml") + element = soup.find_all("div", {"class": "search_results_count"}) + if len(element) < 1: + return count + + count = int(element[0].contents[0].split(" ")[0].replace(",", "")) + + return count + + def _get_games_from_page(self, start: int, count: int) -> List[SteamSpecialOffer]: + games = List(SteamSpecialOffer) + result = requests.get( + f"https://store.steampowered.com/search/results?query&start={start}&count={count}&force_infinite=1&specials=1" + ) + soup = bs4.BeautifulSoup(result.text, "lxml") + elements = soup.find_all("a", {"class": "search_result_row"}) + if len(elements) < 1: + return games + + for element in elements: + name_element = element.find("span", {"class": "title"}) + original_price_element = element.find("div", {"class": "discount_original_price"}) + discount_element = element.find("div", {"class": "discount_pct"}) + discount_price_element = element.find("div", {"class": "discount_final_price"}) + + if ( + name_element is None + or len(name_element.contents) < 1 + or original_price_element is None + or len(original_price_element.contents) < 1 + or discount_element is None + or len(discount_element.contents) < 1 + or discount_price_element is None + or len(discount_price_element.contents) < 1 + ): + continue + + name = name_element.contents[0].replace("'", "`").replace('"', "`") + original_price = float( + original_price_element.contents[0].replace(" ", "").replace("€", "").replace(",", ".") + ) + discount = int(discount_element.contents[0].replace("%", "")) + discount_price = float( + discount_price_element.contents[0].replace(" ", "").replace("€", "").replace(",", ".") + ) + games.add(SteamSpecialOffer(name, original_price, discount_price, discount)) + self._urls[name] = element.attrs["href"] + self._image_urls[name] = element.find("div", {"class": "search_capsule"}).find("img").attrs["src"] + + return games + + def _get_new_game_offers(self) -> List[SteamSpecialOffer]: + new_offers = List(SteamSpecialOffer) + + # sale_count = self._get_max_count() + 100 + sale_count = 500 # only look at first 500 + self._logger.debug(__name__, f"Get special offers from 0 to {sale_count}") + for i in range(0, sale_count, 100): + new_offers.extend(self._get_games_from_page(i, 100)) + + self._logger.debug(__name__, f"Got {new_offers.count()} offers") + + return new_offers + + async def _send_embed_for_offer(self, offer: SteamSpecialOffer, channel_id: int) -> discord.Embed: + embed = discord.Embed( + title=offer.name, + url=self._urls[offer.name], + color=int("ef9d0d", 16), + timestamp=datetime.datetime.now(), + ) + + embed.add_field( + name=self._t.transform("modules.special_offers.price"), + value=f"~~{offer.original_price}€~~", + inline=True, + ) + embed.add_field( + name=self._t.transform("modules.special_offers.discount"), + value=f"{offer.discount_pct}%", + inline=True, + ) + embed.add_field( + name=self._t.transform("modules.special_offers.discount_price"), + value=f"{offer.discount_price}€", + inline=True, + ) + + embed.set_image(url=self._image_urls[offer.name]) + + await self._message_service.send_channel_message( + self._bot.get_channel(channel_id), + embed, + is_persistent=True, + ) + + def _watch(self) -> List[SteamSpecialOffer]: + self._is_new = self._offers.get_steam_special_offers().count() == 0 + new_offers = self._get_new_game_offers() + new_offers_names = new_offers.select(lambda x: x.name).to_list() + + old_offers = self._offers.get_steam_special_offers() + old_offers_names = old_offers.select(lambda x: x.name).to_list() + + offers_for_notifications = List(SteamSpecialOffer) + + for offer in old_offers: + offer: SteamSpecialOffer = offer + if offer.name in new_offers_names: + continue + + self._offers.delete_steam_special_offer(offer) + self._db.save_changes() + + for offer in new_offers: + if offer.name in old_offers_names: + self._offers.update_steam_special_offer(offer) + self._db.save_changes() + continue + + self._offers.add_steam_special_offer(offer) + self._db.save_changes() + offers_for_notifications.add(offer) + + self._logger.trace(__name__, "Finished watching") + return offers_for_notifications + + @tasks.loop(time=datetime.time(hour=16, minute=30)) + async def watch(self): + self._logger.info(__name__, "Watching steam special offers") + try: + offers_for_notifications = self._watch() + self._logger.debug( + __name__, + f"Sending offer notifications for {offers_for_notifications.count()} offers", + ) + if self._is_new: + return + for guild in self._bot.guilds: + settings: ServerConfig = self._config.get_configuration(f"ServerConfig_{guild.id}") + if ( + not FeatureFlagsSettings.get_flag_from_dict( + settings.feature_flags, FeatureFlagsEnum.steam_special_offers + ) + or settings.game_offer_notification_chat_id is None + ): + continue + + for offer in offers_for_notifications: + self._bot.loop.create_task( + self._send_embed_for_offer(offer, settings.game_offer_notification_chat_id) + ) + except Exception as e: + self._logger.error(__name__, f"Steam offer watcher failed", e) + + @watch.before_loop + async def wait(self): + await self._wait_until_ready() diff --git a/kdb-bot/src/modules/technician/__init__.py b/bot/src/modules/technician/__init__.py similarity index 84% rename from kdb-bot/src/modules/technician/__init__.py rename to bot/src/modules/technician/__init__.py index 09303612..7e184291 100644 --- a/kdb-bot/src/modules/technician/__init__.py +++ b/bot/src/modules/technician/__init__.py @@ -15,7 +15,7 @@ __title__ = "modules.technician" __author__ = "Sven Heidemann" __license__ = "MIT" __copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de" -__version__ = "1.1.10" +__version__ = "1.2.0" from collections import namedtuple @@ -23,4 +23,4 @@ from collections import namedtuple # imports: VersionInfo = namedtuple("VersionInfo", "major minor micro") -version_info = VersionInfo(major="1", minor="1", micro="10") +version_info = VersionInfo(major="1", minor="2", micro="0") diff --git a/kdb-bot/src/modules/technician/api_key_seeder.py b/bot/src/modules/technician/api_key_seeder.py similarity index 100% rename from kdb-bot/src/modules/technician/api_key_seeder.py rename to bot/src/modules/technician/api_key_seeder.py diff --git a/kdb-bot/src/modules/technician/command/__init__.py b/bot/src/modules/technician/command/__init__.py similarity index 84% rename from kdb-bot/src/modules/technician/command/__init__.py rename to bot/src/modules/technician/command/__init__.py index 7317fca2..ef7939c0 100644 --- a/kdb-bot/src/modules/technician/command/__init__.py +++ b/bot/src/modules/technician/command/__init__.py @@ -15,7 +15,7 @@ __title__ = "modules.technician.command" __author__ = "Sven Heidemann" __license__ = "MIT" __copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de" -__version__ = "1.1.10" +__version__ = "1.2.0" from collections import namedtuple @@ -23,4 +23,4 @@ from collections import namedtuple # imports: VersionInfo = namedtuple("VersionInfo", "major minor micro") -version_info = VersionInfo(major="1", minor="1", micro="10") +version_info = VersionInfo(major="1", minor="2", micro="0") diff --git a/kdb-bot/src/modules/technician/command/api_key_group.py b/bot/src/modules/technician/command/api_key_group.py similarity index 100% rename from kdb-bot/src/modules/technician/command/api_key_group.py rename to bot/src/modules/technician/command/api_key_group.py diff --git a/kdb-bot/src/modules/technician/command/log_command.py b/bot/src/modules/technician/command/log_command.py similarity index 100% rename from kdb-bot/src/modules/technician/command/log_command.py rename to bot/src/modules/technician/command/log_command.py diff --git a/kdb-bot/src/modules/technician/command/restart_command.py b/bot/src/modules/technician/command/restart_command.py similarity index 100% rename from kdb-bot/src/modules/technician/command/restart_command.py rename to bot/src/modules/technician/command/restart_command.py diff --git a/kdb-bot/src/modules/technician/command/shutdown_command.py b/bot/src/modules/technician/command/shutdown_command.py similarity index 100% rename from kdb-bot/src/modules/technician/command/shutdown_command.py rename to bot/src/modules/technician/command/shutdown_command.py diff --git a/kdb-bot/src/modules/technician/command/sync_xp_command.py b/bot/src/modules/technician/command/sync_xp_command.py similarity index 100% rename from kdb-bot/src/modules/technician/command/sync_xp_command.py rename to bot/src/modules/technician/command/sync_xp_command.py diff --git a/kdb-bot/src/modules/technician/technician.json b/bot/src/modules/technician/technician.json similarity index 95% rename from kdb-bot/src/modules/technician/technician.json rename to bot/src/modules/technician/technician.json index 7ae46664..24080baa 100644 --- a/kdb-bot/src/modules/technician/technician.json +++ b/bot/src/modules/technician/technician.json @@ -3,8 +3,8 @@ "Name": "technician", "Version": { "Major": "1", - "Minor": "1", - "Micro": "10" + "Minor": "2", + "Micro": "0" }, "Author": "", "AuthorEmail": "", diff --git a/kdb-bot/src/modules/technician/technician_module.py b/bot/src/modules/technician/technician_module.py similarity index 84% rename from kdb-bot/src/modules/technician/technician_module.py rename to bot/src/modules/technician/technician_module.py index 5d5472ba..8550b7d6 100644 --- a/kdb-bot/src/modules/technician/technician_module.py +++ b/bot/src/modules/technician/technician_module.py @@ -24,9 +24,9 @@ class TechnicianModule(ModuleABC): def configure_services(self, services: ServiceCollectionABC, env: ApplicationEnvironmentABC): services.add_transient(DataSeederABC, ApiKeySeeder) # commands - self._dc.add_command(RestartCommand) - self._dc.add_command(ShutdownCommand) - self._dc.add_command(LogCommand) - self._dc.add_command(ApiKeyGroup) - self._dc.add_command(SyncXpGroup) + services.add_transient(RestartCommand) + services.add_transient(ShutdownCommand) + services.add_transient(LogCommand) + services.add_transient(ApiKeyGroup) + services.add_transient(SyncXpGroup) # events diff --git a/kdb-bot/tools/checks/UserJoinedVoiceChannel.json b/bot/tools/checks/UserJoinedVoiceChannel.json similarity index 100% rename from kdb-bot/tools/checks/UserJoinedVoiceChannel.json rename to bot/tools/checks/UserJoinedVoiceChannel.json diff --git a/kdb-bot/tools/checks/__init__.py b/bot/tools/checks/__init__.py similarity index 100% rename from kdb-bot/tools/checks/__init__.py rename to bot/tools/checks/__init__.py diff --git a/kdb-bot/tools/checks/checks.json b/bot/tools/checks/checks.json similarity index 96% rename from kdb-bot/tools/checks/checks.json rename to bot/tools/checks/checks.json index 295f0a4b..c95779e7 100644 --- a/kdb-bot/tools/checks/checks.json +++ b/bot/tools/checks/checks.json @@ -3,8 +3,8 @@ "Name": "checks", "Version": { "Major": "1", - "Minor": "1", - "Micro": "10" + "Minor": "2", + "Micro": "0" }, "Author": "Sven Heidemann", "AuthorEmail": "sven.heidemann@sh-edraft.de", diff --git a/kdb-bot/tools/checks/get_ontime_overlaps.py b/bot/tools/checks/get_ontime_overlaps.py similarity index 100% rename from kdb-bot/tools/checks/get_ontime_overlaps.py rename to bot/tools/checks/get_ontime_overlaps.py diff --git a/kdb-bot/tools/get_version/__init__.py b/bot/tools/get_version/__init__.py similarity index 100% rename from kdb-bot/tools/get_version/__init__.py rename to bot/tools/get_version/__init__.py diff --git a/kdb-bot/tools/get_version/application.py b/bot/tools/get_version/application.py similarity index 100% rename from kdb-bot/tools/get_version/application.py rename to bot/tools/get_version/application.py diff --git a/kdb-bot/tools/get_version/get-version.json b/bot/tools/get_version/get-version.json similarity index 96% rename from kdb-bot/tools/get_version/get-version.json rename to bot/tools/get_version/get-version.json index 0c0aacb6..bf6aa56f 100644 --- a/kdb-bot/tools/get_version/get-version.json +++ b/bot/tools/get_version/get-version.json @@ -3,8 +3,8 @@ "Name": "get-version", "Version": { "Major": "1", - "Minor": "1", - "Micro": "10" + "Minor": "2", + "Micro": "0" }, "Author": "Sven Heidemann", "AuthorEmail": "sven.heidemann@sh-edraft.de", diff --git a/kdb-bot/tools/get_version/main.py b/bot/tools/get_version/main.py similarity index 100% rename from kdb-bot/tools/get_version/main.py rename to bot/tools/get_version/main.py diff --git a/kdb-bot/tools/get_version/startup.py b/bot/tools/get_version/startup.py similarity index 100% rename from kdb-bot/tools/get_version/startup.py rename to bot/tools/get_version/startup.py diff --git a/kdb-bot/tools/post_build/__init__.py b/bot/tools/post_build/__init__.py similarity index 100% rename from kdb-bot/tools/post_build/__init__.py rename to bot/tools/post_build/__init__.py diff --git a/kdb-bot/tools/post_build/application.py b/bot/tools/post_build/application.py similarity index 100% rename from kdb-bot/tools/post_build/application.py rename to bot/tools/post_build/application.py diff --git a/kdb-bot/tools/post_build/appsettings.json b/bot/tools/post_build/appsettings.json similarity index 100% rename from kdb-bot/tools/post_build/appsettings.json rename to bot/tools/post_build/appsettings.json diff --git a/kdb-bot/tools/post_build/main.py b/bot/tools/post_build/main.py similarity index 100% rename from kdb-bot/tools/post_build/main.py rename to bot/tools/post_build/main.py diff --git a/kdb-bot/tools/post_build/post-build.json b/bot/tools/post_build/post-build.json similarity index 96% rename from kdb-bot/tools/post_build/post-build.json rename to bot/tools/post_build/post-build.json index f499bc71..97cd72d1 100644 --- a/kdb-bot/tools/post_build/post-build.json +++ b/bot/tools/post_build/post-build.json @@ -3,8 +3,8 @@ "Name": "post-build", "Version": { "Major": "1", - "Minor": "1", - "Micro": "10" + "Minor": "2", + "Micro": "0" }, "Author": "Sven Heidemann", "AuthorEmail": "sven.heidemann@sh-edraft.de", diff --git a/kdb-bot/tools/post_build/post_build_settings.py b/bot/tools/post_build/post_build_settings.py similarity index 100% rename from kdb-bot/tools/post_build/post_build_settings.py rename to bot/tools/post_build/post_build_settings.py diff --git a/kdb-bot/tools/post_build/service/__init__.py b/bot/tools/post_build/service/__init__.py similarity index 100% rename from kdb-bot/tools/post_build/service/__init__.py rename to bot/tools/post_build/service/__init__.py diff --git a/kdb-bot/tools/post_build/service/dependencies.py b/bot/tools/post_build/service/dependencies.py similarity index 100% rename from kdb-bot/tools/post_build/service/dependencies.py rename to bot/tools/post_build/service/dependencies.py diff --git a/kdb-bot/tools/post_build/service/remove_config.py b/bot/tools/post_build/service/remove_config.py similarity index 100% rename from kdb-bot/tools/post_build/service/remove_config.py rename to bot/tools/post_build/service/remove_config.py diff --git a/kdb-bot/tools/post_build/startup.py b/bot/tools/post_build/startup.py similarity index 100% rename from kdb-bot/tools/post_build/startup.py rename to bot/tools/post_build/startup.py diff --git a/kdb-bot/tools/set_version/__init__.py b/bot/tools/set_version/__init__.py similarity index 100% rename from kdb-bot/tools/set_version/__init__.py rename to bot/tools/set_version/__init__.py diff --git a/kdb-bot/tools/set_version/application.py b/bot/tools/set_version/application.py similarity index 92% rename from kdb-bot/tools/set_version/application.py rename to bot/tools/set_version/application.py index 92055455..882d819a 100644 --- a/kdb-bot/tools/set_version/application.py +++ b/bot/tools/set_version/application.py @@ -57,7 +57,9 @@ class Application(ApplicationABC): try: if branch.startswith("#"): self._configuration.add_json_file( - self._workspace.projects[self._workspace.default_project], optional=False, output=False + self._workspace.projects[self._workspace.default_project], + optional=False, + output=False, ) ps: ProjectSettings = self._configuration.get_configuration(ProjectSettings) @@ -111,10 +113,16 @@ class Application(ApplicationABC): Console.write_line(f"Set dependencies {self._version_pipe.transform(version)} for {project}") self._version_setter.set_dependencies( - self._workspace.projects[project], version, "Dependencies", skipped=skipped + self._workspace.projects[project], + version, + "Dependencies", + skipped=skipped, ) self._version_setter.set_dependencies( - self._workspace.projects[project], version, "DevDependencies", skipped=skipped + self._workspace.projects[project], + version, + "DevDependencies", + skipped=skipped, ) Console.write_line(f"Set version {self._version_pipe.transform(version)} for {project}") diff --git a/kdb-bot/tools/set_version/git_service.py b/bot/tools/set_version/git_service.py similarity index 100% rename from kdb-bot/tools/set_version/git_service.py rename to bot/tools/set_version/git_service.py diff --git a/kdb-bot/tools/set_version/main.py b/bot/tools/set_version/main.py similarity index 100% rename from kdb-bot/tools/set_version/main.py rename to bot/tools/set_version/main.py diff --git a/kdb-bot/tools/set_version/set-version.json b/bot/tools/set_version/set-version.json similarity index 96% rename from kdb-bot/tools/set_version/set-version.json rename to bot/tools/set_version/set-version.json index 6ea92728..0c2e47ff 100644 --- a/kdb-bot/tools/set_version/set-version.json +++ b/bot/tools/set_version/set-version.json @@ -3,8 +3,8 @@ "Name": "set-version", "Version": { "Major": "1", - "Minor": "1", - "Micro": "10" + "Minor": "2", + "Micro": "0" }, "Author": "Sven Heidemann", "AuthorEmail": "sven.heidemann@sh-edraft.de", diff --git a/kdb-bot/tools/set_version/startup.py b/bot/tools/set_version/startup.py similarity index 100% rename from kdb-bot/tools/set_version/startup.py rename to bot/tools/set_version/startup.py diff --git a/kdb-bot/tools/set_version/version_setter_service.py b/bot/tools/set_version/version_setter_service.py similarity index 92% rename from kdb-bot/tools/set_version/version_setter_service.py rename to bot/tools/set_version/version_setter_service.py index e1dfcf8a..af019658 100644 --- a/kdb-bot/tools/set_version/version_setter_service.py +++ b/bot/tools/set_version/version_setter_service.py @@ -55,7 +55,10 @@ class VersionSetterService: continue new_deps.append( - dependency.replace(dep_version, f'{version["Major"]}.{version["Minor"]}.{version["Micro"]}') + dependency.replace( + dep_version, + f'{version["Major"]}.{version["Minor"]}.{version["Micro"]}', + ) ) project_json["ProjectSettings"][key] = new_deps diff --git a/kdb-bot/docker b/kdb-bot/docker deleted file mode 160000 index 7ae47838..00000000 --- a/kdb-bot/docker +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 7ae4783874d5aa8015d8f0da2c19c293fcd72762 diff --git a/kdb-bot/src/bot/config b/kdb-bot/src/bot/config deleted file mode 160000 index 23eafb2e..00000000 --- a/kdb-bot/src/bot/config +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 23eafb2e211241acbbc52833d139c67f1ecc69f5 diff --git a/kdb-bot/src/bot_api/config b/kdb-bot/src/bot_api/config deleted file mode 160000 index b6ffed4d..00000000 --- a/kdb-bot/src/bot_api/config +++ /dev/null @@ -1 +0,0 @@ -Subproject commit b6ffed4da1f75f5fbad1ce7f312b67f32de010b5 diff --git a/kdb-bot/src/bot_data/migration/db_history_scripts/users.sql b/kdb-bot/src/bot_data/migration/db_history_scripts/users.sql deleted file mode 100644 index 8dfebf63..00000000 --- a/kdb-bot/src/bot_data/migration/db_history_scripts/users.sql +++ /dev/null @@ -1,46 +0,0 @@ -ALTER TABLE `Users` - CHANGE `CreatedAt` `CreatedAt` DATETIME(6) NULL DEFAULT CURRENT_TIMESTAMP(6); - -ALTER TABLE `Users` - CHANGE `LastModifiedAt` `LastModifiedAt` DATETIME(6) NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6); - -CREATE TABLE IF NOT EXISTS `UsersHistory` -( - `Id` BIGINT(20) NOT NULL, - `DiscordId` BIGINT(20) NOT NULL, - `XP` BIGINT(20) NOT NULL DEFAULT 0, - `ServerId` BIGINT(20) DEFAULT NULL, - `Deleted` BOOL DEFAULT FALSE, - `DateFrom` DATETIME(6) NOT NULL, - `DateTo` DATETIME(6) NOT NULL -); - -DROP TRIGGER IF EXISTS `TR_UsersUpdate`; - -CREATE TRIGGER `TR_UsersUpdate` - AFTER UPDATE - ON `Users` - FOR EACH ROW -BEGIN - INSERT INTO `UsersHistory` ( - `Id`, `DiscordId`, `XP`, `ServerId`, `DateFrom`, `DateTo` - ) - VALUES ( - OLD.UserId, OLD.DiscordId, OLD.XP, OLD.ServerId, OLD.LastModifiedAt, CURRENT_TIMESTAMP(6) - ); -END; - -DROP TRIGGER IF EXISTS `TR_UsersDelete`; - -CREATE TRIGGER `TR_UsersDelete` - AFTER DELETE - ON `Users` - FOR EACH ROW -BEGIN - INSERT INTO `UsersHistory` ( - `Id`, `DiscordId`, `XP`, `ServerId`, `Deleted`, `DateFrom`, `DateTo` - ) - VALUES ( - OLD.UserId, OLD.DiscordId, OLD.XP, OLD.ServerId, TRUE, OLD.LastModifiedAt, CURRENT_TIMESTAMP(6) - ); -END; \ No newline at end of file diff --git a/kdb-bot/src/bot_graphql/mutations/user_mutation.py b/kdb-bot/src/bot_graphql/mutations/user_mutation.py deleted file mode 100644 index 9cd71438..00000000 --- a/kdb-bot/src/bot_graphql/mutations/user_mutation.py +++ /dev/null @@ -1,53 +0,0 @@ -from cpl_core.database.context import DatabaseContextABC -from cpl_discord.service import DiscordBotServiceABC - -from bot_data.abc.level_repository_abc import LevelRepositoryABC -from bot_data.abc.server_repository_abc import ServerRepositoryABC -from bot_data.abc.user_repository_abc import UserRepositoryABC -from bot_data.model.user_role_enum import UserRoleEnum -from bot_graphql.abc.query_abc import QueryABC -from modules.level.service.level_service import LevelService -from modules.permission.service.permission_service import PermissionService - - -class UserMutation(QueryABC): - def __init__( - self, - servers: ServerRepositoryABC, - users: UserRepositoryABC, - bot: DiscordBotServiceABC, - db: DatabaseContextABC, - permissions: PermissionService, - levels: LevelRepositoryABC, - level_service: LevelService, - ): - QueryABC.__init__(self, "UserMutation") - - self._servers = servers - self._users = users - self._bot = bot - self._db = db - self._permissions = permissions - self._levels = levels - self._level_service = level_service - - self.set_field("updateUser", self.resolve_update_user) - - def resolve_update_user(self, *_, input: dict): - user = self._users.get_user_by_id(input["id"]) - self._can_user_mutate_data(user.server, UserRoleEnum.moderator) - - new_xp = None - if "levelId" in input: - level = self._levels.get_level_by_id(input["levelId"]) - if user.level.id != level.id: - new_xp = level.min_xp - - user.xp = new_xp if new_xp is not None else input["xp"] if "xp" in input else user.xp - - self._users.update_user(user) - self._db.save_changes() - self._bot.loop.create_task(self._level_service.set_level(user)) - - user = self._users.get_user_by_id(input["id"]) - return user diff --git a/kdb-web/src/app/modules/view/server/profile/profile.component.html b/kdb-web/src/app/modules/view/server/profile/profile.component.html deleted file mode 100644 index 28de57cb..00000000 --- a/kdb-web/src/app/modules/view/server/profile/profile.component.html +++ /dev/null @@ -1,165 +0,0 @@ -

- {{'view.server.profile.header' | translate}} -

-
-
-

- {{user.name}} -

-
- -
-
-
-
{{'common.id' | translate}}:
-
{{user.id}}
-
-
-
{{'common.discord_id' | translate}}:
-
{{user.discordId}}
-
-
- -
-
-
{{'view.server.profile.name' | translate}}:
-
{{user.name}}
-
-
- -
-
-
{{'view.server.profile.xp' | translate}}:
-
{{user.xp}}
-
-
- -
-
-
{{'view.server.profile.ontime' | translate}}:
-
{{user.ontime}}
-
-
- - - - - - - - -
-
-
{{'view.server.profile.level' | translate}}:
-
{{user.level?.name}}
-
-
- -
-
-
{{'view.server.profile.left_server' | translate}}:
-
{{user.leftServer | bool}}
-
-
- -
-
-
{{'common.created_at' | translate}}:
-
{{user.createdAt | date:'dd.MM.yyyy HH:mm:ss'}}
-
-
- -
-
-
{{'common.modified_at' | translate}}:
-
{{user.modifiedAt | date:'dd.MM.yyyy HH:mm:ss'}}
-
-
- -
- - -
-
-
-
{{'common.name' | translate}}:
-
{{achievement.name}}
-
- -
-
{{'view.server.profile.achievements.time' | translate}}:
-
{{achievement.createdAt | date:'dd.MM.yyyy HH:mm:ss'}}
-
-
-
-
- - -
-
-
-
{{'view.server.profile.joined_voice_channel.time' | translate}}:
-
{{join.time}} {{'general.hours' | translate}}
-
- -
-
{{'view.server.profile.joined_voice_channel.channel' | translate}}:
-
{{join.channelName}}
-
- -
-
{{'common.joined_at' | translate}}:
-
{{join.joinedOn | date:'dd.MM.yyyy HH:mm:ss'}}
-
- -
-
{{'common.leaved_at' | translate}}:
-
{{join.leavedOn | date:'dd.MM.yyyy HH:mm:ss'}}
-
-
-
-
- - -
-
-
-
{{'view.server.profile.joined_game_server.time' | translate}}:
-
{{join.time}} {{'general.hours' | translate}}
-
- -
-
{{'view.server.profile.joined_game_server.name' | translate}}:
-
{{join.gameServer}}
-
- -
-
{{'common.joined_at' | translate}}:
-
{{join.joinedOn | date:'dd.MM.yyyy HH:mm:ss'}}
-
- -
-
{{'common.leaved_at' | translate}}:
-
{{join.leavedOn | date:'dd.MM.yyyy HH:mm:ss'}}
-
-
-
-
- - -
-
-
-
{{'common.joined_at' | translate}}:
-
{{join.joinedOn | date:'dd.MM.yyyy HH:mm:ss'}}
-
- -
-
{{'common.leaved_at' | translate}}:
-
{{join.leavedOn | date:'dd.MM.yyyy HH:mm:ss'}}
-
-
-
-
-
-
diff --git a/kdb-web/src/app/modules/view/server/profile/profile.component.ts b/kdb-web/src/app/modules/view/server/profile/profile.component.ts deleted file mode 100644 index 4df9cda5..00000000 --- a/kdb-web/src/app/modules/view/server/profile/profile.component.ts +++ /dev/null @@ -1,80 +0,0 @@ -import { Component, OnDestroy, OnInit } from "@angular/core"; -import { ActivatedRoute, Router } from "@angular/router"; -import { Queries } from "../../../../models/graphql/queries.model"; -import { UserListQuery } from "../../../../models/graphql/query.model"; -import { SpinnerService } from "../../../../services/spinner/spinner.service"; -import { DataService } from "../../../../services/data/data.service"; -import { User } from "../../../../models/data/user.model"; -import { UserDTO } from "../../../../models/auth/auth-user.dto"; -import { AuthService } from "src/app/services/auth/auth.service"; -import { ToastService } from "src/app/services/toast/toast.service"; -import { TranslateService } from "@ngx-translate/core"; -import { Server } from "../../../../models/data/server.model"; -import { Subject } from "rxjs"; -import { takeUntil } from "rxjs/operators"; - -@Component({ - selector: "app-profile", - templateUrl: "./profile.component.html", - styleUrls: ["./profile.component.scss"] -}) -export class ProfileComponent implements OnInit, OnDestroy { - - user: User = { createdAt: "", modifiedAt: "" }; - private server: Server = {}; - - private unsubscriber = new Subject(); - - constructor( - private route: ActivatedRoute, - private router: Router, - private spinner: SpinnerService, - private data: DataService, - private auth: AuthService, - private toast: ToastService, - private translate: TranslateService - ) { - } - - public ngOnInit(): void { - this.route.params.pipe(takeUntil(this.unsubscriber)).subscribe(params => { - this.data.getServerFromRoute(this.route).then(async (server) => { - if (!params["memberId"] || params["memberId"] == "undefined") { - await this.router.navigate([`/server/${server.id}`]); - return; - } - this.server = server; - - let authUser = await this.auth.getLoggedInUser(); - this.spinner.showSpinner(); - let user: UserDTO | null = authUser?.users?.find(u => u.server == server.id) ?? null; - if (!user || user?.id != params["memberId"] && !user?.isModerator) { - this.toast.error(this.translate.instant("view.server.profile.permission_denied"), this.translate.instant("view.server.profile.permission_denied_d")); - this.spinner.hideSpinner(); - await this.router.navigate(["/server", server.id]); - return; - } - - this.data.query(Queries.userProfile, { - serverId: this.server.id, - userId: params["memberId"] - }, - (x: { servers: Server[] }) => { - return x.servers[0]; - } - ).subscribe(users => { - if (!users.users[0]) { - this.router.navigate([`/server/${server.id}`]); - } - this.user = users.users[0]; - this.spinner.hideSpinner(); - }); - }); - }); - } - - public ngOnDestroy(): void { - this.unsubscriber.next(); - this.unsubscriber.complete(); - } -} diff --git a/kdb-web/src/app/modules/view/server/server.module.ts b/kdb-web/src/app/modules/view/server/server.module.ts deleted file mode 100644 index 6a04b47f..00000000 --- a/kdb-web/src/app/modules/view/server/server.module.ts +++ /dev/null @@ -1,25 +0,0 @@ -import { NgModule } from '@angular/core'; -import { CommonModule } from '@angular/common'; -import { ServerDashboardComponent } from './server-dashboard/server-dashboard.component'; -import { ServerRoutingModule } from './server-routing.module'; -import { SharedModule } from '../../shared/shared.module'; -import { ProfileComponent } from './profile/profile.component'; -import { MembersComponent } from './members/members.component'; -import { ClientComponent } from './server-dashboard/components/client/client.component'; - - - -@NgModule({ - declarations: [ - ServerDashboardComponent, - ProfileComponent, - MembersComponent, - ClientComponent, - ], - imports: [ - CommonModule, - ServerRoutingModule, - SharedModule - ] -}) -export class ServerModule { } diff --git a/kdb-web/src/assets/version.json b/kdb-web/src/assets/version.json deleted file mode 100644 index f7826e37..00000000 --- a/kdb-web/src/assets/version.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "WebVersion": { - "Major": "1", - "Minor": "1", - "Micro": "10" - } -} diff --git a/kdb-web/.browserslistrc b/web/.browserslistrc similarity index 100% rename from kdb-web/.browserslistrc rename to web/.browserslistrc diff --git a/kdb-web/.editorconfig b/web/.editorconfig similarity index 100% rename from kdb-web/.editorconfig rename to web/.editorconfig diff --git a/kdb-web/.gitignore b/web/.gitignore similarity index 100% rename from kdb-web/.gitignore rename to web/.gitignore diff --git a/kdb-web/.prettierrc b/web/.prettierrc similarity index 100% rename from kdb-web/.prettierrc rename to web/.prettierrc diff --git a/kdb-web/README.md b/web/README.md similarity index 100% rename from kdb-web/README.md rename to web/README.md diff --git a/kdb-web/angular.json b/web/angular.json similarity index 100% rename from kdb-web/angular.json rename to web/angular.json diff --git a/kdb-web/dockerfile b/web/dockerfile similarity index 86% rename from kdb-web/dockerfile rename to web/dockerfile index 106595b5..ff84e5af 100644 --- a/kdb-web/dockerfile +++ b/web/dockerfile @@ -1,7 +1,7 @@ FROM nginx:alpine COPY nginx.conf.template /etc/nginx/conf.d/nginx.conf.template RUN rm -rf /usr/share/nginx/html/* -COPY ./dist/kdb-web/ /usr/share/nginx/html +COPY ./dist/web/ /usr/share/nginx/html RUN apk update RUN apk add bash CMD /bin/bash -c "envsubst '\$BOT_CONTAINER_NAME' < /etc/nginx/conf.d/nginx.conf.template > /etc/nginx/nginx.conf; nginx -g 'daemon off;'" diff --git a/kdb-web/karma.conf.js b/web/karma.conf.js similarity index 100% rename from kdb-web/karma.conf.js rename to web/karma.conf.js diff --git a/kdb-web/nginx.conf.template b/web/nginx.conf.template similarity index 100% rename from kdb-web/nginx.conf.template rename to web/nginx.conf.template diff --git a/kdb-web/package-lock.json b/web/package-lock.json similarity index 99% rename from kdb-web/package-lock.json rename to web/package-lock.json index 9281a434..b19c0429 100644 --- a/kdb-web/package-lock.json +++ b/web/package-lock.json @@ -1,12 +1,12 @@ { - "name": "kdb-web", - "version": "1.0.dev127_config_in_wi", + "name": "web", + "version": "1.2.0", "lockfileVersion": 3, "requires": true, "packages": { "": { - "name": "kdb-web", - "version": "1.0.dev127_config_in_wi", + "name": "web", + "version": "1.2.0", "dependencies": { "@angular/animations": "^15.1.4", "@angular/common": "^15.1.4", @@ -21,7 +21,7 @@ "@ngx-translate/core": "^14.0.0", "@ngx-translate/http-loader": "^7.0.0", "@types/socket.io-client": "^3.0.0", - "primeflex": "^3.3.1", + "moment": "^2.29.4", "primeicons": "^6.0.1", "primeng": "^15.2.0", "rxjs": "~7.5.0", @@ -8157,6 +8157,14 @@ "mkdirp": "bin/cmd.js" } }, + "node_modules/moment": { + "version": "2.29.4", + "resolved": "https://registry.npmjs.org/moment/-/moment-2.29.4.tgz", + "integrity": "sha512-5LC9SOxjSc2HF6vO2CyuTDNivEdoz2IvyJJGj6X8DJ0eFyfszE0QiEd+iXmBvUP3WHxSjFH/vIsA0EN00cgr8w==", + "engines": { + "node": "*" + } + }, "node_modules/ms": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", @@ -9303,11 +9311,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/primeflex": { - "version": "3.3.1", - "resolved": "https://registry.npmjs.org/primeflex/-/primeflex-3.3.1.tgz", - "integrity": "sha512-zaOq3YvcOYytbAmKv3zYc+0VNS9Wg5d37dfxZnveKBFPr7vEIwfV5ydrpiouTft8MVW6qNjfkaQphHSnvgQbpQ==" - }, "node_modules/primeicons": { "version": "6.0.1", "resolved": "https://registry.npmjs.org/primeicons/-/primeicons-6.0.1.tgz", diff --git a/kdb-web/package.json b/web/package.json similarity index 96% rename from kdb-web/package.json rename to web/package.json index 1b99a94e..dce1efde 100644 --- a/kdb-web/package.json +++ b/web/package.json @@ -1,6 +1,6 @@ { - "name": "kdb-web", - "version": "1.1.10", + "name": "web", + "version": "1.2.0", "scripts": { "ng": "ng", "update-version": "ts-node update-version.ts", @@ -30,6 +30,7 @@ "@ngx-translate/core": "^14.0.0", "@ngx-translate/http-loader": "^7.0.0", "@types/socket.io-client": "^3.0.0", + "moment": "^2.29.4", "primeicons": "^6.0.1", "primeng": "^15.2.0", "rxjs": "~7.5.0", @@ -51,4 +52,4 @@ "tslib": "^2.4.1", "typescript": "~4.9.5" } -} +} \ No newline at end of file diff --git a/kdb-web/src/app/app-routing.module.ts b/web/src/app/app-routing.module.ts similarity index 100% rename from kdb-web/src/app/app-routing.module.ts rename to web/src/app/app-routing.module.ts diff --git a/kdb-web/src/app/app.component.html b/web/src/app/app.component.html similarity index 100% rename from kdb-web/src/app/app.component.html rename to web/src/app/app.component.html diff --git a/kdb-web/src/app/app.component.scss b/web/src/app/app.component.scss similarity index 100% rename from kdb-web/src/app/app.component.scss rename to web/src/app/app.component.scss diff --git a/kdb-web/src/app/app.component.spec.ts b/web/src/app/app.component.spec.ts similarity index 100% rename from kdb-web/src/app/app.component.spec.ts rename to web/src/app/app.component.spec.ts diff --git a/kdb-web/src/app/app.component.ts b/web/src/app/app.component.ts similarity index 100% rename from kdb-web/src/app/app.component.ts rename to web/src/app/app.component.ts diff --git a/kdb-web/src/app/app.module.ts b/web/src/app/app.module.ts similarity index 50% rename from kdb-web/src/app/app.module.ts rename to web/src/app/app.module.ts index 3e2b348b..e6d9877d 100644 --- a/kdb-web/src/app/app.module.ts +++ b/web/src/app/app.module.ts @@ -1,23 +1,22 @@ -import { HttpClient, HttpClientModule } from '@angular/common/http'; -import { APP_INITIALIZER, ErrorHandler, NgModule } from '@angular/core'; -import { BrowserModule } from '@angular/platform-browser'; -import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; -import { JwtModule } from '@auth0/angular-jwt'; -import { TranslateLoader, TranslateModule } from '@ngx-translate/core'; -import { TranslateHttpLoader } from '@ngx-translate/http-loader'; -import { ConfirmationService, MessageService } from 'primeng/api'; -import { DialogService } from 'primeng/dynamicdialog'; -import { AppRoutingModule } from './app-routing.module'; -import { AppComponent } from './app.component'; -import { NotFoundComponent } from './components/error/not-found/not-found.component'; -import { FooterComponent } from './components/footer/footer.component'; -import { HeaderComponent } from './components/header/header.component'; -import { SidebarComponent } from './components/sidebar/sidebar.component'; -import { SpinnerComponent } from './components/spinner/spinner.component'; -import { SharedModule } from './modules/shared/shared.module'; -import { ErrorHandlerService } from './services/error-handler/error-handler.service'; -import { SettingsService } from './services/settings/settings.service'; - +import { HttpClient, HttpClientModule } from "@angular/common/http"; +import { APP_INITIALIZER, ErrorHandler, NgModule } from "@angular/core"; +import { BrowserModule } from "@angular/platform-browser"; +import { BrowserAnimationsModule } from "@angular/platform-browser/animations"; +import { JwtModule } from "@auth0/angular-jwt"; +import { TranslateLoader, TranslateModule } from "@ngx-translate/core"; +import { TranslateHttpLoader } from "@ngx-translate/http-loader"; +import { ConfirmationService, MessageService } from "primeng/api"; +import { DialogService } from "primeng/dynamicdialog"; +import { AppRoutingModule } from "./app-routing.module"; +import { AppComponent } from "./app.component"; +import { NotFoundComponent } from "./components/error/not-found/not-found.component"; +import { FooterComponent } from "./components/footer/footer.component"; +import { HeaderComponent } from "./components/header/header.component"; +import { SidebarComponent } from "./components/sidebar/sidebar.component"; +import { SpinnerComponent } from "./components/spinner/spinner.component"; +import { SharedModule } from "./modules/shared/shared.module"; +import { ErrorHandlerService } from "./services/error-handler/error-handler.service"; +import { SettingsService } from "./services/settings/settings.service"; @NgModule({ @@ -63,7 +62,7 @@ import { SettingsService } from './services/settings/settings.service'; }, MessageService, ConfirmationService, - DialogService + DialogService, ], bootstrap: [AppComponent] }) diff --git a/kdb-web/src/app/base/component-with-table.spec.ts b/web/src/app/base/component-with-table.spec.ts similarity index 100% rename from kdb-web/src/app/base/component-with-table.spec.ts rename to web/src/app/base/component-with-table.spec.ts diff --git a/kdb-web/src/app/base/component-with-table.ts b/web/src/app/base/component-with-table.ts similarity index 100% rename from kdb-web/src/app/base/component-with-table.ts rename to web/src/app/base/component-with-table.ts diff --git a/kdb-web/src/app/components/error/not-found/not-found.component.html b/web/src/app/components/error/not-found/not-found.component.html similarity index 100% rename from kdb-web/src/app/components/error/not-found/not-found.component.html rename to web/src/app/components/error/not-found/not-found.component.html diff --git a/kdb-web/src/app/components/error/not-found/not-found.component.scss b/web/src/app/components/error/not-found/not-found.component.scss similarity index 100% rename from kdb-web/src/app/components/error/not-found/not-found.component.scss rename to web/src/app/components/error/not-found/not-found.component.scss diff --git a/kdb-web/src/app/components/error/not-found/not-found.component.spec.ts b/web/src/app/components/error/not-found/not-found.component.spec.ts similarity index 100% rename from kdb-web/src/app/components/error/not-found/not-found.component.spec.ts rename to web/src/app/components/error/not-found/not-found.component.spec.ts diff --git a/kdb-web/src/app/components/error/not-found/not-found.component.ts b/web/src/app/components/error/not-found/not-found.component.ts similarity index 100% rename from kdb-web/src/app/components/error/not-found/not-found.component.ts rename to web/src/app/components/error/not-found/not-found.component.ts diff --git a/kdb-web/src/app/components/footer/footer.component.html b/web/src/app/components/footer/footer.component.html similarity index 100% rename from kdb-web/src/app/components/footer/footer.component.html rename to web/src/app/components/footer/footer.component.html diff --git a/kdb-web/src/app/components/footer/footer.component.scss b/web/src/app/components/footer/footer.component.scss similarity index 100% rename from kdb-web/src/app/components/footer/footer.component.scss rename to web/src/app/components/footer/footer.component.scss diff --git a/kdb-web/src/app/components/footer/footer.component.spec.ts b/web/src/app/components/footer/footer.component.spec.ts similarity index 100% rename from kdb-web/src/app/components/footer/footer.component.spec.ts rename to web/src/app/components/footer/footer.component.spec.ts diff --git a/kdb-web/src/app/components/footer/footer.component.ts b/web/src/app/components/footer/footer.component.ts similarity index 100% rename from kdb-web/src/app/components/footer/footer.component.ts rename to web/src/app/components/footer/footer.component.ts diff --git a/kdb-web/src/app/components/header/header.component.html b/web/src/app/components/header/header.component.html similarity index 100% rename from kdb-web/src/app/components/header/header.component.html rename to web/src/app/components/header/header.component.html diff --git a/kdb-web/src/app/components/header/header.component.scss b/web/src/app/components/header/header.component.scss similarity index 100% rename from kdb-web/src/app/components/header/header.component.scss rename to web/src/app/components/header/header.component.scss diff --git a/kdb-web/src/app/components/header/header.component.spec.ts b/web/src/app/components/header/header.component.spec.ts similarity index 100% rename from kdb-web/src/app/components/header/header.component.spec.ts rename to web/src/app/components/header/header.component.spec.ts diff --git a/kdb-web/src/app/components/header/header.component.ts b/web/src/app/components/header/header.component.ts similarity index 100% rename from kdb-web/src/app/components/header/header.component.ts rename to web/src/app/components/header/header.component.ts diff --git a/kdb-web/src/app/components/sidebar/sidebar.component.html b/web/src/app/components/sidebar/sidebar.component.html similarity index 100% rename from kdb-web/src/app/components/sidebar/sidebar.component.html rename to web/src/app/components/sidebar/sidebar.component.html diff --git a/kdb-web/src/app/components/sidebar/sidebar.component.scss b/web/src/app/components/sidebar/sidebar.component.scss similarity index 100% rename from kdb-web/src/app/components/sidebar/sidebar.component.scss rename to web/src/app/components/sidebar/sidebar.component.scss diff --git a/kdb-web/src/app/components/sidebar/sidebar.component.spec.ts b/web/src/app/components/sidebar/sidebar.component.spec.ts similarity index 100% rename from kdb-web/src/app/components/sidebar/sidebar.component.spec.ts rename to web/src/app/components/sidebar/sidebar.component.spec.ts diff --git a/kdb-web/src/app/components/sidebar/sidebar.component.ts b/web/src/app/components/sidebar/sidebar.component.ts similarity index 100% rename from kdb-web/src/app/components/sidebar/sidebar.component.ts rename to web/src/app/components/sidebar/sidebar.component.ts diff --git a/kdb-web/src/app/components/spinner/spinner.component.html b/web/src/app/components/spinner/spinner.component.html similarity index 100% rename from kdb-web/src/app/components/spinner/spinner.component.html rename to web/src/app/components/spinner/spinner.component.html diff --git a/kdb-web/src/app/components/spinner/spinner.component.scss b/web/src/app/components/spinner/spinner.component.scss similarity index 100% rename from kdb-web/src/app/components/spinner/spinner.component.scss rename to web/src/app/components/spinner/spinner.component.scss diff --git a/kdb-web/src/app/components/spinner/spinner.component.spec.ts b/web/src/app/components/spinner/spinner.component.spec.ts similarity index 100% rename from kdb-web/src/app/components/spinner/spinner.component.spec.ts rename to web/src/app/components/spinner/spinner.component.spec.ts diff --git a/kdb-web/src/app/components/spinner/spinner.component.ts b/web/src/app/components/spinner/spinner.component.ts similarity index 100% rename from kdb-web/src/app/components/spinner/spinner.component.ts rename to web/src/app/components/spinner/spinner.component.ts diff --git a/kdb-web/src/app/models/auth/admin-update-user.dto.ts b/web/src/app/models/auth/admin-update-user.dto.ts similarity index 100% rename from kdb-web/src/app/models/auth/admin-update-user.dto.ts rename to web/src/app/models/auth/admin-update-user.dto.ts diff --git a/kdb-web/src/app/models/auth/auth-error-messages.enum.ts b/web/src/app/models/auth/auth-error-messages.enum.ts similarity index 100% rename from kdb-web/src/app/models/auth/auth-error-messages.enum.ts rename to web/src/app/models/auth/auth-error-messages.enum.ts diff --git a/kdb-web/src/app/models/auth/auth-roles.enum.ts b/web/src/app/models/auth/auth-roles.enum.ts similarity index 100% rename from kdb-web/src/app/models/auth/auth-roles.enum.ts rename to web/src/app/models/auth/auth-roles.enum.ts diff --git a/kdb-web/src/app/models/auth/auth-user-atr-errors.ts b/web/src/app/models/auth/auth-user-atr-errors.ts similarity index 100% rename from kdb-web/src/app/models/auth/auth-user-atr-errors.ts rename to web/src/app/models/auth/auth-user-atr-errors.ts diff --git a/kdb-web/src/app/models/auth/auth-user.dto.ts b/web/src/app/models/auth/auth-user.dto.ts similarity index 100% rename from kdb-web/src/app/models/auth/auth-user.dto.ts rename to web/src/app/models/auth/auth-user.dto.ts diff --git a/kdb-web/src/app/models/auth/discord-auth-url.dto.ts b/web/src/app/models/auth/discord-auth-url.dto.ts similarity index 100% rename from kdb-web/src/app/models/auth/discord-auth-url.dto.ts rename to web/src/app/models/auth/discord-auth-url.dto.ts diff --git a/kdb-web/src/app/models/auth/email-string.dto.ts b/web/src/app/models/auth/email-string.dto.ts similarity index 100% rename from kdb-web/src/app/models/auth/email-string.dto.ts rename to web/src/app/models/auth/email-string.dto.ts diff --git a/kdb-web/src/app/models/auth/oauth.dto.ts b/web/src/app/models/auth/oauth.dto.ts similarity index 100% rename from kdb-web/src/app/models/auth/oauth.dto.ts rename to web/src/app/models/auth/oauth.dto.ts diff --git a/kdb-web/src/app/models/auth/register-error-messages.enum.ts b/web/src/app/models/auth/register-error-messages.enum.ts similarity index 100% rename from kdb-web/src/app/models/auth/register-error-messages.enum.ts rename to web/src/app/models/auth/register-error-messages.enum.ts diff --git a/kdb-web/src/app/models/auth/reset-password.dto.ts b/web/src/app/models/auth/reset-password.dto.ts similarity index 100% rename from kdb-web/src/app/models/auth/reset-password.dto.ts rename to web/src/app/models/auth/reset-password.dto.ts diff --git a/kdb-web/src/app/models/auth/token.dto.ts b/web/src/app/models/auth/token.dto.ts similarity index 100% rename from kdb-web/src/app/models/auth/token.dto.ts rename to web/src/app/models/auth/token.dto.ts diff --git a/kdb-web/src/app/models/auth/update-user.dto.ts b/web/src/app/models/auth/update-user.dto.ts similarity index 100% rename from kdb-web/src/app/models/auth/update-user.dto.ts rename to web/src/app/models/auth/update-user.dto.ts diff --git a/kdb-web/src/app/models/config/api-version.ts b/web/src/app/models/config/api-version.ts similarity index 100% rename from kdb-web/src/app/models/config/api-version.ts rename to web/src/app/models/config/api-version.ts diff --git a/kdb-web/src/app/models/config/app-settings.ts b/web/src/app/models/config/app-settings.ts similarity index 100% rename from kdb-web/src/app/models/config/app-settings.ts rename to web/src/app/models/config/app-settings.ts diff --git a/kdb-web/src/app/models/config/feature-flags.model.ts b/web/src/app/models/config/feature-flags.model.ts similarity index 100% rename from kdb-web/src/app/models/config/feature-flags.model.ts rename to web/src/app/models/config/feature-flags.model.ts diff --git a/kdb-web/src/app/models/config/server-config.model.ts b/web/src/app/models/config/server-config.model.ts similarity index 91% rename from kdb-web/src/app/models/config/server-config.model.ts rename to web/src/app/models/config/server-config.model.ts index a1873b49..616dbecc 100644 --- a/kdb-web/src/app/models/config/server-config.model.ts +++ b/web/src/app/models/config/server-config.model.ts @@ -12,12 +12,14 @@ export interface ServerConfig extends DataWithHistory { xpPerOntimeHour?: number; xpPerEventParticipation?: number; xpPerAchievement?: number; + xpForBirthday?: number; afkCommandChannelId?: string; helpVoiceChannelId?: string; teamChannelId?: string; loginMessageChannelId?: string; defaultRoleId?: string; shortRoleNameOnlySetHighestRole?: boolean; + gameOfferNotificationChatId?: string; featureFlags: FeatureFlag[]; afkChannelIds: string[]; moderatorRoleIds: string[]; diff --git a/kdb-web/src/app/models/config/settings.dto.ts b/web/src/app/models/config/settings.dto.ts similarity index 100% rename from kdb-web/src/app/models/config/settings.dto.ts rename to web/src/app/models/config/settings.dto.ts diff --git a/kdb-web/src/app/models/config/software-version.dto.ts b/web/src/app/models/config/software-version.dto.ts similarity index 100% rename from kdb-web/src/app/models/config/software-version.dto.ts rename to web/src/app/models/config/software-version.dto.ts diff --git a/kdb-web/src/app/models/config/software-version.ts b/web/src/app/models/config/software-version.ts similarity index 100% rename from kdb-web/src/app/models/config/software-version.ts rename to web/src/app/models/config/software-version.ts diff --git a/kdb-web/src/app/models/config/technician-config.model.ts b/web/src/app/models/config/technician-config.model.ts similarity index 100% rename from kdb-web/src/app/models/config/technician-config.model.ts rename to web/src/app/models/config/technician-config.model.ts diff --git a/kdb-web/src/app/models/data/achievement.model.ts b/web/src/app/models/data/achievement.model.ts similarity index 100% rename from kdb-web/src/app/models/data/achievement.model.ts rename to web/src/app/models/data/achievement.model.ts diff --git a/kdb-web/src/app/models/data/auto_role.model.ts b/web/src/app/models/data/auto_role.model.ts similarity index 100% rename from kdb-web/src/app/models/data/auto_role.model.ts rename to web/src/app/models/data/auto_role.model.ts diff --git a/kdb-web/src/app/models/data/client.model.ts b/web/src/app/models/data/client.model.ts similarity index 100% rename from kdb-web/src/app/models/data/client.model.ts rename to web/src/app/models/data/client.model.ts diff --git a/kdb-web/src/app/models/data/data.model.ts b/web/src/app/models/data/data.model.ts similarity index 100% rename from kdb-web/src/app/models/data/data.model.ts rename to web/src/app/models/data/data.model.ts diff --git a/kdb-web/src/app/models/data/discord.model.ts b/web/src/app/models/data/discord.model.ts similarity index 100% rename from kdb-web/src/app/models/data/discord.model.ts rename to web/src/app/models/data/discord.model.ts diff --git a/kdb-web/src/app/models/data/level.model.ts b/web/src/app/models/data/level.model.ts similarity index 100% rename from kdb-web/src/app/models/data/level.model.ts rename to web/src/app/models/data/level.model.ts diff --git a/kdb-web/src/app/models/data/server.model.ts b/web/src/app/models/data/server.model.ts similarity index 100% rename from kdb-web/src/app/models/data/server.model.ts rename to web/src/app/models/data/server.model.ts diff --git a/kdb-web/src/app/models/data/short_role_name.model.ts b/web/src/app/models/data/short_role_name.model.ts similarity index 100% rename from kdb-web/src/app/models/data/short_role_name.model.ts rename to web/src/app/models/data/short_role_name.model.ts diff --git a/kdb-web/src/app/models/data/user.model.ts b/web/src/app/models/data/user.model.ts similarity index 85% rename from kdb-web/src/app/models/data/user.model.ts rename to web/src/app/models/data/user.model.ts index 6d649da4..5dcd05aa 100644 --- a/kdb-web/src/app/models/data/user.model.ts +++ b/web/src/app/models/data/user.model.ts @@ -5,14 +5,16 @@ import { UserJoinedServer } from "./user_joined_server.model"; import { UserJoinedVoiceChannel } from "./user_joined_voice_channel.model"; import { UserJoinedGameServer } from "./user_joined_game_server.model"; import { Achievement } from "./achievement.model"; +import { UserWarning } from "./user_warning.model"; export interface User extends DataWithHistory { id?: number; discordId?: number; name?: string; xp?: number; - message_count?: number; - reaction_count?: number; + messageCount?: number; + reactionCount?: number; + birthday?: string; ontime?: number; level?: Level; server?: Server; @@ -29,6 +31,9 @@ export interface User extends DataWithHistory { achievementCount?: number; achievements?: Achievement[]; + + userWarningCount?: number; + userWarnings?: UserWarning[]; } export interface UserFilter { diff --git a/kdb-web/src/app/models/data/user_joined_game_server.model.ts b/web/src/app/models/data/user_joined_game_server.model.ts similarity index 100% rename from kdb-web/src/app/models/data/user_joined_game_server.model.ts rename to web/src/app/models/data/user_joined_game_server.model.ts diff --git a/kdb-web/src/app/models/data/user_joined_server.model.ts b/web/src/app/models/data/user_joined_server.model.ts similarity index 100% rename from kdb-web/src/app/models/data/user_joined_server.model.ts rename to web/src/app/models/data/user_joined_server.model.ts diff --git a/kdb-web/src/app/models/data/user_joined_voice_channel.model.ts b/web/src/app/models/data/user_joined_voice_channel.model.ts similarity index 100% rename from kdb-web/src/app/models/data/user_joined_voice_channel.model.ts rename to web/src/app/models/data/user_joined_voice_channel.model.ts diff --git a/web/src/app/models/data/user_warning.model.ts b/web/src/app/models/data/user_warning.model.ts new file mode 100644 index 00000000..37ceeae9 --- /dev/null +++ b/web/src/app/models/data/user_warning.model.ts @@ -0,0 +1,16 @@ +import { DataWithHistory } from "./data.model"; +import { User, UserFilter } from "./user.model"; + +export interface UserWarning extends DataWithHistory { + id?: number; + user?: User; + description?: string; + author?: User; +} + +export interface UserWarningFilter { + id?: number; + user?: UserFilter; + description?: string; + author?: UserFilter; +} diff --git a/kdb-web/src/app/models/error/error-dto.ts b/web/src/app/models/error/error-dto.ts similarity index 100% rename from kdb-web/src/app/models/error/error-dto.ts rename to web/src/app/models/error/error-dto.ts diff --git a/kdb-web/src/app/models/error/service-error-code.enum.ts b/web/src/app/models/error/service-error-code.enum.ts similarity index 100% rename from kdb-web/src/app/models/error/service-error-code.enum.ts rename to web/src/app/models/error/service-error-code.enum.ts diff --git a/kdb-web/src/app/models/graphql/filter/page.model.ts b/web/src/app/models/graphql/filter/page.model.ts similarity index 100% rename from kdb-web/src/app/models/graphql/filter/page.model.ts rename to web/src/app/models/graphql/filter/page.model.ts diff --git a/kdb-web/src/app/models/graphql/filter/sort.model.ts b/web/src/app/models/graphql/filter/sort.model.ts similarity index 100% rename from kdb-web/src/app/models/graphql/filter/sort.model.ts rename to web/src/app/models/graphql/filter/sort.model.ts diff --git a/kdb-web/src/app/models/graphql/mutations.model.ts b/web/src/app/models/graphql/mutations.model.ts similarity index 81% rename from kdb-web/src/app/models/graphql/mutations.model.ts rename to web/src/app/models/graphql/mutations.model.ts index ece931d6..853d4178 100644 --- a/kdb-web/src/app/models/graphql/mutations.model.ts +++ b/web/src/app/models/graphql/mutations.model.ts @@ -1,15 +1,22 @@ export class Mutations { static updateUser = ` - mutation updateUser($id: ID, $xp: Int, $levelId: ID) { + mutation updateUser($id: ID, $xp: Int $birthday: String, $levelId: ID, $userWarnings: [UserWarningInput]) { user { - updateUser(input: { id: $id, xp: $xp, levelId: $levelId }) { + updateUser(input: { id: $id, xp: $xp, birthday: $birthday, levelId: $levelId, userWarnings: $userWarnings }) { id name xp + messageCount + reactionCount + birthday level { id name } + userWarnings { + id + description + } } } } @@ -249,12 +256,14 @@ export class Mutations { $xpPerOntimeHour: Int, $xpPerEventParticipation: Int, $xpPerAchievement: Int, + $xpForBirthday: Int, $afkCommandChannelId: String, $helpVoiceChannelId: String, $teamChannelId: String, $loginMessageChannelId: String, $defaultRoleId: String, - $shortRoleNameOnlySetHighestRole: Boolean + $shortRoleNameOnlySetHighestRole: Boolean, + $gameOfferNotificationChatId: String, $featureFlags: [FeatureFlagInput], $afkChannelIds: [String], $moderatorRoleIds: [String], @@ -272,12 +281,14 @@ export class Mutations { xpPerOntimeHour: $xpPerOntimeHour, xpPerEventParticipation: $xpPerEventParticipation, xpPerAchievement: $xpPerAchievement, + xpForBirthday: $xpForBirthday, afkCommandChannelId: $afkCommandChannelId, helpVoiceChannelId: $helpVoiceChannelId, teamChannelId: $teamChannelId, loginMessageChannelId: $loginMessageChannelId, defaultRoleId: $defaultRoleId, shortRoleNameOnlySetHighestRole: $shortRoleNameOnlySetHighestRole, + gameOfferNotificationChatId: $gameOfferNotificationChatId, featureFlags: $featureFlags, afkChannelIds: $afkChannelIds, moderatorRoleIds: $moderatorRoleIds, @@ -293,12 +304,14 @@ export class Mutations { xpPerOntimeHour xpPerEventParticipation xpPerAchievement + xpForBirthday afkCommandChannelId helpVoiceChannelId teamChannelId loginMessageChannelId defaultRoleId shortRoleNameOnlySetHighestRole + gameOfferNotificationChatId featureFlags { key value @@ -314,4 +327,50 @@ export class Mutations { } } `; + + + + static createUserWarning = ` + mutation createUserWarning($name: String, $description: String, $attribute: String, $operator: String, $value: String, $serverId: ID) { + userWarning { + createUserWarning(input: { name: $name, description: $description, attribute: $attribute, operator: $operator, value: $value, serverId: $serverId}) { + id + name + description + attribute + operator + value + server { + id + } + } + } + } + `; + + static updateUserWarning = ` + mutation updateUserWarning($id: ID, $name: String, $description: String, $attribute: String, $operator: String, $value: String) { + userWarning { + updateUserWarning(input: { id: $id, name: $name, description: $description, attribute: $attribute, operator: $operator, value: $value}) { + id + name + description + attribute + operator + value + } + } + } + `; + + static deleteUserWarning = ` + mutation deleteUserWarning($id: ID) { + userWarning { + deleteUserWarning(id: $id) { + id + name + } + } + } + `; } diff --git a/kdb-web/src/app/models/graphql/queries.model.ts b/web/src/app/models/graphql/queries.model.ts similarity index 82% rename from kdb-web/src/app/models/graphql/queries.model.ts rename to web/src/app/models/graphql/queries.model.ts index 02c2da1d..bbc6a408 100644 --- a/kdb-web/src/app/models/graphql/queries.model.ts +++ b/web/src/app/models/graphql/queries.model.ts @@ -208,7 +208,7 @@ export class Queries { query { shortRoleNamePositions } - ` + `; static shortRoleNameQuery = ` query ShortRoleNameList($serverId: ID, $filter: ShortRoleNameFilter, $page: Page, $sort: Sort) { @@ -279,58 +279,101 @@ export class Queries { static userProfile = ` query UserProfile($serverId: ID, $userId: ID, $page: Page, $sort: Sort) { - servers(filter: {id: $serverId}) { - userCount - users(filter: {id: $userId}, page: $page, sort: $sort) { + userCount + users(filter: {server: {id: $serverId}, id: $userId}, page: $page, sort: $sort) { + id + discordId + name + xp + messageCount + reactionCount + birthday + ontime + level { id - discordId name - xp - ontime - level { + } + leftServer + server { + id + name + } + + joinedServerCount + joinedServers { + id + joinedOn + leavedOn + } + + createdAt + modifiedAt + } + } + `; + + static userProfileAchievements = ` + query UserProfile($serverId: ID, $userId: ID, $page: Page, $sort: Sort) { + users(filter: {server: {id: $serverId}, id: $userId}, page: $page, sort: $sort) { + achievementCount + achievements { + id + name + description + createdAt + } + } + } + `; + + static userProfileVoiceChannelJoins = ` + query UserProfile($serverId: ID, $userId: ID, $page: Page, $sort: Sort) { + users(filter: {server: {id: $serverId}, id: $userId}, page: $page, sort: $sort) { + joinedVoiceChannelCount + joinedVoiceChannels { + id + channelId + channelName + time + joinedOn + leavedOn + } + } + } + `; + + static userProfileGameserverJoins = ` + query UserProfile($serverId: ID, $userId: ID, $page: Page, $sort: Sort) { + users(filter: {server: {id: $serverId}, id: $userId}, page: $page, sort: $sort) { + userJoinedGameServerCount + userJoinedGameServers { + id + gameServer + time + joinedOn + leavedOn + } + } + } + `; + + static userProfileWarnings = ` + query UserProfile($serverId: ID, $userId: ID, $page: Page, $sort: Sort) { + users(filter: {server: {id: $serverId}, id: $userId}, page: $page, sort: $sort) { + userWarningCount + userWarnings { + id + user { id name } - leftServer - server { + description + author { id name } - joinedServerCount - joinedServers { - id - joinedOn - leavedOn - } - - joinedVoiceChannelCount - joinedVoiceChannels { - id - channelId - channelName - time - joinedOn - leavedOn - } - - userJoinedGameServerCount - userJoinedGameServers { - id - gameServer - time - joinedOn - leavedOn - } - - achievements { - id - name - createdAt - } - createdAt - modifiedAt } } } @@ -482,6 +525,7 @@ export class Queries { xpPerOntimeHour xpPerEventParticipation xpPerAchievement + xpForBirthday afkCommandChannelId helpVoiceChannelId teamChannelId diff --git a/kdb-web/src/app/models/graphql/query.model.ts b/web/src/app/models/graphql/query.model.ts similarity index 92% rename from kdb-web/src/app/models/graphql/query.model.ts rename to web/src/app/models/graphql/query.model.ts index 7fc95684..f98f9a4a 100644 --- a/kdb-web/src/app/models/graphql/query.model.ts +++ b/web/src/app/models/graphql/query.model.ts @@ -8,6 +8,7 @@ import { TechnicianConfig } from "../config/technician-config.model"; import { ServerConfig } from "../config/server-config.model"; import { ShortRoleName } from "../data/short_role_name.model"; import { FeatureFlag } from "../config/feature-flags.model"; +import { UserWarning } from "../data/user_warning.model"; export interface Query { serverCount: number; @@ -31,6 +32,11 @@ export interface UserListQuery { users: User[]; } +export interface UserWarningQuery { + userWarningCount: number; + userWarnings: UserWarning[]; +} + export interface GameServerListQuery { gameServerCount: number; gameServers: GameServer[]; diff --git a/kdb-web/src/app/models/graphql/result.model.ts b/web/src/app/models/graphql/result.model.ts similarity index 88% rename from kdb-web/src/app/models/graphql/result.model.ts rename to web/src/app/models/graphql/result.model.ts index cff8fcf2..411d6f1d 100644 --- a/kdb-web/src/app/models/graphql/result.model.ts +++ b/web/src/app/models/graphql/result.model.ts @@ -6,6 +6,7 @@ import { Achievement } from "../data/achievement.model"; import { TechnicianConfig } from "../config/technician-config.model"; import { ServerConfig } from "../config/server-config.model"; import { ShortRoleName } from "../data/short_role_name.model"; +import { UserWarning } from "../data/user_warning.model"; export interface GraphQLResult { data: { @@ -77,3 +78,11 @@ export interface ShortRoleNameMutationResult { deleteShortRoleName?: ShortRoleName }; } + +export interface UserWarningMutationResult { + userWarning: { + createUserWarning?: UserWarning + updateUserWarning?: UserWarning + deleteUserWarning?: UserWarning + }; +} diff --git a/kdb-web/src/app/models/graphql/variables.model.ts b/web/src/app/models/graphql/variables.model.ts similarity index 100% rename from kdb-web/src/app/models/graphql/variables.model.ts rename to web/src/app/models/graphql/variables.model.ts diff --git a/kdb-web/src/app/models/selection/auth-user/auth-user-select-criterion.dto.ts b/web/src/app/models/selection/auth-user/auth-user-select-criterion.dto.ts similarity index 100% rename from kdb-web/src/app/models/selection/auth-user/auth-user-select-criterion.dto.ts rename to web/src/app/models/selection/auth-user/auth-user-select-criterion.dto.ts diff --git a/kdb-web/src/app/models/selection/auth-user/get-filtered-auth-users-result.dto.ts b/web/src/app/models/selection/auth-user/get-filtered-auth-users-result.dto.ts similarity index 100% rename from kdb-web/src/app/models/selection/auth-user/get-filtered-auth-users-result.dto.ts rename to web/src/app/models/selection/auth-user/get-filtered-auth-users-result.dto.ts diff --git a/kdb-web/src/app/models/selection/select-criterion.model.ts b/web/src/app/models/selection/select-criterion.model.ts similarity index 100% rename from kdb-web/src/app/models/selection/select-criterion.model.ts rename to web/src/app/models/selection/select-criterion.model.ts diff --git a/kdb-web/src/app/models/utils/confirmation-dialog.ts b/web/src/app/models/utils/confirmation-dialog.ts similarity index 100% rename from kdb-web/src/app/models/utils/confirmation-dialog.ts rename to web/src/app/models/utils/confirmation-dialog.ts diff --git a/kdb-web/src/app/models/utils/toast-options.ts b/web/src/app/models/utils/toast-options.ts similarity index 100% rename from kdb-web/src/app/models/utils/toast-options.ts rename to web/src/app/models/utils/toast-options.ts diff --git a/kdb-web/src/app/models/view/theme.ts b/web/src/app/models/view/theme.ts similarity index 100% rename from kdb-web/src/app/models/view/theme.ts rename to web/src/app/models/view/theme.ts diff --git a/kdb-web/src/app/models/view/themes.enum.ts b/web/src/app/models/view/themes.enum.ts similarity index 100% rename from kdb-web/src/app/models/view/themes.enum.ts rename to web/src/app/models/view/themes.enum.ts diff --git a/kdb-web/src/app/modules/admin/auth-users/auth-user-routing.module.ts b/web/src/app/modules/admin/auth-users/auth-user-routing.module.ts similarity index 100% rename from kdb-web/src/app/modules/admin/auth-users/auth-user-routing.module.ts rename to web/src/app/modules/admin/auth-users/auth-user-routing.module.ts diff --git a/kdb-web/src/app/modules/admin/auth-users/auth-user.module.ts b/web/src/app/modules/admin/auth-users/auth-user.module.ts similarity index 100% rename from kdb-web/src/app/modules/admin/auth-users/auth-user.module.ts rename to web/src/app/modules/admin/auth-users/auth-user.module.ts diff --git a/kdb-web/src/app/modules/admin/auth-users/components/auth-user/auth-user.component.html b/web/src/app/modules/admin/auth-users/components/auth-user/auth-user.component.html similarity index 100% rename from kdb-web/src/app/modules/admin/auth-users/components/auth-user/auth-user.component.html rename to web/src/app/modules/admin/auth-users/components/auth-user/auth-user.component.html diff --git a/kdb-web/src/app/modules/admin/auth-users/components/auth-user/auth-user.component.scss b/web/src/app/modules/admin/auth-users/components/auth-user/auth-user.component.scss similarity index 100% rename from kdb-web/src/app/modules/admin/auth-users/components/auth-user/auth-user.component.scss rename to web/src/app/modules/admin/auth-users/components/auth-user/auth-user.component.scss diff --git a/kdb-web/src/app/modules/admin/auth-users/components/auth-user/auth-user.component.spec.ts b/web/src/app/modules/admin/auth-users/components/auth-user/auth-user.component.spec.ts similarity index 100% rename from kdb-web/src/app/modules/admin/auth-users/components/auth-user/auth-user.component.spec.ts rename to web/src/app/modules/admin/auth-users/components/auth-user/auth-user.component.spec.ts diff --git a/kdb-web/src/app/modules/admin/auth-users/components/auth-user/auth-user.component.ts b/web/src/app/modules/admin/auth-users/components/auth-user/auth-user.component.ts similarity index 100% rename from kdb-web/src/app/modules/admin/auth-users/components/auth-user/auth-user.component.ts rename to web/src/app/modules/admin/auth-users/components/auth-user/auth-user.component.ts diff --git a/kdb-web/src/app/modules/admin/settings/components/settings/settings.component.html b/web/src/app/modules/admin/settings/components/settings/settings.component.html similarity index 100% rename from kdb-web/src/app/modules/admin/settings/components/settings/settings.component.html rename to web/src/app/modules/admin/settings/components/settings/settings.component.html diff --git a/kdb-web/src/app/modules/admin/settings/components/settings/settings.component.scss b/web/src/app/modules/admin/settings/components/settings/settings.component.scss similarity index 100% rename from kdb-web/src/app/modules/admin/settings/components/settings/settings.component.scss rename to web/src/app/modules/admin/settings/components/settings/settings.component.scss diff --git a/kdb-web/src/app/modules/admin/settings/components/settings/settings.component.spec.ts b/web/src/app/modules/admin/settings/components/settings/settings.component.spec.ts similarity index 100% rename from kdb-web/src/app/modules/admin/settings/components/settings/settings.component.spec.ts rename to web/src/app/modules/admin/settings/components/settings/settings.component.spec.ts diff --git a/kdb-web/src/app/modules/admin/settings/components/settings/settings.component.ts b/web/src/app/modules/admin/settings/components/settings/settings.component.ts similarity index 100% rename from kdb-web/src/app/modules/admin/settings/components/settings/settings.component.ts rename to web/src/app/modules/admin/settings/components/settings/settings.component.ts diff --git a/kdb-web/src/app/modules/admin/settings/settings-routing.module.ts b/web/src/app/modules/admin/settings/settings-routing.module.ts similarity index 100% rename from kdb-web/src/app/modules/admin/settings/settings-routing.module.ts rename to web/src/app/modules/admin/settings/settings-routing.module.ts diff --git a/kdb-web/src/app/modules/admin/settings/settings.module.ts b/web/src/app/modules/admin/settings/settings.module.ts similarity index 100% rename from kdb-web/src/app/modules/admin/settings/settings.module.ts rename to web/src/app/modules/admin/settings/settings.module.ts diff --git a/kdb-web/src/app/modules/auth/auth-routing.module.ts b/web/src/app/modules/auth/auth-routing.module.ts similarity index 100% rename from kdb-web/src/app/modules/auth/auth-routing.module.ts rename to web/src/app/modules/auth/auth-routing.module.ts diff --git a/kdb-web/src/app/modules/auth/auth.module.ts b/web/src/app/modules/auth/auth.module.ts similarity index 100% rename from kdb-web/src/app/modules/auth/auth.module.ts rename to web/src/app/modules/auth/auth.module.ts diff --git a/kdb-web/src/app/modules/auth/components/auth-footer/auth-footer.component.html b/web/src/app/modules/auth/components/auth-footer/auth-footer.component.html similarity index 100% rename from kdb-web/src/app/modules/auth/components/auth-footer/auth-footer.component.html rename to web/src/app/modules/auth/components/auth-footer/auth-footer.component.html diff --git a/kdb-web/src/app/modules/auth/components/auth-footer/auth-footer.component.scss b/web/src/app/modules/auth/components/auth-footer/auth-footer.component.scss similarity index 100% rename from kdb-web/src/app/modules/auth/components/auth-footer/auth-footer.component.scss rename to web/src/app/modules/auth/components/auth-footer/auth-footer.component.scss diff --git a/kdb-web/src/app/modules/auth/components/auth-footer/auth-footer.component.spec.ts b/web/src/app/modules/auth/components/auth-footer/auth-footer.component.spec.ts similarity index 100% rename from kdb-web/src/app/modules/auth/components/auth-footer/auth-footer.component.spec.ts rename to web/src/app/modules/auth/components/auth-footer/auth-footer.component.spec.ts diff --git a/kdb-web/src/app/modules/auth/components/auth-footer/auth-footer.component.ts b/web/src/app/modules/auth/components/auth-footer/auth-footer.component.ts similarity index 100% rename from kdb-web/src/app/modules/auth/components/auth-footer/auth-footer.component.ts rename to web/src/app/modules/auth/components/auth-footer/auth-footer.component.ts diff --git a/kdb-web/src/app/modules/auth/components/auth-header/auth-header.component.html b/web/src/app/modules/auth/components/auth-header/auth-header.component.html similarity index 100% rename from kdb-web/src/app/modules/auth/components/auth-header/auth-header.component.html rename to web/src/app/modules/auth/components/auth-header/auth-header.component.html diff --git a/kdb-web/src/app/modules/auth/components/auth-header/auth-header.component.scss b/web/src/app/modules/auth/components/auth-header/auth-header.component.scss similarity index 100% rename from kdb-web/src/app/modules/auth/components/auth-header/auth-header.component.scss rename to web/src/app/modules/auth/components/auth-header/auth-header.component.scss diff --git a/kdb-web/src/app/modules/auth/components/auth-header/auth-header.component.spec.ts b/web/src/app/modules/auth/components/auth-header/auth-header.component.spec.ts similarity index 100% rename from kdb-web/src/app/modules/auth/components/auth-header/auth-header.component.spec.ts rename to web/src/app/modules/auth/components/auth-header/auth-header.component.spec.ts diff --git a/kdb-web/src/app/modules/auth/components/auth-header/auth-header.component.ts b/web/src/app/modules/auth/components/auth-header/auth-header.component.ts similarity index 100% rename from kdb-web/src/app/modules/auth/components/auth-header/auth-header.component.ts rename to web/src/app/modules/auth/components/auth-header/auth-header.component.ts diff --git a/kdb-web/src/app/modules/auth/components/forget-password/forget-password.component.html b/web/src/app/modules/auth/components/forget-password/forget-password.component.html similarity index 100% rename from kdb-web/src/app/modules/auth/components/forget-password/forget-password.component.html rename to web/src/app/modules/auth/components/forget-password/forget-password.component.html diff --git a/kdb-web/src/app/modules/auth/components/forget-password/forget-password.component.scss b/web/src/app/modules/auth/components/forget-password/forget-password.component.scss similarity index 100% rename from kdb-web/src/app/modules/auth/components/forget-password/forget-password.component.scss rename to web/src/app/modules/auth/components/forget-password/forget-password.component.scss diff --git a/kdb-web/src/app/modules/auth/components/forget-password/forget-password.component.spec.ts b/web/src/app/modules/auth/components/forget-password/forget-password.component.spec.ts similarity index 100% rename from kdb-web/src/app/modules/auth/components/forget-password/forget-password.component.spec.ts rename to web/src/app/modules/auth/components/forget-password/forget-password.component.spec.ts diff --git a/kdb-web/src/app/modules/auth/components/forget-password/forget-password.component.ts b/web/src/app/modules/auth/components/forget-password/forget-password.component.ts similarity index 100% rename from kdb-web/src/app/modules/auth/components/forget-password/forget-password.component.ts rename to web/src/app/modules/auth/components/forget-password/forget-password.component.ts diff --git a/kdb-web/src/app/modules/auth/components/login/login.component.html b/web/src/app/modules/auth/components/login/login.component.html similarity index 100% rename from kdb-web/src/app/modules/auth/components/login/login.component.html rename to web/src/app/modules/auth/components/login/login.component.html diff --git a/kdb-web/src/app/modules/auth/components/login/login.component.scss b/web/src/app/modules/auth/components/login/login.component.scss similarity index 100% rename from kdb-web/src/app/modules/auth/components/login/login.component.scss rename to web/src/app/modules/auth/components/login/login.component.scss diff --git a/kdb-web/src/app/modules/auth/components/login/login.component.spec.ts b/web/src/app/modules/auth/components/login/login.component.spec.ts similarity index 100% rename from kdb-web/src/app/modules/auth/components/login/login.component.spec.ts rename to web/src/app/modules/auth/components/login/login.component.spec.ts diff --git a/kdb-web/src/app/modules/auth/components/login/login.component.ts b/web/src/app/modules/auth/components/login/login.component.ts similarity index 100% rename from kdb-web/src/app/modules/auth/components/login/login.component.ts rename to web/src/app/modules/auth/components/login/login.component.ts diff --git a/kdb-web/src/app/modules/auth/components/registration/registration.component.html b/web/src/app/modules/auth/components/registration/registration.component.html similarity index 100% rename from kdb-web/src/app/modules/auth/components/registration/registration.component.html rename to web/src/app/modules/auth/components/registration/registration.component.html diff --git a/kdb-web/src/app/modules/auth/components/registration/registration.component.scss b/web/src/app/modules/auth/components/registration/registration.component.scss similarity index 100% rename from kdb-web/src/app/modules/auth/components/registration/registration.component.scss rename to web/src/app/modules/auth/components/registration/registration.component.scss diff --git a/kdb-web/src/app/modules/auth/components/registration/registration.component.spec.ts b/web/src/app/modules/auth/components/registration/registration.component.spec.ts similarity index 100% rename from kdb-web/src/app/modules/auth/components/registration/registration.component.spec.ts rename to web/src/app/modules/auth/components/registration/registration.component.spec.ts diff --git a/kdb-web/src/app/modules/auth/components/registration/registration.component.ts b/web/src/app/modules/auth/components/registration/registration.component.ts similarity index 100% rename from kdb-web/src/app/modules/auth/components/registration/registration.component.ts rename to web/src/app/modules/auth/components/registration/registration.component.ts diff --git a/kdb-web/src/app/modules/shared/base/hideable-component.spec.ts b/web/src/app/modules/shared/base/hideable-component.spec.ts similarity index 100% rename from kdb-web/src/app/modules/shared/base/hideable-component.spec.ts rename to web/src/app/modules/shared/base/hideable-component.spec.ts diff --git a/kdb-web/src/app/modules/shared/base/hideable-component.ts b/web/src/app/modules/shared/base/hideable-component.ts similarity index 69% rename from kdb-web/src/app/modules/shared/base/hideable-component.ts rename to web/src/app/modules/shared/base/hideable-component.ts index 4421ff91..3626eb48 100644 --- a/kdb-web/src/app/modules/shared/base/hideable-component.ts +++ b/web/src/app/modules/shared/base/hideable-component.ts @@ -5,9 +5,11 @@ import { ComponentWithTable } from "../../../base/component-with-table"; export class HideableComponent { @HostBinding("class.hidden-column") get hidden() { - return !(this.parent?.isColumnVisible(this.column) ?? true); + const column = this.subColumn ?? this.column; + return !(this.parent?.isColumnVisible(column) ?? true); }; @Input() column!: string; + @Input() subColumn!: string; @Input() parent!: ComponentWithTable; } diff --git a/kdb-web/src/app/modules/shared/base/multi-select-columns/multi-select-columns.component.html b/web/src/app/modules/shared/base/multi-select-columns/multi-select-columns.component.html similarity index 100% rename from kdb-web/src/app/modules/shared/base/multi-select-columns/multi-select-columns.component.html rename to web/src/app/modules/shared/base/multi-select-columns/multi-select-columns.component.html diff --git a/kdb-web/src/app/modules/shared/base/multi-select-columns/multi-select-columns.component.scss b/web/src/app/modules/shared/base/multi-select-columns/multi-select-columns.component.scss similarity index 100% rename from kdb-web/src/app/modules/shared/base/multi-select-columns/multi-select-columns.component.scss rename to web/src/app/modules/shared/base/multi-select-columns/multi-select-columns.component.scss diff --git a/kdb-web/src/app/modules/shared/base/multi-select-columns/multi-select-columns.component.spec.ts b/web/src/app/modules/shared/base/multi-select-columns/multi-select-columns.component.spec.ts similarity index 100% rename from kdb-web/src/app/modules/shared/base/multi-select-columns/multi-select-columns.component.spec.ts rename to web/src/app/modules/shared/base/multi-select-columns/multi-select-columns.component.spec.ts diff --git a/kdb-web/src/app/modules/shared/base/multi-select-columns/multi-select-columns.component.ts b/web/src/app/modules/shared/base/multi-select-columns/multi-select-columns.component.ts similarity index 100% rename from kdb-web/src/app/modules/shared/base/multi-select-columns/multi-select-columns.component.ts rename to web/src/app/modules/shared/base/multi-select-columns/multi-select-columns.component.ts diff --git a/kdb-web/src/app/modules/shared/components/config-list/config-list.component.html b/web/src/app/modules/shared/components/config-list/config-list.component.html similarity index 100% rename from kdb-web/src/app/modules/shared/components/config-list/config-list.component.html rename to web/src/app/modules/shared/components/config-list/config-list.component.html diff --git a/kdb-web/src/app/modules/shared/components/config-list/config-list.component.scss b/web/src/app/modules/shared/components/config-list/config-list.component.scss similarity index 100% rename from kdb-web/src/app/modules/shared/components/config-list/config-list.component.scss rename to web/src/app/modules/shared/components/config-list/config-list.component.scss diff --git a/kdb-web/src/app/modules/shared/components/config-list/config-list.component.spec.ts b/web/src/app/modules/shared/components/config-list/config-list.component.spec.ts similarity index 100% rename from kdb-web/src/app/modules/shared/components/config-list/config-list.component.spec.ts rename to web/src/app/modules/shared/components/config-list/config-list.component.spec.ts diff --git a/kdb-web/src/app/modules/shared/components/config-list/config-list.component.ts b/web/src/app/modules/shared/components/config-list/config-list.component.ts similarity index 100% rename from kdb-web/src/app/modules/shared/components/config-list/config-list.component.ts rename to web/src/app/modules/shared/components/config-list/config-list.component.ts diff --git a/kdb-web/src/app/modules/shared/components/feature-flag-list/feature-flag-list.component.html b/web/src/app/modules/shared/components/feature-flag-list/feature-flag-list.component.html similarity index 100% rename from kdb-web/src/app/modules/shared/components/feature-flag-list/feature-flag-list.component.html rename to web/src/app/modules/shared/components/feature-flag-list/feature-flag-list.component.html diff --git a/kdb-web/src/app/modules/shared/components/feature-flag-list/feature-flag-list.component.scss b/web/src/app/modules/shared/components/feature-flag-list/feature-flag-list.component.scss similarity index 100% rename from kdb-web/src/app/modules/shared/components/feature-flag-list/feature-flag-list.component.scss rename to web/src/app/modules/shared/components/feature-flag-list/feature-flag-list.component.scss diff --git a/kdb-web/src/app/modules/shared/components/feature-flag-list/feature-flag-list.component.spec.ts b/web/src/app/modules/shared/components/feature-flag-list/feature-flag-list.component.spec.ts similarity index 100% rename from kdb-web/src/app/modules/shared/components/feature-flag-list/feature-flag-list.component.spec.ts rename to web/src/app/modules/shared/components/feature-flag-list/feature-flag-list.component.spec.ts diff --git a/kdb-web/src/app/modules/shared/components/feature-flag-list/feature-flag-list.component.ts b/web/src/app/modules/shared/components/feature-flag-list/feature-flag-list.component.ts similarity index 100% rename from kdb-web/src/app/modules/shared/components/feature-flag-list/feature-flag-list.component.ts rename to web/src/app/modules/shared/components/feature-flag-list/feature-flag-list.component.ts diff --git a/kdb-web/src/app/modules/shared/components/hideable-column/hideable-column.component.html b/web/src/app/modules/shared/components/hideable-column/hideable-column.component.html similarity index 100% rename from kdb-web/src/app/modules/shared/components/hideable-column/hideable-column.component.html rename to web/src/app/modules/shared/components/hideable-column/hideable-column.component.html diff --git a/kdb-web/src/app/modules/shared/components/hideable-column/hideable-column.component.scss b/web/src/app/modules/shared/components/hideable-column/hideable-column.component.scss similarity index 100% rename from kdb-web/src/app/modules/shared/components/hideable-column/hideable-column.component.scss rename to web/src/app/modules/shared/components/hideable-column/hideable-column.component.scss diff --git a/kdb-web/src/app/modules/shared/components/hideable-column/hideable-column.component.spec.ts b/web/src/app/modules/shared/components/hideable-column/hideable-column.component.spec.ts similarity index 100% rename from kdb-web/src/app/modules/shared/components/hideable-column/hideable-column.component.spec.ts rename to web/src/app/modules/shared/components/hideable-column/hideable-column.component.spec.ts diff --git a/kdb-web/src/app/modules/shared/components/hideable-column/hideable-column.component.ts b/web/src/app/modules/shared/components/hideable-column/hideable-column.component.ts similarity index 100% rename from kdb-web/src/app/modules/shared/components/hideable-column/hideable-column.component.ts rename to web/src/app/modules/shared/components/hideable-column/hideable-column.component.ts diff --git a/kdb-web/src/app/modules/shared/components/hideable-header/hideable-header.component.html b/web/src/app/modules/shared/components/hideable-header/hideable-header.component.html similarity index 75% rename from kdb-web/src/app/modules/shared/components/hideable-header/hideable-header.component.html rename to web/src/app/modules/shared/components/hideable-header/hideable-header.component.html index f35a2a42..dd36bef3 100644 --- a/kdb-web/src/app/modules/shared/components/hideable-header/hideable-header.component.html +++ b/web/src/app/modules/shared/components/hideable-header/hideable-header.component.html @@ -2,7 +2,7 @@ -
+
diff --git a/kdb-web/src/app/modules/shared/components/hideable-header/hideable-header.component.scss b/web/src/app/modules/shared/components/hideable-header/hideable-header.component.scss similarity index 100% rename from kdb-web/src/app/modules/shared/components/hideable-header/hideable-header.component.scss rename to web/src/app/modules/shared/components/hideable-header/hideable-header.component.scss diff --git a/kdb-web/src/app/modules/shared/components/hideable-header/hideable-header.component.spec.ts b/web/src/app/modules/shared/components/hideable-header/hideable-header.component.spec.ts similarity index 100% rename from kdb-web/src/app/modules/shared/components/hideable-header/hideable-header.component.spec.ts rename to web/src/app/modules/shared/components/hideable-header/hideable-header.component.spec.ts diff --git a/kdb-web/src/app/modules/shared/components/hideable-header/hideable-header.component.ts b/web/src/app/modules/shared/components/hideable-header/hideable-header.component.ts similarity index 100% rename from kdb-web/src/app/modules/shared/components/hideable-header/hideable-header.component.ts rename to web/src/app/modules/shared/components/hideable-header/hideable-header.component.ts diff --git a/kdb-web/src/app/modules/shared/components/history-btn/history-btn.component.html b/web/src/app/modules/shared/components/history-btn/history-btn.component.html similarity index 100% rename from kdb-web/src/app/modules/shared/components/history-btn/history-btn.component.html rename to web/src/app/modules/shared/components/history-btn/history-btn.component.html diff --git a/kdb-web/src/app/modules/shared/components/history-btn/history-btn.component.scss b/web/src/app/modules/shared/components/history-btn/history-btn.component.scss similarity index 100% rename from kdb-web/src/app/modules/shared/components/history-btn/history-btn.component.scss rename to web/src/app/modules/shared/components/history-btn/history-btn.component.scss diff --git a/kdb-web/src/app/modules/shared/components/history-btn/history-btn.component.spec.ts b/web/src/app/modules/shared/components/history-btn/history-btn.component.spec.ts similarity index 100% rename from kdb-web/src/app/modules/shared/components/history-btn/history-btn.component.spec.ts rename to web/src/app/modules/shared/components/history-btn/history-btn.component.spec.ts diff --git a/kdb-web/src/app/modules/shared/components/history-btn/history-btn.component.ts b/web/src/app/modules/shared/components/history-btn/history-btn.component.ts similarity index 100% rename from kdb-web/src/app/modules/shared/components/history-btn/history-btn.component.ts rename to web/src/app/modules/shared/components/history-btn/history-btn.component.ts diff --git a/kdb-web/src/app/modules/shared/guards/auth/auth.guard.spec.ts b/web/src/app/modules/shared/guards/auth/auth.guard.spec.ts similarity index 100% rename from kdb-web/src/app/modules/shared/guards/auth/auth.guard.spec.ts rename to web/src/app/modules/shared/guards/auth/auth.guard.spec.ts diff --git a/kdb-web/src/app/modules/shared/guards/auth/auth.guard.ts b/web/src/app/modules/shared/guards/auth/auth.guard.ts similarity index 100% rename from kdb-web/src/app/modules/shared/guards/auth/auth.guard.ts rename to web/src/app/modules/shared/guards/auth/auth.guard.ts diff --git a/kdb-web/src/app/modules/shared/pipes/auth-role.pipe.ts b/web/src/app/modules/shared/pipes/auth-role.pipe.ts similarity index 100% rename from kdb-web/src/app/modules/shared/pipes/auth-role.pipe.ts rename to web/src/app/modules/shared/pipes/auth-role.pipe.ts diff --git a/kdb-web/src/app/modules/shared/pipes/bool.pipe.spec.ts b/web/src/app/modules/shared/pipes/bool.pipe.spec.ts similarity index 100% rename from kdb-web/src/app/modules/shared/pipes/bool.pipe.spec.ts rename to web/src/app/modules/shared/pipes/bool.pipe.spec.ts diff --git a/kdb-web/src/app/modules/shared/pipes/bool.pipe.ts b/web/src/app/modules/shared/pipes/bool.pipe.ts similarity index 100% rename from kdb-web/src/app/modules/shared/pipes/bool.pipe.ts rename to web/src/app/modules/shared/pipes/bool.pipe.ts diff --git a/kdb-web/src/app/modules/shared/pipes/ip-address.pipe.ts b/web/src/app/modules/shared/pipes/ip-address.pipe.ts similarity index 100% rename from kdb-web/src/app/modules/shared/pipes/ip-address.pipe.ts rename to web/src/app/modules/shared/pipes/ip-address.pipe.ts diff --git a/kdb-web/src/app/modules/shared/shared.module.ts b/web/src/app/modules/shared/shared.module.ts similarity index 73% rename from kdb-web/src/app/modules/shared/shared.module.ts rename to web/src/app/modules/shared/shared.module.ts index 9cea8e7f..f05452c0 100644 --- a/kdb-web/src/app/modules/shared/shared.module.ts +++ b/web/src/app/modules/shared/shared.module.ts @@ -32,8 +32,37 @@ import { HideableHeaderComponent } from './components/hideable-header/hideable-h import { MultiSelectColumnsComponent } from './base/multi-select-columns/multi-select-columns.component'; import { FeatureFlagListComponent } from './components/feature-flag-list/feature-flag-list.component'; import { InputSwitchModule } from "primeng/inputswitch"; +import { CalendarModule } from "primeng/calendar"; +const PrimeNGModules = [ + ButtonModule, + PasswordModule, + MenuModule, + DialogModule, + ProgressSpinnerModule, + HttpClientModule, + FormsModule, + ReactiveFormsModule, + ToastModule, + ConfirmDialogModule, + TableModule, + InputTextModule, + CheckboxModule, + DropdownModule, + TranslateModule, + DynamicDialogModule, + PanelMenuModule, + PanelModule, + InputNumberModule, + ImageModule, + SidebarModule, + DataViewModule, + MultiSelectModule, + InputSwitchModule, + CalendarModule, +] + @NgModule({ declarations: [ AuthRolePipe, @@ -48,66 +77,20 @@ import { InputSwitchModule } from "primeng/inputswitch"; ], imports: [ CommonModule, - ButtonModule, - PasswordModule, - MenuModule, - DialogModule, - ProgressSpinnerModule, - HttpClientModule, - FormsModule, - ReactiveFormsModule, - ToastModule, - ConfirmDialogModule, - TableModule, - InputTextModule, - CheckboxModule, - DropdownModule, - TranslateModule, - DynamicDialogModule, - PanelMenuModule, - PanelModule, - InputNumberModule, - ImageModule, - SidebarModule, - DataViewModule, - MultiSelectModule, - InputSwitchModule, + ...PrimeNGModules ], exports: [ - ButtonModule, - PasswordModule, - MenuModule, - DialogModule, - ProgressSpinnerModule, - HttpClientModule, - FormsModule, - ReactiveFormsModule, - ToastModule, - ConfirmDialogModule, - TableModule, - InputTextModule, - CheckboxModule, - DropdownModule, - TranslateModule, - DynamicDialogModule, - PanelMenuModule, - PanelModule, + ...PrimeNGModules, AuthRolePipe, IpAddressPipe, BoolPipe, - InputNumberModule, - ImageModule, - SidebarModule, HistoryBtnComponent, - DataViewModule, DataViewLayoutOptions, ConfigListComponent, - MultiSelectModule, HideableColumnComponent, HideableHeaderComponent, MultiSelectColumnsComponent, FeatureFlagListComponent, - InputSwitchModule, ] }) export class SharedModule { diff --git a/kdb-web/src/app/modules/view/change-password/change-password-routing.module.ts b/web/src/app/modules/view/change-password/change-password-routing.module.ts similarity index 100% rename from kdb-web/src/app/modules/view/change-password/change-password-routing.module.ts rename to web/src/app/modules/view/change-password/change-password-routing.module.ts diff --git a/kdb-web/src/app/modules/view/change-password/change-password.module.ts b/web/src/app/modules/view/change-password/change-password.module.ts similarity index 100% rename from kdb-web/src/app/modules/view/change-password/change-password.module.ts rename to web/src/app/modules/view/change-password/change-password.module.ts diff --git a/kdb-web/src/app/modules/view/change-password/components/change-password/change-password.component.html b/web/src/app/modules/view/change-password/components/change-password/change-password.component.html similarity index 100% rename from kdb-web/src/app/modules/view/change-password/components/change-password/change-password.component.html rename to web/src/app/modules/view/change-password/components/change-password/change-password.component.html diff --git a/kdb-web/src/app/modules/view/change-password/components/change-password/change-password.component.scss b/web/src/app/modules/view/change-password/components/change-password/change-password.component.scss similarity index 100% rename from kdb-web/src/app/modules/view/change-password/components/change-password/change-password.component.scss rename to web/src/app/modules/view/change-password/components/change-password/change-password.component.scss diff --git a/kdb-web/src/app/modules/view/change-password/components/change-password/change-password.component.spec.ts b/web/src/app/modules/view/change-password/components/change-password/change-password.component.spec.ts similarity index 100% rename from kdb-web/src/app/modules/view/change-password/components/change-password/change-password.component.spec.ts rename to web/src/app/modules/view/change-password/components/change-password/change-password.component.spec.ts diff --git a/kdb-web/src/app/modules/view/change-password/components/change-password/change-password.component.ts b/web/src/app/modules/view/change-password/components/change-password/change-password.component.ts similarity index 100% rename from kdb-web/src/app/modules/view/change-password/components/change-password/change-password.component.ts rename to web/src/app/modules/view/change-password/components/change-password/change-password.component.ts diff --git a/kdb-web/src/app/modules/view/dashboard/components/dashboard/dashboard.component.html b/web/src/app/modules/view/dashboard/components/dashboard/dashboard.component.html similarity index 100% rename from kdb-web/src/app/modules/view/dashboard/components/dashboard/dashboard.component.html rename to web/src/app/modules/view/dashboard/components/dashboard/dashboard.component.html diff --git a/kdb-web/src/app/modules/view/dashboard/components/dashboard/dashboard.component.scss b/web/src/app/modules/view/dashboard/components/dashboard/dashboard.component.scss similarity index 100% rename from kdb-web/src/app/modules/view/dashboard/components/dashboard/dashboard.component.scss rename to web/src/app/modules/view/dashboard/components/dashboard/dashboard.component.scss diff --git a/kdb-web/src/app/modules/view/dashboard/components/dashboard/dashboard.component.spec.ts b/web/src/app/modules/view/dashboard/components/dashboard/dashboard.component.spec.ts similarity index 100% rename from kdb-web/src/app/modules/view/dashboard/components/dashboard/dashboard.component.spec.ts rename to web/src/app/modules/view/dashboard/components/dashboard/dashboard.component.spec.ts diff --git a/kdb-web/src/app/modules/view/dashboard/components/dashboard/dashboard.component.ts b/web/src/app/modules/view/dashboard/components/dashboard/dashboard.component.ts similarity index 100% rename from kdb-web/src/app/modules/view/dashboard/components/dashboard/dashboard.component.ts rename to web/src/app/modules/view/dashboard/components/dashboard/dashboard.component.ts diff --git a/kdb-web/src/app/modules/view/dashboard/dashboard-routing.module.ts b/web/src/app/modules/view/dashboard/dashboard-routing.module.ts similarity index 100% rename from kdb-web/src/app/modules/view/dashboard/dashboard-routing.module.ts rename to web/src/app/modules/view/dashboard/dashboard-routing.module.ts diff --git a/kdb-web/src/app/modules/view/dashboard/dashboard.module.ts b/web/src/app/modules/view/dashboard/dashboard.module.ts similarity index 100% rename from kdb-web/src/app/modules/view/dashboard/dashboard.module.ts rename to web/src/app/modules/view/dashboard/dashboard.module.ts diff --git a/kdb-web/src/app/modules/view/server/achievements/achievements-routing.module.ts b/web/src/app/modules/view/server/achievements/achievements-routing.module.ts similarity index 100% rename from kdb-web/src/app/modules/view/server/achievements/achievements-routing.module.ts rename to web/src/app/modules/view/server/achievements/achievements-routing.module.ts diff --git a/kdb-web/src/app/modules/view/server/achievements/achievements.module.ts b/web/src/app/modules/view/server/achievements/achievements.module.ts similarity index 100% rename from kdb-web/src/app/modules/view/server/achievements/achievements.module.ts rename to web/src/app/modules/view/server/achievements/achievements.module.ts diff --git a/kdb-web/src/app/modules/view/server/achievements/components/achievement/achievement.component.html b/web/src/app/modules/view/server/achievements/components/achievement/achievement.component.html similarity index 100% rename from kdb-web/src/app/modules/view/server/achievements/components/achievement/achievement.component.html rename to web/src/app/modules/view/server/achievements/components/achievement/achievement.component.html diff --git a/kdb-web/src/app/modules/view/server/achievements/components/achievement/achievement.component.scss b/web/src/app/modules/view/server/achievements/components/achievement/achievement.component.scss similarity index 100% rename from kdb-web/src/app/modules/view/server/achievements/components/achievement/achievement.component.scss rename to web/src/app/modules/view/server/achievements/components/achievement/achievement.component.scss diff --git a/kdb-web/src/app/modules/view/server/achievements/components/achievement/achievement.component.spec.ts b/web/src/app/modules/view/server/achievements/components/achievement/achievement.component.spec.ts similarity index 100% rename from kdb-web/src/app/modules/view/server/achievements/components/achievement/achievement.component.spec.ts rename to web/src/app/modules/view/server/achievements/components/achievement/achievement.component.spec.ts diff --git a/kdb-web/src/app/modules/view/server/achievements/components/achievement/achievement.component.ts b/web/src/app/modules/view/server/achievements/components/achievement/achievement.component.ts similarity index 100% rename from kdb-web/src/app/modules/view/server/achievements/components/achievement/achievement.component.ts rename to web/src/app/modules/view/server/achievements/components/achievement/achievement.component.ts diff --git a/kdb-web/src/app/modules/view/server/auto-role/auto-role-routing.module.ts b/web/src/app/modules/view/server/auto-role/auto-role-routing.module.ts similarity index 100% rename from kdb-web/src/app/modules/view/server/auto-role/auto-role-routing.module.ts rename to web/src/app/modules/view/server/auto-role/auto-role-routing.module.ts diff --git a/kdb-web/src/app/modules/view/server/auto-role/auto-role.module.ts b/web/src/app/modules/view/server/auto-role/auto-role.module.ts similarity index 100% rename from kdb-web/src/app/modules/view/server/auto-role/auto-role.module.ts rename to web/src/app/modules/view/server/auto-role/auto-role.module.ts diff --git a/kdb-web/src/app/modules/view/server/auto-role/components/auto-roles-rules/auto-roles-rules.component.html b/web/src/app/modules/view/server/auto-role/components/auto-roles-rules/auto-roles-rules.component.html similarity index 100% rename from kdb-web/src/app/modules/view/server/auto-role/components/auto-roles-rules/auto-roles-rules.component.html rename to web/src/app/modules/view/server/auto-role/components/auto-roles-rules/auto-roles-rules.component.html diff --git a/kdb-web/src/app/modules/view/server/auto-role/components/auto-roles-rules/auto-roles-rules.component.scss b/web/src/app/modules/view/server/auto-role/components/auto-roles-rules/auto-roles-rules.component.scss similarity index 100% rename from kdb-web/src/app/modules/view/server/auto-role/components/auto-roles-rules/auto-roles-rules.component.scss rename to web/src/app/modules/view/server/auto-role/components/auto-roles-rules/auto-roles-rules.component.scss diff --git a/kdb-web/src/app/modules/view/server/auto-role/components/auto-roles-rules/auto-roles-rules.component.spec.ts b/web/src/app/modules/view/server/auto-role/components/auto-roles-rules/auto-roles-rules.component.spec.ts similarity index 100% rename from kdb-web/src/app/modules/view/server/auto-role/components/auto-roles-rules/auto-roles-rules.component.spec.ts rename to web/src/app/modules/view/server/auto-role/components/auto-roles-rules/auto-roles-rules.component.spec.ts diff --git a/kdb-web/src/app/modules/view/server/auto-role/components/auto-roles-rules/auto-roles-rules.component.ts b/web/src/app/modules/view/server/auto-role/components/auto-roles-rules/auto-roles-rules.component.ts similarity index 100% rename from kdb-web/src/app/modules/view/server/auto-role/components/auto-roles-rules/auto-roles-rules.component.ts rename to web/src/app/modules/view/server/auto-role/components/auto-roles-rules/auto-roles-rules.component.ts diff --git a/kdb-web/src/app/modules/view/server/auto-role/components/auto-roles/auto-roles.component.html b/web/src/app/modules/view/server/auto-role/components/auto-roles/auto-roles.component.html similarity index 100% rename from kdb-web/src/app/modules/view/server/auto-role/components/auto-roles/auto-roles.component.html rename to web/src/app/modules/view/server/auto-role/components/auto-roles/auto-roles.component.html diff --git a/kdb-web/src/app/modules/view/server/auto-role/components/auto-roles/auto-roles.component.scss b/web/src/app/modules/view/server/auto-role/components/auto-roles/auto-roles.component.scss similarity index 100% rename from kdb-web/src/app/modules/view/server/auto-role/components/auto-roles/auto-roles.component.scss rename to web/src/app/modules/view/server/auto-role/components/auto-roles/auto-roles.component.scss diff --git a/kdb-web/src/app/modules/view/server/auto-role/components/auto-roles/auto-roles.component.spec.ts b/web/src/app/modules/view/server/auto-role/components/auto-roles/auto-roles.component.spec.ts similarity index 100% rename from kdb-web/src/app/modules/view/server/auto-role/components/auto-roles/auto-roles.component.spec.ts rename to web/src/app/modules/view/server/auto-role/components/auto-roles/auto-roles.component.spec.ts diff --git a/kdb-web/src/app/modules/view/server/auto-role/components/auto-roles/auto-roles.component.ts b/web/src/app/modules/view/server/auto-role/components/auto-roles/auto-roles.component.ts similarity index 100% rename from kdb-web/src/app/modules/view/server/auto-role/components/auto-roles/auto-roles.component.ts rename to web/src/app/modules/view/server/auto-role/components/auto-roles/auto-roles.component.ts diff --git a/kdb-web/src/app/modules/view/server/config/components/config/config.component.html b/web/src/app/modules/view/server/config/components/config/config.component.html similarity index 89% rename from kdb-web/src/app/modules/view/server/config/components/config/config.component.html rename to web/src/app/modules/view/server/config/components/config/config.component.html index d21e71f9..8bc387f3 100644 --- a/kdb-web/src/app/modules/view/server/config/components/config/config.component.html +++ b/web/src/app/modules/view/server/config/components/config/config.component.html @@ -82,6 +82,14 @@
+
+
+
{{'view.server.config.bot.xp_for_birthday' | translate}}:
+
+
+
+
{{'view.server.config.bot.afk_command_channel_id' | translate}}:
@@ -130,6 +138,14 @@
+
+
+
{{'view.server.config.bot.game_offer_notification_chat_id' | translate}}:
+ +
+
+
diff --git a/kdb-web/src/app/modules/view/server/config/components/config/config.component.scss b/web/src/app/modules/view/server/config/components/config/config.component.scss similarity index 100% rename from kdb-web/src/app/modules/view/server/config/components/config/config.component.scss rename to web/src/app/modules/view/server/config/components/config/config.component.scss diff --git a/kdb-web/src/app/modules/view/server/config/components/config/config.component.spec.ts b/web/src/app/modules/view/server/config/components/config/config.component.spec.ts similarity index 100% rename from kdb-web/src/app/modules/view/server/config/components/config/config.component.spec.ts rename to web/src/app/modules/view/server/config/components/config/config.component.spec.ts diff --git a/kdb-web/src/app/modules/view/server/config/components/config/config.component.ts b/web/src/app/modules/view/server/config/components/config/config.component.ts similarity index 97% rename from kdb-web/src/app/modules/view/server/config/components/config/config.component.ts rename to web/src/app/modules/view/server/config/components/config/config.component.ts index 0a41f365..0c39cd02 100644 --- a/kdb-web/src/app/modules/view/server/config/components/config/config.component.ts +++ b/web/src/app/modules/view/server/config/components/config/config.component.ts @@ -118,12 +118,14 @@ export class ConfigComponent implements OnInit { xpPerOntimeHour: this.config.xpPerOntimeHour, xpPerEventParticipation: this.config.xpPerEventParticipation, xpPerAchievement: this.config.xpPerAchievement, + xpForBirthday: this.config.xpForBirthday, afkCommandChannelId: this.config.afkCommandChannelId, helpVoiceChannelId: this.config.helpVoiceChannelId, teamChannelId: this.config.teamChannelId, loginMessageChannelId: this.config.loginMessageChannelId, defaultRoleId: this.config.defaultRoleId, shortRoleNameOnlySetHighestRole: this.config.shortRoleNameOnlySetHighestRole, + gameOfferNotificationChatId: this.config.gameOfferNotificationChatId, featureFlags: this.config.featureFlags, afkChannelIds: this.config.afkChannelIds, moderatorRoleIds: this.config.moderatorRoleIds, diff --git a/kdb-web/src/app/modules/view/server/config/config-routing.module.ts b/web/src/app/modules/view/server/config/config-routing.module.ts similarity index 100% rename from kdb-web/src/app/modules/view/server/config/config-routing.module.ts rename to web/src/app/modules/view/server/config/config-routing.module.ts diff --git a/kdb-web/src/app/modules/view/server/config/config.module.ts b/web/src/app/modules/view/server/config/config.module.ts similarity index 100% rename from kdb-web/src/app/modules/view/server/config/config.module.ts rename to web/src/app/modules/view/server/config/config.module.ts diff --git a/kdb-web/src/app/modules/view/server/levels/components/levels/levels.component.html b/web/src/app/modules/view/server/levels/components/levels/levels.component.html similarity index 100% rename from kdb-web/src/app/modules/view/server/levels/components/levels/levels.component.html rename to web/src/app/modules/view/server/levels/components/levels/levels.component.html diff --git a/kdb-web/src/app/modules/view/server/levels/components/levels/levels.component.scss b/web/src/app/modules/view/server/levels/components/levels/levels.component.scss similarity index 100% rename from kdb-web/src/app/modules/view/server/levels/components/levels/levels.component.scss rename to web/src/app/modules/view/server/levels/components/levels/levels.component.scss diff --git a/kdb-web/src/app/modules/view/server/levels/components/levels/levels.component.spec.ts b/web/src/app/modules/view/server/levels/components/levels/levels.component.spec.ts similarity index 100% rename from kdb-web/src/app/modules/view/server/levels/components/levels/levels.component.spec.ts rename to web/src/app/modules/view/server/levels/components/levels/levels.component.spec.ts diff --git a/kdb-web/src/app/modules/view/server/levels/components/levels/levels.component.ts b/web/src/app/modules/view/server/levels/components/levels/levels.component.ts similarity index 100% rename from kdb-web/src/app/modules/view/server/levels/components/levels/levels.component.ts rename to web/src/app/modules/view/server/levels/components/levels/levels.component.ts diff --git a/kdb-web/src/app/modules/view/server/levels/levels-routing.module.ts b/web/src/app/modules/view/server/levels/levels-routing.module.ts similarity index 100% rename from kdb-web/src/app/modules/view/server/levels/levels-routing.module.ts rename to web/src/app/modules/view/server/levels/levels-routing.module.ts diff --git a/kdb-web/src/app/modules/view/server/levels/levels.module.ts b/web/src/app/modules/view/server/levels/levels.module.ts similarity index 100% rename from kdb-web/src/app/modules/view/server/levels/levels.module.ts rename to web/src/app/modules/view/server/levels/levels.module.ts diff --git a/kdb-web/src/app/modules/view/server/members/members.component.html b/web/src/app/modules/view/server/members/members.component.html similarity index 97% rename from kdb-web/src/app/modules/view/server/members/members.component.html rename to web/src/app/modules/view/server/members/members.component.html index 1054f688..ba4baabd 100644 --- a/kdb-web/src/app/modules/view/server/members/members.component.html +++ b/web/src/app/modules/view/server/members/members.component.html @@ -72,10 +72,10 @@ - +
{{'common.level' | translate}}
- +
@@ -204,7 +204,7 @@ {{'common.level' | translate}}: - + {{member.level.name}} diff --git a/kdb-web/src/app/modules/view/server/members/members.component.scss b/web/src/app/modules/view/server/members/members.component.scss similarity index 100% rename from kdb-web/src/app/modules/view/server/members/members.component.scss rename to web/src/app/modules/view/server/members/members.component.scss diff --git a/kdb-web/src/app/modules/view/server/members/members.component.spec.ts b/web/src/app/modules/view/server/members/members.component.spec.ts similarity index 100% rename from kdb-web/src/app/modules/view/server/members/members.component.spec.ts rename to web/src/app/modules/view/server/members/members.component.spec.ts diff --git a/kdb-web/src/app/modules/view/server/members/members.component.ts b/web/src/app/modules/view/server/members/members.component.ts similarity index 100% rename from kdb-web/src/app/modules/view/server/members/members.component.ts rename to web/src/app/modules/view/server/members/members.component.ts diff --git a/web/src/app/modules/view/server/profile/profile.component.html b/web/src/app/modules/view/server/profile/profile.component.html new file mode 100644 index 00000000..43cca8b0 --- /dev/null +++ b/web/src/app/modules/view/server/profile/profile.component.html @@ -0,0 +1,299 @@ +

+ {{'view.server.profile.header' | translate}} +

+
+
+

+ {{user.name}} +

+
+ +
+
+
+
{{'common.id' | translate}}:
+
{{user.id}}
+
+
+
{{'common.discord_id' | translate}}:
+
{{user.discordId}}
+
+
+ +
+
+
{{'view.server.profile.name' | translate}}:
+
{{user.name}}
+
+
+ +
+
+
{{'view.server.profile.xp' | translate}}:
+
{{user.xp}}
+
+
+
+ +
+
+
{{'view.server.profile.message_count' | translate}}:
+
{{user.messageCount}}
+
+
+ +
+
+
{{'view.server.profile.reaction_count' | translate}}:
+
{{user.reactionCount}}
+
+
+ +
+
+
{{'view.server.profile.birthday' | translate}}:
+
{{user.birthday}}
+
+ +
+
+
+ +
+
+
{{'view.server.profile.ontime' | translate}}:
+
{{user.ontime}}
+
+
+ +
+
+
{{'view.server.profile.level' | translate}}:
+
{{user.level?.name}}
+
+ + +
+
+
+ +
+
+
{{'view.server.profile.left_server' | translate}}:
+
{{user.leftServer | bool}}
+
+
+ +
+
+
{{'common.created_at' | translate}}:
+
{{user.createdAt | date:'dd.MM.yyyy HH:mm:ss'}}
+
+
+ +
+
+
{{'common.modified_at' | translate}}:
+
{{user.modifiedAt | date:'dd.MM.yyyy HH:mm:ss'}}
+
+
+ +
+
+ + +
+
+
+

{{'common.user_warnings' | translate}}

+
+
+
+ +
+
+
+ + + +
+
{{'common.description' | translate}}
+
+ + + +
+
{{'common.author' | translate}}
+
+ + + +
+
{{'common.created_at' | translate}}
+
+ + + +
+
{{'common.actions' | translate}}
+
+ + +
+ + + + + + + + + {{value.description}} + + + + + + + {{value.author?.name}} + + + {{value.author?.name}} + + + + + + {{'common.created_at' | translate}}: + + + {{value.createdAt | date:'dd.MM.yy HH:mm'}} + + + {{value.createdAt | date:'dd.MM.yy HH:mm'}} + + + + +
+ + + + +
+ + +
+
+
+
+ +
+ + +
+
+
+
{{'common.name' | translate}}:
+
{{achievement.name}}
+
+ +
+
{{'common.description' | translate}}:
+
{{achievement.description}}
+
+ +
+
{{'view.server.profile.achievements.time' | translate}}:
+
{{achievement.createdAt | date:'dd.MM.yyyy HH:mm:ss'}}
+
+
+
+
+ + +
+
+
+
{{'view.server.profile.joined_voice_channel.time' | translate}}:
+
{{join.time}} {{'general.hours' | translate}}
+
+ +
+
{{'view.server.profile.joined_voice_channel.channel' | translate}}:
+
{{join.channelName}}
+
+ +
+
{{'common.joined_at' | translate}}:
+
{{join.joinedOn | date:'dd.MM.yyyy HH:mm:ss'}}
+
+ +
+
{{'common.leaved_at' | translate}}:
+
{{join.leavedOn | date:'dd.MM.yyyy HH:mm:ss'}}
+
+
+
+
+ + +
+
+
+
{{'view.server.profile.joined_game_server.time' | translate}}:
+
{{join.time}} {{'general.hours' | translate}}
+
+ +
+
{{'view.server.profile.joined_game_server.name' | translate}}:
+
{{join.gameServer}}
+
+ +
+
{{'common.joined_at' | translate}}:
+
{{join.joinedOn | date:'dd.MM.yyyy HH:mm:ss'}}
+
+ +
+
{{'common.leaved_at' | translate}}:
+
{{join.leavedOn | date:'dd.MM.yyyy HH:mm:ss'}}
+
+
+
+
+ + +
+
+
+
{{'common.joined_at' | translate}}:
+
{{join.joinedOn | date:'dd.MM.yyyy HH:mm:ss'}}
+
+ +
+
{{'common.leaved_at' | translate}}:
+
{{join.leavedOn | date:'dd.MM.yyyy HH:mm:ss'}}
+
+
+
+
+ +
+ +
+
+ + +
+
+
+
diff --git a/kdb-web/src/app/modules/view/server/profile/profile.component.scss b/web/src/app/modules/view/server/profile/profile.component.scss similarity index 100% rename from kdb-web/src/app/modules/view/server/profile/profile.component.scss rename to web/src/app/modules/view/server/profile/profile.component.scss diff --git a/kdb-web/src/app/modules/view/server/profile/profile.component.spec.ts b/web/src/app/modules/view/server/profile/profile.component.spec.ts similarity index 100% rename from kdb-web/src/app/modules/view/server/profile/profile.component.spec.ts rename to web/src/app/modules/view/server/profile/profile.component.spec.ts diff --git a/web/src/app/modules/view/server/profile/profile.component.ts b/web/src/app/modules/view/server/profile/profile.component.ts new file mode 100644 index 00000000..6625f101 --- /dev/null +++ b/web/src/app/modules/view/server/profile/profile.component.ts @@ -0,0 +1,244 @@ +import { Component, OnDestroy, OnInit } from "@angular/core"; +import { ActivatedRoute, Router } from "@angular/router"; +import { Queries } from "../../../../models/graphql/queries.model"; +import { LevelListQuery, Query, UserListQuery, UserWarningQuery } from "../../../../models/graphql/query.model"; +import { SpinnerService } from "../../../../services/spinner/spinner.service"; +import { DataService } from "../../../../services/data/data.service"; +import { User } from "../../../../models/data/user.model"; +import { UserDTO } from "../../../../models/auth/auth-user.dto"; +import { AuthService } from "src/app/services/auth/auth.service"; +import { ToastService } from "src/app/services/toast/toast.service"; +import { TranslateService } from "@ngx-translate/core"; +import { Server } from "../../../../models/data/server.model"; +import { forkJoin, Subject, throwError } from "rxjs"; +import { catchError, takeUntil } from "rxjs/operators"; +import { Table } from "primeng/table"; +import { UpdateUserMutationResult } from "../../../../models/graphql/result.model"; +import { Mutations } from "../../../../models/graphql/mutations.model"; +import { MenuItem } from "primeng/api"; +import { UserWarning } from "../../../../models/data/user_warning.model"; +import moment from "moment"; + +@Component({ + selector: "app-profile", + templateUrl: "./profile.component.html", + styleUrls: ["./profile.component.scss"] +}) +export class ProfileComponent implements OnInit, OnDestroy { + + user: User = { createdAt: "", modifiedAt: "" }; + levels!: MenuItem[]; + private server: Server = {}; + private author?: UserDTO; + private clonedUserWarnings: UserWarning[] = []; + public isEditingNewUserWarning: boolean = false; + public isEditing: boolean = false; + public isModerator: boolean = false; + + private unsubscriber = new Subject(); + + constructor( + private route: ActivatedRoute, + private router: Router, + private spinner: SpinnerService, + private data: DataService, + private auth: AuthService, + private toast: ToastService, + private translate: TranslateService, + private toastService: ToastService + ) { + } + + public ngOnInit(): void { + this.isEditing = false; + this.loadProfile(); + } + + private loadProfile() { + this.route.params.pipe(takeUntil(this.unsubscriber)).subscribe(params => { + this.data.getServerFromRoute(this.route).then(async (server) => { + if (!params["memberId"] || params["memberId"] == "undefined") { + await this.router.navigate([`/server/${server.id}`]); + return; + } + this.server = server; + + this.data.query(Queries.levelQuery, { + serverId: server.id + }, + (data: Query) => { + return data.servers[0]; + } + ).subscribe(data => { + this.levels = data.levels.map(level => { + return { label: level.name, value: level }; + }); + }); + + let authUser = await this.auth.getLoggedInUser(); + this.spinner.showSpinner(); + let user: UserDTO | null = authUser?.users?.find(u => u.server == server.id) ?? null; + if (!user || user?.id != params["memberId"] && !user?.isModerator) { + this.toast.error(this.translate.instant("view.server.profile.permission_denied"), this.translate.instant("view.server.profile.permission_denied_d")); + this.spinner.hideSpinner(); + await this.router.navigate(["/server", server.id]); + return; + } + this.author = user; + this.isModerator = user?.isModerator; + + this.data.query(Queries.userProfile, { + serverId: this.server.id, + userId: params["memberId"] + } + ).subscribe(users => { + if (!users.users[0]) { + this.router.navigate([`/server/${server.id}`]); + } + this.user = users.users[0]; + + this.data.query(Queries.userProfileWarnings, { + serverId: this.server.id, + userId: this.user.id + }, + (data: UserListQuery) => { + return data.users[0]; + } + ).subscribe(result => { + this.user.userWarningCount = result.userWarningCount; + this.user.userWarnings = result.userWarnings; + + this.spinner.hideSpinner(); + }); + }); + }); + }); + } + + public toogleEditUser() { + this.isEditing = !this.isEditing; + } + + public updateUser() { + this.spinner.showSpinner(); + this.data.mutation(Mutations.updateUser, { + id: this.user.id, + xp: this.user.xp, + birthday: moment(this.user.birthday).format("DD.MM.YYYY"), + levelId: this.user.level?.id, + userWarnings: this.user.userWarnings?.map(userWarning => { + return { + id: userWarning.id, + user: userWarning.user?.id ?? this.user.id, + description: userWarning.description, + author: userWarning.author?.id ?? this.author?.id + }; + }) + } + ).pipe(catchError(err => { + this.spinner.hideSpinner(); + this.isEditing = false; + return throwError(err); + })).subscribe(_ => { + this.spinner.hideSpinner(); + this.toastService.success(this.translate.instant("view.server.members.message.user_changed"), this.translate.instant("view.server.members.message.user_changed_d", { name: this.user.name })); + this.isEditing = false; + this.loadProfile(); + }); + } + + public ngOnDestroy(): void { + this.unsubscriber.next(); + this.unsubscriber.complete(); + } + + public onBeforeToggle(event: Event, collapsed: boolean) { + const filterUser = (x: { users: User[] }) => { + const users = x.users ?? []; + return users[0]; + }; + + if (collapsed) { + this.spinner.showSpinner(); + forkJoin([ + this.data.query(Queries.userProfileAchievements, { + serverId: this.server.id, + userId: this.user.id + }, + filterUser + ), + this.data.query(Queries.userProfileVoiceChannelJoins, { + serverId: this.server.id, + userId: this.user.id + }, + filterUser + ), + this.data.query(Queries.userProfileGameserverJoins, { + serverId: this.server.id, + userId: this.user.id + }, + filterUser + ) + ]).subscribe(data => { + this.user.achievementCount = data[0].achievementCount; + this.user.achievements = data[0].achievements; + + this.user.joinedVoiceChannelCount = data[1].joinedVoiceChannelCount; + this.user.joinedVoiceChannels = data[1].joinedVoiceChannels; + + this.user.userJoinedGameServerCount = data[2].userJoinedGameServerCount; + this.user.userJoinedGameServers = data[2].userJoinedGameServers; + this.spinner.hideSpinner(); + }); + return; + } + this.user.achievementCount = 0; + this.user.achievements = []; + + this.user.userJoinedGameServerCount = 0; + this.user.userJoinedGameServers = []; + + this.user.joinedVoiceChannelCount = 0; + this.user.joinedVoiceChannels = []; + } + + public addNewUserWarning(table: Table) { + const newWarning: UserWarning = { + description: "", + user: this.user + }; + + this.user.userWarnings = [newWarning, ...this.user.userWarnings ?? []]; + + table.initRowEdit(newWarning); + + const index = this.user.userWarnings.findIndex(l => l.id == newWarning.id); + this.onRowEditInit(table, newWarning, index); + + this.isEditingNewUserWarning = true; + } + + public onRowEditInit(table: Table, user: User, index: number): void { + this.clonedUserWarnings[index] = { ...user }; + } + + public deleteUserWarning(index: number) { + this.user.userWarnings?.splice(index, 1); + } + + public editSaveUserWarning(value: any, index: number) { + this.isEditingNewUserWarning = false; + if (!value.value || !this.user.userWarnings || this.user.userWarnings[index] == this.clonedUserWarnings[index]) { + return; + } + + delete this.clonedUserWarnings[index]; + } + + public editCancelUserWarning(index: number) { + if (this.user.userWarnings) { + this.user.userWarnings[index] = this.clonedUserWarnings[index]; + } + delete this.clonedUserWarnings[index]; + } +} diff --git a/kdb-web/src/app/modules/view/server/server-dashboard/components/client/client.component.html b/web/src/app/modules/view/server/server-dashboard/components/client/client.component.html similarity index 100% rename from kdb-web/src/app/modules/view/server/server-dashboard/components/client/client.component.html rename to web/src/app/modules/view/server/server-dashboard/components/client/client.component.html diff --git a/kdb-web/src/app/modules/view/server/server-dashboard/components/client/client.component.scss b/web/src/app/modules/view/server/server-dashboard/components/client/client.component.scss similarity index 100% rename from kdb-web/src/app/modules/view/server/server-dashboard/components/client/client.component.scss rename to web/src/app/modules/view/server/server-dashboard/components/client/client.component.scss diff --git a/kdb-web/src/app/modules/view/server/server-dashboard/components/client/client.component.spec.ts b/web/src/app/modules/view/server/server-dashboard/components/client/client.component.spec.ts similarity index 100% rename from kdb-web/src/app/modules/view/server/server-dashboard/components/client/client.component.spec.ts rename to web/src/app/modules/view/server/server-dashboard/components/client/client.component.spec.ts diff --git a/kdb-web/src/app/modules/view/server/server-dashboard/components/client/client.component.ts b/web/src/app/modules/view/server/server-dashboard/components/client/client.component.ts similarity index 100% rename from kdb-web/src/app/modules/view/server/server-dashboard/components/client/client.component.ts rename to web/src/app/modules/view/server/server-dashboard/components/client/client.component.ts diff --git a/kdb-web/src/app/modules/view/server/server-dashboard/server-dashboard.component.html b/web/src/app/modules/view/server/server-dashboard/server-dashboard.component.html similarity index 100% rename from kdb-web/src/app/modules/view/server/server-dashboard/server-dashboard.component.html rename to web/src/app/modules/view/server/server-dashboard/server-dashboard.component.html diff --git a/kdb-web/src/app/modules/view/server/server-dashboard/server-dashboard.component.scss b/web/src/app/modules/view/server/server-dashboard/server-dashboard.component.scss similarity index 100% rename from kdb-web/src/app/modules/view/server/server-dashboard/server-dashboard.component.scss rename to web/src/app/modules/view/server/server-dashboard/server-dashboard.component.scss diff --git a/kdb-web/src/app/modules/view/server/server-dashboard/server-dashboard.component.spec.ts b/web/src/app/modules/view/server/server-dashboard/server-dashboard.component.spec.ts similarity index 100% rename from kdb-web/src/app/modules/view/server/server-dashboard/server-dashboard.component.spec.ts rename to web/src/app/modules/view/server/server-dashboard/server-dashboard.component.spec.ts diff --git a/kdb-web/src/app/modules/view/server/server-dashboard/server-dashboard.component.ts b/web/src/app/modules/view/server/server-dashboard/server-dashboard.component.ts similarity index 100% rename from kdb-web/src/app/modules/view/server/server-dashboard/server-dashboard.component.ts rename to web/src/app/modules/view/server/server-dashboard/server-dashboard.component.ts diff --git a/kdb-web/src/app/modules/view/server/server-routing.module.ts b/web/src/app/modules/view/server/server-routing.module.ts similarity index 100% rename from kdb-web/src/app/modules/view/server/server-routing.module.ts rename to web/src/app/modules/view/server/server-routing.module.ts diff --git a/web/src/app/modules/view/server/server.module.ts b/web/src/app/modules/view/server/server.module.ts new file mode 100644 index 00000000..5ac78d1c --- /dev/null +++ b/web/src/app/modules/view/server/server.module.ts @@ -0,0 +1,24 @@ +import { NgModule } from "@angular/core"; +import { CommonModule } from "@angular/common"; +import { ServerDashboardComponent } from "./server-dashboard/server-dashboard.component"; +import { ServerRoutingModule } from "./server-routing.module"; +import { SharedModule } from "../../shared/shared.module"; +import { ProfileComponent } from "./profile/profile.component"; +import { MembersComponent } from "./members/members.component"; +import { ClientComponent } from "./server-dashboard/components/client/client.component"; + + +@NgModule({ + declarations: [ + ServerDashboardComponent, + ProfileComponent, + MembersComponent, + ClientComponent, + ], + imports: [ + CommonModule, + ServerRoutingModule, + SharedModule + ] +}) +export class ServerModule { } diff --git a/kdb-web/src/app/modules/view/server/short-role-name/components/short-role-names/short-role-names.component.html b/web/src/app/modules/view/server/short-role-name/components/short-role-names/short-role-names.component.html similarity index 100% rename from kdb-web/src/app/modules/view/server/short-role-name/components/short-role-names/short-role-names.component.html rename to web/src/app/modules/view/server/short-role-name/components/short-role-names/short-role-names.component.html diff --git a/kdb-web/src/app/modules/view/server/short-role-name/components/short-role-names/short-role-names.component.scss b/web/src/app/modules/view/server/short-role-name/components/short-role-names/short-role-names.component.scss similarity index 100% rename from kdb-web/src/app/modules/view/server/short-role-name/components/short-role-names/short-role-names.component.scss rename to web/src/app/modules/view/server/short-role-name/components/short-role-names/short-role-names.component.scss diff --git a/kdb-web/src/app/modules/view/server/short-role-name/components/short-role-names/short-role-names.component.spec.ts b/web/src/app/modules/view/server/short-role-name/components/short-role-names/short-role-names.component.spec.ts similarity index 100% rename from kdb-web/src/app/modules/view/server/short-role-name/components/short-role-names/short-role-names.component.spec.ts rename to web/src/app/modules/view/server/short-role-name/components/short-role-names/short-role-names.component.spec.ts diff --git a/kdb-web/src/app/modules/view/server/short-role-name/components/short-role-names/short-role-names.component.ts b/web/src/app/modules/view/server/short-role-name/components/short-role-names/short-role-names.component.ts similarity index 100% rename from kdb-web/src/app/modules/view/server/short-role-name/components/short-role-names/short-role-names.component.ts rename to web/src/app/modules/view/server/short-role-name/components/short-role-names/short-role-names.component.ts diff --git a/kdb-web/src/app/modules/view/server/short-role-name/short-role-name-routing.module.ts b/web/src/app/modules/view/server/short-role-name/short-role-name-routing.module.ts similarity index 100% rename from kdb-web/src/app/modules/view/server/short-role-name/short-role-name-routing.module.ts rename to web/src/app/modules/view/server/short-role-name/short-role-name-routing.module.ts diff --git a/kdb-web/src/app/modules/view/server/short-role-name/short-role-name.module.ts b/web/src/app/modules/view/server/short-role-name/short-role-name.module.ts similarity index 100% rename from kdb-web/src/app/modules/view/server/short-role-name/short-role-name.module.ts rename to web/src/app/modules/view/server/short-role-name/short-role-name.module.ts diff --git a/kdb-web/src/app/modules/view/user-settings/components/user-settings/user-settings.component.html b/web/src/app/modules/view/user-settings/components/user-settings/user-settings.component.html similarity index 100% rename from kdb-web/src/app/modules/view/user-settings/components/user-settings/user-settings.component.html rename to web/src/app/modules/view/user-settings/components/user-settings/user-settings.component.html diff --git a/kdb-web/src/app/modules/view/user-settings/components/user-settings/user-settings.component.scss b/web/src/app/modules/view/user-settings/components/user-settings/user-settings.component.scss similarity index 100% rename from kdb-web/src/app/modules/view/user-settings/components/user-settings/user-settings.component.scss rename to web/src/app/modules/view/user-settings/components/user-settings/user-settings.component.scss diff --git a/kdb-web/src/app/modules/view/user-settings/components/user-settings/user-settings.component.spec.ts b/web/src/app/modules/view/user-settings/components/user-settings/user-settings.component.spec.ts similarity index 100% rename from kdb-web/src/app/modules/view/user-settings/components/user-settings/user-settings.component.spec.ts rename to web/src/app/modules/view/user-settings/components/user-settings/user-settings.component.spec.ts diff --git a/kdb-web/src/app/modules/view/user-settings/components/user-settings/user-settings.component.ts b/web/src/app/modules/view/user-settings/components/user-settings/user-settings.component.ts similarity index 100% rename from kdb-web/src/app/modules/view/user-settings/components/user-settings/user-settings.component.ts rename to web/src/app/modules/view/user-settings/components/user-settings/user-settings.component.ts diff --git a/kdb-web/src/app/modules/view/user-settings/user-settings-routing.module.ts b/web/src/app/modules/view/user-settings/user-settings-routing.module.ts similarity index 100% rename from kdb-web/src/app/modules/view/user-settings/user-settings-routing.module.ts rename to web/src/app/modules/view/user-settings/user-settings-routing.module.ts diff --git a/kdb-web/src/app/modules/view/user-settings/user-settings.module.ts b/web/src/app/modules/view/user-settings/user-settings.module.ts similarity index 100% rename from kdb-web/src/app/modules/view/user-settings/user-settings.module.ts rename to web/src/app/modules/view/user-settings/user-settings.module.ts diff --git a/kdb-web/src/app/services/auth/auth.service.spec.ts b/web/src/app/services/auth/auth.service.spec.ts similarity index 100% rename from kdb-web/src/app/services/auth/auth.service.spec.ts rename to web/src/app/services/auth/auth.service.spec.ts diff --git a/kdb-web/src/app/services/auth/auth.service.ts b/web/src/app/services/auth/auth.service.ts similarity index 100% rename from kdb-web/src/app/services/auth/auth.service.ts rename to web/src/app/services/auth/auth.service.ts diff --git a/kdb-web/src/app/services/confirmation-dialog/confirmation-dialog.service.spec.ts b/web/src/app/services/confirmation-dialog/confirmation-dialog.service.spec.ts similarity index 100% rename from kdb-web/src/app/services/confirmation-dialog/confirmation-dialog.service.spec.ts rename to web/src/app/services/confirmation-dialog/confirmation-dialog.service.spec.ts diff --git a/kdb-web/src/app/services/confirmation-dialog/confirmation-dialog.service.ts b/web/src/app/services/confirmation-dialog/confirmation-dialog.service.ts similarity index 100% rename from kdb-web/src/app/services/confirmation-dialog/confirmation-dialog.service.ts rename to web/src/app/services/confirmation-dialog/confirmation-dialog.service.ts diff --git a/kdb-web/src/app/services/data/data.service.spec.ts b/web/src/app/services/data/data.service.spec.ts similarity index 100% rename from kdb-web/src/app/services/data/data.service.spec.ts rename to web/src/app/services/data/data.service.spec.ts diff --git a/kdb-web/src/app/services/data/data.service.ts b/web/src/app/services/data/data.service.ts similarity index 100% rename from kdb-web/src/app/services/data/data.service.ts rename to web/src/app/services/data/data.service.ts diff --git a/kdb-web/src/app/services/error-handler/error-handler.service.spec.ts b/web/src/app/services/error-handler/error-handler.service.spec.ts similarity index 100% rename from kdb-web/src/app/services/error-handler/error-handler.service.spec.ts rename to web/src/app/services/error-handler/error-handler.service.spec.ts diff --git a/kdb-web/src/app/services/error-handler/error-handler.service.ts b/web/src/app/services/error-handler/error-handler.service.ts similarity index 100% rename from kdb-web/src/app/services/error-handler/error-handler.service.ts rename to web/src/app/services/error-handler/error-handler.service.ts diff --git a/kdb-web/src/app/services/gui/gui.service.spec.ts b/web/src/app/services/gui/gui.service.spec.ts similarity index 100% rename from kdb-web/src/app/services/gui/gui.service.spec.ts rename to web/src/app/services/gui/gui.service.spec.ts diff --git a/kdb-web/src/app/services/gui/gui.service.ts b/web/src/app/services/gui/gui.service.ts similarity index 100% rename from kdb-web/src/app/services/gui/gui.service.ts rename to web/src/app/services/gui/gui.service.ts diff --git a/kdb-web/src/app/services/server.service.spec.ts b/web/src/app/services/server.service.spec.ts similarity index 100% rename from kdb-web/src/app/services/server.service.spec.ts rename to web/src/app/services/server.service.spec.ts diff --git a/kdb-web/src/app/services/server.service.ts b/web/src/app/services/server.service.ts similarity index 100% rename from kdb-web/src/app/services/server.service.ts rename to web/src/app/services/server.service.ts diff --git a/kdb-web/src/app/services/settings/settings.service.spec.ts b/web/src/app/services/settings/settings.service.spec.ts similarity index 100% rename from kdb-web/src/app/services/settings/settings.service.spec.ts rename to web/src/app/services/settings/settings.service.spec.ts diff --git a/kdb-web/src/app/services/settings/settings.service.ts b/web/src/app/services/settings/settings.service.ts similarity index 100% rename from kdb-web/src/app/services/settings/settings.service.ts rename to web/src/app/services/settings/settings.service.ts diff --git a/kdb-web/src/app/services/sidebar/sidebar.service.spec.ts b/web/src/app/services/sidebar/sidebar.service.spec.ts similarity index 100% rename from kdb-web/src/app/services/sidebar/sidebar.service.spec.ts rename to web/src/app/services/sidebar/sidebar.service.spec.ts diff --git a/kdb-web/src/app/services/sidebar/sidebar.service.ts b/web/src/app/services/sidebar/sidebar.service.ts similarity index 99% rename from kdb-web/src/app/services/sidebar/sidebar.service.ts rename to web/src/app/services/sidebar/sidebar.service.ts index a416e57c..2a1f3861 100644 --- a/kdb-web/src/app/services/sidebar/sidebar.service.ts +++ b/web/src/app/services/sidebar/sidebar.service.ts @@ -194,7 +194,6 @@ export class SidebarService { let user: UserDTO | null = authUser?.users?.find(u => u.server == this.server?.id) ?? null; let isTechnician = (authUser?.users?.map(u => u.isTechnician).filter(u => u) ?? []).length > 0; let isTechnicianAndFullAccessActive = this.hasFeature("TechnicianFullAccess") && isTechnician; - console.log(this.hasFeature("TechnicianFullAccess")) if (build || this.menuItems$.value.length == 0) { await this.buildMenu(user, hasPermission, isTechnician); diff --git a/kdb-web/src/app/services/socket/socket.service.spec.ts b/web/src/app/services/socket/socket.service.spec.ts similarity index 100% rename from kdb-web/src/app/services/socket/socket.service.spec.ts rename to web/src/app/services/socket/socket.service.spec.ts diff --git a/kdb-web/src/app/services/socket/socket.service.ts b/web/src/app/services/socket/socket.service.ts similarity index 100% rename from kdb-web/src/app/services/socket/socket.service.ts rename to web/src/app/services/socket/socket.service.ts diff --git a/kdb-web/src/app/services/spinner/spinner.service.spec.ts b/web/src/app/services/spinner/spinner.service.spec.ts similarity index 100% rename from kdb-web/src/app/services/spinner/spinner.service.spec.ts rename to web/src/app/services/spinner/spinner.service.spec.ts diff --git a/kdb-web/src/app/services/spinner/spinner.service.ts b/web/src/app/services/spinner/spinner.service.ts similarity index 100% rename from kdb-web/src/app/services/spinner/spinner.service.ts rename to web/src/app/services/spinner/spinner.service.ts diff --git a/kdb-web/src/app/services/theme/theme.service.spec.ts b/web/src/app/services/theme/theme.service.spec.ts similarity index 100% rename from kdb-web/src/app/services/theme/theme.service.spec.ts rename to web/src/app/services/theme/theme.service.spec.ts diff --git a/kdb-web/src/app/services/theme/theme.service.ts b/web/src/app/services/theme/theme.service.ts similarity index 100% rename from kdb-web/src/app/services/theme/theme.service.ts rename to web/src/app/services/theme/theme.service.ts diff --git a/kdb-web/src/app/services/toast/toast.service.spec.ts b/web/src/app/services/toast/toast.service.spec.ts similarity index 100% rename from kdb-web/src/app/services/toast/toast.service.spec.ts rename to web/src/app/services/toast/toast.service.spec.ts diff --git a/kdb-web/src/app/services/toast/toast.service.ts b/web/src/app/services/toast/toast.service.ts similarity index 100% rename from kdb-web/src/app/services/toast/toast.service.ts rename to web/src/app/services/toast/toast.service.ts diff --git a/kdb-web/src/assets/config.json b/web/src/assets/config.json similarity index 100% rename from kdb-web/src/assets/config.json rename to web/src/assets/config.json diff --git a/kdb-web/src/assets/i18n/de.json b/web/src/assets/i18n/de.json similarity index 98% rename from kdb-web/src/assets/i18n/de.json rename to web/src/assets/i18n/de.json index 12b18760..ade9226c 100644 --- a/kdb-web/src/assets/i18n/de.json +++ b/web/src/assets/i18n/de.json @@ -128,6 +128,7 @@ "add": "Hinzufügen", "attribute": "Attribut", "auth_role": "Rolle", + "author": "Autor", "bool_as_string": { "false": "Nein", "true": "Ja" @@ -138,6 +139,7 @@ "created_at": "Erstellt am", "description": "Beschreibung", "discord_id": "Discord Id", + "edit": "Bearbeiten", "email": "E-Mail", "emoji": "Emoji", "error": "Fehler", @@ -192,6 +194,7 @@ "role": "Rolle", "rule_count": "Regeln", "save": "Speichern", + "user_warnings": "Verwarnungen", "users": "Benutzer", "value": "Wert", "xp": "XP" @@ -419,7 +422,7 @@ "afk_channels": "AFK Sprachkanäle", "afk_command_channel_id": "AFK Kanal für den Befehl /afk", "default_role_id": "Standardrolle des Servers", - "short_role_name_only_set_highest_role": "Bei Rollen Kürzeln nur die höchste Rolle verwenden", + "game_offer_notification_chat_id": "Benachrichtungskanal für Spiel Angebote", "header": "Bot Konfiguration", "help_voice_channel_id": "Sprachkanal für Hilfsbenachrichtung", "login_message_channel_id": "Kanal für die Nachricht vom Bot nach Start", @@ -428,7 +431,9 @@ "message_delete_timer": "Zeit bis zum löschen einer Botnachricht in sekunden", "moderator_roles": "Moderator Rollen", "notification_chat_id": "Benachrichtungskanal", + "short_role_name_only_set_highest_role": "Bei Rollen Kürzeln nur die höchste Rolle verwenden", "team_channel_id": "Team chat", + "xp_for_birthday": "XP für Geburtstag", "xp_per_achievement": "XP für Errungenschaft", "xp_per_event_participation": "XP für Event Teilnahme", "xp_per_message": "XP für eine Nachricht", @@ -486,6 +491,7 @@ "header": "Errungeschaften", "time": "Erreicht am" }, + "birthday": "Geburtstag", "header": "Dein Profil", "joined_game_server": { "header": "Gameserver-beitritte", @@ -503,11 +509,13 @@ }, "left_server": "Hat Server verlassen", "level": "Level", + "message_count": "Anzahl Nachrichten", "minecraft_id": "Minecraft Id", "name": "Name", "ontime": "Ontime", "permission_denied": "Zugriff verweigert!", "permission_denied_d": "Du musst Moderator sein, um andere Profile sehen zu können!", + "reaction_count": "Anzahl Reaktionen", "xp": "XP" }, "short_role_names": { diff --git a/kdb-web/src/assets/i18n/en.json b/web/src/assets/i18n/en.json similarity index 98% rename from kdb-web/src/assets/i18n/en.json rename to web/src/assets/i18n/en.json index ca81d078..36d7f324 100644 --- a/kdb-web/src/assets/i18n/en.json +++ b/web/src/assets/i18n/en.json @@ -128,6 +128,7 @@ "add": "Add", "attribute": "Attribute", "auth_role": "Role", + "author": "Author", "bool_as_string": { "false": "No", "true": "Yes" @@ -138,6 +139,7 @@ "created_at": "Created at", "description": "Description", "discord_id": "Discord Id", + "edit": "Edit", "email": "E-Mail", "emoji": "Emoji", "error": "Error", @@ -192,6 +194,7 @@ "role": "Role", "rule_count": "Rules", "save": "Save", + "user_warnings": "User warnings", "users": "User", "value": "Value", "xp": "XP" @@ -419,7 +422,7 @@ "afk_channels": "AFK Voicechannel", "afk_command_channel_id": "AFK Channel for the command /afk", "default_role_id": "Default role", - "short_role_name_only_set_highest_role": "For role abbreviations use only the highest role", + "game_offer_notification_chat_id": "Notification channel for game sales", "header": "Bot configuration", "help_voice_channel_id": "Voicechannel für help notifications", "login_message_channel_id": "Channel for bot message after start", @@ -428,7 +431,9 @@ "message_delete_timer": "Time to wait before delete bot messages", "moderator_roles": "Moderator roles", "notification_chat_id": "Notification channel", + "short_role_name_only_set_highest_role": "For role abbreviations use only the highest role", "team_channel_id": "Team chat", + "xp_for_birthday": "XP for birthday", "xp_per_achievement": "XP for achievement", "xp_per_event_participation": "XP for event participation", "xp_per_message": "XP for message", @@ -486,6 +491,7 @@ "header": "Achievements", "time": "Reached at" }, + "birthday": "Birthday", "header": "Profile", "joined_game_server": { "header": "Game server accessions", @@ -503,11 +509,13 @@ }, "left_server": "Leaved server", "level": "Level", + "message_count": "Message count", "minecraft_id": "Minecraft Id", "name": "Name", "ontime": "Ontime", "permission_denied": "Access denied!", "permission_denied_d": "You have to be moderator to see other profiles!", + "reaction_count": "Reaction count", "xp": "XP" }, "short_role_names": { diff --git a/kdb-web/src/assets/images/favicon.ico b/web/src/assets/images/favicon.ico similarity index 100% rename from kdb-web/src/assets/images/favicon.ico rename to web/src/assets/images/favicon.ico diff --git a/web/src/assets/version.json b/web/src/assets/version.json new file mode 100644 index 00000000..3ae731e3 --- /dev/null +++ b/web/src/assets/version.json @@ -0,0 +1,7 @@ +{ + "WebVersion": { + "Major": "1", + "Minor": "2", + "Micro": "0" + } +} \ No newline at end of file diff --git a/kdb-web/src/environments/environment.development.ts b/web/src/environments/environment.development.ts similarity index 100% rename from kdb-web/src/environments/environment.development.ts rename to web/src/environments/environment.development.ts diff --git a/kdb-web/src/environments/environment.prod.ts b/web/src/environments/environment.prod.ts similarity index 100% rename from kdb-web/src/environments/environment.prod.ts rename to web/src/environments/environment.prod.ts diff --git a/kdb-web/src/environments/environment.staging.ts b/web/src/environments/environment.staging.ts similarity index 100% rename from kdb-web/src/environments/environment.staging.ts rename to web/src/environments/environment.staging.ts diff --git a/kdb-web/src/environments/environment.ts b/web/src/environments/environment.ts similarity index 100% rename from kdb-web/src/environments/environment.ts rename to web/src/environments/environment.ts diff --git a/kdb-web/src/favicon.ico b/web/src/favicon.ico similarity index 100% rename from kdb-web/src/favicon.ico rename to web/src/favicon.ico diff --git a/kdb-web/src/index.html b/web/src/index.html similarity index 100% rename from kdb-web/src/index.html rename to web/src/index.html diff --git a/kdb-web/src/main.ts b/web/src/main.ts similarity index 100% rename from kdb-web/src/main.ts rename to web/src/main.ts diff --git a/kdb-web/src/polyfills.ts b/web/src/polyfills.ts similarity index 100% rename from kdb-web/src/polyfills.ts rename to web/src/polyfills.ts diff --git a/kdb-web/src/styles.scss b/web/src/styles.scss similarity index 99% rename from kdb-web/src/styles.scss rename to web/src/styles.scss index 16baf300..a9d27980 100644 --- a/kdb-web/src/styles.scss +++ b/web/src/styles.scss @@ -201,10 +201,10 @@ header { font-size: 18px; } + } - .content-divider { - margin: 5px 0; - } + .content-divider { + margin: 10px 0; } p-panel { @@ -493,7 +493,7 @@ header { } .content-divider { - margin: 5px 0; + margin: 10px 0; } .content-input-field { diff --git a/kdb-web/src/styles/constants.scss b/web/src/styles/constants.scss similarity index 100% rename from kdb-web/src/styles/constants.scss rename to web/src/styles/constants.scss diff --git a/kdb-web/src/styles/primeng-fixes.scss b/web/src/styles/primeng-fixes.scss similarity index 94% rename from kdb-web/src/styles/primeng-fixes.scss rename to web/src/styles/primeng-fixes.scss index 67f10cd6..81ad47dc 100644 --- a/kdb-web/src/styles/primeng-fixes.scss +++ b/web/src/styles/primeng-fixes.scss @@ -94,8 +94,13 @@ p-table { } } -.p-dropdown { - width: 100% !important; +.content-row { + p-dropdown, + .p-dropdown, + p-calendar, + .p-calendar, { + width: 100% !important; + } } .pi-sort-alt:before { diff --git a/kdb-web/src/styles/themes/default-dark-theme.scss b/web/src/styles/themes/default-dark-theme.scss similarity index 99% rename from kdb-web/src/styles/themes/default-dark-theme.scss rename to web/src/styles/themes/default-dark-theme.scss index e3283097..58abe55e 100644 --- a/kdb-web/src/styles/themes/default-dark-theme.scss +++ b/web/src/styles/themes/default-dark-theme.scss @@ -20,7 +20,8 @@ background-color: $primaryBackgroundColor; h1, - h2 { + h2, + h3 { color: $primaryHeaderColor; } diff --git a/kdb-web/src/styles/themes/default-light-theme.scss b/web/src/styles/themes/default-light-theme.scss similarity index 99% rename from kdb-web/src/styles/themes/default-light-theme.scss rename to web/src/styles/themes/default-light-theme.scss index 41d46599..115dff70 100644 --- a/kdb-web/src/styles/themes/default-light-theme.scss +++ b/web/src/styles/themes/default-light-theme.scss @@ -20,7 +20,8 @@ background-color: $primaryBackgroundColor; h1, - h2 { + h2, + h3 { color: $primaryHeaderColor; } diff --git a/kdb-web/src/styles/themes/sh-edraft-dark-theme.scss b/web/src/styles/themes/sh-edraft-dark-theme.scss similarity index 89% rename from kdb-web/src/styles/themes/sh-edraft-dark-theme.scss rename to web/src/styles/themes/sh-edraft-dark-theme.scss index a23b4064..827d3933 100644 --- a/kdb-web/src/styles/themes/sh-edraft-dark-theme.scss +++ b/web/src/styles/themes/sh-edraft-dark-theme.scss @@ -21,7 +21,8 @@ h1, - h2 { + h2, + h3 { color: $primaryHeaderColor; } @@ -682,4 +683,77 @@ p-inputNumber { background-color: $primaryBackgroundColor !important; } + + p-calendar > span > button { + background-color: $primaryHeaderColor !important; + border: 1px solid $primaryHeaderColor !important; + + &:focus { + box-shadow: none !important; + } + } + + .p-calendar { + .p-datepicker:not(.p-datepicker-inline) { + background-color: $secondaryBackgroundColor !important; + } + + .p-datepicker { + .p-datepicker-header { + color: $primaryHeaderColor !important; + background-color: $primaryBackgroundColor !important; + + .p-datepicker-title .p-datepicker-year, + .p-datepicker-title .p-datepicker-month, + .p-datepicker .p-datepicker-header .p-datepicker-title .p-datepicker-month { + color: $primaryTextColor !important; + + &:hover { + color: $primaryHeaderColor !important; + } + + &:focus { + box-shadow: none !important; + } + } + } + } + + table td > span { + color: $primaryTextColor !important; + + &:hover { + color: $primaryHeaderColor !important; + background-color: $primaryBackgroundColor !important; + } + + &:focus { + box-shadow: none !important; + } + } + + table td.p-datepicker-today > span { + color: $primaryHeaderColor !important; + background-color: $primaryBackgroundColor !important; + } + + table td > span.p-highlight { + color: $primaryHeaderColor !important; + background-color: $primaryBackgroundColor !important; + } + + .p-yearpicker .p-yearpicker-year, + .p-monthpicker .p-monthpicker-month:not(.p-disabled):not(.p-highlight) { + color: $primaryTextColor !important; + background-color: $secondaryBackgroundColor !important; + + &:hover { + color: $primaryHeaderColor !important; + } + + &:focus { + box-shadow: none !important; + } + } + } } diff --git a/kdb-web/src/styles/themes/sh-edraft-light-theme.scss b/web/src/styles/themes/sh-edraft-light-theme.scss similarity index 99% rename from kdb-web/src/styles/themes/sh-edraft-light-theme.scss rename to web/src/styles/themes/sh-edraft-light-theme.scss index e1191651..870fb6e0 100644 --- a/kdb-web/src/styles/themes/sh-edraft-light-theme.scss +++ b/web/src/styles/themes/sh-edraft-light-theme.scss @@ -20,7 +20,8 @@ background-color: $primaryBackgroundColor; h1, - h2 { + h2, + h3 { color: $primaryHeaderColor; } diff --git a/kdb-web/src/test.ts b/web/src/test.ts similarity index 100% rename from kdb-web/src/test.ts rename to web/src/test.ts diff --git a/kdb-web/tsconfig.app.json b/web/tsconfig.app.json similarity index 100% rename from kdb-web/tsconfig.app.json rename to web/tsconfig.app.json diff --git a/kdb-web/tsconfig.json b/web/tsconfig.json similarity index 100% rename from kdb-web/tsconfig.json rename to web/tsconfig.json diff --git a/kdb-web/tsconfig.spec.json b/web/tsconfig.spec.json similarity index 100% rename from kdb-web/tsconfig.spec.json rename to web/tsconfig.spec.json diff --git a/kdb-web/update-version.ts b/web/update-version.ts similarity index 100% rename from kdb-web/update-version.ts rename to web/update-version.ts