Compare commits
63 Commits
1.1.5
...
1f07a03186
| Author | SHA1 | Date | |
|---|---|---|---|
| 1f07a03186 | |||
| 97e7f2f01e | |||
| 45a96cf06e | |||
| f9d99697db | |||
| d771243217 | |||
| 55f23d703b | |||
| 3ff767a545 | |||
| a8a48709c6 | |||
| f41515a739 | |||
| 52787d0fb5 | |||
| 09d63e7418 | |||
| fc3bf73986 | |||
| 9450020d94 | |||
| 4d4941ef68 | |||
| 2c7a617ac8 | |||
| 2a435bc71c | |||
| 8585606347 | |||
| d146777b65 | |||
| a3229848ef | |||
| a869ee4780 | |||
| 5776854494 | |||
| 5c820214a1 | |||
| f11d9af6c7 | |||
| bff435d51e | |||
| 0f67bf467a | |||
| 2c7e5edbd7 | |||
| 0846bbb29b | |||
| 926323252a | |||
| fedf2f4b8b | |||
| 4d4320dbcd | |||
| c0b7e0913c | |||
| 9dcb75109f | |||
| 67baf350fa | |||
| 642a4d4dac | |||
| 6b86cc3ca8 | |||
| fd10614b20 | |||
| 0ec67d41e2 | |||
| 51928dcb4d | |||
| e36f0b8c76 | |||
| 2578c47c44 | |||
| dda2e2f5f6 | |||
| 8aa96482c1 | |||
| 109bbf3729 | |||
| 3db548fb86 | |||
| 0e5ec588fc | |||
| 2c9434396d | |||
| a49188b412 | |||
| 9e9879497a | |||
| 95e766d023 | |||
| e25c29b2a6 | |||
| 1dd6db4c85 | |||
| 9a51e51235 | |||
| fe5f3ced39 | |||
| c1ec7dd97b | |||
| 09771ac2a3 | |||
| 6f27ce7bbc | |||
| 806144d9d3 | |||
| 877af6b945 | |||
| 979e0a0e6f | |||
| fdf10f2728 | |||
| f7ffd78dcc | |||
| 8ddb9f087a | |||
| 0ca3be478b |
@@ -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/config.json",
|
||||
"config": "src/modules/config/modules/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: 7ae4783874...62475d6546
@@ -15,7 +15,7 @@ __title__ = "bot"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.1.4"
|
||||
__version__ = "1.0.7"
|
||||
|
||||
from collections import namedtuple
|
||||
|
||||
@@ -23,4 +23,4 @@ from collections import namedtuple
|
||||
# imports:
|
||||
|
||||
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
||||
version_info = VersionInfo(major="1", minor="1", micro="4")
|
||||
version_info = VersionInfo(major="1", minor="0", micro="7")
|
||||
|
||||
@@ -71,7 +71,7 @@ class Application(DiscordBotApplicationABC):
|
||||
self._api.stop()
|
||||
|
||||
await self._bot.close()
|
||||
await self._data_integrity.check_data_integrity(is_for_shutdown=True)
|
||||
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": "1",
|
||||
"Micro": "4"
|
||||
"Minor": "0",
|
||||
"Micro": "7"
|
||||
},
|
||||
"Author": "Sven Heidemann",
|
||||
"AuthorEmail": "sven.heidemann@sh-edraft.de",
|
||||
@@ -30,8 +30,7 @@
|
||||
"requests-oauthlib==1.3.1",
|
||||
"icmplib==3.0.3",
|
||||
"ariadne==0.20.1",
|
||||
"cryptography==41.0.2",
|
||||
"discord>=2.3.2"
|
||||
"cryptography==41.0.2"
|
||||
],
|
||||
"DevDependencies": [
|
||||
"cpl-cli==2023.4.0.post3",
|
||||
@@ -60,11 +59,9 @@
|
||||
"../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: 23eafb2e21...359f9c38c3
@@ -15,7 +15,7 @@ __title__ = "bot.extension"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.1.4"
|
||||
__version__ = "1.0.7"
|
||||
|
||||
from collections import namedtuple
|
||||
|
||||
@@ -23,4 +23,4 @@ from collections import namedtuple
|
||||
# imports:
|
||||
|
||||
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
||||
version_info = VersionInfo(major="1", minor="1", micro="4")
|
||||
version_info = VersionInfo(major="1", minor="0", micro="7")
|
||||
|
||||
@@ -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,10 +9,8 @@ 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.default_role_migration import DefaultRoleMigration
|
||||
from bot_data.migration.initial_migration import InitialMigration
|
||||
from bot_data.migration.level_migration import LevelMigration
|
||||
from bot_data.migration.remove_stats_migration import RemoveStatsMigration
|
||||
@@ -48,5 +46,3 @@ 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
|
||||
services.add_transient(MigrationABC, DefaultRoleMigration) # 24.09.2023 #360 - 1.1.3
|
||||
|
||||
@@ -151,7 +151,6 @@
|
||||
}
|
||||
},
|
||||
"base": {
|
||||
"member_left_message": "{} hat uns leider verlassen :(",
|
||||
"complaints": {
|
||||
"title": "Beschwerde einreichen",
|
||||
"label": "Beschwerde",
|
||||
|
||||
@@ -15,7 +15,7 @@ __title__ = "bot_api"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.1.4"
|
||||
__version__ = "1.0.7"
|
||||
|
||||
from collections import namedtuple
|
||||
|
||||
@@ -23,4 +23,4 @@ from collections import namedtuple
|
||||
# imports:
|
||||
|
||||
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
||||
version_info = VersionInfo(major="1", minor="1", micro="4")
|
||||
version_info = VersionInfo(major="1", minor="0", micro="7")
|
||||
|
||||
@@ -15,7 +15,7 @@ __title__ = "bot_api.abc"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.1.4"
|
||||
__version__ = "1.0.7"
|
||||
|
||||
from collections import namedtuple
|
||||
|
||||
@@ -23,4 +23,4 @@ from collections import namedtuple
|
||||
# imports:
|
||||
|
||||
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
||||
version_info = VersionInfo(major="1", minor="1", micro="4")
|
||||
version_info = VersionInfo(major="1", minor="0", micro="7")
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
"Name": "bot-api",
|
||||
"Version": {
|
||||
"Major": "1",
|
||||
"Minor": "1",
|
||||
"Micro": "4"
|
||||
"Minor": "0",
|
||||
"Micro": "7"
|
||||
},
|
||||
"Author": "",
|
||||
"AuthorEmail": "",
|
||||
|
||||
Submodule kdb-bot/src/bot_api/config updated: b6ffed4da1...6d3f253f41
@@ -15,7 +15,7 @@ __title__ = "bot_api.configuration"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.1.4"
|
||||
__version__ = "1.0.7"
|
||||
|
||||
from collections import namedtuple
|
||||
|
||||
@@ -23,4 +23,4 @@ from collections import namedtuple
|
||||
# imports
|
||||
|
||||
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
||||
version_info = VersionInfo(major="1", minor="1", micro="4")
|
||||
version_info = VersionInfo(major="1", minor="0", micro="7")
|
||||
|
||||
@@ -15,7 +15,7 @@ __title__ = "bot_api.controller"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.1.4"
|
||||
__version__ = "1.0.7"
|
||||
|
||||
from collections import namedtuple
|
||||
|
||||
@@ -23,4 +23,4 @@ from collections import namedtuple
|
||||
# imports:
|
||||
|
||||
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
||||
version_info = VersionInfo(major="1", minor="1", micro="4")
|
||||
version_info = VersionInfo(major="1", minor="0", micro="7")
|
||||
|
||||
@@ -15,7 +15,7 @@ __title__ = "bot_api.event"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.1.4"
|
||||
__version__ = "1.0.7"
|
||||
|
||||
from collections import namedtuple
|
||||
|
||||
@@ -23,4 +23,4 @@ from collections import namedtuple
|
||||
# imports:
|
||||
|
||||
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
||||
version_info = VersionInfo(major="1", minor="1", micro="4")
|
||||
version_info = VersionInfo(major="1", minor="0", micro="7")
|
||||
|
||||
@@ -15,7 +15,7 @@ __title__ = "bot_api.exception"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.1.4"
|
||||
__version__ = "1.0.7"
|
||||
|
||||
from collections import namedtuple
|
||||
|
||||
@@ -23,4 +23,4 @@ from collections import namedtuple
|
||||
# imports:
|
||||
|
||||
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
||||
version_info = VersionInfo(major="1", minor="1", micro="4")
|
||||
version_info = VersionInfo(major="1", minor="0", micro="7")
|
||||
|
||||
@@ -15,7 +15,7 @@ __title__ = "bot_api.filter"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.1.4"
|
||||
__version__ = "1.0.7"
|
||||
|
||||
from collections import namedtuple
|
||||
|
||||
@@ -23,4 +23,4 @@ from collections import namedtuple
|
||||
# imports:
|
||||
|
||||
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
||||
version_info = VersionInfo(major="1", minor="1", micro="4")
|
||||
version_info = VersionInfo(major="1", minor="0", micro="7")
|
||||
|
||||
@@ -15,7 +15,7 @@ __title__ = "bot_api.filter.discord"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.1.4"
|
||||
__version__ = "1.0.7"
|
||||
|
||||
from collections import namedtuple
|
||||
|
||||
@@ -23,4 +23,4 @@ from collections import namedtuple
|
||||
# imports:
|
||||
|
||||
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
||||
version_info = VersionInfo(major="1", minor="1", micro="4")
|
||||
version_info = VersionInfo(major="1", minor="0", micro="7")
|
||||
|
||||
@@ -15,7 +15,7 @@ __title__ = "bot_api.logging"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.1.4"
|
||||
__version__ = "1.0.7"
|
||||
|
||||
from collections import namedtuple
|
||||
|
||||
@@ -23,4 +23,4 @@ from collections import namedtuple
|
||||
# imports:
|
||||
|
||||
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
||||
version_info = VersionInfo(major="1", minor="1", micro="4")
|
||||
version_info = VersionInfo(major="1", minor="0", micro="7")
|
||||
|
||||
@@ -15,7 +15,7 @@ __title__ = "bot_api.model"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.1.4"
|
||||
__version__ = "1.0.7"
|
||||
|
||||
from collections import namedtuple
|
||||
|
||||
@@ -23,4 +23,4 @@ from collections import namedtuple
|
||||
# imports:
|
||||
|
||||
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
||||
version_info = VersionInfo(major="1", minor="1", micro="4")
|
||||
version_info = VersionInfo(major="1", minor="0", micro="7")
|
||||
|
||||
@@ -15,7 +15,7 @@ __title__ = "bot_api.model.discord"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.1.4"
|
||||
__version__ = "1.0.7"
|
||||
|
||||
from collections import namedtuple
|
||||
|
||||
@@ -23,4 +23,4 @@ from collections import namedtuple
|
||||
# imports:
|
||||
|
||||
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
||||
version_info = VersionInfo(major="1", minor="1", micro="4")
|
||||
version_info = VersionInfo(major="1", minor="0", micro="7")
|
||||
|
||||
@@ -15,7 +15,7 @@ __title__ = "bot_api.route"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.1.4"
|
||||
__version__ = "1.0.7"
|
||||
|
||||
from collections import namedtuple
|
||||
|
||||
@@ -23,4 +23,4 @@ from collections import namedtuple
|
||||
# imports:
|
||||
|
||||
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
||||
version_info = VersionInfo(major="1", minor="1", micro="4")
|
||||
version_info = VersionInfo(major="1", minor="0", micro="7")
|
||||
|
||||
@@ -15,7 +15,7 @@ __title__ = "bot_api.service"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.1.4"
|
||||
__version__ = "1.0.7"
|
||||
|
||||
from collections import namedtuple
|
||||
|
||||
@@ -23,4 +23,4 @@ from collections import namedtuple
|
||||
# imports
|
||||
|
||||
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
||||
version_info = VersionInfo(major="1", minor="1", micro="4")
|
||||
version_info = VersionInfo(major="1", minor="0", micro="7")
|
||||
|
||||
@@ -494,13 +494,8 @@ class AuthService(AuthServiceABC):
|
||||
added_user = True
|
||||
|
||||
db_user = self._auth_users.get_auth_user_by_email(user_dto.email)
|
||||
user_ids = db_user.users.select(lambda x: x.id)
|
||||
|
||||
for user in self._users.get_users_by_discord_id(dc_id):
|
||||
if user.id in user_ids:
|
||||
continue
|
||||
|
||||
self._auth_users.add_auth_user_user_rel(AuthUserUsersRelation(db_user, user))
|
||||
if db_user.users.count() == 0:
|
||||
members.for_each(lambda x: self._auth_users.add_auth_user_user_rel(AuthUserUsersRelation(db_user, x)))
|
||||
|
||||
if db_user.confirmation_id is not None and not added_user:
|
||||
raise ServiceException(ServiceErrorCode.Forbidden, "E-Mail not verified")
|
||||
|
||||
@@ -15,7 +15,7 @@ __title__ = "bot_api.transformer"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.1.4"
|
||||
__version__ = "1.0.7"
|
||||
|
||||
from collections import namedtuple
|
||||
|
||||
@@ -23,4 +23,4 @@ from collections import namedtuple
|
||||
# imports:
|
||||
|
||||
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
||||
version_info = VersionInfo(major="1", minor="1", micro="4")
|
||||
version_info = VersionInfo(major="1", minor="0", micro="7")
|
||||
|
||||
@@ -15,7 +15,7 @@ __title__ = "bot_core"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.1.4"
|
||||
__version__ = "1.0.7"
|
||||
|
||||
from collections import namedtuple
|
||||
|
||||
@@ -23,4 +23,4 @@ from collections import namedtuple
|
||||
# imports
|
||||
|
||||
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
||||
version_info = VersionInfo(major="1", minor="1", micro="4")
|
||||
version_info = VersionInfo(major="1", minor="0", micro="7")
|
||||
|
||||
@@ -15,7 +15,7 @@ __title__ = "bot_core.abc"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.1.4"
|
||||
__version__ = "1.0.7"
|
||||
|
||||
from collections import namedtuple
|
||||
|
||||
@@ -23,4 +23,4 @@ from collections import namedtuple
|
||||
# imports:
|
||||
|
||||
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
||||
version_info = VersionInfo(major="1", minor="1", micro="4")
|
||||
version_info = VersionInfo(major="1", minor="0", micro="7")
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
from abc import ABC, abstractmethod
|
||||
from datetime import datetime
|
||||
from typing import Callable, Union
|
||||
from typing import Callable
|
||||
|
||||
import discord
|
||||
from cpl_query.extension import List
|
||||
@@ -67,7 +67,3 @@ class ClientUtilsABC(ABC):
|
||||
self, discord_channel_id: int, discord_message_id: int, rule: AutoRoleRule, guild: discord.Guild
|
||||
):
|
||||
pass
|
||||
|
||||
@abstractmethod
|
||||
async def check_default_role(self, member: Union[discord.User, discord.Member]):
|
||||
pass
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
"Name": "bot-core",
|
||||
"Version": {
|
||||
"Major": "1",
|
||||
"Minor": "1",
|
||||
"Micro": "4"
|
||||
"Minor": "0",
|
||||
"Micro": "7"
|
||||
},
|
||||
"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.1.4"
|
||||
__version__ = "1.0.7"
|
||||
|
||||
from collections import namedtuple
|
||||
|
||||
@@ -23,4 +23,4 @@ from collections import namedtuple
|
||||
# imports:
|
||||
|
||||
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
||||
version_info = VersionInfo(major="1", minor="1", micro="4")
|
||||
version_info = VersionInfo(major="1", minor="0", micro="7")
|
||||
|
||||
@@ -5,17 +5,18 @@ 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,7 +8,8 @@ class FeatureFlagsSettings(ConfigurationModelABC):
|
||||
# modules
|
||||
FeatureFlagsEnum.achievements_module.value: False, # 14.06.2023 #268
|
||||
FeatureFlagsEnum.api_module.value: False, # 13.10.2022 #70
|
||||
FeatureFlagsEnum.auto_role_module.value: False, # 03.10.2022 #54
|
||||
FeatureFlagsEnum.admin_module.value: False, # 02.10.2022 #48
|
||||
FeatureFlagsEnum.auto_role_module.value: True, # 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
|
||||
@@ -33,17 +34,6 @@ 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.1.4"
|
||||
__version__ = "1.0.7"
|
||||
|
||||
from collections import namedtuple
|
||||
|
||||
@@ -23,4 +23,4 @@ from collections import namedtuple
|
||||
# imports:
|
||||
|
||||
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
||||
version_info = VersionInfo(major="1", minor="1", micro="4")
|
||||
version_info = VersionInfo(major="1", minor="0", micro="7")
|
||||
|
||||
@@ -11,7 +11,6 @@ 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
|
||||
|
||||
@@ -24,7 +23,6 @@ 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.1.4"
|
||||
__version__ = "1.0.7"
|
||||
|
||||
from collections import namedtuple
|
||||
|
||||
@@ -23,4 +23,4 @@ from collections import namedtuple
|
||||
# imports:
|
||||
|
||||
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
||||
version_info = VersionInfo(major="1", minor="1", micro="4")
|
||||
version_info = VersionInfo(major="1", minor="0", micro="7")
|
||||
|
||||
@@ -15,7 +15,7 @@ __title__ = "bot_core.exception"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.1.4"
|
||||
__version__ = "1.0.7"
|
||||
|
||||
from collections import namedtuple
|
||||
|
||||
@@ -23,4 +23,4 @@ from collections import namedtuple
|
||||
# imports:
|
||||
|
||||
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
||||
version_info = VersionInfo(major="1", minor="1", micro="4")
|
||||
version_info = VersionInfo(major="1", minor="0", micro="7")
|
||||
|
||||
@@ -15,7 +15,7 @@ __title__ = "bot_core.helper"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.1.4"
|
||||
__version__ = "1.0.7"
|
||||
|
||||
from collections import namedtuple
|
||||
|
||||
@@ -23,4 +23,4 @@ from collections import namedtuple
|
||||
# imports:
|
||||
|
||||
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
||||
version_info = VersionInfo(major="1", minor="1", micro="4")
|
||||
version_info = VersionInfo(major="1", minor="0", micro="7")
|
||||
|
||||
@@ -15,7 +15,7 @@ __title__ = "bot_core.logging"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.1.4"
|
||||
__version__ = "1.0.7"
|
||||
|
||||
from collections import namedtuple
|
||||
|
||||
@@ -23,4 +23,4 @@ from collections import namedtuple
|
||||
# imports
|
||||
|
||||
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
||||
version_info = VersionInfo(major="1", minor="1", micro="4")
|
||||
version_info = VersionInfo(major="1", minor="0", micro="7")
|
||||
|
||||
@@ -15,7 +15,7 @@ __title__ = "bot_core.pipes"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.1.4"
|
||||
__version__ = "1.0.7"
|
||||
|
||||
from collections import namedtuple
|
||||
|
||||
@@ -23,4 +23,4 @@ from collections import namedtuple
|
||||
# imports
|
||||
|
||||
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
||||
version_info = VersionInfo(major="1", minor="1", micro="4")
|
||||
version_info = VersionInfo(major="1", minor="0", micro="7")
|
||||
|
||||
@@ -15,7 +15,7 @@ __title__ = "bot_core.service"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.1.4"
|
||||
__version__ = "1.0.7"
|
||||
|
||||
from collections import namedtuple
|
||||
|
||||
@@ -23,4 +23,4 @@ from collections import namedtuple
|
||||
# imports:
|
||||
|
||||
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
||||
version_info = VersionInfo(major="1", minor="1", micro="4")
|
||||
version_info = VersionInfo(major="1", minor="0", micro="7")
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
from datetime import datetime
|
||||
from typing import Callable, Union
|
||||
from typing import Callable
|
||||
|
||||
import discord
|
||||
from cpl_core.configuration import ConfigurationABC
|
||||
@@ -218,20 +218,3 @@ class ClientUtilsService(ClientUtilsABC):
|
||||
f"Cannot add reaction {rule.emoji_name} to message: {discord_message_id}",
|
||||
e,
|
||||
)
|
||||
|
||||
async def check_default_role(self, member: Union[discord.User, discord.Member]):
|
||||
try:
|
||||
server = self._servers.get_server_by_discord_id(member.guild.id)
|
||||
settings: ServerConfig = self._config.get_configuration(f"ServerConfig_{server.discord_id}")
|
||||
|
||||
if settings.default_role_id is None:
|
||||
return
|
||||
|
||||
default_role = member.guild.get_role(settings.default_role_id)
|
||||
if default_role in member.roles:
|
||||
return
|
||||
|
||||
await member.add_roles(default_role)
|
||||
|
||||
except Exception as e:
|
||||
self._logger.error(__name__, f"Cannot check for default role for member {member.id}", e)
|
||||
|
||||
@@ -1,50 +0,0 @@
|
||||
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()
|
||||
@@ -6,7 +6,6 @@ from cpl_core.configuration import ConfigurationABC
|
||||
from cpl_core.database.context import DatabaseContextABC
|
||||
from cpl_discord.service import DiscordBotServiceABC
|
||||
|
||||
from bot_core.abc.client_utils_abc import ClientUtilsABC
|
||||
from bot_core.logging.database_logger import DatabaseLogger
|
||||
from bot_core.pipes.date_time_offset_pipe import DateTimeOffsetPipe
|
||||
from bot_data.abc.client_repository_abc import ClientRepositoryABC
|
||||
@@ -45,7 +44,6 @@ class DataIntegrityService:
|
||||
user_joins_vc: UserJoinedVoiceChannelRepositoryABC,
|
||||
user_joined_gs: UserJoinedGameServerRepositoryABC,
|
||||
achievement_service: AchievementService,
|
||||
client_utils: ClientUtilsABC,
|
||||
dtp: DateTimeOffsetPipe,
|
||||
):
|
||||
self._config = config
|
||||
@@ -62,7 +60,6 @@ class DataIntegrityService:
|
||||
self._user_joins_vc = user_joins_vc
|
||||
self._user_joined_gs = user_joined_gs
|
||||
self._achievements = achievement_service
|
||||
self._client_utils = client_utils
|
||||
self._dtp = dtp
|
||||
|
||||
self._is_for_shutdown = False
|
||||
@@ -294,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()
|
||||
@@ -359,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)
|
||||
|
||||
async def _check_for_user_achievements(self):
|
||||
def _check_for_user_achievements(self):
|
||||
self._logger.debug(__name__, f"Start checking UserGotAchievement table")
|
||||
|
||||
for guild in self._bot.guilds:
|
||||
@@ -383,18 +380,12 @@ class DataIntegrityService:
|
||||
if user is None:
|
||||
self._logger.fatal(__name__, f"User not found in database: {member.id}")
|
||||
|
||||
await self._achievements.validate_achievements_for_user(user)
|
||||
self._bot.loop.create_task(self._achievements.validate_achievements_for_user(user))
|
||||
|
||||
async def _check_default_role(self):
|
||||
for guild in self._bot.guilds:
|
||||
for member in guild.members:
|
||||
await self._client_utils.check_default_role(member)
|
||||
|
||||
async def check_data_integrity(self, is_for_shutdown=False):
|
||||
def check_data_integrity(self, is_for_shutdown=False):
|
||||
if is_for_shutdown != self._is_for_shutdown:
|
||||
self._is_for_shutdown = is_for_shutdown
|
||||
|
||||
await self._check_default_role()
|
||||
self._check_known_users()
|
||||
self._check_servers()
|
||||
self._check_clients()
|
||||
@@ -402,4 +393,4 @@ class DataIntegrityService:
|
||||
self._check_user_joins()
|
||||
self._check_user_joins_vc()
|
||||
self._check_user_joined_gs()
|
||||
await self._check_for_user_achievements()
|
||||
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.1.4"
|
||||
__version__ = "1.0.7"
|
||||
|
||||
from collections import namedtuple
|
||||
|
||||
@@ -23,4 +23,4 @@ from collections import namedtuple
|
||||
# imports
|
||||
|
||||
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
||||
version_info = VersionInfo(major="1", minor="1", micro="4")
|
||||
version_info = VersionInfo(major="1", minor="0", micro="7")
|
||||
|
||||
@@ -15,7 +15,7 @@ __title__ = "bot_data.abc"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.1.4"
|
||||
__version__ = "1.0.7"
|
||||
|
||||
from collections import namedtuple
|
||||
|
||||
@@ -23,4 +23,4 @@ from collections import namedtuple
|
||||
# imports
|
||||
|
||||
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
||||
version_info = VersionInfo(major="1", minor="1", micro="4")
|
||||
version_info = VersionInfo(major="1", minor="0", micro="7")
|
||||
|
||||
@@ -14,10 +14,6 @@ class AuthUserRepositoryABC(ABC):
|
||||
def __init__(self):
|
||||
pass
|
||||
|
||||
@abstractmethod
|
||||
def get_auth_user_relation_ids(self, auth_user: AuthUser) -> List[int]:
|
||||
pass
|
||||
|
||||
@abstractmethod
|
||||
def get_all_auth_users(self) -> List[AuthUser]:
|
||||
pass
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
"Name": "bot-data",
|
||||
"Version": {
|
||||
"Major": "1",
|
||||
"Minor": "1",
|
||||
"Micro": "4"
|
||||
"Minor": "0",
|
||||
"Micro": "7"
|
||||
},
|
||||
"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.1.4"
|
||||
__version__ = "1.0.7"
|
||||
|
||||
from collections import namedtuple
|
||||
|
||||
@@ -23,4 +23,4 @@ from collections import namedtuple
|
||||
# imports
|
||||
|
||||
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
||||
version_info = VersionInfo(major="1", minor="1", micro="4")
|
||||
version_info = VersionInfo(major="1", minor="0", micro="7")
|
||||
|
||||
@@ -1,29 +0,0 @@
|
||||
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,8 +143,6 @@ 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`;")
|
||||
|
||||
@@ -1,34 +0,0 @@
|
||||
from bot_core.logging.database_logger import DatabaseLogger
|
||||
from bot_data.abc.migration_abc import MigrationABC
|
||||
from bot_data.db_context import DBContext
|
||||
|
||||
|
||||
class DefaultRoleMigration(MigrationABC):
|
||||
name = "1.1.3_DefaultRoleMigration"
|
||||
|
||||
def __init__(self, logger: DatabaseLogger, db: DBContext):
|
||||
MigrationABC.__init__(self)
|
||||
self._logger = logger
|
||||
self._db = db
|
||||
self._cursor = db.cursor
|
||||
|
||||
def upgrade(self):
|
||||
self._logger.debug(__name__, "Running upgrade")
|
||||
|
||||
self._cursor.execute(
|
||||
str(
|
||||
f"""
|
||||
ALTER TABLE CFG_Server
|
||||
ADD DefaultRoleId BIGINT NULL AFTER LoginMessageChannelId;
|
||||
"""
|
||||
)
|
||||
)
|
||||
|
||||
def downgrade(self):
|
||||
self._cursor.execute(
|
||||
str(
|
||||
f"""
|
||||
ALTER TABLE CFG_Server DROP COLUMN DefaultRoleId;
|
||||
"""
|
||||
)
|
||||
)
|
||||
@@ -15,7 +15,7 @@ __title__ = "bot_data.model"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.1.4"
|
||||
__version__ = "1.0.7"
|
||||
|
||||
from collections import namedtuple
|
||||
|
||||
@@ -23,4 +23,4 @@ from collections import namedtuple
|
||||
# imports
|
||||
|
||||
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
||||
version_info = VersionInfo(major="1", minor="1", micro="4")
|
||||
version_info = VersionInfo(major="1", minor="0", micro="7")
|
||||
|
||||
@@ -108,15 +108,6 @@ 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,11 +1,9 @@
|
||||
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
|
||||
|
||||
@@ -26,8 +24,6 @@ class ServerConfig(TableABC, ConfigurationModelABC):
|
||||
help_voice_channel_id: int,
|
||||
team_channel_id: int,
|
||||
login_message_channel_id: int,
|
||||
default_role_id: int,
|
||||
feature_flags: dict[FeatureFlagsEnum],
|
||||
server: Server,
|
||||
afk_channel_ids: List[int],
|
||||
team_role_ids: List[ServerTeamRoleIdsConfig],
|
||||
@@ -49,8 +45,6 @@ class ServerConfig(TableABC, ConfigurationModelABC):
|
||||
self._help_voice_channel_id = help_voice_channel_id
|
||||
self._team_channel_id = team_channel_id
|
||||
self._login_message_channel_id = login_message_channel_id
|
||||
self._default_role_id = default_role_id
|
||||
self._feature_flags = feature_flags
|
||||
self._server = server
|
||||
self._afk_channel_ids = afk_channel_ids
|
||||
self._team_role_ids = team_role_ids
|
||||
@@ -167,22 +161,6 @@ class ServerConfig(TableABC, ConfigurationModelABC):
|
||||
def login_message_channel_id(self, value: int):
|
||||
self._login_message_channel_id = value
|
||||
|
||||
@property
|
||||
def default_role_id(self) -> int:
|
||||
return self._default_role_id
|
||||
|
||||
@default_role_id.setter
|
||||
def default_role_id(self, value: int):
|
||||
self._default_role_id = value
|
||||
|
||||
@property
|
||||
def feature_flags(self) -> dict[FeatureFlagsEnum]:
|
||||
return self._feature_flags
|
||||
|
||||
@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
|
||||
@@ -247,8 +225,6 @@ class ServerConfig(TableABC, ConfigurationModelABC):
|
||||
`HelpVoiceChannelId`,
|
||||
`TeamChannelId`,
|
||||
`LoginMessageChannelId`,
|
||||
`DefaultRoleId`,
|
||||
`FeatureFlags`,
|
||||
`ServerId`
|
||||
) VALUES (
|
||||
{self._message_delete_timer},
|
||||
@@ -264,8 +240,6 @@ class ServerConfig(TableABC, ConfigurationModelABC):
|
||||
{self._help_voice_channel_id},
|
||||
{self._team_channel_id},
|
||||
{self._login_message_channel_id},
|
||||
{self._default_role_id},
|
||||
'{json.dumps(self._feature_flags)}',
|
||||
{self._server.id}
|
||||
);
|
||||
"""
|
||||
@@ -289,8 +263,6 @@ class ServerConfig(TableABC, ConfigurationModelABC):
|
||||
`HelpVoiceChannelId` = {self._help_voice_channel_id},
|
||||
`TeamChannelId` = {self._team_channel_id},
|
||||
`LoginMessageChannelId` = {self._login_message_channel_id},
|
||||
`DefaultRoleId` = {self._default_role_id},
|
||||
`FeatureFlags` = '{json.dumps(self._feature_flags)}',
|
||||
`ServerId` = {self._server.id}
|
||||
WHERE `Id` = {self._id};
|
||||
"""
|
||||
|
||||
@@ -17,8 +17,6 @@ class ServerConfigHistory(HistoryTableABC):
|
||||
help_voice_channel_id: int,
|
||||
team_channel_id: int,
|
||||
login_message_channel_id: int,
|
||||
default_role_id: int,
|
||||
feature_flags: dict[str],
|
||||
server_id: int,
|
||||
deleted: bool,
|
||||
date_from: str,
|
||||
@@ -41,8 +39,6 @@ class ServerConfigHistory(HistoryTableABC):
|
||||
self._help_voice_channel_id = help_voice_channel_id
|
||||
self._team_channel_id = team_channel_id
|
||||
self._login_message_channel_id = login_message_channel_id
|
||||
self._default_role_id = default_role_id
|
||||
self._feature_flags = feature_flags
|
||||
self._server_id = server_id
|
||||
|
||||
self._deleted = deleted
|
||||
@@ -101,14 +97,6 @@ class ServerConfigHistory(HistoryTableABC):
|
||||
def login_message_channel_id(self) -> int:
|
||||
return self._login_message_channel_id
|
||||
|
||||
@property
|
||||
def default_role_id(self) -> int:
|
||||
return self._default_role_id
|
||||
|
||||
@property
|
||||
def feature_flags(self) -> dict[str]:
|
||||
return self._feature_flags
|
||||
|
||||
@property
|
||||
def server_id(self) -> int:
|
||||
return self._server_id
|
||||
|
||||
@@ -1,12 +1,9 @@
|
||||
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__(
|
||||
@@ -15,7 +12,6 @@ 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,
|
||||
@@ -27,7 +23,6 @@ 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
|
||||
|
||||
@@ -71,14 +66,6 @@ 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
|
||||
@@ -117,13 +104,12 @@ class TechnicianConfig(TableABC, ConfigurationModelABC):
|
||||
return str(
|
||||
f"""
|
||||
INSERT INTO `CFG_Technician` (
|
||||
`HelpCommandReferenceUrl`, `WaitForRestart`, `WaitForShutdown`, `CacheMaxMessages`, `FeatureFlags`
|
||||
`HelpCommandReferenceUrl`, `WaitForRestart`, `WaitForShutdown`, `CacheMaxMessages`
|
||||
) VALUES (
|
||||
'{self._help_command_reference_url}',
|
||||
{self._wait_for_restart},
|
||||
{self._wait_for_shutdown},
|
||||
{self._cache_max_messages},
|
||||
'{json.dumps(self._feature_flags)}'
|
||||
{self._cache_max_messages}
|
||||
);
|
||||
"""
|
||||
)
|
||||
@@ -136,8 +122,7 @@ 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},
|
||||
`FeatureFlags` = '{json.dumps(self._feature_flags)}'
|
||||
`CacheMaxMessages` = {self._cache_max_messages}
|
||||
WHERE `Id` = {self._id};
|
||||
"""
|
||||
)
|
||||
|
||||
@@ -15,8 +15,8 @@ class User(TableABC):
|
||||
self,
|
||||
dc_id: int,
|
||||
xp: int,
|
||||
reaction_count: int,
|
||||
message_count: int,
|
||||
reaction_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._reaction_count = reaction_count
|
||||
self._message_count = message_count
|
||||
self._reaction_count = reaction_count
|
||||
self._server = server
|
||||
|
||||
TableABC.__init__(self)
|
||||
|
||||
@@ -39,10 +39,7 @@ class UserJoinedVoiceChannel(TableABC):
|
||||
@property
|
||||
@ServiceProviderABC.inject
|
||||
def channel_name(self, bot: DiscordBotServiceABC) -> str:
|
||||
channel = bot.get_channel(self.channel_id)
|
||||
if channel is None:
|
||||
return ""
|
||||
return channel.name
|
||||
return bot.get_channel(self.channel_id).name
|
||||
|
||||
@property
|
||||
def user(self) -> User:
|
||||
|
||||
@@ -41,10 +41,7 @@ class UserJoinedVoiceChannelHistory(HistoryTableABC):
|
||||
@property
|
||||
@ServiceProviderABC.inject
|
||||
def channel_name(self, bot: DiscordBotServiceABC) -> str:
|
||||
channel = bot.get_channel(self.channel_id)
|
||||
if channel is None:
|
||||
return ""
|
||||
return channel.name
|
||||
return bot.get_channel(self.channel_id).name
|
||||
|
||||
@property
|
||||
def user(self) -> int:
|
||||
|
||||
@@ -15,7 +15,7 @@ __title__ = "bot_data.service"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.1.4"
|
||||
__version__ = "1.0.7"
|
||||
|
||||
from collections import namedtuple
|
||||
|
||||
@@ -23,4 +23,4 @@ from collections import namedtuple
|
||||
# imports
|
||||
|
||||
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
||||
version_info = VersionInfo(major="1", minor="1", micro="4")
|
||||
version_info = VersionInfo(major="1", minor="0", micro="7")
|
||||
|
||||
@@ -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_server_id_string(server_id)}")
|
||||
results = self._context.select(Achievement.get_select_by_server_id_string(server_id))
|
||||
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())
|
||||
for result in results:
|
||||
self._logger.trace(__name__, f"Get user with id {result[0]}")
|
||||
achievements.append(self._from_result(result))
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
from enum import Enum
|
||||
from typing import Optional
|
||||
|
||||
from cpl_core.database.context import DatabaseContextABC
|
||||
@@ -50,7 +49,13 @@ class AuthUserRepositoryService(AuthUserRepositoryABC):
|
||||
auth_user_id=self._get_value_from_result(au_result[0]),
|
||||
)
|
||||
|
||||
for user_id in self.get_auth_user_relation_ids(auth_user):
|
||||
self._logger.trace(
|
||||
__name__,
|
||||
f"Send SQL command: {auth_user.get_select_user_id_from_relations()}",
|
||||
)
|
||||
results = self._context.select(auth_user.get_select_user_id_from_relations())
|
||||
for result in results:
|
||||
user_id = self._get_value_from_result(result[0])
|
||||
if user_id is None:
|
||||
continue
|
||||
|
||||
@@ -59,19 +64,6 @@ class AuthUserRepositoryService(AuthUserRepositoryABC):
|
||||
|
||||
return auth_user
|
||||
|
||||
def get_auth_user_relation_ids(self, auth_user: AuthUser) -> List[int]:
|
||||
self._logger.trace(
|
||||
__name__,
|
||||
f"Send SQL command: {auth_user.get_select_user_id_from_relations()}",
|
||||
)
|
||||
relation_ids = List(int)
|
||||
results = self._context.select(auth_user.get_select_user_id_from_relations())
|
||||
for result in results:
|
||||
self._logger.trace(__name__, f"Got auth user relation with id {result[0]}")
|
||||
relation_ids.append(result[0])
|
||||
|
||||
return relation_ids
|
||||
|
||||
def get_all_auth_users(self) -> List[AuthUser]:
|
||||
users = List(AuthUser)
|
||||
self._logger.trace(__name__, f"Send SQL command: {AuthUser.get_select_all_string()}")
|
||||
@@ -108,17 +100,9 @@ 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)
|
||||
if not isinstance(getattr(x, criteria.sort_column), Enum)
|
||||
else getattr(x, criteria.sort_column).value
|
||||
)
|
||||
query = query.order_by_descending(lambda x: getattr(x, criteria.sort_column))
|
||||
else:
|
||||
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
|
||||
)
|
||||
query = query.order_by(lambda x: getattr(x, criteria.sort_column))
|
||||
|
||||
result = FilteredResult()
|
||||
result.total_count = query.count()
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
import json
|
||||
|
||||
from cpl_core.database.context import DatabaseContextABC
|
||||
from cpl_query.extension import List
|
||||
|
||||
@@ -64,25 +62,23 @@ class ServerConfigRepositoryService(ServerConfigRepositoryABC):
|
||||
result[11],
|
||||
result[12],
|
||||
result[13],
|
||||
result[14],
|
||||
json.loads(result[15]),
|
||||
self._servers.get_server_by_id(result[16]),
|
||||
self._get_afk_channel_ids(result[16]),
|
||||
self._get_team_role_ids(result[16]),
|
||||
result[17],
|
||||
result[18],
|
||||
self._servers.get_server_by_id(result[14]),
|
||||
self._get_afk_channel_ids(result[14]),
|
||||
self._get_team_role_ids(result[14]),
|
||||
result[15],
|
||||
result[16],
|
||||
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_server_id_string(server_id)}")
|
||||
result = self._context.select(ServerConfig.get_select_by_server_id_string(server_id))
|
||||
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))
|
||||
|
||||
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_server_id_string(server_id)}")
|
||||
result = self._context.select(ServerConfig.get_select_by_server_id_string(server_id))[0]
|
||||
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]
|
||||
|
||||
return self._from_result(result)
|
||||
|
||||
|
||||
@@ -48,7 +48,6 @@ class ServerConfigSeeder(DataSeederABC):
|
||||
guild.system_channel.id,
|
||||
guild.system_channel.id,
|
||||
guild.system_channel.id,
|
||||
{},
|
||||
server,
|
||||
[],
|
||||
[],
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
import json
|
||||
|
||||
from cpl_core.database.context import DatabaseContextABC
|
||||
from cpl_query.extension import List
|
||||
|
||||
@@ -43,11 +41,10 @@ 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,7 +32,6 @@ 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.1.4"
|
||||
__version__ = "1.0.7"
|
||||
|
||||
from collections import namedtuple
|
||||
|
||||
@@ -23,4 +23,4 @@ from collections import namedtuple
|
||||
# imports
|
||||
|
||||
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
||||
version_info = VersionInfo(major="1", minor="1", micro="4")
|
||||
version_info = VersionInfo(major="1", minor="0", micro="7")
|
||||
|
||||
@@ -15,7 +15,7 @@ __title__ = "bot_graphql.abc"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.1.4"
|
||||
__version__ = "1.0.7"
|
||||
|
||||
from collections import namedtuple
|
||||
|
||||
@@ -23,4 +23,4 @@ from collections import namedtuple
|
||||
# imports:
|
||||
|
||||
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
||||
version_info = VersionInfo(major="1", minor="1", micro="4")
|
||||
version_info = VersionInfo(major="1", minor="0", micro="7")
|
||||
|
||||
@@ -2,15 +2,12 @@ from typing import Callable
|
||||
|
||||
from ariadne import ObjectType
|
||||
from cpl_core.dependency_injection import ServiceProviderABC
|
||||
from cpl_core.type import T
|
||||
from cpl_discord.service import DiscordBotServiceABC
|
||||
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
|
||||
@@ -19,7 +16,6 @@ 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
|
||||
@@ -69,27 +65,13 @@ 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 get_services(services: ServiceProviderABC) -> ServiceProviderABC:
|
||||
return services
|
||||
|
||||
services = get_services()
|
||||
@ServiceProviderABC.inject
|
||||
def _can_user_see_element(self, user: AuthUser, element, services: ServiceProviderABC) -> bool:
|
||||
permissions: PermissionService = services.get_service(PermissionService)
|
||||
bot: DiscordBotServiceABC = services.get_service(DiscordBotServiceABC)
|
||||
|
||||
access = False
|
||||
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:
|
||||
if type(element) == AutoRole:
|
||||
element: AutoRole = element
|
||||
for u in user.users:
|
||||
u: User = u
|
||||
@@ -100,12 +82,12 @@ class QueryABC(ObjectType):
|
||||
break
|
||||
|
||||
elif type(element) == AutoRoleRule:
|
||||
element: AutoRoleRule = element
|
||||
element: AutoRole = 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.auto_role.server.id:
|
||||
if permissions.is_member_moderator(member) and u.server.id == element.server.id:
|
||||
access = True
|
||||
break
|
||||
|
||||
@@ -175,24 +157,6 @@ 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": "1",
|
||||
"Micro": "4"
|
||||
"Minor": "0",
|
||||
"Micro": "7"
|
||||
},
|
||||
"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.1.4"
|
||||
__version__ = "1.0.7"
|
||||
|
||||
from collections import namedtuple
|
||||
|
||||
@@ -23,4 +23,4 @@ from collections import namedtuple
|
||||
# imports:
|
||||
|
||||
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
||||
version_info = VersionInfo(major="1", minor="1", micro="4")
|
||||
version_info = VersionInfo(major="1", minor="0", micro="7")
|
||||
|
||||
@@ -1,53 +0,0 @@
|
||||
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
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
type FeatureFlag {
|
||||
key: String
|
||||
value: Boolean
|
||||
}
|
||||
|
||||
input FeatureFlagInput {
|
||||
key: String
|
||||
value: Boolean
|
||||
}
|
||||
@@ -37,12 +37,6 @@ 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
|
||||
@@ -111,13 +105,6 @@ 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)
|
||||
|
||||
@@ -1,26 +0,0 @@
|
||||
# -*- 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.4"
|
||||
|
||||
from collections import namedtuple
|
||||
|
||||
|
||||
# imports
|
||||
|
||||
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
||||
version_info = VersionInfo(major="1", minor="1", micro="4")
|
||||
29
kdb-bot/src/bot_graphql/model/discord.gql
Normal file
29
kdb-bot/src/bot_graphql/model/discord.gql
Normal file
@@ -0,0 +1,29 @@
|
||||
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
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
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
|
||||
@@ -38,6 +38,6 @@ type Query {
|
||||
achievementOperators: [String]
|
||||
|
||||
technicianConfig: TechnicianConfig
|
||||
possibleFeatureFlags: [String]
|
||||
discord: Discord
|
||||
|
||||
guilds(filter: GuildFilter): [Guild]
|
||||
}
|
||||
@@ -13,9 +13,6 @@ type ServerConfig implements TableWithHistoryQuery {
|
||||
helpVoiceChannelId: String
|
||||
teamChannelId: String
|
||||
loginMessageChannelId: String
|
||||
defaultRoleId: String
|
||||
featureFlagCount: Int
|
||||
featureFlags: [FeatureFlag]
|
||||
|
||||
afkChannelIds: [String]
|
||||
moderatorRoleIds: [String]
|
||||
@@ -44,9 +41,6 @@ type ServerConfigHistory implements HistoryTableQuery {
|
||||
helpVoiceChannelId: String
|
||||
teamChannelId: String
|
||||
loginMessageChannelId: String
|
||||
defaultRoleId: String
|
||||
featureFlagCount: Int
|
||||
featureFlags: [FeatureFlag]
|
||||
|
||||
serverId: ID
|
||||
|
||||
@@ -93,8 +87,6 @@ input ServerConfigInput {
|
||||
helpVoiceChannelId: String
|
||||
teamChannelId: String
|
||||
loginMessageChannelId: String
|
||||
defaultRoleId: String
|
||||
featureFlags: [FeatureFlagInput]
|
||||
|
||||
afkChannelIds: [String]
|
||||
moderatorRoleIds: [String]
|
||||
@@ -4,8 +4,6 @@ type TechnicianConfig implements TableWithHistoryQuery {
|
||||
waitForRestart: Int
|
||||
waitForShutdown: Int
|
||||
cacheMaxMessages: Int
|
||||
featureFlagCount: Int
|
||||
featureFlags: [FeatureFlag]
|
||||
pingURLs: [String]
|
||||
technicianIds: [String]
|
||||
|
||||
@@ -23,8 +21,6 @@ type TechnicianConfigHistory implements HistoryTableQuery {
|
||||
waitForRestart: Int
|
||||
waitForShutdown: Int
|
||||
cacheMaxMessages: Int
|
||||
featureFlagCount: Int
|
||||
featureFlags: [FeatureFlag]
|
||||
|
||||
deleted: Boolean
|
||||
dateFrom: String
|
||||
@@ -59,7 +55,6 @@ input TechnicianConfigInput {
|
||||
waitForRestart: Int
|
||||
waitForShutdown: Int
|
||||
cacheMaxMessages: Int
|
||||
featureFlags: [FeatureFlagInput]
|
||||
pingURLs: [String]
|
||||
technicianIds: [String]
|
||||
}
|
||||
@@ -15,7 +15,7 @@ __title__ = "bot_graphql.mutations"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.1.4"
|
||||
__version__ = "1.0.7"
|
||||
|
||||
from collections import namedtuple
|
||||
|
||||
@@ -23,4 +23,4 @@ from collections import namedtuple
|
||||
# imports:
|
||||
|
||||
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
||||
version_info = VersionInfo(major="1", minor="1", micro="4")
|
||||
version_info = VersionInfo(major="1", minor="0", micro="7")
|
||||
|
||||
@@ -3,8 +3,6 @@ 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
|
||||
@@ -13,7 +11,6 @@ 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):
|
||||
@@ -24,8 +21,6 @@ class ServerConfigMutation(QueryABC):
|
||||
servers: ServerRepositoryABC,
|
||||
server_configs: ServerConfigRepositoryABC,
|
||||
db: DatabaseContextABC,
|
||||
config_service: ConfigService,
|
||||
permissions: PermissionServiceABC,
|
||||
):
|
||||
QueryABC.__init__(self, "ServerConfigMutation")
|
||||
|
||||
@@ -34,8 +29,6 @@ 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)
|
||||
|
||||
@@ -43,8 +36,8 @@ class ServerConfigMutation(QueryABC):
|
||||
if "id" not in input:
|
||||
raise ValueError("Id not set")
|
||||
|
||||
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 = self._server_configs.get_server_config_by_server(input["id"])
|
||||
self._can_user_mutate_data(server_config, UserRoleEnum.admin)
|
||||
|
||||
server_config.message_delete_timer = (
|
||||
input["messageDeleteTimer"] if "messageDeleteTimer" in input else server_config.message_delete_timer
|
||||
@@ -89,14 +82,6 @@ class ServerConfigMutation(QueryABC):
|
||||
if "loginMessageChannelId" in input
|
||||
else server_config.login_message_channel_id
|
||||
)
|
||||
server_config.default_role_id = (
|
||||
input["defaultRoleId"] if "defaultRoleId" in input else server_config.default_role_id
|
||||
)
|
||||
server_config.feature_flags = (
|
||||
dict(zip([x["key"] for x in input["featureFlags"]], [x["value"] for x in input["featureFlags"]]))
|
||||
if "featureFlags" in input
|
||||
else server_config.feature_flags
|
||||
)
|
||||
server_config.afk_channel_ids = (
|
||||
List(int).extend([int(x) for x in input["afkChannelIds"]])
|
||||
if "afkChannelIds" in input
|
||||
@@ -140,7 +125,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_server(new_config.server.id)
|
||||
old_config = self._server_configs.get_server_config_by_id(new_config.server.id)
|
||||
for channel_id in old_config.afk_channel_ids:
|
||||
if channel_id in new_config.afk_channel_ids:
|
||||
continue
|
||||
@@ -158,7 +143,7 @@ class ServerConfigMutation(QueryABC):
|
||||
)
|
||||
|
||||
def _update_team_role_ids(self, new_config: ServerConfig):
|
||||
old_config = self._server_configs.get_server_config_by_server(new_config.server.id)
|
||||
old_config = self._server_configs.get_server_config_by_id(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
|
||||
@@ -176,6 +161,3 @@ 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,8 +3,6 @@ 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
|
||||
@@ -12,7 +10,6 @@ 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):
|
||||
@@ -23,8 +20,6 @@ class TechnicianConfigMutation(QueryABC):
|
||||
servers: ServerRepositoryABC,
|
||||
technician_configs: TechnicianConfigRepositoryABC,
|
||||
db: DatabaseContextABC,
|
||||
permissions: PermissionServiceABC,
|
||||
config_service: ConfigService,
|
||||
):
|
||||
QueryABC.__init__(self, "TechnicianConfigMutation")
|
||||
|
||||
@@ -33,14 +28,12 @@ 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(Route.get_user().users[0].server, UserRoleEnum.technician)
|
||||
self._can_user_mutate_data(technician_config, UserRoleEnum.admin)
|
||||
|
||||
technician_config.help_command_reference_url = (
|
||||
input["helpCommandReferenceUrl"]
|
||||
@@ -56,11 +49,6 @@ 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
|
||||
)
|
||||
@@ -112,6 +100,3 @@ 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.1.4"
|
||||
__version__ = "1.0.7"
|
||||
|
||||
from collections import namedtuple
|
||||
|
||||
@@ -23,4 +23,4 @@ from collections import namedtuple
|
||||
# imports:
|
||||
|
||||
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
||||
version_info = VersionInfo(major="1", minor="1", micro="4")
|
||||
version_info = VersionInfo(major="1", minor="0", micro="7")
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user