0.3 - Levelsystem (#25) #92
@ -10,6 +10,7 @@
|
||||
"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",
|
||||
@ -18,7 +19,6 @@
|
||||
"set-version": "tools/set_version/set-version.json"
|
||||
},
|
||||
"Scripts": {
|
||||
|
||||
"sv": "cpl set-version",
|
||||
"set-version": "cpl run set-version $ARGS; echo '';",
|
||||
|
||||
@ -30,8 +30,10 @@
|
||||
|
||||
"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;",
|
||||
|
||||
|
@ -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')
|
||||
|
@ -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"
|
||||
]
|
||||
|
@ -8,7 +8,7 @@
|
||||
"LoggingSettings": {
|
||||
"Path": "logs/",
|
||||
"Filename": "bot.log",
|
||||
"ConsoleLogLevel": "TRACE",
|
||||
"ConsoleLogLevel": "DEBUG",
|
||||
"FileLogLevel": "TRACE"
|
||||
},
|
||||
"BotLoggingSettings": {
|
||||
@ -76,7 +76,12 @@
|
||||
},
|
||||
"BootLog": {
|
||||
"910199451145076828": {
|
||||
"LoginMessageChannelId": "910199452915093588"
|
||||
"LoginMessageChannelId": 910199452915093588
|
||||
}
|
||||
},
|
||||
"Level": {
|
||||
"910199451145076828": {
|
||||
"ChangedLevelNotificationChannelId": 910199452667637892
|
||||
}
|
||||
},
|
||||
"Permission": {
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -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,
|
||||
|
@ -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
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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": {
|
||||
}
|
||||
|
@ -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')
|
||||
|
@ -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')
|
||||
|
@ -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')
|
||||
|
@ -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')
|
||||
|
@ -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')
|
||||
|
@ -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')
|
||||
|
@ -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')
|
||||
|
@ -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')
|
||||
|
@ -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')
|
||||
|
@ -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')
|
||||
|
@ -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')
|
||||
|
@ -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')
|
||||
|
@ -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')
|
||||
|
@ -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')
|
||||
|
@ -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')
|
||||
|
@ -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')
|
||||
|
@ -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')
|
||||
|
@ -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')
|
||||
|
@ -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
|
||||
|
@ -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')
|
||||
|
@ -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')
|
||||
|
@ -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')
|
||||
|
@ -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')
|
||||
|
@ -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')
|
||||
|
@ -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')
|
||||
|
@ -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):
|
||||
|
@ -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')
|
||||
|
@ -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')
|
||||
|
10
kdb-bot/src/bot_data/abc/data_seeder_abc.py
Normal file
10
kdb-bot/src/bot_data/abc/data_seeder_abc.py
Normal file
@ -0,0 +1,10 @@
|
||||
from abc import ABC, abstractmethod
|
||||
|
||||
|
||||
class DataSeederABC(ABC):
|
||||
|
||||
@abstractmethod
|
||||
def __init__(self): pass
|
||||
|
||||
@abstractmethod
|
||||
def seed(self): pass
|
36
kdb-bot/src/bot_data/abc/level_repository_abc.py
Normal file
36
kdb-bot/src/bot_data/abc/level_repository_abc.py
Normal file
@ -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
|
@ -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,8 @@ 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.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
|
||||
@ -40,3 +43,6 @@ class DataModule(ModuleABC):
|
||||
services.add_transient(UserJoinedServerRepositoryABC, UserJoinedServerRepositoryService)
|
||||
services.add_transient(UserJoinedVoiceChannelRepositoryABC, UserJoinedVoiceChannelRepositoryService)
|
||||
services.add_transient(AutoRoleRepositoryABC, AutoRoleRepositoryService)
|
||||
services.add_transient(LevelRepositoryABC, LevelRepositoryService)
|
||||
|
||||
services.add_transient(SeederService)
|
||||
|
@ -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')
|
||||
|
37
kdb-bot/src/bot_data/migration/level_migration.py
Normal file
37
kdb-bot/src/bot_data/migration/level_migration.py
Normal file
@ -0,0 +1,37 @@
|
||||
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,
|
||||
`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`)
|
||||
);
|
||||
""")
|
||||
)
|
||||
|
||||
def downgrade(self):
|
||||
self._cursor.execute('DROP TABLE `Levels`;')
|
||||
|
@ -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')
|
||||
|
119
kdb-bot/src/bot_data/model/level.py
Normal file
119
kdb-bot/src/bot_data/model/level.py
Normal file
@ -0,0 +1,119 @@
|
||||
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) -> Server:
|
||||
return self._server
|
||||
|
||||
@server.setter
|
||||
def server(self, value: Server):
|
||||
self._server = value
|
||||
|
||||
@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(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}',
|
||||
`Color` = '{self._color}',
|
||||
`MinXp` = {self._min_xp},
|
||||
`PermissionInt` = {self._permissions},
|
||||
`LastModifiedAt` = '{self._modified_at}'
|
||||
WHERE `Id` = {self._id};
|
||||
""")
|
||||
|
||||
@property
|
||||
def delete_string(self) -> str:
|
||||
Ebola-Chan marked this conversation as resolved
|
||||
return str(f"""
|
||||
DELETE FROM `Levels`
|
||||
WHERE `Id` = {self._id};
|
||||
""")
|
@ -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')
|
||||
|
97
kdb-bot/src/bot_data/service/level_repository_service.py
Normal file
97
kdb-bot/src/bot_data/service/level_repository_service.py
Normal file
@ -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))
|
||||
|
||||
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)
|
25
kdb-bot/src/bot_data/service/seeder_service.py
Normal file
25
kdb-bot/src/bot_data/service/seeder_service.py
Normal file
@ -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()
|
@ -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')
|
||||
|
@ -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')
|
||||
|
@ -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')
|
||||
|
@ -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')
|
||||
|
@ -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')
|
||||
|
@ -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')
|
||||
|
@ -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')
|
||||
|
@ -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')
|
||||
|
@ -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')
|
||||
|
@ -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')
|
||||
|
@ -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')
|
||||
|
@ -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')
|
||||
|
@ -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')
|
||||
|
@ -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')
|
||||
|
@ -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')
|
||||
|
@ -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):
|
||||
|
@ -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()
|
||||
|
26
kdb-bot/src/modules/level/__init__.py
Normal file
26
kdb-bot/src/modules/level/__init__.py
Normal file
@ -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.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')
|
26
kdb-bot/src/modules/level/configuration/__init__.py
Normal file
26
kdb-bot/src/modules/level/configuration/__init__.py
Normal file
@ -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.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')
|
@ -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()}')
|
@ -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()}')
|
32
kdb-bot/src/modules/level/configuration/level_settings.py
Normal file
32
kdb-bot/src/modules/level/configuration/level_settings.py
Normal file
@ -0,0 +1,32 @@
|
||||
import traceback
|
||||
|
||||
from cpl_core.configuration.configuration_model_abc import ConfigurationModelABC
|
||||
from cpl_core.console import Console
|
||||
from cpl_query.extension import List
|
||||
|
||||
from modules.level.configuration.level_server_settings import LevelServerSettings
|
||||
|
||||
|
||||
class LevelSettings(ConfigurationModelABC):
|
||||
|
||||
def __init__(self):
|
||||
ConfigurationModelABC.__init__(self)
|
||||
|
||||
self._servers: List[LevelServerSettings] = List()
|
||||
|
||||
@property
|
||||
def servers(self) -> List[LevelServerSettings]:
|
||||
return self._servers
|
||||
|
||||
def from_dict(self, settings: dict):
|
||||
try:
|
||||
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()}')
|
31
kdb-bot/src/modules/level/default-level.json
Normal file
31
kdb-bot/src/modules/level/default-level.json
Normal file
@ -0,0 +1,31 @@
|
||||
{
|
||||
"DefaultLevel": {
|
||||
"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
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
26
kdb-bot/src/modules/level/events/__init__.py
Normal file
26
kdb-bot/src/modules/level/events/__init__.py
Normal file
@ -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.level.events'
|
||||
__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')
|
21
kdb-bot/src/modules/level/events/level_on_message_event.py
Normal file
21
kdb-bot/src/modules/level/events/level_on_message_event.py
Normal file
@ -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)
|
@ -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)
|
46
kdb-bot/src/modules/level/level.json
Normal file
46
kdb-bot/src/modules/level/level.json
Normal file
@ -0,0 +1,46 @@
|
||||
{
|
||||
"ProjectSettings": {
|
||||
"Name": "level",
|
||||
"Version": {
|
||||
"Major": "1",
|
||||
"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": []
|
||||
}
|
||||
}
|
33
kdb-bot/src/modules/level/level_module.py
Normal file
33
kdb-bot/src/modules/level/level_module.py
Normal file
@ -0,0 +1,33 @@
|
||||
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
|
||||
|
||||
|
||||
class LevelModule(ModuleABC):
|
||||
|
||||
def __init__(self, dc: DiscordCollectionABC):
|
||||
ModuleABC.__init__(self, dc, FeatureFlagsEnum.level_module)
|
||||
|
||||
def configure_configuration(self, config: ConfigurationABC, env: ApplicationEnvironmentABC):
|
||||
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, 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)
|
83
kdb-bot/src/modules/level/level_seeder.py
Normal file
83
kdb-bot/src/modules/level/level_seeder.py
Normal file
@ -0,0 +1,83 @@
|
||||
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.default_level_settings import DefaultLevelSettings
|
||||
|
||||
|
||||
class LevelSeeder(DataSeederABC):
|
||||
|
||||
def __init__(self, logger: DatabaseLogger, levels: DefaultLevelSettings, level_repo: LevelRepositoryService, servers: ServerRepositoryABC, bot: DiscordBotServiceABC):
|
||||
DataSeederABC.__init__(self)
|
||||
|
||||
self._logger = logger
|
||||
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).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))
|
||||
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):
|
||||
# create levels
|
||||
for guild in self._bot.guilds:
|
||||
created_default = False
|
||||
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:
|
||||
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
|
||||
|
||||
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
|
||||
|
||||
new_position = position_above_levels - (levels.index(levels.where(lambda l: l.name == role.name).single()) + 1)
|
||||
if new_position <= 0:
|
||||
new_position = 1
|
||||
try:
|
||||
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'Cannot change position of {role.name}', e)
|
||||
|
||||
self._logger.debug(__name__, f'Checked role order')
|
26
kdb-bot/src/modules/level/service/__init__.py
Normal file
26
kdb-bot/src/modules/level/service/__init__.py
Normal file
@ -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.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')
|
92
kdb-bot/src/modules/level/service/level_service.py
Normal file
92
kdb-bot/src/modules/level/service/level_service.py
Normal file
@ -0,0 +1,92 @@
|
||||
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 cpl_translation import TranslatePipe
|
||||
|
||||
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,
|
||||
message_service: MessageService,
|
||||
t: TranslatePipe
|
||||
):
|
||||
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
|
||||
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)
|
||||
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()
|
||||
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
|
||||
|
||||
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)
|
||||
|
||||
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),
|
||||
self._t.transform('modules.level.new_level_message'.format(member.id, level.name)),
|
||||
is_persistent=True
|
||||
)
|
||||
|
||||
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)
|
@ -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')
|
||||
|
@ -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')
|
||||
|
@ -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')
|
||||
|
@ -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')
|
||||
|
@ -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')
|
||||
|
@ -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')
|
||||
|
@ -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')
|
||||
|
Loading…
Reference in New Issue
Block a user
Evtl noch ein
und
zu
unbenennen?
Da wäre noch die Frage wegen der Konsistenz: Wollen wir wie bei den Get-Strings nur die ID übergeben oder "self"?
Sollte der Bot von z.B. einem Server genommen werden, können die Level zu den Server schnell und einfach gepurged werden.
Evtl kann dies auch zu einem kleinen Ticket werden
Aktuell wollen wir den Fall nicht abdecken, dass der Bot einen Server verlässt bzw. ignorieren dass. So kann der Bot zukünftig wiedergeholt werden und die "Konfig" ist dann nicht weg.
Daher halte ich den vorschlag nicht für brauchbar. Des weiteren wäre mein Ansatz an stelle das ganze aus Python zu machen (wegen Logging und so).