1.1.8 #384

Merged
edraft merged 9 commits from 1.1.8 into support 2023-09-29 19:20:42 +02:00
133 changed files with 902 additions and 201 deletions
Showing only changes of commit 74f3ee2f08 - Show all commits

View File

@ -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: '{}'

View File

@ -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: '{}'

View File

@ -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

86
docker-compose.yml Normal file
View File

@ -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

View File

@ -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;"

View File

@ -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")

View File

@ -4,7 +4,7 @@
"Version": {
"Major": "1",
"Minor": "1",
"Micro": "1"
"Micro": "6"
},
"Author": "Sven Heidemann",
"AuthorEmail": "sven.heidemann@sh-edraft.de",

View File

@ -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")

View File

@ -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

View File

@ -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 :)"

View File

@ -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")

View File

@ -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")

View File

@ -4,7 +4,7 @@
"Version": {
"Major": "1",
"Minor": "1",
"Micro": "1"
"Micro": "6"
},
"Author": "",
"AuthorEmail": "",

@ -1 +1 @@
Subproject commit 3d81c81c9ef9b02f33b4f1a6167c67c040170d0a
Subproject commit b6ffed4da1f75f5fbad1ce7f312b67f32de010b5

View File

@ -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")

View File

@ -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")

View File

@ -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")

View File

@ -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")

View File

@ -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")

View File

@ -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")

View File

@ -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")

View File

@ -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")

View File

@ -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")

View File

@ -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")

View File

@ -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")

View File

@ -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")

View File

@ -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")

View File

@ -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")

View File

@ -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")

View File

@ -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

View File

@ -4,7 +4,7 @@
"Version": {
"Major": "1",
"Minor": "1",
"Micro": "1"
"Micro": "6"
},
"Author": "Sven Heidemann",
"AuthorEmail": "sven.heidemann@sh-edraft.de",

View File

@ -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")

View File

@ -20,3 +20,5 @@ class FeatureFlagsEnum(Enum):
api_only = "ApiOnly"
presence = "Presence"
version_in_presence = "VersionInPresence"
game_server = "GameServer"
sync_xp = "SyncXp"

View File

@ -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):

View File

@ -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")

View File

@ -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")

View File

@ -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")

View File

@ -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")

View File

@ -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")

View File

@ -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")

View File

@ -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")

View File

@ -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)

View File

@ -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()

View File

@ -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")

View File

@ -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")

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -4,7 +4,7 @@
"Version": {
"Major": "1",
"Minor": "1",
"Micro": "1"
"Micro": "6"
},
"Author": "Sven Heidemann",
"AuthorEmail": "sven.heidemann@sh-edraft.de",

View File

@ -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")

View File

@ -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;
"""
)
)

View File

@ -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")

View File

@ -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};

View File

@ -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

View File

@ -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(

View File

@ -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:

View File

@ -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:

View File

@ -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")

View File

@ -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()}")

View File

@ -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}")

View File

@ -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],
)

View File

@ -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__,

View File

@ -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")

View File

@ -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")

View File

@ -4,7 +4,7 @@
"Version": {
"Major": "1",
"Minor": "1",
"Micro": "1"
"Micro": "6"
},
"Author": "Sven Heidemann",
"AuthorEmail": "sven.heidemann@sh-edraft.de",

View File

@ -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")

View File

@ -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]

View File

@ -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")

View File

@ -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")

View File

@ -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

View File

@ -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)

View File

@ -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")

View File

@ -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")

View File

@ -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]),

View File

@ -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")

View File

@ -4,7 +4,7 @@
"Version": {
"Major": "1",
"Minor": "1",
"Micro": "1"
"Micro": "6"
},
"Author": "Sven Heidemann",
"AuthorEmail": "sven.heidemann@sh-edraft.de",

View File

@ -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")

View File

@ -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")

View File

@ -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")

View File

@ -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")

View File

@ -4,7 +4,7 @@
"Version": {
"Major": "1",
"Minor": "1",
"Micro": "1"
"Micro": "6"
},
"Author": "",
"AuthorEmail": "",

View File

@ -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")

View File

@ -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")

View File

@ -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")

View File

@ -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")

View File

@ -4,7 +4,7 @@
"Version": {
"Major": "1",
"Minor": "1",
"Micro": "1"
"Micro": "6"
},
"Author": "",
"AuthorEmail": "",

View File

@ -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")

View File

@ -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)
]

View File

@ -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")

View File

@ -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)

View File

@ -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")

View File

@ -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")

View File

@ -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")

View File

@ -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")

View File

@ -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")

View File

@ -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")

View File

@ -4,7 +4,7 @@
"Version": {
"Major": "1",
"Minor": "1",
"Micro": "1"
"Micro": "6"
},
"Author": "",
"AuthorEmail": "",

View File

@ -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")

View File

@ -4,7 +4,7 @@
"Version": {
"Major": "1",
"Minor": "1",
"Micro": "1"
"Micro": "6"
},
"Author": "",
"AuthorEmail": "",

View File

@ -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")

Some files were not shown because too many files have changed in this diff Show More