diff --git a/.gitea/workflows/deploy_prod.yaml b/.gitea/workflows/deploy_prod.yaml new file mode 100644 index 00000000..4406bb86 --- /dev/null +++ b/.gitea/workflows/deploy_prod.yaml @@ -0,0 +1,48 @@ +name: Deploy dev on push +run-name: Deploy dev on push +on: + push: + branches: + - master + +jobs: + on-push-deploy_sh-edraft: + runs-on: [ dobby.sh-edraft.de, ubuntu-latest ] + container: catthehacker/ubuntu:act-latest + steps: + - name: Setup Python 3.10 + uses: actions/setup-python@v3 + with: + python-version: "3.10.12" + - run: python -v + + - name: Setup docker + uses: https://github.com/papodaca/install-docker-action@main + - run: docker -v + + - name: Clone Repository + uses: https://github.com/actions/checkout@v3 + + - name: Install cpl cli + run: | + pip install --extra-index-url https://pip.sh-edraft.de cpl-cli + + - name: Install deps + run: cpl i + + - name: Build docker + run: | + docker stack rm service_observer + docker image prune -f + cpl docker-build + + - name: Deploy Stack to sh-edraft.de + uses: https://github.com/kgierke/portainer-stack-deployment@v1 + with: + portainer-url: "https://docker.sh-edraft.de" + portainer-username: "gitea_job" + portainer-password: "${{ secrets.docker_job }}" + portainer-endpoint: 2 + name: service_observer + file: ./docker-compose.yml + variables: '{}' diff --git a/.gitea/workflows/deploy_support.yaml b/.gitea/workflows/deploy_support.yaml new file mode 100644 index 00000000..f76aafcc --- /dev/null +++ b/.gitea/workflows/deploy_support.yaml @@ -0,0 +1,65 @@ +name: Deploy dev on push +run-name: Deploy dev on push +on: + push: + branches: + - support + +jobs: + on-push-deploy_sh-edraft: + runs-on: [ dobby.sh-edraft.de, ubuntu-latest ] + container: catthehacker/ubuntu:act-latest + steps: + - name: Setup Python 3.10 + uses: actions/setup-python@v3 + with: + python-version: "3.10.12" + - run: python -v + + - name: Setup docker + uses: https://github.com/papodaca/install-docker-action@main + - run: docker -v + + - name: Clone Repository + uses: https://github.com/actions/checkout@v3 + + - name: Shutdown stack + run: docker stack rm kdb_staging + + - name: Prepare bot build + run: | + cd kdb-bot + pip install --extra-index-url https://pip.sh-edraft.de cpl-cli + cpl i + + - name: Build docker bot + run: | + cd kdb-bot + docker image prune -f + cpl docker-build + + - name: Setup node + uses: https://github.com/actions/setup-node@v3 + + - name: Prepare web build + run: | + cd kdb-web + npm install -g ts-node + npm i + + - name: Build docker web + run: | + cd kdb-web + docker image prune -f + npm run docker-build + + - name: Deploy Stack to sh-edraft.de + uses: https://github.com/kgierke/portainer-stack-deployment@v1 + with: + portainer-url: "https://docker.sh-edraft.de" + portainer-username: "gitea_job" + portainer-password: "${{ secrets.docker_job }}" + portainer-endpoint: 2 + name: kdb_staging + file: ./docker-compose.staging.yml + variables: '{}' diff --git a/docker-compose.staging.yml b/docker-compose.staging.yml new file mode 100644 index 00000000..ff05cefc --- /dev/null +++ b/docker-compose.staging.yml @@ -0,0 +1,89 @@ +version: "3.9" + +volumes: + kdb_db_staging_1: + +services: + kdb_bot_staging_1: + image: sh-edraft.de/kdb-bot:1.1.6 + container_name: kdb_bot_staging_1 + depends_on: + - kdb_db_staging_1 + networks: + - kdb_test + - reverse_proxy + volumes: + - /opt/kdb/staging/bot/config:/app/bot/config + - /opt/kdb/staging/bot/api_config:/app/bot_api/config + - /opt/kdb/staging/bot/logs:/app/bot/logs + environment: + KDB_ENVIRONMENT: "staging" + KDB_TOKEN: "OTk4MTU5ODAyMzkzOTY0NTk0.G-csct.b2Y-HxvLz0SfFLl5HpukROv2GaiWhcMABbMzYE" + KDB_PREFIX: "!kt " + command: bash /app/bot/bot -stage + deploy: + mode: replicated + replicas: 1 + placement: + constraints: [ node.role == manager ] + resources: + reservations: + cpus: "0.5" + memory: 1024M + + kdb_web_staging_1: + image: sh-edraft.de/kdb-web:1.1.6 + container_name: kdb_web_staging_1 + depends_on: + - kdb_bot_staging_1 + networks: + - kdb_test + - reverse_proxy + volumes: + - /opt/kdb/staging/web/config.json:/usr/share/nginx/html/assets/config.json + environment: + BOT_CONTAINER_NAME: "kdb_bot_staging_1" + deploy: + mode: replicated + replicas: 1 + placement: + constraints: [ node.role == manager ] + resources: + limits: + cpus: "0.4" + memory: 400M + reservations: + cpus: "0.1" + memory: 20M + + kdb_db_staging_1: + image: mysql:latest + container_name: kdb_db_staging_1 + command: mysqld --default-authentication-plugin=mysql_native_password --log_bin_trust_function_creators=1 + networks: + - kdb_test + environment: + MYSQL_ROOT_PASSWORD: "kd_kdb" + MYSQL_USER: "kd_kdb" + MYSQL_PASSWORD: "~qELxjvtjJ3r7yg4PZr5!,V}d.{TC4rg" + MYSQL_DATABASE: "kd_kdb" + ports: + - "3308:3306" + volumes: + - kdb_db_staging_1:/var/lib/mysql + deploy: + mode: replicated + replicas: 1 + placement: + constraints: [ node.role == manager ] + resources: + reservations: + cpus: "0.1" + memory: 150M + +networks: + reverse_proxy: + external: true + kdb_test: + driver: overlay + attachable: true \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 00000000..ccfdb542 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,86 @@ +version: "3.9" + +volumes: + kdb_db_prod_1: + +services: + kdb_bot_prod_1: + image: sh-edraft.de/kdb-bot:1.1.6 + depends_on: + - kdb_db_prod_1 + networks: + - kdb_prod + - reverse_proxy + volumes: + - /opt/kdb/production/bot/config:/app/bot/config + - /opt/kdb/production/bot/api_config:/app/bot_api/config + - /opt/kdb/production/bot/logs:/app/bot/logs + environment: + KDB_ENVIRONMENT: "production" + KDB_TOKEN: "OTk4MTU5NTEyNDYyNzA4Nzg2.Gx0hSB.Ouq2dfRKxLBJvHfEq8OrFBHVUF24AQrVf55coM" + KDB_PREFIX: "!k " + deploy: + mode: replicated + replicas: 1 + placement: + constraints: [ node.role == manager ] + resources: + reservations: + cpus: "0.5" + memory: 1024M + + kdb_web_prod_1: + image: sh-edraft.de/kdb-web:1.1.6 + depends_on: + - kdb_bot_prod_1 + networks: + - kdb_prod + - reverse_proxy + volumes: + - /opt/kdb/production/web/config.json:/usr/share/nginx/html/assets/config.json + environment: + BOT_CONTAINER_NAME: "kdb_bot_prod_1" + deploy: + mode: replicated + replicas: 1 + placement: + constraints: [ node.role == manager ] + resources: + limits: + cpus: "0.4" + memory: 400M + reservations: + cpus: "0.1" + memory: 20M + + kdb_db_prod_1: + image: mysql:latest + command: mysqld --default-authentication-plugin=mysql_native_password --log_bin_trust_function_creators=1 + networks: + - kdb_prod + restart: unless-stopped + environment: + MYSQL_ROOT_PASSWORD: "kd_kdb" + MYSQL_USER: "kd_kdb" + MYSQL_PASSWORD: ",2#MzfN4J=7r(q,Tz3npDkCR§>VE&}7T" + MYSQL_DATABASE: "kd_kdb" + ports: + - "3307:3306" + volumes: + - kdb_db_prod_1:/var/lib/mysql + deploy: + mode: replicated + replicas: 1 + placement: + constraints: [ node.role == manager ] + resources: + reservations: + cpus: "0.1" + memory: 150M + +networks: + reverse_proxy: + external: true + kdb_prod: + driver: overlay + attachable: true \ No newline at end of file diff --git a/kdb-bot/cpl-workspace.json b/kdb-bot/cpl-workspace.json index 229bc577..29d7ef29 100644 --- a/kdb-bot/cpl-workspace.json +++ b/kdb-bot/cpl-workspace.json @@ -35,7 +35,7 @@ "stage": "export KDB_ENVIRONMENT=staging; export KDB_NAME=KDB-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 kdb-bot/kdb-bot:$(cpl gv) .;", + "docker-build": "cpl build $ARGS; docker build -t sh-edraft.de/kdb-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/src/bot/__init__.py b/kdb-bot/src/bot/__init__.py index 5a449e82..2f4dc7ca 100644 --- a/kdb-bot/src/bot/__init__.py +++ b/kdb-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.1" +__version__ = "1.1.6" 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="1") +version_info = VersionInfo(major="1", minor="1", micro="6") diff --git a/kdb-bot/src/bot/bot.json b/kdb-bot/src/bot/bot.json index d20486d7..9f0c063b 100644 --- a/kdb-bot/src/bot/bot.json +++ b/kdb-bot/src/bot/bot.json @@ -4,7 +4,7 @@ "Version": { "Major": "1", "Minor": "1", - "Micro": "1" + "Micro": "6" }, "Author": "Sven Heidemann", "AuthorEmail": "sven.heidemann@sh-edraft.de", diff --git a/kdb-bot/src/bot/extension/__init__.py b/kdb-bot/src/bot/extension/__init__.py index 158bf5b8..ab1e0d0c 100644 --- a/kdb-bot/src/bot/extension/__init__.py +++ b/kdb-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.1" +__version__ = "1.1.6" 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="1") +version_info = VersionInfo(major="1", minor="1", micro="6") diff --git a/kdb-bot/src/bot/startup_migration_extension.py b/kdb-bot/src/bot/startup_migration_extension.py index 89c5ae7d..b8f9eece 100644 --- a/kdb-bot/src/bot/startup_migration_extension.py +++ b/kdb-bot/src/bot/startup_migration_extension.py @@ -12,6 +12,7 @@ from bot_data.migration.auto_role_migration import AutoRoleMigration 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.initial_migration import InitialMigration from bot_data.migration.level_migration import LevelMigration from bot_data.migration.remove_stats_migration import RemoveStatsMigration @@ -48,3 +49,4 @@ class StartupMigrationExtension(StartupExtensionABC): services.add_transient(MigrationABC, AchievementsMigration) # 14.06.2023 #268 - 1.1.0 services.add_transient(MigrationABC, ConfigMigration) # 19.07.2023 #127 - 1.1.0 services.add_transient(MigrationABC, ConfigFeatureFlagsMigration) # 15.08.2023 #334 - 1.1.0 + services.add_transient(MigrationABC, DefaultRoleMigration) # 24.09.2023 #360 - 1.1.3 diff --git a/kdb-bot/src/bot/translation/de.json b/kdb-bot/src/bot/translation/de.json index 82842240..3ab20a64 100644 --- a/kdb-bot/src/bot/translation/de.json +++ b/kdb-bot/src/bot/translation/de.json @@ -21,6 +21,7 @@ } }, "common": { + "feature_not_activated": "Diese Funktion ist deaktiviert", "bot_has_no_permission_message": "Ey!!!\nWas soll das?\nIch habe keine Berechtigungen :(\nScheiß System...", "colors": { "blue": "Blau", @@ -170,6 +171,11 @@ "error": { "nothing_found": "Keine Gameserver gefunden." }, + "list_members": { + "title": "Mitglieder", + "description": "Konfigurierte Mitglieder:", + "users": "Mitglieder" + }, "list": { "title": "Gameserver", "description": "Konfigurierte Gameserver:", @@ -351,6 +357,7 @@ "success": "API-Schlüssel wurde entfernt :D" } }, + "synced_message": "Der Sync wurde abgeschlossen.", "log_message": "Hier sind deine Logdateien! :)", "restart_message": "Bin gleich wieder da :D", "shutdown_message": "Trauert nicht um mich, es war eine logische Entscheidung. Das Wohl von Vielen, es wiegt schwerer als das Wohl von Wenigen oder eines Einzelnen. Ich war es und ich werde es immer sein, euer Freund. Lebt lange und in Frieden :)" diff --git a/kdb-bot/src/bot_api/__init__.py b/kdb-bot/src/bot_api/__init__.py index c094b678..99edb8d3 100644 --- a/kdb-bot/src/bot_api/__init__.py +++ b/kdb-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.1" +__version__ = "1.1.6" 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="1") +version_info = VersionInfo(major="1", minor="1", micro="6") diff --git a/kdb-bot/src/bot_api/abc/__init__.py b/kdb-bot/src/bot_api/abc/__init__.py index e90eeba4..45d47bf7 100644 --- a/kdb-bot/src/bot_api/abc/__init__.py +++ b/kdb-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.1" +__version__ = "1.1.6" 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="1") +version_info = VersionInfo(major="1", minor="1", micro="6") diff --git a/kdb-bot/src/bot_api/bot-api.json b/kdb-bot/src/bot_api/bot-api.json index fbe48c5e..6f4d2c1c 100644 --- a/kdb-bot/src/bot_api/bot-api.json +++ b/kdb-bot/src/bot_api/bot-api.json @@ -4,7 +4,7 @@ "Version": { "Major": "1", "Minor": "1", - "Micro": "1" + "Micro": "6" }, "Author": "", "AuthorEmail": "", diff --git a/kdb-bot/src/bot_api/config b/kdb-bot/src/bot_api/config index 3d81c81c..b6ffed4d 160000 --- a/kdb-bot/src/bot_api/config +++ b/kdb-bot/src/bot_api/config @@ -1 +1 @@ -Subproject commit 3d81c81c9ef9b02f33b4f1a6167c67c040170d0a +Subproject commit b6ffed4da1f75f5fbad1ce7f312b67f32de010b5 diff --git a/kdb-bot/src/bot_api/configuration/__init__.py b/kdb-bot/src/bot_api/configuration/__init__.py index 7dc1694f..70de4cf2 100644 --- a/kdb-bot/src/bot_api/configuration/__init__.py +++ b/kdb-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.1" +__version__ = "1.1.6" 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="1") +version_info = VersionInfo(major="1", minor="1", micro="6") diff --git a/kdb-bot/src/bot_api/controller/__init__.py b/kdb-bot/src/bot_api/controller/__init__.py index c8cbf733..474d7841 100644 --- a/kdb-bot/src/bot_api/controller/__init__.py +++ b/kdb-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.1" +__version__ = "1.1.6" 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="1") +version_info = VersionInfo(major="1", minor="1", micro="6") diff --git a/kdb-bot/src/bot_api/event/__init__.py b/kdb-bot/src/bot_api/event/__init__.py index 67daf54c..7a3cc29f 100644 --- a/kdb-bot/src/bot_api/event/__init__.py +++ b/kdb-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.1" +__version__ = "1.1.6" 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="1") +version_info = VersionInfo(major="1", minor="1", micro="6") diff --git a/kdb-bot/src/bot_api/exception/__init__.py b/kdb-bot/src/bot_api/exception/__init__.py index b055a824..55055c27 100644 --- a/kdb-bot/src/bot_api/exception/__init__.py +++ b/kdb-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.1" +__version__ = "1.1.6" 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="1") +version_info = VersionInfo(major="1", minor="1", micro="6") diff --git a/kdb-bot/src/bot_api/filter/__init__.py b/kdb-bot/src/bot_api/filter/__init__.py index 53818430..77145c97 100644 --- a/kdb-bot/src/bot_api/filter/__init__.py +++ b/kdb-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.1" +__version__ = "1.1.6" 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="1") +version_info = VersionInfo(major="1", minor="1", micro="6") diff --git a/kdb-bot/src/bot_api/filter/discord/__init__.py b/kdb-bot/src/bot_api/filter/discord/__init__.py index c78ce4eb..38245fe3 100644 --- a/kdb-bot/src/bot_api/filter/discord/__init__.py +++ b/kdb-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.1" +__version__ = "1.1.6" 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="1") +version_info = VersionInfo(major="1", minor="1", micro="6") diff --git a/kdb-bot/src/bot_api/logging/__init__.py b/kdb-bot/src/bot_api/logging/__init__.py index dfd7a09b..fcd37e0c 100644 --- a/kdb-bot/src/bot_api/logging/__init__.py +++ b/kdb-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.1" +__version__ = "1.1.6" 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="1") +version_info = VersionInfo(major="1", minor="1", micro="6") diff --git a/kdb-bot/src/bot_api/model/__init__.py b/kdb-bot/src/bot_api/model/__init__.py index dc0b55e4..4d0b966b 100644 --- a/kdb-bot/src/bot_api/model/__init__.py +++ b/kdb-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.1" +__version__ = "1.1.6" 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="1") +version_info = VersionInfo(major="1", minor="1", micro="6") diff --git a/kdb-bot/src/bot_api/model/discord/__init__.py b/kdb-bot/src/bot_api/model/discord/__init__.py index 205b5a3b..d482dff9 100644 --- a/kdb-bot/src/bot_api/model/discord/__init__.py +++ b/kdb-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.1" +__version__ = "1.1.6" 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="1") +version_info = VersionInfo(major="1", minor="1", micro="6") diff --git a/kdb-bot/src/bot_api/route/__init__.py b/kdb-bot/src/bot_api/route/__init__.py index 3803ffbd..1e63cbc6 100644 --- a/kdb-bot/src/bot_api/route/__init__.py +++ b/kdb-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.1" +__version__ = "1.1.6" 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="1") +version_info = VersionInfo(major="1", minor="1", micro="6") diff --git a/kdb-bot/src/bot_api/service/__init__.py b/kdb-bot/src/bot_api/service/__init__.py index 6e4230d4..ba7b31ba 100644 --- a/kdb-bot/src/bot_api/service/__init__.py +++ b/kdb-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.1" +__version__ = "1.1.6" 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="1") +version_info = VersionInfo(major="1", minor="1", micro="6") diff --git a/kdb-bot/src/bot_api/service/auth_service.py b/kdb-bot/src/bot_api/service/auth_service.py index 03fe78a5..94410b52 100644 --- a/kdb-bot/src/bot_api/service/auth_service.py +++ b/kdb-bot/src/bot_api/service/auth_service.py @@ -494,8 +494,13 @@ class AuthService(AuthServiceABC): added_user = True db_user = self._auth_users.get_auth_user_by_email(user_dto.email) - if db_user.users.count() == 0: - members.for_each(lambda x: self._auth_users.add_auth_user_user_rel(AuthUserUsersRelation(db_user, x))) + user_ids = db_user.users.select(lambda x: x.id) + + for user in self._users.get_users_by_discord_id(dc_id): + if user.id in user_ids: + continue + + self._auth_users.add_auth_user_user_rel(AuthUserUsersRelation(db_user, user)) if db_user.confirmation_id is not None and not added_user: raise ServiceException(ServiceErrorCode.Forbidden, "E-Mail not verified") diff --git a/kdb-bot/src/bot_api/transformer/__init__.py b/kdb-bot/src/bot_api/transformer/__init__.py index e68ab6b3..93e08c87 100644 --- a/kdb-bot/src/bot_api/transformer/__init__.py +++ b/kdb-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.1" +__version__ = "1.1.6" 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="1") +version_info = VersionInfo(major="1", minor="1", micro="6") diff --git a/kdb-bot/src/bot_core/__init__.py b/kdb-bot/src/bot_core/__init__.py index 54924dc8..c5e0872a 100644 --- a/kdb-bot/src/bot_core/__init__.py +++ b/kdb-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.1" +__version__ = "1.1.6" 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="1") +version_info = VersionInfo(major="1", minor="1", micro="6") diff --git a/kdb-bot/src/bot_core/abc/__init__.py b/kdb-bot/src/bot_core/abc/__init__.py index f0dade7b..452f6763 100644 --- a/kdb-bot/src/bot_core/abc/__init__.py +++ b/kdb-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.1" +__version__ = "1.1.6" 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="1") +version_info = VersionInfo(major="1", minor="1", micro="6") diff --git a/kdb-bot/src/bot_core/abc/client_utils_abc.py b/kdb-bot/src/bot_core/abc/client_utils_abc.py index ecb67321..045228cb 100644 --- a/kdb-bot/src/bot_core/abc/client_utils_abc.py +++ b/kdb-bot/src/bot_core/abc/client_utils_abc.py @@ -1,6 +1,6 @@ from abc import ABC, abstractmethod from datetime import datetime -from typing import Callable +from typing import Callable, Union import discord from cpl_query.extension import List @@ -67,3 +67,7 @@ class ClientUtilsABC(ABC): self, discord_channel_id: int, discord_message_id: int, rule: AutoRoleRule, guild: discord.Guild ): pass + + @abstractmethod + async def check_default_role(self, member: Union[discord.User, discord.Member]): + pass diff --git a/kdb-bot/src/bot_core/bot-core.json b/kdb-bot/src/bot_core/bot-core.json index d33fcd76..384e8c4b 100644 --- a/kdb-bot/src/bot_core/bot-core.json +++ b/kdb-bot/src/bot_core/bot-core.json @@ -4,7 +4,7 @@ "Version": { "Major": "1", "Minor": "1", - "Micro": "1" + "Micro": "6" }, "Author": "Sven Heidemann", "AuthorEmail": "sven.heidemann@sh-edraft.de", diff --git a/kdb-bot/src/bot_core/configuration/__init__.py b/kdb-bot/src/bot_core/configuration/__init__.py index 27b05e84..9e8b82e8 100644 --- a/kdb-bot/src/bot_core/configuration/__init__.py +++ b/kdb-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.1" +__version__ = "1.1.6" 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="1") +version_info = VersionInfo(major="1", minor="1", micro="6") diff --git a/kdb-bot/src/bot_core/configuration/feature_flags_enum.py b/kdb-bot/src/bot_core/configuration/feature_flags_enum.py index 2ef3f70f..d91d18f4 100644 --- a/kdb-bot/src/bot_core/configuration/feature_flags_enum.py +++ b/kdb-bot/src/bot_core/configuration/feature_flags_enum.py @@ -20,3 +20,5 @@ class FeatureFlagsEnum(Enum): api_only = "ApiOnly" presence = "Presence" version_in_presence = "VersionInPresence" + game_server = "GameServer" + sync_xp = "SyncXp" diff --git a/kdb-bot/src/bot_core/configuration/feature_flags_settings.py b/kdb-bot/src/bot_core/configuration/feature_flags_settings.py index f132cc03..c90684a3 100644 --- a/kdb-bot/src/bot_core/configuration/feature_flags_settings.py +++ b/kdb-bot/src/bot_core/configuration/feature_flags_settings.py @@ -22,6 +22,8 @@ class FeatureFlagsSettings(ConfigurationModelABC): FeatureFlagsEnum.api_only.value: False, # 13.10.2022 #70 FeatureFlagsEnum.presence.value: True, # 03.10.2022 #56 FeatureFlagsEnum.version_in_presence.value: False, # 21.03.2023 #253 + FeatureFlagsEnum.game_server.value: False, # 25.09.2023 #366 + FeatureFlagsEnum.sync_xp.value: False, # 25.09.2023 #366 } def __init__(self, **kwargs: dict): diff --git a/kdb-bot/src/bot_core/core_extension/__init__.py b/kdb-bot/src/bot_core/core_extension/__init__.py index e42c1764..658eaffc 100644 --- a/kdb-bot/src/bot_core/core_extension/__init__.py +++ b/kdb-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.1" +__version__ = "1.1.6" 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="1") +version_info = VersionInfo(major="1", minor="1", micro="6") diff --git a/kdb-bot/src/bot_core/events/__init__.py b/kdb-bot/src/bot_core/events/__init__.py index a2cc4da4..c31d23d0 100644 --- a/kdb-bot/src/bot_core/events/__init__.py +++ b/kdb-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.1" +__version__ = "1.1.6" 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="1") +version_info = VersionInfo(major="1", minor="1", micro="6") diff --git a/kdb-bot/src/bot_core/exception/__init__.py b/kdb-bot/src/bot_core/exception/__init__.py index 9b2931dc..96b2feae 100644 --- a/kdb-bot/src/bot_core/exception/__init__.py +++ b/kdb-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.1" +__version__ = "1.1.6" 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="1") +version_info = VersionInfo(major="1", minor="1", micro="6") diff --git a/kdb-bot/src/bot_core/helper/__init__.py b/kdb-bot/src/bot_core/helper/__init__.py index ddeb5b75..79023949 100644 --- a/kdb-bot/src/bot_core/helper/__init__.py +++ b/kdb-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.1" +__version__ = "1.1.6" 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="1") +version_info = VersionInfo(major="1", minor="1", micro="6") diff --git a/kdb-bot/src/bot_core/logging/__init__.py b/kdb-bot/src/bot_core/logging/__init__.py index 5fb56d9c..23c4b996 100644 --- a/kdb-bot/src/bot_core/logging/__init__.py +++ b/kdb-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.1" +__version__ = "1.1.6" 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="1") +version_info = VersionInfo(major="1", minor="1", micro="6") diff --git a/kdb-bot/src/bot_core/pipes/__init__.py b/kdb-bot/src/bot_core/pipes/__init__.py index 6f2f6a8d..f4b9cbfe 100644 --- a/kdb-bot/src/bot_core/pipes/__init__.py +++ b/kdb-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.1" +__version__ = "1.1.6" 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="1") +version_info = VersionInfo(major="1", minor="1", micro="6") diff --git a/kdb-bot/src/bot_core/service/__init__.py b/kdb-bot/src/bot_core/service/__init__.py index 34f83c39..8af6564f 100644 --- a/kdb-bot/src/bot_core/service/__init__.py +++ b/kdb-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.1" +__version__ = "1.1.6" 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="1") +version_info = VersionInfo(major="1", minor="1", micro="6") diff --git a/kdb-bot/src/bot_core/service/client_utils_service.py b/kdb-bot/src/bot_core/service/client_utils_service.py index 104c5267..42d0c65c 100644 --- a/kdb-bot/src/bot_core/service/client_utils_service.py +++ b/kdb-bot/src/bot_core/service/client_utils_service.py @@ -1,5 +1,5 @@ from datetime import datetime -from typing import Callable +from typing import Callable, Union import discord from cpl_core.configuration import ConfigurationABC @@ -218,3 +218,20 @@ class ClientUtilsService(ClientUtilsABC): f"Cannot add reaction {rule.emoji_name} to message: {discord_message_id}", e, ) + + async def check_default_role(self, member: Union[discord.User, discord.Member]): + try: + server = self._servers.get_server_by_discord_id(member.guild.id) + settings: ServerConfig = self._config.get_configuration(f"ServerConfig_{server.discord_id}") + + if settings.default_role_id is None: + return + + default_role = member.guild.get_role(settings.default_role_id) + if default_role in member.roles: + return + + await member.add_roles(default_role) + + except Exception as e: + self._logger.error(__name__, f"Cannot check for default role for member {member.id}", e) diff --git a/kdb-bot/src/bot_core/service/data_integrity_service.py b/kdb-bot/src/bot_core/service/data_integrity_service.py index 946d6d29..8290cb88 100644 --- a/kdb-bot/src/bot_core/service/data_integrity_service.py +++ b/kdb-bot/src/bot_core/service/data_integrity_service.py @@ -6,6 +6,7 @@ from cpl_core.configuration import ConfigurationABC from cpl_core.database.context import DatabaseContextABC from cpl_discord.service import DiscordBotServiceABC +from bot_core.abc.client_utils_abc import ClientUtilsABC 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 @@ -44,6 +45,7 @@ class DataIntegrityService: user_joins_vc: UserJoinedVoiceChannelRepositoryABC, user_joined_gs: UserJoinedGameServerRepositoryABC, achievement_service: AchievementService, + client_utils: ClientUtilsABC, dtp: DateTimeOffsetPipe, ): self._config = config @@ -60,6 +62,7 @@ class DataIntegrityService: self._user_joins_vc = user_joins_vc self._user_joined_gs = user_joined_gs self._achievements = achievement_service + self._client_utils = client_utils self._dtp = dtp self._is_for_shutdown = False @@ -382,10 +385,16 @@ class DataIntegrityService: await self._achievements.validate_achievements_for_user(user) + async def _check_default_role(self): + for guild in self._bot.guilds: + for member in guild.members: + await self._client_utils.check_default_role(member) + async def check_data_integrity(self, is_for_shutdown=False): if is_for_shutdown != self._is_for_shutdown: self._is_for_shutdown = is_for_shutdown + await self._check_default_role() self._check_known_users() self._check_servers() self._check_clients() diff --git a/kdb-bot/src/bot_data/__init__.py b/kdb-bot/src/bot_data/__init__.py index df496bcb..cfda6242 100644 --- a/kdb-bot/src/bot_data/__init__.py +++ b/kdb-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.1" +__version__ = "1.1.6" 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="1") +version_info = VersionInfo(major="1", minor="1", micro="6") diff --git a/kdb-bot/src/bot_data/abc/__init__.py b/kdb-bot/src/bot_data/abc/__init__.py index 24c605bb..230338fc 100644 --- a/kdb-bot/src/bot_data/abc/__init__.py +++ b/kdb-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.1" +__version__ = "1.1.6" 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="1") +version_info = VersionInfo(major="1", minor="1", micro="6") diff --git a/kdb-bot/src/bot_data/abc/auth_user_repository_abc.py b/kdb-bot/src/bot_data/abc/auth_user_repository_abc.py index f0299068..9d9b06ec 100644 --- a/kdb-bot/src/bot_data/abc/auth_user_repository_abc.py +++ b/kdb-bot/src/bot_data/abc/auth_user_repository_abc.py @@ -14,6 +14,10 @@ class AuthUserRepositoryABC(ABC): def __init__(self): pass + @abstractmethod + def get_auth_user_relation_ids(self, auth_user: AuthUser) -> List[int]: + pass + @abstractmethod def get_all_auth_users(self) -> List[AuthUser]: pass diff --git a/kdb-bot/src/bot_data/abc/game_server_repository_abc.py b/kdb-bot/src/bot_data/abc/game_server_repository_abc.py index 50e6fe7a..b71d1582 100644 --- a/kdb-bot/src/bot_data/abc/game_server_repository_abc.py +++ b/kdb-bot/src/bot_data/abc/game_server_repository_abc.py @@ -23,7 +23,7 @@ class GameServerRepositoryABC(ABC): pass @abstractmethod - def get_game_server_by_api_key_id(self, id: int) -> GameServer: + def get_game_servers_by_api_key_id(self, id: int) -> List[GameServer]: pass @abstractmethod diff --git a/kdb-bot/src/bot_data/abc/user_game_ident_repository_abc.py b/kdb-bot/src/bot_data/abc/user_game_ident_repository_abc.py index fbaa0831..ba45e02b 100644 --- a/kdb-bot/src/bot_data/abc/user_game_ident_repository_abc.py +++ b/kdb-bot/src/bot_data/abc/user_game_ident_repository_abc.py @@ -14,6 +14,10 @@ class UserGameIdentRepositoryABC(ABC): def get_user_game_idents(self) -> List[UserGameIdent]: pass + @abstractmethod + def get_user_game_idents_by_game_server_id(self, id: int) -> List[UserGameIdent]: + pass + @abstractmethod def get_user_game_ident_by_id(self, id: int) -> UserGameIdent: pass diff --git a/kdb-bot/src/bot_data/bot-data.json b/kdb-bot/src/bot_data/bot-data.json index c378e4e8..a808af01 100644 --- a/kdb-bot/src/bot_data/bot-data.json +++ b/kdb-bot/src/bot_data/bot-data.json @@ -4,7 +4,7 @@ "Version": { "Major": "1", "Minor": "1", - "Micro": "1" + "Micro": "6" }, "Author": "Sven Heidemann", "AuthorEmail": "sven.heidemann@sh-edraft.de", diff --git a/kdb-bot/src/bot_data/migration/__init__.py b/kdb-bot/src/bot_data/migration/__init__.py index 77b69cda..0fdf7f51 100644 --- a/kdb-bot/src/bot_data/migration/__init__.py +++ b/kdb-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.1" +__version__ = "1.1.6" 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="1") +version_info = VersionInfo(major="1", minor="1", micro="6") diff --git a/kdb-bot/src/bot_data/migration/default_role_migration.py b/kdb-bot/src/bot_data/migration/default_role_migration.py new file mode 100644 index 00000000..24fd4940 --- /dev/null +++ b/kdb-bot/src/bot_data/migration/default_role_migration.py @@ -0,0 +1,34 @@ +from bot_core.logging.database_logger import DatabaseLogger +from bot_data.abc.migration_abc import MigrationABC +from bot_data.db_context import DBContext + + +class DefaultRoleMigration(MigrationABC): + name = "1.1.3_DefaultRoleMigration" + + 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 CFG_Server + ADD DefaultRoleId BIGINT NULL AFTER LoginMessageChannelId; + """ + ) + ) + + def downgrade(self): + self._cursor.execute( + str( + f""" + ALTER TABLE CFG_Server DROP COLUMN DefaultRoleId; + """ + ) + ) diff --git a/kdb-bot/src/bot_data/model/__init__.py b/kdb-bot/src/bot_data/model/__init__.py index b804469d..b9b6a0e5 100644 --- a/kdb-bot/src/bot_data/model/__init__.py +++ b/kdb-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.1" +__version__ = "1.1.6" 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="1") +version_info = VersionInfo(major="1", minor="1", micro="6") diff --git a/kdb-bot/src/bot_data/model/server_config.py b/kdb-bot/src/bot_data/model/server_config.py index 64c666d1..87064e66 100644 --- a/kdb-bot/src/bot_data/model/server_config.py +++ b/kdb-bot/src/bot_data/model/server_config.py @@ -26,6 +26,7 @@ class ServerConfig(TableABC, ConfigurationModelABC): help_voice_channel_id: int, team_channel_id: int, login_message_channel_id: int, + default_role_id: int, feature_flags: dict[FeatureFlagsEnum], server: Server, afk_channel_ids: List[int], @@ -48,6 +49,7 @@ class ServerConfig(TableABC, ConfigurationModelABC): 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._feature_flags = feature_flags self._server = server self._afk_channel_ids = afk_channel_ids @@ -165,6 +167,14 @@ class ServerConfig(TableABC, ConfigurationModelABC): def login_message_channel_id(self, value: int): self._login_message_channel_id = value + @property + def default_role_id(self) -> int: + return self._default_role_id + + @default_role_id.setter + def default_role_id(self, value: int): + self._default_role_id = value + @property def feature_flags(self) -> dict[FeatureFlagsEnum]: return self._feature_flags @@ -237,6 +247,7 @@ class ServerConfig(TableABC, ConfigurationModelABC): `HelpVoiceChannelId`, `TeamChannelId`, `LoginMessageChannelId`, + `DefaultRoleId`, `FeatureFlags`, `ServerId` ) VALUES ( @@ -253,6 +264,7 @@ class ServerConfig(TableABC, ConfigurationModelABC): {self._help_voice_channel_id}, {self._team_channel_id}, {self._login_message_channel_id}, + {self._default_role_id}, '{json.dumps(self._feature_flags)}', {self._server.id} ); @@ -277,6 +289,7 @@ class ServerConfig(TableABC, ConfigurationModelABC): `HelpVoiceChannelId` = {self._help_voice_channel_id}, `TeamChannelId` = {self._team_channel_id}, `LoginMessageChannelId` = {self._login_message_channel_id}, + `DefaultRoleId` = {self._default_role_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/kdb-bot/src/bot_data/model/server_config_history.py index a816e069..5ee9bc28 100644 --- a/kdb-bot/src/bot_data/model/server_config_history.py +++ b/kdb-bot/src/bot_data/model/server_config_history.py @@ -17,6 +17,7 @@ class ServerConfigHistory(HistoryTableABC): help_voice_channel_id: int, team_channel_id: int, login_message_channel_id: int, + default_role_id: int, feature_flags: dict[str], server_id: int, deleted: bool, @@ -40,6 +41,7 @@ class ServerConfigHistory(HistoryTableABC): 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._feature_flags = feature_flags self._server_id = server_id @@ -99,6 +101,10 @@ class ServerConfigHistory(HistoryTableABC): def login_message_channel_id(self) -> int: return self._login_message_channel_id + @property + def default_role_id(self) -> int: + return self._default_role_id + @property def feature_flags(self) -> dict[str]: return self._feature_flags diff --git a/kdb-bot/src/bot_data/model/user_game_ident.py b/kdb-bot/src/bot_data/model/user_game_ident.py index 22e7946f..79468d13 100644 --- a/kdb-bot/src/bot_data/model/user_game_ident.py +++ b/kdb-bot/src/bot_data/model/user_game_ident.py @@ -49,6 +49,15 @@ class UserGameIdent(TableABC): """ ) + @staticmethod + def get_select_by_game_server_id_string(id: int) -> str: + return str( + f""" + SELECT * FROM `UserGameIdents` + WHERE `GameServerId` = {id}; + """ + ) + @staticmethod def get_select_by_id_string(id: int) -> str: return str( diff --git a/kdb-bot/src/bot_data/model/user_joined_voice_channel.py b/kdb-bot/src/bot_data/model/user_joined_voice_channel.py index dda013e6..3b938452 100644 --- a/kdb-bot/src/bot_data/model/user_joined_voice_channel.py +++ b/kdb-bot/src/bot_data/model/user_joined_voice_channel.py @@ -39,7 +39,10 @@ class UserJoinedVoiceChannel(TableABC): @property @ServiceProviderABC.inject def channel_name(self, bot: DiscordBotServiceABC) -> str: - return bot.get_channel(self.channel_id).name + channel = bot.get_channel(self.channel_id) + if channel is None: + return "" + return channel.name @property def user(self) -> User: diff --git a/kdb-bot/src/bot_data/model/user_joined_voice_channel_history.py b/kdb-bot/src/bot_data/model/user_joined_voice_channel_history.py index 5c1ee49a..0f84b35f 100644 --- a/kdb-bot/src/bot_data/model/user_joined_voice_channel_history.py +++ b/kdb-bot/src/bot_data/model/user_joined_voice_channel_history.py @@ -41,7 +41,10 @@ class UserJoinedVoiceChannelHistory(HistoryTableABC): @property @ServiceProviderABC.inject def channel_name(self, bot: DiscordBotServiceABC) -> str: - return bot.get_channel(self.channel_id).name + channel = bot.get_channel(self.channel_id) + if channel is None: + return "" + return channel.name @property def user(self) -> int: diff --git a/kdb-bot/src/bot_data/service/__init__.py b/kdb-bot/src/bot_data/service/__init__.py index 4ede7cd9..1fac6c5f 100644 --- a/kdb-bot/src/bot_data/service/__init__.py +++ b/kdb-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.1" +__version__ = "1.1.6" 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="1") +version_info = VersionInfo(major="1", minor="1", micro="6") diff --git a/kdb-bot/src/bot_data/service/auth_user_repository_service.py b/kdb-bot/src/bot_data/service/auth_user_repository_service.py index 87b39169..00afe7ae 100644 --- a/kdb-bot/src/bot_data/service/auth_user_repository_service.py +++ b/kdb-bot/src/bot_data/service/auth_user_repository_service.py @@ -50,13 +50,7 @@ class AuthUserRepositoryService(AuthUserRepositoryABC): auth_user_id=self._get_value_from_result(au_result[0]), ) - self._logger.trace( - __name__, - f"Send SQL command: {auth_user.get_select_user_id_from_relations()}", - ) - results = self._context.select(auth_user.get_select_user_id_from_relations()) - for result in results: - user_id = self._get_value_from_result(result[0]) + for user_id in self.get_auth_user_relation_ids(auth_user): if user_id is None: continue @@ -65,6 +59,19 @@ class AuthUserRepositoryService(AuthUserRepositoryABC): return auth_user + def get_auth_user_relation_ids(self, auth_user: AuthUser) -> List[int]: + self._logger.trace( + __name__, + f"Send SQL command: {auth_user.get_select_user_id_from_relations()}", + ) + relation_ids = List(int) + results = self._context.select(auth_user.get_select_user_id_from_relations()) + for result in results: + self._logger.trace(__name__, f"Got auth user relation with id {result[0]}") + relation_ids.append(result[0]) + + return relation_ids + def get_all_auth_users(self) -> List[AuthUser]: users = List(AuthUser) self._logger.trace(__name__, f"Send SQL command: {AuthUser.get_select_all_string()}") diff --git a/kdb-bot/src/bot_data/service/game_server_repository_service.py b/kdb-bot/src/bot_data/service/game_server_repository_service.py index 20f89433..1bdd0aeb 100644 --- a/kdb-bot/src/bot_data/service/game_server_repository_service.py +++ b/kdb-bot/src/bot_data/service/game_server_repository_service.py @@ -68,13 +68,16 @@ class GameServerRepositoryService(GameServerRepositoryABC): result = self._context.select(GameServer.get_select_by_id_string(id))[0] return self._from_result(result) - def get_game_server_by_api_key_id(self, id: int) -> GameServer: + def get_game_servers_by_api_key_id(self, id: int) -> List[GameServer]: self._logger.trace( __name__, f"Send SQL command: {GameServer.get_select_by_api_key_id_string(id)}", ) - result = self._context.select(GameServer.get_select_by_api_key_id_string(id))[0] - return self._from_result(result) + game_servers = List(GameServer) + results = self._context.select(GameServer.get_select_by_api_key_id_string(id)) + for result in results: + game_servers.append(self._from_result(result)) + return game_servers def add_game_server(self, game_server: GameServer): self._logger.trace(__name__, f"Send SQL command: {game_server.insert_string}") diff --git a/kdb-bot/src/bot_data/service/server_config_repository_service.py b/kdb-bot/src/bot_data/service/server_config_repository_service.py index 33f011ea..0e03a87e 100644 --- a/kdb-bot/src/bot_data/service/server_config_repository_service.py +++ b/kdb-bot/src/bot_data/service/server_config_repository_service.py @@ -64,12 +64,13 @@ class ServerConfigRepositoryService(ServerConfigRepositoryABC): result[11], result[12], result[13], - json.loads(result[14]), - self._servers.get_server_by_id(result[15]), - self._get_afk_channel_ids(result[15]), - self._get_team_role_ids(result[15]), - result[16], + result[14], + json.loads(result[15]), + self._servers.get_server_by_id(result[16]), + self._get_afk_channel_ids(result[16]), + self._get_team_role_ids(result[16]), result[17], + result[18], id=result[0], ) diff --git a/kdb-bot/src/bot_data/service/user_game_ident_repository_service.py b/kdb-bot/src/bot_data/service/user_game_ident_repository_service.py index 5967d78b..d0dfc38b 100644 --- a/kdb-bot/src/bot_data/service/user_game_ident_repository_service.py +++ b/kdb-bot/src/bot_data/service/user_game_ident_repository_service.py @@ -51,6 +51,19 @@ class UserGameIdentRepositoryService(UserGameIdentRepositoryABC): return joins + def get_user_game_idents_by_game_server_id(self, game_server_id: int) -> List[UserGameIdent]: + joins = List(UserGameIdent) + self._logger.trace( + __name__, + f"Send SQL command: {UserGameIdent.get_select_by_game_server_id_string(game_server_id)}", + ) + results = self._context.select(UserGameIdent.get_select_by_game_server_id_string(game_server_id)) + for result in results: + self._logger.trace(__name__, f"Get UserGameIdent with id {result[0]}") + joins.append(self._from_result(result)) + + return joins + def get_user_game_ident_by_id(self, id: int) -> UserGameIdent: self._logger.trace( __name__, diff --git a/kdb-bot/src/bot_graphql/__init__.py b/kdb-bot/src/bot_graphql/__init__.py index de0cc27c..4272d8e2 100644 --- a/kdb-bot/src/bot_graphql/__init__.py +++ b/kdb-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.1" +__version__ = "1.1.6" 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="1") +version_info = VersionInfo(major="1", minor="1", micro="6") diff --git a/kdb-bot/src/bot_graphql/abc/__init__.py b/kdb-bot/src/bot_graphql/abc/__init__.py index 281aa940..d723ec75 100644 --- a/kdb-bot/src/bot_graphql/abc/__init__.py +++ b/kdb-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.1" +__version__ = "1.1.6" 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="1") +version_info = VersionInfo(major="1", minor="1", micro="6") diff --git a/kdb-bot/src/bot_graphql/bot-graphql.json b/kdb-bot/src/bot_graphql/bot-graphql.json index e68b27c4..d42e532e 100644 --- a/kdb-bot/src/bot_graphql/bot-graphql.json +++ b/kdb-bot/src/bot_graphql/bot-graphql.json @@ -4,7 +4,7 @@ "Version": { "Major": "1", "Minor": "1", - "Micro": "1" + "Micro": "6" }, "Author": "Sven Heidemann", "AuthorEmail": "sven.heidemann@sh-edraft.de", diff --git a/kdb-bot/src/bot_graphql/filter/__init__.py b/kdb-bot/src/bot_graphql/filter/__init__.py index 3f28c605..00ce8266 100644 --- a/kdb-bot/src/bot_graphql/filter/__init__.py +++ b/kdb-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.1" +__version__ = "1.1.6" 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="1") +version_info = VersionInfo(major="1", minor="1", micro="6") diff --git a/kdb-bot/src/bot_graphql/graphql/serverConfig.gql b/kdb-bot/src/bot_graphql/graphql/serverConfig.gql index 1734114a..2b834a48 100644 --- a/kdb-bot/src/bot_graphql/graphql/serverConfig.gql +++ b/kdb-bot/src/bot_graphql/graphql/serverConfig.gql @@ -13,6 +13,7 @@ type ServerConfig implements TableWithHistoryQuery { helpVoiceChannelId: String teamChannelId: String loginMessageChannelId: String + defaultRoleId: String featureFlagCount: Int featureFlags: [FeatureFlag] @@ -43,6 +44,7 @@ type ServerConfigHistory implements HistoryTableQuery { helpVoiceChannelId: String teamChannelId: String loginMessageChannelId: String + defaultRoleId: String featureFlagCount: Int featureFlags: [FeatureFlag] @@ -91,6 +93,7 @@ input ServerConfigInput { helpVoiceChannelId: String teamChannelId: String loginMessageChannelId: String + defaultRoleId: String featureFlags: [FeatureFlagInput] afkChannelIds: [String] diff --git a/kdb-bot/src/bot_graphql/model/__init__.py b/kdb-bot/src/bot_graphql/model/__init__.py index d0709bfe..9bacb226 100644 --- a/kdb-bot/src/bot_graphql/model/__init__.py +++ b/kdb-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.1" +__version__ = "1.1.6" 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="1") +version_info = VersionInfo(major="1", minor="1", micro="6") diff --git a/kdb-bot/src/bot_graphql/mutations/__init__.py b/kdb-bot/src/bot_graphql/mutations/__init__.py index d65a1e7e..09ed2432 100644 --- a/kdb-bot/src/bot_graphql/mutations/__init__.py +++ b/kdb-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.1" +__version__ = "1.1.6" 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="1") +version_info = VersionInfo(major="1", minor="1", micro="6") diff --git a/kdb-bot/src/bot_graphql/mutations/server_config_mutation.py b/kdb-bot/src/bot_graphql/mutations/server_config_mutation.py index 4a56d9f0..a555e092 100644 --- a/kdb-bot/src/bot_graphql/mutations/server_config_mutation.py +++ b/kdb-bot/src/bot_graphql/mutations/server_config_mutation.py @@ -89,6 +89,9 @@ class ServerConfigMutation(QueryABC): if "loginMessageChannelId" in input else server_config.login_message_channel_id ) + server_config.default_role_id = ( + input["defaultRoleId"] if "defaultRoleId" in input else server_config.default_role_id + ) server_config.feature_flags = ( dict(zip([x["key"] for x in input["featureFlags"]], [x["value"] for x in input["featureFlags"]])) if "featureFlags" in input diff --git a/kdb-bot/src/bot_graphql/mutations/user_joined_game_server_mutation.py b/kdb-bot/src/bot_graphql/mutations/user_joined_game_server_mutation.py index 62fef010..9225299d 100644 --- a/kdb-bot/src/bot_graphql/mutations/user_joined_game_server_mutation.py +++ b/kdb-bot/src/bot_graphql/mutations/user_joined_game_server_mutation.py @@ -9,6 +9,8 @@ from cpl_discord.service import DiscordBotServiceABC from flask import request from bot_api.configuration.authentication_settings import AuthenticationSettings +from bot_core.configuration.feature_flags_enum import FeatureFlagsEnum +from bot_core.configuration.feature_flags_settings import FeatureFlagsSettings 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 @@ -75,14 +77,13 @@ class UserJoinedGameServerMutation(QueryABC): ) def resolve_user_joined(self, *_, input: dict): - api_key = self._get_api_key() - if api_key is None: - self._logger.warn(__name__, f"UserJoinedGameServer not saved. Api-Key not available!") - return - - game_server = self._game_servers.get_game_server_by_api_key_id(api_key.id) game_ident = self._user_game_idents.get_user_game_ident_by_ident(input["ident"]) user = game_ident.user + + settings: ServerConfig = self._config.get_configuration(f"ServerConfig_{user.server.discord_id}") + if not FeatureFlagsSettings.get_flag_from_dict(settings.feature_flags, FeatureFlagsEnum.game_server): + raise Exception("Feature not activated") + self._can_user_mutate_data(user.server, UserRoleEnum.admin) active = self._user_joined_game_servers.find_active_user_joined_game_server_by_user_id(user.id) @@ -93,22 +94,22 @@ class UserJoinedGameServerMutation(QueryABC): ) return - new = UserJoinedGameServer(user, game_server, datetime.now()) + new = UserJoinedGameServer(user, game_ident.game_server, datetime.now()) self._user_joined_game_servers.add_user_joined_game_server(new) self._db.save_changes() return self._user_joined_game_servers.get_active_user_joined_game_server_by_user_id(user.id) def resolve_user_left(self, *_, input: dict): - api_key = self._get_api_key() - if api_key is None: - self._logger.warn(__name__, f"UserJoinedGameServer not saved. Api-Key not available!") - return - game_ident = self._user_game_idents.find_user_game_ident_by_ident(input["ident"]) if game_ident is None: return user = game_ident.user + + settings: ServerConfig = self._config.get_configuration(f"ServerConfig_{user.server.discord_id}") + if not FeatureFlagsSettings.get_flag_from_dict(settings.feature_flags, FeatureFlagsEnum.game_server): + raise Exception("Feature not activated") + self._can_user_mutate_data(user.server, UserRoleEnum.admin) active = self._user_joined_game_servers.find_active_user_joined_game_server_by_user_id(user.id) diff --git a/kdb-bot/src/bot_graphql/queries/__init__.py b/kdb-bot/src/bot_graphql/queries/__init__.py index f0a15057..af3a9fdf 100644 --- a/kdb-bot/src/bot_graphql/queries/__init__.py +++ b/kdb-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.1" +__version__ = "1.1.6" 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="1") +version_info = VersionInfo(major="1", minor="1", micro="6") diff --git a/kdb-bot/src/bot_graphql/queries/discord/__init__.py b/kdb-bot/src/bot_graphql/queries/discord/__init__.py index 63a54aee..a4425748 100644 --- a/kdb-bot/src/bot_graphql/queries/discord/__init__.py +++ b/kdb-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.1" +__version__ = "1.1.6" 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="1") +version_info = VersionInfo(major="1", minor="1", micro="6") diff --git a/kdb-bot/src/bot_graphql/queries/server_config_query.py b/kdb-bot/src/bot_graphql/queries/server_config_query.py index 73e61828..6a068ffe 100644 --- a/kdb-bot/src/bot_graphql/queries/server_config_query.py +++ b/kdb-bot/src/bot_graphql/queries/server_config_query.py @@ -24,6 +24,7 @@ class ServerConfigQuery(DataQueryWithHistoryABC): 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.add_collection( "featureFlag", lambda config, *_: List(any, [{"key": x, "value": config.feature_flags[x]} for x in config.feature_flags]), diff --git a/kdb-bot/src/modules/achievements/__init__.py b/kdb-bot/src/modules/achievements/__init__.py index d4d8603c..eda08773 100644 --- a/kdb-bot/src/modules/achievements/__init__.py +++ b/kdb-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.1" +__version__ = "1.1.6" 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="1") +version_info = VersionInfo(major="1", minor="1", micro="6") diff --git a/kdb-bot/src/modules/achievements/achievements.json b/kdb-bot/src/modules/achievements/achievements.json index 2b5018d8..e11f0f63 100644 --- a/kdb-bot/src/modules/achievements/achievements.json +++ b/kdb-bot/src/modules/achievements/achievements.json @@ -4,7 +4,7 @@ "Version": { "Major": "1", "Minor": "1", - "Micro": "1" + "Micro": "6" }, "Author": "Sven Heidemann", "AuthorEmail": "sven.heidemann@sh-edraft.de", diff --git a/kdb-bot/src/modules/achievements/commands/__init__.py b/kdb-bot/src/modules/achievements/commands/__init__.py index 91f6dfd0..dbff52dc 100644 --- a/kdb-bot/src/modules/achievements/commands/__init__.py +++ b/kdb-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.1" +__version__ = "1.1.6" 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="1") +version_info = VersionInfo(major="1", minor="1", micro="6") diff --git a/kdb-bot/src/modules/achievements/events/__init__.py b/kdb-bot/src/modules/achievements/events/__init__.py index f36ce551..dfaa74e8 100644 --- a/kdb-bot/src/modules/achievements/events/__init__.py +++ b/kdb-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.1" +__version__ = "1.1.6" 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="1") +version_info = VersionInfo(major="1", minor="1", micro="6") diff --git a/kdb-bot/src/modules/achievements/model/__init__.py b/kdb-bot/src/modules/achievements/model/__init__.py index 26137876..d803c190 100644 --- a/kdb-bot/src/modules/achievements/model/__init__.py +++ b/kdb-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.1" +__version__ = "1.1.6" 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="1") +version_info = VersionInfo(major="1", minor="1", micro="6") diff --git a/kdb-bot/src/modules/auto_role/__init__.py b/kdb-bot/src/modules/auto_role/__init__.py index 7b9d2d26..47815bd7 100644 --- a/kdb-bot/src/modules/auto_role/__init__.py +++ b/kdb-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.1" +__version__ = "1.1.6" 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="1") +version_info = VersionInfo(major="1", minor="1", micro="6") diff --git a/kdb-bot/src/modules/auto_role/auto-role.json b/kdb-bot/src/modules/auto_role/auto-role.json index 7bda4434..4609845a 100644 --- a/kdb-bot/src/modules/auto_role/auto-role.json +++ b/kdb-bot/src/modules/auto_role/auto-role.json @@ -4,7 +4,7 @@ "Version": { "Major": "1", "Minor": "1", - "Micro": "1" + "Micro": "6" }, "Author": "", "AuthorEmail": "", diff --git a/kdb-bot/src/modules/auto_role/command/__init__.py b/kdb-bot/src/modules/auto_role/command/__init__.py index 27a2827b..9bcc8212 100644 --- a/kdb-bot/src/modules/auto_role/command/__init__.py +++ b/kdb-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.1" +__version__ = "1.1.6" 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="1") +version_info = VersionInfo(major="1", minor="1", micro="6") diff --git a/kdb-bot/src/modules/auto_role/events/__init__.py b/kdb-bot/src/modules/auto_role/events/__init__.py index c2f2d5c3..a3cbb613 100644 --- a/kdb-bot/src/modules/auto_role/events/__init__.py +++ b/kdb-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.1" +__version__ = "1.1.6" 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="1") +version_info = VersionInfo(major="1", minor="1", micro="6") diff --git a/kdb-bot/src/modules/auto_role/helper/__init__.py b/kdb-bot/src/modules/auto_role/helper/__init__.py index ffa9851b..16d38163 100644 --- a/kdb-bot/src/modules/auto_role/helper/__init__.py +++ b/kdb-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.1" +__version__ = "1.1.6" 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="1") +version_info = VersionInfo(major="1", minor="1", micro="6") diff --git a/kdb-bot/src/modules/base/__init__.py b/kdb-bot/src/modules/base/__init__.py index e9674fe2..dfc3a901 100644 --- a/kdb-bot/src/modules/base/__init__.py +++ b/kdb-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.1" +__version__ = "1.1.6" 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="1") +version_info = VersionInfo(major="1", minor="1", micro="6") diff --git a/kdb-bot/src/modules/base/base.json b/kdb-bot/src/modules/base/base.json index b418ff09..c5b462df 100644 --- a/kdb-bot/src/modules/base/base.json +++ b/kdb-bot/src/modules/base/base.json @@ -4,7 +4,7 @@ "Version": { "Major": "1", "Minor": "1", - "Micro": "1" + "Micro": "6" }, "Author": "", "AuthorEmail": "", diff --git a/kdb-bot/src/modules/base/command/__init__.py b/kdb-bot/src/modules/base/command/__init__.py index 81b8049d..73da5488 100644 --- a/kdb-bot/src/modules/base/command/__init__.py +++ b/kdb-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.1" +__version__ = "1.1.6" 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="1") +version_info = VersionInfo(major="1", minor="1", micro="6") diff --git a/kdb-bot/src/modules/base/command/game_server_group.py b/kdb-bot/src/modules/base/command/game_server_group.py index 7d3073be..b822f3de 100644 --- a/kdb-bot/src/modules/base/command/game_server_group.py +++ b/kdb-bot/src/modules/base/command/game_server_group.py @@ -1,6 +1,7 @@ from typing import 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 @@ -11,38 +12,49 @@ from discord.ext.commands import Context from bot_core.abc.client_utils_abc import ClientUtilsABC from bot_core.abc.message_service_abc import MessageServiceABC +from bot_core.configuration.feature_flags_enum import FeatureFlagsEnum +from bot_core.configuration.feature_flags_settings import FeatureFlagsSettings from bot_core.helper.command_checks import CommandChecks from bot_core.logging.command_logger import CommandLogger 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_repository_abc import UserRepositoryABC from bot_data.model.game_server import GameServer +from bot_data.model.server_config import ServerConfig from modules.permission.abc.permission_service_abc import PermissionServiceABC class GameServerGroup(DiscordCommandABC): def __init__( self, + config: ConfigurationABC, logger: CommandLogger, message_service: MessageServiceABC, bot: DiscordBotServiceABC, client_utils: ClientUtilsABC, translate: TranslatePipe, servers: ServerRepositoryABC, + user: UserRepositoryABC, game_servers: GameServerRepositoryABC, + user_game_idents: UserGameIdentRepositoryABC, api_keys: ApiKeyRepositoryABC, db: DatabaseContextABC, permission_service: PermissionServiceABC, ): DiscordCommandABC.__init__(self) + self._config = config self._logger = logger self._message_service = message_service self._bot = bot self._client_utils = client_utils self._t = translate self._servers = servers + self._user = user self._game_servers = game_servers + self._user_game_idents = user_game_idents self._api_keys = api_keys self._db = db self._permissions = permission_service @@ -64,6 +76,11 @@ class GameServerGroup(DiscordCommandABC): if ctx.guild is None: return + settings: ServerConfig = self._config.get_configuration(f"ServerConfig_{ctx.guild.id}") + if not FeatureFlagsSettings.get_flag_from_dict(settings.feature_flags, FeatureFlagsEnum.game_server): + await self._message_service.send_ctx_msg(ctx, self._t.transform("common.feature_not_activated")) + return + server = self._servers.get_server_by_discord_id(ctx.guild.id) game_servers = self._game_servers.get_game_servers_by_server_id(server.id) if game_servers.count() < 1: @@ -102,6 +119,14 @@ class GameServerGroup(DiscordCommandABC): async def add(self, ctx: Context, name: str, api_key_id: int): self._logger.debug(__name__, f"Received command game-server add {ctx}: {name} {api_key_id}") + if ctx.guild is None: + return + + settings: ServerConfig = self._config.get_configuration(f"ServerConfig_{ctx.guild.id}") + if not FeatureFlagsSettings.get_flag_from_dict(settings.feature_flags, FeatureFlagsEnum.game_server): + await self._message_service.send_ctx_msg(ctx, self._t.transform("common.feature_not_activated")) + return + server = self._servers.get_server_by_discord_id(ctx.guild.id) api_key = self._api_keys.get_api_key_by_id(api_key_id) game_server = GameServer(name, server, api_key) @@ -133,6 +158,14 @@ class GameServerGroup(DiscordCommandABC): async def remove(self, ctx: Context, id: int): self._logger.debug(__name__, f"Received command game-server remove {ctx}: {id}") + if ctx.guild is None: + return + + settings: ServerConfig = self._config.get_configuration(f"ServerConfig_{ctx.guild.id}") + if not FeatureFlagsSettings.get_flag_from_dict(settings.feature_flags, FeatureFlagsEnum.game_server): + await self._message_service.send_ctx_msg(ctx, self._t.transform("common.feature_not_activated")) + return + game_server = self._game_servers.get_game_server_by_id(id) self._game_servers.delete_game_server(game_server) self._db.save_changes() @@ -149,3 +182,44 @@ class GameServerGroup(DiscordCommandABC): app_commands.Choice(name=gs.name, value=gs.id) for gs in self._client_utils.get_auto_complete_list(game_servers, current, lambda x: x.name) ] + + @game_server.command(name="list-members") + @commands.guild_only() + @CommandChecks.check_is_ready() + @CommandChecks.check_is_member_moderator() + async def list_members(self, ctx: Context, id: int, wait: int = None): + self._logger.debug(__name__, f"Received command game-server remove {ctx}: {id}") + + if ctx.guild is None: + return + + settings: ServerConfig = self._config.get_configuration(f"ServerConfig_{ctx.guild.id}") + if not FeatureFlagsSettings.get_flag_from_dict(settings.feature_flags, FeatureFlagsEnum.game_server): + await self._message_service.send_ctx_msg(ctx, self._t.transform("common.feature_not_activated")) + return + + game_server = self._game_servers.get_game_server_by_id(id) + game_idents = self._user_game_idents.get_user_game_idents_by_game_server_id(game_server.id) + users = "" + for game_ident in game_idents: + users += f"\n{game_ident.user.name}" + + embed = discord.Embed( + title=self._t.transform("modules.base.game_server.list_members.title"), + 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) + await self._message_service.send_ctx_msg(ctx, embed, wait_before_delete=wait) + + self._logger.trace(__name__, f"Finished command game-server remove") + + @list_members.autocomplete("id") + async def id_autocomplete(self, interaction: discord.Interaction, current: str) -> TList[app_commands.Choice[str]]: + server = self._servers.get_server_by_discord_id(interaction.guild.id) + game_servers = self._game_servers.get_game_servers_by_server_id(server.id) + + return [ + app_commands.Choice(name=gs.name, value=gs.id) + for gs in self._client_utils.get_auto_complete_list(game_servers, current, lambda x: x.name) + ] diff --git a/kdb-bot/src/modules/base/events/__init__.py b/kdb-bot/src/modules/base/events/__init__.py index 9c228994..ad93bb83 100644 --- a/kdb-bot/src/modules/base/events/__init__.py +++ b/kdb-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.1" +__version__ = "1.1.6" 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="1") +version_info = VersionInfo(major="1", minor="1", micro="6") diff --git a/kdb-bot/src/modules/base/events/base_on_member_join_event.py b/kdb-bot/src/modules/base/events/base_on_member_join_event.py index 58af0a00..79568f4b 100644 --- a/kdb-bot/src/modules/base/events/base_on_member_join_event.py +++ b/kdb-bot/src/modules/base/events/base_on_member_join_event.py @@ -6,8 +6,10 @@ from cpl_core.configuration import ConfigurationABC from cpl_core.database.context import DatabaseContextABC from cpl_core.logging import LoggerABC from cpl_discord.events import OnMemberJoinABC +from cpl_discord.service import DiscordBotServiceABC from cpl_translation import TranslatePipe +from bot_core.abc.client_utils_abc import ClientUtilsABC from bot_core.abc.message_service_abc import MessageServiceABC from bot_core.helper.event_checks import EventChecks from bot_data.abc.known_user_repository_abc import KnownUserRepositoryABC @@ -28,10 +30,12 @@ class BaseOnMemberJoinEvent(OnMemberJoinABC): messenger: MessageServiceABC, permissions: PermissionServiceABC, db: DatabaseContextABC, + bot: DiscordBotServiceABC, known_users: KnownUserRepositoryABC, users: UserRepositoryABC, servers: ServerRepositoryABC, user_joins: UserJoinedServerRepositoryABC, + client_utils: ClientUtilsABC, translate: TranslatePipe, ): OnMemberJoinABC.__init__(self) @@ -40,10 +44,12 @@ class BaseOnMemberJoinEvent(OnMemberJoinABC): self._messenger = messenger self._permission_service = permissions self._db = db + self._bot = bot self._known_users = known_users self._users = users self._servers = servers self._user_joins = user_joins + self._client_utils = client_utils self._t = translate def _check_for_known_user(self, member: Union[discord.User, discord.Member]): @@ -98,5 +104,6 @@ class BaseOnMemberJoinEvent(OnMemberJoinABC): @EventChecks.check_is_ready() async def on_member_join(self, member: discord.Member): self._logger.debug(__name__, f"Module {type(self)} started") + await self._client_utils.check_default_role(member) self._check_for_known_user(member) await self._add_if_not_exists_user_async(member) diff --git a/kdb-bot/src/modules/base/forms/__init__.py b/kdb-bot/src/modules/base/forms/__init__.py index f200fa70..340c079a 100644 --- a/kdb-bot/src/modules/base/forms/__init__.py +++ b/kdb-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.1" +__version__ = "1.1.6" 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="1") +version_info = VersionInfo(major="1", minor="1", micro="6") diff --git a/kdb-bot/src/modules/base/helper/__init__.py b/kdb-bot/src/modules/base/helper/__init__.py index b03be39b..4d715c27 100644 --- a/kdb-bot/src/modules/base/helper/__init__.py +++ b/kdb-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.1" +__version__ = "1.1.6" 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="1") +version_info = VersionInfo(major="1", minor="1", micro="6") diff --git a/kdb-bot/src/modules/base/model/__init__.py b/kdb-bot/src/modules/base/model/__init__.py index 1d13e97c..aaaa2bd4 100644 --- a/kdb-bot/src/modules/base/model/__init__.py +++ b/kdb-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.1" +__version__ = "1.1.6" 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="1") +version_info = VersionInfo(major="1", minor="1", micro="6") diff --git a/kdb-bot/src/modules/base/service/__init__.py b/kdb-bot/src/modules/base/service/__init__.py index 3d8aa908..59c5de9b 100644 --- a/kdb-bot/src/modules/base/service/__init__.py +++ b/kdb-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.1" +__version__ = "1.1.6" 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="1") +version_info = VersionInfo(major="1", minor="1", micro="6") diff --git a/kdb-bot/src/modules/base/thread/__init__.py b/kdb-bot/src/modules/base/thread/__init__.py index 9f648ab9..daccd3b7 100644 --- a/kdb-bot/src/modules/base/thread/__init__.py +++ b/kdb-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.1" +__version__ = "1.1.6" 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="1") +version_info = VersionInfo(major="1", minor="1", micro="6") diff --git a/kdb-bot/src/modules/boot_log/__init__.py b/kdb-bot/src/modules/boot_log/__init__.py index f71b9ec3..37cba8a2 100644 --- a/kdb-bot/src/modules/boot_log/__init__.py +++ b/kdb-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.1" +__version__ = "1.1.6" 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="1") +version_info = VersionInfo(major="1", minor="1", micro="6") diff --git a/kdb-bot/src/modules/boot_log/boot-log.json b/kdb-bot/src/modules/boot_log/boot-log.json index 427bc5ae..351f7fbb 100644 --- a/kdb-bot/src/modules/boot_log/boot-log.json +++ b/kdb-bot/src/modules/boot_log/boot-log.json @@ -4,7 +4,7 @@ "Version": { "Major": "1", "Minor": "1", - "Micro": "1" + "Micro": "6" }, "Author": "", "AuthorEmail": "", diff --git a/kdb-bot/src/modules/config/__init__.py b/kdb-bot/src/modules/config/__init__.py index 30f6ea36..0330d875 100644 --- a/kdb-bot/src/modules/config/__init__.py +++ b/kdb-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.1" +__version__ = "1.1.6" 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="1") +version_info = VersionInfo(major="1", minor="1", micro="6") diff --git a/kdb-bot/src/modules/config/config.json b/kdb-bot/src/modules/config/config.json index 613562d7..a0d39cf8 100644 --- a/kdb-bot/src/modules/config/config.json +++ b/kdb-bot/src/modules/config/config.json @@ -4,7 +4,7 @@ "Version": { "Major": "1", "Minor": "1", - "Micro": "1" + "Micro": "6" }, "Author": "", "AuthorEmail": "", diff --git a/kdb-bot/src/modules/config/events/__init__.py b/kdb-bot/src/modules/config/events/__init__.py index b463cef0..a19fb622 100644 --- a/kdb-bot/src/modules/config/events/__init__.py +++ b/kdb-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.1" +__version__ = "1.1.6" 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="1") +version_info = VersionInfo(major="1", minor="1", micro="6") diff --git a/kdb-bot/src/modules/config/service/__init__.py b/kdb-bot/src/modules/config/service/__init__.py index b73bd167..f3869c77 100644 --- a/kdb-bot/src/modules/config/service/__init__.py +++ b/kdb-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.1" +__version__ = "1.1.6" 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="1") +version_info = VersionInfo(major="1", minor="1", micro="6") diff --git a/kdb-bot/src/modules/database/__init__.py b/kdb-bot/src/modules/database/__init__.py index 4edc1f64..4605835b 100644 --- a/kdb-bot/src/modules/database/__init__.py +++ b/kdb-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.1" +__version__ = "1.1.6" 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="1") +version_info = VersionInfo(major="1", minor="1", micro="6") diff --git a/kdb-bot/src/modules/database/database.json b/kdb-bot/src/modules/database/database.json index 80d172a8..c0f5e616 100644 --- a/kdb-bot/src/modules/database/database.json +++ b/kdb-bot/src/modules/database/database.json @@ -4,7 +4,7 @@ "Version": { "Major": "1", "Minor": "1", - "Micro": "1" + "Micro": "6" }, "Author": "Sven Heidemann", "AuthorEmail": "sven.heidemann@sh-edraft.de", diff --git a/kdb-bot/src/modules/level/__init__.py b/kdb-bot/src/modules/level/__init__.py index b5a68c80..6d650e08 100644 --- a/kdb-bot/src/modules/level/__init__.py +++ b/kdb-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.1" +__version__ = "1.1.6" 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="1") +version_info = VersionInfo(major="1", minor="1", micro="6") diff --git a/kdb-bot/src/modules/level/command/__init__.py b/kdb-bot/src/modules/level/command/__init__.py index 31a33eac..958058b4 100644 --- a/kdb-bot/src/modules/level/command/__init__.py +++ b/kdb-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.1" +__version__ = "1.1.6" 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="1") +version_info = VersionInfo(major="1", minor="1", micro="6") diff --git a/kdb-bot/src/modules/level/configuration/__init__.py b/kdb-bot/src/modules/level/configuration/__init__.py index 802ba4f4..1340f77d 100644 --- a/kdb-bot/src/modules/level/configuration/__init__.py +++ b/kdb-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.1" +__version__ = "1.1.6" 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="1") +version_info = VersionInfo(major="1", minor="1", micro="6") diff --git a/kdb-bot/src/modules/level/events/__init__.py b/kdb-bot/src/modules/level/events/__init__.py index 75c3efe3..1c7d6538 100644 --- a/kdb-bot/src/modules/level/events/__init__.py +++ b/kdb-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.1" +__version__ = "1.1.6" 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="1") +version_info = VersionInfo(major="1", minor="1", micro="6") diff --git a/kdb-bot/src/modules/level/level.json b/kdb-bot/src/modules/level/level.json index 2fb7a536..aac241e5 100644 --- a/kdb-bot/src/modules/level/level.json +++ b/kdb-bot/src/modules/level/level.json @@ -4,7 +4,7 @@ "Version": { "Major": "1", "Minor": "1", - "Micro": "1" + "Micro": "6" }, "Author": "", "AuthorEmail": "", diff --git a/kdb-bot/src/modules/level/service/__init__.py b/kdb-bot/src/modules/level/service/__init__.py index a04c2f81..baf51d2f 100644 --- a/kdb-bot/src/modules/level/service/__init__.py +++ b/kdb-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.1" +__version__ = "1.1.6" 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="1") +version_info = VersionInfo(major="1", minor="1", micro="6") diff --git a/kdb-bot/src/modules/level/service/level_service.py b/kdb-bot/src/modules/level/service/level_service.py index 3dccade3..e85c1719 100644 --- a/kdb-bot/src/modules/level/service/level_service.py +++ b/kdb-bot/src/modules/level/service/level_service.py @@ -40,6 +40,9 @@ class LevelService: def get_level(self, user: User) -> Level: levels_by_server = self._levels.get_levels_by_server_id(user.server.id) + if user.xp < 0: + return levels_by_server.order_by(lambda l: l.min_xp).first() + levels = levels_by_server.order_by(lambda l: l.min_xp).where(lambda l: user.xp >= l.min_xp) if levels.count() == 0: diff --git a/kdb-bot/src/modules/permission/__init__.py b/kdb-bot/src/modules/permission/__init__.py index 0ee2cb28..50356dc0 100644 --- a/kdb-bot/src/modules/permission/__init__.py +++ b/kdb-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.1" +__version__ = "1.1.6" 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="1") +version_info = VersionInfo(major="1", minor="1", micro="6") diff --git a/kdb-bot/src/modules/permission/abc/__init__.py b/kdb-bot/src/modules/permission/abc/__init__.py index 940c526d..4ded6a8e 100644 --- a/kdb-bot/src/modules/permission/abc/__init__.py +++ b/kdb-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.1" +__version__ = "1.1.6" 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="1") +version_info = VersionInfo(major="1", minor="1", micro="6") diff --git a/kdb-bot/src/modules/permission/events/__init__.py b/kdb-bot/src/modules/permission/events/__init__.py index 50f5ed44..046d7be3 100644 --- a/kdb-bot/src/modules/permission/events/__init__.py +++ b/kdb-bot/src/modules/permission/events/__init__.py @@ -15,7 +15,7 @@ __title__ = "modules.permission.events" __author__ = "Sven Heidemann" __license__ = "MIT" __copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de" -__version__ = "1.1.1" +__version__ = "1.1.6" 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="1") +version_info = VersionInfo(major="1", minor="1", micro="6") diff --git a/kdb-bot/src/modules/permission/permission.json b/kdb-bot/src/modules/permission/permission.json index 50e8a1d7..7b90445a 100644 --- a/kdb-bot/src/modules/permission/permission.json +++ b/kdb-bot/src/modules/permission/permission.json @@ -4,7 +4,7 @@ "Version": { "Major": "1", "Minor": "1", - "Micro": "1" + "Micro": "6" }, "Author": "", "AuthorEmail": "", diff --git a/kdb-bot/src/modules/permission/service/__init__.py b/kdb-bot/src/modules/permission/service/__init__.py index 3fba7748..171cdfa0 100644 --- a/kdb-bot/src/modules/permission/service/__init__.py +++ b/kdb-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.1" +__version__ = "1.1.6" 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="1") +version_info = VersionInfo(major="1", minor="1", micro="6") diff --git a/kdb-bot/src/modules/technician/__init__.py b/kdb-bot/src/modules/technician/__init__.py index 81b28724..0e73eb44 100644 --- a/kdb-bot/src/modules/technician/__init__.py +++ b/kdb-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.1" +__version__ = "1.1.6" 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="1") +version_info = VersionInfo(major="1", minor="1", micro="6") diff --git a/kdb-bot/src/modules/technician/command/__init__.py b/kdb-bot/src/modules/technician/command/__init__.py index 30be5df8..260f7e77 100644 --- a/kdb-bot/src/modules/technician/command/__init__.py +++ b/kdb-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.1" +__version__ = "1.1.6" 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="1") +version_info = VersionInfo(major="1", minor="1", micro="6") diff --git a/kdb-bot/src/modules/technician/command/sync_xp_command.py b/kdb-bot/src/modules/technician/command/sync_xp_command.py new file mode 100644 index 00000000..73b810d5 --- /dev/null +++ b/kdb-bot/src/modules/technician/command/sync_xp_command.py @@ -0,0 +1,156 @@ +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_translation import TranslatePipe +from discord import app_commands +from discord.ext import commands +from discord.ext.commands import Context + +from bot_core.abc.client_utils_abc import ClientUtilsABC +from bot_core.abc.message_service_abc import MessageServiceABC +from bot_core.configuration.feature_flags_enum import FeatureFlagsEnum +from bot_core.configuration.feature_flags_settings import FeatureFlagsSettings +from bot_core.helper.command_checks import CommandChecks +from bot_core.logging.command_logger import CommandLogger +from bot_data.abc.server_repository_abc import ServerRepositoryABC +from bot_data.abc.user_repository_abc import UserRepositoryABC +from bot_data.model.server_config import ServerConfig +from bot_data.model.technician_config import TechnicianConfig +from bot_data.model.user import User +from modules.permission.abc.permission_service_abc import PermissionServiceABC + + +class SyncXpGroup(DiscordCommandABC): + def __init__( + self, + logger: CommandLogger, + config: ConfigurationABC, + message_service: MessageServiceABC, + bot: DiscordBotServiceABC, + client_utils: ClientUtilsABC, + translate: TranslatePipe, + servers: ServerRepositoryABC, + users: UserRepositoryABC, + permissions: PermissionServiceABC, + settings: TechnicianConfig, + db: DatabaseContextABC, + ): + DiscordCommandABC.__init__(self) + + self._logger = logger + self._config = config + self._message_service = message_service + self._bot = bot + self._client_utils = client_utils + self._t = translate + self._servers = servers + self._users = users + self._permissions = permissions + self._settings = settings + self._db = db + + self._logger.trace(__name__, f"Loaded command service: {type(self).__name__}") + + @commands.hybrid_group(name="sync-xp") + @commands.guild_only() + async def sync_xp(self, ctx: Context): + pass + + @sync_xp.command(name="all-members") + @commands.guild_only() + @CommandChecks.check_is_ready() + @CommandChecks.check_is_member_technician() + async def all_members(self, ctx: Context, server_id: int): + self._logger.debug(__name__, f"Received command sync xp {ctx}") + + if ctx.guild is None: + return + + settings: ServerConfig = self._config.get_configuration(f"ServerConfig_{ctx.guild.id}") + if not FeatureFlagsSettings.get_flag_from_dict(settings.feature_flags, FeatureFlagsEnum.sync_xp): + await self._message_service.send_ctx_msg(ctx, self._t.transform("common.feature_not_activated")) + return + + other_server = self._servers.get_server_by_id(server_id) + users_on_other_server = self._users.get_users_by_server_id(other_server.id).where(lambda x: not x.left_server) + discord_ids_on_other_server = users_on_other_server.select(lambda x: x.discord_id) + + for user in self._users.get_users_by_server_id(self._servers.get_server_by_discord_id(ctx.guild.id).id).where( + lambda x: not x.left_server + ): + try: + if user.discord_id not in discord_ids_on_other_server: + continue + + user_on_other_server: User = users_on_other_server.where( + lambda x: x.discord_id == user.discord_id + ).first_or_default() + if user_on_other_server is None or user_on_other_server.xp <= user.xp: + continue + + user.xp = user_on_other_server.xp + self._users.update_user(user) + self._db.save_changes() + except Exception as e: + self._logger.error(__name__, f"Cannot sync user {user.name}", e) + + await self._message_service.send_ctx_msg(ctx, self._t.transform("modules.technician.synced_message")) + self._logger.trace(__name__, f"Finished sync xp command") + + @all_members.autocomplete("server_id") + async def list_autocomplete(self, interaction: discord.Interaction, current: str) -> list[app_commands.Choice]: + return [ + app_commands.Choice(name=server.name, value=server.id) + for server in self._client_utils.get_auto_complete_list( + self._servers.get_servers(), current, lambda x: x.name + ) + ] + + @sync_xp.command(name="by_member") + @commands.guild_only() + @CommandChecks.check_is_ready() + @CommandChecks.check_is_member_technician() + async def by_member(self, ctx: Context, server_id: int, member: discord.Member): + self._logger.debug(__name__, f"Received command sync xp {ctx}") + + if ctx.guild is None: + return + + settings: ServerConfig = self._config.get_configuration(f"ServerConfig_{ctx.guild.id}") + if not FeatureFlagsSettings.get_flag_from_dict(settings.feature_flags, FeatureFlagsEnum.sync_xp): + await self._message_service.send_ctx_msg(ctx, self._t.transform("common.feature_not_activated")) + return + + other_server = self._servers.get_server_by_id(server_id) + user = self._users.get_user_by_discord_id_and_server_id( + self._servers.get_server_by_discord_id(ctx.guild.id).id, member.id + ) + + try: + user_on_other_server = ( + self._users.get_users_by_server_id(other_server.id) + .where(lambda x: x.discord_id == member.id) + .first_or_default() + ) + if user_on_other_server is None or user_on_other_server.xp <= user.xp: + return + + user.xp = user_on_other_server.xp + self._users.update_user(user) + self._db.save_changes() + except Exception as e: + self._logger.error(__name__, f"Cannot sync user {user.name}", e) + + await self._message_service.send_ctx_msg(ctx, self._t.transform("modules.technician.synced_message")) + self._logger.trace(__name__, f"Finished sync xp command") + + @by_member.autocomplete("server_id") + async def list_autocomplete(self, interaction: discord.Interaction, current: str) -> list[app_commands.Choice]: + return [ + app_commands.Choice(name=server.name, value=server.id) + for server in self._client_utils.get_auto_complete_list( + self._servers.get_servers(), current, lambda x: x.name + ) + ] diff --git a/kdb-bot/src/modules/technician/technician.json b/kdb-bot/src/modules/technician/technician.json index 43b8a4f0..1fb18154 100644 --- a/kdb-bot/src/modules/technician/technician.json +++ b/kdb-bot/src/modules/technician/technician.json @@ -4,7 +4,7 @@ "Version": { "Major": "1", "Minor": "1", - "Micro": "1" + "Micro": "6" }, "Author": "", "AuthorEmail": "", diff --git a/kdb-bot/src/modules/technician/technician_module.py b/kdb-bot/src/modules/technician/technician_module.py index 57282ebc..5d5472ba 100644 --- a/kdb-bot/src/modules/technician/technician_module.py +++ b/kdb-bot/src/modules/technician/technician_module.py @@ -11,6 +11,7 @@ from modules.technician.command.api_key_group import ApiKeyGroup from modules.technician.command.log_command import LogCommand from modules.technician.command.restart_command import RestartCommand from modules.technician.command.shutdown_command import ShutdownCommand +from modules.technician.command.sync_xp_command import SyncXpGroup class TechnicianModule(ModuleABC): @@ -27,4 +28,5 @@ class TechnicianModule(ModuleABC): self._dc.add_command(ShutdownCommand) self._dc.add_command(LogCommand) self._dc.add_command(ApiKeyGroup) + self._dc.add_command(SyncXpGroup) # events diff --git a/kdb-bot/tools/checks/checks.json b/kdb-bot/tools/checks/checks.json index 1be230cc..343cbdf4 100644 --- a/kdb-bot/tools/checks/checks.json +++ b/kdb-bot/tools/checks/checks.json @@ -4,7 +4,7 @@ "Version": { "Major": "1", "Minor": "1", - "Micro": "1" + "Micro": "6" }, "Author": "Sven Heidemann", "AuthorEmail": "sven.heidemann@sh-edraft.de", diff --git a/kdb-bot/tools/get_version/get-version.json b/kdb-bot/tools/get_version/get-version.json index 1ec0e763..c9a5c83b 100644 --- a/kdb-bot/tools/get_version/get-version.json +++ b/kdb-bot/tools/get_version/get-version.json @@ -4,7 +4,7 @@ "Version": { "Major": "1", "Minor": "1", - "Micro": "1" + "Micro": "6" }, "Author": "Sven Heidemann", "AuthorEmail": "sven.heidemann@sh-edraft.de", diff --git a/kdb-bot/tools/post_build/post-build.json b/kdb-bot/tools/post_build/post-build.json index 74ff3592..40a46e27 100644 --- a/kdb-bot/tools/post_build/post-build.json +++ b/kdb-bot/tools/post_build/post-build.json @@ -4,7 +4,7 @@ "Version": { "Major": "1", "Minor": "1", - "Micro": "1" + "Micro": "6" }, "Author": "Sven Heidemann", "AuthorEmail": "sven.heidemann@sh-edraft.de", diff --git a/kdb-bot/tools/set_version/set-version.json b/kdb-bot/tools/set_version/set-version.json index f8f7d23b..f547987d 100644 --- a/kdb-bot/tools/set_version/set-version.json +++ b/kdb-bot/tools/set_version/set-version.json @@ -4,7 +4,7 @@ "Version": { "Major": "1", "Minor": "1", - "Micro": "1" + "Micro": "6" }, "Author": "Sven Heidemann", "AuthorEmail": "sven.heidemann@sh-edraft.de", diff --git a/kdb-web/package.json b/kdb-web/package.json index 39dc6c89..c640dd53 100644 --- a/kdb-web/package.json +++ b/kdb-web/package.json @@ -1,9 +1,9 @@ { "name": "kdb-web", - "version": "1.1.1", + "version": "1.1.6", "scripts": { "ng": "ng", - "update-version": "ts-node-esm update-version.ts", + "update-version": "ts-node update-version.ts", "prestart": "npm run update-version", "start": "ng serve", "prebuild": "npm run update-version", @@ -11,9 +11,9 @@ "watch": "ng build --watch --configuration development", "test": "ng test", "predocker-build": "npm run update-version", - "docker-build": "export VERSION=$npm_package_version; ng build; docker build -t kdb-web/kdb-web:$VERSION .", - "docker-build-dev": "export VERSION=$npm_package_version; ng build --configuration development; docker build -t kdb-web/kdb-web:$VERSION .", - "docker-build-stage": "export VERSION=$npm_package_version; ng build --configuration staging; docker build -t kdb-web/kdb-web:$VERSION ." + "docker-build": "export VERSION=$npm_package_version; ng build; docker build -t sh-edraft.de/kdb-web:$VERSION .", + "docker-build-dev": "export VERSION=$npm_package_version; ng build --configuration development; docker build -t sh-edraft.de/kdb-web:$VERSION .", + "docker-build-stage": "export VERSION=$npm_package_version; ng build --configuration staging; docker build -t sh-edraft.de/kdb-web:$VERSION ." }, "private": true, "dependencies": { @@ -51,4 +51,4 @@ "tslib": "^2.4.1", "typescript": "~4.9.5" } -} \ No newline at end of file +} diff --git a/kdb-web/src/app/models/config/server-config.model.ts b/kdb-web/src/app/models/config/server-config.model.ts index c2b1d1c8..3d17b8d2 100644 --- a/kdb-web/src/app/models/config/server-config.model.ts +++ b/kdb-web/src/app/models/config/server-config.model.ts @@ -16,6 +16,7 @@ export interface ServerConfig extends DataWithHistory { helpVoiceChannelId?: string; teamChannelId?: string; loginMessageChannelId?: string; + defaultRoleId?: string; featureFlags: FeatureFlag[]; afkChannelIds: string[]; moderatorRoleIds: string[]; diff --git a/kdb-web/src/app/models/graphql/mutations.model.ts b/kdb-web/src/app/models/graphql/mutations.model.ts index 20263626..6fc27fc0 100644 --- a/kdb-web/src/app/models/graphql/mutations.model.ts +++ b/kdb-web/src/app/models/graphql/mutations.model.ts @@ -211,6 +211,7 @@ export class Mutations { $helpVoiceChannelId: String, $teamChannelId: String, $loginMessageChannelId: String, + $defaultRoleId: String, $featureFlags: [FeatureFlagInput], $afkChannelIds: [String], $moderatorRoleIds: [String], @@ -232,6 +233,7 @@ export class Mutations { helpVoiceChannelId: $helpVoiceChannelId, teamChannelId: $teamChannelId, loginMessageChannelId: $loginMessageChannelId, + defaultRoleId: $defaultRoleId, featureFlags: $featureFlags, afkChannelIds: $afkChannelIds, moderatorRoleIds: $moderatorRoleIds, diff --git a/kdb-web/src/app/models/graphql/queries.model.ts b/kdb-web/src/app/models/graphql/queries.model.ts index bd83b01d..1014ec79 100644 --- a/kdb-web/src/app/models/graphql/queries.model.ts +++ b/kdb-web/src/app/models/graphql/queries.model.ts @@ -424,6 +424,7 @@ export class Queries { helpVoiceChannelId teamChannelId loginMessageChannelId + defaultRoleId featureFlags { key value diff --git a/kdb-web/src/app/modules/view/server/config/components/config/config.component.html b/kdb-web/src/app/modules/view/server/config/components/config/config.component.html index 89b1372e..2512a986 100644 --- a/kdb-web/src/app/modules/view/server/config/components/config/config.component.html +++ b/kdb-web/src/app/modules/view/server/config/components/config/config.component.html @@ -114,6 +114,14 @@ +
+
+
{{'view.server.config.bot.default_role_id' | translate}}:
+ +
+
+
diff --git a/kdb-web/src/app/modules/view/server/config/components/config/config.component.ts b/kdb-web/src/app/modules/view/server/config/components/config/config.component.ts index 70855220..ed82b024 100644 --- a/kdb-web/src/app/modules/view/server/config/components/config/config.component.ts +++ b/kdb-web/src/app/modules/view/server/config/components/config/config.component.ts @@ -118,6 +118,7 @@ export class ConfigComponent implements OnInit { helpVoiceChannelId: this.config.helpVoiceChannelId, teamChannelId: this.config.teamChannelId, loginMessageChannelId: this.config.loginMessageChannelId, + defaultRoleId: this.config.defaultRoleId, featureFlags: this.config.featureFlags, afkChannelIds: this.config.afkChannelIds, moderatorRoleIds: this.config.moderatorRoleIds, diff --git a/kdb-web/src/assets/i18n/de.json b/kdb-web/src/assets/i18n/de.json index cd900f90..0eb8d3b2 100644 --- a/kdb-web/src/assets/i18n/de.json +++ b/kdb-web/src/assets/i18n/de.json @@ -412,6 +412,7 @@ "admin_roles": "Admin Rollen", "afk_channels": "AFK Sprachkanäle", "afk_command_channel_id": "AFK Kanal für den Befehl /afk", + "default_role_id": "Standardrolle des Servers", "header": "Bot Konfiguration", "help_voice_channel_id": "Sprachkanal für Hilfsbenachrichtung", "login_message_channel_id": "Kanal für die Nachricht vom Bot nach Start", diff --git a/kdb-web/src/assets/i18n/en.json b/kdb-web/src/assets/i18n/en.json index 7f6423e6..c19e61bf 100644 --- a/kdb-web/src/assets/i18n/en.json +++ b/kdb-web/src/assets/i18n/en.json @@ -412,6 +412,7 @@ "admin_roles": "Admin Roles", "afk_channels": "AFK Voicechannel", "afk_command_channel_id": "AFK Channel for the command /afk", + "default_role_id": "Default role", "header": "Bot configuration", "help_voice_channel_id": "Voicechannel für help notifications", "login_message_channel_id": "Channel for bot message after start", diff --git a/kdb-web/src/assets/version.json b/kdb-web/src/assets/version.json index 17952632..e6fe0a48 100644 --- a/kdb-web/src/assets/version.json +++ b/kdb-web/src/assets/version.json @@ -2,6 +2,6 @@ "WebVersion": { "Major": "1", "Minor": "1", - "Micro": "1" + "Micro": "6" } } \ No newline at end of file