From e1dbab3f4f4528760bf54dffc5be2b32abf233e8 Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Sun, 6 Nov 2022 14:25:46 +0100 Subject: [PATCH 01/15] Added level module and migration #25 --- kdb-bot/cpl-workspace.json | 8 +--- .../src/bot/startup_migration_extension.py | 2 + .../configuration/feature_flags_enum.py | 1 + .../src/bot_data/migration/level_migration.py | 33 +++++++++++++ kdb-bot/src/modules/level/__init__.py | 1 + kdb-bot/src/modules/level/level.json | 46 +++++++++++++++++++ kdb-bot/src/modules/level/level_module.py | 19 ++++++++ 7 files changed, 104 insertions(+), 6 deletions(-) create mode 100644 kdb-bot/src/bot_data/migration/level_migration.py create mode 100644 kdb-bot/src/modules/level/__init__.py create mode 100644 kdb-bot/src/modules/level/level.json create mode 100644 kdb-bot/src/modules/level/level_module.py diff --git a/kdb-bot/cpl-workspace.json b/kdb-bot/cpl-workspace.json index ed99de6618..37a8b6c688 100644 --- a/kdb-bot/cpl-workspace.json +++ b/kdb-bot/cpl-workspace.json @@ -15,26 +15,22 @@ "bot-api": "src/bot_api/bot-api.json", "get-version": "tools/get_version/get-version.json", "post-build": "tools/post_build/post-build.json", - "set-version": "tools/set_version/set-version.json" + "set-version": "tools/set_version/set-version.json", + "level": "src/modules/level/level.json" }, "Scripts": { - "sv": "cpl set-version", "set-version": "cpl run set-version $ARGS; echo '';", - "gv": "cpl get-version", "get-version": "export VERSION=$(cpl run get-version); echo $VERSION;", - "pre-build": "cpl set-version $ARGS", "post-build": "cpl run post-build", - "pre-prod": "cpl build", "prod": "export KDB_ENVIRONMENT=production; export KDB_NAME=KDB-Prod; cpl start;", "pre-stage": "cpl build", "stage": "export KDB_ENVIRONMENT=staging; export KDB_NAME=KDB-Stage; cpl start;", "pre-dev": "cpl build", "dev": "export KDB_ENVIRONMENT=development; export KDB_NAME=KDB-Dev; cpl start;", - "docker-build": "cpl b; docker-compose down; docker build -t kdb-bot/kdb-bot:$(cpl gv) .", "docker-compose": "docker-compose up -d", "docker": "cpl docker-build; cpl docker-compose;" diff --git a/kdb-bot/src/bot/startup_migration_extension.py b/kdb-bot/src/bot/startup_migration_extension.py index 62d4d39d85..a5d75b6dca 100644 --- a/kdb-bot/src/bot/startup_migration_extension.py +++ b/kdb-bot/src/bot/startup_migration_extension.py @@ -7,6 +7,7 @@ from bot_data.abc.migration_abc import MigrationABC from bot_data.migration.api_migration import ApiMigration from bot_data.migration.auto_role_migration import AutoRoleMigration from bot_data.migration.initial_migration import InitialMigration +from bot_data.migration.level_migration import LevelMigration from bot_data.service.migration_service import MigrationService @@ -23,3 +24,4 @@ class StartupMigrationExtension(StartupExtensionABC): services.add_transient(MigrationABC, InitialMigration) services.add_transient(MigrationABC, AutoRoleMigration) # 03.10.2022 #54 - 0.2.2 services.add_transient(MigrationABC, ApiMigration) # 15.10.2022 #70 - 0.3.0 + services.add_transient(MigrationABC, LevelMigration) # 06.11.2022 #25 - 0.3.0 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 b41ec6e53e..226ca1d8e0 100644 --- a/kdb-bot/src/bot_core/configuration/feature_flags_enum.py +++ b/kdb-bot/src/bot_core/configuration/feature_flags_enum.py @@ -13,6 +13,7 @@ class FeatureFlagsEnum(Enum): core_extension_module = 'CoreExtensionModule' data_module = 'DataModule', database_module = 'DatabaseModule', + level_module = 'LevelModule' moderator_module = 'ModeratorModule' permission_module = 'PermissionModule' # features diff --git a/kdb-bot/src/bot_data/migration/level_migration.py b/kdb-bot/src/bot_data/migration/level_migration.py new file mode 100644 index 0000000000..d01b567744 --- /dev/null +++ b/kdb-bot/src/bot_data/migration/level_migration.py @@ -0,0 +1,33 @@ +from bot_core.logging.database_logger import DatabaseLogger +from bot_data.abc.migration_abc import MigrationABC +from bot_data.db_context import DBContext + + +class LevelMigration(MigrationABC): + name = '0.3_LevelMigration' + + 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 `Levels` ( + `Id` BIGINT NOT NULL AUTO_INCREMENT, + `Name` VARCHAR(255) NOT NULL, + `PermissionInt` BIGINT NOT NULL, + `ServerId` BIGINT, + PRIMARY KEY(`Id`), + FOREIGN KEY (`ServerId`) REFERENCES `Servers`(`ServerId`) + ); + """) + ) + + def downgrade(self): + self._cursor.execute('DROP TABLE `Levels`;') + diff --git a/kdb-bot/src/modules/level/__init__.py b/kdb-bot/src/modules/level/__init__.py new file mode 100644 index 0000000000..ad5eca3064 --- /dev/null +++ b/kdb-bot/src/modules/level/__init__.py @@ -0,0 +1 @@ +# imports: diff --git a/kdb-bot/src/modules/level/level.json b/kdb-bot/src/modules/level/level.json new file mode 100644 index 0000000000..1d8d742502 --- /dev/null +++ b/kdb-bot/src/modules/level/level.json @@ -0,0 +1,46 @@ +{ + "ProjectSettings": { + "Name": "level", + "Version": { + "Major": "0", + "Minor": "0", + "Micro": "0" + }, + "Author": "", + "AuthorEmail": "", + "Description": "", + "LongDescription": "", + "URL": "", + "CopyrightDate": "", + "CopyrightName": "", + "LicenseName": "", + "LicenseDescription": "", + "Dependencies": [ + "cpl-core>=2022.10.0.post7" + ], + "DevDependencies": [ + "cpl-cli>=2022.10.1" + ], + "PythonVersion": ">=3.10.4", + "PythonPath": { + "linux": "" + }, + "Classifiers": [] + }, + "BuildSettings": { + "ProjectType": "library", + "SourcePath": "", + "OutputPath": "../../dist", + "Main": "level.main", + "EntryPoint": "level", + "IncludePackageData": false, + "Included": [], + "Excluded": [ + "*/__pycache__", + "*/logs", + "*/tests" + ], + "PackageData": {}, + "ProjectReferences": [] + } +} \ No newline at end of file diff --git a/kdb-bot/src/modules/level/level_module.py b/kdb-bot/src/modules/level/level_module.py new file mode 100644 index 0000000000..dfdd9bdae3 --- /dev/null +++ b/kdb-bot/src/modules/level/level_module.py @@ -0,0 +1,19 @@ +from cpl_core.configuration import ConfigurationABC +from cpl_core.dependency_injection import ServiceCollectionABC +from cpl_core.environment import ApplicationEnvironmentABC +from cpl_discord.service.discord_collection_abc import DiscordCollectionABC + +from bot_core.abc.module_abc import ModuleABC +from bot_core.configuration.feature_flags_enum import FeatureFlagsEnum + + +class LevelModule(ModuleABC): + + def __init__(self, dc: DiscordCollectionABC): + ModuleABC.__init__(self, dc, FeatureFlagsEnum.level_module) + + def configure_configuration(self, config: ConfigurationABC, env: ApplicationEnvironmentABC): + pass + + def configure_services(self, service: ServiceCollectionABC, env: ApplicationEnvironmentABC): + pass From 5a3eb57c0b99623ca068797d7df476647bf86628 Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Sun, 6 Nov 2022 14:35:28 +0100 Subject: [PATCH 02/15] Added level model #25 --- .../src/bot_data/migration/level_migration.py | 2 + kdb-bot/src/bot_data/model/level.py | 116 ++++++++++++++++++ 2 files changed, 118 insertions(+) create mode 100644 kdb-bot/src/bot_data/model/level.py diff --git a/kdb-bot/src/bot_data/migration/level_migration.py b/kdb-bot/src/bot_data/migration/level_migration.py index d01b567744..71d618aef4 100644 --- a/kdb-bot/src/bot_data/migration/level_migration.py +++ b/kdb-bot/src/bot_data/migration/level_migration.py @@ -20,6 +20,8 @@ class LevelMigration(MigrationABC): CREATE TABLE IF NOT EXISTS `Levels` ( `Id` BIGINT NOT NULL AUTO_INCREMENT, `Name` VARCHAR(255) NOT NULL, + `Color` VARCHAR(7) NOT NULL, + `MinXp` BIGINT NOT NULL, `PermissionInt` BIGINT NOT NULL, `ServerId` BIGINT, PRIMARY KEY(`Id`), diff --git a/kdb-bot/src/bot_data/model/level.py b/kdb-bot/src/bot_data/model/level.py new file mode 100644 index 0000000000..abd7e68737 --- /dev/null +++ b/kdb-bot/src/bot_data/model/level.py @@ -0,0 +1,116 @@ +from datetime import datetime +from typing import Optional +from cpl_core.database import TableABC + +from bot_data.model.server import Server + + +class Level(TableABC): + + def __init__(self, name: str, color: str, min_xp: int, permissions: int, server: Optional[Server], created_at: datetime = None, modified_at: datetime = None, id=0): + self._id = id + self._name = name + self._color = color + self._min_xp = min_xp + self._permissions = permissions + 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 name(self) -> str: + return self._name + + @name.setter + def name(self, value: str): + self._name = value + + @property + def color(self) -> str: + return self._color + + @color.setter + def color(self, value: str): + self._color = value + + @property + def min_xp(self) -> int: + return self._min_xp + + @min_xp.setter + def min_xp(self, value: int): + self._min_xp = value + + @property + def permissions(self) -> int: + return self._permissions + + @permissions.setter + def permissions(self, value: int): + self._permissions = value + + @property + def server(self) -> Optional[Server]: + return self._server + + @staticmethod + def get_select_all_string() -> str: + return str(f""" + SELECT * FROM `Levels`; + """) + + @staticmethod + def get_select_by_id_string(id: int) -> str: + return str(f""" + SELECT * FROM `Levels` + WHERE `Id` = {id}; + """) + + @staticmethod + def get_select_by_server_id_string(dc_id: int, s_id: int) -> str: + return str(f""" + SELECT * FROM `Levels` + WHERE `ServerId` = {s_id}; + """) + + @property + def insert_string(self) -> str: + return str(f""" + INSERT INTO `Levels` ( + `Name`, `Color`, `MinXp`, `PermissionInt`, `ServerId`, `CreatedAt`, `LastModifiedAt` + ) VALUES ( + `{self._name}`, + `{self._color}`, + {self._min_xp}, + {self._permissions}, + {self._server.server_id}, + '{self._created_at}', + '{self._modified_at}' + ); + """) + + @property + def udpate_string(self) -> str: + return str(f""" + UPDATE `Levels` + SET `Name` = {self._name}, + `Name` = {self._name}, + `Color` = {self._color}, + `MinXp` = {self._min_xp}, + `PermissionInt` = {self._permissions}, + `LastModifiedAt` = '{self._modified_at}' + WHERE `Id` = {self._id}; + """) + + @property + def delete_string(self) -> str: + return str(f""" + DELETE FROM `Levels` + WHERE `Id` = {self._id}; + """) From e6e26b77f90a3f5a4d860e7452391fd7163ffa88 Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Sun, 6 Nov 2022 14:46:11 +0100 Subject: [PATCH 03/15] Added level repo #25 --- .../src/bot_data/abc/level_repository_abc.py | 36 +++++++ kdb-bot/src/bot_data/data_module.py | 3 + kdb-bot/src/bot_data/model/level.py | 2 +- .../service/level_repository_service.py | 97 +++++++++++++++++++ 4 files changed, 137 insertions(+), 1 deletion(-) create mode 100644 kdb-bot/src/bot_data/abc/level_repository_abc.py create mode 100644 kdb-bot/src/bot_data/service/level_repository_service.py diff --git a/kdb-bot/src/bot_data/abc/level_repository_abc.py b/kdb-bot/src/bot_data/abc/level_repository_abc.py new file mode 100644 index 0000000000..89a2a67f55 --- /dev/null +++ b/kdb-bot/src/bot_data/abc/level_repository_abc.py @@ -0,0 +1,36 @@ +from abc import ABC, abstractmethod +from typing import Optional + +from cpl_query.extension import List + +from bot_data.model.level import Level + + +class LevelRepositoryABC(ABC): + + @abstractmethod + def __init__(self): pass + + @abstractmethod + def get_levels(self) -> List[Level]: pass + + @abstractmethod + def get_level_by_id(self, id: int) -> Level: pass + + @abstractmethod + def find_level_by_id(self, id: int) -> Optional[Level]: pass + + @abstractmethod + def get_levels_by_server_id(self, server_id: int) -> List[Level]: pass + + @abstractmethod + def find_levels_by_server_id(self, server_id: int) -> Optional[List[Level]]: pass + + @abstractmethod + def add_level(self, level: Level): pass + + @abstractmethod + def update_level(self, level: Level): pass + + @abstractmethod + def delete_level(self, level: Level): pass diff --git a/kdb-bot/src/bot_data/data_module.py b/kdb-bot/src/bot_data/data_module.py index 7537b6f282..bf8786e529 100644 --- a/kdb-bot/src/bot_data/data_module.py +++ b/kdb-bot/src/bot_data/data_module.py @@ -9,6 +9,7 @@ from bot_data.abc.auth_user_repository_abc import AuthUserRepositoryABC from bot_data.abc.auto_role_repository_abc import AutoRoleRepositoryABC from bot_data.abc.client_repository_abc import ClientRepositoryABC from bot_data.abc.known_user_repository_abc import KnownUserRepositoryABC +from bot_data.abc.level_repository_abc import LevelRepositoryABC from bot_data.abc.server_repository_abc import ServerRepositoryABC from bot_data.abc.user_joined_server_repository_abc import UserJoinedServerRepositoryABC from bot_data.abc.user_joined_voice_channel_abc import UserJoinedVoiceChannelRepositoryABC @@ -17,6 +18,7 @@ from bot_data.service.auth_user_repository_service import AuthUserRepositoryServ from bot_data.service.auto_role_repository_service import AutoRoleRepositoryService from bot_data.service.client_repository_service import ClientRepositoryService from bot_data.service.known_user_repository_service import KnownUserRepositoryService +from bot_data.service.level_repository_service import LevelRepositoryService from bot_data.service.server_repository_service import ServerRepositoryService from bot_data.service.user_joined_server_repository_service import UserJoinedServerRepositoryService from bot_data.service.user_joined_voice_channel_service import UserJoinedVoiceChannelRepositoryService @@ -40,3 +42,4 @@ class DataModule(ModuleABC): services.add_transient(UserJoinedServerRepositoryABC, UserJoinedServerRepositoryService) services.add_transient(UserJoinedVoiceChannelRepositoryABC, UserJoinedVoiceChannelRepositoryService) services.add_transient(AutoRoleRepositoryABC, AutoRoleRepositoryService) + services.add_transient(LevelRepositoryABC, LevelRepositoryService) diff --git a/kdb-bot/src/bot_data/model/level.py b/kdb-bot/src/bot_data/model/level.py index abd7e68737..fcde27bfcf 100644 --- a/kdb-bot/src/bot_data/model/level.py +++ b/kdb-bot/src/bot_data/model/level.py @@ -73,7 +73,7 @@ class Level(TableABC): """) @staticmethod - def get_select_by_server_id_string(dc_id: int, s_id: int) -> str: + def get_select_by_server_id_string(s_id: int) -> str: return str(f""" SELECT * FROM `Levels` WHERE `ServerId` = {s_id}; diff --git a/kdb-bot/src/bot_data/service/level_repository_service.py b/kdb-bot/src/bot_data/service/level_repository_service.py new file mode 100644 index 0000000000..37ee595298 --- /dev/null +++ b/kdb-bot/src/bot_data/service/level_repository_service.py @@ -0,0 +1,97 @@ +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.level_repository_abc import LevelRepositoryABC +from bot_data.model.level import Level + + +class LevelRepositoryService(LevelRepositoryABC): + + def __init__(self, logger: DatabaseLogger, db_context: DatabaseContextABC, servers: ServerRepositoryABC): + self._logger = logger + self._context = db_context + + self._servers = servers + + LevelRepositoryABC.__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 _level_from_result(self, sql_result: tuple) -> Level: + return Level( + self._get_value_from_result(sql_result[1]), # name + self._get_value_from_result(sql_result[2]), # color + int(self._get_value_from_result(sql_result[3])), # min xp + int(self._get_value_from_result(sql_result[4])), # permissions + self._servers.get_server_by_id(sql_result[5]), # server + id=self._get_value_from_result(sql_result[0]) # id + ) + + def get_levels(self) -> List[Level]: + levels = List(Level) + self._logger.trace(__name__, f'Send SQL command: {Level.get_select_all_string()}') + results = self._context.select(Level.get_select_all_string()) + for result in results: + self._logger.trace(__name__, f'Get level with id {result[0]}') + levels.append(self._level_from_result(result)) + + return levels + + def get_level_by_id(self, id: int) -> Level: + self._logger.trace(__name__, f'Send SQL command: {Level.get_select_by_id_string(id)}') + result = self._context.select(Level.get_select_by_id_string(id))[0] + + return self._level_from_result(result) + + def find_level_by_id(self, id: int) -> Optional[Level]: + self._logger.trace(__name__, f'Send SQL command: {Level.get_select_by_id_string(id)}') + result = self._context.select(Level.get_select_by_id_string(id)) + if result is None or len(result) == 0: + return None + + return self._level_from_result(result[0]) + + def get_levels_by_server_id(self, server_id: int) -> List[Level]: + levels = List(Level) + self._logger.trace(__name__, f'Send SQL command: {Level.get_select_by_server_id_string(server_id)}') + results = self._context.select(Level.get_select_by_server_id_string(server_id))[0] + + for result in results: + self._logger.trace(__name__, f'Get level with id {result[0]}') + levels.append(self._level_from_result(result)) + + return levels + + def find_levels_by_server_id(self, server_id: int) -> Optional[List[Level]]: + levels = List(Level) + self._logger.trace(__name__, f'Send SQL command: {Level.get_select_by_server_id_string(server_id)}') + results = self._context.select(Level.get_select_by_server_id_string(server_id)) + if results is None or len(results) == 0: + return None + + for result in results: + self._logger.trace(__name__, f'Get level with id {result[0]}') + levels.append(self._level_from_result(result)) + + return levels + + def add_level(self, level: Level): + self._logger.trace(__name__, f'Send SQL command: {level.insert_string}') + self._context.cursor.execute(level.insert_string) + + def update_level(self, level: Level): + self._logger.trace(__name__, f'Send SQL command: {level.udpate_string}') + self._context.cursor.execute(level.udpate_string) + + def delete_level(self, level: Level): + self._logger.trace(__name__, f'Send SQL command: {level.delete_string}') + self._context.cursor.execute(level.delete_string) From 666c527730fe600ebaf1b8a9ae1206a32b836ee6 Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Sun, 6 Nov 2022 16:26:09 +0100 Subject: [PATCH 04/15] Added logic to handle default levels #25 --- kdb-bot/src/bot/config/feature-flags.json | 3 +- kdb-bot/src/bot/module_list.py | 2 + kdb-bot/src/bot_data/abc/data_seeder_abc.py | 10 ++++ kdb-bot/src/bot_data/data_module.py | 3 ++ .../src/bot_data/migration/level_migration.py | 4 +- kdb-bot/src/bot_data/model/level.py | 15 +++--- .../src/bot_data/service/seeder_service.py | 25 ++++++++++ .../modules/database/database_extension.py | 1 + .../database/database_on_ready_event.py | 5 ++ .../modules/level/configuration/__init__.py | 1 + .../level/configuration/level_settings.py | 33 +++++++++++++ kdb-bot/src/modules/level/default-level.json | 28 +++++++++++ kdb-bot/src/modules/level/level_module.py | 12 +++-- kdb-bot/src/modules/level/level_seeder.py | 46 +++++++++++++++++++ 14 files changed, 177 insertions(+), 11 deletions(-) create mode 100644 kdb-bot/src/bot_data/abc/data_seeder_abc.py create mode 100644 kdb-bot/src/bot_data/service/seeder_service.py create mode 100644 kdb-bot/src/modules/level/configuration/__init__.py create mode 100644 kdb-bot/src/modules/level/configuration/level_settings.py create mode 100644 kdb-bot/src/modules/level/default-level.json create mode 100644 kdb-bot/src/modules/level/level_seeder.py diff --git a/kdb-bot/src/bot/config/feature-flags.json b/kdb-bot/src/bot/config/feature-flags.json index 68bf6e002c..da07fa2398 100644 --- a/kdb-bot/src/bot/config/feature-flags.json +++ b/kdb-bot/src/bot/config/feature-flags.json @@ -1,6 +1,6 @@ { "FeatureFlags": { - "ApiModule": true, + "ApiModule": false, "AdminModule": true, "AutoRoleModule": true, "BaseModule": true, @@ -9,6 +9,7 @@ "CoreExtensionModule": true, "DatabaseModule": true, "ModeratorModule": true, + "LevelModule": true, "PermissionModule": true, "PresenceModule": true } diff --git a/kdb-bot/src/bot/module_list.py b/kdb-bot/src/bot/module_list.py index b818ad4bcd..03b8307cda 100644 --- a/kdb-bot/src/bot/module_list.py +++ b/kdb-bot/src/bot/module_list.py @@ -9,6 +9,7 @@ from modules.auto_role.auto_role_module import AutoRoleModule from modules.base.base_module import BaseModule from modules.boot_log.boot_log_module import BootLogModule from modules.database.database_module import DatabaseModule +from modules.level.level_module import LevelModule from modules.moderator.moderator_module import ModeratorModule from modules.permission.permission_module import PermissionModule @@ -25,6 +26,7 @@ class ModuleList: AutoRoleModule, BaseModule, DatabaseModule, + LevelModule, ModeratorModule, PermissionModule, ApiModule, diff --git a/kdb-bot/src/bot_data/abc/data_seeder_abc.py b/kdb-bot/src/bot_data/abc/data_seeder_abc.py new file mode 100644 index 0000000000..a4fecdd77e --- /dev/null +++ b/kdb-bot/src/bot_data/abc/data_seeder_abc.py @@ -0,0 +1,10 @@ +from abc import ABC, abstractmethod + + +class DataSeederABC(ABC): + + @abstractmethod + def __init__(self): pass + + @abstractmethod + def seed(self): pass diff --git a/kdb-bot/src/bot_data/data_module.py b/kdb-bot/src/bot_data/data_module.py index bf8786e529..0668bffed8 100644 --- a/kdb-bot/src/bot_data/data_module.py +++ b/kdb-bot/src/bot_data/data_module.py @@ -19,6 +19,7 @@ from bot_data.service.auto_role_repository_service import AutoRoleRepositoryServ from bot_data.service.client_repository_service import ClientRepositoryService from bot_data.service.known_user_repository_service import KnownUserRepositoryService from bot_data.service.level_repository_service import LevelRepositoryService +from bot_data.service.seeder_service import SeederService from bot_data.service.server_repository_service import ServerRepositoryService from bot_data.service.user_joined_server_repository_service import UserJoinedServerRepositoryService from bot_data.service.user_joined_voice_channel_service import UserJoinedVoiceChannelRepositoryService @@ -43,3 +44,5 @@ class DataModule(ModuleABC): services.add_transient(UserJoinedVoiceChannelRepositoryABC, UserJoinedVoiceChannelRepositoryService) services.add_transient(AutoRoleRepositoryABC, AutoRoleRepositoryService) services.add_transient(LevelRepositoryABC, LevelRepositoryService) + + services.add_transient(SeederService) diff --git a/kdb-bot/src/bot_data/migration/level_migration.py b/kdb-bot/src/bot_data/migration/level_migration.py index 71d618aef4..5b1dbc0fc3 100644 --- a/kdb-bot/src/bot_data/migration/level_migration.py +++ b/kdb-bot/src/bot_data/migration/level_migration.py @@ -20,10 +20,12 @@ class LevelMigration(MigrationABC): CREATE TABLE IF NOT EXISTS `Levels` ( `Id` BIGINT NOT NULL AUTO_INCREMENT, `Name` VARCHAR(255) NOT NULL, - `Color` VARCHAR(7) NOT NULL, + `Color` VARCHAR(8) NOT NULL, `MinXp` BIGINT NOT NULL, `PermissionInt` BIGINT NOT NULL, `ServerId` BIGINT, + `CreatedAt` DATETIME(6), + `LastModifiedAt` DATETIME(6), PRIMARY KEY(`Id`), FOREIGN KEY (`ServerId`) REFERENCES `Servers`(`ServerId`) ); diff --git a/kdb-bot/src/bot_data/model/level.py b/kdb-bot/src/bot_data/model/level.py index fcde27bfcf..9cfc63f179 100644 --- a/kdb-bot/src/bot_data/model/level.py +++ b/kdb-bot/src/bot_data/model/level.py @@ -56,8 +56,12 @@ class Level(TableABC): self._permissions = value @property - def server(self) -> Optional[Server]: + def server(self) -> Server: return self._server + + @server.setter + def server(self, value: Server): + self._server = value @staticmethod def get_select_all_string() -> str: @@ -85,8 +89,8 @@ class Level(TableABC): INSERT INTO `Levels` ( `Name`, `Color`, `MinXp`, `PermissionInt`, `ServerId`, `CreatedAt`, `LastModifiedAt` ) VALUES ( - `{self._name}`, - `{self._color}`, + '{self._name}', + '{self._color}', {self._min_xp}, {self._permissions}, {self._server.server_id}, @@ -99,9 +103,8 @@ class Level(TableABC): def udpate_string(self) -> str: return str(f""" UPDATE `Levels` - SET `Name` = {self._name}, - `Name` = {self._name}, - `Color` = {self._color}, + SET `Name` = '{self._name}', + `Color` = '{self._color}', `MinXp` = {self._min_xp}, `PermissionInt` = {self._permissions}, `LastModifiedAt` = '{self._modified_at}' diff --git a/kdb-bot/src/bot_data/service/seeder_service.py b/kdb-bot/src/bot_data/service/seeder_service.py new file mode 100644 index 0000000000..6d0f9b7df4 --- /dev/null +++ b/kdb-bot/src/bot_data/service/seeder_service.py @@ -0,0 +1,25 @@ +from cpl_core.database.context import DatabaseContextABC +from cpl_core.dependency_injection import ServiceProviderABC +from cpl_query.extension import List + +from bot_core.logging.database_logger import DatabaseLogger +from bot_data.abc.data_seeder_abc import DataSeederABC + + +class SeederService: + + def __init__(self, logger: DatabaseLogger, services: ServiceProviderABC, db: DatabaseContextABC): + self._logger = logger + self._services = services + + self._db = db + + self._seeder = List(type, DataSeederABC.__subclasses__()) + + async def seed(self): + self._logger.info(__name__, f"Seed data") + for seeder in self._seeder: + seeder_as_service: DataSeederABC = self._services.get_service(seeder) + self._logger.debug(__name__, f"Starting seeder {seeder.__name__}") + await seeder_as_service.seed() + self._db.save_changes() diff --git a/kdb-bot/src/modules/database/database_extension.py b/kdb-bot/src/modules/database/database_extension.py index 8bc111e9a9..1cc7a77fe5 100644 --- a/kdb-bot/src/modules/database/database_extension.py +++ b/kdb-bot/src/modules/database/database_extension.py @@ -9,6 +9,7 @@ from bot_core.configuration.feature_flags_enum import FeatureFlagsEnum from bot_core.configuration.feature_flags_settings import FeatureFlagsSettings from bot_core.logging.database_logger import DatabaseLogger from bot_data.service.migration_service import MigrationService +from bot_data.service.seeder_service import SeederService class DatabaseExtension(ApplicationExtensionABC): diff --git a/kdb-bot/src/modules/database/database_on_ready_event.py b/kdb-bot/src/modules/database/database_on_ready_event.py index 9176a26c15..96f013eefc 100644 --- a/kdb-bot/src/modules/database/database_on_ready_event.py +++ b/kdb-bot/src/modules/database/database_on_ready_event.py @@ -20,6 +20,7 @@ from bot_data.model.server import Server 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.base.configuration.base_server_settings import BaseServerSettings @@ -30,6 +31,7 @@ class DatabaseOnReadyEvent(OnReadyABC): self, config: ConfigurationABC, logger: DatabaseLogger, + seeder: SeederService, bot: DiscordBotServiceABC, db_context: DatabaseContextABC, server_repo: ServerRepositoryABC, @@ -43,6 +45,7 @@ class DatabaseOnReadyEvent(OnReadyABC): self._config = config self._logger = logger + self._seeder = seeder self._bot = bot self._db_context = db_context self._servers = server_repo @@ -303,6 +306,8 @@ class DatabaseOnReadyEvent(OnReadyABC): async def on_ready(self): self._logger.debug(__name__, f'Module {type(self)} started') + await self._seeder.seed() + self._check_known_users() self._check_servers() self._check_clients() diff --git a/kdb-bot/src/modules/level/configuration/__init__.py b/kdb-bot/src/modules/level/configuration/__init__.py new file mode 100644 index 0000000000..425ab6c146 --- /dev/null +++ b/kdb-bot/src/modules/level/configuration/__init__.py @@ -0,0 +1 @@ +# imports diff --git a/kdb-bot/src/modules/level/configuration/level_settings.py b/kdb-bot/src/modules/level/configuration/level_settings.py new file mode 100644 index 0000000000..95dda2c862 --- /dev/null +++ b/kdb-bot/src/modules/level/configuration/level_settings.py @@ -0,0 +1,33 @@ +import traceback + +from cpl_core.configuration.configuration_model_abc import ConfigurationModelABC +from cpl_core.console import Console +from cpl_query.extension import List + +from bot_data.model.level import Level + + +class LevelSettings(ConfigurationModelABC): + + def __init__(self): + ConfigurationModelABC.__init__(self) + + self._levels = List(Level) + + @property + def levels(self) -> List[Level]: + return self._levels + + def from_dict(self, settings: dict): + try: + for level in settings: + self._levels.append(Level( + level['Name'], + level['Color'], + int(level['MinXp']), + int(level['Permissions']), + None + )) + except Exception as e: + Console.error(f'[ ERROR ] [ {__name__} ]: Reading error in {type(self).__name__} settings') + Console.error(f'[ EXCEPTION ] [ {__name__} ]: {e} -> {traceback.format_exc()}') diff --git a/kdb-bot/src/modules/level/default-level.json b/kdb-bot/src/modules/level/default-level.json new file mode 100644 index 0000000000..04cb874550 --- /dev/null +++ b/kdb-bot/src/modules/level/default-level.json @@ -0,0 +1,28 @@ +{ + "Level": [ + { + "Name": "Newbie", + "Color": "0x1abc9c", + "MinXp": 0, + "Permissions": 968552209984 + }, + { + "Name": "Keks", + "Color": "0x2ecc71", + "MinXp": 100, + "Permissions": 1002928856640 + }, + { + "Name": "Doppelkeks", + "Color": "0x3498db", + "MinXp": 200, + "Permissions": 1071849660224 + }, + { + "Name": "Auror", + "Color": "0xf1c40f", + "MinXp": 300, + "Permissions": 1089042120513 + } + ] +} \ No newline at end of file diff --git a/kdb-bot/src/modules/level/level_module.py b/kdb-bot/src/modules/level/level_module.py index dfdd9bdae3..565297436f 100644 --- a/kdb-bot/src/modules/level/level_module.py +++ b/kdb-bot/src/modules/level/level_module.py @@ -1,3 +1,5 @@ +import os + from cpl_core.configuration import ConfigurationABC from cpl_core.dependency_injection import ServiceCollectionABC from cpl_core.environment import ApplicationEnvironmentABC @@ -5,6 +7,7 @@ from cpl_discord.service.discord_collection_abc import DiscordCollectionABC from bot_core.abc.module_abc import ModuleABC from bot_core.configuration.feature_flags_enum import FeatureFlagsEnum +from modules.level.level_seeder import LevelSeeder class LevelModule(ModuleABC): @@ -13,7 +16,10 @@ class LevelModule(ModuleABC): ModuleABC.__init__(self, dc, FeatureFlagsEnum.level_module) def configure_configuration(self, config: ConfigurationABC, env: ApplicationEnvironmentABC): - pass + cwd = env.working_directory + env.set_working_directory(os.path.dirname(os.path.realpath(__file__))) + config.add_json_file(f'default-level.json', optional=False) + env.set_working_directory(cwd) - def configure_services(self, service: ServiceCollectionABC, env: ApplicationEnvironmentABC): - pass + def configure_services(self, services: ServiceCollectionABC, env: ApplicationEnvironmentABC): + services.add_transient(LevelSeeder) diff --git a/kdb-bot/src/modules/level/level_seeder.py b/kdb-bot/src/modules/level/level_seeder.py new file mode 100644 index 0000000000..a8bcd5db94 --- /dev/null +++ b/kdb-bot/src/modules/level/level_seeder.py @@ -0,0 +1,46 @@ +from cpl_discord.service import DiscordBotServiceABC +from discord import Permissions, Colour + +from bot_core.logging.database_logger import DatabaseLogger +from bot_data.abc.data_seeder_abc import DataSeederABC +from bot_data.abc.server_repository_abc import ServerRepositoryABC +from bot_data.service.level_repository_service import LevelRepositoryService +from modules.level.configuration.level_settings import LevelSettings + + +class LevelSeeder(DataSeederABC): + + def __init__(self, logger: DatabaseLogger, levels: LevelSettings, level_repo: LevelRepositoryService, servers: ServerRepositoryABC, bot: DiscordBotServiceABC): + DataSeederABC.__init__(self) + + self._logger = logger + self._default_levels = levels.levels.order_by_descending(lambda l: l.min_xp) + self._levels = level_repo + self._servers = servers + self._bot = bot + + async def seed(self): + if self._levels.get_levels().count() > 0: + return + + for guild in self._bot.guilds: + server = self._servers.find_server_by_discord_id(guild.id) + if server is None: + continue + + levels = self._levels.find_levels_by_server_id(server.server_id) + if levels is not None and levels.count() > 0: + continue + + for level in self._default_levels: + try: + if guild.roles.where(lambda r: r.name == level.name).count() == 0: + await guild.create_role(name=level.name, colour=Colour(int(level.color, 16)), hoist=False, mentionable=True, permissions=Permissions(level.permissions)) + + self._logger.info(__name__, f'Created default level {level.name}') + level.server = server + self._levels.add_level(level) + except Exception as e: + self._logger.error(__name__, f'Creating default role failed', e) + + self._logger.debug(__name__, f'Seeded default levels') From 861a84708824ecb7f641e857ecffcc86ef42a7b6 Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Sun, 6 Nov 2022 19:18:11 +0100 Subject: [PATCH 05/15] Improved logic to create roles for levels by default #25 --- .../bot/config/appsettings.edrafts-pc.json | 2 +- kdb-bot/src/modules/level/level_seeder.py | 67 +++++++++++++++---- 2 files changed, 56 insertions(+), 13 deletions(-) diff --git a/kdb-bot/src/bot/config/appsettings.edrafts-pc.json b/kdb-bot/src/bot/config/appsettings.edrafts-pc.json index 2e9e52a3d7..9deca01737 100644 --- a/kdb-bot/src/bot/config/appsettings.edrafts-pc.json +++ b/kdb-bot/src/bot/config/appsettings.edrafts-pc.json @@ -8,7 +8,7 @@ "LoggingSettings": { "Path": "logs/", "Filename": "bot.log", - "ConsoleLogLevel": "TRACE", + "ConsoleLogLevel": "DEBUG", "FileLogLevel": "TRACE" }, "BotLoggingSettings": { diff --git a/kdb-bot/src/modules/level/level_seeder.py b/kdb-bot/src/modules/level/level_seeder.py index a8bcd5db94..8193f47426 100644 --- a/kdb-bot/src/modules/level/level_seeder.py +++ b/kdb-bot/src/modules/level/level_seeder.py @@ -1,9 +1,13 @@ +from cpl_discord.container import Guild, Role from cpl_discord.service import DiscordBotServiceABC +from cpl_query.extension import List from discord import Permissions, Colour from bot_core.logging.database_logger import DatabaseLogger from bot_data.abc.data_seeder_abc import DataSeederABC from bot_data.abc.server_repository_abc import ServerRepositoryABC +from bot_data.model.level import Level +from bot_data.model.server import Server from bot_data.service.level_repository_service import LevelRepositoryService from modules.level.configuration.level_settings import LevelSettings @@ -19,8 +23,39 @@ class LevelSeeder(DataSeederABC): self._servers = servers self._bot = bot + async def _create_level(self, level: Level, guild: Guild, server: Server): + try: + if guild.roles.where(lambda r: r.name == level.name).count() != 0: + return + + await guild.create_role(name=level.name, colour=Colour(int(level.color, 16)), hoist=False, mentionable=True, permissions=Permissions(level.permissions)) + self._logger.info(__name__, f'Created level {level.name}') + level.server = server + self._levels.add_level(level) + except Exception as e: + self._logger.error(__name__, f'Creating level failed', e) + async def seed(self): - if self._levels.get_levels().count() > 0: + created_default = False + for guild in self._bot.guilds: + server = self._servers.find_server_by_discord_id(guild.id) + if server is None: + continue + + levels = self._levels.find_levels_by_server_id(server.server_id) + if levels is not None and levels.count() > 0: + for level in levels: + await self._create_level(level, guild, server) + + continue + + for level in self._default_levels: + created_default = True + await self._create_level(level, guild, server) + + self._logger.debug(__name__, f'Seeded default levels') + + if created_default: return for guild in self._bot.guilds: @@ -29,18 +64,26 @@ class LevelSeeder(DataSeederABC): continue levels = self._levels.find_levels_by_server_id(server.server_id) - if levels is not None and levels.count() > 0: - continue + roles: List[Role] = List(Role) + for role in guild.roles.order_by_descending(lambda r: r.position): + if levels.where(lambda l: l.name == role.name).count() == 0: + continue + + roles.append(role) + + levels = levels.order_by(lambda l: l.min_xp) + position_below_levels = roles.where(lambda r: r.name == levels.order_by(lambda l: l.min_xp).first().name).single().position - 1 + for role in roles: + new_position = position_below_levels + (levels.index(levels.where(lambda l: l.name == role.name).single()) - 1) + if new_position <= 0: + above_role: Role = roles.where(lambda r: r.position == 1).single() + await above_role.edit(position=above_role.position + 1) + new_position = 1 - for level in self._default_levels: try: - if guild.roles.where(lambda r: r.name == level.name).count() == 0: - await guild.create_role(name=level.name, colour=Colour(int(level.color, 16)), hoist=False, mentionable=True, permissions=Permissions(level.permissions)) - - self._logger.info(__name__, f'Created default level {level.name}') - level.server = server - self._levels.add_level(level) + self._logger.debug(__name__, f'Moved {role.name} from {role.position} to {new_position}') + await role.edit(position=new_position) except Exception as e: - self._logger.error(__name__, f'Creating default role failed', e) + self._logger.error(__name__, f'Cannot change position of {role.name}', e) - self._logger.debug(__name__, f'Seeded default levels') + self._logger.debug(__name__, f'Checked role order') From 8118d4edc3f68c86f84ca05d96a6d51df5073e5b Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Sun, 6 Nov 2022 19:36:15 +0100 Subject: [PATCH 06/15] Improved logic to create roles for levels by default #25 --- kdb-bot/src/modules/level/level_seeder.py | 46 ++++++++++------------- 1 file changed, 19 insertions(+), 27 deletions(-) diff --git a/kdb-bot/src/modules/level/level_seeder.py b/kdb-bot/src/modules/level/level_seeder.py index 8193f47426..e732912653 100644 --- a/kdb-bot/src/modules/level/level_seeder.py +++ b/kdb-bot/src/modules/level/level_seeder.py @@ -25,7 +25,7 @@ class LevelSeeder(DataSeederABC): async def _create_level(self, level: Level, guild: Guild, server: Server): try: - if guild.roles.where(lambda r: r.name == level.name).count() != 0: + if guild.roles.where(lambda r: r.name == level.name).count() > 0: return await guild.create_role(name=level.name, colour=Colour(int(level.color, 16)), hoist=False, mentionable=True, permissions=Permissions(level.permissions)) @@ -36,50 +36,42 @@ class LevelSeeder(DataSeederABC): self._logger.error(__name__, f'Creating level failed', e) async def seed(self): - created_default = False + # create levels for guild in self._bot.guilds: + created_default = False + if guild.roles.where(lambda r: r.name == '___ Level ___').count() == 0: + await guild.create_role(name='___ Level ___') + server = self._servers.find_server_by_discord_id(guild.id) if server is None: continue levels = self._levels.find_levels_by_server_id(server.server_id) if levels is not None and levels.count() > 0: + # create levels from db for level in levels: await self._create_level(level, guild, server) + self._logger.debug(__name__, f'Seeded levels') + else: + # create default levels + for level in self._default_levels: + created_default = True + await self._create_level(level, guild, server) + + self._logger.debug(__name__, f'Seeded default levels') + + if created_default: continue - for level in self._default_levels: - created_default = True - await self._create_level(level, guild, server) - - self._logger.debug(__name__, f'Seeded default levels') - - if created_default: - return - - for guild in self._bot.guilds: - server = self._servers.find_server_by_discord_id(guild.id) - if server is None: - continue - - levels = self._levels.find_levels_by_server_id(server.server_id) - roles: List[Role] = List(Role) + position_above_levels = guild.roles.where(lambda r: r.name == '~~~ Level ~~~').single().position for role in guild.roles.order_by_descending(lambda r: r.position): if levels.where(lambda l: l.name == role.name).count() == 0: continue - roles.append(role) - - levels = levels.order_by(lambda l: l.min_xp) - position_below_levels = roles.where(lambda r: r.name == levels.order_by(lambda l: l.min_xp).first().name).single().position - 1 - for role in roles: - new_position = position_below_levels + (levels.index(levels.where(lambda l: l.name == role.name).single()) - 1) + new_position = position_above_levels - (levels.index(levels.where(lambda l: l.name == role.name).single()) + 1) if new_position <= 0: - above_role: Role = roles.where(lambda r: r.position == 1).single() - await above_role.edit(position=above_role.position + 1) new_position = 1 - try: self._logger.debug(__name__, f'Moved {role.name} from {role.position} to {new_position}') await role.edit(position=new_position) From 8aee72856c31d35e3d6522a423914360b13a9c43 Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Sun, 6 Nov 2022 19:51:43 +0100 Subject: [PATCH 07/15] Added level service #25 --- kdb-bot/src/modules/level/level_module.py | 2 + kdb-bot/src/modules/level/service/__init__.py | 1 + .../modules/level/service/level_service.py | 53 +++++++++++++++++++ 3 files changed, 56 insertions(+) create mode 100644 kdb-bot/src/modules/level/service/__init__.py create mode 100644 kdb-bot/src/modules/level/service/level_service.py diff --git a/kdb-bot/src/modules/level/level_module.py b/kdb-bot/src/modules/level/level_module.py index 565297436f..760544babf 100644 --- a/kdb-bot/src/modules/level/level_module.py +++ b/kdb-bot/src/modules/level/level_module.py @@ -8,6 +8,7 @@ from cpl_discord.service.discord_collection_abc import DiscordCollectionABC from bot_core.abc.module_abc import ModuleABC from bot_core.configuration.feature_flags_enum import FeatureFlagsEnum from modules.level.level_seeder import LevelSeeder +from modules.level.service.level_service import LevelService class LevelModule(ModuleABC): @@ -23,3 +24,4 @@ class LevelModule(ModuleABC): def configure_services(self, services: ServiceCollectionABC, env: ApplicationEnvironmentABC): services.add_transient(LevelSeeder) + services.add_transient(LevelService) diff --git a/kdb-bot/src/modules/level/service/__init__.py b/kdb-bot/src/modules/level/service/__init__.py new file mode 100644 index 0000000000..425ab6c146 --- /dev/null +++ b/kdb-bot/src/modules/level/service/__init__.py @@ -0,0 +1 @@ +# imports diff --git a/kdb-bot/src/modules/level/service/level_service.py b/kdb-bot/src/modules/level/service/level_service.py new file mode 100644 index 0000000000..b3d2f664f4 --- /dev/null +++ b/kdb-bot/src/modules/level/service/level_service.py @@ -0,0 +1,53 @@ +from cpl_core.database.context import DatabaseContextABC +from cpl_core.logging import LoggerABC +from cpl_discord.container import Guild, Role, Member +from cpl_discord.service import DiscordBotServiceABC + +from bot_data.model.level import Level +from bot_data.model.user import User +from bot_data.service.level_repository_service import LevelRepositoryService +from bot_data.service.user_repository_service import UserRepositoryService + + +class LevelService: + + def __init__( + self, + logger: LoggerABC, + db: DatabaseContextABC, + levels: LevelRepositoryService, + users: UserRepositoryService, + bot: DiscordBotServiceABC + ): + self._logger = logger + self._db = db + self._levels = levels + self._users = users + self._bot = bot + + def get_level(self, user: User) -> Level: + levels = self._levels.get_levels_by_server_id(user.server.server_id).order_by(lambda l: l.min_xp) + return levels.where(lambda l: l.min_xp > user.xp).first() + + async def set_level(self, user: User): + level_names = self._levels.get_levels_by_server_id(user.server.server_id).select(lambda l: l.name) + guild: Guild = self._bot.guilds.where(lambda g: g.id == user.server.discord_server_id).single() + level_role: Role = guild.roles.where(lambda r: r.name == self.get_level(user).name).single() + member: Member = guild.members.where(lambda m: m.id == user.discord_id).single() + for role in member.roles: + if role.name not in level_names.to_list(): + continue + + try: + self._logger.debug(__name__, f'Try to remove role {role.name} from {member.name}') + await member.remove_roles(role) + self._logger.info(__name__, f'Removed role {role.name} from {member.name}') + except Exception as e: + self._logger.error(__name__, f'Removing role {role.name} from {member.name} failed!', e) + + try: + self._logger.debug(__name__, f'Try to add role {level_role.name} to {member.name}') + await member.add_roles(level_role) + self._logger.info(__name__, f'Add role {level_role.name} to {member.name}') + except Exception as e: + self._logger.error(__name__, f'Adding role {level_role.name} to {member.name} failed!', e) From 164671a07c2391f2cc560e1ecc400ae44ef734d2 Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Sun, 6 Nov 2022 21:34:58 +0100 Subject: [PATCH 08/15] Added logic to handle level by xp #25 --- .../service/level_repository_service.py | 2 +- .../level/configuration/level_settings.py | 8 ++- kdb-bot/src/modules/level/default-level.json | 55 ++++++++++--------- kdb-bot/src/modules/level/events/__init__.py | 26 +++++++++ .../level/events/level_on_message_event.py | 21 +++++++ .../level_on_voice_state_update_event.py | 23 ++++++++ kdb-bot/src/modules/level/level_module.py | 6 ++ kdb-bot/src/modules/level/level_seeder.py | 12 ++-- .../modules/level/service/level_service.py | 19 ++++++- 9 files changed, 138 insertions(+), 34 deletions(-) create mode 100644 kdb-bot/src/modules/level/events/__init__.py create mode 100644 kdb-bot/src/modules/level/events/level_on_message_event.py create mode 100644 kdb-bot/src/modules/level/events/level_on_voice_state_update_event.py diff --git a/kdb-bot/src/bot_data/service/level_repository_service.py b/kdb-bot/src/bot_data/service/level_repository_service.py index 37ee595298..3e41fc1b4b 100644 --- a/kdb-bot/src/bot_data/service/level_repository_service.py +++ b/kdb-bot/src/bot_data/service/level_repository_service.py @@ -63,7 +63,7 @@ class LevelRepositoryService(LevelRepositoryABC): def get_levels_by_server_id(self, server_id: int) -> List[Level]: levels = List(Level) self._logger.trace(__name__, f'Send SQL command: {Level.get_select_by_server_id_string(server_id)}') - results = self._context.select(Level.get_select_by_server_id_string(server_id))[0] + results = self._context.select(Level.get_select_by_server_id_string(server_id)) for result in results: self._logger.trace(__name__, f'Get level with id {result[0]}') diff --git a/kdb-bot/src/modules/level/configuration/level_settings.py b/kdb-bot/src/modules/level/configuration/level_settings.py index 95dda2c862..6f38e31b1a 100644 --- a/kdb-bot/src/modules/level/configuration/level_settings.py +++ b/kdb-bot/src/modules/level/configuration/level_settings.py @@ -13,14 +13,20 @@ class LevelSettings(ConfigurationModelABC): ConfigurationModelABC.__init__(self) self._levels = List(Level) + self._level_header = '' @property def levels(self) -> List[Level]: return self._levels + @property + def level_header(self) -> str: + return self._level_header + def from_dict(self, settings: dict): try: - for level in settings: + self._level_header = settings['LevelHeader'] + for level in settings['Levels']: self._levels.append(Level( level['Name'], level['Color'], diff --git a/kdb-bot/src/modules/level/default-level.json b/kdb-bot/src/modules/level/default-level.json index 04cb874550..451e7544cd 100644 --- a/kdb-bot/src/modules/level/default-level.json +++ b/kdb-bot/src/modules/level/default-level.json @@ -1,28 +1,31 @@ { - "Level": [ - { - "Name": "Newbie", - "Color": "0x1abc9c", - "MinXp": 0, - "Permissions": 968552209984 - }, - { - "Name": "Keks", - "Color": "0x2ecc71", - "MinXp": 100, - "Permissions": 1002928856640 - }, - { - "Name": "Doppelkeks", - "Color": "0x3498db", - "MinXp": 200, - "Permissions": 1071849660224 - }, - { - "Name": "Auror", - "Color": "0xf1c40f", - "MinXp": 300, - "Permissions": 1089042120513 - } - ] + "Level": { + "LevelHeader": "~~~ Level ~~~", + "Levels": [ + { + "Name": "Newbie", + "Color": "0x1abc9c", + "MinXp": 0, + "Permissions": 968552209984 + }, + { + "Name": "Keks", + "Color": "0x2ecc71", + "MinXp": 100, + "Permissions": 1002928856640 + }, + { + "Name": "Doppelkeks", + "Color": "0x3498db", + "MinXp": 200, + "Permissions": 1071849660224 + }, + { + "Name": "Auror", + "Color": "0xf1c40f", + "MinXp": 300, + "Permissions": 1089042120513 + } + ] + } } \ No newline at end of file diff --git a/kdb-bot/src/modules/level/events/__init__.py b/kdb-bot/src/modules/level/events/__init__.py new file mode 100644 index 0000000000..85e09931a0 --- /dev/null +++ b/kdb-bot/src/modules/level/events/__init__.py @@ -0,0 +1,26 @@ +# -*- coding: utf-8 -*- + +""" +bot Keksdose bot +~~~~~~~~~~~~~~~~~~~ + +Discord bot for the Keksdose discord Server + +:copyright: (c) 2022 sh-edraft.de +:license: MIT, see LICENSE for more details. + +""" + +__title__ = 'modules.base.events' +__author__ = 'Sven Heidemann' +__license__ = 'MIT' +__copyright__ = 'Copyright (c) 2022 sh-edraft.de' +__version__ = '0.3.dev70' + +from collections import namedtuple + + +# imports: + +VersionInfo = namedtuple('VersionInfo', 'major minor micro') +version_info = VersionInfo(major='0', minor='3', micro='dev70') diff --git a/kdb-bot/src/modules/level/events/level_on_message_event.py b/kdb-bot/src/modules/level/events/level_on_message_event.py new file mode 100644 index 0000000000..cd69622e07 --- /dev/null +++ b/kdb-bot/src/modules/level/events/level_on_message_event.py @@ -0,0 +1,21 @@ +import discord +from cpl_discord.events import OnMessageABC + +from bot_core.logging.message_logger import MessageLogger +from modules.level.service.level_service import LevelService + + +class LevelOnMessageEvent(OnMessageABC): + + def __init__( + self, + logger: MessageLogger, + level: LevelService + ): + OnMessageABC.__init__(self) + self._logger = logger + self._level = level + + async def on_message(self, message: discord.Message): + self._logger.debug(__name__, f'Module {type(self)} started') + await self._level.check_level(message.author) diff --git a/kdb-bot/src/modules/level/events/level_on_voice_state_update_event.py b/kdb-bot/src/modules/level/events/level_on_voice_state_update_event.py new file mode 100644 index 0000000000..c9127e0376 --- /dev/null +++ b/kdb-bot/src/modules/level/events/level_on_voice_state_update_event.py @@ -0,0 +1,23 @@ +import discord +from cpl_core.logging import LoggerABC +from cpl_discord.events import OnVoiceStateUpdateABC + +from modules.level.service.level_service import LevelService + + +class LevelOnVoiceStateUpdateEvent(OnVoiceStateUpdateABC): + + def __init__( + self, + logger: LoggerABC, + level: LevelService + ): + OnVoiceStateUpdateABC.__init__(self) + self._logger = logger + self._level = level + + self._logger.info(__name__, f'Module {type(self)} loaded') + + async def on_voice_state_update(self, member: discord.Member, before: discord.VoiceState, after: discord.VoiceState): + self._logger.debug(__name__, f'Module {type(self)} started') + await self._level.check_level(member) diff --git a/kdb-bot/src/modules/level/level_module.py b/kdb-bot/src/modules/level/level_module.py index 760544babf..1943e73cf4 100644 --- a/kdb-bot/src/modules/level/level_module.py +++ b/kdb-bot/src/modules/level/level_module.py @@ -3,10 +3,13 @@ import os 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 modules.level.events.level_on_message_event import LevelOnMessageEvent +from modules.level.events.level_on_voice_state_update_event import LevelOnVoiceStateUpdateEvent from modules.level.level_seeder import LevelSeeder from modules.level.service.level_service import LevelService @@ -25,3 +28,6 @@ class LevelModule(ModuleABC): def configure_services(self, services: ServiceCollectionABC, env: ApplicationEnvironmentABC): services.add_transient(LevelSeeder) services.add_transient(LevelService) + + self._dc.add_event(DiscordEventTypesEnum.on_message.value, LevelOnMessageEvent) + self._dc.add_event(DiscordEventTypesEnum.on_voice_state_update.value, LevelOnVoiceStateUpdateEvent) diff --git a/kdb-bot/src/modules/level/level_seeder.py b/kdb-bot/src/modules/level/level_seeder.py index e732912653..377bfd2a6d 100644 --- a/kdb-bot/src/modules/level/level_seeder.py +++ b/kdb-bot/src/modules/level/level_seeder.py @@ -18,14 +18,16 @@ class LevelSeeder(DataSeederABC): DataSeederABC.__init__(self) self._logger = logger - self._default_levels = levels.levels.order_by_descending(lambda l: l.min_xp) self._levels = level_repo self._servers = servers self._bot = bot + self._level_header = levels.level_header + self._default_levels = levels.levels.order_by_descending(lambda l: l.min_xp) + async def _create_level(self, level: Level, guild: Guild, server: Server): try: - if guild.roles.where(lambda r: r.name == level.name).count() > 0: + if guild.roles.where(lambda r: r.name == level.name).first_or_default() is not None: return await guild.create_role(name=level.name, colour=Colour(int(level.color, 16)), hoist=False, mentionable=True, permissions=Permissions(level.permissions)) @@ -39,8 +41,8 @@ class LevelSeeder(DataSeederABC): # create levels for guild in self._bot.guilds: created_default = False - if guild.roles.where(lambda r: r.name == '___ Level ___').count() == 0: - await guild.create_role(name='___ Level ___') + if guild.roles.where(lambda r: r.name == self._level_header).first_or_default() is None: + await guild.create_role(name=self._level_header) server = self._servers.find_server_by_discord_id(guild.id) if server is None: @@ -64,7 +66,7 @@ class LevelSeeder(DataSeederABC): if created_default: continue - position_above_levels = guild.roles.where(lambda r: r.name == '~~~ Level ~~~').single().position + position_above_levels = guild.roles.where(lambda r: r.name == self._level_header).single().position for role in guild.roles.order_by_descending(lambda r: r.position): if levels.where(lambda l: l.name == role.name).count() == 0: continue diff --git a/kdb-bot/src/modules/level/service/level_service.py b/kdb-bot/src/modules/level/service/level_service.py index b3d2f664f4..95fbcae623 100644 --- a/kdb-bot/src/modules/level/service/level_service.py +++ b/kdb-bot/src/modules/level/service/level_service.py @@ -1,3 +1,4 @@ +import discord from cpl_core.database.context import DatabaseContextABC from cpl_core.logging import LoggerABC from cpl_discord.container import Guild, Role, Member @@ -6,6 +7,7 @@ from cpl_discord.service import DiscordBotServiceABC from bot_data.model.level import Level from bot_data.model.user import User from bot_data.service.level_repository_service import LevelRepositoryService +from bot_data.service.server_repository_service import ServerRepositoryService from bot_data.service.user_repository_service import UserRepositoryService @@ -17,17 +19,19 @@ class LevelService: db: DatabaseContextABC, levels: LevelRepositoryService, users: UserRepositoryService, + servers: ServerRepositoryService, bot: DiscordBotServiceABC ): self._logger = logger self._db = db self._levels = levels self._users = users + self._servers = servers self._bot = bot def get_level(self, user: User) -> Level: levels = self._levels.get_levels_by_server_id(user.server.server_id).order_by(lambda l: l.min_xp) - return levels.where(lambda l: l.min_xp > user.xp).first() + return levels.where(lambda l: user.xp >= l.min_xp).first() async def set_level(self, user: User): level_names = self._levels.get_levels_by_server_id(user.server.server_id).select(lambda l: l.name) @@ -45,9 +49,22 @@ class LevelService: except Exception as e: self._logger.error(__name__, f'Removing role {role.name} from {member.name} failed!', e) + if level_role in member.roles: + return try: self._logger.debug(__name__, f'Try to add role {level_role.name} to {member.name}') await member.add_roles(level_role) self._logger.info(__name__, f'Add role {level_role.name} to {member.name}') except Exception as e: self._logger.error(__name__, f'Adding role {level_role.name} to {member.name} failed!', e) + + async def check_level(self, member: discord.Member): + if member.bot: + return + + server = self._servers.get_server_by_discord_id(member.guild.id) + user = self._users.find_user_by_discord_id_and_server_id(member.id, server.server_id) + if user is None: + self._logger.warn(__name__, f'User not found {member.guild.name}@{member.name}') + + await self.set_level(user) From 6e39154c75a908e285dcd306d03308c57f3e52e4 Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Sun, 6 Nov 2022 21:54:21 +0100 Subject: [PATCH 09/15] Fixed level assignment #25 --- kdb-bot/src/modules/level/service/level_service.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/kdb-bot/src/modules/level/service/level_service.py b/kdb-bot/src/modules/level/service/level_service.py index 95fbcae623..292d548aad 100644 --- a/kdb-bot/src/modules/level/service/level_service.py +++ b/kdb-bot/src/modules/level/service/level_service.py @@ -1,3 +1,5 @@ +import asyncio + import discord from cpl_core.database.context import DatabaseContextABC from cpl_core.logging import LoggerABC @@ -31,12 +33,11 @@ class LevelService: def get_level(self, user: User) -> Level: levels = self._levels.get_levels_by_server_id(user.server.server_id).order_by(lambda l: l.min_xp) - return levels.where(lambda l: user.xp >= l.min_xp).first() + return levels.where(lambda l: user.xp >= l.min_xp).last() async def set_level(self, user: User): level_names = self._levels.get_levels_by_server_id(user.server.server_id).select(lambda l: l.name) guild: Guild = self._bot.guilds.where(lambda g: g.id == user.server.discord_server_id).single() - level_role: Role = guild.roles.where(lambda r: r.name == self.get_level(user).name).single() member: Member = guild.members.where(lambda m: m.id == user.discord_id).single() for role in member.roles: if role.name not in level_names.to_list(): @@ -49,6 +50,7 @@ class LevelService: except Exception as e: self._logger.error(__name__, f'Removing role {role.name} from {member.name} failed!', e) + level_role: Role = guild.roles.where(lambda r: r.name == self.get_level(user).name).single() if level_role in member.roles: return try: From 6640d70440e3dc759f1f8745c427ef5b15a630a8 Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Sun, 6 Nov 2022 22:17:17 +0100 Subject: [PATCH 10/15] Added logic to send message after level up #25 --- .../bot/config/appsettings.edrafts-pc.json | 7 +++- kdb-bot/src/bot/startup_settings_extension.py | 2 + .../src/bot_core/service/message_service.py | 9 ++++- .../configuration/default_level_settings.py | 39 +++++++++++++++++++ .../configuration/level_server_settings.py | 29 ++++++++++++++ .../level/configuration/level_settings.py | 29 ++++++-------- kdb-bot/src/modules/level/default-level.json | 2 +- kdb-bot/src/modules/level/level_seeder.py | 4 +- .../modules/level/service/level_service.py | 25 ++++++++++-- 9 files changed, 119 insertions(+), 27 deletions(-) create mode 100644 kdb-bot/src/modules/level/configuration/default_level_settings.py create mode 100644 kdb-bot/src/modules/level/configuration/level_server_settings.py diff --git a/kdb-bot/src/bot/config/appsettings.edrafts-pc.json b/kdb-bot/src/bot/config/appsettings.edrafts-pc.json index 9deca01737..eca8346df9 100644 --- a/kdb-bot/src/bot/config/appsettings.edrafts-pc.json +++ b/kdb-bot/src/bot/config/appsettings.edrafts-pc.json @@ -76,7 +76,12 @@ }, "BootLog": { "910199451145076828": { - "LoginMessageChannelId": "910199452915093588" + "LoginMessageChannelId": 910199452667637892 + } + }, + "Level": { + "910199451145076828": { + "ChangedLevelNotificationChannelId": 910199452915093588 } }, "Permission": { diff --git a/kdb-bot/src/bot/startup_settings_extension.py b/kdb-bot/src/bot/startup_settings_extension.py index 4dcee8bf4d..655ccd7b6c 100644 --- a/kdb-bot/src/bot/startup_settings_extension.py +++ b/kdb-bot/src/bot/startup_settings_extension.py @@ -11,6 +11,7 @@ from bot_core.configuration.bot_logging_settings import BotLoggingSettings from bot_core.configuration.bot_settings import BotSettings from modules.base.configuration.base_settings import BaseSettings from modules.boot_log.configuration.boot_log_settings import BootLogSettings +from modules.level.configuration.level_settings import LevelSettings from modules.permission.configuration.permission_settings import PermissionSettings @@ -35,6 +36,7 @@ class StartupSettingsExtension(StartupExtensionABC): self._configure_settings_with_sub_settings(configuration, BotSettings, lambda x: x.servers, lambda x: x.id) self._configure_settings_with_sub_settings(configuration, BaseSettings, lambda x: x.servers, lambda x: x.id) self._configure_settings_with_sub_settings(configuration, BootLogSettings, lambda x: x.servers, lambda x: x.id) + self._configure_settings_with_sub_settings(configuration, LevelSettings, lambda x: x.servers, lambda x: x.id) self._configure_settings_with_sub_settings(configuration, PermissionSettings, lambda x: x.servers, lambda x: x.id) self._configure_settings_with_sub_settings(configuration, BotLoggingSettings, lambda x: x.files, lambda x: x.key) diff --git a/kdb-bot/src/bot_core/service/message_service.py b/kdb-bot/src/bot_core/service/message_service.py index 7094236d8b..6a43f32cc6 100644 --- a/kdb-bot/src/bot_core/service/message_service.py +++ b/kdb-bot/src/bot_core/service/message_service.py @@ -49,7 +49,7 @@ class MessageService(MessageServiceABC): self._db.save_changes() self._logger.info(__name__, f'Deleted message {message}') - async def send_channel_message(self, channel: discord.TextChannel, message: Union[str, discord.Embed], without_tracking=False): + async def send_channel_message(self, channel: discord.TextChannel, message: Union[str, discord.Embed], is_persistent: bool = False, wait_before_delete: int = None, without_tracking=False): self._logger.debug(__name__, f'Try to send message\n\t{message}\n\tto: {channel}') msg = None try: @@ -64,6 +64,13 @@ class MessageService(MessageServiceABC): if not without_tracking: self._clients.append_sent_message_count(self._bot.user.id, channel.guild.id, 1) self._db.save_changes() + + if wait_before_delete is not None: + await asyncio.sleep(wait_before_delete) + + if is_persistent: + return + await self.delete_message(msg, without_tracking) async def send_dm_message(self, message: Union[str, discord.Embed], receiver: Union[discord.User, discord.Member], without_tracking=False): diff --git a/kdb-bot/src/modules/level/configuration/default_level_settings.py b/kdb-bot/src/modules/level/configuration/default_level_settings.py new file mode 100644 index 0000000000..3687ab83a9 --- /dev/null +++ b/kdb-bot/src/modules/level/configuration/default_level_settings.py @@ -0,0 +1,39 @@ +import traceback + +from cpl_core.configuration.configuration_model_abc import ConfigurationModelABC +from cpl_core.console import Console +from cpl_query.extension import List + +from bot_data.model.level import Level + + +class DefaultLevelSettings(ConfigurationModelABC): + + def __init__(self): + ConfigurationModelABC.__init__(self) + + self._levels = List(Level) + self._level_header = '' + + @property + def levels(self) -> List[Level]: + return self._levels + + @property + def level_header(self) -> str: + return self._level_header + + def from_dict(self, settings: dict): + try: + self._level_header = settings['LevelHeader'] + for level in settings['Levels']: + self._levels.append(Level( + level['Name'], + level['Color'], + int(level['MinXp']), + int(level['Permissions']), + None + )) + except Exception as e: + Console.error(f'[ ERROR ] [ {__name__} ]: Reading error in {type(self).__name__} settings') + Console.error(f'[ EXCEPTION ] [ {__name__} ]: {e} -> {traceback.format_exc()}') diff --git a/kdb-bot/src/modules/level/configuration/level_server_settings.py b/kdb-bot/src/modules/level/configuration/level_server_settings.py new file mode 100644 index 0000000000..85985cffc3 --- /dev/null +++ b/kdb-bot/src/modules/level/configuration/level_server_settings.py @@ -0,0 +1,29 @@ +import traceback + +from cpl_core.configuration.configuration_model_abc import ConfigurationModelABC +from cpl_core.console import Console + + +class LevelServerSettings(ConfigurationModelABC): + + def __init__(self): + ConfigurationModelABC.__init__(self) + + self._id: int = 0 + self._changed_level_notification_channel = 0 + + @property + def id(self) -> int: + return self._id + + @property + def changed_level_notification_channel(self) -> int: + return self._changed_level_notification_channel + + def from_dict(self, settings: dict): + try: + self._id = int(settings['Id']) + self._changed_level_notification_channel = int(settings['ChangedLevelNotificationChannelId']) + except Exception as e: + Console.error(f'[ ERROR ] [ {__name__} ]: Reading error in {type(self).__name__} settings') + Console.error(f'[ EXCEPTION ] [ {__name__} ]: {e} -> {traceback.format_exc()}') diff --git a/kdb-bot/src/modules/level/configuration/level_settings.py b/kdb-bot/src/modules/level/configuration/level_settings.py index 6f38e31b1a..7962941ca0 100644 --- a/kdb-bot/src/modules/level/configuration/level_settings.py +++ b/kdb-bot/src/modules/level/configuration/level_settings.py @@ -4,7 +4,7 @@ from cpl_core.configuration.configuration_model_abc import ConfigurationModelABC from cpl_core.console import Console from cpl_query.extension import List -from bot_data.model.level import Level +from modules.level.configuration.level_server_settings import LevelServerSettings class LevelSettings(ConfigurationModelABC): @@ -12,28 +12,21 @@ class LevelSettings(ConfigurationModelABC): def __init__(self): ConfigurationModelABC.__init__(self) - self._levels = List(Level) - self._level_header = '' + self._servers: List[LevelServerSettings] = List() @property - def levels(self) -> List[Level]: - return self._levels - - @property - def level_header(self) -> str: - return self._level_header + def servers(self) -> List[LevelServerSettings]: + return self._servers def from_dict(self, settings: dict): try: - self._level_header = settings['LevelHeader'] - for level in settings['Levels']: - self._levels.append(Level( - level['Name'], - level['Color'], - int(level['MinXp']), - int(level['Permissions']), - None - )) + servers = List(LevelServerSettings) + for s in settings: + st = LevelServerSettings() + settings[s]['Id'] = s + st.from_dict(settings[s]) + servers.append(st) + self._servers = servers except Exception as e: Console.error(f'[ ERROR ] [ {__name__} ]: Reading error in {type(self).__name__} settings') Console.error(f'[ EXCEPTION ] [ {__name__} ]: {e} -> {traceback.format_exc()}') diff --git a/kdb-bot/src/modules/level/default-level.json b/kdb-bot/src/modules/level/default-level.json index 451e7544cd..047b811a28 100644 --- a/kdb-bot/src/modules/level/default-level.json +++ b/kdb-bot/src/modules/level/default-level.json @@ -1,5 +1,5 @@ { - "Level": { + "DefaultLevel": { "LevelHeader": "~~~ Level ~~~", "Levels": [ { diff --git a/kdb-bot/src/modules/level/level_seeder.py b/kdb-bot/src/modules/level/level_seeder.py index 377bfd2a6d..9a1148bb49 100644 --- a/kdb-bot/src/modules/level/level_seeder.py +++ b/kdb-bot/src/modules/level/level_seeder.py @@ -9,12 +9,12 @@ from bot_data.abc.server_repository_abc import ServerRepositoryABC from bot_data.model.level import Level from bot_data.model.server import Server from bot_data.service.level_repository_service import LevelRepositoryService -from modules.level.configuration.level_settings import LevelSettings +from modules.level.configuration.default_level_settings import DefaultLevelSettings class LevelSeeder(DataSeederABC): - def __init__(self, logger: DatabaseLogger, levels: LevelSettings, level_repo: LevelRepositoryService, servers: ServerRepositoryABC, bot: DiscordBotServiceABC): + def __init__(self, logger: DatabaseLogger, levels: DefaultLevelSettings, level_repo: LevelRepositoryService, servers: ServerRepositoryABC, bot: DiscordBotServiceABC): DataSeederABC.__init__(self) self._logger = logger diff --git a/kdb-bot/src/modules/level/service/level_service.py b/kdb-bot/src/modules/level/service/level_service.py index 292d548aad..6385b9ae67 100644 --- a/kdb-bot/src/modules/level/service/level_service.py +++ b/kdb-bot/src/modules/level/service/level_service.py @@ -1,35 +1,42 @@ import asyncio import discord +from cpl_core.configuration import ConfigurationABC from cpl_core.database.context import DatabaseContextABC from cpl_core.logging import LoggerABC from cpl_discord.container import Guild, Role, Member from cpl_discord.service import DiscordBotServiceABC +from bot_core.service.message_service import MessageService from bot_data.model.level import Level from bot_data.model.user import User from bot_data.service.level_repository_service import LevelRepositoryService from bot_data.service.server_repository_service import ServerRepositoryService from bot_data.service.user_repository_service import UserRepositoryService +from modules.level.configuration.level_server_settings import LevelServerSettings class LevelService: def __init__( self, + config: ConfigurationABC, logger: LoggerABC, db: DatabaseContextABC, levels: LevelRepositoryService, users: UserRepositoryService, servers: ServerRepositoryService, - bot: DiscordBotServiceABC + bot: DiscordBotServiceABC, + message_service: MessageService ): + self._config = config self._logger = logger self._db = db self._levels = levels self._users = users self._servers = servers self._bot = bot + self._message_service = message_service def get_level(self, user: User) -> Level: levels = self._levels.get_levels_by_server_id(user.server.server_id).order_by(lambda l: l.min_xp) @@ -39,6 +46,12 @@ class LevelService: level_names = self._levels.get_levels_by_server_id(user.server.server_id).select(lambda l: l.name) guild: Guild = self._bot.guilds.where(lambda g: g.id == user.server.discord_server_id).single() member: Member = guild.members.where(lambda m: m.id == user.discord_id).single() + + level = self.get_level(user) + level_role: Role = guild.roles.where(lambda r: r.name == level.name).single() + if level_role in member.roles: + return + for role in member.roles: if role.name not in level_names.to_list(): continue @@ -50,9 +63,6 @@ class LevelService: except Exception as e: self._logger.error(__name__, f'Removing role {role.name} from {member.name} failed!', e) - level_role: Role = guild.roles.where(lambda r: r.name == self.get_level(user).name).single() - if level_role in member.roles: - return try: self._logger.debug(__name__, f'Try to add role {level_role.name} to {member.name}') await member.add_roles(level_role) @@ -60,6 +70,13 @@ class LevelService: except Exception as e: self._logger.error(__name__, f'Adding role {level_role.name} to {member.name} failed!', e) + level_settings: LevelServerSettings = self._config.get_configuration(f'LevelServerSettings_{guild.id}') + await self._message_service.send_channel_message( + self._bot.get_channel(level_settings.changed_level_notification_channel), + f'<@{member.id}> ist nun Level {level.name}', + is_persistent=True + ) + async def check_level(self, member: discord.Member): if member.bot: return From 23fde793db28a4d8aef3c413bc70de91c8de4ad0 Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Sun, 6 Nov 2022 22:19:41 +0100 Subject: [PATCH 11/15] Fixed my config #25 --- kdb-bot/src/bot/config/appsettings.edrafts-pc.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kdb-bot/src/bot/config/appsettings.edrafts-pc.json b/kdb-bot/src/bot/config/appsettings.edrafts-pc.json index eca8346df9..e912b14863 100644 --- a/kdb-bot/src/bot/config/appsettings.edrafts-pc.json +++ b/kdb-bot/src/bot/config/appsettings.edrafts-pc.json @@ -76,12 +76,12 @@ }, "BootLog": { "910199451145076828": { - "LoginMessageChannelId": 910199452667637892 + "LoginMessageChannelId": 910199452915093588 } }, "Level": { "910199451145076828": { - "ChangedLevelNotificationChannelId": 910199452915093588 + "ChangedLevelNotificationChannelId": 910199452667637892 } }, "Permission": { From dc90258a282bceb1ef3567e5a52ce0129fa18d11 Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Sun, 6 Nov 2022 22:30:57 +0100 Subject: [PATCH 12/15] "Repaired" workspace file #25 --- kdb-bot/cpl-workspace.json | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/kdb-bot/cpl-workspace.json b/kdb-bot/cpl-workspace.json index 37a8b6c688..7af45bfebe 100644 --- a/kdb-bot/cpl-workspace.json +++ b/kdb-bot/cpl-workspace.json @@ -10,27 +10,33 @@ "base": "src/modules/base/base.json", "boot-log": "src/modules/boot_log/boot-log.json", "database": "src/modules/database/database.json", + "level": "src/modules/level/level.json", "moderator": "src/modules/moderator/moderator.json", "permission": "src/modules/permission/permission.json", "bot-api": "src/bot_api/bot-api.json", "get-version": "tools/get_version/get-version.json", "post-build": "tools/post_build/post-build.json", - "set-version": "tools/set_version/set-version.json", - "level": "src/modules/level/level.json" + "set-version": "tools/set_version/set-version.json" }, "Scripts": { "sv": "cpl set-version", "set-version": "cpl run set-version $ARGS; echo '';", + "gv": "cpl get-version", "get-version": "export VERSION=$(cpl run get-version); echo $VERSION;", + "pre-build": "cpl set-version $ARGS", "post-build": "cpl run post-build", + "pre-prod": "cpl build", "prod": "export KDB_ENVIRONMENT=production; export KDB_NAME=KDB-Prod; cpl start;", + "pre-stage": "cpl build", "stage": "export KDB_ENVIRONMENT=staging; export KDB_NAME=KDB-Stage; cpl start;", + "pre-dev": "cpl build", "dev": "export KDB_ENVIRONMENT=development; export KDB_NAME=KDB-Dev; cpl start;", + "docker-build": "cpl b; docker-compose down; docker build -t kdb-bot/kdb-bot:$(cpl gv) .", "docker-compose": "docker-compose up -d", "docker": "cpl docker-build; cpl docker-compose;" From 1b587b049a34eb992347a97b181ae5eccd9c9016 Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Sun, 6 Nov 2022 22:40:30 +0100 Subject: [PATCH 13/15] Build files #25 --- kdb-bot/src/bot/__init__.py | 4 +-- kdb-bot/src/bot/bot.json | 3 ++- kdb-bot/src/bot_api/__init__.py | 4 +-- kdb-bot/src/bot_api/abc/__init__.py | 4 +-- kdb-bot/src/bot_api/configuration/__init__.py | 4 +-- kdb-bot/src/bot_api/controller/__init__.py | 4 +-- .../bot_api/controller/discord/__init__.py | 4 +-- kdb-bot/src/bot_api/event/__init__.py | 4 +-- kdb-bot/src/bot_api/exception/__init__.py | 4 +-- kdb-bot/src/bot_api/filter/__init__.py | 4 +-- .../src/bot_api/filter/discord/__init__.py | 4 +-- kdb-bot/src/bot_api/logging/__init__.py | 4 +-- kdb-bot/src/bot_api/model/__init__.py | 4 +-- kdb-bot/src/bot_api/model/discord/__init__.py | 4 +-- kdb-bot/src/bot_api/route/__init__.py | 4 +-- kdb-bot/src/bot_api/service/__init__.py | 4 +-- kdb-bot/src/bot_api/transformer/__init__.py | 4 +-- kdb-bot/src/bot_core/__init__.py | 4 +-- kdb-bot/src/bot_core/abc/__init__.py | 4 +-- .../src/bot_core/configuration/__init__.py | 4 +-- .../src/bot_core/core_extension/__init__.py | 4 +-- kdb-bot/src/bot_core/events/__init__.py | 4 +-- kdb-bot/src/bot_core/helper/__init__.py | 4 +-- kdb-bot/src/bot_core/logging/__init__.py | 4 +-- kdb-bot/src/bot_core/pipes/__init__.py | 4 +-- kdb-bot/src/bot_core/service/__init__.py | 4 +-- kdb-bot/src/bot_data/__init__.py | 4 +-- kdb-bot/src/bot_data/abc/__init__.py | 4 +-- kdb-bot/src/bot_data/migration/__init__.py | 4 +-- kdb-bot/src/bot_data/model/__init__.py | 4 +-- kdb-bot/src/bot_data/service/__init__.py | 4 +-- kdb-bot/src/modules/admin/__init__.py | 4 +-- kdb-bot/src/modules/admin/command/__init__.py | 4 +-- kdb-bot/src/modules/auto_role/__init__.py | 4 +-- .../src/modules/auto_role/command/__init__.py | 4 +-- .../src/modules/auto_role/events/__init__.py | 4 +-- .../src/modules/auto_role/helper/__init__.py | 4 +-- kdb-bot/src/modules/base/__init__.py | 4 +-- kdb-bot/src/modules/base/abc/__init__.py | 4 +-- kdb-bot/src/modules/base/command/__init__.py | 4 +-- .../modules/base/configuration/__init__.py | 4 +-- kdb-bot/src/modules/base/events/__init__.py | 4 +-- kdb-bot/src/modules/base/service/__init__.py | 4 +-- kdb-bot/src/modules/boot_log/__init__.py | 4 +-- .../boot_log/configuration/__init__.py | 4 +-- kdb-bot/src/modules/database/__init__.py | 4 +-- kdb-bot/src/modules/level/__init__.py | 25 +++++++++++++++++++ .../modules/level/configuration/__init__.py | 25 +++++++++++++++++++ kdb-bot/src/modules/level/events/__init__.py | 6 ++--- kdb-bot/src/modules/level/service/__init__.py | 25 +++++++++++++++++++ kdb-bot/src/modules/moderator/__init__.py | 4 +-- .../src/modules/moderator/command/__init__.py | 4 +-- kdb-bot/src/modules/permission/__init__.py | 4 +-- .../src/modules/permission/abc/__init__.py | 4 +-- .../permission/configuration/__init__.py | 4 +-- .../src/modules/permission/events/__init__.py | 4 +-- .../modules/permission/service/__init__.py | 4 +-- 57 files changed, 184 insertions(+), 108 deletions(-) diff --git a/kdb-bot/src/bot/__init__.py b/kdb-bot/src/bot/__init__.py index 69dfae3aa8..9184f6b955 100644 --- a/kdb-bot/src/bot/__init__.py +++ b/kdb-bot/src/bot/__init__.py @@ -15,7 +15,7 @@ __title__ = 'bot' __author__ = 'Sven Heidemann' __license__ = 'MIT' __copyright__ = 'Copyright (c) 2022 sh-edraft.de' -__version__ = '0.3.dev70' +__version__ = '0.3.dev25' from collections import namedtuple @@ -23,4 +23,4 @@ from collections import namedtuple # imports: VersionInfo = namedtuple('VersionInfo', 'major minor micro') -version_info = VersionInfo(major='0', minor='3', micro='dev70') +version_info = VersionInfo(major='0', minor='3', micro='dev25') diff --git a/kdb-bot/src/bot/bot.json b/kdb-bot/src/bot/bot.json index 36270e64d3..db8ef6fe92 100644 --- a/kdb-bot/src/bot/bot.json +++ b/kdb-bot/src/bot/bot.json @@ -4,7 +4,7 @@ "Version": { "Major": "0", "Minor": "3", - "Micro": "dev70" + "Micro": "dev25" }, "Author": "Sven Heidemann", "AuthorEmail": "sven.heidemann@sh-edraft.de", @@ -60,6 +60,7 @@ "../modules/base/base.json", "../modules/boot_log/boot-log.json", "../modules/database/database.json", + "../modules/level/level.json", "../modules/moderator/moderator.json", "../modules/permission/permission.json" ] diff --git a/kdb-bot/src/bot_api/__init__.py b/kdb-bot/src/bot_api/__init__.py index 3b884c17ab..c2ec271ab4 100644 --- a/kdb-bot/src/bot_api/__init__.py +++ b/kdb-bot/src/bot_api/__init__.py @@ -15,7 +15,7 @@ __title__ = 'bot_api' __author__ = 'Sven Heidemann' __license__ = 'MIT' __copyright__ = 'Copyright (c) 2022 sh-edraft.de' -__version__ = '0.3.dev70' +__version__ = '0.3.dev25' from collections import namedtuple @@ -23,4 +23,4 @@ from collections import namedtuple # imports: VersionInfo = namedtuple('VersionInfo', 'major minor micro') -version_info = VersionInfo(major='0', minor='3', micro='dev70') +version_info = VersionInfo(major='0', minor='3', micro='dev25') diff --git a/kdb-bot/src/bot_api/abc/__init__.py b/kdb-bot/src/bot_api/abc/__init__.py index 93c7c132eb..20368eb69a 100644 --- a/kdb-bot/src/bot_api/abc/__init__.py +++ b/kdb-bot/src/bot_api/abc/__init__.py @@ -15,7 +15,7 @@ __title__ = 'bot_api.abc' __author__ = 'Sven Heidemann' __license__ = 'MIT' __copyright__ = 'Copyright (c) 2022 sh-edraft.de' -__version__ = '0.3.dev70' +__version__ = '0.3.dev25' from collections import namedtuple @@ -23,4 +23,4 @@ from collections import namedtuple # imports: VersionInfo = namedtuple('VersionInfo', 'major minor micro') -version_info = VersionInfo(major='0', minor='3', micro='dev70') +version_info = VersionInfo(major='0', minor='3', micro='dev25') diff --git a/kdb-bot/src/bot_api/configuration/__init__.py b/kdb-bot/src/bot_api/configuration/__init__.py index e6ba2a1ba8..ab482a2816 100644 --- a/kdb-bot/src/bot_api/configuration/__init__.py +++ b/kdb-bot/src/bot_api/configuration/__init__.py @@ -15,7 +15,7 @@ __title__ = 'bot_api.configuration' __author__ = 'Sven Heidemann' __license__ = 'MIT' __copyright__ = 'Copyright (c) 2022 sh-edraft.de' -__version__ = '0.3.dev70' +__version__ = '0.3.dev25' from collections import namedtuple @@ -23,4 +23,4 @@ from collections import namedtuple # imports VersionInfo = namedtuple('VersionInfo', 'major minor micro') -version_info = VersionInfo(major='0', minor='3', micro='dev70') +version_info = VersionInfo(major='0', minor='3', micro='dev25') diff --git a/kdb-bot/src/bot_api/controller/__init__.py b/kdb-bot/src/bot_api/controller/__init__.py index 3a46a81cba..122f580c77 100644 --- a/kdb-bot/src/bot_api/controller/__init__.py +++ b/kdb-bot/src/bot_api/controller/__init__.py @@ -15,7 +15,7 @@ __title__ = 'bot_api.controller' __author__ = 'Sven Heidemann' __license__ = 'MIT' __copyright__ = 'Copyright (c) 2022 sh-edraft.de' -__version__ = '0.3.dev70' +__version__ = '0.3.dev25' from collections import namedtuple @@ -23,4 +23,4 @@ from collections import namedtuple # imports: VersionInfo = namedtuple('VersionInfo', 'major minor micro') -version_info = VersionInfo(major='0', minor='3', micro='dev70') +version_info = VersionInfo(major='0', minor='3', micro='dev25') diff --git a/kdb-bot/src/bot_api/controller/discord/__init__.py b/kdb-bot/src/bot_api/controller/discord/__init__.py index a23ef46015..975b9cff5c 100644 --- a/kdb-bot/src/bot_api/controller/discord/__init__.py +++ b/kdb-bot/src/bot_api/controller/discord/__init__.py @@ -15,7 +15,7 @@ __title__ = 'bot_api.controller.discord' __author__ = 'Sven Heidemann' __license__ = 'MIT' __copyright__ = 'Copyright (c) 2022 sh-edraft.de' -__version__ = '0.3.dev70' +__version__ = '0.3.dev25' from collections import namedtuple @@ -23,4 +23,4 @@ from collections import namedtuple # imports: VersionInfo = namedtuple('VersionInfo', 'major minor micro') -version_info = VersionInfo(major='0', minor='3', micro='dev70') +version_info = VersionInfo(major='0', minor='3', micro='dev25') diff --git a/kdb-bot/src/bot_api/event/__init__.py b/kdb-bot/src/bot_api/event/__init__.py index 7a717ae74a..23b33965cc 100644 --- a/kdb-bot/src/bot_api/event/__init__.py +++ b/kdb-bot/src/bot_api/event/__init__.py @@ -15,7 +15,7 @@ __title__ = 'bot_api.event' __author__ = 'Sven Heidemann' __license__ = 'MIT' __copyright__ = 'Copyright (c) 2022 sh-edraft.de' -__version__ = '0.3.dev70' +__version__ = '0.3.dev25' from collections import namedtuple @@ -23,4 +23,4 @@ from collections import namedtuple # imports: VersionInfo = namedtuple('VersionInfo', 'major minor micro') -version_info = VersionInfo(major='0', minor='3', micro='dev70') +version_info = VersionInfo(major='0', minor='3', micro='dev25') diff --git a/kdb-bot/src/bot_api/exception/__init__.py b/kdb-bot/src/bot_api/exception/__init__.py index d23b0c2237..a8c5329d0e 100644 --- a/kdb-bot/src/bot_api/exception/__init__.py +++ b/kdb-bot/src/bot_api/exception/__init__.py @@ -15,7 +15,7 @@ __title__ = 'bot_api.exception' __author__ = 'Sven Heidemann' __license__ = 'MIT' __copyright__ = 'Copyright (c) 2022 sh-edraft.de' -__version__ = '0.3.dev70' +__version__ = '0.3.dev25' from collections import namedtuple @@ -23,4 +23,4 @@ from collections import namedtuple # imports: VersionInfo = namedtuple('VersionInfo', 'major minor micro') -version_info = VersionInfo(major='0', minor='3', micro='dev70') +version_info = VersionInfo(major='0', minor='3', micro='dev25') diff --git a/kdb-bot/src/bot_api/filter/__init__.py b/kdb-bot/src/bot_api/filter/__init__.py index 800e73009a..8dc3d9742e 100644 --- a/kdb-bot/src/bot_api/filter/__init__.py +++ b/kdb-bot/src/bot_api/filter/__init__.py @@ -15,7 +15,7 @@ __title__ = 'bot_api.filter' __author__ = 'Sven Heidemann' __license__ = 'MIT' __copyright__ = 'Copyright (c) 2022 sh-edraft.de' -__version__ = '0.3.dev70' +__version__ = '0.3.dev25' from collections import namedtuple @@ -23,4 +23,4 @@ from collections import namedtuple # imports: VersionInfo = namedtuple('VersionInfo', 'major minor micro') -version_info = VersionInfo(major='0', minor='3', micro='dev70') +version_info = VersionInfo(major='0', minor='3', micro='dev25') diff --git a/kdb-bot/src/bot_api/filter/discord/__init__.py b/kdb-bot/src/bot_api/filter/discord/__init__.py index cb6b161f2a..d228164ff0 100644 --- a/kdb-bot/src/bot_api/filter/discord/__init__.py +++ b/kdb-bot/src/bot_api/filter/discord/__init__.py @@ -15,7 +15,7 @@ __title__ = 'bot_api.filter.discord' __author__ = 'Sven Heidemann' __license__ = 'MIT' __copyright__ = 'Copyright (c) 2022 sh-edraft.de' -__version__ = '0.3.dev70' +__version__ = '0.3.dev25' from collections import namedtuple @@ -23,4 +23,4 @@ from collections import namedtuple # imports: VersionInfo = namedtuple('VersionInfo', 'major minor micro') -version_info = VersionInfo(major='0', minor='3', micro='dev70') +version_info = VersionInfo(major='0', minor='3', micro='dev25') diff --git a/kdb-bot/src/bot_api/logging/__init__.py b/kdb-bot/src/bot_api/logging/__init__.py index 7877e2bb00..24cc8ae16c 100644 --- a/kdb-bot/src/bot_api/logging/__init__.py +++ b/kdb-bot/src/bot_api/logging/__init__.py @@ -15,7 +15,7 @@ __title__ = 'bot_api.logging' __author__ = 'Sven Heidemann' __license__ = 'MIT' __copyright__ = 'Copyright (c) 2022 sh-edraft.de' -__version__ = '0.3.dev70' +__version__ = '0.3.dev25' from collections import namedtuple @@ -23,4 +23,4 @@ from collections import namedtuple # imports: VersionInfo = namedtuple('VersionInfo', 'major minor micro') -version_info = VersionInfo(major='0', minor='3', micro='dev70') +version_info = VersionInfo(major='0', minor='3', micro='dev25') diff --git a/kdb-bot/src/bot_api/model/__init__.py b/kdb-bot/src/bot_api/model/__init__.py index bf076571f6..be2392ef04 100644 --- a/kdb-bot/src/bot_api/model/__init__.py +++ b/kdb-bot/src/bot_api/model/__init__.py @@ -15,7 +15,7 @@ __title__ = 'bot_api.model' __author__ = 'Sven Heidemann' __license__ = 'MIT' __copyright__ = 'Copyright (c) 2022 sh-edraft.de' -__version__ = '0.3.dev70' +__version__ = '0.3.dev25' from collections import namedtuple @@ -23,4 +23,4 @@ from collections import namedtuple # imports: VersionInfo = namedtuple('VersionInfo', 'major minor micro') -version_info = VersionInfo(major='0', minor='3', micro='dev70') +version_info = VersionInfo(major='0', minor='3', micro='dev25') diff --git a/kdb-bot/src/bot_api/model/discord/__init__.py b/kdb-bot/src/bot_api/model/discord/__init__.py index 9e0ec39b52..667ceb2a96 100644 --- a/kdb-bot/src/bot_api/model/discord/__init__.py +++ b/kdb-bot/src/bot_api/model/discord/__init__.py @@ -15,7 +15,7 @@ __title__ = 'bot_api.model.discord' __author__ = 'Sven Heidemann' __license__ = 'MIT' __copyright__ = 'Copyright (c) 2022 sh-edraft.de' -__version__ = '0.3.dev70' +__version__ = '0.3.dev25' from collections import namedtuple @@ -23,4 +23,4 @@ from collections import namedtuple # imports: VersionInfo = namedtuple('VersionInfo', 'major minor micro') -version_info = VersionInfo(major='0', minor='3', micro='dev70') +version_info = VersionInfo(major='0', minor='3', micro='dev25') diff --git a/kdb-bot/src/bot_api/route/__init__.py b/kdb-bot/src/bot_api/route/__init__.py index f781f96da8..230ae05d39 100644 --- a/kdb-bot/src/bot_api/route/__init__.py +++ b/kdb-bot/src/bot_api/route/__init__.py @@ -15,7 +15,7 @@ __title__ = 'bot_api.route' __author__ = 'Sven Heidemann' __license__ = 'MIT' __copyright__ = 'Copyright (c) 2022 sh-edraft.de' -__version__ = '0.3.dev70' +__version__ = '0.3.dev25' from collections import namedtuple @@ -23,4 +23,4 @@ from collections import namedtuple # imports: VersionInfo = namedtuple('VersionInfo', 'major minor micro') -version_info = VersionInfo(major='0', minor='3', micro='dev70') +version_info = VersionInfo(major='0', minor='3', micro='dev25') diff --git a/kdb-bot/src/bot_api/service/__init__.py b/kdb-bot/src/bot_api/service/__init__.py index ae381d3d93..d6b86d11b2 100644 --- a/kdb-bot/src/bot_api/service/__init__.py +++ b/kdb-bot/src/bot_api/service/__init__.py @@ -15,7 +15,7 @@ __title__ = 'bot_api.service' __author__ = 'Sven Heidemann' __license__ = 'MIT' __copyright__ = 'Copyright (c) 2022 sh-edraft.de' -__version__ = '0.3.dev70' +__version__ = '0.3.dev25' from collections import namedtuple @@ -23,4 +23,4 @@ from collections import namedtuple # imports VersionInfo = namedtuple('VersionInfo', 'major minor micro') -version_info = VersionInfo(major='0', minor='3', micro='dev70') +version_info = VersionInfo(major='0', minor='3', micro='dev25') diff --git a/kdb-bot/src/bot_api/transformer/__init__.py b/kdb-bot/src/bot_api/transformer/__init__.py index 0dc9db2a45..50cc9ad57c 100644 --- a/kdb-bot/src/bot_api/transformer/__init__.py +++ b/kdb-bot/src/bot_api/transformer/__init__.py @@ -15,7 +15,7 @@ __title__ = 'bot_api.transformer' __author__ = 'Sven Heidemann' __license__ = 'MIT' __copyright__ = 'Copyright (c) 2022 sh-edraft.de' -__version__ = '0.3.dev70' +__version__ = '0.3.dev25' from collections import namedtuple @@ -23,4 +23,4 @@ from collections import namedtuple # imports: VersionInfo = namedtuple('VersionInfo', 'major minor micro') -version_info = VersionInfo(major='0', minor='3', micro='dev70') +version_info = VersionInfo(major='0', minor='3', micro='dev25') diff --git a/kdb-bot/src/bot_core/__init__.py b/kdb-bot/src/bot_core/__init__.py index 178a3f4eda..bc622310bc 100644 --- a/kdb-bot/src/bot_core/__init__.py +++ b/kdb-bot/src/bot_core/__init__.py @@ -15,7 +15,7 @@ __title__ = 'bot_core' __author__ = 'Sven Heidemann' __license__ = 'MIT' __copyright__ = 'Copyright (c) 2022 sh-edraft.de' -__version__ = '0.3.dev70' +__version__ = '0.3.dev25' from collections import namedtuple @@ -23,4 +23,4 @@ from collections import namedtuple # imports VersionInfo = namedtuple('VersionInfo', 'major minor micro') -version_info = VersionInfo(major='0', minor='3', micro='dev70') +version_info = VersionInfo(major='0', minor='3', micro='dev25') diff --git a/kdb-bot/src/bot_core/abc/__init__.py b/kdb-bot/src/bot_core/abc/__init__.py index a388e22a50..4056210a9a 100644 --- a/kdb-bot/src/bot_core/abc/__init__.py +++ b/kdb-bot/src/bot_core/abc/__init__.py @@ -15,7 +15,7 @@ __title__ = 'bot_core.abc' __author__ = 'Sven Heidemann' __license__ = 'MIT' __copyright__ = 'Copyright (c) 2022 sh-edraft.de' -__version__ = '0.3.dev70' +__version__ = '0.3.dev25' from collections import namedtuple @@ -23,4 +23,4 @@ from collections import namedtuple # imports: VersionInfo = namedtuple('VersionInfo', 'major minor micro') -version_info = VersionInfo(major='0', minor='3', micro='dev70') +version_info = VersionInfo(major='0', minor='3', micro='dev25') diff --git a/kdb-bot/src/bot_core/configuration/__init__.py b/kdb-bot/src/bot_core/configuration/__init__.py index 6dbe179135..8e677c73a5 100644 --- a/kdb-bot/src/bot_core/configuration/__init__.py +++ b/kdb-bot/src/bot_core/configuration/__init__.py @@ -15,7 +15,7 @@ __title__ = 'bot_core.configuration' __author__ = 'Sven Heidemann' __license__ = 'MIT' __copyright__ = 'Copyright (c) 2022 sh-edraft.de' -__version__ = '0.3.dev70' +__version__ = '0.3.dev25' from collections import namedtuple @@ -23,4 +23,4 @@ from collections import namedtuple # imports: VersionInfo = namedtuple('VersionInfo', 'major minor micro') -version_info = VersionInfo(major='0', minor='3', micro='dev70') +version_info = VersionInfo(major='0', minor='3', micro='dev25') diff --git a/kdb-bot/src/bot_core/core_extension/__init__.py b/kdb-bot/src/bot_core/core_extension/__init__.py index 09f8f2371f..a107f3d828 100644 --- a/kdb-bot/src/bot_core/core_extension/__init__.py +++ b/kdb-bot/src/bot_core/core_extension/__init__.py @@ -15,7 +15,7 @@ __title__ = 'bot_core.core_extension' __author__ = 'Sven Heidemann' __license__ = 'MIT' __copyright__ = 'Copyright (c) 2022 sh-edraft.de' -__version__ = '0.3.dev70' +__version__ = '0.3.dev25' from collections import namedtuple @@ -23,4 +23,4 @@ from collections import namedtuple # imports: VersionInfo = namedtuple('VersionInfo', 'major minor micro') -version_info = VersionInfo(major='0', minor='3', micro='dev70') +version_info = VersionInfo(major='0', minor='3', micro='dev25') diff --git a/kdb-bot/src/bot_core/events/__init__.py b/kdb-bot/src/bot_core/events/__init__.py index 885b39c3ac..b73ac3fb7f 100644 --- a/kdb-bot/src/bot_core/events/__init__.py +++ b/kdb-bot/src/bot_core/events/__init__.py @@ -15,7 +15,7 @@ __title__ = 'bot_core.events' __author__ = 'Sven Heidemann' __license__ = 'MIT' __copyright__ = 'Copyright (c) 2022 sh-edraft.de' -__version__ = '0.3.dev70' +__version__ = '0.3.dev25' from collections import namedtuple @@ -23,4 +23,4 @@ from collections import namedtuple # imports: VersionInfo = namedtuple('VersionInfo', 'major minor micro') -version_info = VersionInfo(major='0', minor='3', micro='dev70') +version_info = VersionInfo(major='0', minor='3', micro='dev25') diff --git a/kdb-bot/src/bot_core/helper/__init__.py b/kdb-bot/src/bot_core/helper/__init__.py index 1b4972d082..0f0edc20ad 100644 --- a/kdb-bot/src/bot_core/helper/__init__.py +++ b/kdb-bot/src/bot_core/helper/__init__.py @@ -15,7 +15,7 @@ __title__ = 'bot_core.helper' __author__ = 'Sven Heidemann' __license__ = 'MIT' __copyright__ = 'Copyright (c) 2022 sh-edraft.de' -__version__ = '0.3.dev70' +__version__ = '0.3.dev25' from collections import namedtuple @@ -23,4 +23,4 @@ from collections import namedtuple # imports: VersionInfo = namedtuple('VersionInfo', 'major minor micro') -version_info = VersionInfo(major='0', minor='3', micro='dev70') +version_info = VersionInfo(major='0', minor='3', micro='dev25') diff --git a/kdb-bot/src/bot_core/logging/__init__.py b/kdb-bot/src/bot_core/logging/__init__.py index eb87740c37..ba6fe7adc3 100644 --- a/kdb-bot/src/bot_core/logging/__init__.py +++ b/kdb-bot/src/bot_core/logging/__init__.py @@ -15,7 +15,7 @@ __title__ = 'bot_core.logging' __author__ = 'Sven Heidemann' __license__ = 'MIT' __copyright__ = 'Copyright (c) 2022 sh-edraft.de' -__version__ = '0.3.dev70' +__version__ = '0.3.dev25' from collections import namedtuple @@ -23,4 +23,4 @@ from collections import namedtuple # imports VersionInfo = namedtuple('VersionInfo', 'major minor micro') -version_info = VersionInfo(major='0', minor='3', micro='dev70') +version_info = VersionInfo(major='0', minor='3', micro='dev25') diff --git a/kdb-bot/src/bot_core/pipes/__init__.py b/kdb-bot/src/bot_core/pipes/__init__.py index 1cad1f886e..85c44be76b 100644 --- a/kdb-bot/src/bot_core/pipes/__init__.py +++ b/kdb-bot/src/bot_core/pipes/__init__.py @@ -15,7 +15,7 @@ __title__ = 'bot_core.pipes' __author__ = 'Sven Heidemann' __license__ = 'MIT' __copyright__ = 'Copyright (c) 2022 sh-edraft.de' -__version__ = '0.3.dev70' +__version__ = '0.3.dev25' from collections import namedtuple @@ -23,4 +23,4 @@ from collections import namedtuple # imports VersionInfo = namedtuple('VersionInfo', 'major minor micro') -version_info = VersionInfo(major='0', minor='3', micro='dev70') +version_info = VersionInfo(major='0', minor='3', micro='dev25') diff --git a/kdb-bot/src/bot_core/service/__init__.py b/kdb-bot/src/bot_core/service/__init__.py index a5c0718e8a..1266f4f1ea 100644 --- a/kdb-bot/src/bot_core/service/__init__.py +++ b/kdb-bot/src/bot_core/service/__init__.py @@ -15,7 +15,7 @@ __title__ = 'bot_core.service' __author__ = 'Sven Heidemann' __license__ = 'MIT' __copyright__ = 'Copyright (c) 2022 sh-edraft.de' -__version__ = '0.3.dev70' +__version__ = '0.3.dev25' from collections import namedtuple @@ -23,4 +23,4 @@ from collections import namedtuple # imports: VersionInfo = namedtuple('VersionInfo', 'major minor micro') -version_info = VersionInfo(major='0', minor='3', micro='dev70') +version_info = VersionInfo(major='0', minor='3', micro='dev25') diff --git a/kdb-bot/src/bot_data/__init__.py b/kdb-bot/src/bot_data/__init__.py index cf89c13c97..5a1acbdfa4 100644 --- a/kdb-bot/src/bot_data/__init__.py +++ b/kdb-bot/src/bot_data/__init__.py @@ -15,7 +15,7 @@ __title__ = 'bot_data' __author__ = 'Sven Heidemann' __license__ = 'MIT' __copyright__ = 'Copyright (c) 2022 sh-edraft.de' -__version__ = '0.3.dev70' +__version__ = '0.3.dev25' from collections import namedtuple @@ -23,4 +23,4 @@ from collections import namedtuple # imports VersionInfo = namedtuple('VersionInfo', 'major minor micro') -version_info = VersionInfo(major='0', minor='3', micro='dev70') +version_info = VersionInfo(major='0', minor='3', micro='dev25') diff --git a/kdb-bot/src/bot_data/abc/__init__.py b/kdb-bot/src/bot_data/abc/__init__.py index 1e3d6dcf60..7209be452e 100644 --- a/kdb-bot/src/bot_data/abc/__init__.py +++ b/kdb-bot/src/bot_data/abc/__init__.py @@ -15,7 +15,7 @@ __title__ = 'bot_data.abc' __author__ = 'Sven Heidemann' __license__ = 'MIT' __copyright__ = 'Copyright (c) 2022 sh-edraft.de' -__version__ = '0.3.dev70' +__version__ = '0.3.dev25' from collections import namedtuple @@ -23,4 +23,4 @@ from collections import namedtuple # imports VersionInfo = namedtuple('VersionInfo', 'major minor micro') -version_info = VersionInfo(major='0', minor='3', micro='dev70') +version_info = VersionInfo(major='0', minor='3', micro='dev25') diff --git a/kdb-bot/src/bot_data/migration/__init__.py b/kdb-bot/src/bot_data/migration/__init__.py index b716abf99d..ed8bf58fd9 100644 --- a/kdb-bot/src/bot_data/migration/__init__.py +++ b/kdb-bot/src/bot_data/migration/__init__.py @@ -15,7 +15,7 @@ __title__ = 'bot_data.migration' __author__ = 'Sven Heidemann' __license__ = 'MIT' __copyright__ = 'Copyright (c) 2022 sh-edraft.de' -__version__ = '0.3.dev70' +__version__ = '0.3.dev25' from collections import namedtuple @@ -23,4 +23,4 @@ from collections import namedtuple # imports VersionInfo = namedtuple('VersionInfo', 'major minor micro') -version_info = VersionInfo(major='0', minor='3', micro='dev70') +version_info = VersionInfo(major='0', minor='3', micro='dev25') diff --git a/kdb-bot/src/bot_data/model/__init__.py b/kdb-bot/src/bot_data/model/__init__.py index 562dec8460..0c33f8c760 100644 --- a/kdb-bot/src/bot_data/model/__init__.py +++ b/kdb-bot/src/bot_data/model/__init__.py @@ -15,7 +15,7 @@ __title__ = 'bot_data.model' __author__ = 'Sven Heidemann' __license__ = 'MIT' __copyright__ = 'Copyright (c) 2022 sh-edraft.de' -__version__ = '0.3.dev70' +__version__ = '0.3.dev25' from collections import namedtuple @@ -23,4 +23,4 @@ from collections import namedtuple # imports VersionInfo = namedtuple('VersionInfo', 'major minor micro') -version_info = VersionInfo(major='0', minor='3', micro='dev70') +version_info = VersionInfo(major='0', minor='3', micro='dev25') diff --git a/kdb-bot/src/bot_data/service/__init__.py b/kdb-bot/src/bot_data/service/__init__.py index 3ff47a8a2f..c2b4323a57 100644 --- a/kdb-bot/src/bot_data/service/__init__.py +++ b/kdb-bot/src/bot_data/service/__init__.py @@ -15,7 +15,7 @@ __title__ = 'bot_data.service' __author__ = 'Sven Heidemann' __license__ = 'MIT' __copyright__ = 'Copyright (c) 2022 sh-edraft.de' -__version__ = '0.3.dev70' +__version__ = '0.3.dev25' from collections import namedtuple @@ -23,4 +23,4 @@ from collections import namedtuple # imports VersionInfo = namedtuple('VersionInfo', 'major minor micro') -version_info = VersionInfo(major='0', minor='3', micro='dev70') +version_info = VersionInfo(major='0', minor='3', micro='dev25') diff --git a/kdb-bot/src/modules/admin/__init__.py b/kdb-bot/src/modules/admin/__init__.py index 0b4143b89a..afcd237eb4 100644 --- a/kdb-bot/src/modules/admin/__init__.py +++ b/kdb-bot/src/modules/admin/__init__.py @@ -15,7 +15,7 @@ __title__ = 'modules.admin' __author__ = 'Sven Heidemann' __license__ = 'MIT' __copyright__ = 'Copyright (c) 2022 sh-edraft.de' -__version__ = '0.3.dev70' +__version__ = '0.3.dev25' from collections import namedtuple @@ -23,4 +23,4 @@ from collections import namedtuple # imports: VersionInfo = namedtuple('VersionInfo', 'major minor micro') -version_info = VersionInfo(major='0', minor='3', micro='dev70') +version_info = VersionInfo(major='0', minor='3', micro='dev25') diff --git a/kdb-bot/src/modules/admin/command/__init__.py b/kdb-bot/src/modules/admin/command/__init__.py index 560c44e583..ed0cff3be5 100644 --- a/kdb-bot/src/modules/admin/command/__init__.py +++ b/kdb-bot/src/modules/admin/command/__init__.py @@ -15,7 +15,7 @@ __title__ = 'modules.admin.command' __author__ = 'Sven Heidemann' __license__ = 'MIT' __copyright__ = 'Copyright (c) 2022 sh-edraft.de' -__version__ = '0.3.dev70' +__version__ = '0.3.dev25' from collections import namedtuple @@ -23,4 +23,4 @@ from collections import namedtuple # imports: VersionInfo = namedtuple('VersionInfo', 'major minor micro') -version_info = VersionInfo(major='0', minor='3', micro='dev70') +version_info = VersionInfo(major='0', minor='3', micro='dev25') diff --git a/kdb-bot/src/modules/auto_role/__init__.py b/kdb-bot/src/modules/auto_role/__init__.py index c98076f25c..4a85332301 100644 --- a/kdb-bot/src/modules/auto_role/__init__.py +++ b/kdb-bot/src/modules/auto_role/__init__.py @@ -15,7 +15,7 @@ __title__ = 'modules.auto_role' __author__ = 'Sven Heidemann' __license__ = 'MIT' __copyright__ = 'Copyright (c) 2022 sh-edraft.de' -__version__ = '0.3.dev70' +__version__ = '0.3.dev25' from collections import namedtuple @@ -23,4 +23,4 @@ from collections import namedtuple # imports: VersionInfo = namedtuple('VersionInfo', 'major minor micro') -version_info = VersionInfo(major='0', minor='3', micro='dev70') +version_info = VersionInfo(major='0', minor='3', micro='dev25') diff --git a/kdb-bot/src/modules/auto_role/command/__init__.py b/kdb-bot/src/modules/auto_role/command/__init__.py index 893b4fd8cf..86a6041df9 100644 --- a/kdb-bot/src/modules/auto_role/command/__init__.py +++ b/kdb-bot/src/modules/auto_role/command/__init__.py @@ -15,7 +15,7 @@ __title__ = 'modules.auto_role.command' __author__ = 'Sven Heidemann' __license__ = 'MIT' __copyright__ = 'Copyright (c) 2022 sh-edraft.de' -__version__ = '0.3.dev70' +__version__ = '0.3.dev25' from collections import namedtuple @@ -23,4 +23,4 @@ from collections import namedtuple # imports: VersionInfo = namedtuple('VersionInfo', 'major minor micro') -version_info = VersionInfo(major='0', minor='3', micro='dev70') +version_info = VersionInfo(major='0', minor='3', micro='dev25') diff --git a/kdb-bot/src/modules/auto_role/events/__init__.py b/kdb-bot/src/modules/auto_role/events/__init__.py index b3c13b1c2f..2946309621 100644 --- a/kdb-bot/src/modules/auto_role/events/__init__.py +++ b/kdb-bot/src/modules/auto_role/events/__init__.py @@ -15,7 +15,7 @@ __title__ = 'modules.auto_role.events' __author__ = 'Sven Heidemann' __license__ = 'MIT' __copyright__ = 'Copyright (c) 2022 sh-edraft.de' -__version__ = '0.3.dev70' +__version__ = '0.3.dev25' from collections import namedtuple @@ -23,4 +23,4 @@ from collections import namedtuple # imports: VersionInfo = namedtuple('VersionInfo', 'major minor micro') -version_info = VersionInfo(major='0', minor='3', micro='dev70') +version_info = VersionInfo(major='0', minor='3', micro='dev25') diff --git a/kdb-bot/src/modules/auto_role/helper/__init__.py b/kdb-bot/src/modules/auto_role/helper/__init__.py index dde66d85e0..a19a540f30 100644 --- a/kdb-bot/src/modules/auto_role/helper/__init__.py +++ b/kdb-bot/src/modules/auto_role/helper/__init__.py @@ -15,7 +15,7 @@ __title__ = 'modules.auto_role.helper' __author__ = 'Sven Heidemann' __license__ = 'MIT' __copyright__ = 'Copyright (c) 2022 sh-edraft.de' -__version__ = '0.3.dev70' +__version__ = '0.3.dev25' from collections import namedtuple @@ -23,4 +23,4 @@ from collections import namedtuple # imports: VersionInfo = namedtuple('VersionInfo', 'major minor micro') -version_info = VersionInfo(major='0', minor='3', micro='dev70') +version_info = VersionInfo(major='0', minor='3', micro='dev25') diff --git a/kdb-bot/src/modules/base/__init__.py b/kdb-bot/src/modules/base/__init__.py index 9013b6d0db..624c476ecc 100644 --- a/kdb-bot/src/modules/base/__init__.py +++ b/kdb-bot/src/modules/base/__init__.py @@ -15,7 +15,7 @@ __title__ = 'modules.base' __author__ = 'Sven Heidemann' __license__ = 'MIT' __copyright__ = 'Copyright (c) 2022 sh-edraft.de' -__version__ = '0.3.dev70' +__version__ = '0.3.dev25' from collections import namedtuple @@ -23,4 +23,4 @@ from collections import namedtuple # imports VersionInfo = namedtuple('VersionInfo', 'major minor micro') -version_info = VersionInfo(major='0', minor='3', micro='dev70') +version_info = VersionInfo(major='0', minor='3', micro='dev25') diff --git a/kdb-bot/src/modules/base/abc/__init__.py b/kdb-bot/src/modules/base/abc/__init__.py index 4f366eaa16..ccc3e98a76 100644 --- a/kdb-bot/src/modules/base/abc/__init__.py +++ b/kdb-bot/src/modules/base/abc/__init__.py @@ -15,7 +15,7 @@ __title__ = 'modules.base.abc' __author__ = 'Sven Heidemann' __license__ = 'MIT' __copyright__ = 'Copyright (c) 2022 sh-edraft.de' -__version__ = '0.3.dev70' +__version__ = '0.3.dev25' from collections import namedtuple @@ -23,4 +23,4 @@ from collections import namedtuple # imports: VersionInfo = namedtuple('VersionInfo', 'major minor micro') -version_info = VersionInfo(major='0', minor='3', micro='dev70') +version_info = VersionInfo(major='0', minor='3', micro='dev25') diff --git a/kdb-bot/src/modules/base/command/__init__.py b/kdb-bot/src/modules/base/command/__init__.py index a1c9429739..c9fccb7ac9 100644 --- a/kdb-bot/src/modules/base/command/__init__.py +++ b/kdb-bot/src/modules/base/command/__init__.py @@ -15,7 +15,7 @@ __title__ = 'modules.base.command' __author__ = 'Sven Heidemann' __license__ = 'MIT' __copyright__ = 'Copyright (c) 2022 sh-edraft.de' -__version__ = '0.3.dev70' +__version__ = '0.3.dev25' from collections import namedtuple @@ -23,4 +23,4 @@ from collections import namedtuple # imports VersionInfo = namedtuple('VersionInfo', 'major minor micro') -version_info = VersionInfo(major='0', minor='3', micro='dev70') +version_info = VersionInfo(major='0', minor='3', micro='dev25') diff --git a/kdb-bot/src/modules/base/configuration/__init__.py b/kdb-bot/src/modules/base/configuration/__init__.py index 1c3feda70b..5dfdba22e7 100644 --- a/kdb-bot/src/modules/base/configuration/__init__.py +++ b/kdb-bot/src/modules/base/configuration/__init__.py @@ -15,7 +15,7 @@ __title__ = 'modules.base.configuration' __author__ = 'Sven Heidemann' __license__ = 'MIT' __copyright__ = 'Copyright (c) 2022 sh-edraft.de' -__version__ = '0.3.dev70' +__version__ = '0.3.dev25' from collections import namedtuple @@ -23,4 +23,4 @@ from collections import namedtuple # imports: VersionInfo = namedtuple('VersionInfo', 'major minor micro') -version_info = VersionInfo(major='0', minor='3', micro='dev70') +version_info = VersionInfo(major='0', minor='3', micro='dev25') diff --git a/kdb-bot/src/modules/base/events/__init__.py b/kdb-bot/src/modules/base/events/__init__.py index 85e09931a0..8b0480696d 100644 --- a/kdb-bot/src/modules/base/events/__init__.py +++ b/kdb-bot/src/modules/base/events/__init__.py @@ -15,7 +15,7 @@ __title__ = 'modules.base.events' __author__ = 'Sven Heidemann' __license__ = 'MIT' __copyright__ = 'Copyright (c) 2022 sh-edraft.de' -__version__ = '0.3.dev70' +__version__ = '0.3.dev25' from collections import namedtuple @@ -23,4 +23,4 @@ from collections import namedtuple # imports: VersionInfo = namedtuple('VersionInfo', 'major minor micro') -version_info = VersionInfo(major='0', minor='3', micro='dev70') +version_info = VersionInfo(major='0', minor='3', micro='dev25') diff --git a/kdb-bot/src/modules/base/service/__init__.py b/kdb-bot/src/modules/base/service/__init__.py index 26d484dac9..4362aaf149 100644 --- a/kdb-bot/src/modules/base/service/__init__.py +++ b/kdb-bot/src/modules/base/service/__init__.py @@ -15,7 +15,7 @@ __title__ = 'modules.base.service' __author__ = 'Sven Heidemann' __license__ = 'MIT' __copyright__ = 'Copyright (c) 2022 sh-edraft.de' -__version__ = '0.3.dev70' +__version__ = '0.3.dev25' from collections import namedtuple @@ -23,4 +23,4 @@ from collections import namedtuple # imports VersionInfo = namedtuple('VersionInfo', 'major minor micro') -version_info = VersionInfo(major='0', minor='3', micro='dev70') +version_info = VersionInfo(major='0', minor='3', micro='dev25') diff --git a/kdb-bot/src/modules/boot_log/__init__.py b/kdb-bot/src/modules/boot_log/__init__.py index a8e3acd4df..afe1ddbda5 100644 --- a/kdb-bot/src/modules/boot_log/__init__.py +++ b/kdb-bot/src/modules/boot_log/__init__.py @@ -15,7 +15,7 @@ __title__ = 'modules.boot_log' __author__ = 'Sven Heidemann' __license__ = 'MIT' __copyright__ = 'Copyright (c) 2022 sh-edraft.de' -__version__ = '0.3.dev70' +__version__ = '0.3.dev25' from collections import namedtuple @@ -23,4 +23,4 @@ from collections import namedtuple # imports: VersionInfo = namedtuple('VersionInfo', 'major minor micro') -version_info = VersionInfo(major='0', minor='3', micro='dev70') +version_info = VersionInfo(major='0', minor='3', micro='dev25') diff --git a/kdb-bot/src/modules/boot_log/configuration/__init__.py b/kdb-bot/src/modules/boot_log/configuration/__init__.py index a7ee6a4ec8..1eee9aba97 100644 --- a/kdb-bot/src/modules/boot_log/configuration/__init__.py +++ b/kdb-bot/src/modules/boot_log/configuration/__init__.py @@ -15,7 +15,7 @@ __title__ = 'modules.boot_log.configuration' __author__ = 'Sven Heidemann' __license__ = 'MIT' __copyright__ = 'Copyright (c) 2022 sh-edraft.de' -__version__ = '0.3.dev70' +__version__ = '0.3.dev25' from collections import namedtuple @@ -23,4 +23,4 @@ from collections import namedtuple # imports: VersionInfo = namedtuple('VersionInfo', 'major minor micro') -version_info = VersionInfo(major='0', minor='3', micro='dev70') +version_info = VersionInfo(major='0', minor='3', micro='dev25') diff --git a/kdb-bot/src/modules/database/__init__.py b/kdb-bot/src/modules/database/__init__.py index 122dd6eba0..a1425bbbd4 100644 --- a/kdb-bot/src/modules/database/__init__.py +++ b/kdb-bot/src/modules/database/__init__.py @@ -15,7 +15,7 @@ __title__ = 'modules.database' __author__ = 'Sven Heidemann' __license__ = 'MIT' __copyright__ = 'Copyright (c) 2022 sh-edraft.de' -__version__ = '0.3.dev70' +__version__ = '0.3.dev25' from collections import namedtuple @@ -23,4 +23,4 @@ from collections import namedtuple # imports: VersionInfo = namedtuple('VersionInfo', 'major minor micro') -version_info = VersionInfo(major='0', minor='3', micro='dev70') +version_info = VersionInfo(major='0', minor='3', micro='dev25') diff --git a/kdb-bot/src/modules/level/__init__.py b/kdb-bot/src/modules/level/__init__.py index ad5eca3064..d1d67ee323 100644 --- a/kdb-bot/src/modules/level/__init__.py +++ b/kdb-bot/src/modules/level/__init__.py @@ -1 +1,26 @@ +# -*- coding: utf-8 -*- + +""" +bot Keksdose bot +~~~~~~~~~~~~~~~~~~~ + +Discord bot for the Keksdose discord Server + +:copyright: (c) 2022 sh-edraft.de +:license: MIT, see LICENSE for more details. + +""" + +__title__ = 'modules.level' +__author__ = 'Sven Heidemann' +__license__ = 'MIT' +__copyright__ = 'Copyright (c) 2022 sh-edraft.de' +__version__ = '0.3.dev25' + +from collections import namedtuple + + # imports: + +VersionInfo = namedtuple('VersionInfo', 'major minor micro') +version_info = VersionInfo(major='0', minor='3', micro='dev25') diff --git a/kdb-bot/src/modules/level/configuration/__init__.py b/kdb-bot/src/modules/level/configuration/__init__.py index 425ab6c146..a30d06e06f 100644 --- a/kdb-bot/src/modules/level/configuration/__init__.py +++ b/kdb-bot/src/modules/level/configuration/__init__.py @@ -1 +1,26 @@ +# -*- coding: utf-8 -*- + +""" +bot Keksdose bot +~~~~~~~~~~~~~~~~~~~ + +Discord bot for the Keksdose discord Server + +:copyright: (c) 2022 sh-edraft.de +:license: MIT, see LICENSE for more details. + +""" + +__title__ = 'modules.level.configuration' +__author__ = 'Sven Heidemann' +__license__ = 'MIT' +__copyright__ = 'Copyright (c) 2022 sh-edraft.de' +__version__ = '0.3.dev25' + +from collections import namedtuple + + # imports + +VersionInfo = namedtuple('VersionInfo', 'major minor micro') +version_info = VersionInfo(major='0', minor='3', micro='dev25') diff --git a/kdb-bot/src/modules/level/events/__init__.py b/kdb-bot/src/modules/level/events/__init__.py index 85e09931a0..5925acf8c6 100644 --- a/kdb-bot/src/modules/level/events/__init__.py +++ b/kdb-bot/src/modules/level/events/__init__.py @@ -11,11 +11,11 @@ Discord bot for the Keksdose discord Server """ -__title__ = 'modules.base.events' +__title__ = 'modules.level.events' __author__ = 'Sven Heidemann' __license__ = 'MIT' __copyright__ = 'Copyright (c) 2022 sh-edraft.de' -__version__ = '0.3.dev70' +__version__ = '0.3.dev25' from collections import namedtuple @@ -23,4 +23,4 @@ from collections import namedtuple # imports: VersionInfo = namedtuple('VersionInfo', 'major minor micro') -version_info = VersionInfo(major='0', minor='3', micro='dev70') +version_info = VersionInfo(major='0', minor='3', micro='dev25') diff --git a/kdb-bot/src/modules/level/service/__init__.py b/kdb-bot/src/modules/level/service/__init__.py index 425ab6c146..4ed3b99f0b 100644 --- a/kdb-bot/src/modules/level/service/__init__.py +++ b/kdb-bot/src/modules/level/service/__init__.py @@ -1 +1,26 @@ +# -*- coding: utf-8 -*- + +""" +bot Keksdose bot +~~~~~~~~~~~~~~~~~~~ + +Discord bot for the Keksdose discord Server + +:copyright: (c) 2022 sh-edraft.de +:license: MIT, see LICENSE for more details. + +""" + +__title__ = 'modules.level.service' +__author__ = 'Sven Heidemann' +__license__ = 'MIT' +__copyright__ = 'Copyright (c) 2022 sh-edraft.de' +__version__ = '0.3.dev25' + +from collections import namedtuple + + # imports + +VersionInfo = namedtuple('VersionInfo', 'major minor micro') +version_info = VersionInfo(major='0', minor='3', micro='dev25') diff --git a/kdb-bot/src/modules/moderator/__init__.py b/kdb-bot/src/modules/moderator/__init__.py index 2582b00b71..ab63ed9f20 100644 --- a/kdb-bot/src/modules/moderator/__init__.py +++ b/kdb-bot/src/modules/moderator/__init__.py @@ -15,7 +15,7 @@ __title__ = 'modules.moderator' __author__ = 'Sven Heidemann' __license__ = 'MIT' __copyright__ = 'Copyright (c) 2022 sh-edraft.de' -__version__ = '0.3.dev70' +__version__ = '0.3.dev25' from collections import namedtuple @@ -23,4 +23,4 @@ from collections import namedtuple # imports: VersionInfo = namedtuple('VersionInfo', 'major minor micro') -version_info = VersionInfo(major='0', minor='3', micro='dev70') +version_info = VersionInfo(major='0', minor='3', micro='dev25') diff --git a/kdb-bot/src/modules/moderator/command/__init__.py b/kdb-bot/src/modules/moderator/command/__init__.py index bdd9ddbd21..68d0c50bf8 100644 --- a/kdb-bot/src/modules/moderator/command/__init__.py +++ b/kdb-bot/src/modules/moderator/command/__init__.py @@ -15,7 +15,7 @@ __title__ = 'modules.moderator.command' __author__ = 'Sven Heidemann' __license__ = 'MIT' __copyright__ = 'Copyright (c) 2022 sh-edraft.de' -__version__ = '0.3.dev70' +__version__ = '0.3.dev25' from collections import namedtuple @@ -23,4 +23,4 @@ from collections import namedtuple # imports: VersionInfo = namedtuple('VersionInfo', 'major minor micro') -version_info = VersionInfo(major='0', minor='3', micro='dev70') +version_info = VersionInfo(major='0', minor='3', micro='dev25') diff --git a/kdb-bot/src/modules/permission/__init__.py b/kdb-bot/src/modules/permission/__init__.py index 151c717547..2215351384 100644 --- a/kdb-bot/src/modules/permission/__init__.py +++ b/kdb-bot/src/modules/permission/__init__.py @@ -15,7 +15,7 @@ __title__ = 'modules.permission' __author__ = 'Sven Heidemann' __license__ = 'MIT' __copyright__ = 'Copyright (c) 2022 sh-edraft.de' -__version__ = '0.3.dev70' +__version__ = '0.3.dev25' from collections import namedtuple @@ -23,4 +23,4 @@ from collections import namedtuple # imports: VersionInfo = namedtuple('VersionInfo', 'major minor micro') -version_info = VersionInfo(major='0', minor='3', micro='dev70') +version_info = VersionInfo(major='0', minor='3', micro='dev25') diff --git a/kdb-bot/src/modules/permission/abc/__init__.py b/kdb-bot/src/modules/permission/abc/__init__.py index 460f1ab59a..294d277c41 100644 --- a/kdb-bot/src/modules/permission/abc/__init__.py +++ b/kdb-bot/src/modules/permission/abc/__init__.py @@ -15,7 +15,7 @@ __title__ = 'modules.permission.abc' __author__ = 'Sven Heidemann' __license__ = 'MIT' __copyright__ = 'Copyright (c) 2022 sh-edraft.de' -__version__ = '0.3.dev70' +__version__ = '0.3.dev25' from collections import namedtuple @@ -23,4 +23,4 @@ from collections import namedtuple # imports VersionInfo = namedtuple('VersionInfo', 'major minor micro') -version_info = VersionInfo(major='0', minor='3', micro='dev70') +version_info = VersionInfo(major='0', minor='3', micro='dev25') diff --git a/kdb-bot/src/modules/permission/configuration/__init__.py b/kdb-bot/src/modules/permission/configuration/__init__.py index 062b17ee96..2a385a0dee 100644 --- a/kdb-bot/src/modules/permission/configuration/__init__.py +++ b/kdb-bot/src/modules/permission/configuration/__init__.py @@ -15,7 +15,7 @@ __title__ = 'modules.permission.configuration' __author__ = 'Sven Heidemann' __license__ = 'MIT' __copyright__ = 'Copyright (c) 2022 sh-edraft.de' -__version__ = '0.3.dev70' +__version__ = '0.3.dev25' from collections import namedtuple @@ -23,4 +23,4 @@ from collections import namedtuple # imports VersionInfo = namedtuple('VersionInfo', 'major minor micro') -version_info = VersionInfo(major='0', minor='3', micro='dev70') +version_info = VersionInfo(major='0', minor='3', micro='dev25') diff --git a/kdb-bot/src/modules/permission/events/__init__.py b/kdb-bot/src/modules/permission/events/__init__.py index 32488e5aa0..d51f9b129d 100644 --- a/kdb-bot/src/modules/permission/events/__init__.py +++ b/kdb-bot/src/modules/permission/events/__init__.py @@ -15,7 +15,7 @@ __title__ = 'modules.permission.events' __author__ = 'Sven Heidemann' __license__ = 'MIT' __copyright__ = 'Copyright (c) 2022 sh-edraft.de' -__version__ = '0.3.dev70' +__version__ = '0.3.dev25' from collections import namedtuple @@ -23,4 +23,4 @@ from collections import namedtuple # imports: VersionInfo = namedtuple('VersionInfo', 'major minor micro') -version_info = VersionInfo(major='0', minor='3', micro='dev70') +version_info = VersionInfo(major='0', minor='3', micro='dev25') diff --git a/kdb-bot/src/modules/permission/service/__init__.py b/kdb-bot/src/modules/permission/service/__init__.py index ddc1eb808b..930246c113 100644 --- a/kdb-bot/src/modules/permission/service/__init__.py +++ b/kdb-bot/src/modules/permission/service/__init__.py @@ -15,7 +15,7 @@ __title__ = 'modules.permission.service' __author__ = 'Sven Heidemann' __license__ = 'MIT' __copyright__ = 'Copyright (c) 2022 sh-edraft.de' -__version__ = '0.3.dev70' +__version__ = '0.3.dev25' from collections import namedtuple @@ -23,4 +23,4 @@ from collections import namedtuple # imports VersionInfo = namedtuple('VersionInfo', 'major minor micro') -version_info = VersionInfo(major='0', minor='3', micro='dev70') +version_info = VersionInfo(major='0', minor='3', micro='dev25') From 3d27295b14324933d1a6341bccbce0a0a6b98261 Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Sun, 6 Nov 2022 22:43:42 +0100 Subject: [PATCH 14/15] Added translation to level service #25 --- kdb-bot/src/bot/translation/de.json | 3 +++ kdb-bot/src/modules/level/service/level_service.py | 7 +++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/kdb-bot/src/bot/translation/de.json b/kdb-bot/src/bot/translation/de.json index 206df3ea17..447b232e4c 100644 --- a/kdb-bot/src/bot/translation/de.json +++ b/kdb-bot/src/bot/translation/de.json @@ -149,6 +149,9 @@ "boot_log": { "login_message": "Ich bin on the line :D\nDer Scheiß hat {} Sekunden gedauert" }, + "level": { + "new_level_message": "<@{}> ist nun Level {}" + }, "database": {}, "permission": { } diff --git a/kdb-bot/src/modules/level/service/level_service.py b/kdb-bot/src/modules/level/service/level_service.py index 6385b9ae67..bf53b11ce8 100644 --- a/kdb-bot/src/modules/level/service/level_service.py +++ b/kdb-bot/src/modules/level/service/level_service.py @@ -6,6 +6,7 @@ from cpl_core.database.context import DatabaseContextABC from cpl_core.logging import LoggerABC from cpl_discord.container import Guild, Role, Member from cpl_discord.service import DiscordBotServiceABC +from cpl_translation import TranslatePipe from bot_core.service.message_service import MessageService from bot_data.model.level import Level @@ -27,7 +28,8 @@ class LevelService: users: UserRepositoryService, servers: ServerRepositoryService, bot: DiscordBotServiceABC, - message_service: MessageService + message_service: MessageService, + t: TranslatePipe ): self._config = config self._logger = logger @@ -37,6 +39,7 @@ class LevelService: self._servers = servers self._bot = bot self._message_service = message_service + self._t = t def get_level(self, user: User) -> Level: levels = self._levels.get_levels_by_server_id(user.server.server_id).order_by(lambda l: l.min_xp) @@ -73,7 +76,7 @@ class LevelService: level_settings: LevelServerSettings = self._config.get_configuration(f'LevelServerSettings_{guild.id}') await self._message_service.send_channel_message( self._bot.get_channel(level_settings.changed_level_notification_channel), - f'<@{member.id}> ist nun Level {level.name}', + self._t.transform('modules.level.new_level_message'.format(member.id, level.name)), is_persistent=True ) From 63000636a81b5c4bc2abe451f911dac337259733 Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Sun, 6 Nov 2022 22:46:15 +0100 Subject: [PATCH 15/15] Updated version of level project #25 --- kdb-bot/src/modules/level/level.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kdb-bot/src/modules/level/level.json b/kdb-bot/src/modules/level/level.json index 1d8d742502..7ceaa22524 100644 --- a/kdb-bot/src/modules/level/level.json +++ b/kdb-bot/src/modules/level/level.json @@ -2,7 +2,7 @@ "ProjectSettings": { "Name": "level", "Version": { - "Major": "0", + "Major": "1", "Minor": "0", "Micro": "0" },