Compare commits
86 Commits
9db00516c3
...
1.1.1
Author | SHA1 | Date | |
---|---|---|---|
9ec65689ba | |||
44f5de32a5 | |||
c016d5fc84 | |||
306ce2664c | |||
3ce5471ef4 | |||
4cdd6c05bf | |||
d364ea1b4c | |||
6fa08ea828 | |||
296c6e8044 | |||
0541f3dfde | |||
052e0f976a | |||
f41dfc9be2 | |||
74437fdc20 | |||
df2b660b75 | |||
12f231aa41 | |||
2f3ae229c9 | |||
5bbed854a4 | |||
2321c12bc9 | |||
1cdfd1291f | |||
223946ad76 | |||
4ea1b5b94c | |||
919970d199 | |||
19ed164845 | |||
92001a45be | |||
78b761a672 | |||
7bfa39f459 | |||
d586cca672 | |||
efce172c01 | |||
0974325148 | |||
206754919f | |||
b49512e28d | |||
fa71759a20 | |||
9338e35504 | |||
2956dcb9c2 | |||
762bebf416 | |||
f3b5cef253 | |||
6869c5a671 | |||
352b44be0f | |||
5912708d3a | |||
45a3127696 | |||
10c20621a8 | |||
49e0e44461 | |||
ec6b080ba6 | |||
28944755ac | |||
7318239b2d | |||
cf66d246a9 | |||
41fe6faa52 | |||
685c96bb38 | |||
2c3e5268e4 | |||
2d5ce58612 | |||
fe3d67eff5 | |||
4cea31fce5 | |||
aa2c80ec12 | |||
e283a18def | |||
f5b2bec356 | |||
c2b32996fd | |||
195566a2b6 | |||
073c318671 | |||
caeec47b7c | |||
44f6b36347 | |||
4e32414f48 | |||
573c9c999e | |||
825fcff82d | |||
a95bf7bc6c | |||
0bc3bff58e | |||
c3b86fab6b | |||
906602134e | |||
30791f7529 | |||
456d939b47 | |||
1f47636e8d | |||
f4acc2669d | |||
46b5757fd1 | |||
1cd75cd78f | |||
f7f3fea7a7 | |||
5dd2000f10 | |||
1b2bb85b37 | |||
113b188a40 | |||
e549341196 | |||
8a0d939147 | |||
4b57d7f102 | |||
02e0c72a80 | |||
bfc9979961 | |||
8d76f79732 | |||
4add293186 | |||
1fc5ef76a6 | |||
e6c9959381 |
@@ -11,7 +11,7 @@
|
||||
"auto-role": "src/modules/auto_role/auto-role.json",
|
||||
"base": "src/modules/base/base.json",
|
||||
"boot-log": "src/modules/boot_log/boot-log.json",
|
||||
"config": "src/modules/config/modules/config.json",
|
||||
"config": "src/modules/config/config.json",
|
||||
"database": "src/modules/database/database.json",
|
||||
"level": "src/modules/level/level.json",
|
||||
"permission": "src/modules/permission/permission.json",
|
||||
|
Submodule kdb-bot/docker updated: 62475d6546...3107817939
@@ -15,7 +15,7 @@ __title__ = "bot"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.0.7"
|
||||
__version__ = "1.1.1"
|
||||
|
||||
from collections import namedtuple
|
||||
|
||||
@@ -23,4 +23,4 @@ from collections import namedtuple
|
||||
# imports:
|
||||
|
||||
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
||||
version_info = VersionInfo(major="1", minor="0", micro="7")
|
||||
version_info = VersionInfo(major="1", minor="1", micro="1")
|
||||
|
@@ -71,7 +71,7 @@ class Application(DiscordBotApplicationABC):
|
||||
self._api.stop()
|
||||
|
||||
await self._bot.close()
|
||||
self._data_integrity.check_data_integrity(is_for_shutdown=True)
|
||||
await self._data_integrity.check_data_integrity(is_for_shutdown=True)
|
||||
self._logger.info(__name__, f"Stopped {DiscordBotService.__name__}")
|
||||
except Exception as e:
|
||||
self._logger.error(__name__, "stop failed", e)
|
||||
|
@@ -3,8 +3,8 @@
|
||||
"Name": "bot",
|
||||
"Version": {
|
||||
"Major": "1",
|
||||
"Minor": "0",
|
||||
"Micro": "7"
|
||||
"Minor": "1",
|
||||
"Micro": "1"
|
||||
},
|
||||
"Author": "Sven Heidemann",
|
||||
"AuthorEmail": "sven.heidemann@sh-edraft.de",
|
||||
@@ -30,7 +30,8 @@
|
||||
"requests-oauthlib==1.3.1",
|
||||
"icmplib==3.0.3",
|
||||
"ariadne==0.20.1",
|
||||
"cryptography==41.0.2"
|
||||
"cryptography==41.0.2",
|
||||
"discord>=2.3.2"
|
||||
],
|
||||
"DevDependencies": [
|
||||
"cpl-cli==2023.4.0.post3",
|
||||
@@ -59,9 +60,11 @@
|
||||
"../bot_core/bot-core.json",
|
||||
"../bot_data/bot-data.json",
|
||||
"../bot_graphql/bot-graphql.json",
|
||||
"../modules/achievements/achievements.json",
|
||||
"../modules/auto_role/auto-role.json",
|
||||
"../modules/base/base.json",
|
||||
"../modules/boot_log/boot-log.json",
|
||||
"../modules/config/config.json",
|
||||
"../modules/database/database.json",
|
||||
"../modules/level/level.json",
|
||||
"../modules/permission/permission.json",
|
||||
|
Submodule kdb-bot/src/bot/config updated: 359f9c38c3...23eafb2e21
@@ -15,7 +15,7 @@ __title__ = "bot.extension"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.0.7"
|
||||
__version__ = "1.1.1"
|
||||
|
||||
from collections import namedtuple
|
||||
|
||||
@@ -23,4 +23,4 @@ from collections import namedtuple
|
||||
# imports:
|
||||
|
||||
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
||||
version_info = VersionInfo(major="1", minor="0", micro="7")
|
||||
version_info = VersionInfo(major="1", minor="1", micro="1")
|
||||
|
@@ -31,10 +31,10 @@ class Program:
|
||||
.use_extension(StartupDiscordExtension)
|
||||
.use_extension(StartupModuleExtension)
|
||||
.use_extension(StartupMigrationExtension)
|
||||
.use_extension(DatabaseExtension)
|
||||
.use_extension(ConfigExtension)
|
||||
.use_extension(InitBotExtension)
|
||||
.use_extension(BootLogExtension)
|
||||
.use_extension(DatabaseExtension)
|
||||
.use_extension(AppApiExtension)
|
||||
.use_extension(CoreExtension)
|
||||
.use_startup(Startup)
|
||||
|
@@ -25,8 +25,8 @@ class ModuleList:
|
||||
[
|
||||
CoreModule, # has to be first!
|
||||
DataModule,
|
||||
ConfigModule, # has to be before db check
|
||||
DatabaseModule,
|
||||
ConfigModule, # has be to after db check
|
||||
GraphQLModule,
|
||||
PermissionModule,
|
||||
AutoRoleModule,
|
||||
|
@@ -9,6 +9,7 @@ from bot_data.migration.api_key_migration import ApiKeyMigration
|
||||
from bot_data.migration.api_migration import ApiMigration
|
||||
from bot_data.migration.auto_role_fix1_migration import AutoRoleFix1Migration
|
||||
from bot_data.migration.auto_role_migration import AutoRoleMigration
|
||||
from bot_data.migration.config_feature_flags_migration import ConfigFeatureFlagsMigration
|
||||
from bot_data.migration.config_migration import ConfigMigration
|
||||
from bot_data.migration.db_history_migration import DBHistoryMigration
|
||||
from bot_data.migration.initial_migration import InitialMigration
|
||||
@@ -46,3 +47,4 @@ class StartupMigrationExtension(StartupExtensionABC):
|
||||
services.add_transient(MigrationABC, DBHistoryMigration) # 06.03.2023 #246 - 1.0.0
|
||||
services.add_transient(MigrationABC, AchievementsMigration) # 14.06.2023 #268 - 1.1.0
|
||||
services.add_transient(MigrationABC, ConfigMigration) # 19.07.2023 #127 - 1.1.0
|
||||
services.add_transient(MigrationABC, ConfigFeatureFlagsMigration) # 15.08.2023 #334 - 1.1.0
|
||||
|
@@ -15,7 +15,7 @@ __title__ = "bot_api"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.0.7"
|
||||
__version__ = "1.1.1"
|
||||
|
||||
from collections import namedtuple
|
||||
|
||||
@@ -23,4 +23,4 @@ from collections import namedtuple
|
||||
# imports:
|
||||
|
||||
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
||||
version_info = VersionInfo(major="1", minor="0", micro="7")
|
||||
version_info = VersionInfo(major="1", minor="1", micro="1")
|
||||
|
@@ -15,7 +15,7 @@ __title__ = "bot_api.abc"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.0.7"
|
||||
__version__ = "1.1.1"
|
||||
|
||||
from collections import namedtuple
|
||||
|
||||
@@ -23,4 +23,4 @@ from collections import namedtuple
|
||||
# imports:
|
||||
|
||||
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
||||
version_info = VersionInfo(major="1", minor="0", micro="7")
|
||||
version_info = VersionInfo(major="1", minor="1", micro="1")
|
||||
|
@@ -3,8 +3,8 @@
|
||||
"Name": "bot-api",
|
||||
"Version": {
|
||||
"Major": "1",
|
||||
"Minor": "0",
|
||||
"Micro": "7"
|
||||
"Minor": "1",
|
||||
"Micro": "1"
|
||||
},
|
||||
"Author": "",
|
||||
"AuthorEmail": "",
|
||||
|
Submodule kdb-bot/src/bot_api/config updated: 6d3f253f41...3d81c81c9e
@@ -15,7 +15,7 @@ __title__ = "bot_api.configuration"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.0.7"
|
||||
__version__ = "1.1.1"
|
||||
|
||||
from collections import namedtuple
|
||||
|
||||
@@ -23,4 +23,4 @@ from collections import namedtuple
|
||||
# imports
|
||||
|
||||
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
||||
version_info = VersionInfo(major="1", minor="0", micro="7")
|
||||
version_info = VersionInfo(major="1", minor="1", micro="1")
|
||||
|
@@ -15,7 +15,7 @@ __title__ = "bot_api.controller"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.0.7"
|
||||
__version__ = "1.1.1"
|
||||
|
||||
from collections import namedtuple
|
||||
|
||||
@@ -23,4 +23,4 @@ from collections import namedtuple
|
||||
# imports:
|
||||
|
||||
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
||||
version_info = VersionInfo(major="1", minor="0", micro="7")
|
||||
version_info = VersionInfo(major="1", minor="1", micro="1")
|
||||
|
@@ -15,7 +15,7 @@ __title__ = "bot_api.event"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.0.7"
|
||||
__version__ = "1.1.1"
|
||||
|
||||
from collections import namedtuple
|
||||
|
||||
@@ -23,4 +23,4 @@ from collections import namedtuple
|
||||
# imports:
|
||||
|
||||
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
||||
version_info = VersionInfo(major="1", minor="0", micro="7")
|
||||
version_info = VersionInfo(major="1", minor="1", micro="1")
|
||||
|
@@ -15,7 +15,7 @@ __title__ = "bot_api.exception"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.0.7"
|
||||
__version__ = "1.1.1"
|
||||
|
||||
from collections import namedtuple
|
||||
|
||||
@@ -23,4 +23,4 @@ from collections import namedtuple
|
||||
# imports:
|
||||
|
||||
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
||||
version_info = VersionInfo(major="1", minor="0", micro="7")
|
||||
version_info = VersionInfo(major="1", minor="1", micro="1")
|
||||
|
@@ -15,7 +15,7 @@ __title__ = "bot_api.filter"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.0.7"
|
||||
__version__ = "1.1.1"
|
||||
|
||||
from collections import namedtuple
|
||||
|
||||
@@ -23,4 +23,4 @@ from collections import namedtuple
|
||||
# imports:
|
||||
|
||||
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
||||
version_info = VersionInfo(major="1", minor="0", micro="7")
|
||||
version_info = VersionInfo(major="1", minor="1", micro="1")
|
||||
|
@@ -15,7 +15,7 @@ __title__ = "bot_api.filter.discord"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.0.7"
|
||||
__version__ = "1.1.1"
|
||||
|
||||
from collections import namedtuple
|
||||
|
||||
@@ -23,4 +23,4 @@ from collections import namedtuple
|
||||
# imports:
|
||||
|
||||
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
||||
version_info = VersionInfo(major="1", minor="0", micro="7")
|
||||
version_info = VersionInfo(major="1", minor="1", micro="1")
|
||||
|
@@ -15,7 +15,7 @@ __title__ = "bot_api.logging"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.0.7"
|
||||
__version__ = "1.1.1"
|
||||
|
||||
from collections import namedtuple
|
||||
|
||||
@@ -23,4 +23,4 @@ from collections import namedtuple
|
||||
# imports:
|
||||
|
||||
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
||||
version_info = VersionInfo(major="1", minor="0", micro="7")
|
||||
version_info = VersionInfo(major="1", minor="1", micro="1")
|
||||
|
@@ -15,7 +15,7 @@ __title__ = "bot_api.model"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.0.7"
|
||||
__version__ = "1.1.1"
|
||||
|
||||
from collections import namedtuple
|
||||
|
||||
@@ -23,4 +23,4 @@ from collections import namedtuple
|
||||
# imports:
|
||||
|
||||
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
||||
version_info = VersionInfo(major="1", minor="0", micro="7")
|
||||
version_info = VersionInfo(major="1", minor="1", micro="1")
|
||||
|
@@ -15,7 +15,7 @@ __title__ = "bot_api.model.discord"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.0.7"
|
||||
__version__ = "1.1.1"
|
||||
|
||||
from collections import namedtuple
|
||||
|
||||
@@ -23,4 +23,4 @@ from collections import namedtuple
|
||||
# imports:
|
||||
|
||||
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
||||
version_info = VersionInfo(major="1", minor="0", micro="7")
|
||||
version_info = VersionInfo(major="1", minor="1", micro="1")
|
||||
|
@@ -15,7 +15,7 @@ __title__ = "bot_api.route"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.0.7"
|
||||
__version__ = "1.1.1"
|
||||
|
||||
from collections import namedtuple
|
||||
|
||||
@@ -23,4 +23,4 @@ from collections import namedtuple
|
||||
# imports:
|
||||
|
||||
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
||||
version_info = VersionInfo(major="1", minor="0", micro="7")
|
||||
version_info = VersionInfo(major="1", minor="1", micro="1")
|
||||
|
@@ -15,7 +15,7 @@ __title__ = "bot_api.service"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.0.7"
|
||||
__version__ = "1.1.1"
|
||||
|
||||
from collections import namedtuple
|
||||
|
||||
@@ -23,4 +23,4 @@ from collections import namedtuple
|
||||
# imports
|
||||
|
||||
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
||||
version_info = VersionInfo(major="1", minor="0", micro="7")
|
||||
version_info = VersionInfo(major="1", minor="1", micro="1")
|
||||
|
@@ -15,7 +15,7 @@ __title__ = "bot_api.transformer"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.0.7"
|
||||
__version__ = "1.1.1"
|
||||
|
||||
from collections import namedtuple
|
||||
|
||||
@@ -23,4 +23,4 @@ from collections import namedtuple
|
||||
# imports:
|
||||
|
||||
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
||||
version_info = VersionInfo(major="1", minor="0", micro="7")
|
||||
version_info = VersionInfo(major="1", minor="1", micro="1")
|
||||
|
@@ -15,7 +15,7 @@ __title__ = "bot_core"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.0.7"
|
||||
__version__ = "1.1.1"
|
||||
|
||||
from collections import namedtuple
|
||||
|
||||
@@ -23,4 +23,4 @@ from collections import namedtuple
|
||||
# imports
|
||||
|
||||
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
||||
version_info = VersionInfo(major="1", minor="0", micro="7")
|
||||
version_info = VersionInfo(major="1", minor="1", micro="1")
|
||||
|
@@ -15,7 +15,7 @@ __title__ = "bot_core.abc"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.0.7"
|
||||
__version__ = "1.1.1"
|
||||
|
||||
from collections import namedtuple
|
||||
|
||||
@@ -23,4 +23,4 @@ from collections import namedtuple
|
||||
# imports:
|
||||
|
||||
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
||||
version_info = VersionInfo(major="1", minor="0", micro="7")
|
||||
version_info = VersionInfo(major="1", minor="1", micro="1")
|
||||
|
@@ -3,8 +3,8 @@
|
||||
"Name": "bot-core",
|
||||
"Version": {
|
||||
"Major": "1",
|
||||
"Minor": "0",
|
||||
"Micro": "7"
|
||||
"Minor": "1",
|
||||
"Micro": "1"
|
||||
},
|
||||
"Author": "Sven Heidemann",
|
||||
"AuthorEmail": "sven.heidemann@sh-edraft.de",
|
||||
|
@@ -15,7 +15,7 @@ __title__ = "bot_core.configuration"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.0.7"
|
||||
__version__ = "1.1.1"
|
||||
|
||||
from collections import namedtuple
|
||||
|
||||
@@ -23,4 +23,4 @@ from collections import namedtuple
|
||||
# imports:
|
||||
|
||||
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
||||
version_info = VersionInfo(major="1", minor="0", micro="7")
|
||||
version_info = VersionInfo(major="1", minor="1", micro="1")
|
||||
|
@@ -5,18 +5,17 @@ class FeatureFlagsEnum(Enum):
|
||||
# modules
|
||||
achievements_module = "AchievementsModule"
|
||||
api_module = "ApiModule"
|
||||
admin_module = "AdminModule"
|
||||
auto_role_module = "AutoRoleModule"
|
||||
base_module = "BaseModule"
|
||||
boot_log_module = "BootLogModule"
|
||||
core_module = "CoreModule"
|
||||
core_extension_module = "CoreExtensionModule"
|
||||
config_module = "ConfigModule"
|
||||
data_module = "DataModule"
|
||||
database_module = "DatabaseModule"
|
||||
level_module = "LevelModule"
|
||||
moderator_module = "ModeratorModule"
|
||||
permission_module = "PermissionModule"
|
||||
config_module = "ConfigModule"
|
||||
# features
|
||||
api_only = "ApiOnly"
|
||||
presence = "Presence"
|
||||
|
@@ -8,8 +8,7 @@ class FeatureFlagsSettings(ConfigurationModelABC):
|
||||
# modules
|
||||
FeatureFlagsEnum.achievements_module.value: False, # 14.06.2023 #268
|
||||
FeatureFlagsEnum.api_module.value: False, # 13.10.2022 #70
|
||||
FeatureFlagsEnum.admin_module.value: False, # 02.10.2022 #48
|
||||
FeatureFlagsEnum.auto_role_module.value: True, # 03.10.2022 #54
|
||||
FeatureFlagsEnum.auto_role_module.value: False, # 03.10.2022 #54
|
||||
FeatureFlagsEnum.base_module.value: True, # 02.10.2022 #48
|
||||
FeatureFlagsEnum.boot_log_module.value: True, # 02.10.2022 #48
|
||||
FeatureFlagsEnum.core_module.value: True, # 03.10.2022 #56
|
||||
@@ -34,6 +33,17 @@ class FeatureFlagsSettings(ConfigurationModelABC):
|
||||
for flag in [f.value for f in FeatureFlagsEnum]:
|
||||
self._load_flag(kwargs, FeatureFlagsEnum(flag))
|
||||
|
||||
@classmethod
|
||||
def get_flag_from_dict(cls, flags: dict, key: FeatureFlagsEnum) -> bool:
|
||||
def get_flag():
|
||||
if key.value not in cls._flags:
|
||||
return False
|
||||
return cls._flags[key.value]
|
||||
|
||||
if key.value not in flags:
|
||||
return get_flag()
|
||||
return flags[key.value]
|
||||
|
||||
def get_flag(self, key: FeatureFlagsEnum) -> bool:
|
||||
if key.value not in self._flags:
|
||||
return False
|
||||
|
@@ -15,7 +15,7 @@ __title__ = "bot_core.core_extension"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.0.7"
|
||||
__version__ = "1.1.1"
|
||||
|
||||
from collections import namedtuple
|
||||
|
||||
@@ -23,4 +23,4 @@ from collections import namedtuple
|
||||
# imports:
|
||||
|
||||
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
||||
version_info = VersionInfo(major="1", minor="0", micro="7")
|
||||
version_info = VersionInfo(major="1", minor="1", micro="1")
|
||||
|
@@ -11,6 +11,7 @@ from bot_core.configuration.feature_flags_enum import FeatureFlagsEnum
|
||||
from bot_core.events.core_on_ready_event import CoreOnReadyEvent
|
||||
from bot_core.pipes.date_time_offset_pipe import DateTimeOffsetPipe
|
||||
from bot_core.service.client_utils_service import ClientUtilsService
|
||||
from bot_core.service.config_service import ConfigService
|
||||
from bot_core.service.data_integrity_service import DataIntegrityService
|
||||
from bot_core.service.message_service import MessageService
|
||||
|
||||
@@ -23,6 +24,7 @@ class CoreModule(ModuleABC):
|
||||
pass
|
||||
|
||||
def configure_services(self, services: ServiceCollectionABC, env: ApplicationEnvironmentABC):
|
||||
services.add_transient(ConfigService)
|
||||
services.add_transient(MessageServiceABC, MessageService)
|
||||
services.add_transient(ClientUtilsABC, ClientUtilsService)
|
||||
services.add_transient(DataIntegrityService)
|
||||
|
@@ -15,7 +15,7 @@ __title__ = "bot_core.events"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.0.7"
|
||||
__version__ = "1.1.1"
|
||||
|
||||
from collections import namedtuple
|
||||
|
||||
@@ -23,4 +23,4 @@ from collections import namedtuple
|
||||
# imports:
|
||||
|
||||
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
||||
version_info = VersionInfo(major="1", minor="0", micro="7")
|
||||
version_info = VersionInfo(major="1", minor="1", micro="1")
|
||||
|
@@ -15,7 +15,7 @@ __title__ = "bot_core.exception"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.0.7"
|
||||
__version__ = "1.1.1"
|
||||
|
||||
from collections import namedtuple
|
||||
|
||||
@@ -23,4 +23,4 @@ from collections import namedtuple
|
||||
# imports:
|
||||
|
||||
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
||||
version_info = VersionInfo(major="1", minor="0", micro="7")
|
||||
version_info = VersionInfo(major="1", minor="1", micro="1")
|
||||
|
@@ -15,7 +15,7 @@ __title__ = "bot_core.helper"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.0.7"
|
||||
__version__ = "1.1.1"
|
||||
|
||||
from collections import namedtuple
|
||||
|
||||
@@ -23,4 +23,4 @@ from collections import namedtuple
|
||||
# imports:
|
||||
|
||||
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
||||
version_info = VersionInfo(major="1", minor="0", micro="7")
|
||||
version_info = VersionInfo(major="1", minor="1", micro="1")
|
||||
|
@@ -15,7 +15,7 @@ __title__ = "bot_core.logging"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.0.7"
|
||||
__version__ = "1.1.1"
|
||||
|
||||
from collections import namedtuple
|
||||
|
||||
@@ -23,4 +23,4 @@ from collections import namedtuple
|
||||
# imports
|
||||
|
||||
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
||||
version_info = VersionInfo(major="1", minor="0", micro="7")
|
||||
version_info = VersionInfo(major="1", minor="1", micro="1")
|
||||
|
@@ -15,7 +15,7 @@ __title__ = "bot_core.pipes"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.0.7"
|
||||
__version__ = "1.1.1"
|
||||
|
||||
from collections import namedtuple
|
||||
|
||||
@@ -23,4 +23,4 @@ from collections import namedtuple
|
||||
# imports
|
||||
|
||||
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
||||
version_info = VersionInfo(major="1", minor="0", micro="7")
|
||||
version_info = VersionInfo(major="1", minor="1", micro="1")
|
||||
|
@@ -15,7 +15,7 @@ __title__ = "bot_core.service"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.0.7"
|
||||
__version__ = "1.1.1"
|
||||
|
||||
from collections import namedtuple
|
||||
|
||||
@@ -23,4 +23,4 @@ from collections import namedtuple
|
||||
# imports:
|
||||
|
||||
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
||||
version_info = VersionInfo(major="1", minor="0", micro="7")
|
||||
version_info = VersionInfo(major="1", minor="1", micro="1")
|
||||
|
50
kdb-bot/src/bot_core/service/config_service.py
Normal file
50
kdb-bot/src/bot_core/service/config_service.py
Normal file
@@ -0,0 +1,50 @@
|
||||
from cpl_core.configuration import ConfigurationABC
|
||||
from cpl_core.dependency_injection import ServiceProviderABC
|
||||
|
||||
from bot_core.configuration.feature_flags_settings import FeatureFlagsSettings
|
||||
from bot_data.abc.server_config_repository_abc import ServerConfigRepositoryABC
|
||||
from bot_data.abc.technician_config_repository_abc import TechnicianConfigRepositoryABC
|
||||
from bot_data.model.server import Server
|
||||
from bot_data.model.technician_config import TechnicianConfig
|
||||
from bot_data.service.server_config_seeder import ServerConfigSeeder
|
||||
from bot_data.service.technician_config_seeder import TechnicianConfigSeeder
|
||||
from modules.permission.abc.permission_service_abc import PermissionServiceABC
|
||||
|
||||
|
||||
class ConfigService:
|
||||
def __init__(
|
||||
self,
|
||||
config: ConfigurationABC,
|
||||
services: ServiceProviderABC,
|
||||
technician_config_repo: TechnicianConfigRepositoryABC,
|
||||
server_config_repo: ServerConfigRepositoryABC,
|
||||
tech_seeder: TechnicianConfigSeeder,
|
||||
server_seeder: ServerConfigSeeder,
|
||||
):
|
||||
self._config = config
|
||||
self._services = services
|
||||
self._technician_config_repo = technician_config_repo
|
||||
self._server_config_repo = server_config_repo
|
||||
|
||||
self._tech_seeder = tech_seeder
|
||||
self._server_seeder = server_seeder
|
||||
|
||||
async def reload_technician_config(self):
|
||||
if not self._technician_config_repo.does_technician_config_exists():
|
||||
await self._tech_seeder.seed()
|
||||
|
||||
technician_config = self._technician_config_repo.get_technician_config()
|
||||
self._config.add_configuration(TechnicianConfig, technician_config)
|
||||
self._config.add_configuration(FeatureFlagsSettings, FeatureFlagsSettings(**technician_config.feature_flags))
|
||||
|
||||
async def reload_server_config(self, server: Server):
|
||||
if not self._server_config_repo.does_server_config_exists(server.id):
|
||||
await self._server_seeder.seed()
|
||||
|
||||
server_config = self._server_config_repo.get_server_config_by_server(server.id)
|
||||
self._config.add_configuration(
|
||||
f"{type(server_config).__name__}_{server_config.server.discord_id}", server_config
|
||||
)
|
||||
|
||||
permissions: PermissionServiceABC = self._services.get_service(PermissionServiceABC)
|
||||
permissions.on_ready()
|
@@ -291,7 +291,7 @@ class DataIntegrityService:
|
||||
self._user_joins_vc.update_user_joined_voice_channel(join)
|
||||
|
||||
if self._is_for_shutdown:
|
||||
user.xp = round(join.time * settings.xp_per_ontime_hour)
|
||||
user.xp += round(join.time * settings.xp_per_ontime_hour)
|
||||
self._users.update_user(user)
|
||||
|
||||
self._db_context.save_changes()
|
||||
@@ -356,14 +356,14 @@ class DataIntegrityService:
|
||||
|
||||
self._user_joined_gs.update_user_joined_game_server(join)
|
||||
if self._is_for_shutdown:
|
||||
user.xp = round(join.time * settings.xp_per_ontime_hour)
|
||||
user.xp += round(join.time * settings.xp_per_ontime_hour)
|
||||
self._users.update_user(user)
|
||||
|
||||
self._db_context.save_changes()
|
||||
except Exception as e:
|
||||
self._logger.error(__name__, f"Cannot get UserJoinedGameServer", e)
|
||||
|
||||
def _check_for_user_achievements(self):
|
||||
async def _check_for_user_achievements(self):
|
||||
self._logger.debug(__name__, f"Start checking UserGotAchievement table")
|
||||
|
||||
for guild in self._bot.guilds:
|
||||
@@ -380,9 +380,9 @@ class DataIntegrityService:
|
||||
if user is None:
|
||||
self._logger.fatal(__name__, f"User not found in database: {member.id}")
|
||||
|
||||
self._bot.loop.create_task(self._achievements.validate_achievements_for_user(user))
|
||||
await self._achievements.validate_achievements_for_user(user)
|
||||
|
||||
def check_data_integrity(self, is_for_shutdown=False):
|
||||
async def check_data_integrity(self, is_for_shutdown=False):
|
||||
if is_for_shutdown != self._is_for_shutdown:
|
||||
self._is_for_shutdown = is_for_shutdown
|
||||
|
||||
@@ -393,4 +393,4 @@ class DataIntegrityService:
|
||||
self._check_user_joins()
|
||||
self._check_user_joins_vc()
|
||||
self._check_user_joined_gs()
|
||||
self._check_for_user_achievements()
|
||||
await self._check_for_user_achievements()
|
||||
|
@@ -15,7 +15,7 @@ __title__ = "bot_data"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.0.7"
|
||||
__version__ = "1.1.1"
|
||||
|
||||
from collections import namedtuple
|
||||
|
||||
@@ -23,4 +23,4 @@ from collections import namedtuple
|
||||
# imports
|
||||
|
||||
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
||||
version_info = VersionInfo(major="1", minor="0", micro="7")
|
||||
version_info = VersionInfo(major="1", minor="1", micro="1")
|
||||
|
@@ -15,7 +15,7 @@ __title__ = "bot_data.abc"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.0.7"
|
||||
__version__ = "1.1.1"
|
||||
|
||||
from collections import namedtuple
|
||||
|
||||
@@ -23,4 +23,4 @@ from collections import namedtuple
|
||||
# imports
|
||||
|
||||
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
||||
version_info = VersionInfo(major="1", minor="0", micro="7")
|
||||
version_info = VersionInfo(major="1", minor="1", micro="1")
|
||||
|
@@ -3,8 +3,8 @@
|
||||
"Name": "bot-data",
|
||||
"Version": {
|
||||
"Major": "1",
|
||||
"Minor": "0",
|
||||
"Micro": "7"
|
||||
"Minor": "1",
|
||||
"Micro": "1"
|
||||
},
|
||||
"Author": "Sven Heidemann",
|
||||
"AuthorEmail": "sven.heidemann@sh-edraft.de",
|
||||
|
@@ -15,7 +15,7 @@ __title__ = "bot_data.migration"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.0.7"
|
||||
__version__ = "1.1.1"
|
||||
|
||||
from collections import namedtuple
|
||||
|
||||
@@ -23,4 +23,4 @@ from collections import namedtuple
|
||||
# imports
|
||||
|
||||
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
||||
version_info = VersionInfo(major="1", minor="0", micro="7")
|
||||
version_info = VersionInfo(major="1", minor="1", micro="1")
|
||||
|
@@ -0,0 +1,29 @@
|
||||
from bot_core.logging.database_logger import DatabaseLogger
|
||||
from bot_data.abc.migration_abc import MigrationABC
|
||||
from bot_data.db_context import DBContext
|
||||
|
||||
|
||||
class ConfigFeatureFlagsMigration(MigrationABC):
|
||||
name = "1.1.0_ConfigFeatureFlagsMigration"
|
||||
|
||||
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("""ALTER TABLE CFG_Technician ADD FeatureFlags JSON NULL DEFAULT ('{}') AFTER CacheMaxMessages;""")
|
||||
)
|
||||
|
||||
self._cursor.execute(
|
||||
str("""ALTER TABLE CFG_Server ADD FeatureFlags JSON NULL DEFAULT ('{}') AFTER LoginMessageChannelId;""")
|
||||
)
|
||||
|
||||
def downgrade(self):
|
||||
self._logger.debug(__name__, "Running downgrade")
|
||||
self._cursor.execute("ALTER TABLE CFG_Technician DROP COLUMN FeatureFlags;")
|
||||
self._cursor.execute("ALTER TABLE CFG_Server DROP COLUMN FeatureFlags;")
|
@@ -143,6 +143,8 @@ class ConfigMigration(MigrationABC):
|
||||
|
||||
def downgrade(self):
|
||||
self._logger.debug(__name__, "Running downgrade")
|
||||
self._server_downgrade()
|
||||
self._technician_downgrade()
|
||||
|
||||
def _server_downgrade(self):
|
||||
self._cursor.execute("DROP TABLE `CFG_Server`;")
|
||||
|
@@ -15,7 +15,7 @@ __title__ = "bot_data.model"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.0.7"
|
||||
__version__ = "1.1.1"
|
||||
|
||||
from collections import namedtuple
|
||||
|
||||
@@ -23,4 +23,4 @@ from collections import namedtuple
|
||||
# imports
|
||||
|
||||
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
||||
version_info = VersionInfo(major="1", minor="0", micro="7")
|
||||
version_info = VersionInfo(major="1", minor="1", micro="1")
|
||||
|
@@ -108,6 +108,15 @@ class Achievement(TableABC):
|
||||
"""
|
||||
)
|
||||
|
||||
@staticmethod
|
||||
def get_select_by_server_id_string(id: int) -> str:
|
||||
return str(
|
||||
f"""
|
||||
SELECT * FROM `Achievements`
|
||||
WHERE `ServerId` = {id};
|
||||
"""
|
||||
)
|
||||
|
||||
@property
|
||||
def insert_string(self) -> str:
|
||||
return str(
|
||||
|
@@ -1,9 +1,11 @@
|
||||
import json
|
||||
from datetime import datetime
|
||||
|
||||
from cpl_core.configuration import ConfigurationModelABC
|
||||
from cpl_core.database import TableABC
|
||||
from cpl_query.extension import List
|
||||
|
||||
from bot_core.configuration.feature_flags_enum import FeatureFlagsEnum
|
||||
from bot_data.model.server import Server
|
||||
from bot_data.model.server_team_role_ids_config import ServerTeamRoleIdsConfig
|
||||
|
||||
@@ -24,6 +26,7 @@ class ServerConfig(TableABC, ConfigurationModelABC):
|
||||
help_voice_channel_id: int,
|
||||
team_channel_id: int,
|
||||
login_message_channel_id: int,
|
||||
feature_flags: dict[FeatureFlagsEnum],
|
||||
server: Server,
|
||||
afk_channel_ids: List[int],
|
||||
team_role_ids: List[ServerTeamRoleIdsConfig],
|
||||
@@ -45,6 +48,7 @@ class ServerConfig(TableABC, ConfigurationModelABC):
|
||||
self._help_voice_channel_id = help_voice_channel_id
|
||||
self._team_channel_id = team_channel_id
|
||||
self._login_message_channel_id = login_message_channel_id
|
||||
self._feature_flags = feature_flags
|
||||
self._server = server
|
||||
self._afk_channel_ids = afk_channel_ids
|
||||
self._team_role_ids = team_role_ids
|
||||
@@ -161,6 +165,14 @@ class ServerConfig(TableABC, ConfigurationModelABC):
|
||||
def login_message_channel_id(self, value: int):
|
||||
self._login_message_channel_id = value
|
||||
|
||||
@property
|
||||
def feature_flags(self) -> dict[FeatureFlagsEnum]:
|
||||
return self._feature_flags
|
||||
|
||||
@feature_flags.setter
|
||||
def feature_flags(self, value: dict[FeatureFlagsEnum]):
|
||||
self._feature_flags = value
|
||||
|
||||
@property
|
||||
def afk_channel_ids(self) -> List[int]:
|
||||
return self._afk_channel_ids
|
||||
@@ -225,6 +237,7 @@ class ServerConfig(TableABC, ConfigurationModelABC):
|
||||
`HelpVoiceChannelId`,
|
||||
`TeamChannelId`,
|
||||
`LoginMessageChannelId`,
|
||||
`FeatureFlags`,
|
||||
`ServerId`
|
||||
) VALUES (
|
||||
{self._message_delete_timer},
|
||||
@@ -240,6 +253,7 @@ class ServerConfig(TableABC, ConfigurationModelABC):
|
||||
{self._help_voice_channel_id},
|
||||
{self._team_channel_id},
|
||||
{self._login_message_channel_id},
|
||||
'{json.dumps(self._feature_flags)}',
|
||||
{self._server.id}
|
||||
);
|
||||
"""
|
||||
@@ -263,6 +277,7 @@ class ServerConfig(TableABC, ConfigurationModelABC):
|
||||
`HelpVoiceChannelId` = {self._help_voice_channel_id},
|
||||
`TeamChannelId` = {self._team_channel_id},
|
||||
`LoginMessageChannelId` = {self._login_message_channel_id},
|
||||
`FeatureFlags` = '{json.dumps(self._feature_flags)}',
|
||||
`ServerId` = {self._server.id}
|
||||
WHERE `Id` = {self._id};
|
||||
"""
|
||||
|
@@ -17,6 +17,7 @@ class ServerConfigHistory(HistoryTableABC):
|
||||
help_voice_channel_id: int,
|
||||
team_channel_id: int,
|
||||
login_message_channel_id: int,
|
||||
feature_flags: dict[str],
|
||||
server_id: int,
|
||||
deleted: bool,
|
||||
date_from: str,
|
||||
@@ -39,6 +40,7 @@ class ServerConfigHistory(HistoryTableABC):
|
||||
self._help_voice_channel_id = help_voice_channel_id
|
||||
self._team_channel_id = team_channel_id
|
||||
self._login_message_channel_id = login_message_channel_id
|
||||
self._feature_flags = feature_flags
|
||||
self._server_id = server_id
|
||||
|
||||
self._deleted = deleted
|
||||
@@ -97,6 +99,10 @@ class ServerConfigHistory(HistoryTableABC):
|
||||
def login_message_channel_id(self) -> int:
|
||||
return self._login_message_channel_id
|
||||
|
||||
@property
|
||||
def feature_flags(self) -> dict[str]:
|
||||
return self._feature_flags
|
||||
|
||||
@property
|
||||
def server_id(self) -> int:
|
||||
return self._server_id
|
||||
|
@@ -1,9 +1,12 @@
|
||||
import json
|
||||
from datetime import datetime
|
||||
|
||||
from cpl_core.configuration import ConfigurationModelABC
|
||||
from cpl_core.database import TableABC
|
||||
from cpl_query.extension import List
|
||||
|
||||
from bot_core.configuration.feature_flags_enum import FeatureFlagsEnum
|
||||
|
||||
|
||||
class TechnicianConfig(TableABC, ConfigurationModelABC):
|
||||
def __init__(
|
||||
@@ -12,6 +15,7 @@ class TechnicianConfig(TableABC, ConfigurationModelABC):
|
||||
wait_for_restart: int,
|
||||
wait_for_shutdown: int,
|
||||
cache_max_messages: int,
|
||||
feature_flags: dict[FeatureFlagsEnum],
|
||||
technician_ids: List[int],
|
||||
ping_urls: List[str],
|
||||
created_at: datetime = None,
|
||||
@@ -23,6 +27,7 @@ class TechnicianConfig(TableABC, ConfigurationModelABC):
|
||||
self._wait_for_restart = wait_for_restart
|
||||
self._wait_for_shutdown = wait_for_shutdown
|
||||
self._cache_max_messages = cache_max_messages
|
||||
self._feature_flags = feature_flags
|
||||
self._technician_ids = technician_ids
|
||||
self._ping_urls = ping_urls
|
||||
|
||||
@@ -66,6 +71,14 @@ class TechnicianConfig(TableABC, ConfigurationModelABC):
|
||||
def cache_max_messages(self, value: int):
|
||||
self._cache_max_messages = value
|
||||
|
||||
@property
|
||||
def feature_flags(self) -> dict[FeatureFlagsEnum]:
|
||||
return self._feature_flags
|
||||
|
||||
@feature_flags.setter
|
||||
def feature_flags(self, value: dict[FeatureFlagsEnum]):
|
||||
self._feature_flags = value
|
||||
|
||||
@property
|
||||
def technician_ids(self) -> List[int]:
|
||||
return self._technician_ids
|
||||
@@ -104,12 +117,13 @@ class TechnicianConfig(TableABC, ConfigurationModelABC):
|
||||
return str(
|
||||
f"""
|
||||
INSERT INTO `CFG_Technician` (
|
||||
`HelpCommandReferenceUrl`, `WaitForRestart`, `WaitForShutdown`, `CacheMaxMessages`
|
||||
`HelpCommandReferenceUrl`, `WaitForRestart`, `WaitForShutdown`, `CacheMaxMessages`, `FeatureFlags`
|
||||
) VALUES (
|
||||
'{self._help_command_reference_url}',
|
||||
{self._wait_for_restart},
|
||||
{self._wait_for_shutdown},
|
||||
{self._cache_max_messages}
|
||||
{self._cache_max_messages},
|
||||
'{json.dumps(self._feature_flags)}'
|
||||
);
|
||||
"""
|
||||
)
|
||||
@@ -122,7 +136,8 @@ class TechnicianConfig(TableABC, ConfigurationModelABC):
|
||||
SET `HelpCommandReferenceUrl` = '{self._help_command_reference_url}',
|
||||
`WaitForRestart` = {self._wait_for_restart},
|
||||
`WaitForShutdown` = {self._wait_for_shutdown},
|
||||
`CacheMaxMessages` = {self._cache_max_messages}
|
||||
`CacheMaxMessages` = {self._cache_max_messages},
|
||||
`FeatureFlags` = '{json.dumps(self._feature_flags)}'
|
||||
WHERE `Id` = {self._id};
|
||||
"""
|
||||
)
|
||||
|
@@ -15,8 +15,8 @@ class User(TableABC):
|
||||
self,
|
||||
dc_id: int,
|
||||
xp: int,
|
||||
message_count: int,
|
||||
reaction_count: int,
|
||||
message_count: int,
|
||||
server: Optional[Server],
|
||||
created_at: datetime = None,
|
||||
modified_at: datetime = None,
|
||||
@@ -25,8 +25,8 @@ class User(TableABC):
|
||||
self._user_id = id
|
||||
self._discord_id = dc_id
|
||||
self._xp = xp
|
||||
self._message_count = message_count
|
||||
self._reaction_count = reaction_count
|
||||
self._message_count = message_count
|
||||
self._server = server
|
||||
|
||||
TableABC.__init__(self)
|
||||
|
@@ -15,7 +15,7 @@ __title__ = "bot_data.service"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.0.7"
|
||||
__version__ = "1.1.1"
|
||||
|
||||
from collections import namedtuple
|
||||
|
||||
@@ -23,4 +23,4 @@ from collections import namedtuple
|
||||
# imports
|
||||
|
||||
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
||||
version_info = VersionInfo(major="1", minor="0", micro="7")
|
||||
version_info = VersionInfo(major="1", minor="1", micro="1")
|
||||
|
@@ -65,8 +65,8 @@ class AchievementRepositoryService(AchievementRepositoryABC):
|
||||
|
||||
def get_achievements_by_server_id(self, server_id: int) -> List[Achievement]:
|
||||
achievements = List(Achievement)
|
||||
self._logger.trace(__name__, f"Send SQL command: {Achievement.get_select_by_id_string(server_id)}")
|
||||
results = self._context.select(Achievement.get_select_all_string())
|
||||
self._logger.trace(__name__, f"Send SQL command: {Achievement.get_select_by_server_id_string(server_id)}")
|
||||
results = self._context.select(Achievement.get_select_by_server_id_string(server_id))
|
||||
for result in results:
|
||||
self._logger.trace(__name__, f"Get user with id {result[0]}")
|
||||
achievements.append(self._from_result(result))
|
||||
|
@@ -1,3 +1,4 @@
|
||||
from enum import Enum
|
||||
from typing import Optional
|
||||
|
||||
from cpl_core.database.context import DatabaseContextABC
|
||||
@@ -100,9 +101,17 @@ class AuthUserRepositoryService(AuthUserRepositoryABC):
|
||||
):
|
||||
crit_sort_direction = criteria.sort_direction.lower()
|
||||
if crit_sort_direction == "desc" or crit_sort_direction == "descending":
|
||||
query = query.order_by_descending(lambda x: getattr(x, criteria.sort_column))
|
||||
query = query.order_by_descending(
|
||||
lambda x: getattr(x, criteria.sort_column)
|
||||
if not isinstance(getattr(x, criteria.sort_column), Enum)
|
||||
else getattr(x, criteria.sort_column).value
|
||||
)
|
||||
else:
|
||||
query = query.order_by(lambda x: getattr(x, criteria.sort_column))
|
||||
query = query.order_by(
|
||||
lambda x: getattr(x, criteria.sort_column)
|
||||
if not isinstance(getattr(x, criteria.sort_column), Enum)
|
||||
else getattr(x, criteria.sort_column).value
|
||||
)
|
||||
|
||||
result = FilteredResult()
|
||||
result.total_count = query.count()
|
||||
|
@@ -1,3 +1,5 @@
|
||||
import json
|
||||
|
||||
from cpl_core.database.context import DatabaseContextABC
|
||||
from cpl_query.extension import List
|
||||
|
||||
@@ -62,23 +64,24 @@ class ServerConfigRepositoryService(ServerConfigRepositoryABC):
|
||||
result[11],
|
||||
result[12],
|
||||
result[13],
|
||||
self._servers.get_server_by_id(result[14]),
|
||||
self._get_afk_channel_ids(result[14]),
|
||||
self._get_team_role_ids(result[14]),
|
||||
result[15],
|
||||
json.loads(result[14]),
|
||||
self._servers.get_server_by_id(result[15]),
|
||||
self._get_afk_channel_ids(result[15]),
|
||||
self._get_team_role_ids(result[15]),
|
||||
result[16],
|
||||
result[17],
|
||||
id=result[0],
|
||||
)
|
||||
|
||||
def does_server_config_exists(self, server_id: int) -> bool:
|
||||
self._logger.trace(__name__, f"Send SQL command: {ServerConfig.get_select_by_id_string(server_id)}")
|
||||
result = self._context.select(ServerConfig.get_select_by_id_string(server_id))
|
||||
self._logger.trace(__name__, f"Send SQL command: {ServerConfig.get_select_by_server_id_string(server_id)}")
|
||||
result = self._context.select(ServerConfig.get_select_by_server_id_string(server_id))
|
||||
|
||||
return len(result) > 0
|
||||
|
||||
def get_server_config_by_server(self, server_id: int) -> ServerConfig:
|
||||
self._logger.trace(__name__, f"Send SQL command: {ServerConfig.get_select_by_id_string(server_id)}")
|
||||
result = self._context.select(ServerConfig.get_select_by_id_string(server_id))[0]
|
||||
self._logger.trace(__name__, f"Send SQL command: {ServerConfig.get_select_by_server_id_string(server_id)}")
|
||||
result = self._context.select(ServerConfig.get_select_by_server_id_string(server_id))[0]
|
||||
|
||||
return self._from_result(result)
|
||||
|
||||
|
@@ -48,6 +48,7 @@ class ServerConfigSeeder(DataSeederABC):
|
||||
guild.system_channel.id,
|
||||
guild.system_channel.id,
|
||||
guild.system_channel.id,
|
||||
{},
|
||||
server,
|
||||
[],
|
||||
[],
|
||||
|
@@ -1,3 +1,5 @@
|
||||
import json
|
||||
|
||||
from cpl_core.database.context import DatabaseContextABC
|
||||
from cpl_query.extension import List
|
||||
|
||||
@@ -41,10 +43,11 @@ class TechnicianConfigRepositoryService(TechnicianConfigRepositoryABC):
|
||||
result[2],
|
||||
result[3],
|
||||
result[4],
|
||||
json.loads(result[5]),
|
||||
self._get_technician_ids(),
|
||||
self._get_technician_ping_urls(),
|
||||
result[5],
|
||||
result[6],
|
||||
result[7],
|
||||
id=result[0],
|
||||
)
|
||||
|
||||
|
@@ -32,6 +32,7 @@ class TechnicianConfigSeeder(DataSeederABC):
|
||||
8,
|
||||
8,
|
||||
1000000,
|
||||
{},
|
||||
List(int, [240160344557879316]),
|
||||
List(str, ["www.google.com", "www.sh-edraft.de", "www.keksdose-gaming.de"]),
|
||||
)
|
||||
|
@@ -15,7 +15,7 @@ __title__ = "bot_graphql"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.0.7"
|
||||
__version__ = "1.1.1"
|
||||
|
||||
from collections import namedtuple
|
||||
|
||||
@@ -23,4 +23,4 @@ from collections import namedtuple
|
||||
# imports
|
||||
|
||||
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
||||
version_info = VersionInfo(major="1", minor="0", micro="7")
|
||||
version_info = VersionInfo(major="1", minor="1", micro="1")
|
||||
|
@@ -15,7 +15,7 @@ __title__ = "bot_graphql.abc"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.0.7"
|
||||
__version__ = "1.1.1"
|
||||
|
||||
from collections import namedtuple
|
||||
|
||||
@@ -23,4 +23,4 @@ from collections import namedtuple
|
||||
# imports:
|
||||
|
||||
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
||||
version_info = VersionInfo(major="1", minor="0", micro="7")
|
||||
version_info = VersionInfo(major="1", minor="1", micro="1")
|
||||
|
@@ -9,6 +9,8 @@ from cpl_query.extension import List
|
||||
from bot_api.exception.service_error_code_enum import ServiceErrorCode
|
||||
from bot_api.exception.service_exception import ServiceException
|
||||
from bot_api.route.route import Route
|
||||
from bot_core.configuration.feature_flags_enum import FeatureFlagsEnum
|
||||
from bot_data.model.achievement import Achievement
|
||||
from bot_data.model.auth_role_enum import AuthRoleEnum
|
||||
from bot_data.model.auth_user import AuthUser
|
||||
from bot_data.model.auto_role import AutoRole
|
||||
@@ -17,6 +19,7 @@ from bot_data.model.client import Client
|
||||
from bot_data.model.known_user import KnownUser
|
||||
from bot_data.model.level import Level
|
||||
from bot_data.model.server import Server
|
||||
from bot_data.model.server_config import ServerConfig
|
||||
from bot_data.model.user import User
|
||||
from bot_data.model.user_joined_game_server import UserJoinedGameServer
|
||||
from bot_data.model.user_joined_server import UserJoinedServer
|
||||
@@ -66,13 +69,27 @@ class QueryABC(ObjectType):
|
||||
self.set_field(f"{name}s", wrapper)
|
||||
self.set_field(f"{name}Count", lambda *args: wrapper(*args).count())
|
||||
|
||||
def _can_user_see_element(self, user: AuthUser, element: T) -> bool:
|
||||
@ServiceProviderABC.inject
|
||||
def _can_user_see_element(self, user: AuthUser, element: T, services: ServiceProviderABC) -> bool:
|
||||
def get_services(services: ServiceProviderABC) -> ServiceProviderABC:
|
||||
return services
|
||||
|
||||
services = get_services()
|
||||
permissions: PermissionService = services.get_service(PermissionService)
|
||||
bot: DiscordBotServiceABC = services.get_service(DiscordBotServiceABC)
|
||||
|
||||
access = False
|
||||
if type(element) == AutoRole:
|
||||
if type(element) == Achievement:
|
||||
element: Achievement = element
|
||||
for u in user.users:
|
||||
u: User = u
|
||||
guild = bot.get_guild(u.server.discord_id)
|
||||
member = guild.get_member(u.discord_id)
|
||||
if permissions.is_member_moderator(member) and u.server.id == element.server.id:
|
||||
access = True
|
||||
break
|
||||
|
||||
elif type(element) == AutoRole:
|
||||
element: AutoRole = element
|
||||
for u in user.users:
|
||||
u: User = u
|
||||
@@ -158,6 +175,24 @@ class QueryABC(ObjectType):
|
||||
access = True
|
||||
break
|
||||
|
||||
elif type(element) == ServerConfig:
|
||||
for u in user.users:
|
||||
u: User = u
|
||||
guild = bot.get_guild(u.server.discord_id)
|
||||
member = guild.get_member(u.discord_id)
|
||||
if permissions.is_member_technician(member):
|
||||
access = True
|
||||
break
|
||||
|
||||
elif type(element) == dict and "key" in element and element["key"] in [e.value for e in FeatureFlagsEnum]:
|
||||
for u in user.users:
|
||||
u: User = u
|
||||
guild = bot.get_guild(u.server.discord_id)
|
||||
member = guild.get_member(u.discord_id)
|
||||
if permissions.is_member_technician(member):
|
||||
access = True
|
||||
break
|
||||
|
||||
return access
|
||||
|
||||
@ServiceProviderABC.inject
|
||||
|
@@ -3,8 +3,8 @@
|
||||
"Name": "bot-data",
|
||||
"Version": {
|
||||
"Major": "1",
|
||||
"Minor": "0",
|
||||
"Micro": "7"
|
||||
"Minor": "1",
|
||||
"Micro": "1"
|
||||
},
|
||||
"Author": "Sven Heidemann",
|
||||
"AuthorEmail": "sven.heidemann@sh-edraft.de",
|
||||
|
@@ -15,7 +15,7 @@ __title__ = "bot_graphql.filter"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.0.7"
|
||||
__version__ = "1.1.1"
|
||||
|
||||
from collections import namedtuple
|
||||
|
||||
@@ -23,4 +23,4 @@ from collections import namedtuple
|
||||
# imports:
|
||||
|
||||
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
||||
version_info = VersionInfo(major="1", minor="0", micro="7")
|
||||
version_info = VersionInfo(major="1", minor="1", micro="1")
|
||||
|
53
kdb-bot/src/bot_graphql/graphql/discord.gql
Normal file
53
kdb-bot/src/bot_graphql/graphql/discord.gql
Normal file
@@ -0,0 +1,53 @@
|
||||
type Discord {
|
||||
guilds(filter: GuildFilter): [Guild]
|
||||
users(filter: DiscordUserFilter): [DiscordUser]
|
||||
}
|
||||
|
||||
type Guild {
|
||||
id: ID
|
||||
name: String
|
||||
|
||||
channels(filter: ChannelFilter): [Channel]
|
||||
roles: [Role]
|
||||
emojis: [Emoji]
|
||||
}
|
||||
|
||||
input GuildFilter {
|
||||
id: ID
|
||||
name: String
|
||||
}
|
||||
|
||||
type Channel {
|
||||
id: String
|
||||
name: String
|
||||
type: String
|
||||
}
|
||||
|
||||
input ChannelFilter {
|
||||
id: String
|
||||
name: String
|
||||
type: String
|
||||
}
|
||||
|
||||
type Role {
|
||||
id: String
|
||||
name: String
|
||||
}
|
||||
|
||||
type DiscordUser {
|
||||
id: String
|
||||
name: String
|
||||
bot: Boolean
|
||||
}
|
||||
|
||||
input DiscordUserFilter {
|
||||
id: ID
|
||||
name: String
|
||||
bot: Boolean
|
||||
}
|
||||
|
||||
type Emoji {
|
||||
id: String
|
||||
name: String
|
||||
url: String
|
||||
}
|
9
kdb-bot/src/bot_graphql/graphql/featureFlags.gql
Normal file
9
kdb-bot/src/bot_graphql/graphql/featureFlags.gql
Normal file
@@ -0,0 +1,9 @@
|
||||
type FeatureFlag {
|
||||
key: String
|
||||
value: Boolean
|
||||
}
|
||||
|
||||
input FeatureFlagInput {
|
||||
key: String
|
||||
value: Boolean
|
||||
}
|
@@ -38,6 +38,6 @@ type Query {
|
||||
achievementOperators: [String]
|
||||
|
||||
technicianConfig: TechnicianConfig
|
||||
|
||||
guilds(filter: GuildFilter): [Guild]
|
||||
possibleFeatureFlags: [String]
|
||||
discord: Discord
|
||||
}
|
@@ -13,6 +13,8 @@ type ServerConfig implements TableWithHistoryQuery {
|
||||
helpVoiceChannelId: String
|
||||
teamChannelId: String
|
||||
loginMessageChannelId: String
|
||||
featureFlagCount: Int
|
||||
featureFlags: [FeatureFlag]
|
||||
|
||||
afkChannelIds: [String]
|
||||
moderatorRoleIds: [String]
|
||||
@@ -41,6 +43,8 @@ type ServerConfigHistory implements HistoryTableQuery {
|
||||
helpVoiceChannelId: String
|
||||
teamChannelId: String
|
||||
loginMessageChannelId: String
|
||||
featureFlagCount: Int
|
||||
featureFlags: [FeatureFlag]
|
||||
|
||||
serverId: ID
|
||||
|
||||
@@ -87,6 +91,7 @@ input ServerConfigInput {
|
||||
helpVoiceChannelId: String
|
||||
teamChannelId: String
|
||||
loginMessageChannelId: String
|
||||
featureFlags: [FeatureFlagInput]
|
||||
|
||||
afkChannelIds: [String]
|
||||
moderatorRoleIds: [String]
|
@@ -4,6 +4,8 @@ type TechnicianConfig implements TableWithHistoryQuery {
|
||||
waitForRestart: Int
|
||||
waitForShutdown: Int
|
||||
cacheMaxMessages: Int
|
||||
featureFlagCount: Int
|
||||
featureFlags: [FeatureFlag]
|
||||
pingURLs: [String]
|
||||
technicianIds: [String]
|
||||
|
||||
@@ -21,6 +23,8 @@ type TechnicianConfigHistory implements HistoryTableQuery {
|
||||
waitForRestart: Int
|
||||
waitForShutdown: Int
|
||||
cacheMaxMessages: Int
|
||||
featureFlagCount: Int
|
||||
featureFlags: [FeatureFlag]
|
||||
|
||||
deleted: Boolean
|
||||
dateFrom: String
|
||||
@@ -55,6 +59,7 @@ input TechnicianConfigInput {
|
||||
waitForRestart: Int
|
||||
waitForShutdown: Int
|
||||
cacheMaxMessages: Int
|
||||
featureFlags: [FeatureFlagInput]
|
||||
pingURLs: [String]
|
||||
technicianIds: [String]
|
||||
}
|
@@ -37,6 +37,12 @@ from bot_graphql.queries.auto_role_rule_history_query import AutoRoleRuleHistory
|
||||
from bot_graphql.queries.auto_role_rule_query import AutoRoleRuleQuery
|
||||
from bot_graphql.queries.client_history_query import ClientHistoryQuery
|
||||
from bot_graphql.queries.client_query import ClientQuery
|
||||
from bot_graphql.queries.discord.channel_query import ChannelQuery
|
||||
from bot_graphql.queries.discord.discord_query import DiscordQuery
|
||||
from bot_graphql.queries.discord.discord_user_query import DiscordUserQuery
|
||||
from bot_graphql.queries.discord.emoji_query import EmojiQuery
|
||||
from bot_graphql.queries.discord.guild_query import GuildQuery
|
||||
from bot_graphql.queries.discord.role_query import RoleQuery
|
||||
from bot_graphql.queries.game_server_query import GameServerQuery
|
||||
from bot_graphql.queries.known_user_history_query import KnownUserHistoryQuery
|
||||
from bot_graphql.queries.known_user_query import KnownUserQuery
|
||||
@@ -105,6 +111,13 @@ class GraphQLModule(ModuleABC):
|
||||
services.add_transient(QueryABC, UserJoinedGameServerHistoryQuery)
|
||||
services.add_transient(QueryABC, UserJoinedGameServerQuery)
|
||||
|
||||
services.add_transient(QueryABC, DiscordQuery)
|
||||
services.add_transient(QueryABC, GuildQuery)
|
||||
services.add_transient(QueryABC, ChannelQuery)
|
||||
services.add_transient(QueryABC, RoleQuery)
|
||||
services.add_transient(QueryABC, EmojiQuery)
|
||||
services.add_transient(QueryABC, DiscordUserQuery)
|
||||
|
||||
# filters
|
||||
services.add_transient(FilterABC, AutoRoleFilter)
|
||||
services.add_transient(FilterABC, AutoRoleRuleFilter)
|
||||
|
26
kdb-bot/src/bot_graphql/model/__init__.py
Normal file
26
kdb-bot/src/bot_graphql/model/__init__.py
Normal file
@@ -0,0 +1,26 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""
|
||||
bot Keksdose bot
|
||||
~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Discord bot for the Keksdose discord Server
|
||||
|
||||
:copyright: (c) 2022 - 2023 sh-edraft.de
|
||||
:license: MIT, see LICENSE for more details.
|
||||
|
||||
"""
|
||||
|
||||
__title__ = "bot_graphql.model"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.1.1"
|
||||
|
||||
from collections import namedtuple
|
||||
|
||||
|
||||
# imports
|
||||
|
||||
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
||||
version_info = VersionInfo(major="1", minor="1", micro="1")
|
@@ -1,29 +0,0 @@
|
||||
type Guild {
|
||||
id: ID
|
||||
name: String
|
||||
|
||||
channels: [Channel]
|
||||
roles: [Role]
|
||||
emojis: [Emoji]
|
||||
}
|
||||
|
||||
input GuildFilter {
|
||||
id: ID
|
||||
}
|
||||
|
||||
type Channel {
|
||||
id: String
|
||||
name: String
|
||||
type: String
|
||||
}
|
||||
|
||||
type Role {
|
||||
id: String
|
||||
name: String
|
||||
}
|
||||
|
||||
type Emoji {
|
||||
id: String
|
||||
name: String
|
||||
url: String
|
||||
}
|
16
kdb-bot/src/bot_graphql/model/discord.py
Normal file
16
kdb-bot/src/bot_graphql/model/discord.py
Normal file
@@ -0,0 +1,16 @@
|
||||
from cpl_query.extension import List
|
||||
from discord import Guild, User
|
||||
|
||||
|
||||
class Discord:
|
||||
def __init__(self, guilds: List[Guild], users: List[User]):
|
||||
self._guilds = guilds
|
||||
self._users = users
|
||||
|
||||
@property
|
||||
def guilds(self) -> List[Guild]:
|
||||
return self._guilds
|
||||
|
||||
@property
|
||||
def users(self) -> List[User]:
|
||||
return self._users
|
@@ -15,7 +15,7 @@ __title__ = "bot_graphql.mutations"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.0.7"
|
||||
__version__ = "1.1.1"
|
||||
|
||||
from collections import namedtuple
|
||||
|
||||
@@ -23,4 +23,4 @@ from collections import namedtuple
|
||||
# imports:
|
||||
|
||||
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
||||
version_info = VersionInfo(major="1", minor="0", micro="7")
|
||||
version_info = VersionInfo(major="1", minor="1", micro="1")
|
||||
|
@@ -3,6 +3,8 @@ from cpl_discord.service import DiscordBotServiceABC
|
||||
from cpl_query.extension import List
|
||||
|
||||
from bot_api.logging.api_logger import ApiLogger
|
||||
from bot_api.route.route import Route
|
||||
from bot_core.service.config_service import ConfigService
|
||||
from bot_data.abc.server_config_repository_abc import ServerConfigRepositoryABC
|
||||
from bot_data.abc.server_repository_abc import ServerRepositoryABC
|
||||
from bot_data.model.server_afk_channel_ids_config import ServerAFKChannelIdsConfig
|
||||
@@ -11,6 +13,7 @@ from bot_data.model.server_team_role_ids_config import ServerTeamRoleIdsConfig
|
||||
from bot_data.model.team_member_type_enum import TeamMemberTypeEnum
|
||||
from bot_data.model.user_role_enum import UserRoleEnum
|
||||
from bot_graphql.abc.query_abc import QueryABC
|
||||
from modules.permission.abc.permission_service_abc import PermissionServiceABC
|
||||
|
||||
|
||||
class ServerConfigMutation(QueryABC):
|
||||
@@ -21,6 +24,8 @@ class ServerConfigMutation(QueryABC):
|
||||
servers: ServerRepositoryABC,
|
||||
server_configs: ServerConfigRepositoryABC,
|
||||
db: DatabaseContextABC,
|
||||
config_service: ConfigService,
|
||||
permissions: PermissionServiceABC,
|
||||
):
|
||||
QueryABC.__init__(self, "ServerConfigMutation")
|
||||
|
||||
@@ -29,6 +34,8 @@ class ServerConfigMutation(QueryABC):
|
||||
self._servers = servers
|
||||
self._server_configs = server_configs
|
||||
self._db = db
|
||||
self._config_service = config_service
|
||||
self._permissions = permissions
|
||||
|
||||
self.set_field("updateServerConfig", self.resolve_update_server_config)
|
||||
|
||||
@@ -36,8 +43,8 @@ class ServerConfigMutation(QueryABC):
|
||||
if "id" not in input:
|
||||
raise ValueError("Id not set")
|
||||
|
||||
server_config = self._server_configs.get_server_config_by_server(input["id"])
|
||||
self._can_user_mutate_data(server_config, UserRoleEnum.admin)
|
||||
server_config = self._server_configs.get_server_config_by_id(int(input["id"]))
|
||||
self._can_user_mutate_data(Route.get_user().users[0].server, UserRoleEnum.technician)
|
||||
|
||||
server_config.message_delete_timer = (
|
||||
input["messageDeleteTimer"] if "messageDeleteTimer" in input else server_config.message_delete_timer
|
||||
@@ -82,6 +89,11 @@ class ServerConfigMutation(QueryABC):
|
||||
if "loginMessageChannelId" in input
|
||||
else server_config.login_message_channel_id
|
||||
)
|
||||
server_config.feature_flags = (
|
||||
dict(zip([x["key"] for x in input["featureFlags"]], [x["value"] for x in input["featureFlags"]]))
|
||||
if "featureFlags" in input
|
||||
else server_config.feature_flags
|
||||
)
|
||||
server_config.afk_channel_ids = (
|
||||
List(int).extend([int(x) for x in input["afkChannelIds"]])
|
||||
if "afkChannelIds" in input
|
||||
@@ -125,7 +137,7 @@ class ServerConfigMutation(QueryABC):
|
||||
return server_config
|
||||
|
||||
def _update_afk_channel_ids(self, new_config: ServerConfig):
|
||||
old_config = self._server_configs.get_server_config_by_id(new_config.server.id)
|
||||
old_config = self._server_configs.get_server_config_by_server(new_config.server.id)
|
||||
for channel_id in old_config.afk_channel_ids:
|
||||
if channel_id in new_config.afk_channel_ids:
|
||||
continue
|
||||
@@ -143,7 +155,7 @@ class ServerConfigMutation(QueryABC):
|
||||
)
|
||||
|
||||
def _update_team_role_ids(self, new_config: ServerConfig):
|
||||
old_config = self._server_configs.get_server_config_by_id(new_config.server.id)
|
||||
old_config = self._server_configs.get_server_config_by_server(new_config.server.id)
|
||||
for role_id in old_config.team_role_ids:
|
||||
if role_id.role_id in new_config.team_role_ids.select(lambda x: int(x.role_id)):
|
||||
continue
|
||||
@@ -161,3 +173,6 @@ class ServerConfigMutation(QueryABC):
|
||||
continue
|
||||
|
||||
self._server_configs.add_server_team_role_id_config(role_id)
|
||||
|
||||
self._bot.loop.create_task(self._config_service.reload_server_config(new_config.server))
|
||||
self._permissions.on_ready()
|
||||
|
@@ -3,6 +3,8 @@ from cpl_discord.service import DiscordBotServiceABC
|
||||
from cpl_query.extension import List
|
||||
|
||||
from bot_api.logging.api_logger import ApiLogger
|
||||
from bot_api.route.route import Route
|
||||
from bot_core.service.config_service import ConfigService
|
||||
from bot_data.abc.server_repository_abc import ServerRepositoryABC
|
||||
from bot_data.abc.technician_config_repository_abc import TechnicianConfigRepositoryABC
|
||||
from bot_data.model.technician_config import TechnicianConfig
|
||||
@@ -10,6 +12,7 @@ from bot_data.model.technician_id_config import TechnicianIdConfig
|
||||
from bot_data.model.technician_ping_url_config import TechnicianPingUrlConfig
|
||||
from bot_data.model.user_role_enum import UserRoleEnum
|
||||
from bot_graphql.abc.query_abc import QueryABC
|
||||
from modules.permission.abc.permission_service_abc import PermissionServiceABC
|
||||
|
||||
|
||||
class TechnicianConfigMutation(QueryABC):
|
||||
@@ -20,6 +23,8 @@ class TechnicianConfigMutation(QueryABC):
|
||||
servers: ServerRepositoryABC,
|
||||
technician_configs: TechnicianConfigRepositoryABC,
|
||||
db: DatabaseContextABC,
|
||||
permissions: PermissionServiceABC,
|
||||
config_service: ConfigService,
|
||||
):
|
||||
QueryABC.__init__(self, "TechnicianConfigMutation")
|
||||
|
||||
@@ -28,12 +33,14 @@ class TechnicianConfigMutation(QueryABC):
|
||||
self._servers = servers
|
||||
self._technician_configs = technician_configs
|
||||
self._db = db
|
||||
self._permissions = permissions
|
||||
self._config_service = config_service
|
||||
|
||||
self.set_field("updateTechnicianConfig", self.resolve_update_technician_config)
|
||||
|
||||
def resolve_update_technician_config(self, *_, input: dict):
|
||||
technician_config = self._technician_configs.get_technician_config()
|
||||
self._can_user_mutate_data(technician_config, UserRoleEnum.admin)
|
||||
self._can_user_mutate_data(Route.get_user().users[0].server, UserRoleEnum.technician)
|
||||
|
||||
technician_config.help_command_reference_url = (
|
||||
input["helpCommandReferenceUrl"]
|
||||
@@ -49,6 +56,11 @@ class TechnicianConfigMutation(QueryABC):
|
||||
technician_config.cache_max_messages = (
|
||||
input["cacheMaxMessages"] if "cacheMaxMessages" in input else technician_config.cache_max_messages
|
||||
)
|
||||
technician_config.feature_flags = (
|
||||
dict(zip([x["key"] for x in input["featureFlags"]], [x["value"] for x in input["featureFlags"]]))
|
||||
if "featureFlags" in input
|
||||
else technician_config.feature_flags
|
||||
)
|
||||
technician_config.ping_urls = (
|
||||
List(str, input["pingURLs"]) if "pingURLs" in input else technician_config.ping_urls
|
||||
)
|
||||
@@ -100,3 +112,6 @@ class TechnicianConfigMutation(QueryABC):
|
||||
continue
|
||||
|
||||
self._technician_configs.add_technician_id_config(TechnicianIdConfig(technician_id))
|
||||
|
||||
self._bot.loop.create_task(self._config_service.reload_technician_config())
|
||||
self._permissions.on_ready()
|
||||
|
@@ -15,7 +15,7 @@ __title__ = "bot_graphql.queries"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.0.7"
|
||||
__version__ = "1.1.1"
|
||||
|
||||
from collections import namedtuple
|
||||
|
||||
@@ -23,4 +23,4 @@ from collections import namedtuple
|
||||
# imports:
|
||||
|
||||
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
||||
version_info = VersionInfo(major="1", minor="0", micro="7")
|
||||
version_info = VersionInfo(major="1", minor="1", micro="1")
|
||||
|
@@ -40,7 +40,7 @@ class ClientQuery(DataQueryWithHistoryABC):
|
||||
|
||||
@staticmethod
|
||||
def resolve_received_message_count(client: Client, *_):
|
||||
return client.received_command_count
|
||||
return client.received_message_count
|
||||
|
||||
@staticmethod
|
||||
def resolve_deleted_message_count(client: Client, *_):
|
||||
|
@@ -15,7 +15,7 @@ __title__ = "bot_graphql.queries.discord"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.0.7"
|
||||
__version__ = "1.1.1"
|
||||
|
||||
from collections import namedtuple
|
||||
|
||||
@@ -23,4 +23,4 @@ from collections import namedtuple
|
||||
# imports:
|
||||
|
||||
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
||||
version_info = VersionInfo(major="1", minor="0", micro="7")
|
||||
version_info = VersionInfo(major="1", minor="1", micro="1")
|
||||
|
@@ -1,10 +1,10 @@
|
||||
from bot_graphql.abc.data_query_abc import DataQueryABC
|
||||
from bot_graphql.abc.query_abc import QueryABC
|
||||
|
||||
|
||||
class ChannelQuery(DataQueryABC):
|
||||
class ChannelQuery(QueryABC):
|
||||
def __init__(self):
|
||||
DataQueryABC.__init__(self, "Channel")
|
||||
QueryABC.__init__(self, "Channel")
|
||||
|
||||
self.set_field("id", lambda c, *_: c.id)
|
||||
self.set_field("name", lambda c, *_: c.name)
|
||||
self.set_field("type", lambda c, *_: type(c))
|
||||
self.set_field("type", lambda c, *_: type(c).__name__)
|
||||
|
48
kdb-bot/src/bot_graphql/queries/discord/discord_query.py
Normal file
48
kdb-bot/src/bot_graphql/queries/discord/discord_query.py
Normal file
@@ -0,0 +1,48 @@
|
||||
from cpl_discord.service import DiscordBotServiceABC
|
||||
from cpl_query.extension import List
|
||||
|
||||
from bot_graphql.abc.query_abc import QueryABC
|
||||
|
||||
|
||||
class DiscordQuery(QueryABC):
|
||||
def __init__(
|
||||
self,
|
||||
bot: DiscordBotServiceABC,
|
||||
):
|
||||
QueryABC.__init__(self, "Discord")
|
||||
|
||||
self._bot = bot
|
||||
|
||||
self.set_field("guilds", self._resolve_guilds)
|
||||
self.set_field("users", self._resolve_users)
|
||||
|
||||
def _resolve_guilds(self, *_, filter=None):
|
||||
guilds = self._bot.guilds
|
||||
|
||||
if filter is None:
|
||||
return guilds
|
||||
|
||||
if "id" in filter:
|
||||
guilds = self._bot.guilds.where(lambda g: g.id == int(filter["id"]))
|
||||
|
||||
if "name" in filter:
|
||||
guilds = self._bot.guilds.where(lambda g: g.name == filter["name"])
|
||||
|
||||
return guilds
|
||||
|
||||
def _resolve_users(self, *_, filter=None):
|
||||
users = List(any).extend(self._bot.users)
|
||||
|
||||
if filter is None:
|
||||
return users
|
||||
|
||||
if "id" in filter:
|
||||
users = users.where(lambda g: g.id == int(filter["id"]))
|
||||
|
||||
if "name" in filter:
|
||||
users = users.where(lambda g: g.name == filter["name"])
|
||||
|
||||
if "bot" in filter:
|
||||
users = users.where(lambda g: g.bot == bool(filter["bot"]))
|
||||
|
||||
return users
|
@@ -0,0 +1,10 @@
|
||||
from bot_graphql.abc.query_abc import QueryABC
|
||||
|
||||
|
||||
class DiscordUserQuery(QueryABC):
|
||||
def __init__(self):
|
||||
QueryABC.__init__(self, "DiscordUser")
|
||||
|
||||
self.set_field("id", lambda r, *_: r.id)
|
||||
self.set_field("name", lambda r, *_: r.name)
|
||||
self.set_field("bot", lambda r, *_: r.bot)
|
@@ -1,9 +1,9 @@
|
||||
from bot_graphql.abc.data_query_abc import DataQueryABC
|
||||
from bot_graphql.abc.query_abc import QueryABC
|
||||
|
||||
|
||||
class RoleQuery(DataQueryABC):
|
||||
class EmojiQuery(QueryABC):
|
||||
def __init__(self):
|
||||
DataQueryABC.__init__(self, "Emoji")
|
||||
QueryABC.__init__(self, "Emoji")
|
||||
|
||||
self.set_field("id", lambda e, *_: e.id)
|
||||
self.set_field("name", lambda e, *_: e.name)
|
||||
|
@@ -1,12 +1,38 @@
|
||||
from bot_graphql.abc.data_query_abc import DataQueryABC
|
||||
from cpl_discord.service import DiscordBotServiceABC
|
||||
from cpl_query.extension import List
|
||||
from discord import Guild
|
||||
|
||||
from bot_graphql.abc.query_abc import QueryABC
|
||||
|
||||
|
||||
class GuildQuery(DataQueryABC):
|
||||
def __init__(self):
|
||||
DataQueryABC.__init__(self, "Guild")
|
||||
class GuildQuery(QueryABC):
|
||||
def __init__(
|
||||
self,
|
||||
bot: DiscordBotServiceABC,
|
||||
):
|
||||
QueryABC.__init__(self, "Guild")
|
||||
|
||||
self._bot = bot
|
||||
|
||||
self.set_field("id", lambda g, *_: g.id)
|
||||
self.set_field("name", lambda g, *_: g.name)
|
||||
self.set_field("channels", lambda g, *_: g.channels)
|
||||
self.set_field("channels", self._resolve_channels)
|
||||
self.set_field("roles", lambda g, *_: g.roles)
|
||||
self.set_field("emojis", lambda g, *_: g.emojis)
|
||||
|
||||
def _resolve_channels(self, g: Guild, *_, filter=None):
|
||||
users = List(any).extend(g.channels)
|
||||
|
||||
if filter is None:
|
||||
return users
|
||||
|
||||
if "id" in filter:
|
||||
users = users.where(lambda c: c.id == int(filter["id"]))
|
||||
|
||||
if "name" in filter:
|
||||
users = users.where(lambda c: c.id == filter["name"])
|
||||
|
||||
if "type" in filter:
|
||||
users = users.where(lambda c: type(c).__name__ == filter["type"])
|
||||
|
||||
return users
|
||||
|
@@ -1,9 +1,9 @@
|
||||
from bot_graphql.abc.data_query_abc import DataQueryABC
|
||||
from bot_graphql.abc.query_abc import QueryABC
|
||||
|
||||
|
||||
class RoleQuery(DataQueryABC):
|
||||
class RoleQuery(QueryABC):
|
||||
def __init__(self):
|
||||
DataQueryABC.__init__(self, "Role")
|
||||
QueryABC.__init__(self, "Role")
|
||||
|
||||
self.set_field("id", lambda r, *_: r.id)
|
||||
self.set_field("name", lambda r, *_: r.name)
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user