diff --git a/docker-compose.staging.yml b/docker-compose.staging.yml index ff05cefc..d6133b82 100644 --- a/docker-compose.staging.yml +++ b/docker-compose.staging.yml @@ -5,7 +5,7 @@ volumes: services: kdb_bot_staging_1: - image: sh-edraft.de/kdb-bot:1.1.6 + image: sh-edraft.de/kdb-bot:1.1.7 container_name: kdb_bot_staging_1 depends_on: - kdb_db_staging_1 @@ -32,7 +32,7 @@ services: memory: 1024M kdb_web_staging_1: - image: sh-edraft.de/kdb-web:1.1.6 + image: sh-edraft.de/kdb-web:1.1.7 container_name: kdb_web_staging_1 depends_on: - kdb_bot_staging_1 diff --git a/docker-compose.yml b/docker-compose.yml index ccfdb542..2da98c4f 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -5,7 +5,7 @@ volumes: services: kdb_bot_prod_1: - image: sh-edraft.de/kdb-bot:1.1.6 + image: sh-edraft.de/kdb-bot:1.1.7 depends_on: - kdb_db_prod_1 networks: @@ -30,7 +30,7 @@ services: memory: 1024M kdb_web_prod_1: - image: sh-edraft.de/kdb-web:1.1.6 + image: sh-edraft.de/kdb-web:1.1.7 depends_on: - kdb_bot_prod_1 networks: diff --git a/kdb-bot/cpl-workspace.json b/kdb-bot/cpl-workspace.json index 29d7ef29..8e010570 100644 --- a/kdb-bot/cpl-workspace.json +++ b/kdb-bot/cpl-workspace.json @@ -16,6 +16,7 @@ "level": "src/modules/level/level.json", "permission": "src/modules/permission/permission.json", "technician": "src/modules/technician/technician.json", + "short-role-name": "src/modules/short_role_name/short-role-name.json", "checks": "tools/checks/checks.json", "get-version": "tools/get_version/get-version.json", "post-build": "tools/post_build/post-build.json", diff --git a/kdb-bot/src/bot/__init__.py b/kdb-bot/src/bot/__init__.py index 2f4dc7ca..a99ba5c7 100644 --- a/kdb-bot/src/bot/__init__.py +++ b/kdb-bot/src/bot/__init__.py @@ -1,10 +1,10 @@ # -*- coding: utf-8 -*- """ -bot Keksdose bot +bot sh-edraft.de Discord bot ~~~~~~~~~~~~~~~~~~~ -Discord bot for the Keksdose discord Server +Discord bot for customers of sh-edraft.de :copyright: (c) 2022 - 2023 sh-edraft.de :license: MIT, see LICENSE for more details. @@ -15,7 +15,7 @@ __title__ = "bot" __author__ = "Sven Heidemann" __license__ = "MIT" __copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de" -__version__ = "1.1.6" +__version__ = "1.1.7" 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="6") +version_info = VersionInfo(major="1", minor="1", micro="7") diff --git a/kdb-bot/src/bot/bot.json b/kdb-bot/src/bot/bot.json index 9f0c063b..c06ecd27 100644 --- a/kdb-bot/src/bot/bot.json +++ b/kdb-bot/src/bot/bot.json @@ -4,12 +4,12 @@ "Version": { "Major": "1", "Minor": "1", - "Micro": "6" + "Micro": "7" }, "Author": "Sven Heidemann", "AuthorEmail": "sven.heidemann@sh-edraft.de", - "Description": "Keksdose bot", - "LongDescription": "Discord bot for the Keksdose discord Server", + "Description": "sh-edraft.de Discord bot", + "LongDescription": "Discord bot for customers of sh-edraft.de", "URL": "https://www.sh-edraft.de", "CopyrightDate": "2022 - 2023", "CopyrightName": "sh-edraft.de", @@ -68,6 +68,7 @@ "../modules/database/database.json", "../modules/level/level.json", "../modules/permission/permission.json", + "../modules/short_role_name/short-role-name.json", "../modules/technician/technician.json" ] } diff --git a/kdb-bot/src/bot/extension/__init__.py b/kdb-bot/src/bot/extension/__init__.py index ab1e0d0c..46864b75 100644 --- a/kdb-bot/src/bot/extension/__init__.py +++ b/kdb-bot/src/bot/extension/__init__.py @@ -1,10 +1,10 @@ # -*- coding: utf-8 -*- """ -bot Keksdose bot +bot sh-edraft.de Discord bot ~~~~~~~~~~~~~~~~~~~ -Discord bot for the Keksdose discord Server +Discord bot for customers of sh-edraft.de :copyright: (c) 2022 - 2023 sh-edraft.de :license: MIT, see LICENSE for more details. @@ -15,7 +15,7 @@ __title__ = "bot.extension" __author__ = "Sven Heidemann" __license__ = "MIT" __copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de" -__version__ = "1.1.6" +__version__ = "1.1.7" 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="6") +version_info = VersionInfo(major="1", minor="1", micro="7") diff --git a/kdb-bot/src/bot/module_list.py b/kdb-bot/src/bot/module_list.py index 3e5fea34..810a0851 100644 --- a/kdb-bot/src/bot/module_list.py +++ b/kdb-bot/src/bot/module_list.py @@ -13,6 +13,7 @@ from modules.config.config_module import ConfigModule from modules.database.database_module import DatabaseModule from modules.level.level_module import LevelModule from modules.permission.permission_module import PermissionModule +from modules.short_role_name.short_role_name_module import ShortRoleNameModule from modules.technician.technician_module import TechnicianModule @@ -35,6 +36,7 @@ class ModuleList: ApiModule, TechnicianModule, AchievementsModule, + ShortRoleNameModule, # has to be last! BootLogModule, CoreExtensionModule, diff --git a/kdb-bot/src/bot/startup_migration_extension.py b/kdb-bot/src/bot/startup_migration_extension.py index b8f9eece..527958ae 100644 --- a/kdb-bot/src/bot/startup_migration_extension.py +++ b/kdb-bot/src/bot/startup_migration_extension.py @@ -13,9 +13,11 @@ from bot_data.migration.config_feature_flags_migration import ConfigFeatureFlags from bot_data.migration.config_migration import ConfigMigration from bot_data.migration.db_history_migration import DBHistoryMigration from bot_data.migration.default_role_migration import DefaultRoleMigration +from bot_data.migration.fix_updates_migration import FixUpdatesMigration from bot_data.migration.initial_migration import InitialMigration from bot_data.migration.level_migration import LevelMigration from bot_data.migration.remove_stats_migration import RemoveStatsMigration +from bot_data.migration.short_role_name_migration import ShortRoleNameMigration from bot_data.migration.stats_migration import StatsMigration from bot_data.migration.user_joined_game_server_migration import UserJoinedGameServerMigration from bot_data.migration.user_message_count_per_hour_migration import ( @@ -50,3 +52,5 @@ class StartupMigrationExtension(StartupExtensionABC): 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 + services.add_transient(MigrationABC, ShortRoleNameMigration) # 28.09.2023 #378 - 1.1.7 + services.add_transient(MigrationABC, FixUpdatesMigration) # 28.09.2023 #378 - 1.1.7 diff --git a/kdb-bot/src/bot_api/__init__.py b/kdb-bot/src/bot_api/__init__.py index 99edb8d3..56046548 100644 --- a/kdb-bot/src/bot_api/__init__.py +++ b/kdb-bot/src/bot_api/__init__.py @@ -1,10 +1,10 @@ # -*- coding: utf-8 -*- """ -bot Keksdose bot +bot sh-edraft.de Discord bot ~~~~~~~~~~~~~~~~~~~ -Discord bot for the Keksdose discord Server +Discord bot for customers of sh-edraft.de :copyright: (c) 2022 - 2023 sh-edraft.de :license: MIT, see LICENSE for more details. @@ -15,7 +15,7 @@ __title__ = "bot_api" __author__ = "Sven Heidemann" __license__ = "MIT" __copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de" -__version__ = "1.1.6" +__version__ = "1.1.7" 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="6") +version_info = VersionInfo(major="1", minor="1", micro="7") diff --git a/kdb-bot/src/bot_api/abc/__init__.py b/kdb-bot/src/bot_api/abc/__init__.py index 45d47bf7..bfee7dce 100644 --- a/kdb-bot/src/bot_api/abc/__init__.py +++ b/kdb-bot/src/bot_api/abc/__init__.py @@ -1,10 +1,10 @@ # -*- coding: utf-8 -*- """ -bot Keksdose bot +bot sh-edraft.de Discord bot ~~~~~~~~~~~~~~~~~~~ -Discord bot for the Keksdose discord Server +Discord bot for customers of sh-edraft.de :copyright: (c) 2022 - 2023 sh-edraft.de :license: MIT, see LICENSE for more details. @@ -15,7 +15,7 @@ __title__ = "bot_api.abc" __author__ = "Sven Heidemann" __license__ = "MIT" __copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de" -__version__ = "1.1.6" +__version__ = "1.1.7" 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="6") +version_info = VersionInfo(major="1", minor="1", micro="7") diff --git a/kdb-bot/src/bot_api/bot-api.json b/kdb-bot/src/bot_api/bot-api.json index 6f4d2c1c..90254d8f 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": "6" + "Micro": "7" }, "Author": "", "AuthorEmail": "", diff --git a/kdb-bot/src/bot_api/configuration/__init__.py b/kdb-bot/src/bot_api/configuration/__init__.py index 70de4cf2..99bce8b2 100644 --- a/kdb-bot/src/bot_api/configuration/__init__.py +++ b/kdb-bot/src/bot_api/configuration/__init__.py @@ -1,10 +1,10 @@ # -*- coding: utf-8 -*- """ -bot Keksdose bot +bot sh-edraft.de Discord bot ~~~~~~~~~~~~~~~~~~~ -Discord bot for the Keksdose discord Server +Discord bot for customers of sh-edraft.de :copyright: (c) 2022 - 2023 sh-edraft.de :license: MIT, see LICENSE for more details. @@ -15,7 +15,7 @@ __title__ = "bot_api.configuration" __author__ = "Sven Heidemann" __license__ = "MIT" __copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de" -__version__ = "1.1.6" +__version__ = "1.1.7" 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="6") +version_info = VersionInfo(major="1", minor="1", micro="7") diff --git a/kdb-bot/src/bot_api/controller/__init__.py b/kdb-bot/src/bot_api/controller/__init__.py index 474d7841..827e00b7 100644 --- a/kdb-bot/src/bot_api/controller/__init__.py +++ b/kdb-bot/src/bot_api/controller/__init__.py @@ -1,10 +1,10 @@ # -*- coding: utf-8 -*- """ -bot Keksdose bot +bot sh-edraft.de Discord bot ~~~~~~~~~~~~~~~~~~~ -Discord bot for the Keksdose discord Server +Discord bot for customers of sh-edraft.de :copyright: (c) 2022 - 2023 sh-edraft.de :license: MIT, see LICENSE for more details. @@ -15,7 +15,7 @@ __title__ = "bot_api.controller" __author__ = "Sven Heidemann" __license__ = "MIT" __copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de" -__version__ = "1.1.6" +__version__ = "1.1.7" 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="6") +version_info = VersionInfo(major="1", minor="1", micro="7") diff --git a/kdb-bot/src/bot_api/event/__init__.py b/kdb-bot/src/bot_api/event/__init__.py index 7a3cc29f..4365338f 100644 --- a/kdb-bot/src/bot_api/event/__init__.py +++ b/kdb-bot/src/bot_api/event/__init__.py @@ -1,10 +1,10 @@ # -*- coding: utf-8 -*- """ -bot Keksdose bot +bot sh-edraft.de Discord bot ~~~~~~~~~~~~~~~~~~~ -Discord bot for the Keksdose discord Server +Discord bot for customers of sh-edraft.de :copyright: (c) 2022 - 2023 sh-edraft.de :license: MIT, see LICENSE for more details. @@ -15,7 +15,7 @@ __title__ = "bot_api.event" __author__ = "Sven Heidemann" __license__ = "MIT" __copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de" -__version__ = "1.1.6" +__version__ = "1.1.7" 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="6") +version_info = VersionInfo(major="1", minor="1", micro="7") diff --git a/kdb-bot/src/bot_api/exception/__init__.py b/kdb-bot/src/bot_api/exception/__init__.py index 55055c27..a35e68e2 100644 --- a/kdb-bot/src/bot_api/exception/__init__.py +++ b/kdb-bot/src/bot_api/exception/__init__.py @@ -1,10 +1,10 @@ # -*- coding: utf-8 -*- """ -bot Keksdose bot +bot sh-edraft.de Discord bot ~~~~~~~~~~~~~~~~~~~ -Discord bot for the Keksdose discord Server +Discord bot for customers of sh-edraft.de :copyright: (c) 2022 - 2023 sh-edraft.de :license: MIT, see LICENSE for more details. @@ -15,7 +15,7 @@ __title__ = "bot_api.exception" __author__ = "Sven Heidemann" __license__ = "MIT" __copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de" -__version__ = "1.1.6" +__version__ = "1.1.7" 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="6") +version_info = VersionInfo(major="1", minor="1", micro="7") diff --git a/kdb-bot/src/bot_api/filter/__init__.py b/kdb-bot/src/bot_api/filter/__init__.py index 77145c97..e44a848e 100644 --- a/kdb-bot/src/bot_api/filter/__init__.py +++ b/kdb-bot/src/bot_api/filter/__init__.py @@ -1,10 +1,10 @@ # -*- coding: utf-8 -*- """ -bot Keksdose bot +bot sh-edraft.de Discord bot ~~~~~~~~~~~~~~~~~~~ -Discord bot for the Keksdose discord Server +Discord bot for customers of sh-edraft.de :copyright: (c) 2022 - 2023 sh-edraft.de :license: MIT, see LICENSE for more details. @@ -15,7 +15,7 @@ __title__ = "bot_api.filter" __author__ = "Sven Heidemann" __license__ = "MIT" __copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de" -__version__ = "1.1.6" +__version__ = "1.1.7" 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="6") +version_info = VersionInfo(major="1", minor="1", micro="7") diff --git a/kdb-bot/src/bot_api/filter/discord/__init__.py b/kdb-bot/src/bot_api/filter/discord/__init__.py index 38245fe3..c02e568e 100644 --- a/kdb-bot/src/bot_api/filter/discord/__init__.py +++ b/kdb-bot/src/bot_api/filter/discord/__init__.py @@ -1,10 +1,10 @@ # -*- coding: utf-8 -*- """ -bot Keksdose bot +bot sh-edraft.de Discord bot ~~~~~~~~~~~~~~~~~~~ -Discord bot for the Keksdose discord Server +Discord bot for customers of sh-edraft.de :copyright: (c) 2022 - 2023 sh-edraft.de :license: MIT, see LICENSE for more details. @@ -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.6" +__version__ = "1.1.7" 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="6") +version_info = VersionInfo(major="1", minor="1", micro="7") diff --git a/kdb-bot/src/bot_api/logging/__init__.py b/kdb-bot/src/bot_api/logging/__init__.py index fcd37e0c..d673fa5d 100644 --- a/kdb-bot/src/bot_api/logging/__init__.py +++ b/kdb-bot/src/bot_api/logging/__init__.py @@ -1,10 +1,10 @@ # -*- coding: utf-8 -*- """ -bot Keksdose bot +bot sh-edraft.de Discord bot ~~~~~~~~~~~~~~~~~~~ -Discord bot for the Keksdose discord Server +Discord bot for customers of sh-edraft.de :copyright: (c) 2022 - 2023 sh-edraft.de :license: MIT, see LICENSE for more details. @@ -15,7 +15,7 @@ __title__ = "bot_api.logging" __author__ = "Sven Heidemann" __license__ = "MIT" __copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de" -__version__ = "1.1.6" +__version__ = "1.1.7" 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="6") +version_info = VersionInfo(major="1", minor="1", micro="7") diff --git a/kdb-bot/src/bot_api/model/__init__.py b/kdb-bot/src/bot_api/model/__init__.py index 4d0b966b..fe5c4f03 100644 --- a/kdb-bot/src/bot_api/model/__init__.py +++ b/kdb-bot/src/bot_api/model/__init__.py @@ -1,10 +1,10 @@ # -*- coding: utf-8 -*- """ -bot Keksdose bot +bot sh-edraft.de Discord bot ~~~~~~~~~~~~~~~~~~~ -Discord bot for the Keksdose discord Server +Discord bot for customers of sh-edraft.de :copyright: (c) 2022 - 2023 sh-edraft.de :license: MIT, see LICENSE for more details. @@ -15,7 +15,7 @@ __title__ = "bot_api.model" __author__ = "Sven Heidemann" __license__ = "MIT" __copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de" -__version__ = "1.1.6" +__version__ = "1.1.7" 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="6") +version_info = VersionInfo(major="1", minor="1", micro="7") diff --git a/kdb-bot/src/bot_api/model/discord/__init__.py b/kdb-bot/src/bot_api/model/discord/__init__.py index d482dff9..12be903d 100644 --- a/kdb-bot/src/bot_api/model/discord/__init__.py +++ b/kdb-bot/src/bot_api/model/discord/__init__.py @@ -1,10 +1,10 @@ # -*- coding: utf-8 -*- """ -bot Keksdose bot +bot sh-edraft.de Discord bot ~~~~~~~~~~~~~~~~~~~ -Discord bot for the Keksdose discord Server +Discord bot for customers of sh-edraft.de :copyright: (c) 2022 - 2023 sh-edraft.de :license: MIT, see LICENSE for more details. @@ -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.6" +__version__ = "1.1.7" 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="6") +version_info = VersionInfo(major="1", minor="1", micro="7") diff --git a/kdb-bot/src/bot_api/route/__init__.py b/kdb-bot/src/bot_api/route/__init__.py index 1e63cbc6..31306cd2 100644 --- a/kdb-bot/src/bot_api/route/__init__.py +++ b/kdb-bot/src/bot_api/route/__init__.py @@ -1,10 +1,10 @@ # -*- coding: utf-8 -*- """ -bot Keksdose bot +bot sh-edraft.de Discord bot ~~~~~~~~~~~~~~~~~~~ -Discord bot for the Keksdose discord Server +Discord bot for customers of sh-edraft.de :copyright: (c) 2022 - 2023 sh-edraft.de :license: MIT, see LICENSE for more details. @@ -15,7 +15,7 @@ __title__ = "bot_api.route" __author__ = "Sven Heidemann" __license__ = "MIT" __copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de" -__version__ = "1.1.6" +__version__ = "1.1.7" 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="6") +version_info = VersionInfo(major="1", minor="1", micro="7") diff --git a/kdb-bot/src/bot_api/service/__init__.py b/kdb-bot/src/bot_api/service/__init__.py index ba7b31ba..ad87feeb 100644 --- a/kdb-bot/src/bot_api/service/__init__.py +++ b/kdb-bot/src/bot_api/service/__init__.py @@ -1,10 +1,10 @@ # -*- coding: utf-8 -*- """ -bot Keksdose bot +bot sh-edraft.de Discord bot ~~~~~~~~~~~~~~~~~~~ -Discord bot for the Keksdose discord Server +Discord bot for customers of sh-edraft.de :copyright: (c) 2022 - 2023 sh-edraft.de :license: MIT, see LICENSE for more details. @@ -15,7 +15,7 @@ __title__ = "bot_api.service" __author__ = "Sven Heidemann" __license__ = "MIT" __copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de" -__version__ = "1.1.6" +__version__ = "1.1.7" 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="6") +version_info = VersionInfo(major="1", minor="1", micro="7") diff --git a/kdb-bot/src/bot_api/transformer/__init__.py b/kdb-bot/src/bot_api/transformer/__init__.py index 93e08c87..b83b5db0 100644 --- a/kdb-bot/src/bot_api/transformer/__init__.py +++ b/kdb-bot/src/bot_api/transformer/__init__.py @@ -1,10 +1,10 @@ # -*- coding: utf-8 -*- """ -bot Keksdose bot +bot sh-edraft.de Discord bot ~~~~~~~~~~~~~~~~~~~ -Discord bot for the Keksdose discord Server +Discord bot for customers of sh-edraft.de :copyright: (c) 2022 - 2023 sh-edraft.de :license: MIT, see LICENSE for more details. @@ -15,7 +15,7 @@ __title__ = "bot_api.transformer" __author__ = "Sven Heidemann" __license__ = "MIT" __copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de" -__version__ = "1.1.6" +__version__ = "1.1.7" 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="6") +version_info = VersionInfo(major="1", minor="1", micro="7") diff --git a/kdb-bot/src/bot_core/__init__.py b/kdb-bot/src/bot_core/__init__.py index c5e0872a..abcd632b 100644 --- a/kdb-bot/src/bot_core/__init__.py +++ b/kdb-bot/src/bot_core/__init__.py @@ -1,10 +1,10 @@ # -*- coding: utf-8 -*- """ -bot Keksdose bot +bot sh-edraft.de Discord bot ~~~~~~~~~~~~~~~~~~~ -Discord bot for the Keksdose discord Server +Discord bot for customers of sh-edraft.de :copyright: (c) 2022 - 2023 sh-edraft.de :license: MIT, see LICENSE for more details. @@ -15,7 +15,7 @@ __title__ = "bot_core" __author__ = "Sven Heidemann" __license__ = "MIT" __copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de" -__version__ = "1.1.6" +__version__ = "1.1.7" 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="6") +version_info = VersionInfo(major="1", minor="1", micro="7") diff --git a/kdb-bot/src/bot_core/abc/__init__.py b/kdb-bot/src/bot_core/abc/__init__.py index 452f6763..c85cb67d 100644 --- a/kdb-bot/src/bot_core/abc/__init__.py +++ b/kdb-bot/src/bot_core/abc/__init__.py @@ -1,10 +1,10 @@ # -*- coding: utf-8 -*- """ -bot Keksdose bot +bot sh-edraft.de Discord bot ~~~~~~~~~~~~~~~~~~~ -Discord bot for the Keksdose discord Server +Discord bot for customers of sh-edraft.de :copyright: (c) 2022 - 2023 sh-edraft.de :license: MIT, see LICENSE for more details. @@ -15,7 +15,7 @@ __title__ = "bot_core.abc" __author__ = "Sven Heidemann" __license__ = "MIT" __copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de" -__version__ = "1.1.6" +__version__ = "1.1.7" 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="6") +version_info = VersionInfo(major="1", minor="1", micro="7") diff --git a/kdb-bot/src/bot_core/bot-core.json b/kdb-bot/src/bot_core/bot-core.json index 384e8c4b..e1f636da 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": "6" + "Micro": "7" }, "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 9e8b82e8..3667c9d4 100644 --- a/kdb-bot/src/bot_core/configuration/__init__.py +++ b/kdb-bot/src/bot_core/configuration/__init__.py @@ -1,10 +1,10 @@ # -*- coding: utf-8 -*- """ -bot Keksdose bot +bot sh-edraft.de Discord bot ~~~~~~~~~~~~~~~~~~~ -Discord bot for the Keksdose discord Server +Discord bot for customers of sh-edraft.de :copyright: (c) 2022 - 2023 sh-edraft.de :license: MIT, see LICENSE for more details. @@ -15,7 +15,7 @@ __title__ = "bot_core.configuration" __author__ = "Sven Heidemann" __license__ = "MIT" __copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de" -__version__ = "1.1.6" +__version__ = "1.1.7" 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="6") +version_info = VersionInfo(major="1", minor="1", micro="7") 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 d91d18f4..c267ccc4 100644 --- a/kdb-bot/src/bot_core/configuration/feature_flags_enum.py +++ b/kdb-bot/src/bot_core/configuration/feature_flags_enum.py @@ -16,9 +16,11 @@ class FeatureFlagsEnum(Enum): level_module = "LevelModule" moderator_module = "ModeratorModule" permission_module = "PermissionModule" + short_role_name_module = "ShortRoleNameModule" # features api_only = "ApiOnly" presence = "Presence" version_in_presence = "VersionInPresence" game_server = "GameServer" sync_xp = "SyncXp" + short_role_name = "ShortRoleName" 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 c90684a3..51f8d924 100644 --- a/kdb-bot/src/bot_core/configuration/feature_flags_settings.py +++ b/kdb-bot/src/bot_core/configuration/feature_flags_settings.py @@ -18,12 +18,14 @@ class FeatureFlagsSettings(ConfigurationModelABC): FeatureFlagsEnum.moderator_module.value: False, # 02.10.2022 #48 FeatureFlagsEnum.permission_module.value: True, # 02.10.2022 #48 FeatureFlagsEnum.config_module.value: True, # 19.07.2023 #127 + FeatureFlagsEnum.short_role_name_module.value: True, # 28.09.2023 #378 # features 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 + FeatureFlagsEnum.short_role_name.value: False, # 28.09.2023 #378 } 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 658eaffc..605441e3 100644 --- a/kdb-bot/src/bot_core/core_extension/__init__.py +++ b/kdb-bot/src/bot_core/core_extension/__init__.py @@ -1,10 +1,10 @@ # -*- coding: utf-8 -*- """ -bot Keksdose bot +bot sh-edraft.de Discord bot ~~~~~~~~~~~~~~~~~~~ -Discord bot for the Keksdose discord Server +Discord bot for customers of sh-edraft.de :copyright: (c) 2022 - 2023 sh-edraft.de :license: MIT, see LICENSE for more details. @@ -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.6" +__version__ = "1.1.7" 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="6") +version_info = VersionInfo(major="1", minor="1", micro="7") diff --git a/kdb-bot/src/bot_core/events/__init__.py b/kdb-bot/src/bot_core/events/__init__.py index c31d23d0..cd82e103 100644 --- a/kdb-bot/src/bot_core/events/__init__.py +++ b/kdb-bot/src/bot_core/events/__init__.py @@ -1,10 +1,10 @@ # -*- coding: utf-8 -*- """ -bot Keksdose bot +bot sh-edraft.de Discord bot ~~~~~~~~~~~~~~~~~~~ -Discord bot for the Keksdose discord Server +Discord bot for customers of sh-edraft.de :copyright: (c) 2022 - 2023 sh-edraft.de :license: MIT, see LICENSE for more details. @@ -15,7 +15,7 @@ __title__ = "bot_core.events" __author__ = "Sven Heidemann" __license__ = "MIT" __copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de" -__version__ = "1.1.6" +__version__ = "1.1.7" 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="6") +version_info = VersionInfo(major="1", minor="1", micro="7") diff --git a/kdb-bot/src/bot_core/exception/__init__.py b/kdb-bot/src/bot_core/exception/__init__.py index 96b2feae..35dbdd70 100644 --- a/kdb-bot/src/bot_core/exception/__init__.py +++ b/kdb-bot/src/bot_core/exception/__init__.py @@ -1,10 +1,10 @@ # -*- coding: utf-8 -*- """ -bot Keksdose bot +bot sh-edraft.de Discord bot ~~~~~~~~~~~~~~~~~~~ -Discord bot for the Keksdose discord Server +Discord bot for customers of sh-edraft.de :copyright: (c) 2022 - 2023 sh-edraft.de :license: MIT, see LICENSE for more details. @@ -15,7 +15,7 @@ __title__ = "bot_core.exception" __author__ = "Sven Heidemann" __license__ = "MIT" __copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de" -__version__ = "1.1.6" +__version__ = "1.1.7" 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="6") +version_info = VersionInfo(major="1", minor="1", micro="7") diff --git a/kdb-bot/src/bot_core/helper/__init__.py b/kdb-bot/src/bot_core/helper/__init__.py index 79023949..d873396e 100644 --- a/kdb-bot/src/bot_core/helper/__init__.py +++ b/kdb-bot/src/bot_core/helper/__init__.py @@ -1,10 +1,10 @@ # -*- coding: utf-8 -*- """ -bot Keksdose bot +bot sh-edraft.de Discord bot ~~~~~~~~~~~~~~~~~~~ -Discord bot for the Keksdose discord Server +Discord bot for customers of sh-edraft.de :copyright: (c) 2022 - 2023 sh-edraft.de :license: MIT, see LICENSE for more details. @@ -15,7 +15,7 @@ __title__ = "bot_core.helper" __author__ = "Sven Heidemann" __license__ = "MIT" __copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de" -__version__ = "1.1.6" +__version__ = "1.1.7" 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="6") +version_info = VersionInfo(major="1", minor="1", micro="7") diff --git a/kdb-bot/src/bot_core/logging/__init__.py b/kdb-bot/src/bot_core/logging/__init__.py index 23c4b996..0d73eb7b 100644 --- a/kdb-bot/src/bot_core/logging/__init__.py +++ b/kdb-bot/src/bot_core/logging/__init__.py @@ -1,10 +1,10 @@ # -*- coding: utf-8 -*- """ -bot Keksdose bot +bot sh-edraft.de Discord bot ~~~~~~~~~~~~~~~~~~~ -Discord bot for the Keksdose discord Server +Discord bot for customers of sh-edraft.de :copyright: (c) 2022 - 2023 sh-edraft.de :license: MIT, see LICENSE for more details. @@ -15,7 +15,7 @@ __title__ = "bot_core.logging" __author__ = "Sven Heidemann" __license__ = "MIT" __copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de" -__version__ = "1.1.6" +__version__ = "1.1.7" 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="6") +version_info = VersionInfo(major="1", minor="1", micro="7") diff --git a/kdb-bot/src/bot_core/pipes/__init__.py b/kdb-bot/src/bot_core/pipes/__init__.py index f4b9cbfe..969224ec 100644 --- a/kdb-bot/src/bot_core/pipes/__init__.py +++ b/kdb-bot/src/bot_core/pipes/__init__.py @@ -1,10 +1,10 @@ # -*- coding: utf-8 -*- """ -bot Keksdose bot +bot sh-edraft.de Discord bot ~~~~~~~~~~~~~~~~~~~ -Discord bot for the Keksdose discord Server +Discord bot for customers of sh-edraft.de :copyright: (c) 2022 - 2023 sh-edraft.de :license: MIT, see LICENSE for more details. @@ -15,7 +15,7 @@ __title__ = "bot_core.pipes" __author__ = "Sven Heidemann" __license__ = "MIT" __copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de" -__version__ = "1.1.6" +__version__ = "1.1.7" 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="6") +version_info = VersionInfo(major="1", minor="1", micro="7") diff --git a/kdb-bot/src/bot_core/service/__init__.py b/kdb-bot/src/bot_core/service/__init__.py index 8af6564f..b46a291f 100644 --- a/kdb-bot/src/bot_core/service/__init__.py +++ b/kdb-bot/src/bot_core/service/__init__.py @@ -1,10 +1,10 @@ # -*- coding: utf-8 -*- """ -bot Keksdose bot +bot sh-edraft.de Discord bot ~~~~~~~~~~~~~~~~~~~ -Discord bot for the Keksdose discord Server +Discord bot for customers of sh-edraft.de :copyright: (c) 2022 - 2023 sh-edraft.de :license: MIT, see LICENSE for more details. @@ -15,7 +15,7 @@ __title__ = "bot_core.service" __author__ = "Sven Heidemann" __license__ = "MIT" __copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de" -__version__ = "1.1.6" +__version__ = "1.1.7" 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="6") +version_info = VersionInfo(major="1", minor="1", micro="7") 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 8290cb88..9a2e613e 100644 --- a/kdb-bot/src/bot_core/service/data_integrity_service.py +++ b/kdb-bot/src/bot_core/service/data_integrity_service.py @@ -24,7 +24,6 @@ from bot_data.model.server_config import ServerConfig from bot_data.model.user import User from bot_data.model.user_joined_server import UserJoinedServer from bot_data.model.user_joined_voice_channel import UserJoinedVoiceChannel -from bot_data.service.seeder_service import SeederService from bot_data.service.user_repository_service import ServerRepositoryABC from modules.achievements.achievement_service import AchievementService @@ -34,7 +33,6 @@ class DataIntegrityService: self, config: ConfigurationABC, logger: DatabaseLogger, - seeder: SeederService, bot: DiscordBotServiceABC, db_context: DatabaseContextABC, server_repo: ServerRepositoryABC, @@ -51,7 +49,6 @@ class DataIntegrityService: self._config = config self._logger = logger - self._seeder = seeder self._bot = bot self._db_context = db_context self._servers = server_repo diff --git a/kdb-bot/src/bot_data/__init__.py b/kdb-bot/src/bot_data/__init__.py index cfda6242..86814b29 100644 --- a/kdb-bot/src/bot_data/__init__.py +++ b/kdb-bot/src/bot_data/__init__.py @@ -1,10 +1,10 @@ # -*- coding: utf-8 -*- """ -bot Keksdose bot +bot sh-edraft.de Discord bot ~~~~~~~~~~~~~~~~~~~ -Discord bot for the Keksdose discord Server +Discord bot for customers of sh-edraft.de :copyright: (c) 2022 - 2023 sh-edraft.de :license: MIT, see LICENSE for more details. @@ -15,7 +15,7 @@ __title__ = "bot_data" __author__ = "Sven Heidemann" __license__ = "MIT" __copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de" -__version__ = "1.1.6" +__version__ = "1.1.7" 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="6") +version_info = VersionInfo(major="1", minor="1", micro="7") diff --git a/kdb-bot/src/bot_data/abc/__init__.py b/kdb-bot/src/bot_data/abc/__init__.py index 230338fc..4bf368a7 100644 --- a/kdb-bot/src/bot_data/abc/__init__.py +++ b/kdb-bot/src/bot_data/abc/__init__.py @@ -1,10 +1,10 @@ # -*- coding: utf-8 -*- """ -bot Keksdose bot +bot sh-edraft.de Discord bot ~~~~~~~~~~~~~~~~~~~ -Discord bot for the Keksdose discord Server +Discord bot for customers of sh-edraft.de :copyright: (c) 2022 - 2023 sh-edraft.de :license: MIT, see LICENSE for more details. @@ -15,7 +15,7 @@ __title__ = "bot_data.abc" __author__ = "Sven Heidemann" __license__ = "MIT" __copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de" -__version__ = "1.1.6" +__version__ = "1.1.7" 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="6") +version_info = VersionInfo(major="1", minor="1", micro="7") diff --git a/kdb-bot/src/bot_data/abc/migration_abc.py b/kdb-bot/src/bot_data/abc/migration_abc.py index e44e0bc2..67ed5e96 100644 --- a/kdb-bot/src/bot_data/abc/migration_abc.py +++ b/kdb-bot/src/bot_data/abc/migration_abc.py @@ -1,13 +1,20 @@ +import os from abc import ABC, abstractmethod +from cpl_core.dependency_injection import ServiceProviderABC +from mysql.connector.cursor import MySQLCursorBuffered + +from bot_data.db_context import DBContext + class MigrationABC(ABC): name = None prio = 0 @abstractmethod - def __init__(self): - pass + @ServiceProviderABC.inject + def __init__(self, db: DBContext): + self._cursor: MySQLCursorBuffered = db.cursor @abstractmethod def upgrade(self): @@ -16,3 +23,10 @@ class MigrationABC(ABC): @abstractmethod def downgrade(self): pass + + def _exec(self, self_file: str, file: str): + path = f"{os.path.dirname(os.path.realpath(self_file))}/db_history_scripts" + sql = open(f"{path}/{file}").read() + + for statement in sql.split("\n\n"): + self._cursor.execute(statement + ";") diff --git a/kdb-bot/src/bot_data/abc/short_role_name_repository_abc.py b/kdb-bot/src/bot_data/abc/short_role_name_repository_abc.py new file mode 100644 index 00000000..f0034a6e --- /dev/null +++ b/kdb-bot/src/bot_data/abc/short_role_name_repository_abc.py @@ -0,0 +1,39 @@ +from abc import ABC, abstractmethod + +from cpl_query.extension import List + +from bot_data.model.short_role_name import ShortRoleName + + +class ShortRoleNameRepositoryABC(ABC): + @abstractmethod + def __init__(self): + pass + + @abstractmethod + def get_short_role_names(self) -> List[ShortRoleName]: + pass + + @abstractmethod + def get_short_role_name_by_id(self, id: int) -> ShortRoleName: + pass + + @abstractmethod + def find_short_role_names_by_role_id(self, role_id: int) -> List[ShortRoleName]: + pass + + @abstractmethod + def get_short_role_names_by_server_id(self, id: int) -> List[ShortRoleName]: + pass + + @abstractmethod + def add_short_role_name(self, short_role_name: ShortRoleName): + pass + + @abstractmethod + def update_short_role_name(self, short_role_name: ShortRoleName): + pass + + @abstractmethod + def delete_short_role_name(self, short_role_name: ShortRoleName): + pass diff --git a/kdb-bot/src/bot_data/bot-data.json b/kdb-bot/src/bot_data/bot-data.json index a808af01..749bb7ff 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": "6" + "Micro": "7" }, "Author": "Sven Heidemann", "AuthorEmail": "sven.heidemann@sh-edraft.de", diff --git a/kdb-bot/src/bot_data/data_module.py b/kdb-bot/src/bot_data/data_module.py index 9c35713e..427c9cc6 100644 --- a/kdb-bot/src/bot_data/data_module.py +++ b/kdb-bot/src/bot_data/data_module.py @@ -16,6 +16,7 @@ from bot_data.abc.known_user_repository_abc import KnownUserRepositoryABC from bot_data.abc.level_repository_abc import LevelRepositoryABC from bot_data.abc.server_config_repository_abc import ServerConfigRepositoryABC from bot_data.abc.server_repository_abc import ServerRepositoryABC +from bot_data.abc.short_role_name_repository_abc import ShortRoleNameRepositoryABC from bot_data.abc.technician_config_repository_abc import TechnicianConfigRepositoryABC from bot_data.abc.user_game_ident_repository_abc import UserGameIdentRepositoryABC from bot_data.abc.user_joined_game_server_repository_abc import UserJoinedGameServerRepositoryABC @@ -41,6 +42,7 @@ from bot_data.service.seeder_service import SeederService from bot_data.service.server_config_repository_service import ServerConfigRepositoryService from bot_data.service.server_config_seeder import ServerConfigSeeder from bot_data.service.server_repository_service import ServerRepositoryService +from bot_data.service.short_role_name_repository_service import ShortRoleNameRepositoryService from bot_data.service.technician_config_repository_service import TechnicianConfigRepositoryService from bot_data.service.technician_config_seeder import TechnicianConfigSeeder from bot_data.service.user_game_ident_repository_service import UserGameIdentRepositoryService @@ -89,6 +91,7 @@ class DataModule(ModuleABC): services.add_transient(AchievementRepositoryABC, AchievementRepositoryService) services.add_transient(TechnicianConfigRepositoryABC, TechnicianConfigRepositoryService) services.add_transient(ServerConfigRepositoryABC, ServerConfigRepositoryService) + services.add_transient(ShortRoleNameRepositoryABC, ShortRoleNameRepositoryService) services.add_transient(SeederService) services.add_transient(DataSeederABC, TechnicianConfigSeeder) diff --git a/kdb-bot/src/bot_data/migration/__init__.py b/kdb-bot/src/bot_data/migration/__init__.py index 0fdf7f51..b55705ac 100644 --- a/kdb-bot/src/bot_data/migration/__init__.py +++ b/kdb-bot/src/bot_data/migration/__init__.py @@ -1,10 +1,10 @@ # -*- coding: utf-8 -*- """ -bot Keksdose bot +bot sh-edraft.de Discord bot ~~~~~~~~~~~~~~~~~~~ -Discord bot for the Keksdose discord Server +Discord bot for customers of sh-edraft.de :copyright: (c) 2022 - 2023 sh-edraft.de :license: MIT, see LICENSE for more details. @@ -15,7 +15,7 @@ __title__ = "bot_data.migration" __author__ = "Sven Heidemann" __license__ = "MIT" __copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de" -__version__ = "1.1.6" +__version__ = "1.1.7" 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="6") +version_info = VersionInfo(major="1", minor="1", micro="7") diff --git a/kdb-bot/src/bot_data/migration/config_migration.py b/kdb-bot/src/bot_data/migration/config_migration.py index 556b396f..d65ac06d 100644 --- a/kdb-bot/src/bot_data/migration/config_migration.py +++ b/kdb-bot/src/bot_data/migration/config_migration.py @@ -1,5 +1,3 @@ -import os - from bot_core.logging.database_logger import DatabaseLogger from bot_data.abc.migration_abc import MigrationABC from bot_data.db_context import DBContext @@ -12,26 +10,18 @@ class ConfigMigration(MigrationABC): MigrationABC.__init__(self) self._logger = logger self._db = db - self._cursor = db.cursor - - def _exec(self, file: str): - path = f"{os.path.dirname(os.path.realpath(__file__))}/db_history_scripts" - sql = open(f"{path}/{file}").read() - - for statement in sql.split("\n\n"): - self._cursor.execute(statement + ";") def upgrade(self): self._logger.debug(__name__, "Running upgrade") self._server_upgrade() self._technician_upgrade() - self._exec("config/server.sql") - self._exec("config/server_afk_channels.sql") - self._exec("config/server_team_roles.sql") - self._exec("config/technician.sql") - self._exec("config/technician_ids.sql") - self._exec("config/technician_ping_urls.sql") + self._exec(__file__, "config/server.sql") + self._exec(__file__, "config/server_afk_channels.sql") + self._exec(__file__, "config/server_team_roles.sql") + self._exec(__file__, "config/technician.sql") + self._exec(__file__, "config/technician_ids.sql") + self._exec(__file__, "config/technician_ping_urls.sql") def _server_upgrade(self): self._cursor.execute( diff --git a/kdb-bot/src/bot_data/migration/db_history_migration.py b/kdb-bot/src/bot_data/migration/db_history_migration.py index e7322ad9..5452d9e5 100644 --- a/kdb-bot/src/bot_data/migration/db_history_migration.py +++ b/kdb-bot/src/bot_data/migration/db_history_migration.py @@ -1,5 +1,3 @@ -import os - from bot_core.logging.database_logger import DatabaseLogger from bot_data.abc.migration_abc import MigrationABC from bot_data.db_context import DBContext @@ -15,33 +13,26 @@ class DBHistoryMigration(MigrationABC): self._db = db self._cursor = db.cursor - def _exec(self, file: str): - path = f"{os.path.dirname(os.path.realpath(__file__))}/db_history_scripts" - sql = open(f"{path}/{file}").read() - - for statement in sql.split("\n\n"): - self._cursor.execute(statement + ";") - def upgrade(self): self._logger.debug(__name__, "Running upgrade") - self._exec("api_keys.sql") - self._exec("auth_users.sql") - self._exec("auth_user_users_relation.sql") - self._exec("auto_role_rules.sql") - self._exec("auto_roles.sql") - self._exec("clients.sql") - self._exec("game_servers.sql") - self._exec("known_users.sql") - self._exec("levels.sql") - self._exec("servers.sql") - self._exec("user_game_idents.sql") - self._exec("user_joined_game_servers.sql") - self._exec("user_joined_servers.sql") - self._exec("user_joined_voice_channel.sql") - self._exec("user_message_count_per_hour.sql") - self._exec("users.sql") - self._exec("user_warnings.sql") + self._exec(__file__, "api_keys.sql") + self._exec(__file__, "auth_users.sql") + self._exec(__file__, "auth_user_users_relation.sql") + self._exec(__file__, "auto_role_rules.sql") + self._exec(__file__, "auto_roles.sql") + self._exec(__file__, "clients.sql") + self._exec(__file__, "game_servers.sql") + self._exec(__file__, "known_users.sql") + self._exec(__file__, "levels.sql") + self._exec(__file__, "servers.sql") + self._exec(__file__, "user_game_idents.sql") + self._exec(__file__, "user_joined_game_servers.sql") + self._exec(__file__, "user_joined_servers.sql") + self._exec(__file__, "user_joined_voice_channel.sql") + self._exec(__file__, "user_message_count_per_hour.sql") + self._exec(__file__, "users.sql") + self._exec(__file__, "user_warnings.sql") self._logger.debug(__name__, "Finished history upgrade") diff --git a/kdb-bot/src/bot_data/migration/db_history_scripts/config/server.sql b/kdb-bot/src/bot_data/migration/db_history_scripts/config/server.sql index e9c327b8..0cbc399a 100644 --- a/kdb-bot/src/bot_data/migration/db_history_scripts/config/server.sql +++ b/kdb-bot/src/bot_data/migration/db_history_scripts/config/server.sql @@ -1,23 +1,25 @@ CREATE TABLE IF NOT EXISTS `CFG_ServerHistory` ( - `Id` BIGINT(20) NOT NULL, - `MessageDeleteTimer` BIGINT NOT NULL DEFAULT 6, - `NotificationChatId` BIGINT NOT NULL, - `MaxVoiceStateHours` BIGINT NOT NULL DEFAULT 6, - `XpPerMessage` BIGINT NOT NULL DEFAULT 1, - `XpPerReaction` BIGINT NOT NULL DEFAULT 1, - `MaxMessageXpPerHour` BIGINT NOT NULL DEFAULT 20, - `XpPerOntimeHour` BIGINT NOT NULL DEFAULT 10, - `XpPerEventParticipation` BIGINT NOT NULL DEFAULT 10, - `XpPerAchievement` BIGINT NOT NULL DEFAULT 10, - `AFKCommandChannelId` BIGINT NOT NULL, - `HelpVoiceChannelId` BIGINT NOT NULL, - `TeamChannelId` BIGINT NOT NULL, - `LoginMessageChannelId` BIGINT NOT NULL, - `ServerId` BIGINT NOT NULL, - `Deleted` BOOL DEFAULT FALSE, - `DateFrom` DATETIME(6) NOT NULL, - `DateTo` DATETIME(6) NOT NULL + `Id` BIGINT(20) NOT NULL, + `MessageDeleteTimer` BIGINT NOT NULL DEFAULT 6, + `NotificationChatId` BIGINT NOT NULL, + `MaxVoiceStateHours` BIGINT NOT NULL DEFAULT 6, + `XpPerMessage` BIGINT NOT NULL DEFAULT 1, + `XpPerReaction` BIGINT NOT NULL DEFAULT 1, + `MaxMessageXpPerHour` BIGINT NOT NULL DEFAULT 20, + `XpPerOntimeHour` BIGINT NOT NULL DEFAULT 10, + `XpPerEventParticipation` BIGINT NOT NULL DEFAULT 10, + `XpPerAchievement` BIGINT NOT NULL DEFAULT 10, + `AFKCommandChannelId` BIGINT NOT NULL, + `HelpVoiceChannelId` BIGINT NOT NULL, + `TeamChannelId` BIGINT NOT NULL, + `LoginMessageChannelId` BIGINT NOT NULL, + `DefaultRoleId` BIGINT NULL, + `FeatureFlags` JSON NULL DEFAULT ('{}'), + `ServerId` BIGINT NOT NULL, + `Deleted` BOOL DEFAULT FALSE, + `DateFrom` DATETIME(6) NOT NULL, + `DateTo` DATETIME(6) NOT NULL ); DROP TRIGGER IF EXISTS `TR_CFG_ServerUpdate`; @@ -27,44 +29,44 @@ CREATE TRIGGER `TR_CFG_ServerUpdate` ON `CFG_Server` FOR EACH ROW BEGIN - INSERT INTO `CFG_ServerHistory` ( - `Id`, - `MessageDeleteTimer`, - `NotificationChatId`, - `MaxVoiceStateHours`, - `XpPerMessage`, - `XpPerReaction`, - `MaxMessageXpPerHour`, - `XpPerOntimeHour`, - `XpPerEventParticipation`, - `XpPerAchievement`, - `AFKCommandChannelId`, - `HelpVoiceChannelId`, - `TeamChannelId`, - `LoginMessageChannelId`, - `ServerId`, - `DateFrom`, - `DateTo` - ) - VALUES ( - OLD.Id, - OLD.MessageDeleteTimer, - OLD.NotificationChatId, - OLD.MaxVoiceStateHours, - OLD.XpPerMessage, - OLD.XpPerReaction, - OLD.MaxMessageXpPerHour, - OLD.XpPerOntimeHour, - OLD.XpPerEventParticipation, - OLD.XpPerAchievement, - OLD.AFKCommandChannelId, - OLD.HelpVoiceChannelId, - OLD.TeamChannelId, - OLD.LoginMessageChannelId, - OLD.ServerId, - OLD.LastModifiedAt, - CURRENT_TIMESTAMP(6) - ); + INSERT INTO `CFG_ServerHistory` (`Id`, + `MessageDeleteTimer`, + `NotificationChatId`, + `MaxVoiceStateHours`, + `XpPerMessage`, + `XpPerReaction`, + `MaxMessageXpPerHour`, + `XpPerOntimeHour`, + `XpPerEventParticipation`, + `XpPerAchievement`, + `AFKCommandChannelId`, + `HelpVoiceChannelId`, + `TeamChannelId`, + `LoginMessageChannelId`, + `DefaultRoleId`, + `FeatureFlags`, + `ServerId`, + `DateFrom`, + `DateTo`) + VALUES (OLD.Id, + OLD.MessageDeleteTimer, + OLD.NotificationChatId, + OLD.MaxVoiceStateHours, + OLD.XpPerMessage, + OLD.XpPerReaction, + OLD.MaxMessageXpPerHour, + OLD.XpPerOntimeHour, + OLD.XpPerEventParticipation, + OLD.XpPerAchievement, + OLD.AFKCommandChannelId, + OLD.HelpVoiceChannelId, + OLD.TeamChannelId, + OLD.LoginMessageChannelId, + OLD.DefaultRoleId, + OLD.FeatureFlags, + OLD.ServerId, + OLD.LastModifiedAt, + CURRENT_TIMESTAMP(6)); END; DROP TRIGGER IF EXISTS `TR_CFG_ServerDelete`; @@ -74,44 +76,44 @@ CREATE TRIGGER `TR_CFG_ServerDelete` ON `CFG_Server` FOR EACH ROW BEGIN - INSERT INTO `CFG_ServerHistory` ( - `Id`, - `MessageDeleteTimer`, - `NotificationChatId`, - `MaxVoiceStateHours`, - `XpPerMessage`, - `XpPerReaction`, - `MaxMessageXpPerHour`, - `XpPerOntimeHour`, - `XpPerEventParticipation`, - `XpPerAchievement`, - `AFKCommandChannelId`, - `HelpVoiceChannelId`, - `TeamChannelId`, - `LoginMessageChannelId`, - `ServerId`, - `Deleted`, - `DateFrom`, - `DateTo` - ) - VALUES ( - OLD.Id, - OLD.MessageDeleteTimer, - OLD.NotificationChatId, - OLD.MaxVoiceStateHours, - OLD.XpPerMessage, - OLD.XpPerReaction, - OLD.MaxMessageXpPerHour, - OLD.XpPerOntimeHour, - OLD.XpPerEventParticipation, - OLD.XpPerAchievement, - OLD.AFKCommandChannelId, - OLD.HelpVoiceChannelId, - OLD.TeamChannelId, - OLD.LoginMessageChannelId, - OLD.ServerId, - TRUE, - OLD.LastModifiedAt, - CURRENT_TIMESTAMP(6) - ); + INSERT INTO `CFG_ServerHistory` (`Id`, + `MessageDeleteTimer`, + `NotificationChatId`, + `MaxVoiceStateHours`, + `XpPerMessage`, + `XpPerReaction`, + `MaxMessageXpPerHour`, + `XpPerOntimeHour`, + `XpPerEventParticipation`, + `XpPerAchievement`, + `AFKCommandChannelId`, + `HelpVoiceChannelId`, + `TeamChannelId`, + `LoginMessageChannelId`, + `DefaultRoleId`, + `ServerId`, + `FeatureFlags`, + `Deleted`, + `DateFrom`, + `DateTo`) + VALUES (OLD.Id, + OLD.MessageDeleteTimer, + OLD.NotificationChatId, + OLD.MaxVoiceStateHours, + OLD.XpPerMessage, + OLD.XpPerReaction, + OLD.MaxMessageXpPerHour, + OLD.XpPerOntimeHour, + OLD.XpPerEventParticipation, + OLD.XpPerAchievement, + OLD.AFKCommandChannelId, + OLD.HelpVoiceChannelId, + OLD.TeamChannelId, + OLD.LoginMessageChannelId, + OLD.DefaultRoleId, + OLD.FeatureFlags, + OLD.ServerId, + TRUE, + OLD.LastModifiedAt, + CURRENT_TIMESTAMP(6)); END; \ No newline at end of file diff --git a/kdb-bot/src/bot_data/migration/db_history_scripts/config/technician.sql b/kdb-bot/src/bot_data/migration/db_history_scripts/config/technician.sql index 50907c2f..2256cbc8 100644 --- a/kdb-bot/src/bot_data/migration/db_history_scripts/config/technician.sql +++ b/kdb-bot/src/bot_data/migration/db_history_scripts/config/technician.sql @@ -1,13 +1,14 @@ CREATE TABLE IF NOT EXISTS `CFG_TechnicianHistory` ( - `Id` BIGINT(20) NOT NULL, + `Id` BIGINT(20) NOT NULL, `HelpCommandReferenceUrl` VARCHAR(255) NOT NULL, - `WaitForRestart` BIGINT NOT NULL DEFAULT 8, - `WaitForShutdown` BIGINT NOT NULL DEFAULT 8, - `CacheMaxMessages` BIGINT NOT NULL DEFAULT 1000000, - `Deleted` BOOL DEFAULT FALSE, - `DateFrom` DATETIME(6) NOT NULL, - `DateTo` DATETIME(6) NOT NULL + `WaitForRestart` BIGINT NOT NULL DEFAULT 8, + `WaitForShutdown` BIGINT NOT NULL DEFAULT 8, + `CacheMaxMessages` BIGINT NOT NULL DEFAULT 1000000, + `FeatureFlags` JSON NULL DEFAULT ('{}'), + `Deleted` BOOL DEFAULT FALSE, + `DateFrom` DATETIME(6) NOT NULL, + `DateTo` DATETIME(6) NOT NULL ); DROP TRIGGER IF EXISTS `TR_CFG_TechnicianUpdate`; @@ -17,24 +18,22 @@ CREATE TRIGGER `TR_CFG_TechnicianUpdate` ON `CFG_Technician` FOR EACH ROW BEGIN - INSERT INTO `CFG_TechnicianHistory` ( - `Id`, - `HelpCommandReferenceUrl`, - `WaitForRestart`, - `WaitForShutdown`, - `CacheMaxMessages`, - `DateFrom`, - `DateTo` - ) - VALUES ( - OLD.Id, - OLD.HelpCommandReferenceUrl, - OLD.WaitForRestart, - OLD.WaitForShutdown, - OLD.CacheMaxMessages, - OLD.LastModifiedAt, - CURRENT_TIMESTAMP(6) - ); + INSERT INTO `CFG_TechnicianHistory` (`Id`, + `HelpCommandReferenceUrl`, + `WaitForRestart`, + `WaitForShutdown`, + `CacheMaxMessages`, + `FeatureFlags`, + `DateFrom`, + `DateTo`) + VALUES (OLD.Id, + OLD.HelpCommandReferenceUrl, + OLD.WaitForRestart, + OLD.WaitForShutdown, + OLD.CacheMaxMessages, + OLD.FeatureFlags, + OLD.LastModifiedAt, + CURRENT_TIMESTAMP(6)); END; DROP TRIGGER IF EXISTS `TR_CFG_TechnicianDelete`; @@ -44,24 +43,22 @@ CREATE TRIGGER `TR_CFG_TechnicianDelete` ON `CFG_Technician` FOR EACH ROW BEGIN - INSERT INTO `CFG_TechnicianHistory` ( - `Id`, - `HelpCommandReferenceUrl`, - `WaitForRestart`, - `WaitForShutdown`, - `CacheMaxMessages`, - `Deleted`, - `DateFrom`, - `DateTo` - ) - VALUES ( - OLD.Id, - OLD.HelpCommandReferenceUrl, - OLD.WaitForRestart, - OLD.WaitForShutdown, - OLD.CacheMaxMessages, - TRUE, - OLD.LastModifiedAt, - CURRENT_TIMESTAMP(6) - ); + INSERT INTO `CFG_TechnicianHistory` (`Id`, + `HelpCommandReferenceUrl`, + `WaitForRestart`, + `WaitForShutdown`, + `CacheMaxMessages`, + `FeatureFlags`, + `Deleted`, + `DateFrom`, + `DateTo`) + VALUES (OLD.Id, + OLD.HelpCommandReferenceUrl, + OLD.WaitForRestart, + OLD.WaitForShutdown, + OLD.CacheMaxMessages, + OLD.FeatureFlags, + TRUE, + OLD.LastModifiedAt, + CURRENT_TIMESTAMP(6)); END; \ No newline at end of file diff --git a/kdb-bot/src/bot_data/migration/db_history_scripts/short_rule_names.sql b/kdb-bot/src/bot_data/migration/db_history_scripts/short_rule_names.sql new file mode 100644 index 00000000..f4ff95c2 --- /dev/null +++ b/kdb-bot/src/bot_data/migration/db_history_scripts/short_rule_names.sql @@ -0,0 +1,38 @@ +CREATE TABLE IF NOT EXISTS `ShortRoleNamesHistory` +( + `Id` BIGINT(20) NOT NULL, + `ShortName` VARCHAR(64) DEFAULT NULL, + `DiscordRoleId` BIGINT(20) NOT NULL, + `Position` ENUM ('Before', 'After') NOT NULL, + `ServerId` BIGINT(20) DEFAULT NULL, + `Deleted` BOOL DEFAULT FALSE, + `DateFrom` DATETIME(6) NOT NULL, + `DateTo` DATETIME(6) NOT NULL +); + +DROP TRIGGER IF EXISTS `TR_ShortRoleNamesUpdate`; + +CREATE TRIGGER `TR_ShortRoleNamesUpdate` + AFTER UPDATE + ON `ShortRoleNames` + FOR EACH ROW +BEGIN + INSERT INTO `ShortRoleNamesHistory` (`Id`, `ShortName`, `DiscordRoleId`, `Position`, `ServerId`, `DateFrom`, + `DateTo`) + VALUES (OLD.Id, OLD.ShortName, OLD.DiscordRoleId, OLD.Position, OLD.ServerId, OLD.LastModifiedAt, + CURRENT_TIMESTAMP(6)); +END; + +DROP TRIGGER IF EXISTS `TR_ShortRoleNamesDelete`; + +CREATE TRIGGER `TR_ShortRoleNamesDelete` + AFTER DELETE + ON `ShortRoleNames` + FOR EACH ROW +BEGIN + INSERT INTO `ShortRoleNamesHistory` (`Id`, `ShortName`, `DiscordRoleId`, `Position`, `ServerId`, `Deleted`, + `DateFrom`, + `DateTo`) + VALUES (OLD.Id, OLD.ShortName, OLD.DiscordRoleId, OLD.Position, OLD.ServerId, TRUE, OLD.LastModifiedAt, + CURRENT_TIMESTAMP(6)); +END; \ No newline at end of file diff --git a/kdb-bot/src/bot_data/migration/fix_updates_migration.py b/kdb-bot/src/bot_data/migration/fix_updates_migration.py new file mode 100644 index 00000000..f4d5e020 --- /dev/null +++ b/kdb-bot/src/bot_data/migration/fix_updates_migration.py @@ -0,0 +1,51 @@ +from bot_core.logging.database_logger import DatabaseLogger +from bot_data.abc.migration_abc import MigrationABC +from bot_data.db_context import DBContext + + +class FixUpdatesMigration(MigrationABC): + name = "1.1.7_FixUpdatesMigration" + + 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_ServerHistory + ADD DefaultRoleId BIGINT NULL AFTER LoginMessageChannelId; + """ + ) + ) + + self._cursor.execute( + str( + """ALTER TABLE CFG_TechnicianHistory ADD FeatureFlags JSON NULL DEFAULT ('{}') AFTER CacheMaxMessages;""" + ) + ) + + self._cursor.execute( + str( + """ALTER TABLE CFG_ServerHistory ADD FeatureFlags JSON NULL DEFAULT ('{}') AFTER LoginMessageChannelId;""" + ) + ) + + self._exec(__file__, "config/server.sql") + self._exec(__file__, "config/technician.sql") + + def downgrade(self): + self._cursor.execute( + str( + f""" + ALTER TABLE CFG_ServerHistory DROP COLUMN DefaultRoleId; + """ + ) + ) + self._cursor.execute("ALTER TABLE CFG_TechnicianHistory DROP COLUMN FeatureFlags;") + self._cursor.execute("ALTER TABLE CFG_ServerHistory DROP COLUMN FeatureFlags;") diff --git a/kdb-bot/src/bot_data/migration/short_role_name_migration.py b/kdb-bot/src/bot_data/migration/short_role_name_migration.py new file mode 100644 index 00000000..7fe5ddfd --- /dev/null +++ b/kdb-bot/src/bot_data/migration/short_role_name_migration.py @@ -0,0 +1,40 @@ +from bot_core.logging.database_logger import DatabaseLogger +from bot_data.abc.migration_abc import MigrationABC +from bot_data.db_context import DBContext + + +class ShortRoleNameMigration(MigrationABC): + name = "1.1.7_ShortRoleNameMigration" + + def __init__(self, logger: DatabaseLogger, db: DBContext): + MigrationABC.__init__(self) + self._logger = logger + self._db = db + self._cursor = db.cursor + + def upgrade(self): + self._logger.debug(__name__, "Running upgrade") + + self._cursor.execute( + str( + f""" + CREATE TABLE IF NOT EXISTS `ShortRoleNames` ( + `Id` BIGINT NOT NULL AUTO_INCREMENT, + `ShortName` VARCHAR(255) NOT NULL, + `DiscordRoleId` BIGINT NOT NULL, + `Position` ENUM('before', 'after') NOT NULL, + `ServerId` BIGINT, + `CreatedAt` DATETIME(6) NULL DEFAULT CURRENT_TIMESTAMP(6), + `LastModifiedAt` DATETIME(6) NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6), + PRIMARY KEY(`Id`), + FOREIGN KEY (`ServerId`) REFERENCES `Servers`(`ServerId`) + ); + """ + ) + ) + + self._exec(__file__, "short_rule_names.sql") + + def downgrade(self): + self._cursor.execute("DROP TABLE `ShortRoleNames`;") + self._cursor.execute("DROP TABLE `ShortRoleNamesHistory`;") diff --git a/kdb-bot/src/bot_data/model/__init__.py b/kdb-bot/src/bot_data/model/__init__.py index b9b6a0e5..02049dd1 100644 --- a/kdb-bot/src/bot_data/model/__init__.py +++ b/kdb-bot/src/bot_data/model/__init__.py @@ -1,10 +1,10 @@ # -*- coding: utf-8 -*- """ -bot Keksdose bot +bot sh-edraft.de Discord bot ~~~~~~~~~~~~~~~~~~~ -Discord bot for the Keksdose discord Server +Discord bot for customers of sh-edraft.de :copyright: (c) 2022 - 2023 sh-edraft.de :license: MIT, see LICENSE for more details. @@ -15,7 +15,7 @@ __title__ = "bot_data.model" __author__ = "Sven Heidemann" __license__ = "MIT" __copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de" -__version__ = "1.1.6" +__version__ = "1.1.7" 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="6") +version_info = VersionInfo(major="1", minor="1", micro="7") diff --git a/kdb-bot/src/bot_data/model/server_config.py b/kdb-bot/src/bot_data/model/server_config.py index 87064e66..63738543 100644 --- a/kdb-bot/src/bot_data/model/server_config.py +++ b/kdb-bot/src/bot_data/model/server_config.py @@ -1,9 +1,11 @@ import json from datetime import datetime +from typing import Optional from cpl_core.configuration import ConfigurationModelABC from cpl_core.database import TableABC from cpl_query.extension import List +from discord import Guild from bot_core.configuration.feature_flags_enum import FeatureFlagsEnum from bot_data.model.server import Server @@ -26,7 +28,7 @@ class ServerConfig(TableABC, ConfigurationModelABC): help_voice_channel_id: int, team_channel_id: int, login_message_channel_id: int, - default_role_id: int, + default_role_id: Optional[int], feature_flags: dict[FeatureFlagsEnum], server: Server, afk_channel_ids: List[int], @@ -59,6 +61,29 @@ class ServerConfig(TableABC, ConfigurationModelABC): self._created_at = created_at if created_at is not None else self._created_at self._modified_at = modified_at if modified_at is not None else self._modified_at + @staticmethod + def new(guild: Guild, server: Server) -> "ServerConfig": + return ServerConfig( + 6, + guild.system_channel.id, + 6, + 1, + 1, + 20, + 10, + 10, + 10, + guild.system_channel.id, + guild.system_channel.id, + guild.system_channel.id, + guild.system_channel.id, + None, + {}, + server, + List(int), + List(int), + ) + @property def id(self) -> int: return self._id @@ -264,7 +289,7 @@ class ServerConfig(TableABC, ConfigurationModelABC): {self._help_voice_channel_id}, {self._team_channel_id}, {self._login_message_channel_id}, - {self._default_role_id}, + {"NULL" if self._default_role_id is None else self._default_role_id}, '{json.dumps(self._feature_flags)}', {self._server.id} ); @@ -289,7 +314,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}, + `DefaultRoleId` = {"NULL" if self._default_role_id is None else 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/short_role_name.py b/kdb-bot/src/bot_data/model/short_role_name.py new file mode 100644 index 00000000..4ddef4f1 --- /dev/null +++ b/kdb-bot/src/bot_data/model/short_role_name.py @@ -0,0 +1,140 @@ +from datetime import datetime + +from cpl_core.database import TableABC +from cpl_core.dependency_injection import ServiceProviderABC +from cpl_discord.service import DiscordBotServiceABC + +from bot_data.model.server import Server +from bot_data.model.short_role_name_position_enum import ShortRoleNamePositionEnum + + +class ShortRoleName(TableABC): + def __init__( + self, + short_name: str, + discord_role_id: int, + position: ShortRoleNamePositionEnum, + server: Server, + created_at: datetime = None, + modified_at: datetime = None, + id=0, + ): + self._id = id + self._short_name = short_name + self._discord_role_id = discord_role_id + self._position = position + self._server = server + + TableABC.__init__(self) + self._created_at = created_at if created_at is not None else self._created_at + self._modified_at = modified_at if modified_at is not None else self._modified_at + + @property + def id(self) -> int: + return self._id + + @property + def short_name(self) -> str: + return self._short_name + + @short_name.setter + def short_name(self, value: str): + self._short_name = value + + @property + def role_id(self) -> int: + return self._discord_role_id + + @role_id.setter + def role_id(self, value: int): + self._discord_role_id = value + + @property + @ServiceProviderABC.inject + def role_name(self, bot: DiscordBotServiceABC) -> str: + guild = bot.get_guild(self._server.discord_id) + return guild.get_role(self.role_id).name + + @property + def position(self) -> ShortRoleNamePositionEnum: + return self._position + + @position.setter + def position(self, value: ShortRoleNamePositionEnum): + self._position = value + + @property + def server(self) -> Server: + return self._server + + @staticmethod + def get_select_all_string() -> str: + return str( + f""" + SELECT * FROM `ShortRoleNames`; + """ + ) + + @staticmethod + def get_select_by_id_string(id: int) -> str: + return str( + f""" + SELECT * FROM `ShortRoleNames` + WHERE `Id` = {id}; + """ + ) + + @staticmethod + def get_select_by_role_id_string(id: int) -> str: + return str( + f""" + SELECT * FROM `ShortRoleNames` + WHERE `DiscordRoleId` = {id}; + """ + ) + + @staticmethod + def get_select_by_server_id_string(id: int) -> str: + return str( + f""" + SELECT * FROM `ShortRoleNames` + WHERE `ServerId` = {id}; + """ + ) + + @property + def insert_string(self) -> str: + return str( + f""" + INSERT INTO `ShortRoleNames` ( + `ShortName`, `DiscordRoleId`, `Position`, `ServerId` + ) VALUES ( + '{self._short_name}', + {self._discord_role_id}, + '{self._position}', + {self._server.id} + ); + """ + ) + + @property + def udpate_string(self) -> str: + return str( + f""" + UPDATE `ShortRoleNames` + SET `ShortName` = '{self._short_name}', + `DiscordRoleId` = {self._discord_role_id}, + `Position` = '{self._position}', + `ServerId` = {self._server.id} + WHERE `Id` = {self._id}; + """ + ) + + @property + def delete_string(self) -> str: + return str( + f""" + DELETE FROM `ShortRoleNames` + WHERE `Id` = {self._id}; + """ + ) diff --git a/kdb-bot/src/bot_data/model/short_role_name_history.py b/kdb-bot/src/bot_data/model/short_role_name_history.py new file mode 100644 index 00000000..90bbdc00 --- /dev/null +++ b/kdb-bot/src/bot_data/model/short_role_name_history.py @@ -0,0 +1,56 @@ +from cpl_core.dependency_injection import ServiceProviderABC +from cpl_discord.service import DiscordBotServiceABC + +from bot_data.abc.history_table_abc import HistoryTableABC + + +class ShortRoleNameHistory(HistoryTableABC): + def __init__( + self, + name: str, + discord_role_id: int, + server: int, + deleted: bool, + date_from: str, + date_to: str, + id=0, + ): + HistoryTableABC.__init__(self) + self._id = id + self._name = name + self._discord_role_id = discord_role_id + self._server = server + + self._deleted = deleted + self._date_from = date_from + self._date_to = date_to + + @property + def id(self) -> int: + return self._id + + @property + def name(self) -> str: + return self._name + + @name.setter + def name(self, value: str): + self._name = value + + @property + def role_id(self) -> int: + return self._discord_role_id + + @role_id.setter + def role_id(self, value: int): + self._discord_role_id = value + + @property + @ServiceProviderABC.inject + def role_name(self, bot: DiscordBotServiceABC) -> str: + guild = bot.get_guild(self._server.discord_id) + return guild.get_role(self.role_id).name + + @property + def server(self) -> int: + return self._server diff --git a/kdb-bot/src/bot_data/model/short_role_name_position_enum.py b/kdb-bot/src/bot_data/model/short_role_name_position_enum.py new file mode 100644 index 00000000..9390ab41 --- /dev/null +++ b/kdb-bot/src/bot_data/model/short_role_name_position_enum.py @@ -0,0 +1,6 @@ +from enum import Enum + + +class ShortRoleNamePositionEnum(Enum): + before = "before" + after = "after" diff --git a/kdb-bot/src/bot_data/service/__init__.py b/kdb-bot/src/bot_data/service/__init__.py index 1fac6c5f..8e99b15f 100644 --- a/kdb-bot/src/bot_data/service/__init__.py +++ b/kdb-bot/src/bot_data/service/__init__.py @@ -1,10 +1,10 @@ # -*- coding: utf-8 -*- """ -bot Keksdose bot +bot sh-edraft.de Discord bot ~~~~~~~~~~~~~~~~~~~ -Discord bot for the Keksdose discord Server +Discord bot for customers of sh-edraft.de :copyright: (c) 2022 - 2023 sh-edraft.de :license: MIT, see LICENSE for more details. @@ -15,7 +15,7 @@ __title__ = "bot_data.service" __author__ = "Sven Heidemann" __license__ = "MIT" __copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de" -__version__ = "1.1.6" +__version__ = "1.1.7" 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="6") +version_info = VersionInfo(major="1", minor="1", micro="7") diff --git a/kdb-bot/src/bot_data/service/server_config_seeder.py b/kdb-bot/src/bot_data/service/server_config_seeder.py index 926c09b4..08450a13 100644 --- a/kdb-bot/src/bot_data/service/server_config_seeder.py +++ b/kdb-bot/src/bot_data/service/server_config_seeder.py @@ -34,30 +34,12 @@ class ServerConfigSeeder(DataSeederABC): if self._server_config.does_server_config_exists(server.id): continue - config = ServerConfig( - 6, - guild.system_channel.id, - 6, - 1, - 1, - 20, - 10, - 10, - 10, - guild.system_channel.id, - guild.system_channel.id, - guild.system_channel.id, - guild.system_channel.id, - {}, - server, - [], - [], - ) + config = ServerConfig.new(guild, server) self._server_config.add_server_config(config) self._db.save_changes() - self._logger.debug(__name__, "Seeded technician config") + self._logger.debug(__name__, "Seeded server config") except Exception as e: - self._logger.error(__name__, f"Seeding technician config failed", e) + self._logger.error(__name__, f"Seeding server config failed", e) diff --git a/kdb-bot/src/bot_data/service/short_role_name_repository_service.py b/kdb-bot/src/bot_data/service/short_role_name_repository_service.py new file mode 100644 index 00000000..fa65077e --- /dev/null +++ b/kdb-bot/src/bot_data/service/short_role_name_repository_service.py @@ -0,0 +1,95 @@ +from typing import Optional + +from cpl_core.database.context import DatabaseContextABC +from cpl_query.extension import List + +from bot_core.logging.database_logger import DatabaseLogger +from bot_data.abc.server_repository_abc import ServerRepositoryABC +from bot_data.abc.short_role_name_repository_abc import ShortRoleNameRepositoryABC +from bot_data.model.short_role_name import ShortRoleName +from bot_data.model.short_role_name_position_enum import ShortRoleNamePositionEnum + + +class ShortRoleNameRepositoryService(ShortRoleNameRepositoryABC): + def __init__( + self, + logger: DatabaseLogger, + db_context: DatabaseContextABC, + servers: ServerRepositoryABC, + ): + self._logger = logger + self._context = db_context + + self._servers = servers + + ShortRoleNameRepositoryABC.__init__(self) + + @staticmethod + def _get_value_from_result(value: any) -> Optional[any]: + if isinstance(value, str) and "NULL" in value: + return None + + return value + + def _short_role_name_from_result(self, sql_result: tuple) -> ShortRoleName: + return ShortRoleName( + self._get_value_from_result(sql_result[1]), # name + int(self._get_value_from_result(sql_result[2])), # role_id + ShortRoleNamePositionEnum(self._get_value_from_result(sql_result[3])), # position + self._servers.get_server_by_id(sql_result[4]), # server + self._get_value_from_result(sql_result[5]), # created_at + self._get_value_from_result(sql_result[6]), # modified_at + id=self._get_value_from_result(sql_result[0]), # id + ) + + def get_short_role_names(self) -> List[ShortRoleName]: + short_role_names = List(ShortRoleName) + self._logger.trace(__name__, f"Send SQL command: {ShortRoleName.get_select_all_string()}") + results = self._context.select(ShortRoleName.get_select_all_string()) + for result in results: + self._logger.trace(__name__, f"Get short_role_name with id {result[0]}") + short_role_names.append(self._short_role_name_from_result(result)) + + return short_role_names + + def get_short_role_name_by_id(self, id: int) -> ShortRoleName: + self._logger.trace(__name__, f"Send SQL command: {ShortRoleName.get_select_by_id_string(id)}") + result = self._context.select(ShortRoleName.get_select_by_id_string(id))[0] + + return self._short_role_name_from_result(result) + + def find_short_role_names_by_role_id(self, role_id: int) -> List[ShortRoleName]: + short_role_names = List(ShortRoleName) + self._logger.trace(__name__, f"Send SQL command: {ShortRoleName.get_select_by_role_id_string(role_id)}") + results = self._context.select(ShortRoleName.get_select_by_role_id_string(role_id)) + for result in results: + self._logger.trace(__name__, f"Get short_role_name with id {result[0]}") + short_role_names.append(self._short_role_name_from_result(result)) + + return short_role_names + + def get_short_role_names_by_server_id(self, server_id: int) -> List[ShortRoleName]: + short_role_names = List(ShortRoleName) + self._logger.trace( + __name__, + f"Send SQL command: {ShortRoleName.get_select_by_server_id_string(server_id)}", + ) + results = self._context.select(ShortRoleName.get_select_by_server_id_string(server_id)) + + for result in results: + self._logger.trace(__name__, f"Get short_role_name with id {result[0]}") + short_role_names.append(self._short_role_name_from_result(result)) + + return short_role_names + + def add_short_role_name(self, short_role_name: ShortRoleName): + self._logger.trace(__name__, f"Send SQL command: {short_role_name.insert_string}") + self._context.cursor.execute(short_role_name.insert_string) + + def update_short_role_name(self, short_role_name: ShortRoleName): + self._logger.trace(__name__, f"Send SQL command: {short_role_name.udpate_string}") + self._context.cursor.execute(short_role_name.udpate_string) + + def delete_short_role_name(self, short_role_name: ShortRoleName): + self._logger.trace(__name__, f"Send SQL command: {short_role_name.delete_string}") + self._context.cursor.execute(short_role_name.delete_string) diff --git a/kdb-bot/src/bot_graphql/__init__.py b/kdb-bot/src/bot_graphql/__init__.py index 4272d8e2..7dfdeefb 100644 --- a/kdb-bot/src/bot_graphql/__init__.py +++ b/kdb-bot/src/bot_graphql/__init__.py @@ -1,10 +1,10 @@ # -*- coding: utf-8 -*- """ -bot Keksdose bot +bot sh-edraft.de Discord bot ~~~~~~~~~~~~~~~~~~~ -Discord bot for the Keksdose discord Server +Discord bot for customers of sh-edraft.de :copyright: (c) 2022 - 2023 sh-edraft.de :license: MIT, see LICENSE for more details. @@ -15,7 +15,7 @@ __title__ = "bot_graphql" __author__ = "Sven Heidemann" __license__ = "MIT" __copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de" -__version__ = "1.1.6" +__version__ = "1.1.7" 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="6") +version_info = VersionInfo(major="1", minor="1", micro="7") diff --git a/kdb-bot/src/bot_graphql/abc/__init__.py b/kdb-bot/src/bot_graphql/abc/__init__.py index d723ec75..8461ba8e 100644 --- a/kdb-bot/src/bot_graphql/abc/__init__.py +++ b/kdb-bot/src/bot_graphql/abc/__init__.py @@ -1,10 +1,10 @@ # -*- coding: utf-8 -*- """ -bot Keksdose bot +bot sh-edraft.de Discord bot ~~~~~~~~~~~~~~~~~~~ -Discord bot for the Keksdose discord Server +Discord bot for customers of sh-edraft.de :copyright: (c) 2022 - 2023 sh-edraft.de :license: MIT, see LICENSE for more details. @@ -15,7 +15,7 @@ __title__ = "bot_graphql.abc" __author__ = "Sven Heidemann" __license__ = "MIT" __copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de" -__version__ = "1.1.6" +__version__ = "1.1.7" 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="6") +version_info = VersionInfo(major="1", minor="1", micro="7") diff --git a/kdb-bot/src/bot_graphql/abc/query_abc.py b/kdb-bot/src/bot_graphql/abc/query_abc.py index 67692585..7a397f42 100644 --- a/kdb-bot/src/bot_graphql/abc/query_abc.py +++ b/kdb-bot/src/bot_graphql/abc/query_abc.py @@ -20,6 +20,7 @@ from bot_data.model.known_user import KnownUser from bot_data.model.level import Level from bot_data.model.server import Server from bot_data.model.server_config import ServerConfig +from bot_data.model.short_role_name import ShortRoleName from bot_data.model.user import User from bot_data.model.user_joined_game_server import UserJoinedGameServer from bot_data.model.user_joined_server import UserJoinedServer @@ -184,6 +185,16 @@ class QueryABC(ObjectType): access = True break + elif type(element) == ShortRoleName: + element: ShortRoleName = element + for u in user.users: + u: User = u + guild = bot.get_guild(u.server.discord_id) + member = guild.get_member(u.discord_id) + if permissions.is_member_moderator(member) and u.server.id == element.server.id: + access = True + break + elif type(element) == dict and "key" in element and element["key"] in [e.value for e in FeatureFlagsEnum]: for u in user.users: u: User = u diff --git a/kdb-bot/src/bot_graphql/bot-graphql.json b/kdb-bot/src/bot_graphql/bot-graphql.json index d42e532e..823c74db 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": "6" + "Micro": "7" }, "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 00ce8266..2578d910 100644 --- a/kdb-bot/src/bot_graphql/filter/__init__.py +++ b/kdb-bot/src/bot_graphql/filter/__init__.py @@ -1,10 +1,10 @@ # -*- coding: utf-8 -*- """ -bot Keksdose bot +bot sh-edraft.de Discord bot ~~~~~~~~~~~~~~~~~~~ -Discord bot for the Keksdose discord Server +Discord bot for customers of sh-edraft.de :copyright: (c) 2022 - 2023 sh-edraft.de :license: MIT, see LICENSE for more details. @@ -15,7 +15,7 @@ __title__ = "bot_graphql.filter" __author__ = "Sven Heidemann" __license__ = "MIT" __copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de" -__version__ = "1.1.6" +__version__ = "1.1.7" 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="6") +version_info = VersionInfo(major="1", minor="1", micro="7") diff --git a/kdb-bot/src/bot_graphql/filter/short_role_name_filter.py b/kdb-bot/src/bot_graphql/filter/short_role_name_filter.py new file mode 100644 index 00000000..426e3630 --- /dev/null +++ b/kdb-bot/src/bot_graphql/filter/short_role_name_filter.py @@ -0,0 +1,70 @@ +from cpl_discord.service import DiscordBotServiceABC +from cpl_query.extension import List + +from bot_data.model.short_role_name import ShortRoleName +from bot_data.model.short_role_name_position_enum import ShortRoleNamePositionEnum +from bot_data.model.user import User +from bot_graphql.abc.filter_abc import FilterABC + + +class ShortRoleNameFilter(FilterABC): + def __init__(self, bot: DiscordBotServiceABC): + FilterABC.__init__(self) + self._bot = bot + + self._id = None + self._short_name = None + self._role_id = None + self._role_name = None + self._position = None + self._server = None + + def from_dict(self, values: dict): + if "id" in values: + self._id = int(values["id"]) + + if "shortName" in values: + self._short_name = values["shortName"] + + if "roleId" in values: + self._role_id = int(values["roleId"]) + + if "roleName" in values: + self._role_name = values["roleName"] + + if "position" in values: + self._position = ShortRoleNamePositionEnum(values["position"]) + + if "server" in values: + from bot_graphql.filter.server_filter import ServerFilter + + self._server: ServerFilter = self._services.get_service(ServerFilter) + self._server.from_dict(values["server"]) + + def filter(self, query: List[User]) -> List[User]: + if self._id is not None: + query = query.where(lambda x: x.id == self._id) + + if self._short_name is not None: + query = query.where(lambda x: x.short_name == self._short_name or self._short_name in x.short_name) + + if self._role_id is not None: + query = query.where(lambda x: x.role_id == self._role_id) + + if self._role_name is not None and self._role_id is not None: + + def get_role_name(x: ShortRoleName): + guild = self._bot.get_guild(x.server.discord_id) + name = guild.get_role(x.role_id).name + return name == self._role_name or self._role_name in name + + query = query.where(get_role_name) + + if self._position is not None: + query = query.where(lambda x: x.position.value == self._position.value) + + if self._server is not None: + servers = self._server.filter(query.select(lambda x: x.server)).select(lambda x: x.id) + query = query.where(lambda x: x.server.id in servers) + + return query diff --git a/kdb-bot/src/bot_graphql/graphql/mutation.gql b/kdb-bot/src/bot_graphql/graphql/mutation.gql index aa1d8cd6..9578fde0 100644 --- a/kdb-bot/src/bot_graphql/graphql/mutation.gql +++ b/kdb-bot/src/bot_graphql/graphql/mutation.gql @@ -5,6 +5,7 @@ type Mutation { user: UserMutation userJoinedGameServer: UserJoinedGameServerMutation achievement: AchievementMutation + shortRoleName: ShortRoleNameMutation technicianConfig: TechnicianConfigMutation serverConfig: ServerConfigMutation } \ No newline at end of file diff --git a/kdb-bot/src/bot_graphql/graphql/query.gql b/kdb-bot/src/bot_graphql/graphql/query.gql index af2d298e..8946e9a9 100644 --- a/kdb-bot/src/bot_graphql/graphql/query.gql +++ b/kdb-bot/src/bot_graphql/graphql/query.gql @@ -37,6 +37,10 @@ type Query { achievementAttributes: [AchievementAttribute] achievementOperators: [String] + shortRoleNameCount: Int + shortRoleNames(filter: ShortRoleNameFilter, page: Page, sort: Sort): [ShortRoleName] + shortRoleNamePositions: [String] + technicianConfig: TechnicianConfig possibleFeatureFlags: [String] discord: Discord diff --git a/kdb-bot/src/bot_graphql/graphql/server.gql b/kdb-bot/src/bot_graphql/graphql/server.gql index be754bdb..2dda4cef 100644 --- a/kdb-bot/src/bot_graphql/graphql/server.gql +++ b/kdb-bot/src/bot_graphql/graphql/server.gql @@ -31,7 +31,11 @@ type Server implements TableWithHistoryQuery { achievementCount: Int achievements(filter: AchievementFilter, page: Page, sort: Sort): [Achievement] + shortRoleNameCount: Int + shortRoleNames(filter: ShortRoleNameFilter, page: Page, sort: Sort): [ShortRoleName] + config: ServerConfig + hasFeatureFlag(flag: String): FeatureFlag createdAt: String modifiedAt: String diff --git a/kdb-bot/src/bot_graphql/graphql/shortRoleName.gql b/kdb-bot/src/bot_graphql/graphql/shortRoleName.gql new file mode 100644 index 00000000..69df2920 --- /dev/null +++ b/kdb-bot/src/bot_graphql/graphql/shortRoleName.gql @@ -0,0 +1,50 @@ +type ShortRoleName implements TableWithHistoryQuery { + id: ID + shortName: String + roleId: String + roleName: String + position: String + + server: Server + + createdAt: String + modifiedAt: String + + history: [ShortRoleNameHistory] +} + +type ShortRoleNameHistory implements HistoryTableQuery { + id: ID + shortName: String + roleId: String + position: String + + server: ID + + deleted: Boolean + dateFrom: String + dateTo: String +} + +input ShortRoleNameFilter { + id: ID + shortName: String + roleId: String + roleName: String + position: String +} + +type ShortRoleNameMutation { + createShortRoleName(input: ShortRoleNameInput!): ShortRoleName + updateShortRoleName(input: ShortRoleNameInput!): ShortRoleName + deleteShortRoleName(id: ID): ShortRoleName +} + +input ShortRoleNameInput { + id: ID + shortName: String + roleId: String + roleName: String + position: String + serverId: ID +} \ No newline at end of file diff --git a/kdb-bot/src/bot_graphql/graphql_module.py b/kdb-bot/src/bot_graphql/graphql_module.py index 1236a7b2..96c72797 100644 --- a/kdb-bot/src/bot_graphql/graphql_module.py +++ b/kdb-bot/src/bot_graphql/graphql_module.py @@ -5,7 +5,6 @@ from cpl_discord.service.discord_collection_abc import DiscordCollectionABC from bot_core.abc.module_abc import ModuleABC from bot_core.configuration.feature_flags_enum import FeatureFlagsEnum -from bot_data.service.seeder_service import SeederService from bot_graphql.abc.filter_abc import FilterABC from bot_graphql.abc.query_abc import QueryABC from bot_graphql.filter.achievement_filter import AchievementFilter @@ -14,6 +13,7 @@ from bot_graphql.filter.auto_role_rule_filter import AutoRoleRuleFilter from bot_graphql.filter.client_filter import ClientFilter from bot_graphql.filter.level_filter import LevelFilter from bot_graphql.filter.server_filter import ServerFilter +from bot_graphql.filter.short_role_name_filter import ShortRoleNameFilter from bot_graphql.filter.user_filter import UserFilter from bot_graphql.filter.user_joined_game_server_filter import UserJoinedGameServerFilter from bot_graphql.filter.user_joined_server_filter import UserJoinedServerFilter @@ -25,6 +25,7 @@ from bot_graphql.mutations.auto_role_mutation import AutoRoleMutation from bot_graphql.mutations.auto_role_rule_mutation import AutoRoleRuleMutation from bot_graphql.mutations.level_mutation import LevelMutation from bot_graphql.mutations.server_config_mutation import ServerConfigMutation +from bot_graphql.mutations.short_role_name_mutation import ShortRoleNameMutation from bot_graphql.mutations.technician_config_mutation import TechnicianConfigMutation from bot_graphql.mutations.user_joined_game_server_mutation import UserJoinedGameServerMutation from bot_graphql.mutations.user_mutation import UserMutation @@ -51,6 +52,8 @@ from bot_graphql.queries.level_query import LevelQuery from bot_graphql.queries.server_config_query import ServerConfigQuery from bot_graphql.queries.server_history_query import ServerHistoryQuery from bot_graphql.queries.server_query import ServerQuery +from bot_graphql.queries.short_role_name_history_query import ShortRoleNameHistoryQuery +from bot_graphql.queries.short_role_name_query import ShortRoleNameQuery from bot_graphql.queries.technician_config_history_query import TechnicianConfigHistoryQuery from bot_graphql.queries.technician_config_query import TechnicianConfigQuery from bot_graphql.queries.technician_id_config_history_query import TechnicianIdConfigHistoryQuery @@ -110,6 +113,8 @@ class GraphQLModule(ModuleABC): services.add_transient(QueryABC, UserJoinedVoiceChannelQuery) services.add_transient(QueryABC, UserJoinedGameServerHistoryQuery) services.add_transient(QueryABC, UserJoinedGameServerQuery) + services.add_transient(QueryABC, ShortRoleNameHistoryQuery) + services.add_transient(QueryABC, ShortRoleNameQuery) services.add_transient(QueryABC, DiscordQuery) services.add_transient(QueryABC, GuildQuery) @@ -129,6 +134,7 @@ class GraphQLModule(ModuleABC): services.add_transient(FilterABC, UserJoinedServerFilter) services.add_transient(FilterABC, UserJoinedVoiceChannelFilter) services.add_transient(FilterABC, UserJoinedGameServerFilter) + services.add_transient(FilterABC, ShortRoleNameFilter) # mutations services.add_transient(QueryABC, AutoRoleMutation) @@ -136,8 +142,7 @@ class GraphQLModule(ModuleABC): services.add_transient(QueryABC, LevelMutation) services.add_transient(QueryABC, UserMutation) services.add_transient(QueryABC, AchievementMutation) + services.add_transient(QueryABC, ShortRoleNameMutation) services.add_transient(QueryABC, UserJoinedGameServerMutation) services.add_transient(QueryABC, TechnicianConfigMutation) services.add_transient(QueryABC, ServerConfigMutation) - - services.add_transient(SeederService) diff --git a/kdb-bot/src/bot_graphql/model/__init__.py b/kdb-bot/src/bot_graphql/model/__init__.py index 9bacb226..20888266 100644 --- a/kdb-bot/src/bot_graphql/model/__init__.py +++ b/kdb-bot/src/bot_graphql/model/__init__.py @@ -1,10 +1,10 @@ # -*- coding: utf-8 -*- """ -bot Keksdose bot +bot sh-edraft.de Discord bot ~~~~~~~~~~~~~~~~~~~ -Discord bot for the Keksdose discord Server +Discord bot for customers of sh-edraft.de :copyright: (c) 2022 - 2023 sh-edraft.de :license: MIT, see LICENSE for more details. @@ -15,7 +15,7 @@ __title__ = "bot_graphql.model" __author__ = "Sven Heidemann" __license__ = "MIT" __copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de" -__version__ = "1.1.6" +__version__ = "1.1.7" 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="6") +version_info = VersionInfo(major="1", minor="1", micro="7") diff --git a/kdb-bot/src/bot_graphql/mutation.py b/kdb-bot/src/bot_graphql/mutation.py index 4631e321..3dc7d599 100644 --- a/kdb-bot/src/bot_graphql/mutation.py +++ b/kdb-bot/src/bot_graphql/mutation.py @@ -5,6 +5,7 @@ from bot_graphql.mutations.auto_role_mutation import AutoRoleMutation from bot_graphql.mutations.auto_role_rule_mutation import AutoRoleRuleMutation from bot_graphql.mutations.level_mutation import LevelMutation from bot_graphql.mutations.server_config_mutation import ServerConfigMutation +from bot_graphql.mutations.short_role_name_mutation import ShortRoleNameMutation from bot_graphql.mutations.technician_config_mutation import TechnicianConfigMutation from bot_graphql.mutations.user_joined_game_server_mutation import UserJoinedGameServerMutation from bot_graphql.mutations.user_mutation import UserMutation @@ -21,6 +22,7 @@ class Mutation(MutationType): user_joined_game_server: UserJoinedGameServerMutation, technician_config: TechnicianConfigMutation, server_config: ServerConfigMutation, + short_role_name_mutation: ShortRoleNameMutation, ): MutationType.__init__(self) @@ -30,5 +32,6 @@ class Mutation(MutationType): self.set_field("user", lambda *_: user_mutation) self.set_field("achievement", lambda *_: achievement_mutation) self.set_field("userJoinedGameServer", lambda *_: user_joined_game_server) + self.set_field("shortRoleName", lambda *_: short_role_name_mutation) self.set_field("technicianConfig", lambda *_: technician_config) self.set_field("serverConfig", lambda *_: server_config) diff --git a/kdb-bot/src/bot_graphql/mutations/__init__.py b/kdb-bot/src/bot_graphql/mutations/__init__.py index 09ed2432..a50a0528 100644 --- a/kdb-bot/src/bot_graphql/mutations/__init__.py +++ b/kdb-bot/src/bot_graphql/mutations/__init__.py @@ -1,10 +1,10 @@ # -*- coding: utf-8 -*- """ -bot Keksdose bot +bot sh-edraft.de Discord bot ~~~~~~~~~~~~~~~~~~~ -Discord bot for the Keksdose discord Server +Discord bot for customers of sh-edraft.de :copyright: (c) 2022 - 2023 sh-edraft.de :license: MIT, see LICENSE for more details. @@ -15,7 +15,7 @@ __title__ = "bot_graphql.mutations" __author__ = "Sven Heidemann" __license__ = "MIT" __copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de" -__version__ = "1.1.6" +__version__ = "1.1.7" 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="6") +version_info = VersionInfo(major="1", minor="1", micro="7") diff --git a/kdb-bot/src/bot_graphql/mutations/short_role_name_mutation.py b/kdb-bot/src/bot_graphql/mutations/short_role_name_mutation.py new file mode 100644 index 00000000..3044af99 --- /dev/null +++ b/kdb-bot/src/bot_graphql/mutations/short_role_name_mutation.py @@ -0,0 +1,85 @@ +from cpl_core.database.context import DatabaseContextABC +from cpl_discord.service import DiscordBotServiceABC + +from bot_data.abc.server_repository_abc import ServerRepositoryABC +from bot_data.abc.short_role_name_repository_abc import ShortRoleNameRepositoryABC +from bot_data.model.short_role_name import ShortRoleName +from bot_data.model.user_role_enum import UserRoleEnum +from bot_graphql.abc.query_abc import QueryABC +from modules.permission.service.permission_service import PermissionService + + +class ShortRoleNameMutation(QueryABC): + def __init__( + self, + servers: ServerRepositoryABC, + short_role_names: ShortRoleNameRepositoryABC, + bot: DiscordBotServiceABC, + db: DatabaseContextABC, + permissions: PermissionService, + ): + QueryABC.__init__(self, "ShortRoleNameMutation") + + self._servers = servers + self._short_role_names = short_role_names + self._bot = bot + self._db = db + self._permissions = permissions + + self.set_field("createShortRoleName", self.resolve_create_short_role_name) + self.set_field("updateShortRoleName", self.resolve_update_short_role_name) + self.set_field("deleteShortRoleName", self.resolve_delete_short_role_name) + + def resolve_create_short_role_name(self, *_, input: dict): + server = self._servers.get_server_by_id(input["serverId"]) + self._can_user_mutate_data(server, UserRoleEnum.admin) + + short_role_name = ShortRoleName( + input["shortName"], + int(input["roleId"]), + input["position"], + server, + ) + + result = self._short_role_names.find_short_role_names_by_role_id(short_role_name.role_id) + if result.count() > 0: + raise ValueError("Short name for role already exists") + + self._short_role_names.add_short_role_name(short_role_name) + self._db.save_changes() + + def get_new_short_role_name(srn: ShortRoleName): + return ( + srn.short_name == short_role_name.short_name + and srn.role_id == short_role_name.role_id + and srn.position.value == short_role_name.position + ) + + return ( + self._short_role_names.get_short_role_names_by_server_id(short_role_name.server.id) + .where(get_new_short_role_name) + .last() + ) + + def resolve_update_short_role_name(self, *_, input: dict): + short_role_name = self._short_role_names.get_short_role_name_by_id(input["id"]) + self._can_user_mutate_data(short_role_name.server, UserRoleEnum.moderator) + + short_role_name.short_name = input["shortName"] if "shortName" in input else short_role_name.short_name + short_role_name.role_id = input["roleId"] if "roleId" in input else short_role_name.role_id + short_role_name.position = input["position"] if "position" in input else short_role_name.position + + self._short_role_names.update_short_role_name(short_role_name) + self._db.save_changes() + + short_role_name = self._short_role_names.get_short_role_name_by_id(input["id"]) + return short_role_name + + def resolve_delete_short_role_name(self, *_, id: int): + short_role_name = self._short_role_names.get_short_role_name_by_id(id) + self._can_user_mutate_data(short_role_name.server, UserRoleEnum.admin) + + self._short_role_names.delete_short_role_name(short_role_name) + self._db.save_changes() + + return short_role_name diff --git a/kdb-bot/src/bot_graphql/queries/__init__.py b/kdb-bot/src/bot_graphql/queries/__init__.py index af3a9fdf..491451b8 100644 --- a/kdb-bot/src/bot_graphql/queries/__init__.py +++ b/kdb-bot/src/bot_graphql/queries/__init__.py @@ -1,10 +1,10 @@ # -*- coding: utf-8 -*- """ -bot Keksdose bot +bot sh-edraft.de Discord bot ~~~~~~~~~~~~~~~~~~~ -Discord bot for the Keksdose discord Server +Discord bot for customers of sh-edraft.de :copyright: (c) 2022 - 2023 sh-edraft.de :license: MIT, see LICENSE for more details. @@ -15,7 +15,7 @@ __title__ = "bot_graphql.queries" __author__ = "Sven Heidemann" __license__ = "MIT" __copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de" -__version__ = "1.1.6" +__version__ = "1.1.7" 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="6") +version_info = VersionInfo(major="1", minor="1", micro="7") diff --git a/kdb-bot/src/bot_graphql/queries/discord/__init__.py b/kdb-bot/src/bot_graphql/queries/discord/__init__.py index a4425748..cd089596 100644 --- a/kdb-bot/src/bot_graphql/queries/discord/__init__.py +++ b/kdb-bot/src/bot_graphql/queries/discord/__init__.py @@ -1,10 +1,10 @@ # -*- coding: utf-8 -*- """ -bot Keksdose bot +bot sh-edraft.de Discord bot ~~~~~~~~~~~~~~~~~~~ -Discord bot for the Keksdose discord Server +Discord bot for customers of sh-edraft.de :copyright: (c) 2022 - 2023 sh-edraft.de :license: MIT, see LICENSE for more details. @@ -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.6" +__version__ = "1.1.7" 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="6") +version_info = VersionInfo(major="1", minor="1", micro="7") diff --git a/kdb-bot/src/bot_graphql/queries/discord/guild_query.py b/kdb-bot/src/bot_graphql/queries/discord/guild_query.py index 95b87b08..98f581f3 100644 --- a/kdb-bot/src/bot_graphql/queries/discord/guild_query.py +++ b/kdb-bot/src/bot_graphql/queries/discord/guild_query.py @@ -1,3 +1,4 @@ +import discord from cpl_discord.service import DiscordBotServiceABC from cpl_query.extension import List from discord import Guild @@ -17,22 +18,24 @@ class GuildQuery(QueryABC): self.set_field("id", lambda g, *_: g.id) self.set_field("name", lambda g, *_: g.name) self.set_field("channels", self._resolve_channels) - self.set_field("roles", lambda g, *_: g.roles) - self.set_field("emojis", lambda g, *_: g.emojis) + self.set_field("roles", lambda g, *_: g.roles.order_by(lambda x: x.position)) + self.set_field( + "emojis", lambda g, *_: List(discord.Emoji, g.emojis).order_by_descending(lambda x: x.created_at) + ) def _resolve_channels(self, g: Guild, *_, filter=None): - users = List(any).extend(g.channels) + channels = List(any).extend(g.channels) if filter is None: - return users + return channels if "id" in filter: - users = users.where(lambda c: c.id == int(filter["id"])) + channels = channels.where(lambda c: c.id == int(filter["id"])) if "name" in filter: - users = users.where(lambda c: c.id == filter["name"]) + channels = channels.where(lambda c: c.id == filter["name"]) if "type" in filter: - users = users.where(lambda c: type(c).__name__ == filter["type"]) + channels = channels.where(lambda c: type(c).__name__ == filter["type"]) - return users + return channels.order_by(lambda x: x.position) diff --git a/kdb-bot/src/bot_graphql/queries/server_query.py b/kdb-bot/src/bot_graphql/queries/server_query.py index 08c686b5..6ba77149 100644 --- a/kdb-bot/src/bot_graphql/queries/server_query.py +++ b/kdb-bot/src/bot_graphql/queries/server_query.py @@ -1,28 +1,35 @@ +from cpl_core.configuration import ConfigurationABC from cpl_core.database.context import DatabaseContextABC from cpl_discord.service import DiscordBotServiceABC +from bot_core.configuration.feature_flags_enum import FeatureFlagsEnum +from bot_core.configuration.feature_flags_settings import FeatureFlagsSettings from bot_data.abc.achievement_repository_abc import AchievementRepositoryABC from bot_data.abc.auto_role_repository_abc import AutoRoleRepositoryABC from bot_data.abc.client_repository_abc import ClientRepositoryABC from bot_data.abc.game_server_repository_abc import GameServerRepositoryABC from bot_data.abc.level_repository_abc import LevelRepositoryABC from bot_data.abc.server_config_repository_abc import ServerConfigRepositoryABC +from bot_data.abc.short_role_name_repository_abc import ShortRoleNameRepositoryABC from bot_data.abc.user_joined_server_repository_abc import UserJoinedServerRepositoryABC from bot_data.abc.user_joined_voice_channel_repository_abc import UserJoinedVoiceChannelRepositoryABC from bot_data.abc.user_repository_abc import UserRepositoryABC from bot_data.model.server import Server +from bot_data.model.server_config import ServerConfig from bot_data.model.server_history import ServerHistory from bot_graphql.abc.data_query_with_history_abc import DataQueryWithHistoryABC from bot_graphql.filter.achievement_filter import AchievementFilter from bot_graphql.filter.auto_role_filter import AutoRoleFilter from bot_graphql.filter.client_filter import ClientFilter from bot_graphql.filter.level_filter import LevelFilter +from bot_graphql.filter.short_role_name_filter import ShortRoleNameFilter from bot_graphql.filter.user_filter import UserFilter class ServerQuery(DataQueryWithHistoryABC): def __init__( self, + config: ConfigurationABC, bot: DiscordBotServiceABC, db: DatabaseContextABC, auto_roles: AutoRoleRepositoryABC, @@ -33,10 +40,12 @@ class ServerQuery(DataQueryWithHistoryABC): ujs: UserJoinedServerRepositoryABC, ujvs: UserJoinedVoiceChannelRepositoryABC, achievements: AchievementRepositoryABC, + short_role_names: ShortRoleNameRepositoryABC, server_configs: ServerConfigRepositoryABC, ): DataQueryWithHistoryABC.__init__(self, "Server", "ServersHistory", ServerHistory, db) + self._config = config self._bot = bot self._auto_roles = auto_roles self._clients = clients @@ -64,7 +73,15 @@ class ServerQuery(DataQueryWithHistoryABC): self.add_collection( "achievement", lambda server, *_: achievements.get_achievements_by_server_id(server.id), AchievementFilter ) + self.add_collection( + "shortRoleName", + lambda server, *_: short_role_names.get_short_role_names_by_server_id(server.id), + ShortRoleNameFilter, + ) self.set_field("config", lambda server, *_: server_configs.get_server_config_by_server(server.id)) + self.set_field( + "hasFeatureFlag", lambda server, *_, **kwargs: self._resolve_has_feature_flag(server, *_, **kwargs) + ) @staticmethod def resolve_id(server: Server, *_): @@ -81,3 +98,12 @@ class ServerQuery(DataQueryWithHistoryABC): @staticmethod def resolve_icon_url(server: Server, *_): return server.icon_url + + def _resolve_has_feature_flag(self, server: Server, *_, **kwargs): + settings: ServerConfig = self._config.get_configuration(f"ServerConfig_{server.discord_id}") + if "flag" not in kwargs: + return False + return { + "key": kwargs["flag"], + "value": FeatureFlagsSettings.get_flag_from_dict(settings.feature_flags, FeatureFlagsEnum(kwargs["flag"])), + } diff --git a/kdb-bot/src/bot_graphql/queries/short_role_name_history_query.py b/kdb-bot/src/bot_graphql/queries/short_role_name_history_query.py new file mode 100644 index 00000000..46cb4a8b --- /dev/null +++ b/kdb-bot/src/bot_graphql/queries/short_role_name_history_query.py @@ -0,0 +1,11 @@ +from bot_graphql.abc.history_query_abc import HistoryQueryABC + + +class ShortRoleNameHistoryQuery(HistoryQueryABC): + def __init__(self): + HistoryQueryABC.__init__(self, "ShortRoleName") + + self.set_field("id", lambda x, *_: x.id) + self.set_field("shortName", lambda x, *_: x.shortName) + self.set_field("roleId", lambda x, *_: x.roleId) + self.set_field("position", lambda x, *_: x.position.value) diff --git a/kdb-bot/src/bot_graphql/queries/short_role_name_query.py b/kdb-bot/src/bot_graphql/queries/short_role_name_query.py new file mode 100644 index 00000000..75d07ac6 --- /dev/null +++ b/kdb-bot/src/bot_graphql/queries/short_role_name_query.py @@ -0,0 +1,18 @@ +from cpl_core.database.context import DatabaseContextABC + +from bot_data.model.short_role_name_history import ShortRoleNameHistory +from bot_graphql.abc.data_query_with_history_abc import DataQueryWithHistoryABC + + +class ShortRoleNameQuery(DataQueryWithHistoryABC): + def __init__( + self, + db: DatabaseContextABC, + ): + DataQueryWithHistoryABC.__init__(self, "ShortRoleName", "ShortRoleNamesHistory", ShortRoleNameHistory, db) + + self.set_field("id", lambda x, *_: x.id) + self.set_field("shortName", lambda x, *_: x.short_name) + self.set_field("roleId", lambda x, *_: x.role_id) + self.set_field("roleName", lambda x, *_: x.role_name) + self.set_field("position", lambda x, *_: x.position.value) diff --git a/kdb-bot/src/bot_graphql/query.py b/kdb-bot/src/bot_graphql/query.py index 69e5553e..abde5cb0 100644 --- a/kdb-bot/src/bot_graphql/query.py +++ b/kdb-bot/src/bot_graphql/query.py @@ -9,11 +9,13 @@ from bot_data.abc.game_server_repository_abc import GameServerRepositoryABC from bot_data.abc.known_user_repository_abc import KnownUserRepositoryABC from bot_data.abc.level_repository_abc import LevelRepositoryABC from bot_data.abc.server_repository_abc import ServerRepositoryABC +from bot_data.abc.short_role_name_repository_abc import ShortRoleNameRepositoryABC from bot_data.abc.technician_config_repository_abc import TechnicianConfigRepositoryABC from bot_data.abc.user_joined_game_server_repository_abc import UserJoinedGameServerRepositoryABC from bot_data.abc.user_joined_server_repository_abc import UserJoinedServerRepositoryABC from bot_data.abc.user_joined_voice_channel_repository_abc import UserJoinedVoiceChannelRepositoryABC from bot_data.abc.user_repository_abc import UserRepositoryABC +from bot_data.model.short_role_name_position_enum import ShortRoleNamePositionEnum from bot_graphql.abc.query_abc import QueryABC from bot_graphql.filter.achievement_filter import AchievementFilter from bot_graphql.filter.auto_role_filter import AutoRoleFilter @@ -21,6 +23,7 @@ from bot_graphql.filter.auto_role_rule_filter import AutoRoleRuleFilter from bot_graphql.filter.client_filter import ClientFilter from bot_graphql.filter.level_filter import LevelFilter from bot_graphql.filter.server_filter import ServerFilter +from bot_graphql.filter.short_role_name_filter import ShortRoleNameFilter from bot_graphql.filter.user_filter import UserFilter from bot_graphql.filter.user_joined_game_server_filter import UserJoinedGameServerFilter from bot_graphql.filter.user_joined_server_filter import UserJoinedServerFilter @@ -44,6 +47,7 @@ class Query(QueryABC): user_joined_game_server: UserJoinedGameServerRepositoryABC, users: UserRepositoryABC, achievements: AchievementRepositoryABC, + short_role_names: ShortRoleNameRepositoryABC, achievement_service: AchievementService, technician_config: TechnicianConfigRepositoryABC, ): @@ -71,9 +75,12 @@ class Query(QueryABC): ) self.add_collection("user", lambda *_: users.get_users(), UserFilter) self.add_collection("achievement", lambda *_: achievements.get_achievements(), AchievementFilter) + self.add_collection("shortRoleName", lambda *_: short_role_names.get_short_role_names(), ShortRoleNameFilter) + self.set_field("technicianConfig", lambda *_: technician_config.get_technician_config()) self.set_field("achievementAttributes", lambda *_: achievement_service.get_attributes()) self.set_field("achievementOperators", lambda *_: achievement_service.get_operators()) + self.set_field("shortRoleNamePositions", lambda *_: [x.value for x in ShortRoleNamePositionEnum]) self.set_field("possibleFeatureFlags", lambda *_: [e.value for e in FeatureFlagsEnum]) self.set_field("discord", lambda *_: Discord(bot.guilds, List(any).extend(bot.users))) diff --git a/kdb-bot/src/modules/achievements/__init__.py b/kdb-bot/src/modules/achievements/__init__.py index eda08773..71ad4b83 100644 --- a/kdb-bot/src/modules/achievements/__init__.py +++ b/kdb-bot/src/modules/achievements/__init__.py @@ -1,10 +1,10 @@ # -*- coding: utf-8 -*- """ -bot Keksdose bot +bot sh-edraft.de Discord bot ~~~~~~~~~~~~~~~~~~~ -Discord bot for the Keksdose discord Server +Discord bot for customers of sh-edraft.de :copyright: (c) 2022 - 2023 sh-edraft.de :license: MIT, see LICENSE for more details. @@ -15,7 +15,7 @@ __title__ = "modules.achievements" __author__ = "Sven Heidemann" __license__ = "MIT" __copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de" -__version__ = "1.1.6" +__version__ = "1.1.7" 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="6") +version_info = VersionInfo(major="1", minor="1", micro="7") diff --git a/kdb-bot/src/modules/achievements/achievements.json b/kdb-bot/src/modules/achievements/achievements.json index e11f0f63..e7e12564 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": "6" + "Micro": "7" }, "Author": "Sven Heidemann", "AuthorEmail": "sven.heidemann@sh-edraft.de", @@ -16,10 +16,10 @@ "LicenseName": "MIT", "LicenseDescription": "MIT, see LICENSE for more details.", "Dependencies": [ - "cpl-core>=1.1.1" + "cpl-core>=1.1.7" ], "DevDependencies": [ - "cpl-cli>=1.1.1" + "cpl-cli>=1.1.7" ], "PythonVersion": ">=3.10.4", "PythonPath": {}, diff --git a/kdb-bot/src/modules/achievements/commands/__init__.py b/kdb-bot/src/modules/achievements/commands/__init__.py index dbff52dc..5b48db75 100644 --- a/kdb-bot/src/modules/achievements/commands/__init__.py +++ b/kdb-bot/src/modules/achievements/commands/__init__.py @@ -1,10 +1,10 @@ # -*- coding: utf-8 -*- """ -bot Keksdose bot +bot sh-edraft.de Discord bot ~~~~~~~~~~~~~~~~~~~ -Discord bot for the Keksdose discord Server +Discord bot for customers of sh-edraft.de :copyright: (c) 2022 - 2023 sh-edraft.de :license: MIT, see LICENSE for more details. @@ -15,7 +15,7 @@ __title__ = "modules.achievements.commands" __author__ = "Sven Heidemann" __license__ = "MIT" __copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de" -__version__ = "1.1.6" +__version__ = "1.1.7" 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="6") +version_info = VersionInfo(major="1", minor="1", micro="7") diff --git a/kdb-bot/src/modules/achievements/events/__init__.py b/kdb-bot/src/modules/achievements/events/__init__.py index dfaa74e8..cec4df26 100644 --- a/kdb-bot/src/modules/achievements/events/__init__.py +++ b/kdb-bot/src/modules/achievements/events/__init__.py @@ -1,10 +1,10 @@ # -*- coding: utf-8 -*- """ -bot Keksdose bot +bot sh-edraft.de Discord bot ~~~~~~~~~~~~~~~~~~~ -Discord bot for the Keksdose discord Server +Discord bot for customers of sh-edraft.de :copyright: (c) 2022 - 2023 sh-edraft.de :license: MIT, see LICENSE for more details. @@ -15,7 +15,7 @@ __title__ = "modules.achievements.events" __author__ = "Sven Heidemann" __license__ = "MIT" __copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de" -__version__ = "1.1.6" +__version__ = "1.1.7" 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="6") +version_info = VersionInfo(major="1", minor="1", micro="7") diff --git a/kdb-bot/src/modules/achievements/model/__init__.py b/kdb-bot/src/modules/achievements/model/__init__.py index d803c190..e5b45037 100644 --- a/kdb-bot/src/modules/achievements/model/__init__.py +++ b/kdb-bot/src/modules/achievements/model/__init__.py @@ -1,10 +1,10 @@ # -*- coding: utf-8 -*- """ -bot Keksdose bot +bot sh-edraft.de Discord bot ~~~~~~~~~~~~~~~~~~~ -Discord bot for the Keksdose discord Server +Discord bot for customers of sh-edraft.de :copyright: (c) 2022 - 2023 sh-edraft.de :license: MIT, see LICENSE for more details. @@ -15,7 +15,7 @@ __title__ = "modules.achievements.model" __author__ = "Sven Heidemann" __license__ = "MIT" __copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de" -__version__ = "1.1.6" +__version__ = "1.1.7" 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="6") +version_info = VersionInfo(major="1", minor="1", micro="7") diff --git a/kdb-bot/src/modules/auto_role/__init__.py b/kdb-bot/src/modules/auto_role/__init__.py index 47815bd7..e308d4c1 100644 --- a/kdb-bot/src/modules/auto_role/__init__.py +++ b/kdb-bot/src/modules/auto_role/__init__.py @@ -1,10 +1,10 @@ # -*- coding: utf-8 -*- """ -bot Keksdose bot +bot sh-edraft.de Discord bot ~~~~~~~~~~~~~~~~~~~ -Discord bot for the Keksdose discord Server +Discord bot for customers of sh-edraft.de :copyright: (c) 2022 - 2023 sh-edraft.de :license: MIT, see LICENSE for more details. @@ -15,7 +15,7 @@ __title__ = "modules.auto_role" __author__ = "Sven Heidemann" __license__ = "MIT" __copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de" -__version__ = "1.1.6" +__version__ = "1.1.7" 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="6") +version_info = VersionInfo(major="1", minor="1", micro="7") diff --git a/kdb-bot/src/modules/auto_role/auto-role.json b/kdb-bot/src/modules/auto_role/auto-role.json index 4609845a..1e74a7b0 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": "6" + "Micro": "7" }, "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 9bcc8212..d885d2c5 100644 --- a/kdb-bot/src/modules/auto_role/command/__init__.py +++ b/kdb-bot/src/modules/auto_role/command/__init__.py @@ -1,10 +1,10 @@ # -*- coding: utf-8 -*- """ -bot Keksdose bot +bot sh-edraft.de Discord bot ~~~~~~~~~~~~~~~~~~~ -Discord bot for the Keksdose discord Server +Discord bot for customers of sh-edraft.de :copyright: (c) 2022 - 2023 sh-edraft.de :license: MIT, see LICENSE for more details. @@ -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.6" +__version__ = "1.1.7" 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="6") +version_info = VersionInfo(major="1", minor="1", micro="7") diff --git a/kdb-bot/src/modules/auto_role/events/__init__.py b/kdb-bot/src/modules/auto_role/events/__init__.py index a3cbb613..1df584f1 100644 --- a/kdb-bot/src/modules/auto_role/events/__init__.py +++ b/kdb-bot/src/modules/auto_role/events/__init__.py @@ -1,10 +1,10 @@ # -*- coding: utf-8 -*- """ -bot Keksdose bot +bot sh-edraft.de Discord bot ~~~~~~~~~~~~~~~~~~~ -Discord bot for the Keksdose discord Server +Discord bot for customers of sh-edraft.de :copyright: (c) 2022 - 2023 sh-edraft.de :license: MIT, see LICENSE for more details. @@ -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.6" +__version__ = "1.1.7" 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="6") +version_info = VersionInfo(major="1", minor="1", micro="7") diff --git a/kdb-bot/src/modules/auto_role/helper/__init__.py b/kdb-bot/src/modules/auto_role/helper/__init__.py index 16d38163..c3c253a4 100644 --- a/kdb-bot/src/modules/auto_role/helper/__init__.py +++ b/kdb-bot/src/modules/auto_role/helper/__init__.py @@ -1,10 +1,10 @@ # -*- coding: utf-8 -*- """ -bot Keksdose bot +bot sh-edraft.de Discord bot ~~~~~~~~~~~~~~~~~~~ -Discord bot for the Keksdose discord Server +Discord bot for customers of sh-edraft.de :copyright: (c) 2022 - 2023 sh-edraft.de :license: MIT, see LICENSE for more details. @@ -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.6" +__version__ = "1.1.7" 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="6") +version_info = VersionInfo(major="1", minor="1", micro="7") diff --git a/kdb-bot/src/modules/base/__init__.py b/kdb-bot/src/modules/base/__init__.py index dfc3a901..52eba085 100644 --- a/kdb-bot/src/modules/base/__init__.py +++ b/kdb-bot/src/modules/base/__init__.py @@ -1,10 +1,10 @@ # -*- coding: utf-8 -*- """ -bot Keksdose bot +bot sh-edraft.de Discord bot ~~~~~~~~~~~~~~~~~~~ -Discord bot for the Keksdose discord Server +Discord bot for customers of sh-edraft.de :copyright: (c) 2022 - 2023 sh-edraft.de :license: MIT, see LICENSE for more details. @@ -15,7 +15,7 @@ __title__ = "modules.base" __author__ = "Sven Heidemann" __license__ = "MIT" __copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de" -__version__ = "1.1.6" +__version__ = "1.1.7" 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="6") +version_info = VersionInfo(major="1", minor="1", micro="7") diff --git a/kdb-bot/src/modules/base/base.json b/kdb-bot/src/modules/base/base.json index c5b462df..a616acc0 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": "6" + "Micro": "7" }, "Author": "", "AuthorEmail": "", diff --git a/kdb-bot/src/modules/base/base_module.py b/kdb-bot/src/modules/base/base_module.py index 4c4c5e5f..626ea4ef 100644 --- a/kdb-bot/src/modules/base/base_module.py +++ b/kdb-bot/src/modules/base/base_module.py @@ -21,6 +21,7 @@ from modules.base.command.unregister_group import UnregisterGroup from modules.base.command.user_group import UserGroup from modules.base.events.base_on_command_error_event import BaseOnCommandErrorEvent from modules.base.events.base_on_command_event import BaseOnCommandEvent +from modules.base.events.base_on_guild_join_event import BaseOnGuildJoinEvent from modules.base.events.base_on_member_join_event import BaseOnMemberJoinEvent from modules.base.events.base_on_member_remove_event import BaseOnMemberRemoveEvent from modules.base.events.base_on_message_delete_event import BaseOnMessageDeleteEvent @@ -103,3 +104,7 @@ class BaseModule(ModuleABC): DiscordEventTypesEnum.on_scheduled_event_update.value, BaseOnScheduledEventUpdateEvent, ) + self._dc.add_event( + DiscordEventTypesEnum.on_guild_join.value, + BaseOnGuildJoinEvent, + ) diff --git a/kdb-bot/src/modules/base/command/__init__.py b/kdb-bot/src/modules/base/command/__init__.py index 73da5488..4d2bebf1 100644 --- a/kdb-bot/src/modules/base/command/__init__.py +++ b/kdb-bot/src/modules/base/command/__init__.py @@ -1,10 +1,10 @@ # -*- coding: utf-8 -*- """ -bot Keksdose bot +bot sh-edraft.de Discord bot ~~~~~~~~~~~~~~~~~~~ -Discord bot for the Keksdose discord Server +Discord bot for customers of sh-edraft.de :copyright: (c) 2022 - 2023 sh-edraft.de :license: MIT, see LICENSE for more details. @@ -15,7 +15,7 @@ __title__ = "modules.base.command" __author__ = "Sven Heidemann" __license__ = "MIT" __copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de" -__version__ = "1.1.6" +__version__ = "1.1.7" 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="6") +version_info = VersionInfo(major="1", minor="1", micro="7") diff --git a/kdb-bot/src/modules/base/events/__init__.py b/kdb-bot/src/modules/base/events/__init__.py index ad93bb83..77d39d5f 100644 --- a/kdb-bot/src/modules/base/events/__init__.py +++ b/kdb-bot/src/modules/base/events/__init__.py @@ -1,10 +1,10 @@ # -*- coding: utf-8 -*- """ -bot Keksdose bot +bot sh-edraft.de Discord bot ~~~~~~~~~~~~~~~~~~~ -Discord bot for the Keksdose discord Server +Discord bot for customers of sh-edraft.de :copyright: (c) 2022 - 2023 sh-edraft.de :license: MIT, see LICENSE for more details. @@ -15,7 +15,7 @@ __title__ = "modules.base.events" __author__ = "Sven Heidemann" __license__ = "MIT" __copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de" -__version__ = "1.1.6" +__version__ = "1.1.7" 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="6") +version_info = VersionInfo(major="1", minor="1", micro="7") diff --git a/kdb-bot/src/modules/base/events/base_on_guild_join_event.py b/kdb-bot/src/modules/base/events/base_on_guild_join_event.py new file mode 100644 index 00000000..4a1582de --- /dev/null +++ b/kdb-bot/src/modules/base/events/base_on_guild_join_event.py @@ -0,0 +1,38 @@ +from cpl_core.database.context import DatabaseContextABC +from cpl_core.logging import LoggerABC +from cpl_discord.events import OnGuildJoinABC +from cpl_discord.service import DiscordBotServiceABC +from discord import Guild + +from bot_data.abc.server_config_repository_abc import ServerConfigRepositoryABC +from bot_data.abc.server_repository_abc import ServerRepositoryABC +from bot_data.model.server import Server +from bot_data.service.seeder_service import SeederService + + +class BaseOnGuildJoinEvent(OnGuildJoinABC): + def __init__( + self, + logger: LoggerABC, + bot: DiscordBotServiceABC, + servers: ServerRepositoryABC, + server_config: ServerConfigRepositoryABC, + db: DatabaseContextABC, + seeder: SeederService, + ): + OnGuildJoinABC.__init__(self) + + self._logger = logger + self._bot = bot + self._servers = servers + self._server_config = server_config + self._db = db + self._seeder = seeder + + async def on_guild_join(self, guild: Guild): + if self._servers.find_server_by_discord_id(guild.id) is None: + self._servers.add_server(Server(guild.id)) + self._db.save_changes() + + await self._seeder.seed() + self._logger.debug(__name__, "Seeded technician config") diff --git a/kdb-bot/src/modules/base/forms/__init__.py b/kdb-bot/src/modules/base/forms/__init__.py index 340c079a..72e2c54f 100644 --- a/kdb-bot/src/modules/base/forms/__init__.py +++ b/kdb-bot/src/modules/base/forms/__init__.py @@ -1,10 +1,10 @@ # -*- coding: utf-8 -*- """ -bot Keksdose bot +bot sh-edraft.de Discord bot ~~~~~~~~~~~~~~~~~~~ -Discord bot for the Keksdose discord Server +Discord bot for customers of sh-edraft.de :copyright: (c) 2022 - 2023 sh-edraft.de :license: MIT, see LICENSE for more details. @@ -15,7 +15,7 @@ __title__ = "modules.base.forms" __author__ = "Sven Heidemann" __license__ = "MIT" __copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de" -__version__ = "1.1.6" +__version__ = "1.1.7" 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="6") +version_info = VersionInfo(major="1", minor="1", micro="7") diff --git a/kdb-bot/src/modules/base/helper/__init__.py b/kdb-bot/src/modules/base/helper/__init__.py index 4d715c27..21f0ed8c 100644 --- a/kdb-bot/src/modules/base/helper/__init__.py +++ b/kdb-bot/src/modules/base/helper/__init__.py @@ -1,10 +1,10 @@ # -*- coding: utf-8 -*- """ -bot Keksdose bot +bot sh-edraft.de Discord bot ~~~~~~~~~~~~~~~~~~~ -Discord bot for the Keksdose discord Server +Discord bot for customers of sh-edraft.de :copyright: (c) 2022 - 2023 sh-edraft.de :license: MIT, see LICENSE for more details. @@ -15,7 +15,7 @@ __title__ = "modules.base.helper" __author__ = "Sven Heidemann" __license__ = "MIT" __copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de" -__version__ = "1.1.6" +__version__ = "1.1.7" 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="6") +version_info = VersionInfo(major="1", minor="1", micro="7") diff --git a/kdb-bot/src/modules/base/model/__init__.py b/kdb-bot/src/modules/base/model/__init__.py index aaaa2bd4..b7080c87 100644 --- a/kdb-bot/src/modules/base/model/__init__.py +++ b/kdb-bot/src/modules/base/model/__init__.py @@ -1,10 +1,10 @@ # -*- coding: utf-8 -*- """ -bot Keksdose bot +bot sh-edraft.de Discord bot ~~~~~~~~~~~~~~~~~~~ -Discord bot for the Keksdose discord Server +Discord bot for customers of sh-edraft.de :copyright: (c) 2022 - 2023 sh-edraft.de :license: MIT, see LICENSE for more details. @@ -15,7 +15,7 @@ __title__ = "modules.base.model" __author__ = "Sven Heidemann" __license__ = "MIT" __copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de" -__version__ = "1.1.6" +__version__ = "1.1.7" 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="6") +version_info = VersionInfo(major="1", minor="1", micro="7") diff --git a/kdb-bot/src/modules/base/service/__init__.py b/kdb-bot/src/modules/base/service/__init__.py index 59c5de9b..9771bb2f 100644 --- a/kdb-bot/src/modules/base/service/__init__.py +++ b/kdb-bot/src/modules/base/service/__init__.py @@ -1,10 +1,10 @@ # -*- coding: utf-8 -*- """ -bot Keksdose bot +bot sh-edraft.de Discord bot ~~~~~~~~~~~~~~~~~~~ -Discord bot for the Keksdose discord Server +Discord bot for customers of sh-edraft.de :copyright: (c) 2022 - 2023 sh-edraft.de :license: MIT, see LICENSE for more details. @@ -15,7 +15,7 @@ __title__ = "modules.base.service" __author__ = "Sven Heidemann" __license__ = "MIT" __copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de" -__version__ = "1.1.6" +__version__ = "1.1.7" 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="6") +version_info = VersionInfo(major="1", minor="1", micro="7") diff --git a/kdb-bot/src/modules/base/thread/__init__.py b/kdb-bot/src/modules/base/thread/__init__.py index daccd3b7..2a348f48 100644 --- a/kdb-bot/src/modules/base/thread/__init__.py +++ b/kdb-bot/src/modules/base/thread/__init__.py @@ -1,10 +1,10 @@ # -*- coding: utf-8 -*- """ -bot Keksdose bot +bot sh-edraft.de Discord bot ~~~~~~~~~~~~~~~~~~~ -Discord bot for the Keksdose discord Server +Discord bot for customers of sh-edraft.de :copyright: (c) 2022 - 2023 sh-edraft.de :license: MIT, see LICENSE for more details. @@ -15,7 +15,7 @@ __title__ = "modules.base.thread" __author__ = "Sven Heidemann" __license__ = "MIT" __copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de" -__version__ = "1.1.6" +__version__ = "1.1.7" 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="6") +version_info = VersionInfo(major="1", minor="1", micro="7") diff --git a/kdb-bot/src/modules/boot_log/__init__.py b/kdb-bot/src/modules/boot_log/__init__.py index 37cba8a2..29eb5718 100644 --- a/kdb-bot/src/modules/boot_log/__init__.py +++ b/kdb-bot/src/modules/boot_log/__init__.py @@ -1,10 +1,10 @@ # -*- coding: utf-8 -*- """ -bot Keksdose bot +bot sh-edraft.de Discord bot ~~~~~~~~~~~~~~~~~~~ -Discord bot for the Keksdose discord Server +Discord bot for customers of sh-edraft.de :copyright: (c) 2022 - 2023 sh-edraft.de :license: MIT, see LICENSE for more details. @@ -15,7 +15,7 @@ __title__ = "modules.boot_log" __author__ = "Sven Heidemann" __license__ = "MIT" __copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de" -__version__ = "1.1.6" +__version__ = "1.1.7" 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="6") +version_info = VersionInfo(major="1", minor="1", micro="7") diff --git a/kdb-bot/src/modules/boot_log/boot-log.json b/kdb-bot/src/modules/boot_log/boot-log.json index 351f7fbb..25678415 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": "6" + "Micro": "7" }, "Author": "", "AuthorEmail": "", diff --git a/kdb-bot/src/modules/config/__init__.py b/kdb-bot/src/modules/config/__init__.py index 0330d875..3176c939 100644 --- a/kdb-bot/src/modules/config/__init__.py +++ b/kdb-bot/src/modules/config/__init__.py @@ -1,10 +1,10 @@ # -*- coding: utf-8 -*- """ -bot Keksdose bot +bot sh-edraft.de Discord bot ~~~~~~~~~~~~~~~~~~~ -Discord bot for the Keksdose discord Server +Discord bot for customers of sh-edraft.de :copyright: (c) 2022 - 2023 sh-edraft.de :license: MIT, see LICENSE for more details. @@ -15,7 +15,7 @@ __title__ = "modules.config" __author__ = "Sven Heidemann" __license__ = "MIT" __copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de" -__version__ = "1.1.6" +__version__ = "1.1.7" 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="6") +version_info = VersionInfo(major="1", minor="1", micro="7") diff --git a/kdb-bot/src/modules/config/config.json b/kdb-bot/src/modules/config/config.json index a0d39cf8..a577cdf4 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": "6" + "Micro": "7" }, "Author": "", "AuthorEmail": "", @@ -16,10 +16,10 @@ "LicenseName": "", "LicenseDescription": "", "Dependencies": [ - "cpl-core>=1.1.1" + "cpl-core>=1.1.7" ], "DevDependencies": [ - "cpl-cli>=1.1.1" + "cpl-cli>=1.1.7" ], "PythonVersion": ">=3.10.4", "PythonPath": { diff --git a/kdb-bot/src/modules/config/events/__init__.py b/kdb-bot/src/modules/config/events/__init__.py index a19fb622..115ca61d 100644 --- a/kdb-bot/src/modules/config/events/__init__.py +++ b/kdb-bot/src/modules/config/events/__init__.py @@ -1,10 +1,10 @@ # -*- coding: utf-8 -*- """ -bot Keksdose bot +bot sh-edraft.de Discord bot ~~~~~~~~~~~~~~~~~~~ -Discord bot for the Keksdose discord Server +Discord bot for customers of sh-edraft.de :copyright: (c) 2022 - 2023 sh-edraft.de :license: MIT, see LICENSE for more details. @@ -15,7 +15,7 @@ __title__ = "modules.config.events" __author__ = "Sven Heidemann" __license__ = "MIT" __copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de" -__version__ = "1.1.6" +__version__ = "1.1.7" 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="6") +version_info = VersionInfo(major="1", minor="1", micro="7") diff --git a/kdb-bot/src/modules/config/service/__init__.py b/kdb-bot/src/modules/config/service/__init__.py index f3869c77..e43d609d 100644 --- a/kdb-bot/src/modules/config/service/__init__.py +++ b/kdb-bot/src/modules/config/service/__init__.py @@ -1,10 +1,10 @@ # -*- coding: utf-8 -*- """ -bot Keksdose bot +bot sh-edraft.de Discord bot ~~~~~~~~~~~~~~~~~~~ -Discord bot for the Keksdose discord Server +Discord bot for customers of sh-edraft.de :copyright: (c) 2022 - 2023 sh-edraft.de :license: MIT, see LICENSE for more details. @@ -15,7 +15,7 @@ __title__ = "modules.config.service" __author__ = "Sven Heidemann" __license__ = "MIT" __copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de" -__version__ = "1.1.6" +__version__ = "1.1.7" 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="6") +version_info = VersionInfo(major="1", minor="1", micro="7") diff --git a/kdb-bot/src/modules/database/__init__.py b/kdb-bot/src/modules/database/__init__.py index 4605835b..f36b93f3 100644 --- a/kdb-bot/src/modules/database/__init__.py +++ b/kdb-bot/src/modules/database/__init__.py @@ -1,10 +1,10 @@ # -*- coding: utf-8 -*- """ -bot Keksdose bot +bot sh-edraft.de Discord bot ~~~~~~~~~~~~~~~~~~~ -Discord bot for the Keksdose discord Server +Discord bot for customers of sh-edraft.de :copyright: (c) 2022 - 2023 sh-edraft.de :license: MIT, see LICENSE for more details. @@ -15,7 +15,7 @@ __title__ = "modules.database" __author__ = "Sven Heidemann" __license__ = "MIT" __copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de" -__version__ = "1.1.6" +__version__ = "1.1.7" 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="6") +version_info = VersionInfo(major="1", minor="1", micro="7") diff --git a/kdb-bot/src/modules/database/database.json b/kdb-bot/src/modules/database/database.json index c0f5e616..34652472 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": "6" + "Micro": "7" }, "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 6d650e08..0aded4e7 100644 --- a/kdb-bot/src/modules/level/__init__.py +++ b/kdb-bot/src/modules/level/__init__.py @@ -1,10 +1,10 @@ # -*- coding: utf-8 -*- """ -bot Keksdose bot +bot sh-edraft.de Discord bot ~~~~~~~~~~~~~~~~~~~ -Discord bot for the Keksdose discord Server +Discord bot for customers of sh-edraft.de :copyright: (c) 2022 - 2023 sh-edraft.de :license: MIT, see LICENSE for more details. @@ -15,7 +15,7 @@ __title__ = "modules.level" __author__ = "Sven Heidemann" __license__ = "MIT" __copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de" -__version__ = "1.1.6" +__version__ = "1.1.7" 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="6") +version_info = VersionInfo(major="1", minor="1", micro="7") diff --git a/kdb-bot/src/modules/level/command/__init__.py b/kdb-bot/src/modules/level/command/__init__.py index 958058b4..154379a7 100644 --- a/kdb-bot/src/modules/level/command/__init__.py +++ b/kdb-bot/src/modules/level/command/__init__.py @@ -1,10 +1,10 @@ # -*- coding: utf-8 -*- """ -bot Keksdose bot +bot sh-edraft.de Discord bot ~~~~~~~~~~~~~~~~~~~ -Discord bot for the Keksdose discord Server +Discord bot for customers of sh-edraft.de :copyright: (c) 2022 - 2023 sh-edraft.de :license: MIT, see LICENSE for more details. @@ -15,7 +15,7 @@ __title__ = "modules.level.command" __author__ = "Sven Heidemann" __license__ = "MIT" __copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de" -__version__ = "1.1.6" +__version__ = "1.1.7" 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="6") +version_info = VersionInfo(major="1", minor="1", micro="7") diff --git a/kdb-bot/src/modules/level/configuration/__init__.py b/kdb-bot/src/modules/level/configuration/__init__.py index 1340f77d..b0b95b47 100644 --- a/kdb-bot/src/modules/level/configuration/__init__.py +++ b/kdb-bot/src/modules/level/configuration/__init__.py @@ -1,10 +1,10 @@ # -*- coding: utf-8 -*- """ -bot Keksdose bot +bot sh-edraft.de Discord bot ~~~~~~~~~~~~~~~~~~~ -Discord bot for the Keksdose discord Server +Discord bot for customers of sh-edraft.de :copyright: (c) 2022 - 2023 sh-edraft.de :license: MIT, see LICENSE for more details. @@ -15,7 +15,7 @@ __title__ = "modules.level.configuration" __author__ = "Sven Heidemann" __license__ = "MIT" __copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de" -__version__ = "1.1.6" +__version__ = "1.1.7" 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="6") +version_info = VersionInfo(major="1", minor="1", micro="7") diff --git a/kdb-bot/src/modules/level/events/__init__.py b/kdb-bot/src/modules/level/events/__init__.py index 1c7d6538..2f4e44d7 100644 --- a/kdb-bot/src/modules/level/events/__init__.py +++ b/kdb-bot/src/modules/level/events/__init__.py @@ -1,10 +1,10 @@ # -*- coding: utf-8 -*- """ -bot Keksdose bot +bot sh-edraft.de Discord bot ~~~~~~~~~~~~~~~~~~~ -Discord bot for the Keksdose discord Server +Discord bot for customers of sh-edraft.de :copyright: (c) 2022 - 2023 sh-edraft.de :license: MIT, see LICENSE for more details. @@ -15,7 +15,7 @@ __title__ = "modules.level.events" __author__ = "Sven Heidemann" __license__ = "MIT" __copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de" -__version__ = "1.1.6" +__version__ = "1.1.7" 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="6") +version_info = VersionInfo(major="1", minor="1", micro="7") diff --git a/kdb-bot/src/modules/level/level.json b/kdb-bot/src/modules/level/level.json index aac241e5..7f18d235 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": "6" + "Micro": "7" }, "Author": "", "AuthorEmail": "", diff --git a/kdb-bot/src/modules/level/service/__init__.py b/kdb-bot/src/modules/level/service/__init__.py index baf51d2f..d2a1658a 100644 --- a/kdb-bot/src/modules/level/service/__init__.py +++ b/kdb-bot/src/modules/level/service/__init__.py @@ -1,10 +1,10 @@ # -*- coding: utf-8 -*- """ -bot Keksdose bot +bot sh-edraft.de Discord bot ~~~~~~~~~~~~~~~~~~~ -Discord bot for the Keksdose discord Server +Discord bot for customers of sh-edraft.de :copyright: (c) 2022 - 2023 sh-edraft.de :license: MIT, see LICENSE for more details. @@ -15,7 +15,7 @@ __title__ = "modules.level.service" __author__ = "Sven Heidemann" __license__ = "MIT" __copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de" -__version__ = "1.1.6" +__version__ = "1.1.7" 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="6") +version_info = VersionInfo(major="1", minor="1", micro="7") diff --git a/kdb-bot/src/modules/permission/__init__.py b/kdb-bot/src/modules/permission/__init__.py index 50356dc0..16cb5fd9 100644 --- a/kdb-bot/src/modules/permission/__init__.py +++ b/kdb-bot/src/modules/permission/__init__.py @@ -1,10 +1,10 @@ # -*- coding: utf-8 -*- """ -bot Keksdose bot +bot sh-edraft.de Discord bot ~~~~~~~~~~~~~~~~~~~ -Discord bot for the Keksdose discord Server +Discord bot for customers of sh-edraft.de :copyright: (c) 2022 - 2023 sh-edraft.de :license: MIT, see LICENSE for more details. @@ -15,7 +15,7 @@ __title__ = "modules.permission" __author__ = "Sven Heidemann" __license__ = "MIT" __copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de" -__version__ = "1.1.6" +__version__ = "1.1.7" 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="6") +version_info = VersionInfo(major="1", minor="1", micro="7") diff --git a/kdb-bot/src/modules/permission/abc/__init__.py b/kdb-bot/src/modules/permission/abc/__init__.py index 4ded6a8e..96807eb3 100644 --- a/kdb-bot/src/modules/permission/abc/__init__.py +++ b/kdb-bot/src/modules/permission/abc/__init__.py @@ -1,10 +1,10 @@ # -*- coding: utf-8 -*- """ -bot Keksdose bot +bot sh-edraft.de Discord bot ~~~~~~~~~~~~~~~~~~~ -Discord bot for the Keksdose discord Server +Discord bot for customers of sh-edraft.de :copyright: (c) 2022 - 2023 sh-edraft.de :license: MIT, see LICENSE for more details. @@ -15,7 +15,7 @@ __title__ = "modules.permission.abc" __author__ = "Sven Heidemann" __license__ = "MIT" __copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de" -__version__ = "1.1.6" +__version__ = "1.1.7" 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="6") +version_info = VersionInfo(major="1", minor="1", micro="7") diff --git a/kdb-bot/src/modules/permission/events/__init__.py b/kdb-bot/src/modules/permission/events/__init__.py index 046d7be3..12c5f310 100644 --- a/kdb-bot/src/modules/permission/events/__init__.py +++ b/kdb-bot/src/modules/permission/events/__init__.py @@ -1,10 +1,10 @@ # -*- coding: utf-8 -*- """ -bot Keksdose bot +bot sh-edraft.de Discord bot ~~~~~~~~~~~~~~~~~~~ -Discord bot for the Keksdose discord Server +Discord bot for customers of sh-edraft.de :copyright: (c) 2022 - 2023 sh-edraft.de :license: MIT, see LICENSE for more details. @@ -15,7 +15,7 @@ __title__ = "modules.permission.events" __author__ = "Sven Heidemann" __license__ = "MIT" __copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de" -__version__ = "1.1.6" +__version__ = "1.1.7" 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="6") +version_info = VersionInfo(major="1", minor="1", micro="7") diff --git a/kdb-bot/src/modules/permission/permission.json b/kdb-bot/src/modules/permission/permission.json index 7b90445a..f8320fdc 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": "6" + "Micro": "7" }, "Author": "", "AuthorEmail": "", diff --git a/kdb-bot/src/modules/permission/service/__init__.py b/kdb-bot/src/modules/permission/service/__init__.py index 171cdfa0..f64820d9 100644 --- a/kdb-bot/src/modules/permission/service/__init__.py +++ b/kdb-bot/src/modules/permission/service/__init__.py @@ -1,10 +1,10 @@ # -*- coding: utf-8 -*- """ -bot Keksdose bot +bot sh-edraft.de Discord bot ~~~~~~~~~~~~~~~~~~~ -Discord bot for the Keksdose discord Server +Discord bot for customers of sh-edraft.de :copyright: (c) 2022 - 2023 sh-edraft.de :license: MIT, see LICENSE for more details. @@ -15,7 +15,7 @@ __title__ = "modules.permission.service" __author__ = "Sven Heidemann" __license__ = "MIT" __copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de" -__version__ = "1.1.6" +__version__ = "1.1.7" 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="6") +version_info = VersionInfo(major="1", minor="1", micro="7") diff --git a/kdb-bot/src/modules/short_role_name/__init__.py b/kdb-bot/src/modules/short_role_name/__init__.py new file mode 100644 index 00000000..41e1dfbb --- /dev/null +++ b/kdb-bot/src/modules/short_role_name/__init__.py @@ -0,0 +1,26 @@ +# -*- coding: utf-8 -*- + +""" +bot sh-edraft.de Discord bot +~~~~~~~~~~~~~~~~~~~ + +Discord bot for customers of sh-edraft.de + +:copyright: (c) 2022 - 2023 sh-edraft.de +:license: MIT, see LICENSE for more details. + +""" + +__title__ = "modules.short_role_name" +__author__ = "Sven Heidemann" +__license__ = "MIT" +__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de" +__version__ = "1.1.7" + +from collections import namedtuple + + +# imports + +VersionInfo = namedtuple("VersionInfo", "major minor micro") +version_info = VersionInfo(major="1", minor="1", micro="7") diff --git a/kdb-bot/src/modules/short_role_name/events/__init__.py b/kdb-bot/src/modules/short_role_name/events/__init__.py new file mode 100644 index 00000000..daa3d4a7 --- /dev/null +++ b/kdb-bot/src/modules/short_role_name/events/__init__.py @@ -0,0 +1,26 @@ +# -*- coding: utf-8 -*- + +""" +bot sh-edraft.de Discord bot +~~~~~~~~~~~~~~~~~~~ + +Discord bot for customers of sh-edraft.de + +:copyright: (c) 2022 - 2023 sh-edraft.de +:license: MIT, see LICENSE for more details. + +""" + +__title__ = "modules.short_role_name.events" +__author__ = "Sven Heidemann" +__license__ = "MIT" +__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de" +__version__ = "1.1.7" + +from collections import namedtuple + + +# imports + +VersionInfo = namedtuple("VersionInfo", "major minor micro") +version_info = VersionInfo(major="1", minor="1", micro="7") diff --git a/kdb-bot/src/modules/short_role_name/events/short_role_name_on_member_update_event.py b/kdb-bot/src/modules/short_role_name/events/short_role_name_on_member_update_event.py new file mode 100644 index 00000000..6b942ed1 --- /dev/null +++ b/kdb-bot/src/modules/short_role_name/events/short_role_name_on_member_update_event.py @@ -0,0 +1,14 @@ +import discord +from cpl_discord.events import OnMemberUpdateABC + +from modules.short_role_name.service.short_role_name_service import ShortRoleNameService + + +class ShortRoleNameOnMemberUpdateEvent(OnMemberUpdateABC): + def __init__(self, service: ShortRoleNameService): + OnMemberUpdateABC.__init__(self) + self._service = service + + async def on_member_update(self, before: discord.member.Member, after: discord.member.Member): + if before.roles != after.roles or before.name != after.name: + await self._service.check_short_role_names(after) diff --git a/kdb-bot/src/modules/short_role_name/service/__init__.py b/kdb-bot/src/modules/short_role_name/service/__init__.py new file mode 100644 index 00000000..8e012943 --- /dev/null +++ b/kdb-bot/src/modules/short_role_name/service/__init__.py @@ -0,0 +1,26 @@ +# -*- coding: utf-8 -*- + +""" +bot sh-edraft.de Discord bot +~~~~~~~~~~~~~~~~~~~ + +Discord bot for customers of sh-edraft.de + +:copyright: (c) 2022 - 2023 sh-edraft.de +:license: MIT, see LICENSE for more details. + +""" + +__title__ = "modules.short_role_name.service" +__author__ = "Sven Heidemann" +__license__ = "MIT" +__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de" +__version__ = "1.1.7" + +from collections import namedtuple + + +# imports + +VersionInfo = namedtuple("VersionInfo", "major minor micro") +version_info = VersionInfo(major="1", minor="1", micro="7") diff --git a/kdb-bot/src/modules/short_role_name/service/short_role_name_service.py b/kdb-bot/src/modules/short_role_name/service/short_role_name_service.py new file mode 100644 index 00000000..8fc04b32 --- /dev/null +++ b/kdb-bot/src/modules/short_role_name/service/short_role_name_service.py @@ -0,0 +1,76 @@ +import discord +from cpl_core.configuration import ConfigurationABC +from cpl_core.logging import LoggerABC +from cpl_discord.service import DiscordBotServiceABC +from cpl_query.extension import List + +from bot_core.configuration.feature_flags_enum import FeatureFlagsEnum +from bot_core.configuration.feature_flags_settings import FeatureFlagsSettings +from bot_data.abc.server_repository_abc import ServerRepositoryABC +from bot_data.abc.short_role_name_repository_abc import ShortRoleNameRepositoryABC +from bot_data.model.server_config import ServerConfig +from bot_data.model.short_role_name import ShortRoleName +from bot_data.model.short_role_name_position_enum import ShortRoleNamePositionEnum + + +class ShortRoleNameService: + def __init__( + self, + config: ConfigurationABC, + logger: LoggerABC, + bot: DiscordBotServiceABC, + server: ServerRepositoryABC, + short_role_names: ShortRoleNameRepositoryABC, + ): + self._config = config + self._logger = logger + self._bot = bot + self._server = server + self._short_role_names = short_role_names + + async def check_short_role_names(self, member: discord.Member): + self._logger.debug(__name__, f"Started short role name check for {member.id}") + settings: ServerConfig = self._config.get_configuration(f"ServerConfig_{member.guild.id}") + if not FeatureFlagsSettings.get_flag_from_dict(settings.feature_flags, FeatureFlagsEnum.short_role_name): + self._logger.debug(__name__, f"Feature not active") + return + + if member == member.guild.owner: + return + + before = "" + after = "" + new_nick = member.nick if member.nick is not None else member.name + role_ids = List(discord.Role, member.roles).select(lambda x: x.id) + + server = self._server.get_server_by_discord_id(member.guild.id) + for short_role_name in self._short_role_names.get_short_role_names_by_server_id(server.id): + short_role_name: ShortRoleName = short_role_name + + new_nick = new_nick.replace(f" [{short_role_name.short_name}]", "") + new_nick = new_nick.replace(f"[{short_role_name.short_name}] ", "") + new_nick = new_nick.replace(f"[{short_role_name.short_name}]", "") + + if short_role_name.role_id not in role_ids: + continue + + if short_role_name.position == ShortRoleNamePositionEnum.before: + before += f"[{short_role_name.short_name}] " + elif short_role_name.position == ShortRoleNamePositionEnum.after: + after += f" [{short_role_name.short_name}]" + + if before != "": + new_nick = before + new_nick + + if after != "": + new_nick = new_nick + after + + if member.nick is None or member.nick == new_nick: + return + + try: + self._logger.debug(__name__, f"Update member {member.id}") + await member.edit(nick=new_nick) + self._logger.debug(__name__, f"Updated member {member.id} {member.name}") + except Exception as e: + self._logger.error(__name__, f"Renaming member {member.name} failed", e) diff --git a/kdb-bot/src/modules/short_role_name/short-role-name.json b/kdb-bot/src/modules/short_role_name/short-role-name.json new file mode 100644 index 00000000..3cc5cce9 --- /dev/null +++ b/kdb-bot/src/modules/short_role_name/short-role-name.json @@ -0,0 +1,46 @@ +{ + "ProjectSettings": { + "Name": "short-role-name", + "Version": { + "Major": "0", + "Minor": "0", + "Micro": "0" + }, + "Author": "", + "AuthorEmail": "", + "Description": "", + "LongDescription": "", + "URL": "", + "CopyrightDate": "", + "CopyrightName": "", + "LicenseName": "", + "LicenseDescription": "", + "Dependencies": [ + "cpl-core>=2023.4.0.post5" + ], + "DevDependencies": [ + "cpl-cli>=2023.4.0.post3" + ], + "PythonVersion": ">=3.10.4", + "PythonPath": { + "linux": "" + }, + "Classifiers": [] + }, + "BuildSettings": { + "ProjectType": "library", + "SourcePath": "", + "OutputPath": "../../dist", + "Main": "short_role_name.main", + "EntryPoint": "short-role-name", + "IncludePackageData": false, + "Included": [], + "Excluded": [ + "*/__pycache__", + "*/logs", + "*/tests" + ], + "PackageData": {}, + "ProjectReferences": [] + } +} \ No newline at end of file diff --git a/kdb-bot/src/modules/short_role_name/short_role_name_module.py b/kdb-bot/src/modules/short_role_name/short_role_name_module.py new file mode 100644 index 00000000..dbc41bfc --- /dev/null +++ b/kdb-bot/src/modules/short_role_name/short_role_name_module.py @@ -0,0 +1,28 @@ +from cpl_core.configuration import ConfigurationABC +from cpl_core.dependency_injection import ServiceCollectionABC +from cpl_core.environment import ApplicationEnvironmentABC +from cpl_discord.discord_event_types_enum import DiscordEventTypesEnum +from cpl_discord.service.discord_collection_abc import DiscordCollectionABC + +from bot_core.abc.module_abc import ModuleABC +from bot_core.configuration.feature_flags_enum import FeatureFlagsEnum +from bot_data.abc.data_seeder_abc import DataSeederABC +from modules.short_role_name.events.short_role_name_on_member_update_event import ShortRoleNameOnMemberUpdateEvent +from modules.short_role_name.service.short_role_name_service import ShortRoleNameService +from modules.short_role_name.short_role_name_seeder import ShortRoleNameSeeder + + +class ShortRoleNameModule(ModuleABC): + def __init__(self, dc: DiscordCollectionABC): + ModuleABC.__init__(self, dc, FeatureFlagsEnum.short_role_name_module) + + def configure_configuration(self, config: ConfigurationABC, env: ApplicationEnvironmentABC): + pass + + def configure_services(self, services: ServiceCollectionABC, env: ApplicationEnvironmentABC): + services.add_transient(DataSeederABC, ShortRoleNameSeeder) + services.add_transient(ShortRoleNameService) + + # commands + # events + self._dc.add_event(DiscordEventTypesEnum.on_member_update.value, ShortRoleNameOnMemberUpdateEvent) diff --git a/kdb-bot/src/modules/short_role_name/short_role_name_seeder.py b/kdb-bot/src/modules/short_role_name/short_role_name_seeder.py new file mode 100644 index 00000000..2f8f70c0 --- /dev/null +++ b/kdb-bot/src/modules/short_role_name/short_role_name_seeder.py @@ -0,0 +1,21 @@ +from cpl_discord.service import DiscordBotServiceABC + +from bot_data.abc.data_seeder_abc import DataSeederABC +from modules.short_role_name.service.short_role_name_service import ShortRoleNameService + + +class ShortRoleNameSeeder(DataSeederABC): + def __init__( + self, + bot: DiscordBotServiceABC, + short_role_name_service: ShortRoleNameService, + ): + DataSeederABC.__init__(self) + + self._bot = bot + self._short_role_name_service = short_role_name_service + + async def seed(self): + for guild in self._bot.guilds: + for member in guild.members: + await self._short_role_name_service.check_short_role_names(member) diff --git a/kdb-bot/src/modules/technician/__init__.py b/kdb-bot/src/modules/technician/__init__.py index 0e73eb44..b9b86092 100644 --- a/kdb-bot/src/modules/technician/__init__.py +++ b/kdb-bot/src/modules/technician/__init__.py @@ -1,10 +1,10 @@ # -*- coding: utf-8 -*- """ -bot Keksdose bot +bot sh-edraft.de Discord bot ~~~~~~~~~~~~~~~~~~~ -Discord bot for the Keksdose discord Server +Discord bot for customers of sh-edraft.de :copyright: (c) 2022 - 2023 sh-edraft.de :license: MIT, see LICENSE for more details. @@ -15,7 +15,7 @@ __title__ = "modules.technician" __author__ = "Sven Heidemann" __license__ = "MIT" __copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de" -__version__ = "1.1.6" +__version__ = "1.1.7" 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="6") +version_info = VersionInfo(major="1", minor="1", micro="7") diff --git a/kdb-bot/src/modules/technician/command/__init__.py b/kdb-bot/src/modules/technician/command/__init__.py index 260f7e77..153318a6 100644 --- a/kdb-bot/src/modules/technician/command/__init__.py +++ b/kdb-bot/src/modules/technician/command/__init__.py @@ -1,10 +1,10 @@ # -*- coding: utf-8 -*- """ -bot Keksdose bot +bot sh-edraft.de Discord bot ~~~~~~~~~~~~~~~~~~~ -Discord bot for the Keksdose discord Server +Discord bot for customers of sh-edraft.de :copyright: (c) 2022 - 2023 sh-edraft.de :license: MIT, see LICENSE for more details. @@ -15,7 +15,7 @@ __title__ = "modules.technician.command" __author__ = "Sven Heidemann" __license__ = "MIT" __copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de" -__version__ = "1.1.6" +__version__ = "1.1.7" 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="6") +version_info = VersionInfo(major="1", minor="1", micro="7") diff --git a/kdb-bot/src/modules/technician/technician.json b/kdb-bot/src/modules/technician/technician.json index 1fb18154..b970353c 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": "6" + "Micro": "7" }, "Author": "", "AuthorEmail": "", diff --git a/kdb-bot/tools/checks/checks.json b/kdb-bot/tools/checks/checks.json index 343cbdf4..8ffa7472 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": "6" + "Micro": "7" }, "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 c9a5c83b..cbaf1592 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": "6" + "Micro": "7" }, "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 40a46e27..0a81bd0a 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": "6" + "Micro": "7" }, "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 f547987d..e2fed633 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": "6" + "Micro": "7" }, "Author": "Sven Heidemann", "AuthorEmail": "sven.heidemann@sh-edraft.de", diff --git a/kdb-web/package.json b/kdb-web/package.json index c640dd53..027cc595 100644 --- a/kdb-web/package.json +++ b/kdb-web/package.json @@ -1,6 +1,6 @@ { "name": "kdb-web", - "version": "1.1.6", + "version": "1.1.7", "scripts": { "ng": "ng", "update-version": "ts-node update-version.ts", @@ -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/data/server.model.ts b/kdb-web/src/app/models/data/server.model.ts index a045186d..483a6e46 100644 --- a/kdb-web/src/app/models/data/server.model.ts +++ b/kdb-web/src/app/models/data/server.model.ts @@ -3,6 +3,8 @@ import {User} from "./user.model"; import {Level} from "./level.model"; import {Client} from "./client.model"; import { AutoRole } from "./auto_role.model"; +import { ServerConfig } from "../config/server-config.model"; +import { FeatureFlag } from "../config/feature-flags.model"; export interface GameServer { id?: number; @@ -22,6 +24,9 @@ export interface Server extends Data { levels?: Level[]; userCount?: number; users?: User[]; + config?: ServerConfig; + hasFeatureFlag?: FeatureFlag; + activeFeatureFlags?: FeatureFlag[]; } export interface ServerFilter { diff --git a/kdb-web/src/app/models/data/short_role_name.model.ts b/kdb-web/src/app/models/data/short_role_name.model.ts new file mode 100644 index 00000000..21c54802 --- /dev/null +++ b/kdb-web/src/app/models/data/short_role_name.model.ts @@ -0,0 +1,20 @@ +import { Data } from "./data.model"; +import { Server, ServerFilter } from "./server.model"; + +export interface ShortRoleName extends Data { + id?: number; + shortName?: string; + roleId?: string; + roleName?: string; + position?: string; + server?: Server; +} + +export interface ShortRoleNameFilter { + id?: number; + shortName?: string; + roleId?: string; + roleName?: string; + position?: string; + server?: ServerFilter; +} diff --git a/kdb-web/src/app/models/graphql/mutations.model.ts b/kdb-web/src/app/models/graphql/mutations.model.ts index 6fc27fc0..e600d07d 100644 --- a/kdb-web/src/app/models/graphql/mutations.model.ts +++ b/kdb-web/src/app/models/graphql/mutations.model.ts @@ -166,6 +166,48 @@ export class Mutations { } `; + static createShortRoleName = ` + mutation createShortRoleName($shortName: String, $roleId: String, $position: String, $serverId: ID) { + shortRoleName { + createShortRoleName(input: { shortName: $shortName, roleId: $roleId, position: $position, serverId: $serverId}) { + id + shortName + roleId + roleName + position + server { + id + } + } + } + } + `; + + static updateShortRoleName = ` + mutation updateShortRoleName($id: ID, $shortName: String, $roleId: String, $position: String, $serverId: ID) { + shortRoleName { + updateShortRoleName(input: { id: $id, shortName: $shortName, roleId: $roleId, position: $position, serverId: $serverId }) { + id + shortName + roleId + roleName + position + } + } + } + `; + + static deleteShortRoleName = ` + mutation deleteShortRoleName($id: ID) { + shortRoleName { + deleteShortRoleName(id: $id) { + id + shortName + } + } + } + `; + static updateTechnicianConfig = ` mutation updateTechnicianConfig($id: ID, $helpCommandReferenceUrl: String, $waitForRestart: Int, $waitForShutdown: Int, $cacheMaxMessages: Int, $featureFlags: [FeatureFlagInput], $pingURLs: [String], $technicianIds: [String]) { technicianConfig { diff --git a/kdb-web/src/app/models/graphql/queries.model.ts b/kdb-web/src/app/models/graphql/queries.model.ts index 1014ec79..51d51e2e 100644 --- a/kdb-web/src/app/models/graphql/queries.model.ts +++ b/kdb-web/src/app/models/graphql/queries.model.ts @@ -82,6 +82,17 @@ export class Queries { } `; + static hasServerFeatureFlag = ` + query HasServerFeatureFlag($filter: ServerFilter, $flag: String) { + servers(filter: $filter) { + hasFeatureFlag(flag: $flag) { + key + value + } + } + } + `; + static gameServerQuery = ` query GameServersList($serverId: ID) { servers(filter: {id: $serverId}) { @@ -192,6 +203,57 @@ export class Queries { } `; + + static shortRoleNamePositionsQuery = ` + query { + shortRoleNamePositions + } + ` + + static shortRoleNameQuery = ` + query ShortRoleNameList($serverId: ID, $filter: ShortRoleNameFilter, $page: Page, $sort: Sort) { + servers(filter: {id: $serverId}) { + shortRoleNameCount + shortRoleNames(filter: $filter, page: $page, sort: $sort) { + id + shortName + roleId + roleName + position + server { + id + name + } + createdAt + modifiedAt + } + } + } + `; + + static shortRoleNameWithHistoryQuery = ` + query ShortRoleNameListHistory($serverId: ID, $id: ID) { + servers(filter: {id: $serverId}) { + shortRoleNameCount + shortRoleNames(filter: {id: $id}) { + id + + history { + id + shortName + roleId + roleName + position + server + deleted + dateFrom + dateTo + } + } + } + } + `; + static usersQuery = ` query UsersList($serverId: ID, $filter: UserFilter, $page: Page, $sort: Sort) { servers(filter: {id: $serverId}) { diff --git a/kdb-web/src/app/models/graphql/query.model.ts b/kdb-web/src/app/models/graphql/query.model.ts index fe0c9683..7fc95684 100644 --- a/kdb-web/src/app/models/graphql/query.model.ts +++ b/kdb-web/src/app/models/graphql/query.model.ts @@ -6,6 +6,8 @@ import { Level } from "../data/level.model"; import { Achievement, AchievementAttribute } from "../data/achievement.model"; import { TechnicianConfig } from "../config/technician-config.model"; import { ServerConfig } from "../config/server-config.model"; +import { ShortRoleName } from "../data/short_role_name.model"; +import { FeatureFlag } from "../config/feature-flags.model"; export interface Query { serverCount: number; @@ -64,3 +66,16 @@ export interface PossibleFeatureFlagsQuery { possibleFeatureFlags: string[]; } +export interface HasServerFeatureFlagQuery { + hasFeatureFlag: FeatureFlag; +} + +export interface ShortRoleNameListQuery { + shortRoleNameCount: number; + shortRoleNames: ShortRoleName[]; +} + +export interface ShortRoleNamePositionsQuery { + shortRoleNamePositions: string[]; +} + diff --git a/kdb-web/src/app/models/graphql/result.model.ts b/kdb-web/src/app/models/graphql/result.model.ts index 573f98ce..cff8fcf2 100644 --- a/kdb-web/src/app/models/graphql/result.model.ts +++ b/kdb-web/src/app/models/graphql/result.model.ts @@ -5,6 +5,7 @@ import { Server } from "../data/server.model"; import { Achievement } from "../data/achievement.model"; import { TechnicianConfig } from "../config/technician-config.model"; import { ServerConfig } from "../config/server-config.model"; +import { ShortRoleName } from "../data/short_role_name.model"; export interface GraphQLResult { data: { @@ -68,3 +69,11 @@ export interface AchievementMutationResult { deleteAchievement?: Achievement }; } + +export interface ShortRoleNameMutationResult { + shortRoleName: { + createShortRoleName?: ShortRoleName + updateShortRoleName?: ShortRoleName + deleteShortRoleName?: ShortRoleName + }; +} diff --git a/kdb-web/src/app/modules/admin/auth-users/components/auth-user/auth-user.component.ts b/kdb-web/src/app/modules/admin/auth-users/components/auth-user/auth-user.component.ts index 1dcfceaa..e0df3efb 100644 --- a/kdb-web/src/app/modules/admin/auth-users/components/auth-user/auth-user.component.ts +++ b/kdb-web/src/app/modules/admin/auth-users/components/auth-user/auth-user.component.ts @@ -39,7 +39,6 @@ export class AuthUserComponent extends ComponentWithTable implements OnInit, OnD ]; newUserTemplate: AuthUserDTO = { - id: 0, firstName: "", lastName: "", email: "", diff --git a/kdb-web/src/app/modules/shared/components/history-btn/history-btn.component.ts b/kdb-web/src/app/modules/shared/components/history-btn/history-btn.component.ts index ca1a2d00..aeeebd39 100644 --- a/kdb-web/src/app/modules/shared/components/history-btn/history-btn.component.ts +++ b/kdb-web/src/app/modules/shared/components/history-btn/history-btn.component.ts @@ -11,6 +11,7 @@ import { FormBuilder } from "@angular/forms"; import { TranslateService } from "@ngx-translate/core"; import { ActivatedRoute } from "@angular/router"; import { SidebarService } from "../../../../services/sidebar/sidebar.service"; +import { ServerService } from "../../../../services/server.service"; @Component({ selector: "app-history-btn", @@ -37,12 +38,12 @@ export class HistoryBtnComponent implements OnInit { private translate: TranslateService, private data: DataService, private route: ActivatedRoute, - private sidebar: SidebarService + private serverService: ServerService ) { } public ngOnInit(): void { - this.server = this.sidebar.server$.value ?? {}; + this.server = this.serverService.server$.value ?? {}; } private findVal(object: any, key: string) { diff --git a/kdb-web/src/app/modules/view/dashboard/components/dashboard/dashboard.component.ts b/kdb-web/src/app/modules/view/dashboard/components/dashboard/dashboard.component.ts index f28ae00b..bf1e7a72 100644 --- a/kdb-web/src/app/modules/view/dashboard/components/dashboard/dashboard.component.ts +++ b/kdb-web/src/app/modules/view/dashboard/components/dashboard/dashboard.component.ts @@ -14,6 +14,7 @@ import { Page } from "../../../../../models/graphql/filter/page.model"; import { Sort } from "../../../../../models/graphql/filter/sort.model"; import { Query } from "../../../../../models/graphql/query.model"; import { SidebarService } from "../../../../../services/sidebar/sidebar.service"; +import { ServerService } from "../../../../../services/server.service"; @Component({ selector: "app-dashboard", @@ -44,12 +45,9 @@ export class DashboardComponent implements OnInit, OnDestroy { constructor( private data: DataService, private spinnerService: SpinnerService, - private toastService: ToastService, - private confirmDialog: ConfirmationDialogService, private fb: FormBuilder, - private translate: TranslateService, private router: Router, - private sidebar: SidebarService + private serverService: ServerService, ) { } @@ -107,7 +105,7 @@ export class DashboardComponent implements OnInit, OnDestroy { } selectServer(server: Server) { - this.sidebar.setServer(server); + this.serverService.setServer(server); this.router.navigate(["/server", server.id]); } diff --git a/kdb-web/src/app/modules/view/server/achievements/components/achievement/achievement.component.ts b/kdb-web/src/app/modules/view/server/achievements/components/achievement/achievement.component.ts index 127848fd..96625572 100644 --- a/kdb-web/src/app/modules/view/server/achievements/components/achievement/achievement.component.ts +++ b/kdb-web/src/app/modules/view/server/achievements/components/achievement/achievement.component.ts @@ -193,7 +193,6 @@ export class AchievementComponent extends ComponentWithTable implements OnInit, } public newAchievementTemplate: Achievement = { - id: 0, createdAt: "", modifiedAt: "" }; @@ -303,11 +302,8 @@ export class AchievementComponent extends ComponentWithTable implements OnInit, public addAchievement(table: Table): void { const newAchievement = JSON.parse(JSON.stringify(this.newAchievementTemplate)); - newAchievement.id = this.achievements.length == 0 ? 1 : Math.max.apply(Math, this.achievements.map(l => { - return l.id ?? 0; - })) + 1; - this.achievements.push(newAchievement); + this.achievements = [newAchievement, ...this.achievements]; table.initRowEdit(newAchievement); diff --git a/kdb-web/src/app/modules/view/server/auto-role/components/auto-roles-rules/auto-roles-rules.component.ts b/kdb-web/src/app/modules/view/server/auto-role/components/auto-roles-rules/auto-roles-rules.component.ts index 8ef1cc57..f19a8c2f 100644 --- a/kdb-web/src/app/modules/view/server/auto-role/components/auto-roles-rules/auto-roles-rules.component.ts +++ b/kdb-web/src/app/modules/view/server/auto-role/components/auto-roles-rules/auto-roles-rules.component.ts @@ -1,4 +1,4 @@ -import { Component, OnDestroy, OnInit, Query } from "@angular/core"; +import { Component, OnDestroy, OnInit } from "@angular/core"; import { DataService } from "../../../../../../services/data/data.service"; import { ActivatedRoute, Router } from "@angular/router"; import { AutoRoleRule, AutoRoleRuleFilter } from "../../../../../../models/data/auto_role.model"; @@ -283,11 +283,8 @@ export class AutoRolesRulesComponent extends ComponentWithTable implements OnIni public addAutoRoleRule(table: Table): void { const newAutoRole = JSON.parse(JSON.stringify(this.newAutoRoleTemplate)); - newAutoRole.id = this.rules.length == 0 ? 1 : Math.max.apply(Math, this.rules.map(u => { - return u.id ?? 0; - })) + 1; - this.rules.push(newAutoRole); + this.rules = [newAutoRole, ...this.rules]; table.initRowEdit(newAutoRole); diff --git a/kdb-web/src/app/modules/view/server/auto-role/components/auto-roles/auto-roles.component.ts b/kdb-web/src/app/modules/view/server/auto-role/components/auto-roles/auto-roles.component.ts index 5cb03ec7..7091a167 100644 --- a/kdb-web/src/app/modules/view/server/auto-role/components/auto-roles/auto-roles.component.ts +++ b/kdb-web/src/app/modules/view/server/auto-role/components/auto-roles/auto-roles.component.ts @@ -256,11 +256,8 @@ export class AutoRolesComponent extends ComponentWithTable implements OnInit, On public addAutoRole(table: Table): void { const newAutoRole = JSON.parse(JSON.stringify(this.newAutoRoleTemplate)); - newAutoRole.id = this.auto_roles.length == 0 ? 1 : Math.max.apply(Math, this.auto_roles.map(u => { - return u.id ?? 0; - })) + 1; - this.auto_roles.push(newAutoRole); + this.auto_roles = [newAutoRole, ...this.auto_roles]; table.initRowEdit(newAutoRole); diff --git a/kdb-web/src/app/modules/view/server/levels/components/levels/levels.component.ts b/kdb-web/src/app/modules/view/server/levels/components/levels/levels.component.ts index 9aba25ea..c1b808b2 100644 --- a/kdb-web/src/app/modules/view/server/levels/components/levels/levels.component.ts +++ b/kdb-web/src/app/modules/view/server/levels/components/levels/levels.component.ts @@ -144,7 +144,6 @@ export class LevelsComponent extends ComponentWithTable implements OnInit, OnDes } public newLevelTemplate: Level = { - id: 0, createdAt: "", modifiedAt: "" }; @@ -260,11 +259,8 @@ export class LevelsComponent extends ComponentWithTable implements OnInit, OnDes public addLevel(table: Table): void { const newLevel = JSON.parse(JSON.stringify(this.newLevelTemplate)); - newLevel.id = this.levels.length == 0 ? 1 : Math.max.apply(Math, this.levels.map(l => { - return l.id ?? 0; - })) + 1; - this.levels.push(newLevel); + this.levels = [newLevel, ...this.levels]; table.initRowEdit(newLevel); diff --git a/kdb-web/src/app/modules/view/server/members/members.component.ts b/kdb-web/src/app/modules/view/server/members/members.component.ts index 6786adad..bfb65b75 100644 --- a/kdb-web/src/app/modules/view/server/members/members.component.ts +++ b/kdb-web/src/app/modules/view/server/members/members.component.ts @@ -37,7 +37,6 @@ export class MembersComponent extends ComponentWithTable implements OnInit, OnDe isEditingNew: boolean = false; newUserTemplate: User = { - id: 0, discordId: 0, name: "", xp: 0, diff --git a/kdb-web/src/app/modules/view/server/server-dashboard/server-dashboard.component.html b/kdb-web/src/app/modules/view/server/server-dashboard/server-dashboard.component.html index 69fa157d..f8263f8d 100644 --- a/kdb-web/src/app/modules/view/server/server-dashboard/server-dashboard.component.html +++ b/kdb-web/src/app/modules/view/server/server-dashboard/server-dashboard.component.html @@ -14,22 +14,22 @@