From 5afd0fafa85a2e0ce6610395217bf627218e47fc Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Tue, 10 Oct 2023 12:21:21 +0200 Subject: [PATCH 01/58] Show user warnings in profile & lazy load other stuff #402 --- .../bot_data/model/user_warnings_history.py | 43 ++++++ .../bot_graphql/filter/achievement_filter.py | 8 +- .../bot_graphql/filter/user_warning_filter.py | 56 ++++++++ kdb-bot/src/bot_graphql/graphql/query.gql | 3 + kdb-bot/src/bot_graphql/graphql/user.gql | 3 + .../src/bot_graphql/graphql/userWarning.gql | 27 ++++ kdb-bot/src/bot_graphql/graphql_module.py | 6 + kdb-bot/src/bot_graphql/queries/user_query.py | 6 + .../queries/user_warning_history_query.py | 11 ++ .../bot_graphql/queries/user_warning_query.py | 17 +++ kdb-bot/src/bot_graphql/query.py | 5 + kdb-web/package.json | 4 +- kdb-web/src/app/models/data/user.model.ts | 4 + .../src/app/models/data/user_warning.model.ts | 16 +++ .../src/app/models/graphql/queries.model.ts | 128 +++++++++++------- kdb-web/src/app/models/graphql/query.model.ts | 6 + .../server/profile/profile.component.html | 107 ++++++++++++++- .../view/server/profile/profile.component.ts | 88 +++++++++++- .../app/modules/view/server/server.module.ts | 17 ++- .../app/services/sidebar/sidebar.service.ts | 1 - kdb-web/src/assets/i18n/de.json | 2 + kdb-web/src/assets/version.json | 12 +- kdb-web/src/styles.scss | 8 +- .../src/styles/themes/default-dark-theme.scss | 3 +- .../styles/themes/default-light-theme.scss | 3 +- .../styles/themes/sh-edraft-dark-theme.scss | 3 +- .../styles/themes/sh-edraft-light-theme.scss | 3 +- 27 files changed, 508 insertions(+), 82 deletions(-) create mode 100644 kdb-bot/src/bot_data/model/user_warnings_history.py create mode 100644 kdb-bot/src/bot_graphql/filter/user_warning_filter.py create mode 100644 kdb-bot/src/bot_graphql/graphql/userWarning.gql create mode 100644 kdb-bot/src/bot_graphql/queries/user_warning_history_query.py create mode 100644 kdb-bot/src/bot_graphql/queries/user_warning_query.py create mode 100644 kdb-web/src/app/models/data/user_warning.model.ts diff --git a/kdb-bot/src/bot_data/model/user_warnings_history.py b/kdb-bot/src/bot_data/model/user_warnings_history.py new file mode 100644 index 00000000..a0ddef24 --- /dev/null +++ b/kdb-bot/src/bot_data/model/user_warnings_history.py @@ -0,0 +1,43 @@ +from typing import Optional + +from bot_data.abc.history_table_abc import HistoryTableABC + + +# had to name it UserWarnings instead of UserWarning because UserWarning is a builtin class +class UserWarningsHistory(HistoryTableABC): + def __init__( + self, + description: str, + user: int, + author: Optional[int], + deleted: bool, + date_from: str, + date_to: str, + id=0, + ): + HistoryTableABC.__init__(self) + + self._id = id + self._description = description + self._user = user + self._author = author + + self._deleted = deleted + self._date_from = date_from + self._date_to = date_to + + @property + def id(self) -> int: + return self._id + + @property + def description(self) -> str: + return self._description + + @property + def user(self) -> int: + return self._user + + @property + def author(self) -> Optional[int]: + return self._author diff --git a/kdb-bot/src/bot_graphql/filter/achievement_filter.py b/kdb-bot/src/bot_graphql/filter/achievement_filter.py index 674af502..b95e00c0 100644 --- a/kdb-bot/src/bot_graphql/filter/achievement_filter.py +++ b/kdb-bot/src/bot_graphql/filter/achievement_filter.py @@ -1,3 +1,4 @@ +from cpl_core.dependency_injection import ServiceProviderABC from cpl_query.extension import List from bot_data.model.user import User @@ -5,9 +6,14 @@ from bot_graphql.abc.filter_abc import FilterABC class AchievementFilter(FilterABC): - def __init__(self): + def __init__( + self, + services: ServiceProviderABC, + ): FilterABC.__init__(self) + self._services = services + self._id = None self._name = None self._description = None diff --git a/kdb-bot/src/bot_graphql/filter/user_warning_filter.py b/kdb-bot/src/bot_graphql/filter/user_warning_filter.py new file mode 100644 index 00000000..2c716c9e --- /dev/null +++ b/kdb-bot/src/bot_graphql/filter/user_warning_filter.py @@ -0,0 +1,56 @@ +from cpl_core.dependency_injection import ServiceProviderABC +from cpl_query.extension import List + +from bot_data.model.user_warnings import UserWarnings +from bot_graphql.abc.filter_abc import FilterABC + + +class UserWarningFilter(FilterABC): + def __init__( + self, + services: ServiceProviderABC, + ): + FilterABC.__init__(self) + + self._services = services + + self._id = None + self._user = None + self._description = None + self._author = None + + def from_dict(self, values: dict): + if "id" in values: + self._id = int(values["id"]) + + if "user" in values: + from bot_graphql.filter.user_filter import UserFilter + + self._user: UserFilter = self._services.get_service(UserFilter) + self._user.from_dict(values["user"]) + + if "description" in values: + self._description = values["description"] + + if "author" in values: + from bot_graphql.filter.user_filter import UserFilter + + self._author: UserFilter = self._services.get_service(UserFilter) + self._author.from_dict(values["author"]) + + def filter(self, query: List[UserWarnings]) -> List[UserWarnings]: + if self._id is not None: + query = query.where(lambda x: x.id == self._id) + + if self._user is not None: + users = self._user.filter(query.select(lambda x: x.user)).select(lambda x: x.id) + query = query.where(lambda x: x.id in users) + + if self._description is not None: + query = query.where(lambda x: x.description == self._description or self._description in x.description) + + if self._author is not None: + users = self._author.filter(query.select(lambda x: x.author)).select(lambda x: x.id) + query = query.where(lambda x: x.id in users) + + return query diff --git a/kdb-bot/src/bot_graphql/graphql/query.gql b/kdb-bot/src/bot_graphql/graphql/query.gql index 8946e9a9..ffa3c21f 100644 --- a/kdb-bot/src/bot_graphql/graphql/query.gql +++ b/kdb-bot/src/bot_graphql/graphql/query.gql @@ -41,6 +41,9 @@ type Query { shortRoleNames(filter: ShortRoleNameFilter, page: Page, sort: Sort): [ShortRoleName] shortRoleNamePositions: [String] + userWarningCount: Int + userWarnings(filter: UserWarningFilter, page: Page, sort: Sort): [UserWarning] + technicianConfig: TechnicianConfig possibleFeatureFlags: [String] discord: Discord diff --git a/kdb-bot/src/bot_graphql/graphql/user.gql b/kdb-bot/src/bot_graphql/graphql/user.gql index 38db3573..84800a8b 100644 --- a/kdb-bot/src/bot_graphql/graphql/user.gql +++ b/kdb-bot/src/bot_graphql/graphql/user.gql @@ -20,6 +20,9 @@ type User implements TableWithHistoryQuery { achievementCount: Int achievements(filter: AchievementFilter, page: Page, sort: Sort): [Achievement] + userWarningCount: Int + userWarnings(filter: UserWarningFilter, page: Page, sort: Sort): [UserWarning] + server: Server leftServer: Boolean diff --git a/kdb-bot/src/bot_graphql/graphql/userWarning.gql b/kdb-bot/src/bot_graphql/graphql/userWarning.gql new file mode 100644 index 00000000..22454da3 --- /dev/null +++ b/kdb-bot/src/bot_graphql/graphql/userWarning.gql @@ -0,0 +1,27 @@ +type UserWarning implements TableWithHistoryQuery { + id: ID + user: User + description: String + author: User + + createdAt: String + modifiedAt: String + + history: [UserWarningHistory] +} + +type UserWarningHistory implements HistoryTableQuery { + id: ID + user: ID + description: String + author: ID + + deleted: Boolean + dateFrom: String + dateTo: String +} + +input UserWarningFilter { + id: ID + user: UserFilter +} \ No newline at end of file diff --git a/kdb-bot/src/bot_graphql/graphql_module.py b/kdb-bot/src/bot_graphql/graphql_module.py index 96c72797..07d028c0 100644 --- a/kdb-bot/src/bot_graphql/graphql_module.py +++ b/kdb-bot/src/bot_graphql/graphql_module.py @@ -18,6 +18,7 @@ from bot_graphql.filter.user_filter import UserFilter from bot_graphql.filter.user_joined_game_server_filter import UserJoinedGameServerFilter from bot_graphql.filter.user_joined_server_filter import UserJoinedServerFilter from bot_graphql.filter.user_joined_voice_channel_filter import UserJoinedVoiceChannelFilter +from bot_graphql.filter.user_warning_filter import UserWarningFilter from bot_graphql.graphql_service import GraphQLService from bot_graphql.mutation import Mutation from bot_graphql.mutations.achievement_mutation import AchievementMutation @@ -66,6 +67,8 @@ from bot_graphql.queries.user_joined_server_query import UserJoinedServerQuery from bot_graphql.queries.user_joined_voice_channel_history_query import UserJoinedVoiceChannelHistoryQuery from bot_graphql.queries.user_joined_voice_channel_query import UserJoinedVoiceChannelQuery from bot_graphql.queries.user_query import UserQuery +from bot_graphql.queries.user_warning_history_query import UserWarningHistoryQuery +from bot_graphql.queries.user_warning_query import UserWarningQuery from bot_graphql.query import Query from bot_graphql.schema import Schema @@ -115,6 +118,8 @@ class GraphQLModule(ModuleABC): services.add_transient(QueryABC, UserJoinedGameServerQuery) services.add_transient(QueryABC, ShortRoleNameHistoryQuery) services.add_transient(QueryABC, ShortRoleNameQuery) + services.add_transient(QueryABC, UserWarningHistoryQuery) + services.add_transient(QueryABC, UserWarningQuery) services.add_transient(QueryABC, DiscordQuery) services.add_transient(QueryABC, GuildQuery) @@ -135,6 +140,7 @@ class GraphQLModule(ModuleABC): services.add_transient(FilterABC, UserJoinedVoiceChannelFilter) services.add_transient(FilterABC, UserJoinedGameServerFilter) services.add_transient(FilterABC, ShortRoleNameFilter) + services.add_transient(FilterABC, UserWarningFilter) # mutations services.add_transient(QueryABC, AutoRoleMutation) diff --git a/kdb-bot/src/bot_graphql/queries/user_query.py b/kdb-bot/src/bot_graphql/queries/user_query.py index 9bb4a48b..f015c847 100644 --- a/kdb-bot/src/bot_graphql/queries/user_query.py +++ b/kdb-bot/src/bot_graphql/queries/user_query.py @@ -6,6 +6,7 @@ from bot_data.abc.achievement_repository_abc import AchievementRepositoryABC from bot_data.abc.user_joined_game_server_repository_abc import UserJoinedGameServerRepositoryABC from bot_data.abc.user_joined_server_repository_abc import UserJoinedServerRepositoryABC from bot_data.abc.user_joined_voice_channel_repository_abc import UserJoinedVoiceChannelRepositoryABC +from bot_data.abc.user_warnings_repository_abc import UserWarningsRepositoryABC from bot_data.model.user import User from bot_data.model.user_history import UserHistory from bot_graphql.abc.data_query_with_history_abc import DataQueryWithHistoryABC @@ -13,6 +14,7 @@ from bot_graphql.filter.achievement_filter import AchievementFilter from bot_graphql.filter.user_joined_game_server_filter import UserJoinedGameServerFilter from bot_graphql.filter.user_joined_server_filter import UserJoinedServerFilter from bot_graphql.filter.user_joined_voice_channel_filter import UserJoinedVoiceChannelFilter +from bot_graphql.filter.user_warning_filter import UserWarningFilter from modules.level.service.level_service import LevelService from modules.permission.abc.permission_service_abc import PermissionServiceABC @@ -29,6 +31,7 @@ class UserQuery(DataQueryWithHistoryABC): user_joined_game_server: UserJoinedGameServerRepositoryABC, permissions: PermissionServiceABC, achievements: AchievementRepositoryABC, + user_warnings: UserWarningsRepositoryABC, ): DataQueryWithHistoryABC.__init__(self, "User", "UsersHistory", UserHistory, db) @@ -67,6 +70,9 @@ class UserQuery(DataQueryWithHistoryABC): self.add_collection( "achievement", lambda user, *_: achievements.get_achievements_by_user_id(user.id), AchievementFilter ) + self.add_collection( + "userWarning", lambda user, *_: user_warnings.get_user_warnings_by_user_id(user.id), UserWarningFilter + ) self.set_field("server", self.resolve_server) self.set_field("leftServer", self.resolve_left_server) diff --git a/kdb-bot/src/bot_graphql/queries/user_warning_history_query.py b/kdb-bot/src/bot_graphql/queries/user_warning_history_query.py new file mode 100644 index 00000000..c120e360 --- /dev/null +++ b/kdb-bot/src/bot_graphql/queries/user_warning_history_query.py @@ -0,0 +1,11 @@ +from bot_graphql.abc.history_query_abc import HistoryQueryABC + + +class UserWarningHistoryQuery(HistoryQueryABC): + def __init__(self): + HistoryQueryABC.__init__(self, "UserWarning") + + self.set_field("id", lambda x, *_: x.id) + self.set_field("user", lambda x, *_: x.user) + self.set_field("description", lambda x, *_: x.description) + self.set_field("author", lambda x, *_: x.author) diff --git a/kdb-bot/src/bot_graphql/queries/user_warning_query.py b/kdb-bot/src/bot_graphql/queries/user_warning_query.py new file mode 100644 index 00000000..f6243d5e --- /dev/null +++ b/kdb-bot/src/bot_graphql/queries/user_warning_query.py @@ -0,0 +1,17 @@ +from cpl_core.database.context import DatabaseContextABC + +from bot_data.model.user_warnings_history import UserWarningsHistory +from bot_graphql.abc.data_query_with_history_abc import DataQueryWithHistoryABC + + +class UserWarningQuery(DataQueryWithHistoryABC): + def __init__( + self, + db: DatabaseContextABC, + ): + DataQueryWithHistoryABC.__init__(self, "UserWarning", "UserWarningsHistory", UserWarningsHistory, db) + + self.set_field("id", lambda x, *_: x.id) + self.set_field("user", lambda x, *_: x.user) + self.set_field("description", lambda x, *_: x.description) + self.set_field("author", lambda x, *_: x.author) diff --git a/kdb-bot/src/bot_graphql/query.py b/kdb-bot/src/bot_graphql/query.py index abde5cb0..5ddb67dd 100644 --- a/kdb-bot/src/bot_graphql/query.py +++ b/kdb-bot/src/bot_graphql/query.py @@ -15,6 +15,7 @@ from bot_data.abc.user_joined_game_server_repository_abc import UserJoinedGameSe from bot_data.abc.user_joined_server_repository_abc import UserJoinedServerRepositoryABC from bot_data.abc.user_joined_voice_channel_repository_abc import UserJoinedVoiceChannelRepositoryABC from bot_data.abc.user_repository_abc import UserRepositoryABC +from bot_data.abc.user_warnings_repository_abc import UserWarningsRepositoryABC from bot_data.model.short_role_name_position_enum import ShortRoleNamePositionEnum from bot_graphql.abc.query_abc import QueryABC from bot_graphql.filter.achievement_filter import AchievementFilter @@ -28,6 +29,7 @@ from bot_graphql.filter.user_filter import UserFilter from bot_graphql.filter.user_joined_game_server_filter import UserJoinedGameServerFilter from bot_graphql.filter.user_joined_server_filter import UserJoinedServerFilter from bot_graphql.filter.user_joined_voice_channel_filter import UserJoinedVoiceChannelFilter +from bot_graphql.filter.user_warning_filter import UserWarningFilter from bot_graphql.model.discord import Discord from modules.achievements.achievement_service import AchievementService @@ -48,6 +50,7 @@ class Query(QueryABC): users: UserRepositoryABC, achievements: AchievementRepositoryABC, short_role_names: ShortRoleNameRepositoryABC, + user_warnings: UserWarningsRepositoryABC, achievement_service: AchievementService, technician_config: TechnicianConfigRepositoryABC, ): @@ -76,11 +79,13 @@ class Query(QueryABC): self.add_collection("user", lambda *_: users.get_users(), UserFilter) self.add_collection("achievement", lambda *_: achievements.get_achievements(), AchievementFilter) self.add_collection("shortRoleName", lambda *_: short_role_names.get_short_role_names(), ShortRoleNameFilter) + self.add_collection("userWarning", lambda *_: user_warnings.get_user_warnings(), UserWarningFilter) self.set_field("technicianConfig", lambda *_: technician_config.get_technician_config()) self.set_field("achievementAttributes", lambda *_: achievement_service.get_attributes()) self.set_field("achievementOperators", lambda *_: achievement_service.get_operators()) self.set_field("shortRoleNamePositions", lambda *_: [x.value for x in ShortRoleNamePositionEnum]) + self.set_field("possibleFeatureFlags", lambda *_: [e.value for e in FeatureFlagsEnum]) self.set_field("discord", lambda *_: Discord(bot.guilds, List(any).extend(bot.users))) diff --git a/kdb-web/package.json b/kdb-web/package.json index 1b99a94e..c7f77d8c 100644 --- a/kdb-web/package.json +++ b/kdb-web/package.json @@ -1,6 +1,6 @@ { "name": "kdb-web", - "version": "1.1.10", + "version": "1.1.dev402", "scripts": { "ng": "ng", "update-version": "ts-node update-version.ts", @@ -51,4 +51,4 @@ "tslib": "^2.4.1", "typescript": "~4.9.5" } -} +} \ No newline at end of file diff --git a/kdb-web/src/app/models/data/user.model.ts b/kdb-web/src/app/models/data/user.model.ts index 6d649da4..8082e781 100644 --- a/kdb-web/src/app/models/data/user.model.ts +++ b/kdb-web/src/app/models/data/user.model.ts @@ -5,6 +5,7 @@ import { UserJoinedServer } from "./user_joined_server.model"; import { UserJoinedVoiceChannel } from "./user_joined_voice_channel.model"; import { UserJoinedGameServer } from "./user_joined_game_server.model"; import { Achievement } from "./achievement.model"; +import { UserWarning } from "./user_warning.model"; export interface User extends DataWithHistory { id?: number; @@ -29,6 +30,9 @@ export interface User extends DataWithHistory { achievementCount?: number; achievements?: Achievement[]; + + userWarningCount?: number; + userWarnings?: UserWarning[]; } export interface UserFilter { diff --git a/kdb-web/src/app/models/data/user_warning.model.ts b/kdb-web/src/app/models/data/user_warning.model.ts new file mode 100644 index 00000000..37ceeae9 --- /dev/null +++ b/kdb-web/src/app/models/data/user_warning.model.ts @@ -0,0 +1,16 @@ +import { DataWithHistory } from "./data.model"; +import { User, UserFilter } from "./user.model"; + +export interface UserWarning extends DataWithHistory { + id?: number; + user?: User; + description?: string; + author?: User; +} + +export interface UserWarningFilter { + id?: number; + user?: UserFilter; + description?: string; + author?: UserFilter; +} diff --git a/kdb-web/src/app/models/graphql/queries.model.ts b/kdb-web/src/app/models/graphql/queries.model.ts index 02c2da1d..4f87d53b 100644 --- a/kdb-web/src/app/models/graphql/queries.model.ts +++ b/kdb-web/src/app/models/graphql/queries.model.ts @@ -208,7 +208,7 @@ export class Queries { query { shortRoleNamePositions } - ` + `; static shortRoleNameQuery = ` query ShortRoleNameList($serverId: ID, $filter: ShortRoleNameFilter, $page: Page, $sort: Sort) { @@ -279,58 +279,94 @@ export class Queries { static userProfile = ` query UserProfile($serverId: ID, $userId: ID, $page: Page, $sort: Sort) { - servers(filter: {id: $serverId}) { - userCount - users(filter: {id: $userId}, page: $page, sort: $sort) { + userCount + users(filter: {server: {id: $serverId}, id: $userId}, page: $page, sort: $sort) { + id + discordId + name + xp + ontime + level { id - discordId name - xp - ontime - level { + } + leftServer + server { + id + name + } + + joinedServerCount + joinedServers { + id + joinedOn + leavedOn + } + + createdAt + modifiedAt + } + } + `; + + static userProfileAchievements = ` + query UserProfile($serverId: ID, $userId: ID, $page: Page, $sort: Sort) { + users(filter: {server: {id: $serverId}, id: $userId}, page: $page, sort: $sort) { + achievementCount + achievements { + id + name + description + createdAt + } + } + } + `; + + static userProfileVoiceChannelJoins = ` + query UserProfile($serverId: ID, $userId: ID, $page: Page, $sort: Sort) { + users(filter: {server: {id: $serverId}, id: $userId}, page: $page, sort: $sort) { + joinedVoiceChannelCount + joinedVoiceChannels { + id + channelId + channelName + time + joinedOn + leavedOn + } + } + } + `; + + static userProfileGameserverJoins = ` + query UserProfile($serverId: ID, $userId: ID, $page: Page, $sort: Sort) { + users(filter: {server: {id: $serverId}, id: $userId}, page: $page, sort: $sort) { + userJoinedGameServerCount + userJoinedGameServers { + id + gameServer + time + joinedOn + leavedOn + } + } + } + `; + + static userProfileWarnings = ` + query UserProfile($serverId: ID, $userId: ID, $page: Page, $sort: Sort) { + users(filter: {server: {id: $serverId}, id: $userId}, page: $page, sort: $sort) { + userWarningCount + userWarnings { + id + description + author { id name } - leftServer - server { - id - name - } - - joinedServerCount - joinedServers { - id - joinedOn - leavedOn - } - - joinedVoiceChannelCount - joinedVoiceChannels { - id - channelId - channelName - time - joinedOn - leavedOn - } - - userJoinedGameServerCount - userJoinedGameServers { - id - gameServer - time - joinedOn - leavedOn - } - - achievements { - id - name - createdAt - } createdAt - modifiedAt } } } diff --git a/kdb-web/src/app/models/graphql/query.model.ts b/kdb-web/src/app/models/graphql/query.model.ts index 7fc95684..f98f9a4a 100644 --- a/kdb-web/src/app/models/graphql/query.model.ts +++ b/kdb-web/src/app/models/graphql/query.model.ts @@ -8,6 +8,7 @@ import { TechnicianConfig } from "../config/technician-config.model"; import { ServerConfig } from "../config/server-config.model"; import { ShortRoleName } from "../data/short_role_name.model"; import { FeatureFlag } from "../config/feature-flags.model"; +import { UserWarning } from "../data/user_warning.model"; export interface Query { serverCount: number; @@ -31,6 +32,11 @@ export interface UserListQuery { users: User[]; } +export interface UserWarningQuery { + userWarningCount: number; + userWarnings: UserWarning[]; +} + export interface GameServerListQuery { gameServerCount: number; gameServers: GameServer[]; diff --git a/kdb-web/src/app/modules/view/server/profile/profile.component.html b/kdb-web/src/app/modules/view/server/profile/profile.component.html index 28de57cb..a101087f 100644 --- a/kdb-web/src/app/modules/view/server/profile/profile.component.html +++ b/kdb-web/src/app/modules/view/server/profile/profile.component.html @@ -76,9 +76,103 @@ +
+
+ + +
+
+
+

{{'common.user_warnings' | translate}}

+
+
+
+ +
+
+
+ + + +
+
{{'common.description' | translate}}
+
+ + + +
+
{{'common.author' | translate}}
+
+ + + +
+
{{'common.created_at' | translate}}
+
+ + + +
+
{{'common.actions' | translate}}
+
+ + +
+ + + + + + + + + {{value.description}} + + + + + + + {{value.author.name}} + + + {{value.author.name}} + + + + + + {{'common.created_at' | translate}}: + + + {{value.createdAt | date:'dd.MM.yy HH:mm'}} + + + {{value.createdAt | date:'dd.MM.yy HH:mm'}} + + + + +
+ + + + +
+ + +
+
+
+
+
- +
@@ -86,6 +180,11 @@
{{achievement.name}}
+
+
{{'common.description' | translate}}:
+
{{achievement.description}}
+
+
{{'view.server.profile.achievements.time' | translate}}:
{{achievement.createdAt | date:'dd.MM.yyyy HH:mm:ss'}}
@@ -94,7 +193,8 @@
- +
@@ -120,7 +220,8 @@
- +
diff --git a/kdb-web/src/app/modules/view/server/profile/profile.component.ts b/kdb-web/src/app/modules/view/server/profile/profile.component.ts index 4df9cda5..60650137 100644 --- a/kdb-web/src/app/modules/view/server/profile/profile.component.ts +++ b/kdb-web/src/app/modules/view/server/profile/profile.component.ts @@ -1,7 +1,7 @@ import { Component, OnDestroy, OnInit } from "@angular/core"; import { ActivatedRoute, Router } from "@angular/router"; import { Queries } from "../../../../models/graphql/queries.model"; -import { UserListQuery } from "../../../../models/graphql/query.model"; +import { UserListQuery, UserWarningQuery } from "../../../../models/graphql/query.model"; import { SpinnerService } from "../../../../services/spinner/spinner.service"; import { DataService } from "../../../../services/data/data.service"; import { User } from "../../../../models/data/user.model"; @@ -10,8 +10,9 @@ import { AuthService } from "src/app/services/auth/auth.service"; import { ToastService } from "src/app/services/toast/toast.service"; import { TranslateService } from "@ngx-translate/core"; import { Server } from "../../../../models/data/server.model"; -import { Subject } from "rxjs"; +import { forkJoin, Subject } from "rxjs"; import { takeUntil } from "rxjs/operators"; +import { Table } from "primeng/table"; @Component({ selector: "app-profile", @@ -58,16 +59,27 @@ export class ProfileComponent implements OnInit, OnDestroy { this.data.query(Queries.userProfile, { serverId: this.server.id, userId: params["memberId"] - }, - (x: { servers: Server[] }) => { - return x.servers[0]; } ).subscribe(users => { if (!users.users[0]) { this.router.navigate([`/server/${server.id}`]); } this.user = users.users[0]; - this.spinner.hideSpinner(); + + this.data.query(Queries.userProfileWarnings, { + serverId: this.server.id, + userId: this.user.id + }, + (data: UserListQuery) => { + return data.users[0]; + } + ).subscribe(result => { + this.user.userWarningCount = result.userWarningCount; + this.user.userWarnings = result.userWarnings; + console.log(result); + + this.spinner.hideSpinner(); + }); }); }); }); @@ -77,4 +89,68 @@ export class ProfileComponent implements OnInit, OnDestroy { this.unsubscriber.next(); this.unsubscriber.complete(); } + + public onBeforeToggle(event: Event, collapsed: boolean) { + const filterUser = (x: { users: User[] }) => { + const users = x.users ?? []; + return users[0]; + }; + + if (collapsed) { + this.spinner.showSpinner(); + forkJoin([ + this.data.query(Queries.userProfileAchievements, { + serverId: this.server.id, + userId: this.user.id + }, + filterUser + ), + this.data.query(Queries.userProfileVoiceChannelJoins, { + serverId: this.server.id, + userId: this.user.id + }, + filterUser + ), + this.data.query(Queries.userProfileGameserverJoins, { + serverId: this.server.id, + userId: this.user.id + }, + filterUser + ) + ]).subscribe(data => { + this.user.achievementCount = data[0].achievementCount; + this.user.achievements = data[0].achievements; + + this.user.joinedVoiceChannelCount = data[1].joinedVoiceChannelCount; + this.user.joinedVoiceChannels = data[1].joinedVoiceChannels; + + this.user.userJoinedGameServerCount = data[2].userJoinedGameServerCount; + this.user.userJoinedGameServers = data[2].userJoinedGameServers; + this.spinner.hideSpinner(); + }); + return; + } + this.user.achievementCount = 0; + this.user.achievements = []; + + this.user.userJoinedGameServerCount = 0; + this.user.userJoinedGameServers = []; + + this.user.joinedVoiceChannelCount = 0; + this.user.joinedVoiceChannels = []; + } + + addNewUserWarning(table: Table) { + } + + deleteUserWarning(index: number) { + } + + editSaveUserWarning(value: any, index: number) { + } + + editCancelUserWarning(index: number) { + } + + protected readonly visualViewport = visualViewport; } diff --git a/kdb-web/src/app/modules/view/server/server.module.ts b/kdb-web/src/app/modules/view/server/server.module.ts index 6a04b47f..5ac78d1c 100644 --- a/kdb-web/src/app/modules/view/server/server.module.ts +++ b/kdb-web/src/app/modules/view/server/server.module.ts @@ -1,12 +1,11 @@ -import { NgModule } from '@angular/core'; -import { CommonModule } from '@angular/common'; -import { ServerDashboardComponent } from './server-dashboard/server-dashboard.component'; -import { ServerRoutingModule } from './server-routing.module'; -import { SharedModule } from '../../shared/shared.module'; -import { ProfileComponent } from './profile/profile.component'; -import { MembersComponent } from './members/members.component'; -import { ClientComponent } from './server-dashboard/components/client/client.component'; - +import { NgModule } from "@angular/core"; +import { CommonModule } from "@angular/common"; +import { ServerDashboardComponent } from "./server-dashboard/server-dashboard.component"; +import { ServerRoutingModule } from "./server-routing.module"; +import { SharedModule } from "../../shared/shared.module"; +import { ProfileComponent } from "./profile/profile.component"; +import { MembersComponent } from "./members/members.component"; +import { ClientComponent } from "./server-dashboard/components/client/client.component"; @NgModule({ diff --git a/kdb-web/src/app/services/sidebar/sidebar.service.ts b/kdb-web/src/app/services/sidebar/sidebar.service.ts index a416e57c..2a1f3861 100644 --- a/kdb-web/src/app/services/sidebar/sidebar.service.ts +++ b/kdb-web/src/app/services/sidebar/sidebar.service.ts @@ -194,7 +194,6 @@ export class SidebarService { let user: UserDTO | null = authUser?.users?.find(u => u.server == this.server?.id) ?? null; let isTechnician = (authUser?.users?.map(u => u.isTechnician).filter(u => u) ?? []).length > 0; let isTechnicianAndFullAccessActive = this.hasFeature("TechnicianFullAccess") && isTechnician; - console.log(this.hasFeature("TechnicianFullAccess")) if (build || this.menuItems$.value.length == 0) { await this.buildMenu(user, hasPermission, isTechnician); diff --git a/kdb-web/src/assets/i18n/de.json b/kdb-web/src/assets/i18n/de.json index 12b18760..2219275a 100644 --- a/kdb-web/src/assets/i18n/de.json +++ b/kdb-web/src/assets/i18n/de.json @@ -122,6 +122,8 @@ } }, "common": { + "user_warnings": "Verwarnungen", + "author": "Autor", "404": "404 - Der Eintrag konnte nicht gefunden werden", "actions": "Aktionen", "active": "Aktiv", diff --git a/kdb-web/src/assets/version.json b/kdb-web/src/assets/version.json index f7826e37..e044326d 100644 --- a/kdb-web/src/assets/version.json +++ b/kdb-web/src/assets/version.json @@ -1,7 +1,7 @@ { - "WebVersion": { - "Major": "1", - "Minor": "1", - "Micro": "10" - } -} + "WebVersion": { + "Major": "1", + "Minor": "1", + "Micro": "dev402" + } +} \ No newline at end of file diff --git a/kdb-web/src/styles.scss b/kdb-web/src/styles.scss index 16baf300..a9d27980 100644 --- a/kdb-web/src/styles.scss +++ b/kdb-web/src/styles.scss @@ -201,10 +201,10 @@ header { font-size: 18px; } + } - .content-divider { - margin: 5px 0; - } + .content-divider { + margin: 10px 0; } p-panel { @@ -493,7 +493,7 @@ header { } .content-divider { - margin: 5px 0; + margin: 10px 0; } .content-input-field { diff --git a/kdb-web/src/styles/themes/default-dark-theme.scss b/kdb-web/src/styles/themes/default-dark-theme.scss index e3283097..58abe55e 100644 --- a/kdb-web/src/styles/themes/default-dark-theme.scss +++ b/kdb-web/src/styles/themes/default-dark-theme.scss @@ -20,7 +20,8 @@ background-color: $primaryBackgroundColor; h1, - h2 { + h2, + h3 { color: $primaryHeaderColor; } diff --git a/kdb-web/src/styles/themes/default-light-theme.scss b/kdb-web/src/styles/themes/default-light-theme.scss index 41d46599..115dff70 100644 --- a/kdb-web/src/styles/themes/default-light-theme.scss +++ b/kdb-web/src/styles/themes/default-light-theme.scss @@ -20,7 +20,8 @@ background-color: $primaryBackgroundColor; h1, - h2 { + h2, + h3 { color: $primaryHeaderColor; } diff --git a/kdb-web/src/styles/themes/sh-edraft-dark-theme.scss b/kdb-web/src/styles/themes/sh-edraft-dark-theme.scss index a23b4064..fba55057 100644 --- a/kdb-web/src/styles/themes/sh-edraft-dark-theme.scss +++ b/kdb-web/src/styles/themes/sh-edraft-dark-theme.scss @@ -21,7 +21,8 @@ h1, - h2 { + h2, + h3 { color: $primaryHeaderColor; } diff --git a/kdb-web/src/styles/themes/sh-edraft-light-theme.scss b/kdb-web/src/styles/themes/sh-edraft-light-theme.scss index e1191651..870fb6e0 100644 --- a/kdb-web/src/styles/themes/sh-edraft-light-theme.scss +++ b/kdb-web/src/styles/themes/sh-edraft-light-theme.scss @@ -20,7 +20,8 @@ background-color: $primaryBackgroundColor; h1, - h2 { + h2, + h3 { color: $primaryHeaderColor; } -- 2.45.2 From 61bdc8a52a2da782de8e1e5e5db752efd04768ec Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Tue, 10 Oct 2023 15:50:38 +0200 Subject: [PATCH 02/58] Improved user warnings in WI #402 --- .../user_warnings_repository_service.py | 2 +- kdb-bot/src/bot_graphql/graphql/user.gql | 1 + .../src/bot_graphql/graphql/userWarning.gql | 7 ++ .../mutations/server_config_mutation.py | 3 +- .../bot_graphql/mutations/user_mutation.py | 26 +++++++ .../src/modules/base/command/user_group.py | 4 +- .../base/service/user_warnings_service.py | 41 +++++++--- .../src/app/models/graphql/mutations.model.ts | 54 ++++++++++++- .../src/app/models/graphql/queries.model.ts | 4 + .../src/app/models/graphql/result.model.ts | 9 +++ .../server/profile/profile.component.html | 11 ++- .../view/server/profile/profile.component.ts | 76 +++++++++++++++++-- 12 files changed, 215 insertions(+), 23 deletions(-) diff --git a/kdb-bot/src/bot_data/service/user_warnings_repository_service.py b/kdb-bot/src/bot_data/service/user_warnings_repository_service.py index ff19d61f..34cded9b 100644 --- a/kdb-bot/src/bot_data/service/user_warnings_repository_service.py +++ b/kdb-bot/src/bot_data/service/user_warnings_repository_service.py @@ -32,7 +32,7 @@ class UserWarningsRepositoryService(UserWarningsRepositoryABC): def _from_result(self, sql_result: tuple) -> UserWarnings: user = self._users.get_user_by_id(self._get_value_from_result(sql_result[2])) author = None - author_id = self._get_value_from_result(sql_result[2]) + author_id = self._get_value_from_result(sql_result[3]) if author_id is not None: author = self._users.get_user_by_id(author_id) diff --git a/kdb-bot/src/bot_graphql/graphql/user.gql b/kdb-bot/src/bot_graphql/graphql/user.gql index 84800a8b..f89e8483 100644 --- a/kdb-bot/src/bot_graphql/graphql/user.gql +++ b/kdb-bot/src/bot_graphql/graphql/user.gql @@ -63,4 +63,5 @@ input UserInput { id: ID xp: Int levelId: ID + userWarnings: [UserWarningInput] } \ No newline at end of file diff --git a/kdb-bot/src/bot_graphql/graphql/userWarning.gql b/kdb-bot/src/bot_graphql/graphql/userWarning.gql index 22454da3..d36a9eeb 100644 --- a/kdb-bot/src/bot_graphql/graphql/userWarning.gql +++ b/kdb-bot/src/bot_graphql/graphql/userWarning.gql @@ -24,4 +24,11 @@ type UserWarningHistory implements HistoryTableQuery { input UserWarningFilter { id: ID user: UserFilter +} + +input UserWarningInput { + id: ID + user: ID + description: String + author: ID } \ No newline at end of file diff --git a/kdb-bot/src/bot_graphql/mutations/server_config_mutation.py b/kdb-bot/src/bot_graphql/mutations/server_config_mutation.py index 044ec3be..024ab3c0 100644 --- a/kdb-bot/src/bot_graphql/mutations/server_config_mutation.py +++ b/kdb-bot/src/bot_graphql/mutations/server_config_mutation.py @@ -139,6 +139,7 @@ class ServerConfigMutation(QueryABC): self._update_team_role_ids(server_config) self._db.save_changes() + self._bot.loop.create_task(self._config_service.reload_server_config(server_config.server)) return server_config def _update_afk_channel_ids(self, new_config: ServerConfig): @@ -178,5 +179,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)) diff --git a/kdb-bot/src/bot_graphql/mutations/user_mutation.py b/kdb-bot/src/bot_graphql/mutations/user_mutation.py index 9cd71438..6c6c0bc6 100644 --- a/kdb-bot/src/bot_graphql/mutations/user_mutation.py +++ b/kdb-bot/src/bot_graphql/mutations/user_mutation.py @@ -4,8 +4,11 @@ from cpl_discord.service import DiscordBotServiceABC from bot_data.abc.level_repository_abc import LevelRepositoryABC from bot_data.abc.server_repository_abc import ServerRepositoryABC from bot_data.abc.user_repository_abc import UserRepositoryABC +from bot_data.abc.user_warnings_repository_abc import UserWarningsRepositoryABC +from bot_data.model.user import User from bot_data.model.user_role_enum import UserRoleEnum from bot_graphql.abc.query_abc import QueryABC +from modules.base.service.user_warnings_service import UserWarningsService from modules.level.service.level_service import LevelService from modules.permission.service.permission_service import PermissionService @@ -20,6 +23,8 @@ class UserMutation(QueryABC): permissions: PermissionService, levels: LevelRepositoryABC, level_service: LevelService, + user_warnings: UserWarningsRepositoryABC, + user_warning_service: UserWarningsService, ): QueryABC.__init__(self, "UserMutation") @@ -30,6 +35,8 @@ class UserMutation(QueryABC): self._permissions = permissions self._levels = levels self._level_service = level_service + self._user_warnings = user_warnings + self._user_warning_service = user_warning_service self.set_field("updateUser", self.resolve_update_user) @@ -45,9 +52,28 @@ class UserMutation(QueryABC): user.xp = new_xp if new_xp is not None else input["xp"] if "xp" in input else user.xp + if "userWarnings" in input: + self._update_user_warning(user, input["userWarnings"]) + self._users.update_user(user) self._db.save_changes() self._bot.loop.create_task(self._level_service.set_level(user)) user = self._users.get_user_by_id(input["id"]) return user + + def _update_user_warning(self, user: User, new_warnings: dict): + old_warnings = self._user_warnings.get_user_warnings_by_user_id(user.id) + for warning in old_warnings: + if warning.id in [int(x["id"]) if "id" in x else None for x in new_warnings]: + continue + + self._user_warning_service.remove_warnings(warning.id) + + for warning in new_warnings: + if "id" in warning and int(warning["id"]) in old_warnings.select(lambda x: x.id): + continue + + member = self._bot.get_guild(user.server.discord_id).get_member(user.discord_id) + author = self._users.get_user_by_id(int(warning["author"])) + self._user_warning_service.add_warnings(member, warning["description"], author.discord_id) diff --git a/kdb-bot/src/modules/base/command/user_group.py b/kdb-bot/src/modules/base/command/user_group.py index 37570a70..2c6f563f 100644 --- a/kdb-bot/src/modules/base/command/user_group.py +++ b/kdb-bot/src/modules/base/command/user_group.py @@ -400,7 +400,7 @@ class UserGroup(DiscordCommandABC): async def add(self, ctx: Context, member: discord.Member, description: str): self._logger.debug(__name__, f"Received command user warning add {ctx}:{member},{description}") try: - await self._user_warnings_service.add_warnings(member, description, ctx.author.id) + await self._user_warnings_service.add_warnings_async(member, description, ctx.author.id) await self._message_service.send_ctx_msg(ctx, self._t.transform("modules.base.warnings.add.success")) except Exception as e: self._logger.error(__name__, f"Adding user warning failed", e) @@ -414,7 +414,7 @@ class UserGroup(DiscordCommandABC): async def remove(self, ctx: Context, warning_id: int): self._logger.debug(__name__, f"Received command user warning remove {ctx}:{warning_id}") try: - await self._user_warnings_service.remove_warnings(warning_id) + await self._user_warnings_service.remove_warnings_async(warning_id) await self._message_service.send_ctx_msg(ctx, self._t.transform("modules.base.warnings.remove.success")) except Exception as e: self._logger.error(__name__, f"Removing user warning failed", e) diff --git a/kdb-bot/src/modules/base/service/user_warnings_service.py b/kdb-bot/src/modules/base/service/user_warnings_service.py index f3b0ab3f..d69659e6 100644 --- a/kdb-bot/src/modules/base/service/user_warnings_service.py +++ b/kdb-bot/src/modules/base/service/user_warnings_service.py @@ -108,7 +108,15 @@ class UserWarningsService: await self.notify_team(member, self._t.transform("modules.base.warnings.kick").format(member.mention)) await member.kick() - async def add_warnings(self, member: discord.Member, description: str, author_id: int = None): + async def _notify_after_add(self, member: discord.Member, warning: UserWarnings): + server = self._servers.get_server_by_discord_id(member.guild.id) + user = self._users.get_user_by_discord_id_and_server_id(member.id, server.id) + + await self.notify_user(member, self._t.transform("modules.base.warnings.warned").format(warning.description)) + await self.notify_team(member, warning.description) + await self.check_for_warnings(member, user) + + def _add_warnings(self, member: discord.Member, description: str, author_id: int = None): server = self._servers.get_server_by_discord_id(member.guild.id) user = self._users.get_user_by_discord_id_and_server_id(member.id, server.id) @@ -119,17 +127,32 @@ class UserWarningsService: warning = UserWarnings(description, user, author) self._warnings.add_user_warnings(warning) self._db.save_changes() - await self.notify_user(member, self._t.transform("modules.base.warnings.warned").format(warning.description)) - await self.notify_team(member, warning.description) - await self.check_for_warnings(member, user) + return warning - async def remove_warnings(self, id: int): + def add_warnings(self, member: discord.Member, description: str, author_id: int = None): + warning = self._add_warnings(member, description, author_id) + self._bot.loop.create_task(self._notify_after_add(member, warning)) + + async def add_warnings_async(self, member: discord.Member, description: str, author_id: int = None): + warning = self._add_warnings(member, description, author_id) + await self._notify_after_add(member, warning) + + async def _notify_after_remove(self, warning: UserWarnings): + guild = self._bot.get_guild(warning.user.server.discord_id) + member = guild.get_member(warning.user.discord_id) + await self.notify_user(member, self._t.transform("modules.base.warnings.removed").format(warning.description)) + await self.notify_team(member, warning.description, removed=True) + + def _remove_warnings(self, id: int): warning = self._warnings.get_user_warnings_by_id(id) self._warnings.delete_user_warnings(warning) self._db.save_changes() + return warning - guild = self._bot.get_guild(warning.user.server.discord_id) - member = guild.get_member(warning.user.discord_id) + def remove_warnings(self, id: int): + warning = self._remove_warnings(id) + self._bot.loop.create_task(self._notify_after_remove(warning)) - await self.notify_user(member, self._t.transform("modules.base.warnings.removed").format(warning.description)) - await self.notify_team(member, warning.description, removed=True) + async def remove_warnings_async(self, id: int): + warning = self._remove_warnings(id) + await self._notify_after_remove(warning) diff --git a/kdb-web/src/app/models/graphql/mutations.model.ts b/kdb-web/src/app/models/graphql/mutations.model.ts index ece931d6..8a877cea 100644 --- a/kdb-web/src/app/models/graphql/mutations.model.ts +++ b/kdb-web/src/app/models/graphql/mutations.model.ts @@ -1,8 +1,8 @@ export class Mutations { static updateUser = ` - mutation updateUser($id: ID, $xp: Int, $levelId: ID) { + mutation updateUser($id: ID, $xp: Int, $levelId: ID, $userWarnings: [UserWarningInput]) { user { - updateUser(input: { id: $id, xp: $xp, levelId: $levelId }) { + updateUser(input: { id: $id, xp: $xp, levelId: $levelId, userWarnings: $userWarnings }) { id name xp @@ -10,6 +10,10 @@ export class Mutations { id name } + userWarnings { + id + description + } } } } @@ -314,4 +318,50 @@ export class Mutations { } } `; + + + + static createUserWarning = ` + mutation createUserWarning($name: String, $description: String, $attribute: String, $operator: String, $value: String, $serverId: ID) { + userWarning { + createUserWarning(input: { name: $name, description: $description, attribute: $attribute, operator: $operator, value: $value, serverId: $serverId}) { + id + name + description + attribute + operator + value + server { + id + } + } + } + } + `; + + static updateUserWarning = ` + mutation updateUserWarning($id: ID, $name: String, $description: String, $attribute: String, $operator: String, $value: String) { + userWarning { + updateUserWarning(input: { id: $id, name: $name, description: $description, attribute: $attribute, operator: $operator, value: $value}) { + id + name + description + attribute + operator + value + } + } + } + `; + + static deleteUserWarning = ` + mutation deleteUserWarning($id: ID) { + userWarning { + deleteUserWarning(id: $id) { + id + name + } + } + } + `; } diff --git a/kdb-web/src/app/models/graphql/queries.model.ts b/kdb-web/src/app/models/graphql/queries.model.ts index 4f87d53b..2e9d362b 100644 --- a/kdb-web/src/app/models/graphql/queries.model.ts +++ b/kdb-web/src/app/models/graphql/queries.model.ts @@ -360,6 +360,10 @@ export class Queries { userWarningCount userWarnings { id + user { + id + name + } description author { id diff --git a/kdb-web/src/app/models/graphql/result.model.ts b/kdb-web/src/app/models/graphql/result.model.ts index cff8fcf2..411d6f1d 100644 --- a/kdb-web/src/app/models/graphql/result.model.ts +++ b/kdb-web/src/app/models/graphql/result.model.ts @@ -6,6 +6,7 @@ import { Achievement } from "../data/achievement.model"; import { TechnicianConfig } from "../config/technician-config.model"; import { ServerConfig } from "../config/server-config.model"; import { ShortRoleName } from "../data/short_role_name.model"; +import { UserWarning } from "../data/user_warning.model"; export interface GraphQLResult { data: { @@ -77,3 +78,11 @@ export interface ShortRoleNameMutationResult { deleteShortRoleName?: ShortRoleName }; } + +export interface UserWarningMutationResult { + userWarning: { + createUserWarning?: UserWarning + updateUserWarning?: UserWarning + deleteUserWarning?: UserWarning + }; +} diff --git a/kdb-web/src/app/modules/view/server/profile/profile.component.html b/kdb-web/src/app/modules/view/server/profile/profile.component.html index a101087f..46ddaf7c 100644 --- a/kdb-web/src/app/modules/view/server/profile/profile.component.html +++ b/kdb-web/src/app/modules/view/server/profile/profile.component.html @@ -135,10 +135,10 @@ - {{value.author.name}} + {{value.author?.name}} - {{value.author.name}} + {{value.author?.name}} @@ -262,5 +262,12 @@
+ +
+ +
+ +
diff --git a/kdb-web/src/app/modules/view/server/profile/profile.component.ts b/kdb-web/src/app/modules/view/server/profile/profile.component.ts index 60650137..c06e8387 100644 --- a/kdb-web/src/app/modules/view/server/profile/profile.component.ts +++ b/kdb-web/src/app/modules/view/server/profile/profile.component.ts @@ -10,9 +10,13 @@ import { AuthService } from "src/app/services/auth/auth.service"; import { ToastService } from "src/app/services/toast/toast.service"; import { TranslateService } from "@ngx-translate/core"; import { Server } from "../../../../models/data/server.model"; -import { forkJoin, Subject } from "rxjs"; -import { takeUntil } from "rxjs/operators"; +import { forkJoin, Subject, throwError } from "rxjs"; +import { catchError, takeUntil } from "rxjs/operators"; import { Table } from "primeng/table"; +import { UserWarning } from "../../../../models/data/user_warning.model"; +import { LevelMutationResult, UpdateUserMutationResult, UserWarningMutationResult } from "../../../../models/graphql/result.model"; +import { Mutations } from "../../../../models/graphql/mutations.model"; +import { ConfirmationDialogService } from "../../../../services/confirmation-dialog/confirmation-dialog.service"; @Component({ selector: "app-profile", @@ -23,6 +27,10 @@ export class ProfileComponent implements OnInit, OnDestroy { user: User = { createdAt: "", modifiedAt: "" }; private server: Server = {}; + private author?: UserDTO; + private clonedUserWarnings: UserWarning[] = []; + public isEditingNewUserWarning: boolean = false; + public isEditing: boolean = false; private unsubscriber = new Subject(); @@ -33,11 +41,16 @@ export class ProfileComponent implements OnInit, OnDestroy { private data: DataService, private auth: AuthService, private toast: ToastService, - private translate: TranslateService + private translate: TranslateService, + private toastService: ToastService ) { } public ngOnInit(): void { + this.loadProfile(); + } + + private loadProfile() { this.route.params.pipe(takeUntil(this.unsubscriber)).subscribe(params => { this.data.getServerFromRoute(this.route).then(async (server) => { if (!params["memberId"] || params["memberId"] == "undefined") { @@ -55,6 +68,7 @@ export class ProfileComponent implements OnInit, OnDestroy { await this.router.navigate(["/server", server.id]); return; } + this.author = user; this.data.query(Queries.userProfile, { serverId: this.server.id, @@ -85,6 +99,32 @@ export class ProfileComponent implements OnInit, OnDestroy { }); } + public updateUser() { + this.spinner.showSpinner(); + this.spinner.showSpinner(); + this.data.mutation(Mutations.updateUser, { + id: this.user.id, + xp: this.user.xp, + levelId: this.user.level?.id, + userWarnings: this.user.userWarnings?.map(userWarning => { + return { + id: userWarning.id, + user: userWarning.user?.id ?? this.user.id, + description: userWarning.description, + author: userWarning.author?.id ?? this.author?.id + } + }) + } + ).pipe(catchError(err => { + this.spinner.hideSpinner(); + return throwError(err); + })).subscribe(_ => { + this.spinner.hideSpinner(); + this.toastService.success(this.translate.instant("view.server.members.message.user_changed"), this.translate.instant("view.server.members.message.user_changed_d", { name: this.user.name })); + this.loadProfile(); + }); + } + public ngOnDestroy(): void { this.unsubscriber.next(); this.unsubscriber.complete(); @@ -141,16 +181,42 @@ export class ProfileComponent implements OnInit, OnDestroy { } addNewUserWarning(table: Table) { + const newWarning: UserWarning = { + description: "", + user: this.user + }; + + this.user.userWarnings = [newWarning, ...this.user.userWarnings ?? []]; + + table.initRowEdit(newWarning); + + const index = this.user.userWarnings.findIndex(l => l.id == newWarning.id); + this.onRowEditInit(table, newWarning, index); + + this.isEditingNewUserWarning = true; + } + + public onRowEditInit(table: Table, user: User, index: number): void { + this.clonedUserWarnings[index] = { ...user }; } deleteUserWarning(index: number) { + this.user.userWarnings?.splice(index, 1); } editSaveUserWarning(value: any, index: number) { + this.isEditingNewUserWarning = false; + if (!value.value || !this.user.userWarnings || this.user.userWarnings[index] == this.clonedUserWarnings[index]) { + return; + } + + delete this.clonedUserWarnings[index]; } editCancelUserWarning(index: number) { + if (this.user.userWarnings) { + this.user.userWarnings[index] = this.clonedUserWarnings[index]; + } + delete this.clonedUserWarnings[index]; } - - protected readonly visualViewport = visualViewport; } -- 2.45.2 From 7aff767a4b12f6444525a812078b05c648ca45e7 Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Tue, 10 Oct 2023 18:50:20 +0200 Subject: [PATCH 03/58] Added birthday to wi #401 --- .../src/bot/startup_migration_extension.py | 4 + .../bot_data/migration/birthday_migration.py | 84 +++++++++++++++++++ .../migration/db_history_scripts/users.sql | 37 ++++---- .../migration/fix_user_history_migration.py | 45 ++++++++++ kdb-bot/src/bot_data/model/server_config.py | 14 ++++ kdb-bot/src/bot_data/model/user.py | 18 +++- .../server_config_repository_service.py | 11 +-- .../service/user_repository_service.py | 5 +- .../src/bot_graphql/graphql/serverConfig.gql | 3 + kdb-bot/src/bot_graphql/graphql/user.gql | 2 + .../bot_graphql/mutations/user_mutation.py | 29 +++++-- .../queries/server_config_query.py | 1 + kdb-bot/src/bot_graphql/queries/user_query.py | 1 + kdb-web/package-lock.json | 19 +++-- kdb-web/package.json | 5 +- kdb-web/src/app/app.module.ts | 41 +++++---- kdb-web/src/app/models/data/user.model.ts | 5 +- .../src/app/models/graphql/mutations.model.ts | 7 +- .../src/app/models/graphql/queries.model.ts | 3 + .../src/app/modules/shared/shared.module.ts | 79 +++++++---------- .../server/members/members.component.html | 2 +- .../server/profile/profile.component.html | 48 ++++++++--- .../view/server/profile/profile.component.ts | 44 +++++++--- kdb-web/src/assets/i18n/de.json | 4 + kdb-web/src/assets/version.json | 4 +- kdb-web/src/styles/primeng-fixes.scss | 9 +- .../styles/themes/sh-edraft-dark-theme.scss | 73 ++++++++++++++++ 27 files changed, 449 insertions(+), 148 deletions(-) create mode 100644 kdb-bot/src/bot_data/migration/birthday_migration.py create mode 100644 kdb-bot/src/bot_data/migration/fix_user_history_migration.py diff --git a/kdb-bot/src/bot/startup_migration_extension.py b/kdb-bot/src/bot/startup_migration_extension.py index bbf5f328..f697bb9a 100644 --- a/kdb-bot/src/bot/startup_migration_extension.py +++ b/kdb-bot/src/bot/startup_migration_extension.py @@ -9,11 +9,13 @@ 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.birthday_migration import BirthdayMigration 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.fix_updates_migration import FixUpdatesMigration +from bot_data.migration.fix_user_history_migration import FixUserHistoryMigration 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 @@ -56,3 +58,5 @@ class StartupMigrationExtension(StartupExtensionABC): services.add_transient(MigrationABC, ShortRoleNameMigration) # 28.09.2023 #378 - 1.1.7 services.add_transient(MigrationABC, FixUpdatesMigration) # 28.09.2023 #378 - 1.1.7 services.add_transient(MigrationABC, ShortRoleNameOnlyHighestMigration) # 02.10.2023 #391 - 1.1.9 + services.add_transient(MigrationABC, FixUserHistoryMigration) # 10.10.2023 #401 - 1.2.0 + services.add_transient(MigrationABC, BirthdayMigration) # 10.10.2023 #401 - 1.2.0 diff --git a/kdb-bot/src/bot_data/migration/birthday_migration.py b/kdb-bot/src/bot_data/migration/birthday_migration.py new file mode 100644 index 00000000..607de4d3 --- /dev/null +++ b/kdb-bot/src/bot_data/migration/birthday_migration.py @@ -0,0 +1,84 @@ +from bot_core.logging.database_logger import DatabaseLogger +from bot_data.abc.migration_abc import MigrationABC +from bot_data.db_context import DBContext + + +class BirthdayMigration(MigrationABC): + name = "1.2.0_BirthdayMigration" + + 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 Users + ADD Birthday DATE NULL AFTER MessageCount; + """ + ) + ) + + self._cursor.execute( + str( + f""" + ALTER TABLE UsersHistory + ADD Birthday DATE NULL AFTER MessageCount; + """ + ) + ) + self._exec(__file__, "users.sql") + + self._cursor.execute( + str( + f""" + ALTER TABLE CFG_Server + ADD XpForBirthday BIGINT(20) NOT NULL DEFAULT 0 AFTER XpPerAchievement; + """ + ) + ) + + self._cursor.execute( + str( + f""" + ALTER TABLE CFG_ServerHistory + ADD XpForBirthday BIGINT(20) NOT NULL DEFAULT 0 AFTER XpPerAchievement; + """ + ) + ) + self._exec(__file__, "config/server.sql") + + def downgrade(self): + self._cursor.execute( + str( + f""" + ALTER TABLE Users DROP COLUMN Birthday; + """ + ) + ) + self._cursor.execute( + str( + f""" + ALTER TABLE UsersHistory DROP COLUMN Birthday; + """ + ) + ) + self._cursor.execute( + str( + f""" + ALTER TABLE CFG_Server DROP COLUMN XpForBirthday; + """ + ) + ) + self._cursor.execute( + str( + f""" + ALTER TABLE CFG_ServerHistory DROP COLUMN XpForBirthday; + """ + ) + ) diff --git a/kdb-bot/src/bot_data/migration/db_history_scripts/users.sql b/kdb-bot/src/bot_data/migration/db_history_scripts/users.sql index 8dfebf63..a91cf560 100644 --- a/kdb-bot/src/bot_data/migration/db_history_scripts/users.sql +++ b/kdb-bot/src/bot_data/migration/db_history_scripts/users.sql @@ -6,13 +6,16 @@ ALTER TABLE `Users` CREATE TABLE IF NOT EXISTS `UsersHistory` ( - `Id` BIGINT(20) NOT NULL, - `DiscordId` BIGINT(20) NOT NULL, - `XP` BIGINT(20) NOT NULL DEFAULT 0, - `ServerId` BIGINT(20) DEFAULT NULL, - `Deleted` BOOL DEFAULT FALSE, - `DateFrom` DATETIME(6) NOT NULL, - `DateTo` DATETIME(6) NOT NULL + `Id` BIGINT(20) NOT NULL, + `DiscordId` BIGINT(20) NOT NULL, + `XP` BIGINT(20) NOT NULL DEFAULT 0, + `ReactionCount` BIGINT(20) NOT NULL DEFAULT 0, + `MessageCount` BIGINT(20) NOT NULL DEFAULT 0, + `Birthday` DATE NULL, + `ServerId` BIGINT(20) DEFAULT NULL, + `Deleted` BOOL DEFAULT FALSE, + `DateFrom` DATETIME(6) NOT NULL, + `DateTo` DATETIME(6) NOT NULL ); DROP TRIGGER IF EXISTS `TR_UsersUpdate`; @@ -22,12 +25,10 @@ CREATE TRIGGER `TR_UsersUpdate` ON `Users` FOR EACH ROW BEGIN - INSERT INTO `UsersHistory` ( - `Id`, `DiscordId`, `XP`, `ServerId`, `DateFrom`, `DateTo` - ) - VALUES ( - OLD.UserId, OLD.DiscordId, OLD.XP, OLD.ServerId, OLD.LastModifiedAt, CURRENT_TIMESTAMP(6) - ); + INSERT INTO `UsersHistory` (`Id`, `DiscordId`, `XP`, `ReactionCount`, `MessageCount`, `Birthday`, `ServerId`, + `DateFrom`, `DateTo`) + VALUES (OLD.UserId, OLD.DiscordId, OLD.XP, OLD.ReactionCount, OLD.MessageCount, OLD.Birthday, OLD.ServerId, + OLD.LastModifiedAt, CURRENT_TIMESTAMP(6)); END; DROP TRIGGER IF EXISTS `TR_UsersDelete`; @@ -37,10 +38,8 @@ CREATE TRIGGER `TR_UsersDelete` ON `Users` FOR EACH ROW BEGIN - INSERT INTO `UsersHistory` ( - `Id`, `DiscordId`, `XP`, `ServerId`, `Deleted`, `DateFrom`, `DateTo` - ) - VALUES ( - OLD.UserId, OLD.DiscordId, OLD.XP, OLD.ServerId, TRUE, OLD.LastModifiedAt, CURRENT_TIMESTAMP(6) - ); + INSERT INTO `UsersHistory` (`Id`, `DiscordId`, `XP`, `ReactionCount`, `MessageCount`, `Birthday`, `ServerId`, + `Deleted`, `DateFrom`, `DateTo`) + VALUES (OLD.UserId, OLD.DiscordId, OLD.XP, OLD.ReactionCount, OLD.MessageCount, OLD.Birthday, OLD.ServerId, TRUE, + OLD.LastModifiedAt, CURRENT_TIMESTAMP(6)); END; \ No newline at end of file diff --git a/kdb-bot/src/bot_data/migration/fix_user_history_migration.py b/kdb-bot/src/bot_data/migration/fix_user_history_migration.py new file mode 100644 index 00000000..b39ec429 --- /dev/null +++ b/kdb-bot/src/bot_data/migration/fix_user_history_migration.py @@ -0,0 +1,45 @@ +from bot_core.logging.database_logger import DatabaseLogger +from bot_data.abc.migration_abc import MigrationABC +from bot_data.db_context import DBContext + + +class FixUserHistoryMigration(MigrationABC): + name = "1.2.0_FixUserHistoryMigration" + + 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") + + # fix 1.1.0_AchievementsMigration + self._cursor.execute( + str( + f"""ALTER TABLE UsersHistory ADD COLUMN IF NOT EXISTS ReactionCount BIGINT NOT NULL DEFAULT 0 AFTER XP;""" + ) + ) + self._cursor.execute( + str( + f"""ALTER TABLE UsersHistory ADD COLUMN IF NOT EXISTS MessageCount BIGINT NOT NULL DEFAULT 0 AFTER ReactionCount;""" + ) + ) + self._exec(__file__, "users.sql") + + def downgrade(self): + self._cursor.execute( + str( + f""" + ALTER TABLE UsersHistory DROP COLUMN MessageCount; + """ + ) + ) + self._cursor.execute( + str( + f""" + ALTER TABLE UsersHistory DROP COLUMN ReactionCount; + """ + ) + ) diff --git a/kdb-bot/src/bot_data/model/server_config.py b/kdb-bot/src/bot_data/model/server_config.py index 8a36ac6f..b10410d7 100644 --- a/kdb-bot/src/bot_data/model/server_config.py +++ b/kdb-bot/src/bot_data/model/server_config.py @@ -24,6 +24,7 @@ class ServerConfig(TableABC, ConfigurationModelABC): xp_per_ontime_hour: int, xp_per_event_participation: int, xp_per_achievement: int, + xp_for_birthday: int, afk_command_channel_id: int, help_voice_channel_id: int, team_channel_id: int, @@ -48,6 +49,7 @@ class ServerConfig(TableABC, ConfigurationModelABC): self._xp_per_ontime_hour = xp_per_ontime_hour self._xp_per_event_participation = xp_per_event_participation self._xp_per_achievement = xp_per_achievement + self._xp_for_birthday = xp_for_birthday self._afk_command_channel_id = afk_command_channel_id self._help_voice_channel_id = help_voice_channel_id self._team_channel_id = team_channel_id @@ -76,6 +78,7 @@ class ServerConfig(TableABC, ConfigurationModelABC): 10, 10, 10, + 10, guild.system_channel.id, guild.system_channel.id, guild.system_channel.id, @@ -164,6 +167,14 @@ class ServerConfig(TableABC, ConfigurationModelABC): def xp_per_achievement(self, value: int): self._xp_per_achievement = value + @property + def xp_for_birthday(self) -> int: + return self._xp_for_birthday + + @xp_for_birthday.setter + def xp_for_birthday(self, value: int): + self._xp_for_birthday = value + @property def afk_command_channel_id(self) -> int: return self._afk_command_channel_id @@ -280,6 +291,7 @@ class ServerConfig(TableABC, ConfigurationModelABC): `XpPerOntimeHour`, `XpPerEventParticipation`, `XpPerAchievement`, + `XpForBirthday`, `AFKCommandChannelId`, `HelpVoiceChannelId`, `TeamChannelId`, @@ -298,6 +310,7 @@ class ServerConfig(TableABC, ConfigurationModelABC): {self._xp_per_ontime_hour}, {self._xp_per_event_participation}, {self._xp_per_achievement}, + '{self._xp_for_birthday}', {self._afk_command_channel_id}, {self._help_voice_channel_id}, {self._team_channel_id}, @@ -324,6 +337,7 @@ class ServerConfig(TableABC, ConfigurationModelABC): `XpPerOntimeHour` = {self._xp_per_ontime_hour}, `XpPerEventParticipation` = {self._xp_per_event_participation}, `XpPerAchievement` = {self._xp_per_achievement}, + `XpForBirthday` = {self._xp_for_birthday}, `AFKCommandChannelId` = {self._afk_command_channel_id}, `HelpVoiceChannelId` = {self._help_voice_channel_id}, `TeamChannelId` = {self._team_channel_id}, diff --git a/kdb-bot/src/bot_data/model/user.py b/kdb-bot/src/bot_data/model/user.py index 57e1cc67..310ecc08 100644 --- a/kdb-bot/src/bot_data/model/user.py +++ b/kdb-bot/src/bot_data/model/user.py @@ -1,4 +1,4 @@ -from datetime import datetime +from datetime import datetime, date from typing import Optional from cpl_core.database import TableABC @@ -17,6 +17,7 @@ class User(TableABC): xp: int, reaction_count: int, message_count: int, + birthday: Optional[date], server: Optional[Server], created_at: datetime = None, modified_at: datetime = None, @@ -27,6 +28,7 @@ class User(TableABC): self._xp = xp self._reaction_count = reaction_count self._message_count = message_count + self._birthday = birthday self._server = server TableABC.__init__(self) @@ -79,6 +81,14 @@ class User(TableABC): def reaction_count(self, value: int): self._reaction_count = value + @property + def birthday(self) -> Optional[datetime]: + return self._birthday + + @birthday.setter + def birthday(self, value: Optional[datetime]): + self._birthday = value + @property @ServiceProviderABC.inject def ontime(self, services: ServiceProviderABC) -> float: @@ -171,12 +181,13 @@ class User(TableABC): return str( f""" INSERT INTO `Users` ( - `DiscordId`, `XP`, `MessageCount`, `ReactionCount`, `ServerId` + `DiscordId`, `XP`, `MessageCount`, `ReactionCount`, `Birthday`, `ServerId` ) VALUES ( {self._discord_id}, {self._xp}, {self._message_count}, {self._reaction_count}, + '{self._birthday}', {self._server.id} ); """ @@ -189,7 +200,8 @@ class User(TableABC): UPDATE `Users` SET `XP` = {self._xp}, `MessageCount` = {self._message_count}, - `ReactionCount` = {self._reaction_count} + `ReactionCount` = {self._reaction_count}, + `Birthday` = '{self._birthday}' WHERE `UserId` = {self._user_id}; """ ) diff --git a/kdb-bot/src/bot_data/service/server_config_repository_service.py b/kdb-bot/src/bot_data/service/server_config_repository_service.py index 4e5d3dcd..391649a5 100644 --- a/kdb-bot/src/bot_data/service/server_config_repository_service.py +++ b/kdb-bot/src/bot_data/service/server_config_repository_service.py @@ -66,12 +66,13 @@ class ServerConfigRepositoryService(ServerConfigRepositoryABC): result[13], result[14], result[15], - json.loads(result[16]), - self._servers.get_server_by_id(result[17]), - self._get_afk_channel_ids(result[17]), - self._get_team_role_ids(result[17]), - result[18], + result[16], + json.loads(result[17]), + self._servers.get_server_by_id(result[18]), + self._get_afk_channel_ids(result[18]), + self._get_team_role_ids(result[18]), result[19], + result[20], id=result[0], ) diff --git a/kdb-bot/src/bot_data/service/user_repository_service.py b/kdb-bot/src/bot_data/service/user_repository_service.py index 73387908..1238fa1b 100644 --- a/kdb-bot/src/bot_data/service/user_repository_service.py +++ b/kdb-bot/src/bot_data/service/user_repository_service.py @@ -29,9 +29,10 @@ class UserRepositoryService(UserRepositoryABC): result[2], result[3], result[4], - self._servers.get_server_by_id(result[5]), - result[6], + result[5].strftime("%d.%m.%Y") if result[5] is not None else None, + self._servers.get_server_by_id(result[6]), result[7], + result[8], id=result[0], ) diff --git a/kdb-bot/src/bot_graphql/graphql/serverConfig.gql b/kdb-bot/src/bot_graphql/graphql/serverConfig.gql index 7683194c..b2ab507a 100644 --- a/kdb-bot/src/bot_graphql/graphql/serverConfig.gql +++ b/kdb-bot/src/bot_graphql/graphql/serverConfig.gql @@ -9,6 +9,7 @@ type ServerConfig implements TableWithHistoryQuery { xpPerOntimeHour: Int xpPerEventParticipation: Int xpPerAchievement: Int + xpForBirthday: Int afkCommandChannelId: String helpVoiceChannelId: String teamChannelId: String @@ -41,6 +42,7 @@ type ServerConfigHistory implements HistoryTableQuery { xpPerOntimeHour: Int xpPerEventParticipation: Int xpPerAchievement: Int + xpForBirthday: Int afkCommandChannelId: String helpVoiceChannelId: String teamChannelId: String @@ -91,6 +93,7 @@ input ServerConfigInput { xpPerOntimeHour: Int xpPerEventParticipation: Int xpPerAchievement: Int + xpForBirthday: Int afkCommandChannelId: String helpVoiceChannelId: String teamChannelId: String diff --git a/kdb-bot/src/bot_graphql/graphql/user.gql b/kdb-bot/src/bot_graphql/graphql/user.gql index f89e8483..9ffff9a2 100644 --- a/kdb-bot/src/bot_graphql/graphql/user.gql +++ b/kdb-bot/src/bot_graphql/graphql/user.gql @@ -5,6 +5,7 @@ type User implements TableWithHistoryQuery { xp: Int messageCount: Int reactionCount: Int + birthday: String ontime: Float level: Level @@ -62,6 +63,7 @@ type UserMutation { input UserInput { id: ID xp: Int + birthday: String levelId: ID userWarnings: [UserWarningInput] } \ No newline at end of file diff --git a/kdb-bot/src/bot_graphql/mutations/user_mutation.py b/kdb-bot/src/bot_graphql/mutations/user_mutation.py index 6c6c0bc6..9ec5f4cc 100644 --- a/kdb-bot/src/bot_graphql/mutations/user_mutation.py +++ b/kdb-bot/src/bot_graphql/mutations/user_mutation.py @@ -1,6 +1,9 @@ +from datetime import datetime + from cpl_core.database.context import DatabaseContextABC from cpl_discord.service import DiscordBotServiceABC +from bot_api.route.route import Route from bot_data.abc.level_repository_abc import LevelRepositoryABC from bot_data.abc.server_repository_abc import ServerRepositoryABC from bot_data.abc.user_repository_abc import UserRepositoryABC @@ -42,18 +45,26 @@ class UserMutation(QueryABC): def resolve_update_user(self, *_, input: dict): user = self._users.get_user_by_id(input["id"]) - self._can_user_mutate_data(user.server, UserRoleEnum.moderator) - new_xp = None - if "levelId" in input: - level = self._levels.get_level_by_id(input["levelId"]) - if user.level.id != level.id: - new_xp = level.min_xp + auth_user = Route.get_user() + member = self._bot.get_guild(user.server.discord_id).get_member( + auth_user.users.where(lambda x: x.server.id == user.server.id).single().discord_id + ) + if member.id != user.discord_id: + self._can_user_mutate_data(user.server, UserRoleEnum.moderator) - user.xp = new_xp if new_xp is not None else input["xp"] if "xp" in input else user.xp + new_xp = None + if "levelId" in input: + level = self._levels.get_level_by_id(input["levelId"]) + if user.level.id != level.id: + new_xp = level.min_xp - if "userWarnings" in input: - self._update_user_warning(user, input["userWarnings"]) + if "userWarnings" in input: + self._update_user_warning(user, input["userWarnings"]) + + user.xp = new_xp if new_xp is not None else input["xp"] if "xp" in input else user.xp + + user.birthday = datetime.strptime(input["birthday"], "%d.%m.%Y") if "birthday" in input else user.birthday self._users.update_user(user) self._db.save_changes() diff --git a/kdb-bot/src/bot_graphql/queries/server_config_query.py b/kdb-bot/src/bot_graphql/queries/server_config_query.py index 5e580eca..b995927a 100644 --- a/kdb-bot/src/bot_graphql/queries/server_config_query.py +++ b/kdb-bot/src/bot_graphql/queries/server_config_query.py @@ -20,6 +20,7 @@ class ServerConfigQuery(DataQueryWithHistoryABC): self.set_field("xpPerOntimeHour", lambda config, *_: config.xp_per_ontime_hour) self.set_field("xpPerEventParticipation", lambda config, *_: config.xp_per_event_participation) self.set_field("xpPerAchievement", lambda config, *_: config.xp_per_achievement) + self.set_field("xpForBirthday", lambda config, *_: config.xp_for_birthday) self.set_field("afkCommandChannelId", lambda config, *_: config.afk_command_channel_id) self.set_field("helpVoiceChannelId", lambda config, *_: config.help_voice_channel_id) self.set_field("teamChannelId", lambda config, *_: config.team_channel_id) diff --git a/kdb-bot/src/bot_graphql/queries/user_query.py b/kdb-bot/src/bot_graphql/queries/user_query.py index f015c847..c04fbcc9 100644 --- a/kdb-bot/src/bot_graphql/queries/user_query.py +++ b/kdb-bot/src/bot_graphql/queries/user_query.py @@ -50,6 +50,7 @@ class UserQuery(DataQueryWithHistoryABC): self.set_field("xp", self.resolve_xp) self.set_field("messageCount", lambda x, *_: x.message_count) self.set_field("reactionCount", lambda x, *_: x.reaction_count) + self.set_field("birthday", lambda x, *_: x.birthday) self.set_field("ontime", self.resolve_ontime) self.set_field("level", self.resolve_level) self.add_collection( diff --git a/kdb-web/package-lock.json b/kdb-web/package-lock.json index 9281a434..aa28d9bb 100644 --- a/kdb-web/package-lock.json +++ b/kdb-web/package-lock.json @@ -1,12 +1,12 @@ { "name": "kdb-web", - "version": "1.0.dev127_config_in_wi", + "version": "1.2.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "kdb-web", - "version": "1.0.dev127_config_in_wi", + "version": "1.2.0", "dependencies": { "@angular/animations": "^15.1.4", "@angular/common": "^15.1.4", @@ -21,7 +21,7 @@ "@ngx-translate/core": "^14.0.0", "@ngx-translate/http-loader": "^7.0.0", "@types/socket.io-client": "^3.0.0", - "primeflex": "^3.3.1", + "moment": "^2.29.4", "primeicons": "^6.0.1", "primeng": "^15.2.0", "rxjs": "~7.5.0", @@ -8157,6 +8157,14 @@ "mkdirp": "bin/cmd.js" } }, + "node_modules/moment": { + "version": "2.29.4", + "resolved": "https://registry.npmjs.org/moment/-/moment-2.29.4.tgz", + "integrity": "sha512-5LC9SOxjSc2HF6vO2CyuTDNivEdoz2IvyJJGj6X8DJ0eFyfszE0QiEd+iXmBvUP3WHxSjFH/vIsA0EN00cgr8w==", + "engines": { + "node": "*" + } + }, "node_modules/ms": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", @@ -9303,11 +9311,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/primeflex": { - "version": "3.3.1", - "resolved": "https://registry.npmjs.org/primeflex/-/primeflex-3.3.1.tgz", - "integrity": "sha512-zaOq3YvcOYytbAmKv3zYc+0VNS9Wg5d37dfxZnveKBFPr7vEIwfV5ydrpiouTft8MVW6qNjfkaQphHSnvgQbpQ==" - }, "node_modules/primeicons": { "version": "6.0.1", "resolved": "https://registry.npmjs.org/primeicons/-/primeicons-6.0.1.tgz", diff --git a/kdb-web/package.json b/kdb-web/package.json index c7f77d8c..064e549b 100644 --- a/kdb-web/package.json +++ b/kdb-web/package.json @@ -1,6 +1,6 @@ { "name": "kdb-web", - "version": "1.1.dev402", + "version": "1.2.0", "scripts": { "ng": "ng", "update-version": "ts-node update-version.ts", @@ -30,6 +30,7 @@ "@ngx-translate/core": "^14.0.0", "@ngx-translate/http-loader": "^7.0.0", "@types/socket.io-client": "^3.0.0", + "moment": "^2.29.4", "primeicons": "^6.0.1", "primeng": "^15.2.0", "rxjs": "~7.5.0", @@ -51,4 +52,4 @@ "tslib": "^2.4.1", "typescript": "~4.9.5" } -} \ No newline at end of file +} diff --git a/kdb-web/src/app/app.module.ts b/kdb-web/src/app/app.module.ts index 3e2b348b..e6d9877d 100644 --- a/kdb-web/src/app/app.module.ts +++ b/kdb-web/src/app/app.module.ts @@ -1,23 +1,22 @@ -import { HttpClient, HttpClientModule } from '@angular/common/http'; -import { APP_INITIALIZER, ErrorHandler, NgModule } from '@angular/core'; -import { BrowserModule } from '@angular/platform-browser'; -import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; -import { JwtModule } from '@auth0/angular-jwt'; -import { TranslateLoader, TranslateModule } from '@ngx-translate/core'; -import { TranslateHttpLoader } from '@ngx-translate/http-loader'; -import { ConfirmationService, MessageService } from 'primeng/api'; -import { DialogService } from 'primeng/dynamicdialog'; -import { AppRoutingModule } from './app-routing.module'; -import { AppComponent } from './app.component'; -import { NotFoundComponent } from './components/error/not-found/not-found.component'; -import { FooterComponent } from './components/footer/footer.component'; -import { HeaderComponent } from './components/header/header.component'; -import { SidebarComponent } from './components/sidebar/sidebar.component'; -import { SpinnerComponent } from './components/spinner/spinner.component'; -import { SharedModule } from './modules/shared/shared.module'; -import { ErrorHandlerService } from './services/error-handler/error-handler.service'; -import { SettingsService } from './services/settings/settings.service'; - +import { HttpClient, HttpClientModule } from "@angular/common/http"; +import { APP_INITIALIZER, ErrorHandler, NgModule } from "@angular/core"; +import { BrowserModule } from "@angular/platform-browser"; +import { BrowserAnimationsModule } from "@angular/platform-browser/animations"; +import { JwtModule } from "@auth0/angular-jwt"; +import { TranslateLoader, TranslateModule } from "@ngx-translate/core"; +import { TranslateHttpLoader } from "@ngx-translate/http-loader"; +import { ConfirmationService, MessageService } from "primeng/api"; +import { DialogService } from "primeng/dynamicdialog"; +import { AppRoutingModule } from "./app-routing.module"; +import { AppComponent } from "./app.component"; +import { NotFoundComponent } from "./components/error/not-found/not-found.component"; +import { FooterComponent } from "./components/footer/footer.component"; +import { HeaderComponent } from "./components/header/header.component"; +import { SidebarComponent } from "./components/sidebar/sidebar.component"; +import { SpinnerComponent } from "./components/spinner/spinner.component"; +import { SharedModule } from "./modules/shared/shared.module"; +import { ErrorHandlerService } from "./services/error-handler/error-handler.service"; +import { SettingsService } from "./services/settings/settings.service"; @NgModule({ @@ -63,7 +62,7 @@ import { SettingsService } from './services/settings/settings.service'; }, MessageService, ConfirmationService, - DialogService + DialogService, ], bootstrap: [AppComponent] }) diff --git a/kdb-web/src/app/models/data/user.model.ts b/kdb-web/src/app/models/data/user.model.ts index 8082e781..5dcd05aa 100644 --- a/kdb-web/src/app/models/data/user.model.ts +++ b/kdb-web/src/app/models/data/user.model.ts @@ -12,8 +12,9 @@ export interface User extends DataWithHistory { discordId?: number; name?: string; xp?: number; - message_count?: number; - reaction_count?: number; + messageCount?: number; + reactionCount?: number; + birthday?: string; ontime?: number; level?: Level; server?: Server; diff --git a/kdb-web/src/app/models/graphql/mutations.model.ts b/kdb-web/src/app/models/graphql/mutations.model.ts index 8a877cea..dda0301c 100644 --- a/kdb-web/src/app/models/graphql/mutations.model.ts +++ b/kdb-web/src/app/models/graphql/mutations.model.ts @@ -1,11 +1,14 @@ export class Mutations { static updateUser = ` - mutation updateUser($id: ID, $xp: Int, $levelId: ID, $userWarnings: [UserWarningInput]) { + mutation updateUser($id: ID, $xp: Int $birthday: String, $levelId: ID, $userWarnings: [UserWarningInput]) { user { - updateUser(input: { id: $id, xp: $xp, levelId: $levelId, userWarnings: $userWarnings }) { + updateUser(input: { id: $id, xp: $xp, birthday: $birthday, levelId: $levelId, userWarnings: $userWarnings }) { id name xp + messageCount + reactionCount + birthday level { id name diff --git a/kdb-web/src/app/models/graphql/queries.model.ts b/kdb-web/src/app/models/graphql/queries.model.ts index 2e9d362b..dbf49e10 100644 --- a/kdb-web/src/app/models/graphql/queries.model.ts +++ b/kdb-web/src/app/models/graphql/queries.model.ts @@ -285,6 +285,9 @@ export class Queries { discordId name xp + messageCount + reactionCount + birthday ontime level { id diff --git a/kdb-web/src/app/modules/shared/shared.module.ts b/kdb-web/src/app/modules/shared/shared.module.ts index 9cea8e7f..f05452c0 100644 --- a/kdb-web/src/app/modules/shared/shared.module.ts +++ b/kdb-web/src/app/modules/shared/shared.module.ts @@ -32,8 +32,37 @@ import { HideableHeaderComponent } from './components/hideable-header/hideable-h import { MultiSelectColumnsComponent } from './base/multi-select-columns/multi-select-columns.component'; import { FeatureFlagListComponent } from './components/feature-flag-list/feature-flag-list.component'; import { InputSwitchModule } from "primeng/inputswitch"; +import { CalendarModule } from "primeng/calendar"; +const PrimeNGModules = [ + ButtonModule, + PasswordModule, + MenuModule, + DialogModule, + ProgressSpinnerModule, + HttpClientModule, + FormsModule, + ReactiveFormsModule, + ToastModule, + ConfirmDialogModule, + TableModule, + InputTextModule, + CheckboxModule, + DropdownModule, + TranslateModule, + DynamicDialogModule, + PanelMenuModule, + PanelModule, + InputNumberModule, + ImageModule, + SidebarModule, + DataViewModule, + MultiSelectModule, + InputSwitchModule, + CalendarModule, +] + @NgModule({ declarations: [ AuthRolePipe, @@ -48,66 +77,20 @@ import { InputSwitchModule } from "primeng/inputswitch"; ], imports: [ CommonModule, - ButtonModule, - PasswordModule, - MenuModule, - DialogModule, - ProgressSpinnerModule, - HttpClientModule, - FormsModule, - ReactiveFormsModule, - ToastModule, - ConfirmDialogModule, - TableModule, - InputTextModule, - CheckboxModule, - DropdownModule, - TranslateModule, - DynamicDialogModule, - PanelMenuModule, - PanelModule, - InputNumberModule, - ImageModule, - SidebarModule, - DataViewModule, - MultiSelectModule, - InputSwitchModule, + ...PrimeNGModules ], exports: [ - ButtonModule, - PasswordModule, - MenuModule, - DialogModule, - ProgressSpinnerModule, - HttpClientModule, - FormsModule, - ReactiveFormsModule, - ToastModule, - ConfirmDialogModule, - TableModule, - InputTextModule, - CheckboxModule, - DropdownModule, - TranslateModule, - DynamicDialogModule, - PanelMenuModule, - PanelModule, + ...PrimeNGModules, AuthRolePipe, IpAddressPipe, BoolPipe, - InputNumberModule, - ImageModule, - SidebarModule, HistoryBtnComponent, - DataViewModule, DataViewLayoutOptions, ConfigListComponent, - MultiSelectModule, HideableColumnComponent, HideableHeaderComponent, MultiSelectColumnsComponent, FeatureFlagListComponent, - InputSwitchModule, ] }) export class SharedModule { diff --git a/kdb-web/src/app/modules/view/server/members/members.component.html b/kdb-web/src/app/modules/view/server/members/members.component.html index 1054f688..cb4271ed 100644 --- a/kdb-web/src/app/modules/view/server/members/members.component.html +++ b/kdb-web/src/app/modules/view/server/members/members.component.html @@ -204,7 +204,7 @@ {{'common.level' | translate}}: - + {{member.level.name}} diff --git a/kdb-web/src/app/modules/view/server/profile/profile.component.html b/kdb-web/src/app/modules/view/server/profile/profile.component.html index 46ddaf7c..43cca8b0 100644 --- a/kdb-web/src/app/modules/view/server/profile/profile.component.html +++ b/kdb-web/src/app/modules/view/server/profile/profile.component.html @@ -30,7 +30,32 @@
{{'view.server.profile.xp' | translate}}:
-
{{user.xp}}
+
{{user.xp}}
+
+
+
+ +
+
+
{{'view.server.profile.message_count' | translate}}:
+
{{user.messageCount}}
+
+
+ +
+
+
{{'view.server.profile.reaction_count' | translate}}:
+
{{user.reactionCount}}
+
+
+ +
+
+
{{'view.server.profile.birthday' | translate}}:
+
{{user.birthday}}
+
+ +
@@ -41,17 +66,14 @@
- - - - - - -
{{'view.server.profile.level' | translate}}:
-
{{user.level?.name}}
+
{{user.level?.name}}
+
+ + +
@@ -266,8 +288,12 @@
- +
+ + +
diff --git a/kdb-web/src/app/modules/view/server/profile/profile.component.ts b/kdb-web/src/app/modules/view/server/profile/profile.component.ts index c06e8387..6625f101 100644 --- a/kdb-web/src/app/modules/view/server/profile/profile.component.ts +++ b/kdb-web/src/app/modules/view/server/profile/profile.component.ts @@ -1,7 +1,7 @@ import { Component, OnDestroy, OnInit } from "@angular/core"; import { ActivatedRoute, Router } from "@angular/router"; import { Queries } from "../../../../models/graphql/queries.model"; -import { UserListQuery, UserWarningQuery } from "../../../../models/graphql/query.model"; +import { LevelListQuery, Query, UserListQuery, UserWarningQuery } from "../../../../models/graphql/query.model"; import { SpinnerService } from "../../../../services/spinner/spinner.service"; import { DataService } from "../../../../services/data/data.service"; import { User } from "../../../../models/data/user.model"; @@ -13,10 +13,11 @@ import { Server } from "../../../../models/data/server.model"; import { forkJoin, Subject, throwError } from "rxjs"; import { catchError, takeUntil } from "rxjs/operators"; import { Table } from "primeng/table"; -import { UserWarning } from "../../../../models/data/user_warning.model"; -import { LevelMutationResult, UpdateUserMutationResult, UserWarningMutationResult } from "../../../../models/graphql/result.model"; +import { UpdateUserMutationResult } from "../../../../models/graphql/result.model"; import { Mutations } from "../../../../models/graphql/mutations.model"; -import { ConfirmationDialogService } from "../../../../services/confirmation-dialog/confirmation-dialog.service"; +import { MenuItem } from "primeng/api"; +import { UserWarning } from "../../../../models/data/user_warning.model"; +import moment from "moment"; @Component({ selector: "app-profile", @@ -26,11 +27,13 @@ import { ConfirmationDialogService } from "../../../../services/confirmation-dia export class ProfileComponent implements OnInit, OnDestroy { user: User = { createdAt: "", modifiedAt: "" }; + levels!: MenuItem[]; private server: Server = {}; private author?: UserDTO; private clonedUserWarnings: UserWarning[] = []; public isEditingNewUserWarning: boolean = false; public isEditing: boolean = false; + public isModerator: boolean = false; private unsubscriber = new Subject(); @@ -47,6 +50,7 @@ export class ProfileComponent implements OnInit, OnDestroy { } public ngOnInit(): void { + this.isEditing = false; this.loadProfile(); } @@ -59,6 +63,18 @@ export class ProfileComponent implements OnInit, OnDestroy { } this.server = server; + this.data.query(Queries.levelQuery, { + serverId: server.id + }, + (data: Query) => { + return data.servers[0]; + } + ).subscribe(data => { + this.levels = data.levels.map(level => { + return { label: level.name, value: level }; + }); + }); + let authUser = await this.auth.getLoggedInUser(); this.spinner.showSpinner(); let user: UserDTO | null = authUser?.users?.find(u => u.server == server.id) ?? null; @@ -69,6 +85,7 @@ export class ProfileComponent implements OnInit, OnDestroy { return; } this.author = user; + this.isModerator = user?.isModerator; this.data.query(Queries.userProfile, { serverId: this.server.id, @@ -90,7 +107,6 @@ export class ProfileComponent implements OnInit, OnDestroy { ).subscribe(result => { this.user.userWarningCount = result.userWarningCount; this.user.userWarnings = result.userWarnings; - console.log(result); this.spinner.hideSpinner(); }); @@ -99,12 +115,16 @@ export class ProfileComponent implements OnInit, OnDestroy { }); } + public toogleEditUser() { + this.isEditing = !this.isEditing; + } + public updateUser() { - this.spinner.showSpinner(); this.spinner.showSpinner(); this.data.mutation(Mutations.updateUser, { id: this.user.id, xp: this.user.xp, + birthday: moment(this.user.birthday).format("DD.MM.YYYY"), levelId: this.user.level?.id, userWarnings: this.user.userWarnings?.map(userWarning => { return { @@ -112,15 +132,17 @@ export class ProfileComponent implements OnInit, OnDestroy { user: userWarning.user?.id ?? this.user.id, description: userWarning.description, author: userWarning.author?.id ?? this.author?.id - } + }; }) } ).pipe(catchError(err => { this.spinner.hideSpinner(); + this.isEditing = false; return throwError(err); })).subscribe(_ => { this.spinner.hideSpinner(); this.toastService.success(this.translate.instant("view.server.members.message.user_changed"), this.translate.instant("view.server.members.message.user_changed_d", { name: this.user.name })); + this.isEditing = false; this.loadProfile(); }); } @@ -180,7 +202,7 @@ export class ProfileComponent implements OnInit, OnDestroy { this.user.joinedVoiceChannels = []; } - addNewUserWarning(table: Table) { + public addNewUserWarning(table: Table) { const newWarning: UserWarning = { description: "", user: this.user @@ -200,11 +222,11 @@ export class ProfileComponent implements OnInit, OnDestroy { this.clonedUserWarnings[index] = { ...user }; } - deleteUserWarning(index: number) { + public deleteUserWarning(index: number) { this.user.userWarnings?.splice(index, 1); } - editSaveUserWarning(value: any, index: number) { + public editSaveUserWarning(value: any, index: number) { this.isEditingNewUserWarning = false; if (!value.value || !this.user.userWarnings || this.user.userWarnings[index] == this.clonedUserWarnings[index]) { return; @@ -213,7 +235,7 @@ export class ProfileComponent implements OnInit, OnDestroy { delete this.clonedUserWarnings[index]; } - editCancelUserWarning(index: number) { + public editCancelUserWarning(index: number) { if (this.user.userWarnings) { this.user.userWarnings[index] = this.clonedUserWarnings[index]; } diff --git a/kdb-web/src/assets/i18n/de.json b/kdb-web/src/assets/i18n/de.json index 2219275a..53e6c76a 100644 --- a/kdb-web/src/assets/i18n/de.json +++ b/kdb-web/src/assets/i18n/de.json @@ -122,6 +122,7 @@ } }, "common": { + "edit": "Bearbeiten", "user_warnings": "Verwarnungen", "author": "Autor", "404": "404 - Der Eintrag konnte nicht gefunden werden", @@ -484,6 +485,9 @@ } }, "profile": { + "message_count": "Anzahl Nachrichten", + "reaction_count": "Anzahl Reaktionen", + "birthday": "Geburtstag", "achievements": { "header": "Errungeschaften", "time": "Erreicht am" diff --git a/kdb-web/src/assets/version.json b/kdb-web/src/assets/version.json index e044326d..3ae731e3 100644 --- a/kdb-web/src/assets/version.json +++ b/kdb-web/src/assets/version.json @@ -1,7 +1,7 @@ { "WebVersion": { "Major": "1", - "Minor": "1", - "Micro": "dev402" + "Minor": "2", + "Micro": "0" } } \ No newline at end of file diff --git a/kdb-web/src/styles/primeng-fixes.scss b/kdb-web/src/styles/primeng-fixes.scss index 67f10cd6..81ad47dc 100644 --- a/kdb-web/src/styles/primeng-fixes.scss +++ b/kdb-web/src/styles/primeng-fixes.scss @@ -94,8 +94,13 @@ p-table { } } -.p-dropdown { - width: 100% !important; +.content-row { + p-dropdown, + .p-dropdown, + p-calendar, + .p-calendar, { + width: 100% !important; + } } .pi-sort-alt:before { diff --git a/kdb-web/src/styles/themes/sh-edraft-dark-theme.scss b/kdb-web/src/styles/themes/sh-edraft-dark-theme.scss index fba55057..827d3933 100644 --- a/kdb-web/src/styles/themes/sh-edraft-dark-theme.scss +++ b/kdb-web/src/styles/themes/sh-edraft-dark-theme.scss @@ -683,4 +683,77 @@ p-inputNumber { background-color: $primaryBackgroundColor !important; } + + p-calendar > span > button { + background-color: $primaryHeaderColor !important; + border: 1px solid $primaryHeaderColor !important; + + &:focus { + box-shadow: none !important; + } + } + + .p-calendar { + .p-datepicker:not(.p-datepicker-inline) { + background-color: $secondaryBackgroundColor !important; + } + + .p-datepicker { + .p-datepicker-header { + color: $primaryHeaderColor !important; + background-color: $primaryBackgroundColor !important; + + .p-datepicker-title .p-datepicker-year, + .p-datepicker-title .p-datepicker-month, + .p-datepicker .p-datepicker-header .p-datepicker-title .p-datepicker-month { + color: $primaryTextColor !important; + + &:hover { + color: $primaryHeaderColor !important; + } + + &:focus { + box-shadow: none !important; + } + } + } + } + + table td > span { + color: $primaryTextColor !important; + + &:hover { + color: $primaryHeaderColor !important; + background-color: $primaryBackgroundColor !important; + } + + &:focus { + box-shadow: none !important; + } + } + + table td.p-datepicker-today > span { + color: $primaryHeaderColor !important; + background-color: $primaryBackgroundColor !important; + } + + table td > span.p-highlight { + color: $primaryHeaderColor !important; + background-color: $primaryBackgroundColor !important; + } + + .p-yearpicker .p-yearpicker-year, + .p-monthpicker .p-monthpicker-month:not(.p-disabled):not(.p-highlight) { + color: $primaryTextColor !important; + background-color: $secondaryBackgroundColor !important; + + &:hover { + color: $primaryHeaderColor !important; + } + + &:focus { + box-shadow: none !important; + } + } + } } -- 2.45.2 From 5057cbed16b03174ef4994d009bd2ffa439ed997 Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Wed, 11 Oct 2023 11:18:37 +0200 Subject: [PATCH 04/58] Added birthday command #401 --- kdb-bot/src/bot/translation/de.json | 4 + .../bot_core/service/client_utils_service.py | 2 +- .../auto_role/command/auto_role_group.py | 2 +- .../src/modules/base/command/user_group.py | 88 +++++++++++++++---- 4 files changed, 79 insertions(+), 17 deletions(-) diff --git a/kdb-bot/src/bot/translation/de.json b/kdb-bot/src/bot/translation/de.json index c1390bdf..5c850579 100644 --- a/kdb-bot/src/bot/translation/de.json +++ b/kdb-bot/src/bot/translation/de.json @@ -229,6 +229,10 @@ "success": "Verlinkung wurde entfernt :D" }, "user": { + "birthday": { + "success": "Dein Geburtstag wurde eingetragen.", + "success_team": "{} hat seinen Geburtstag eingetragen: {}" + }, "add": { "xp": "Die {} von {} wurden um {} erhöht" }, diff --git a/kdb-bot/src/bot_core/service/client_utils_service.py b/kdb-bot/src/bot_core/service/client_utils_service.py index 24143dbb..e5bd200a 100644 --- a/kdb-bot/src/bot_core/service/client_utils_service.py +++ b/kdb-bot/src/bot_core/service/client_utils_service.py @@ -131,7 +131,7 @@ class ClientUtilsService(ClientUtilsABC): if current in sl: sl = sl.skip(sl.index_of(current)) - _l = _l.where(lambda x: x.name in sl) + _l = _l.where(lambda x: select(x) in sl) return _l.take(25) diff --git a/kdb-bot/src/modules/auto_role/command/auto_role_group.py b/kdb-bot/src/modules/auto_role/command/auto_role_group.py index bf1f7758..58b8532c 100644 --- a/kdb-bot/src/modules/auto_role/command/auto_role_group.py +++ b/kdb-bot/src/modules/auto_role/command/auto_role_group.py @@ -61,7 +61,7 @@ class AutoRoleGroup(DiscordCommandABC): auto_roles = self._auto_roles.get_auto_roles_by_server_id(server.id).select(lambda x: x.id) return [ app_commands.Choice(name=auto_role, value=auto_role) - for auto_role in self._client_utils.get_auto_complete_list(auto_roles, current) + for auto_role in self._client_utils.get_auto_complete_list(auto_roles, current, lambda x: x.name) ] @commands.hybrid_group(name="auto-role") diff --git a/kdb-bot/src/modules/base/command/user_group.py b/kdb-bot/src/modules/base/command/user_group.py index 2c6f563f..7f8a6510 100644 --- a/kdb-bot/src/modules/base/command/user_group.py +++ b/kdb-bot/src/modules/base/command/user_group.py @@ -1,10 +1,12 @@ -from typing import Optional, List +import datetime +from typing import Optional, List as TList import discord from cpl_core.configuration import ConfigurationABC from cpl_core.database.context import DatabaseContextABC from cpl_discord.command import DiscordCommandABC from cpl_discord.service import DiscordBotServiceABC +from cpl_query.extension import List from cpl_translation import TranslatePipe from discord import app_commands from discord.ext import commands @@ -22,6 +24,7 @@ from bot_data.abc.user_joined_voice_channel_repository_abc import ( ) from bot_data.abc.user_repository_abc import UserRepositoryABC from bot_data.abc.user_warnings_repository_abc import UserWarningsRepositoryABC +from bot_data.model.server_config import ServerConfig from modules.base.service.user_warnings_service import UserWarningsService from modules.level.service.level_service import LevelService from modules.permission.abc.permission_service_abc import PermissionServiceABC @@ -73,7 +76,7 @@ class UserGroup(DiscordCommandABC): "ontime": self._t.transform("modules.base.user.atr.ontime"), } - self._atr_list = [(key, self._atr_dict[key]) for key in self._atr_dict] + self._atr_TList = [(key, self._atr_dict[key]) for key in self._atr_dict] async def _handle_atr_calc( self, @@ -116,6 +119,61 @@ class UserGroup(DiscordCommandABC): async def user(self, ctx: Context): pass + @user.command() + @commands.guild_only() + @CommandChecks.check_is_ready() + async def birthday(self, ctx: Context, day: int, month: int, year: int): + self._logger.debug(__name__, f"Received command user birthday {ctx}:{ctx.author},{day}:{month}:{year}") + date = datetime.date(year, month, day) + server = self._servers.get_server_by_discord_id(ctx.guild.id) + user = self._users.get_user_by_discord_id_and_server_id(ctx.author.id, server.id) + user.birthday = date + self._users.update_user(user) + self._db.save_changes() + await self._message_service.send_interaction_msg( + ctx.interaction, self._t.transform("modules.base.user.birthday.success") + ) + # notify team to prevent multiple entries every day + settings: ServerConfig = self._config.get_configuration(f"ServerConfig_{ctx.guild.id}") + channel = ctx.guild.get_channel(settings.team_channel_id) + await self._message_service.send_channel_message( + channel, + self._t.transform("modules.base.user.birthday.success_team").format(ctx.author.mention, date), + is_persistent=True, + ) + self._logger.trace(__name__, f"Finished user-info command") + + @birthday.autocomplete("day") + async def birthday_autocomplete( + self, interaction: discord.Interaction, current: str + ) -> TList[app_commands.Choice[int]]: + days = List(int, range(0, 32)).select(lambda x: str(x)) + return [ + app_commands.Choice(name=date, value=date) + for date in self._client_utils.get_auto_complete_list(days, current) + ] + + @birthday.autocomplete("month") + async def birthday_autocomplete( + self, interaction: discord.Interaction, current: str + ) -> TList[app_commands.Choice[int]]: + days = List(int, range(0, 13)).select(lambda x: str(x)) + return [ + app_commands.Choice(name=date, value=date) + for date in self._client_utils.get_auto_complete_list(days, current) + ] + + @birthday.autocomplete("year") + async def birthday_autocomplete( + self, interaction: discord.Interaction, current: str + ) -> TList[app_commands.Choice[int]]: + today = datetime.date.today() + days = List(int, range(today.year - 75, today.year)).select(lambda x: str(x)) + return [ + app_commands.Choice(name=date, value=date) + for date in self._client_utils.get_auto_complete_list(days, current) + ] + @user.command() @commands.guild_only() @CommandChecks.check_is_ready() @@ -237,8 +295,8 @@ class UserGroup(DiscordCommandABC): ) @get.autocomplete("atr") - async def get_autocomplete(self, interaction: discord.Interaction, current: str) -> List[app_commands.Choice[str]]: - return [app_commands.Choice(name=value, value=key) for key, value in self._atr_list] + async def get_autocomplete(self, interaction: discord.Interaction, current: str) -> TList[app_commands.Choice[str]]: + return [app_commands.Choice(name=value, value=key) for key, value in self._atr_TList] @user.command() @commands.guild_only() @@ -281,9 +339,9 @@ class UserGroup(DiscordCommandABC): ) @set.autocomplete("atr") - async def set_autocomplete(self, interaction: discord.Interaction, current: str) -> List[app_commands.Choice[str]]: - atr_list = [("xp", self._atr_dict["xp"])] - return [app_commands.Choice(name=value, value=key) for key, value in atr_list] + async def set_autocomplete(self, interaction: discord.Interaction, current: str) -> TList[app_commands.Choice[str]]: + atr_TList = [("xp", self._atr_dict["xp"])] + return [app_commands.Choice(name=value, value=key) for key, value in atr_TList] @user.command() @commands.guild_only() @@ -294,9 +352,9 @@ class UserGroup(DiscordCommandABC): await self._handle_atr_calc(ctx, atr, value, member) @add.autocomplete("atr") - async def set_autocomplete(self, interaction: discord.Interaction, current: str) -> List[app_commands.Choice[str]]: - atr_list = [("xp", self._atr_dict["xp"])] - return [app_commands.Choice(name=value, value=key) for key, value in atr_list] + async def set_autocomplete(self, interaction: discord.Interaction, current: str) -> TList[app_commands.Choice[str]]: + atr_TList = [("xp", self._atr_dict["xp"])] + return [app_commands.Choice(name=value, value=key) for key, value in atr_TList] @user.command() @commands.guild_only() @@ -307,9 +365,9 @@ class UserGroup(DiscordCommandABC): await self._handle_atr_calc(ctx, atr, value, member, is_remove=True) @remove.autocomplete("atr") - async def set_autocomplete(self, interaction: discord.Interaction, current: str) -> List[app_commands.Choice[str]]: - atr_list = [("xp", self._atr_dict["xp"])] - return [app_commands.Choice(name=value, value=key) for key, value in atr_list] + async def set_autocomplete(self, interaction: discord.Interaction, current: str) -> TList[app_commands.Choice[str]]: + atr_TList = [("xp", self._atr_dict["xp"])] + return [app_commands.Choice(name=value, value=key) for key, value in atr_TList] @user.command() @commands.guild_only() @@ -349,8 +407,8 @@ class UserGroup(DiscordCommandABC): @reset.autocomplete("atr") async def reset_autocomplete( self, interaction: discord.Interaction, current: str - ) -> List[app_commands.Choice[str]]: - return [app_commands.Choice(name=value, value=key) for key, value in self._atr_list] + ) -> TList[app_commands.Choice[str]]: + return [app_commands.Choice(name=value, value=key) for key, value in self._atr_TList] @user.group() @commands.guild_only() -- 2.45.2 From 4747f23202579b82802a196f2db44291041cfbd5 Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Wed, 11 Oct 2023 13:51:57 +0200 Subject: [PATCH 05/58] Get steam offers #188 --- kdb-bot/cpl-workspace.json | 1 + kdb-bot/src/bot/bot.json | 1 + kdb-bot/src/bot/config | 2 +- kdb-bot/src/bot/module_list.py | 2 + kdb-bot/src/bot/startup.py | 2 + .../configuration/feature_flags_enum.py | 2 + .../configuration/feature_flags_settings.py | 2 + kdb-bot/src/bot_core/logging/task_logger.py | 15 ++++ .../modules/steam_special_offers/__init__.py | 1 + .../steam_special_offers/base/__init__.py | 1 + .../base/special_offer_watcher_abc.py | 13 +++ .../steam_special_offers/events/__init__.py | 1 + .../events/special_offer_on_ready_event.py | 25 ++++++ .../steam_special_offers/model/__init__.py | 1 + .../steam_special_offers/model/game_offer.py | 6 ++ .../steam_special_offers/special-offers.json | 46 ++++++++++ .../special_offers_module.py | 25 ++++++ .../steam_offer_watcher.py | 88 +++++++++++++++++++ 18 files changed, 233 insertions(+), 1 deletion(-) create mode 100644 kdb-bot/src/bot_core/logging/task_logger.py create mode 100644 kdb-bot/src/modules/steam_special_offers/__init__.py create mode 100644 kdb-bot/src/modules/steam_special_offers/base/__init__.py create mode 100644 kdb-bot/src/modules/steam_special_offers/base/special_offer_watcher_abc.py create mode 100644 kdb-bot/src/modules/steam_special_offers/events/__init__.py create mode 100644 kdb-bot/src/modules/steam_special_offers/events/special_offer_on_ready_event.py create mode 100644 kdb-bot/src/modules/steam_special_offers/model/__init__.py create mode 100644 kdb-bot/src/modules/steam_special_offers/model/game_offer.py create mode 100644 kdb-bot/src/modules/steam_special_offers/special-offers.json create mode 100644 kdb-bot/src/modules/steam_special_offers/special_offers_module.py create mode 100644 kdb-bot/src/modules/steam_special_offers/steam_offer_watcher.py diff --git a/kdb-bot/cpl-workspace.json b/kdb-bot/cpl-workspace.json index 8e010570..3072efb4 100644 --- a/kdb-bot/cpl-workspace.json +++ b/kdb-bot/cpl-workspace.json @@ -17,6 +17,7 @@ "permission": "src/modules/permission/permission.json", "technician": "src/modules/technician/technician.json", "short-role-name": "src/modules/short_role_name/short-role-name.json", + "steam-special-offers": "src/modules/steam_special_offers/steam-special-offers.json", "checks": "tools/checks/checks.json", "get-version": "tools/get_version/get-version.json", "post-build": "tools/post_build/post-build.json", diff --git a/kdb-bot/src/bot/bot.json b/kdb-bot/src/bot/bot.json index 6cfefe9a..3f096001 100644 --- a/kdb-bot/src/bot/bot.json +++ b/kdb-bot/src/bot/bot.json @@ -69,6 +69,7 @@ "../modules/level/level.json", "../modules/permission/permission.json", "../modules/short_role_name/short-role-name.json", + "../modules/steam_special_offers/steam-special-offers.json", "../modules/technician/technician.json" ] } diff --git a/kdb-bot/src/bot/config b/kdb-bot/src/bot/config index 23eafb2e..839bbb82 160000 --- a/kdb-bot/src/bot/config +++ b/kdb-bot/src/bot/config @@ -1 +1 @@ -Subproject commit 23eafb2e211241acbbc52833d139c67f1ecc69f5 +Subproject commit 839bbb823a6e0c9e1443e0844446bfe240284063 diff --git a/kdb-bot/src/bot/module_list.py b/kdb-bot/src/bot/module_list.py index 810a0851..65107af2 100644 --- a/kdb-bot/src/bot/module_list.py +++ b/kdb-bot/src/bot/module_list.py @@ -14,6 +14,7 @@ from modules.database.database_module import DatabaseModule from modules.level.level_module import LevelModule from modules.permission.permission_module import PermissionModule from modules.short_role_name.short_role_name_module import ShortRoleNameModule +from modules.steam_special_offers.special_offers_module import SteamSpecialOffersModule from modules.technician.technician_module import TechnicianModule @@ -37,6 +38,7 @@ class ModuleList: TechnicianModule, AchievementsModule, ShortRoleNameModule, + SteamSpecialOffersModule, # has to be last! BootLogModule, CoreExtensionModule, diff --git a/kdb-bot/src/bot/startup.py b/kdb-bot/src/bot/startup.py index 6895ddc8..0a5422d2 100644 --- a/kdb-bot/src/bot/startup.py +++ b/kdb-bot/src/bot/startup.py @@ -16,6 +16,7 @@ from bot_core.configuration.feature_flags_settings import FeatureFlagsSettings from bot_core.logging.command_logger import CommandLogger from bot_core.logging.database_logger import DatabaseLogger from bot_core.logging.message_logger import MessageLogger +from bot_core.logging.task_logger import TaskLogger from bot_data.db_context import DBContext @@ -43,6 +44,7 @@ class Startup(StartupABC): services.add_singleton(CustomFileLoggerABC, CommandLogger) services.add_singleton(CustomFileLoggerABC, DatabaseLogger) services.add_singleton(CustomFileLoggerABC, MessageLogger) + services.add_singleton(CustomFileLoggerABC, TaskLogger) if self._feature_flags.get_flag(FeatureFlagsEnum.api_module): services.add_singleton(CustomFileLoggerABC, ApiLogger) diff --git a/kdb-bot/src/bot_core/configuration/feature_flags_enum.py b/kdb-bot/src/bot_core/configuration/feature_flags_enum.py index f56f06b0..6d051b0c 100644 --- a/kdb-bot/src/bot_core/configuration/feature_flags_enum.py +++ b/kdb-bot/src/bot_core/configuration/feature_flags_enum.py @@ -17,6 +17,7 @@ class FeatureFlagsEnum(Enum): moderator_module = "ModeratorModule" permission_module = "PermissionModule" short_role_name_module = "ShortRoleNameModule" + steam_special_offers_module = "SteamSpecialOffersModule" # features api_only = "ApiOnly" presence = "Presence" @@ -25,3 +26,4 @@ class FeatureFlagsEnum(Enum): sync_xp = "SyncXp" short_role_name = "ShortRoleName" technician_full_access = "TechnicianFullAccess" + steam_special_offers = "SteamSpecialOffers" diff --git a/kdb-bot/src/bot_core/configuration/feature_flags_settings.py b/kdb-bot/src/bot_core/configuration/feature_flags_settings.py index 37c17483..0ed95e71 100644 --- a/kdb-bot/src/bot_core/configuration/feature_flags_settings.py +++ b/kdb-bot/src/bot_core/configuration/feature_flags_settings.py @@ -19,6 +19,7 @@ class FeatureFlagsSettings(ConfigurationModelABC): FeatureFlagsEnum.permission_module.value: True, # 02.10.2022 #48 FeatureFlagsEnum.config_module.value: True, # 19.07.2023 #127 FeatureFlagsEnum.short_role_name_module.value: True, # 28.09.2023 #378 + FeatureFlagsEnum.steam_special_offers_module.value: True, # 11.10.2023 #188 # features FeatureFlagsEnum.api_only.value: False, # 13.10.2022 #70 FeatureFlagsEnum.presence.value: True, # 03.10.2022 #56 @@ -27,6 +28,7 @@ class FeatureFlagsSettings(ConfigurationModelABC): FeatureFlagsEnum.sync_xp.value: False, # 25.09.2023 #366 FeatureFlagsEnum.short_role_name.value: False, # 28.09.2023 #378 FeatureFlagsEnum.technician_full_access.value: False, # 03.10.2023 #393 + FeatureFlagsEnum.steam_special_offers.value: False, # 11.10.2023 #188 } def __init__(self, **kwargs: dict): diff --git a/kdb-bot/src/bot_core/logging/task_logger.py b/kdb-bot/src/bot_core/logging/task_logger.py new file mode 100644 index 00000000..fc4a637c --- /dev/null +++ b/kdb-bot/src/bot_core/logging/task_logger.py @@ -0,0 +1,15 @@ +from cpl_core.configuration import ConfigurationABC +from cpl_core.environment import ApplicationEnvironmentABC +from cpl_core.time import TimeFormatSettings + +from bot_core.abc.custom_file_logger_abc import CustomFileLoggerABC + + +class TaskLogger(CustomFileLoggerABC): + def __init__( + self, + config: ConfigurationABC, + time_format: TimeFormatSettings, + env: ApplicationEnvironmentABC, + ): + CustomFileLoggerABC.__init__(self, "Task", config, time_format, env) diff --git a/kdb-bot/src/modules/steam_special_offers/__init__.py b/kdb-bot/src/modules/steam_special_offers/__init__.py new file mode 100644 index 00000000..425ab6c1 --- /dev/null +++ b/kdb-bot/src/modules/steam_special_offers/__init__.py @@ -0,0 +1 @@ +# imports diff --git a/kdb-bot/src/modules/steam_special_offers/base/__init__.py b/kdb-bot/src/modules/steam_special_offers/base/__init__.py new file mode 100644 index 00000000..425ab6c1 --- /dev/null +++ b/kdb-bot/src/modules/steam_special_offers/base/__init__.py @@ -0,0 +1 @@ +# imports diff --git a/kdb-bot/src/modules/steam_special_offers/base/special_offer_watcher_abc.py b/kdb-bot/src/modules/steam_special_offers/base/special_offer_watcher_abc.py new file mode 100644 index 00000000..fd4fe99d --- /dev/null +++ b/kdb-bot/src/modules/steam_special_offers/base/special_offer_watcher_abc.py @@ -0,0 +1,13 @@ +from abc import ABC, abstractmethod + +from discord.ext import commands + + +class SpecialOfferWatcherABC(commands.Cog): + @abstractmethod + def __init__(self): + commands.Cog.__init__(self) + + @abstractmethod + def start(self): + pass diff --git a/kdb-bot/src/modules/steam_special_offers/events/__init__.py b/kdb-bot/src/modules/steam_special_offers/events/__init__.py new file mode 100644 index 00000000..425ab6c1 --- /dev/null +++ b/kdb-bot/src/modules/steam_special_offers/events/__init__.py @@ -0,0 +1 @@ +# imports diff --git a/kdb-bot/src/modules/steam_special_offers/events/special_offer_on_ready_event.py b/kdb-bot/src/modules/steam_special_offers/events/special_offer_on_ready_event.py new file mode 100644 index 00000000..db7e7f18 --- /dev/null +++ b/kdb-bot/src/modules/steam_special_offers/events/special_offer_on_ready_event.py @@ -0,0 +1,25 @@ +from cpl_core.logging import LoggerABC +from cpl_discord.events import OnReadyABC +from cpl_discord.service import DiscordBotServiceABC + +from bot_core.logging.task_logger import TaskLogger +from modules.steam_special_offers.base.special_offer_watcher_abc import SpecialOfferWatcherABC + + +class SpecialOfferOnReadyEvent(OnReadyABC): + def __init__( + self, + logger: TaskLogger, + bot: DiscordBotServiceABC, + watchers: list[SpecialOfferWatcherABC], + ): + OnReadyABC.__init__(self) + + self._logger = logger + self._bot = bot + self._watchers = watchers + + async def on_ready(self): + for watcher in self._watchers: + self._logger.info(__name__, f"Starting watcher {type(watcher).__name__}") + watcher.start() diff --git a/kdb-bot/src/modules/steam_special_offers/model/__init__.py b/kdb-bot/src/modules/steam_special_offers/model/__init__.py new file mode 100644 index 00000000..425ab6c1 --- /dev/null +++ b/kdb-bot/src/modules/steam_special_offers/model/__init__.py @@ -0,0 +1 @@ +# imports diff --git a/kdb-bot/src/modules/steam_special_offers/model/game_offer.py b/kdb-bot/src/modules/steam_special_offers/model/game_offer.py new file mode 100644 index 00000000..df6562fe --- /dev/null +++ b/kdb-bot/src/modules/steam_special_offers/model/game_offer.py @@ -0,0 +1,6 @@ +class GameOffer: + def __init__(self, name: str, original_price: float, discount_price: float, discount_pct: int): + self.name = name + self.original_price = original_price + self.discount_price = discount_price + self.discount_pct = discount_pct diff --git a/kdb-bot/src/modules/steam_special_offers/special-offers.json b/kdb-bot/src/modules/steam_special_offers/special-offers.json new file mode 100644 index 00000000..3a1bdc9b --- /dev/null +++ b/kdb-bot/src/modules/steam_special_offers/special-offers.json @@ -0,0 +1,46 @@ +{ + "ProjectSettings": { + "Name": "steam-special-offers", + "Version": { + "Major": "0", + "Minor": "0", + "Micro": "0" + }, + "Author": "", + "AuthorEmail": "", + "Description": "", + "LongDescription": "", + "URL": "", + "CopyrightDate": "", + "CopyrightName": "", + "LicenseName": "", + "LicenseDescription": "", + "Dependencies": [ + "cpl-core>=2023.4.0.post5" + ], + "DevDependencies": [ + "cpl-cli>=2023.4.0.post3" + ], + "PythonVersion": ">=3.10.4", + "PythonPath": { + "linux": "" + }, + "Classifiers": [] + }, + "BuildSettings": { + "ProjectType": "library", + "SourcePath": "", + "OutputPath": "../../dist", + "Main": "steam_special_offers.main", + "EntryPoint": "steam-special-offers", + "IncludePackageData": false, + "Included": [], + "Excluded": [ + "*/__pycache__", + "*/logs", + "*/tests" + ], + "PackageData": {}, + "ProjectReferences": [] + } +} \ No newline at end of file diff --git a/kdb-bot/src/modules/steam_special_offers/special_offers_module.py b/kdb-bot/src/modules/steam_special_offers/special_offers_module.py new file mode 100644 index 00000000..4050442f --- /dev/null +++ b/kdb-bot/src/modules/steam_special_offers/special_offers_module.py @@ -0,0 +1,25 @@ +from cpl_core.configuration import ConfigurationABC +from cpl_core.dependency_injection import ServiceCollectionABC +from cpl_core.environment import ApplicationEnvironmentABC +from cpl_discord.discord_event_types_enum import DiscordEventTypesEnum +from cpl_discord.service.discord_collection_abc import DiscordCollectionABC + +from bot_core.abc.module_abc import ModuleABC +from bot_core.configuration.feature_flags_enum import FeatureFlagsEnum +from modules.steam_special_offers.base.special_offer_watcher_abc import SpecialOfferWatcherABC +from modules.steam_special_offers.events.special_offer_on_ready_event import SpecialOfferOnReadyEvent +from modules.steam_special_offers.steam_offer_watcher import SteamOfferWatcher + + +class SteamSpecialOffersModule(ModuleABC): + def __init__(self, dc: DiscordCollectionABC): + ModuleABC.__init__(self, dc, FeatureFlagsEnum.steam_special_offers_module) + + def configure_configuration(self, config: ConfigurationABC, env: ApplicationEnvironmentABC): + pass + + def configure_services(self, services: ServiceCollectionABC, env: ApplicationEnvironmentABC): + services.add_singleton(SpecialOfferWatcherABC, SteamOfferWatcher) + # commands + # events + self._dc.add_event(DiscordEventTypesEnum.on_ready.value, SpecialOfferOnReadyEvent) diff --git a/kdb-bot/src/modules/steam_special_offers/steam_offer_watcher.py b/kdb-bot/src/modules/steam_special_offers/steam_offer_watcher.py new file mode 100644 index 00000000..f3408c37 --- /dev/null +++ b/kdb-bot/src/modules/steam_special_offers/steam_offer_watcher.py @@ -0,0 +1,88 @@ +import bs4 +import requests +from cpl_query.extension import List +from discord.ext import tasks + +from bot_core.logging.task_logger import TaskLogger +from modules.steam_special_offers.base.special_offer_watcher_abc import SpecialOfferWatcherABC +from modules.steam_special_offers.model.game_offer import GameOffer + + +class SteamOfferWatcher(SpecialOfferWatcherABC): + def __init__(self, logger: TaskLogger): + SpecialOfferWatcherABC.__init__(self) + + self._logger = logger + + def start(self): + self.watch.start() + + def _get_max_count(self) -> int: + count = 0 + result = requests.get(f"https://store.steampowered.com/search/results?specials=1") + soup = bs4.BeautifulSoup(result.text, "lxml") + element = soup.find_all("div", {"class": "search_results_count"}) + if len(element) < 1: + return count + + count = int(element[0].contents[0].split(" ")[0].replace(",", "")) + + return count + + def _get_games_from_page(self, start: int, count: int) -> List[GameOffer]: + games = List(GameOffer) + result = requests.get( + f"https://store.steampowered.com/search/results?query&start={start}&count={count}&force_infinite=1&specials=1" + ) + soup = bs4.BeautifulSoup(result.text, "lxml") + elements = soup.find_all("a", {"class": "search_result_row"}) + if len(elements) < 1: + return games + + for element in elements: + name_element = element.find("span", {"class": "title"}) + original_price_element = element.find("div", {"class": "discount_original_price"}) + discount_element = element.find("div", {"class": "discount_pct"}) + discount_price_element = element.find("div", {"class": "discount_final_price"}) + + if ( + name_element is None + or len(name_element.contents) < 1 + or original_price_element is None + or len(original_price_element.contents) < 1 + or discount_element is None + or len(discount_element.contents) < 1 + or discount_price_element is None + or len(discount_price_element.contents) < 1 + ): + continue + + name = name_element.contents[0] + original_price = float( + original_price_element.contents[0].replace(" ", "").replace("€", "").replace(",", ".") + ) + discount = int(discount_element.contents[0].replace("%", "")) + discount_price = float( + discount_price_element.contents[0].replace(" ", "").replace("€", "").replace(",", ".") + ) + games.add(GameOffer(name, original_price, discount_price, discount)) + + return games + + async def _watch(self): + self._logger.warn(__name__, "Watching") + new_offers = List(GameOffer) + + max = self._get_max_count() + for i in range(0, max + 100, 100): + self._logger.debug(__name__, f"Get special offers from {i}") + new_offers.extend(self._get_games_from_page(i, 100)) + + self._logger.trace(__name__, "Finished watching") + + @tasks.loop(seconds=5) + async def watch(self): + try: + await self._watch() + except Exception as e: + self._logger.error(__name__, f"Steam offer watcher failed", e) -- 2.45.2 From 3a42b42dbfba20c6872a3abae93b3790c754c0d3 Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Wed, 11 Oct 2023 20:03:54 +0200 Subject: [PATCH 06/58] Improved steam offer #188 --- kdb-bot/cpl-workspace.json | 2 +- kdb-bot/src/bot/bot.json | 2 +- kdb-bot/src/bot/module_list.py | 2 +- .../src/bot/startup_migration_extension.py | 2 + kdb-bot/src/bot/translation/de.json | 5 + .../src/bot_core/service/message_service.py | 4 +- .../abc/steam_special_offer_repository_abc.py | 32 +++ kdb-bot/src/bot_data/data_module.py | 3 + .../steam_special_offer_migration.py | 68 ++++++ kdb-bot/src/bot_data/model/server_config.py | 14 ++ .../src/bot_data/model/steam_special_offer.py | 115 ++++++++++ .../server_config_repository_service.py | 11 +- .../steam_special_offer_repository_service.py | 68 ++++++ .../src/bot_graphql/graphql/serverConfig.gql | 3 + .../mutations/server_config_mutation.py | 5 + .../queries/server_config_query.py | 1 + .../__init__.py | 0 .../base/__init__.py | 0 .../base/special_offer_watcher_abc.py | 0 .../events/__init__.py | 0 .../events/special_offer_on_ready_event.py | 2 +- .../special-offers.json | 0 .../special_offers_module.py | 6 +- .../special_offers/steam_offer_watcher.py | 210 ++++++++++++++++++ .../steam_special_offers/model/__init__.py | 1 - .../steam_special_offers/model/game_offer.py | 6 - .../steam_offer_watcher.py | 88 -------- kdb-web/package.json | 2 +- .../app/models/config/server-config.model.ts | 1 + .../src/app/models/graphql/mutations.model.ts | 5 +- .../components/config/config.component.html | 8 + .../components/config/config.component.ts | 1 + kdb-web/src/assets/i18n/de.json | 15 +- kdb-web/src/assets/i18n/en.json | 9 +- 34 files changed, 573 insertions(+), 118 deletions(-) create mode 100644 kdb-bot/src/bot_data/abc/steam_special_offer_repository_abc.py create mode 100644 kdb-bot/src/bot_data/migration/steam_special_offer_migration.py create mode 100644 kdb-bot/src/bot_data/model/steam_special_offer.py create mode 100644 kdb-bot/src/bot_data/service/steam_special_offer_repository_service.py rename kdb-bot/src/modules/{steam_special_offers => special_offers}/__init__.py (100%) rename kdb-bot/src/modules/{steam_special_offers => special_offers}/base/__init__.py (100%) rename kdb-bot/src/modules/{steam_special_offers => special_offers}/base/special_offer_watcher_abc.py (100%) rename kdb-bot/src/modules/{steam_special_offers => special_offers}/events/__init__.py (100%) rename kdb-bot/src/modules/{steam_special_offers => special_offers}/events/special_offer_on_ready_event.py (87%) rename kdb-bot/src/modules/{steam_special_offers => special_offers}/special-offers.json (100%) rename kdb-bot/src/modules/{steam_special_offers => special_offers}/special_offers_module.py (78%) create mode 100644 kdb-bot/src/modules/special_offers/steam_offer_watcher.py delete mode 100644 kdb-bot/src/modules/steam_special_offers/model/__init__.py delete mode 100644 kdb-bot/src/modules/steam_special_offers/model/game_offer.py delete mode 100644 kdb-bot/src/modules/steam_special_offers/steam_offer_watcher.py diff --git a/kdb-bot/cpl-workspace.json b/kdb-bot/cpl-workspace.json index 3072efb4..833b19a0 100644 --- a/kdb-bot/cpl-workspace.json +++ b/kdb-bot/cpl-workspace.json @@ -17,7 +17,7 @@ "permission": "src/modules/permission/permission.json", "technician": "src/modules/technician/technician.json", "short-role-name": "src/modules/short_role_name/short-role-name.json", - "steam-special-offers": "src/modules/steam_special_offers/steam-special-offers.json", + "special-offers": "src/modules/special_offers/special-offers.json", "checks": "tools/checks/checks.json", "get-version": "tools/get_version/get-version.json", "post-build": "tools/post_build/post-build.json", diff --git a/kdb-bot/src/bot/bot.json b/kdb-bot/src/bot/bot.json index 3f096001..54db031a 100644 --- a/kdb-bot/src/bot/bot.json +++ b/kdb-bot/src/bot/bot.json @@ -69,7 +69,7 @@ "../modules/level/level.json", "../modules/permission/permission.json", "../modules/short_role_name/short-role-name.json", - "../modules/steam_special_offers/steam-special-offers.json", + "../modules/special_offers/special-offers.json", "../modules/technician/technician.json" ] } diff --git a/kdb-bot/src/bot/module_list.py b/kdb-bot/src/bot/module_list.py index 65107af2..88e99721 100644 --- a/kdb-bot/src/bot/module_list.py +++ b/kdb-bot/src/bot/module_list.py @@ -14,7 +14,7 @@ from modules.database.database_module import DatabaseModule from modules.level.level_module import LevelModule from modules.permission.permission_module import PermissionModule from modules.short_role_name.short_role_name_module import ShortRoleNameModule -from modules.steam_special_offers.special_offers_module import SteamSpecialOffersModule +from modules.special_offers.special_offers_module import SteamSpecialOffersModule from modules.technician.technician_module import TechnicianModule diff --git a/kdb-bot/src/bot/startup_migration_extension.py b/kdb-bot/src/bot/startup_migration_extension.py index f697bb9a..bef5cd4d 100644 --- a/kdb-bot/src/bot/startup_migration_extension.py +++ b/kdb-bot/src/bot/startup_migration_extension.py @@ -22,6 +22,7 @@ from bot_data.migration.remove_stats_migration import RemoveStatsMigration from bot_data.migration.short_role_name_migration import ShortRoleNameMigration from bot_data.migration.short_role_name_only_highest_migration import ShortRoleNameOnlyHighestMigration from bot_data.migration.stats_migration import StatsMigration +from bot_data.migration.steam_special_offer_migration import SteamSpecialOfferMigration from bot_data.migration.user_joined_game_server_migration import UserJoinedGameServerMigration from bot_data.migration.user_message_count_per_hour_migration import ( UserMessageCountPerHourMigration, @@ -60,3 +61,4 @@ class StartupMigrationExtension(StartupExtensionABC): services.add_transient(MigrationABC, ShortRoleNameOnlyHighestMigration) # 02.10.2023 #391 - 1.1.9 services.add_transient(MigrationABC, FixUserHistoryMigration) # 10.10.2023 #401 - 1.2.0 services.add_transient(MigrationABC, BirthdayMigration) # 10.10.2023 #401 - 1.2.0 + services.add_transient(MigrationABC, SteamSpecialOfferMigration) # 10.10.2023 #188 - 1.2.0 diff --git a/kdb-bot/src/bot/translation/de.json b/kdb-bot/src/bot/translation/de.json index 5c850579..5f394911 100644 --- a/kdb-bot/src/bot/translation/de.json +++ b/kdb-bot/src/bot/translation/de.json @@ -94,6 +94,11 @@ } }, "modules": { + "special_offers": { + "price": "Preis", + "discount": "Rabatt", + "discount_price": "Neuer Preis" + }, "achievements": { "commands": { "check": "Alles klar, ich schaue eben nach... nom nom" diff --git a/kdb-bot/src/bot_core/service/message_service.py b/kdb-bot/src/bot_core/service/message_service.py index 71caa831..9140742f 100644 --- a/kdb-bot/src/bot_core/service/message_service.py +++ b/kdb-bot/src/bot_core/service/message_service.py @@ -71,7 +71,7 @@ class MessageService(MessageServiceABC): async def send_channel_message( self, channel: discord.TextChannel, - message: Union[str, discord.Embed], + message: Union[str, discord.Embed, list[discord.Embed]], is_persistent: bool = False, wait_before_delete: int = None, without_tracking=False, @@ -81,6 +81,8 @@ class MessageService(MessageServiceABC): try: if isinstance(message, discord.Embed): msg = await channel.send(embed=message) + elif isinstance(message, list): + msg = await channel.send(embeds=message) else: msg = await channel.send(message) except Exception as e: diff --git a/kdb-bot/src/bot_data/abc/steam_special_offer_repository_abc.py b/kdb-bot/src/bot_data/abc/steam_special_offer_repository_abc.py new file mode 100644 index 00000000..7f412730 --- /dev/null +++ b/kdb-bot/src/bot_data/abc/steam_special_offer_repository_abc.py @@ -0,0 +1,32 @@ +from abc import ABC, abstractmethod +from typing import Optional + +from cpl_query.extension import List + +from bot_data.model.steam_special_offer import SteamSpecialOffer + + +class SteamSpecialOfferRepositoryABC(ABC): + @abstractmethod + def __init__(self): + pass + + @abstractmethod + def get_steam_special_offers(self) -> List[SteamSpecialOffer]: + pass + + @abstractmethod + def get_steam_special_offer_by_name(self, name: str) -> SteamSpecialOffer: + pass + + @abstractmethod + def add_steam_special_offer(self, steam_special_offer: SteamSpecialOffer): + pass + + @abstractmethod + def update_steam_special_offer(self, steam_special_offer: SteamSpecialOffer): + pass + + @abstractmethod + def delete_steam_special_offer(self, steam_special_offer: SteamSpecialOffer): + pass diff --git a/kdb-bot/src/bot_data/data_module.py b/kdb-bot/src/bot_data/data_module.py index 427c9cc6..378216ed 100644 --- a/kdb-bot/src/bot_data/data_module.py +++ b/kdb-bot/src/bot_data/data_module.py @@ -17,6 +17,7 @@ from bot_data.abc.level_repository_abc import LevelRepositoryABC from bot_data.abc.server_config_repository_abc import ServerConfigRepositoryABC from bot_data.abc.server_repository_abc import ServerRepositoryABC from bot_data.abc.short_role_name_repository_abc import ShortRoleNameRepositoryABC +from bot_data.abc.steam_special_offer_repository_abc import SteamSpecialOfferRepositoryABC from bot_data.abc.technician_config_repository_abc import TechnicianConfigRepositoryABC from bot_data.abc.user_game_ident_repository_abc import UserGameIdentRepositoryABC from bot_data.abc.user_joined_game_server_repository_abc import UserJoinedGameServerRepositoryABC @@ -43,6 +44,7 @@ from bot_data.service.server_config_repository_service import ServerConfigReposi from bot_data.service.server_config_seeder import ServerConfigSeeder from bot_data.service.server_repository_service import ServerRepositoryService from bot_data.service.short_role_name_repository_service import ShortRoleNameRepositoryService +from bot_data.service.steam_special_offer_repository_service import SteamSpecialOfferRepositoryService from bot_data.service.technician_config_repository_service import TechnicianConfigRepositoryService from bot_data.service.technician_config_seeder import TechnicianConfigSeeder from bot_data.service.user_game_ident_repository_service import UserGameIdentRepositoryService @@ -92,6 +94,7 @@ class DataModule(ModuleABC): services.add_transient(TechnicianConfigRepositoryABC, TechnicianConfigRepositoryService) services.add_transient(ServerConfigRepositoryABC, ServerConfigRepositoryService) services.add_transient(ShortRoleNameRepositoryABC, ShortRoleNameRepositoryService) + services.add_transient(SteamSpecialOfferRepositoryABC, SteamSpecialOfferRepositoryService) services.add_transient(SeederService) services.add_transient(DataSeederABC, TechnicianConfigSeeder) diff --git a/kdb-bot/src/bot_data/migration/steam_special_offer_migration.py b/kdb-bot/src/bot_data/migration/steam_special_offer_migration.py new file mode 100644 index 00000000..18813ae7 --- /dev/null +++ b/kdb-bot/src/bot_data/migration/steam_special_offer_migration.py @@ -0,0 +1,68 @@ +from bot_core.logging.database_logger import DatabaseLogger +from bot_data.abc.migration_abc import MigrationABC +from bot_data.db_context import DBContext + + +class SteamSpecialOfferMigration(MigrationABC): + name = "1.2.0_SteamSpecialOfferMigration" + + def __init__(self, logger: DatabaseLogger, db: DBContext): + MigrationABC.__init__(self) + self._logger = logger + self._db = db + self._cursor = db.cursor + + def upgrade(self): + self._logger.debug(__name__, "Running upgrade") + + self._cursor.execute( + str( + f""" + CREATE TABLE IF NOT EXISTS `SteamSpecialOffers` ( + `Id` BIGINT NOT NULL AUTO_INCREMENT, + `Game` VARCHAR(255) NOT NULL, + `OriginalPrice` FLOAT NOT NULL, + `DiscountPrice` FLOAT NOT NULL, + `DiscountPct` BIGINT NOT NULL, + `CreatedAt` DATETIME(6) NULL DEFAULT CURRENT_TIMESTAMP(6), + `LastModifiedAt` DATETIME(6) NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6), + PRIMARY KEY(`Id`) + ); + """ + ) + ) + + self._cursor.execute( + str( + f""" + ALTER TABLE CFG_Server + ADD COLUMN IF NOT EXISTS GameOfferNotificationChatId BIGINT NULL AFTER ShortRoleNameSetOnlyHighest; + """ + ) + ) + + self._cursor.execute( + str( + f""" + ALTER TABLE CFG_ServerHistory + ADD COLUMN IF NOT EXISTS GameOfferNotificationChatId BIGINT NULL AFTER ShortRoleNameSetOnlyHighest; + """ + ) + ) + + def downgrade(self): + self._cursor.execute("DROP TABLE `SteamSpecialOffers`;") + self._cursor.execute( + str( + f""" + ALTER TABLE CFG_Server DROP COLUMN ShortRoleNameSetOnlyHighest; + """ + ) + ) + self._cursor.execute( + str( + f""" + ALTER TABLE CFG_ServerHistory DROP COLUMN ShortRoleNameSetOnlyHighest; + """ + ) + ) diff --git a/kdb-bot/src/bot_data/model/server_config.py b/kdb-bot/src/bot_data/model/server_config.py index b10410d7..cf220355 100644 --- a/kdb-bot/src/bot_data/model/server_config.py +++ b/kdb-bot/src/bot_data/model/server_config.py @@ -31,6 +31,7 @@ class ServerConfig(TableABC, ConfigurationModelABC): login_message_channel_id: int, default_role_id: Optional[int], short_role_name_only_set_highest_role: bool, + game_offer_notification_chat_id: int, feature_flags: dict[FeatureFlagsEnum], server: Server, afk_channel_ids: List[int], @@ -56,6 +57,7 @@ class ServerConfig(TableABC, ConfigurationModelABC): self._login_message_channel_id = login_message_channel_id self._default_role_id = default_role_id self._short_role_name_only_set_highest_role = short_role_name_only_set_highest_role + self._game_offer_notification_chat_id = game_offer_notification_chat_id self._feature_flags = feature_flags self._server = server @@ -85,6 +87,7 @@ class ServerConfig(TableABC, ConfigurationModelABC): guild.system_channel.id, None, False, + guild.system_channel.id, {}, server, List(int), @@ -223,6 +226,14 @@ class ServerConfig(TableABC, ConfigurationModelABC): def short_role_name_only_set_highest_role(self, value: bool): self._short_role_name_only_set_highest_role = value + @property + def game_offer_notification_chat_id(self) -> int: + return self._game_offer_notification_chat_id + + @game_offer_notification_chat_id.setter + def game_offer_notification_chat_id(self, value: int): + self._game_offer_notification_chat_id = value + @property def feature_flags(self) -> dict[FeatureFlagsEnum]: return self._feature_flags @@ -298,6 +309,7 @@ class ServerConfig(TableABC, ConfigurationModelABC): `LoginMessageChannelId`, `DefaultRoleId`, `ShortRoleNameSetOnlyHighest`, + `GameOfferNotificationChatId`, `FeatureFlags`, `ServerId` ) VALUES ( @@ -317,6 +329,7 @@ class ServerConfig(TableABC, ConfigurationModelABC): {self._login_message_channel_id}, {"NULL" if self._default_role_id is None else self._default_role_id}, {self._short_role_name_only_set_highest_role}, + {self._game_offer_notification_chat_id}, '{json.dumps(self._feature_flags)}', {self._server.id} ); @@ -344,6 +357,7 @@ class ServerConfig(TableABC, ConfigurationModelABC): `LoginMessageChannelId` = {self._login_message_channel_id}, `DefaultRoleId` = {"NULL" if self._default_role_id is None else self._default_role_id}, `ShortRoleNameSetOnlyHighest` = {self._short_role_name_only_set_highest_role}, + `GameOfferNotificationChatId` = {self._game_offer_notification_chat_id}, `FeatureFlags` = '{json.dumps(self._feature_flags)}', `ServerId` = {self._server.id} WHERE `Id` = {self._id}; diff --git a/kdb-bot/src/bot_data/model/steam_special_offer.py b/kdb-bot/src/bot_data/model/steam_special_offer.py new file mode 100644 index 00000000..76301dc4 --- /dev/null +++ b/kdb-bot/src/bot_data/model/steam_special_offer.py @@ -0,0 +1,115 @@ +from datetime import datetime + +from cpl_core.database import TableABC + + +class SteamSpecialOffer(TableABC): + def __init__( + self, + name: str, + original_price: float, + discount_price: float, + discount_pct: int, + created_at: datetime = None, + modified_at: datetime = None, + id=0, + ): + self._id = id + self._name = name + self._original_price = original_price + self._discount_price = discount_price + self._discount_pct = discount_pct + + TableABC.__init__(self) + self._created_at = created_at if created_at is not None else self._created_at + self._modified_at = modified_at if modified_at is not None else self._modified_at + + @property + def id(self) -> int: + return self._id + + @property + def name(self) -> str: + return self._name + + @name.setter + def name(self, value: str): + self._name = value + + @property + def original_price(self) -> float: + return self._original_price + + @original_price.setter + def original_price(self, value: float): + self._original_price = value + + @property + def discount_price(self) -> float: + return self._discount_price + + @discount_price.setter + def discount_price(self, value: float): + self._discount_price = value + + @property + def discount_pct(self) -> int: + return self._discount_pct + + @discount_pct.setter + def discount_pct(self, value: int): + self._discount_pct = value + + @staticmethod + def get_select_all_string() -> str: + return str( + f""" + SELECT * FROM `SteamSpecialOffers`; + """ + ) + + @staticmethod + def get_select_by_name_string(name: str) -> str: + return str( + f""" + SELECT * FROM `SteamSpecialOffers` + WHERE `Game` = '{name}'; + """ + ) + + @property + def insert_string(self) -> str: + return str( + f""" + INSERT INTO `SteamSpecialOffers` ( + `Game`, `OriginalPrice`, `DiscountPrice`, `DiscountPct` + ) VALUES ( + '{self._name}', + {self._original_price}, + {self._discount_price}, + {self._discount_pct} + ); + """ + ) + + @property + def udpate_string(self) -> str: + return str( + f""" + UPDATE `SteamSpecialOffers` + SET `Game` = '{self._name}', + `OriginalPrice` = {self._original_price}, + `DiscountPrice` = {self._discount_price}, + `DiscountPct` = {self._discount_pct} + WHERE `Id` = {self._id}; + """ + ) + + @property + def delete_string(self) -> str: + return str( + f""" + DELETE FROM `SteamSpecialOffers` + WHERE `Id` = {self._id}; + """ + ) diff --git a/kdb-bot/src/bot_data/service/server_config_repository_service.py b/kdb-bot/src/bot_data/service/server_config_repository_service.py index 391649a5..302a5752 100644 --- a/kdb-bot/src/bot_data/service/server_config_repository_service.py +++ b/kdb-bot/src/bot_data/service/server_config_repository_service.py @@ -67,12 +67,13 @@ class ServerConfigRepositoryService(ServerConfigRepositoryABC): result[14], result[15], result[16], - json.loads(result[17]), - self._servers.get_server_by_id(result[18]), - self._get_afk_channel_ids(result[18]), - self._get_team_role_ids(result[18]), - result[19], + result[17], + json.loads(result[18]), + self._servers.get_server_by_id(result[19]), + self._get_afk_channel_ids(result[19]), + self._get_team_role_ids(result[19]), result[20], + result[21], id=result[0], ) diff --git a/kdb-bot/src/bot_data/service/steam_special_offer_repository_service.py b/kdb-bot/src/bot_data/service/steam_special_offer_repository_service.py new file mode 100644 index 00000000..94ee702d --- /dev/null +++ b/kdb-bot/src/bot_data/service/steam_special_offer_repository_service.py @@ -0,0 +1,68 @@ +from typing import Optional + +from cpl_core.database.context import DatabaseContextABC +from cpl_query.extension import List + +from bot_core.logging.database_logger import DatabaseLogger +from bot_data.abc.server_repository_abc import ServerRepositoryABC +from bot_data.abc.steam_special_offer_repository_abc import SteamSpecialOfferRepositoryABC +from bot_data.model.steam_special_offer import SteamSpecialOffer + + +class SteamSpecialOfferRepositoryService(SteamSpecialOfferRepositoryABC): + def __init__( + self, + logger: DatabaseLogger, + db_context: DatabaseContextABC, + servers: ServerRepositoryABC, + ): + self._logger = logger + self._context = db_context + + self._servers = servers + + SteamSpecialOfferRepositoryABC.__init__(self) + + @staticmethod + def _get_value_from_result(value: any) -> Optional[any]: + if isinstance(value, str) and "NULL" in value: + return None + + return value + + def _steam_special_offer_from_result(self, sql_result: tuple) -> SteamSpecialOffer: + return SteamSpecialOffer( + self._get_value_from_result(sql_result[1]), # name + float(self._get_value_from_result(sql_result[2])), # original_price + float(self._get_value_from_result(sql_result[3])), # discount_price + int(self._get_value_from_result(sql_result[4])), # discount_pct + id=self._get_value_from_result(sql_result[0]), # id + ) + + def get_steam_special_offers(self) -> List[SteamSpecialOffer]: + steam_special_offers = List(SteamSpecialOffer) + self._logger.trace(__name__, f"Send SQL command: {SteamSpecialOffer.get_select_all_string()}") + results = self._context.select(SteamSpecialOffer.get_select_all_string()) + for result in results: + self._logger.trace(__name__, f"Get steam_special_offer with id {result[0]}") + steam_special_offers.append(self._steam_special_offer_from_result(result)) + + return steam_special_offers + + def get_steam_special_offer_by_name(self, name: str) -> SteamSpecialOffer: + self._logger.trace(__name__, f"Send SQL command: {SteamSpecialOffer.get_select_by_name_string(name)}") + result = self._context.select(SteamSpecialOffer.get_select_by_name_string(name))[0] + + return self._steam_special_offer_from_result(result) + + def add_steam_special_offer(self, steam_special_offer: SteamSpecialOffer): + self._logger.trace(__name__, f"Send SQL command: {steam_special_offer.insert_string}") + self._context.cursor.execute(steam_special_offer.insert_string) + + def update_steam_special_offer(self, steam_special_offer: SteamSpecialOffer): + self._logger.trace(__name__, f"Send SQL command: {steam_special_offer.udpate_string}") + self._context.cursor.execute(steam_special_offer.udpate_string) + + def delete_steam_special_offer(self, steam_special_offer: SteamSpecialOffer): + self._logger.trace(__name__, f"Send SQL command: {steam_special_offer.delete_string}") + self._context.cursor.execute(steam_special_offer.delete_string) diff --git a/kdb-bot/src/bot_graphql/graphql/serverConfig.gql b/kdb-bot/src/bot_graphql/graphql/serverConfig.gql index b2ab507a..bc2f1e24 100644 --- a/kdb-bot/src/bot_graphql/graphql/serverConfig.gql +++ b/kdb-bot/src/bot_graphql/graphql/serverConfig.gql @@ -16,6 +16,7 @@ type ServerConfig implements TableWithHistoryQuery { loginMessageChannelId: String defaultRoleId: String shortRoleNameOnlySetHighestRole: Boolean + gameOfferNotificationChatId: String featureFlagCount: Int featureFlags: [FeatureFlag] @@ -49,6 +50,7 @@ type ServerConfigHistory implements HistoryTableQuery { loginMessageChannelId: String defaultRoleId: String shortRoleNameOnlySetHighestRole: Boolean + gameOfferNotificationChatId: String featureFlagCount: Int featureFlags: [FeatureFlag] @@ -100,6 +102,7 @@ input ServerConfigInput { loginMessageChannelId: String defaultRoleId: String shortRoleNameOnlySetHighestRole: Boolean + gameOfferNotificationChatId: String featureFlags: [FeatureFlagInput] afkChannelIds: [String] diff --git a/kdb-bot/src/bot_graphql/mutations/server_config_mutation.py b/kdb-bot/src/bot_graphql/mutations/server_config_mutation.py index 024ab3c0..94a04b4f 100644 --- a/kdb-bot/src/bot_graphql/mutations/server_config_mutation.py +++ b/kdb-bot/src/bot_graphql/mutations/server_config_mutation.py @@ -94,6 +94,11 @@ class ServerConfigMutation(QueryABC): if "shortRoleNameOnlySetHighestRole" in input else server_config.short_role_name_only_set_highest_role ) + server_config.game_offer_notification_chat_id = ( + input["gameOfferNotificationChatId"] + if "gameOfferNotificationChatId" in input + else server_config.game_offer_notification_chat_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 diff --git a/kdb-bot/src/bot_graphql/queries/server_config_query.py b/kdb-bot/src/bot_graphql/queries/server_config_query.py index b995927a..080fd874 100644 --- a/kdb-bot/src/bot_graphql/queries/server_config_query.py +++ b/kdb-bot/src/bot_graphql/queries/server_config_query.py @@ -29,6 +29,7 @@ class ServerConfigQuery(DataQueryWithHistoryABC): self.set_field( "shortRoleNameOnlySetHighestRole", lambda config, *_: config.short_role_name_only_set_highest_role ) + self.set_field("gameOfferNotificationChatId", lambda config, *_: config.game_offer_notification_chat_id) self.add_collection( "featureFlag", lambda config, *_: List(any, [{"key": x, "value": config.feature_flags[x]} for x in config.feature_flags]), diff --git a/kdb-bot/src/modules/steam_special_offers/__init__.py b/kdb-bot/src/modules/special_offers/__init__.py similarity index 100% rename from kdb-bot/src/modules/steam_special_offers/__init__.py rename to kdb-bot/src/modules/special_offers/__init__.py diff --git a/kdb-bot/src/modules/steam_special_offers/base/__init__.py b/kdb-bot/src/modules/special_offers/base/__init__.py similarity index 100% rename from kdb-bot/src/modules/steam_special_offers/base/__init__.py rename to kdb-bot/src/modules/special_offers/base/__init__.py diff --git a/kdb-bot/src/modules/steam_special_offers/base/special_offer_watcher_abc.py b/kdb-bot/src/modules/special_offers/base/special_offer_watcher_abc.py similarity index 100% rename from kdb-bot/src/modules/steam_special_offers/base/special_offer_watcher_abc.py rename to kdb-bot/src/modules/special_offers/base/special_offer_watcher_abc.py diff --git a/kdb-bot/src/modules/steam_special_offers/events/__init__.py b/kdb-bot/src/modules/special_offers/events/__init__.py similarity index 100% rename from kdb-bot/src/modules/steam_special_offers/events/__init__.py rename to kdb-bot/src/modules/special_offers/events/__init__.py diff --git a/kdb-bot/src/modules/steam_special_offers/events/special_offer_on_ready_event.py b/kdb-bot/src/modules/special_offers/events/special_offer_on_ready_event.py similarity index 87% rename from kdb-bot/src/modules/steam_special_offers/events/special_offer_on_ready_event.py rename to kdb-bot/src/modules/special_offers/events/special_offer_on_ready_event.py index db7e7f18..b594cf7b 100644 --- a/kdb-bot/src/modules/steam_special_offers/events/special_offer_on_ready_event.py +++ b/kdb-bot/src/modules/special_offers/events/special_offer_on_ready_event.py @@ -3,7 +3,7 @@ from cpl_discord.events import OnReadyABC from cpl_discord.service import DiscordBotServiceABC from bot_core.logging.task_logger import TaskLogger -from modules.steam_special_offers.base.special_offer_watcher_abc import SpecialOfferWatcherABC +from modules.special_offers.base.special_offer_watcher_abc import SpecialOfferWatcherABC class SpecialOfferOnReadyEvent(OnReadyABC): diff --git a/kdb-bot/src/modules/steam_special_offers/special-offers.json b/kdb-bot/src/modules/special_offers/special-offers.json similarity index 100% rename from kdb-bot/src/modules/steam_special_offers/special-offers.json rename to kdb-bot/src/modules/special_offers/special-offers.json diff --git a/kdb-bot/src/modules/steam_special_offers/special_offers_module.py b/kdb-bot/src/modules/special_offers/special_offers_module.py similarity index 78% rename from kdb-bot/src/modules/steam_special_offers/special_offers_module.py rename to kdb-bot/src/modules/special_offers/special_offers_module.py index 4050442f..72adf21b 100644 --- a/kdb-bot/src/modules/steam_special_offers/special_offers_module.py +++ b/kdb-bot/src/modules/special_offers/special_offers_module.py @@ -6,9 +6,9 @@ from cpl_discord.service.discord_collection_abc import DiscordCollectionABC from bot_core.abc.module_abc import ModuleABC from bot_core.configuration.feature_flags_enum import FeatureFlagsEnum -from modules.steam_special_offers.base.special_offer_watcher_abc import SpecialOfferWatcherABC -from modules.steam_special_offers.events.special_offer_on_ready_event import SpecialOfferOnReadyEvent -from modules.steam_special_offers.steam_offer_watcher import SteamOfferWatcher +from modules.special_offers.base.special_offer_watcher_abc import SpecialOfferWatcherABC +from modules.special_offers.events.special_offer_on_ready_event import SpecialOfferOnReadyEvent +from modules.special_offers.steam_offer_watcher import SteamOfferWatcher class SteamSpecialOffersModule(ModuleABC): diff --git a/kdb-bot/src/modules/special_offers/steam_offer_watcher.py b/kdb-bot/src/modules/special_offers/steam_offer_watcher.py new file mode 100644 index 00000000..36d54e72 --- /dev/null +++ b/kdb-bot/src/modules/special_offers/steam_offer_watcher.py @@ -0,0 +1,210 @@ +from datetime import datetime +from typing import Optional + +import bs4 +import discord +import requests +from cpl_core.configuration import ConfigurationABC +from cpl_core.database.context import DatabaseContextABC +from cpl_discord.service import DiscordBotServiceABC +from cpl_query.extension import List +from cpl_translation import TranslatePipe +from discord.ext import tasks + +from bot_core.configuration.feature_flags_enum import FeatureFlagsEnum +from bot_core.configuration.feature_flags_settings import FeatureFlagsSettings +from bot_core.logging.task_logger import TaskLogger +from bot_core.service.message_service import MessageService +from bot_data.abc.steam_special_offer_repository_abc import SteamSpecialOfferRepositoryABC +from bot_data.model.server_config import ServerConfig +from bot_data.model.steam_special_offer import SteamSpecialOffer +from modules.special_offers.base.special_offer_watcher_abc import SpecialOfferWatcherABC + + +class SteamOfferWatcher(SpecialOfferWatcherABC): + def __init__( + self, + config: ConfigurationABC, + bot: DiscordBotServiceABC, + logger: TaskLogger, + db: DatabaseContextABC, + offers: SteamSpecialOfferRepositoryABC, + message_service: MessageService, + t: TranslatePipe, + ): + SpecialOfferWatcherABC.__init__(self) + + self._config = config + self._logger = logger + self._db = db + self._offers = offers + self._bot = bot + self._message_service = message_service + self._t = t + + self._is_new = False + self._urls = {} + self._image_urls = {} + + def start(self): + self.watch.start() + + @staticmethod + def _get_max_count() -> int: + count = 0 + result = requests.get(f"https://store.steampowered.com/search/results?specials=1") + soup = bs4.BeautifulSoup(result.text, "lxml") + element = soup.find_all("div", {"class": "search_results_count"}) + if len(element) < 1: + return count + + count = int(element[0].contents[0].split(" ")[0].replace(",", "")) + + return count + + def _get_games_from_page(self, start: int, count: int) -> List[SteamSpecialOffer]: + games = List(SteamSpecialOffer) + result = requests.get( + f"https://store.steampowered.com/search/results?query&start={start}&count={count}&force_infinite=1&specials=1" + ) + soup = bs4.BeautifulSoup(result.text, "lxml") + elements = soup.find_all("a", {"class": "search_result_row"}) + if len(elements) < 1: + return games + + for element in elements: + name_element = element.find("span", {"class": "title"}) + original_price_element = element.find("div", {"class": "discount_original_price"}) + discount_element = element.find("div", {"class": "discount_pct"}) + discount_price_element = element.find("div", {"class": "discount_final_price"}) + + if ( + name_element is None + or len(name_element.contents) < 1 + or original_price_element is None + or len(original_price_element.contents) < 1 + or discount_element is None + or len(discount_element.contents) < 1 + or discount_price_element is None + or len(discount_price_element.contents) < 1 + ): + continue + + name = name_element.contents[0].replace("'", "`").replace('"', "`") + original_price = float( + original_price_element.contents[0].replace(" ", "").replace("€", "").replace(",", ".") + ) + discount = int(discount_element.contents[0].replace("%", "")) + discount_price = float( + discount_price_element.contents[0].replace(" ", "").replace("€", "").replace(",", ".") + ) + games.add(SteamSpecialOffer(name, original_price, discount_price, discount)) + self._urls[name] = element.attrs["href"] + self._image_urls[name] = element.find("div", {"class": "search_capsule"}).find("img").attrs["src"] + + return games + + def _get_new_game_offers(self) -> List[SteamSpecialOffer]: + new_offers = List(SteamSpecialOffer) + + sale_count = self._get_max_count() + 100 + sale_count = 300 + self._logger.debug(__name__, f"Get special offers from 0 to {sale_count}") + for i in range(0, sale_count, 100): + new_offers.extend(self._get_games_from_page(i, 100)) + + self._logger.debug(__name__, f"Got {new_offers.count()} offers") + + return new_offers + + def _build_embed_for_offer(self, offer: SteamSpecialOffer) -> discord.Embed: + embed = discord.Embed( + title=offer.name, + url=self._urls[offer.name], + color=int("ef9d0d", 16), + timestamp=datetime.now(), + ) + + embed.add_field( + name=self._t.transform("modules.special_offers.price"), + value=f"~~{offer.original_price}€~~", + inline=True, + ) + embed.add_field( + name=self._t.transform("modules.special_offers.discount"), value=f"{offer.discount_pct}%", inline=True + ) + embed.add_field( + name=self._t.transform("modules.special_offers.discount_price"), + value=f"{offer.discount_price}€", + inline=True, + ) + + embed.set_image(url=self._image_urls[offer.name]) + return embed + + async def _watch(self): + self._is_new = self._offers.get_steam_special_offers().count() == 0 + new_offers = self._get_new_game_offers() + new_offers_names = new_offers.select(lambda x: x.name).to_list() + + old_offers = self._offers.get_steam_special_offers() + old_offers_names = old_offers.select(lambda x: x.name).to_list() + + offers_for_notifications = List(SteamSpecialOffer) + + for offer in old_offers: + offer: SteamSpecialOffer = offer + if offer.name in new_offers_names: + continue + + self._offers.delete_steam_special_offer(offer) + self._db.save_changes() + + for offer in new_offers: + if offer.name in old_offers_names: + self._offers.update_steam_special_offer(offer) + self._db.save_changes() + continue + + self._offers.add_steam_special_offer(offer) + self._db.save_changes() + offers_for_notifications.add(offer) + + self._logger.trace(__name__, "Finished watching") + # if self._is_new: + # return + + self._logger.debug(__name__, f"Sending offer notifications for {offers_for_notifications.count()} offers") + for guild in self._bot.guilds: + settings: ServerConfig = self._config.get_configuration(f"ServerConfig_{guild.id}") + if ( + not FeatureFlagsSettings.get_flag_from_dict( + settings.feature_flags, FeatureFlagsEnum.steam_special_offers + ) + and settings.game_offer_notification_chat_id is None + ): + continue + + embeds = [] + + for offer in offers_for_notifications: + embed = self._build_embed_for_offer(offer) + if embed is None: + continue + embeds.append(embed) + + print(embeds) + # await self._message_service.send_channel_message( + # self._bot.get_channel(settings.game_offer_notification_chat_id), + # embeds, + # is_persistent=True, + # ) + + @tasks.loop(minutes=60) + async def watch(self): + self._logger.info(__name__, "Watching steam special offers") + try: + pass + # await self._watch() + except Exception as e: + self._logger.error(__name__, f"Steam offer watcher failed", e) diff --git a/kdb-bot/src/modules/steam_special_offers/model/__init__.py b/kdb-bot/src/modules/steam_special_offers/model/__init__.py deleted file mode 100644 index 425ab6c1..00000000 --- a/kdb-bot/src/modules/steam_special_offers/model/__init__.py +++ /dev/null @@ -1 +0,0 @@ -# imports diff --git a/kdb-bot/src/modules/steam_special_offers/model/game_offer.py b/kdb-bot/src/modules/steam_special_offers/model/game_offer.py deleted file mode 100644 index df6562fe..00000000 --- a/kdb-bot/src/modules/steam_special_offers/model/game_offer.py +++ /dev/null @@ -1,6 +0,0 @@ -class GameOffer: - def __init__(self, name: str, original_price: float, discount_price: float, discount_pct: int): - self.name = name - self.original_price = original_price - self.discount_price = discount_price - self.discount_pct = discount_pct diff --git a/kdb-bot/src/modules/steam_special_offers/steam_offer_watcher.py b/kdb-bot/src/modules/steam_special_offers/steam_offer_watcher.py deleted file mode 100644 index f3408c37..00000000 --- a/kdb-bot/src/modules/steam_special_offers/steam_offer_watcher.py +++ /dev/null @@ -1,88 +0,0 @@ -import bs4 -import requests -from cpl_query.extension import List -from discord.ext import tasks - -from bot_core.logging.task_logger import TaskLogger -from modules.steam_special_offers.base.special_offer_watcher_abc import SpecialOfferWatcherABC -from modules.steam_special_offers.model.game_offer import GameOffer - - -class SteamOfferWatcher(SpecialOfferWatcherABC): - def __init__(self, logger: TaskLogger): - SpecialOfferWatcherABC.__init__(self) - - self._logger = logger - - def start(self): - self.watch.start() - - def _get_max_count(self) -> int: - count = 0 - result = requests.get(f"https://store.steampowered.com/search/results?specials=1") - soup = bs4.BeautifulSoup(result.text, "lxml") - element = soup.find_all("div", {"class": "search_results_count"}) - if len(element) < 1: - return count - - count = int(element[0].contents[0].split(" ")[0].replace(",", "")) - - return count - - def _get_games_from_page(self, start: int, count: int) -> List[GameOffer]: - games = List(GameOffer) - result = requests.get( - f"https://store.steampowered.com/search/results?query&start={start}&count={count}&force_infinite=1&specials=1" - ) - soup = bs4.BeautifulSoup(result.text, "lxml") - elements = soup.find_all("a", {"class": "search_result_row"}) - if len(elements) < 1: - return games - - for element in elements: - name_element = element.find("span", {"class": "title"}) - original_price_element = element.find("div", {"class": "discount_original_price"}) - discount_element = element.find("div", {"class": "discount_pct"}) - discount_price_element = element.find("div", {"class": "discount_final_price"}) - - if ( - name_element is None - or len(name_element.contents) < 1 - or original_price_element is None - or len(original_price_element.contents) < 1 - or discount_element is None - or len(discount_element.contents) < 1 - or discount_price_element is None - or len(discount_price_element.contents) < 1 - ): - continue - - name = name_element.contents[0] - original_price = float( - original_price_element.contents[0].replace(" ", "").replace("€", "").replace(",", ".") - ) - discount = int(discount_element.contents[0].replace("%", "")) - discount_price = float( - discount_price_element.contents[0].replace(" ", "").replace("€", "").replace(",", ".") - ) - games.add(GameOffer(name, original_price, discount_price, discount)) - - return games - - async def _watch(self): - self._logger.warn(__name__, "Watching") - new_offers = List(GameOffer) - - max = self._get_max_count() - for i in range(0, max + 100, 100): - self._logger.debug(__name__, f"Get special offers from {i}") - new_offers.extend(self._get_games_from_page(i, 100)) - - self._logger.trace(__name__, "Finished watching") - - @tasks.loop(seconds=5) - async def watch(self): - try: - await self._watch() - except Exception as e: - self._logger.error(__name__, f"Steam offer watcher failed", e) diff --git a/kdb-web/package.json b/kdb-web/package.json index 064e549b..8312e902 100644 --- a/kdb-web/package.json +++ b/kdb-web/package.json @@ -52,4 +52,4 @@ "tslib": "^2.4.1", "typescript": "~4.9.5" } -} +} \ No newline at end of file diff --git a/kdb-web/src/app/models/config/server-config.model.ts b/kdb-web/src/app/models/config/server-config.model.ts index a1873b49..e6cd2cdf 100644 --- a/kdb-web/src/app/models/config/server-config.model.ts +++ b/kdb-web/src/app/models/config/server-config.model.ts @@ -18,6 +18,7 @@ export interface ServerConfig extends DataWithHistory { loginMessageChannelId?: string; defaultRoleId?: string; shortRoleNameOnlySetHighestRole?: boolean; + gameOfferNotificationChatId?: string; featureFlags: FeatureFlag[]; afkChannelIds: string[]; moderatorRoleIds: string[]; diff --git a/kdb-web/src/app/models/graphql/mutations.model.ts b/kdb-web/src/app/models/graphql/mutations.model.ts index dda0301c..23340f2e 100644 --- a/kdb-web/src/app/models/graphql/mutations.model.ts +++ b/kdb-web/src/app/models/graphql/mutations.model.ts @@ -261,7 +261,8 @@ export class Mutations { $teamChannelId: String, $loginMessageChannelId: String, $defaultRoleId: String, - $shortRoleNameOnlySetHighestRole: Boolean + $shortRoleNameOnlySetHighestRole: Boolean, + $gameOfferNotificationChatId: String, $featureFlags: [FeatureFlagInput], $afkChannelIds: [String], $moderatorRoleIds: [String], @@ -285,6 +286,7 @@ export class Mutations { loginMessageChannelId: $loginMessageChannelId, defaultRoleId: $defaultRoleId, shortRoleNameOnlySetHighestRole: $shortRoleNameOnlySetHighestRole, + gameOfferNotificationChatId: $gameOfferNotificationChatId, featureFlags: $featureFlags, afkChannelIds: $afkChannelIds, moderatorRoleIds: $moderatorRoleIds, @@ -306,6 +308,7 @@ export class Mutations { loginMessageChannelId defaultRoleId shortRoleNameOnlySetHighestRole + gameOfferNotificationChatId featureFlags { key value diff --git a/kdb-web/src/app/modules/view/server/config/components/config/config.component.html b/kdb-web/src/app/modules/view/server/config/components/config/config.component.html index d21e71f9..114f559f 100644 --- a/kdb-web/src/app/modules/view/server/config/components/config/config.component.html +++ b/kdb-web/src/app/modules/view/server/config/components/config/config.component.html @@ -130,6 +130,14 @@ +
+
+
{{'view.server.config.bot.game_offer_notification_chat_id' | translate}}:
+ +
+
+
diff --git a/kdb-web/src/app/modules/view/server/config/components/config/config.component.ts b/kdb-web/src/app/modules/view/server/config/components/config/config.component.ts index 0a41f365..f295b57e 100644 --- a/kdb-web/src/app/modules/view/server/config/components/config/config.component.ts +++ b/kdb-web/src/app/modules/view/server/config/components/config/config.component.ts @@ -124,6 +124,7 @@ export class ConfigComponent implements OnInit { loginMessageChannelId: this.config.loginMessageChannelId, defaultRoleId: this.config.defaultRoleId, shortRoleNameOnlySetHighestRole: this.config.shortRoleNameOnlySetHighestRole, + gameOfferNotificationChatId: this.config.gameOfferNotificationChatId, featureFlags: this.config.featureFlags, afkChannelIds: this.config.afkChannelIds, moderatorRoleIds: this.config.moderatorRoleIds, diff --git a/kdb-web/src/assets/i18n/de.json b/kdb-web/src/assets/i18n/de.json index 53e6c76a..b1a1d87a 100644 --- a/kdb-web/src/assets/i18n/de.json +++ b/kdb-web/src/assets/i18n/de.json @@ -122,15 +122,13 @@ } }, "common": { - "edit": "Bearbeiten", - "user_warnings": "Verwarnungen", - "author": "Autor", "404": "404 - Der Eintrag konnte nicht gefunden werden", "actions": "Aktionen", "active": "Aktiv", "add": "Hinzufügen", "attribute": "Attribut", "auth_role": "Rolle", + "author": "Autor", "bool_as_string": { "false": "Nein", "true": "Ja" @@ -141,6 +139,7 @@ "created_at": "Erstellt am", "description": "Beschreibung", "discord_id": "Discord Id", + "edit": "Bearbeiten", "email": "E-Mail", "emoji": "Emoji", "error": "Fehler", @@ -195,6 +194,7 @@ "role": "Rolle", "rule_count": "Regeln", "save": "Speichern", + "user_warnings": "Verwarnungen", "users": "Benutzer", "value": "Wert", "xp": "XP" @@ -422,7 +422,7 @@ "afk_channels": "AFK Sprachkanäle", "afk_command_channel_id": "AFK Kanal für den Befehl /afk", "default_role_id": "Standardrolle des Servers", - "short_role_name_only_set_highest_role": "Bei Rollen Kürzeln nur die höchste Rolle verwenden", + "game_offer_notification_chat_id": "Benachrichtungskanal für Spiel Angebote", "header": "Bot Konfiguration", "help_voice_channel_id": "Sprachkanal für Hilfsbenachrichtung", "login_message_channel_id": "Kanal für die Nachricht vom Bot nach Start", @@ -431,6 +431,7 @@ "message_delete_timer": "Zeit bis zum löschen einer Botnachricht in sekunden", "moderator_roles": "Moderator Rollen", "notification_chat_id": "Benachrichtungskanal", + "short_role_name_only_set_highest_role": "Bei Rollen Kürzeln nur die höchste Rolle verwenden", "team_channel_id": "Team chat", "xp_per_achievement": "XP für Errungenschaft", "xp_per_event_participation": "XP für Event Teilnahme", @@ -485,13 +486,11 @@ } }, "profile": { - "message_count": "Anzahl Nachrichten", - "reaction_count": "Anzahl Reaktionen", - "birthday": "Geburtstag", "achievements": { "header": "Errungeschaften", "time": "Erreicht am" }, + "birthday": "Geburtstag", "header": "Dein Profil", "joined_game_server": { "header": "Gameserver-beitritte", @@ -509,11 +508,13 @@ }, "left_server": "Hat Server verlassen", "level": "Level", + "message_count": "Anzahl Nachrichten", "minecraft_id": "Minecraft Id", "name": "Name", "ontime": "Ontime", "permission_denied": "Zugriff verweigert!", "permission_denied_d": "Du musst Moderator sein, um andere Profile sehen zu können!", + "reaction_count": "Anzahl Reaktionen", "xp": "XP" }, "short_role_names": { diff --git a/kdb-web/src/assets/i18n/en.json b/kdb-web/src/assets/i18n/en.json index ca81d078..5acc6c23 100644 --- a/kdb-web/src/assets/i18n/en.json +++ b/kdb-web/src/assets/i18n/en.json @@ -128,6 +128,7 @@ "add": "Add", "attribute": "Attribute", "auth_role": "Role", + "author": "Author", "bool_as_string": { "false": "No", "true": "Yes" @@ -138,6 +139,7 @@ "created_at": "Created at", "description": "Description", "discord_id": "Discord Id", + "edit": "Edit", "email": "E-Mail", "emoji": "Emoji", "error": "Error", @@ -192,6 +194,7 @@ "role": "Role", "rule_count": "Rules", "save": "Save", + "user_warnings": "User warnings", "users": "User", "value": "Value", "xp": "XP" @@ -419,7 +422,7 @@ "afk_channels": "AFK Voicechannel", "afk_command_channel_id": "AFK Channel for the command /afk", "default_role_id": "Default role", - "short_role_name_only_set_highest_role": "For role abbreviations use only the highest role", + "game_offer_notification_chat_id": "Notification channel for game sales", "header": "Bot configuration", "help_voice_channel_id": "Voicechannel für help notifications", "login_message_channel_id": "Channel for bot message after start", @@ -428,6 +431,7 @@ "message_delete_timer": "Time to wait before delete bot messages", "moderator_roles": "Moderator roles", "notification_chat_id": "Notification channel", + "short_role_name_only_set_highest_role": "For role abbreviations use only the highest role", "team_channel_id": "Team chat", "xp_per_achievement": "XP for achievement", "xp_per_event_participation": "XP for event participation", @@ -486,6 +490,7 @@ "header": "Achievements", "time": "Reached at" }, + "birthday": "Birthday", "header": "Profile", "joined_game_server": { "header": "Game server accessions", @@ -503,11 +508,13 @@ }, "left_server": "Leaved server", "level": "Level", + "message_count": "Message count", "minecraft_id": "Minecraft Id", "name": "Name", "ontime": "Ontime", "permission_denied": "Access denied!", "permission_denied_d": "You have to be moderator to see other profiles!", + "reaction_count": "Reaction count", "xp": "XP" }, "short_role_names": { -- 2.45.2 From dcafa63d746aa4aabe6fe70aebfb51084c9783b9 Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Wed, 11 Oct 2023 21:22:10 +0200 Subject: [PATCH 07/58] Improved steam offer #188 --- kdb-bot/src/bot/application.py | 6 ++ .../abc/task_abc.py} | 2 +- .../modules/special_offers/base/__init__.py | 1 - .../modules/special_offers/events/__init__.py | 1 - .../events/special_offer_on_ready_event.py | 25 ------ .../special_offers/special_offers_module.py | 7 +- .../special_offers/steam_offer_watcher.py | 87 ++++++++++--------- 7 files changed, 57 insertions(+), 72 deletions(-) rename kdb-bot/src/{modules/special_offers/base/special_offer_watcher_abc.py => bot_core/abc/task_abc.py} (82%) delete mode 100644 kdb-bot/src/modules/special_offers/base/__init__.py delete mode 100644 kdb-bot/src/modules/special_offers/events/__init__.py delete mode 100644 kdb-bot/src/modules/special_offers/events/special_offer_on_ready_event.py diff --git a/kdb-bot/src/bot/application.py b/kdb-bot/src/bot/application.py index 13d46815..257d57ff 100644 --- a/kdb-bot/src/bot/application.py +++ b/kdb-bot/src/bot/application.py @@ -8,6 +8,7 @@ from cpl_discord.service import DiscordBotServiceABC, DiscordBotService from cpl_translation import TranslatePipe, TranslationServiceABC, TranslationSettings from bot_api.api_thread import ApiThread +from bot_core.abc.task_abc import TaskABC from bot_core.configuration.feature_flags_enum import FeatureFlagsEnum from bot_core.configuration.feature_flags_settings import FeatureFlagsSettings from bot_core.service.data_integrity_service import DataIntegrityService @@ -29,6 +30,8 @@ class Application(DiscordBotApplicationABC): # cpl-translation self._translation: TranslationServiceABC = services.get_service(TranslationServiceABC) self._t: TranslatePipe = services.get_service(TranslatePipe) + # internal stuff + self._tasks = services.get_services(list[TaskABC]) self._feature_flags: FeatureFlagsSettings = config.get_configuration(FeatureFlagsSettings) @@ -55,6 +58,9 @@ class Application(DiscordBotApplicationABC): return self._logger.info(__name__, f"Try to start {DiscordBotService.__name__}") + for task in self._tasks: + await self._bot.add_cog(task) + await self._bot.start_async() await self._bot.stop_async() except Exception as e: diff --git a/kdb-bot/src/modules/special_offers/base/special_offer_watcher_abc.py b/kdb-bot/src/bot_core/abc/task_abc.py similarity index 82% rename from kdb-bot/src/modules/special_offers/base/special_offer_watcher_abc.py rename to kdb-bot/src/bot_core/abc/task_abc.py index fd4fe99d..093f0893 100644 --- a/kdb-bot/src/modules/special_offers/base/special_offer_watcher_abc.py +++ b/kdb-bot/src/bot_core/abc/task_abc.py @@ -3,7 +3,7 @@ from abc import ABC, abstractmethod from discord.ext import commands -class SpecialOfferWatcherABC(commands.Cog): +class TaskABC(commands.Cog): @abstractmethod def __init__(self): commands.Cog.__init__(self) diff --git a/kdb-bot/src/modules/special_offers/base/__init__.py b/kdb-bot/src/modules/special_offers/base/__init__.py deleted file mode 100644 index 425ab6c1..00000000 --- a/kdb-bot/src/modules/special_offers/base/__init__.py +++ /dev/null @@ -1 +0,0 @@ -# imports diff --git a/kdb-bot/src/modules/special_offers/events/__init__.py b/kdb-bot/src/modules/special_offers/events/__init__.py deleted file mode 100644 index 425ab6c1..00000000 --- a/kdb-bot/src/modules/special_offers/events/__init__.py +++ /dev/null @@ -1 +0,0 @@ -# imports diff --git a/kdb-bot/src/modules/special_offers/events/special_offer_on_ready_event.py b/kdb-bot/src/modules/special_offers/events/special_offer_on_ready_event.py deleted file mode 100644 index b594cf7b..00000000 --- a/kdb-bot/src/modules/special_offers/events/special_offer_on_ready_event.py +++ /dev/null @@ -1,25 +0,0 @@ -from cpl_core.logging import LoggerABC -from cpl_discord.events import OnReadyABC -from cpl_discord.service import DiscordBotServiceABC - -from bot_core.logging.task_logger import TaskLogger -from modules.special_offers.base.special_offer_watcher_abc import SpecialOfferWatcherABC - - -class SpecialOfferOnReadyEvent(OnReadyABC): - def __init__( - self, - logger: TaskLogger, - bot: DiscordBotServiceABC, - watchers: list[SpecialOfferWatcherABC], - ): - OnReadyABC.__init__(self) - - self._logger = logger - self._bot = bot - self._watchers = watchers - - async def on_ready(self): - for watcher in self._watchers: - self._logger.info(__name__, f"Starting watcher {type(watcher).__name__}") - watcher.start() diff --git a/kdb-bot/src/modules/special_offers/special_offers_module.py b/kdb-bot/src/modules/special_offers/special_offers_module.py index 72adf21b..e64108b5 100644 --- a/kdb-bot/src/modules/special_offers/special_offers_module.py +++ b/kdb-bot/src/modules/special_offers/special_offers_module.py @@ -1,13 +1,11 @@ from cpl_core.configuration import ConfigurationABC from cpl_core.dependency_injection import ServiceCollectionABC from cpl_core.environment import ApplicationEnvironmentABC -from cpl_discord.discord_event_types_enum import DiscordEventTypesEnum from cpl_discord.service.discord_collection_abc import DiscordCollectionABC from bot_core.abc.module_abc import ModuleABC +from bot_core.abc.task_abc import TaskABC from bot_core.configuration.feature_flags_enum import FeatureFlagsEnum -from modules.special_offers.base.special_offer_watcher_abc import SpecialOfferWatcherABC -from modules.special_offers.events.special_offer_on_ready_event import SpecialOfferOnReadyEvent from modules.special_offers.steam_offer_watcher import SteamOfferWatcher @@ -19,7 +17,6 @@ class SteamSpecialOffersModule(ModuleABC): pass def configure_services(self, services: ServiceCollectionABC, env: ApplicationEnvironmentABC): - services.add_singleton(SpecialOfferWatcherABC, SteamOfferWatcher) + services.add_singleton(TaskABC, SteamOfferWatcher) # commands # events - self._dc.add_event(DiscordEventTypesEnum.on_ready.value, SpecialOfferOnReadyEvent) diff --git a/kdb-bot/src/modules/special_offers/steam_offer_watcher.py b/kdb-bot/src/modules/special_offers/steam_offer_watcher.py index 36d54e72..7830d43e 100644 --- a/kdb-bot/src/modules/special_offers/steam_offer_watcher.py +++ b/kdb-bot/src/modules/special_offers/steam_offer_watcher.py @@ -1,5 +1,5 @@ +import asyncio from datetime import datetime -from typing import Optional import bs4 import discord @@ -11,6 +11,7 @@ from cpl_query.extension import List from cpl_translation import TranslatePipe from discord.ext import tasks +from bot_core.abc.task_abc import TaskABC from bot_core.configuration.feature_flags_enum import FeatureFlagsEnum from bot_core.configuration.feature_flags_settings import FeatureFlagsSettings from bot_core.logging.task_logger import TaskLogger @@ -18,10 +19,9 @@ from bot_core.service.message_service import MessageService from bot_data.abc.steam_special_offer_repository_abc import SteamSpecialOfferRepositoryABC from bot_data.model.server_config import ServerConfig from bot_data.model.steam_special_offer import SteamSpecialOffer -from modules.special_offers.base.special_offer_watcher_abc import SpecialOfferWatcherABC -class SteamOfferWatcher(SpecialOfferWatcherABC): +class SteamOfferWatcher(TaskABC): def __init__( self, config: ConfigurationABC, @@ -32,7 +32,7 @@ class SteamOfferWatcher(SpecialOfferWatcherABC): message_service: MessageService, t: TranslatePipe, ): - SpecialOfferWatcherABC.__init__(self) + TaskABC.__init__(self) self._config = config self._logger = logger @@ -46,6 +46,8 @@ class SteamOfferWatcher(SpecialOfferWatcherABC): self._urls = {} self._image_urls = {} + self.watch.start() + def start(self): self.watch.start() @@ -107,8 +109,8 @@ class SteamOfferWatcher(SpecialOfferWatcherABC): def _get_new_game_offers(self) -> List[SteamSpecialOffer]: new_offers = List(SteamSpecialOffer) - sale_count = self._get_max_count() + 100 - sale_count = 300 + # sale_count = self._get_max_count() + 100 + sale_count = 1500 # only look at first 1500 self._logger.debug(__name__, f"Get special offers from 0 to {sale_count}") for i in range(0, sale_count, 100): new_offers.extend(self._get_games_from_page(i, 100)) @@ -117,7 +119,7 @@ class SteamOfferWatcher(SpecialOfferWatcherABC): return new_offers - def _build_embed_for_offer(self, offer: SteamSpecialOffer) -> discord.Embed: + async def _send_embed_for_offer(self, offer: SteamSpecialOffer, channel_id: int) -> discord.Embed: embed = discord.Embed( title=offer.name, url=self._urls[offer.name], @@ -140,9 +142,14 @@ class SteamOfferWatcher(SpecialOfferWatcherABC): ) embed.set_image(url=self._image_urls[offer.name]) - return embed - async def _watch(self): + await self._message_service.send_channel_message( + self._bot.get_channel(channel_id), + embed, + is_persistent=True, + ) + + def _watch(self) -> List[SteamSpecialOffer]: self._is_new = self._offers.get_steam_special_offers().count() == 0 new_offers = self._get_new_game_offers() new_offers_names = new_offers.select(lambda x: x.name).to_list() @@ -171,40 +178,42 @@ class SteamOfferWatcher(SpecialOfferWatcherABC): offers_for_notifications.add(offer) self._logger.trace(__name__, "Finished watching") - # if self._is_new: - # return - - self._logger.debug(__name__, f"Sending offer notifications for {offers_for_notifications.count()} offers") - for guild in self._bot.guilds: - settings: ServerConfig = self._config.get_configuration(f"ServerConfig_{guild.id}") - if ( - not FeatureFlagsSettings.get_flag_from_dict( - settings.feature_flags, FeatureFlagsEnum.steam_special_offers - ) - and settings.game_offer_notification_chat_id is None - ): - continue - - embeds = [] - - for offer in offers_for_notifications: - embed = self._build_embed_for_offer(offer) - if embed is None: - continue - embeds.append(embed) - - print(embeds) - # await self._message_service.send_channel_message( - # self._bot.get_channel(settings.game_offer_notification_chat_id), - # embeds, - # is_persistent=True, - # ) + return offers_for_notifications @tasks.loop(minutes=60) async def watch(self): self._logger.info(__name__, "Watching steam special offers") try: - pass - # await self._watch() + offers_for_notifications = self._watch() + self._logger.debug(__name__, f"Sending offer notifications for {offers_for_notifications.count()} offers") + if self._is_new: + return + for guild in self._bot.guilds: + settings: ServerConfig = self._config.get_configuration(f"ServerConfig_{guild.id}") + if ( + not FeatureFlagsSettings.get_flag_from_dict( + settings.feature_flags, FeatureFlagsEnum.steam_special_offers + ) + or settings.game_offer_notification_chat_id is None + ): + continue + + for offer in offers_for_notifications: + self._bot.loop.create_task( + self._send_embed_for_offer(offer, settings.game_offer_notification_chat_id) + ) except Exception as e: self._logger.error(__name__, f"Steam offer watcher failed", e) + + @watch.before_loop + async def before_printer(self): + self._logger.debug(__name__, f"Waiting before checking steam special offers") + await self._bot.wait_until_ready() + + async def wait(): + is_ready = self._config.get_configuration("IS_READY") + if is_ready != "true": + await asyncio.sleep(1) + await wait() + + await wait() -- 2.45.2 From bd1d230f671c77a6afdd91fff818aac04a0fec36 Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Wed, 11 Oct 2023 21:56:49 +0200 Subject: [PATCH 08/58] Added birthday watcher #401 --- kdb-bot/src/bot/translation/de.json | 1 + kdb-bot/src/bot_core/abc/task_abc.py | 23 +++++-- .../service/user_repository_service.py | 3 +- .../mutations/server_config_mutation.py | 3 + kdb-bot/src/modules/base/base_module.py | 3 + kdb-bot/src/modules/base/birthday_watcher.py | 67 +++++++++++++++++++ .../special_offers/steam_offer_watcher.py | 24 ++----- .../app/models/config/server-config.model.ts | 1 + .../src/app/models/graphql/mutations.model.ts | 3 + .../src/app/models/graphql/queries.model.ts | 1 + .../components/config/config.component.html | 8 +++ .../components/config/config.component.ts | 1 + kdb-web/src/assets/i18n/de.json | 1 + kdb-web/src/assets/i18n/en.json | 1 + 14 files changed, 117 insertions(+), 23 deletions(-) create mode 100644 kdb-bot/src/modules/base/birthday_watcher.py diff --git a/kdb-bot/src/bot/translation/de.json b/kdb-bot/src/bot/translation/de.json index 5f394911..9f0a57fa 100644 --- a/kdb-bot/src/bot/translation/de.json +++ b/kdb-bot/src/bot/translation/de.json @@ -235,6 +235,7 @@ }, "user": { "birthday": { + "has_birthday": "Alles Gute zum Geburtag {} :D", "success": "Dein Geburtstag wurde eingetragen.", "success_team": "{} hat seinen Geburtstag eingetragen: {}" }, diff --git a/kdb-bot/src/bot_core/abc/task_abc.py b/kdb-bot/src/bot_core/abc/task_abc.py index 093f0893..990b95b0 100644 --- a/kdb-bot/src/bot_core/abc/task_abc.py +++ b/kdb-bot/src/bot_core/abc/task_abc.py @@ -1,13 +1,28 @@ -from abc import ABC, abstractmethod +import asyncio +from abc import abstractmethod +from cpl_core.configuration import ConfigurationABC +from cpl_core.dependency_injection import ServiceProviderABC +from cpl_discord.service import DiscordBotServiceABC from discord.ext import commands +from bot_core.logging.task_logger import TaskLogger + class TaskABC(commands.Cog): @abstractmethod def __init__(self): commands.Cog.__init__(self) - @abstractmethod - def start(self): - pass + @ServiceProviderABC.inject + async def _wait_until_ready(self, config: ConfigurationABC, logger: TaskLogger, bot: DiscordBotServiceABC): + logger.debug(__name__, f"Waiting before checking steam special offers") + await bot.wait_until_ready() + + async def wait(): + is_ready = config.get_configuration("IS_READY") + if is_ready != "true": + await asyncio.sleep(1) + await wait() + + await wait() diff --git a/kdb-bot/src/bot_data/service/user_repository_service.py b/kdb-bot/src/bot_data/service/user_repository_service.py index 1238fa1b..940156a8 100644 --- a/kdb-bot/src/bot_data/service/user_repository_service.py +++ b/kdb-bot/src/bot_data/service/user_repository_service.py @@ -1,3 +1,4 @@ +import datetime from typing import Optional from cpl_core.database.context import DatabaseContextABC @@ -29,7 +30,7 @@ class UserRepositoryService(UserRepositoryABC): result[2], result[3], result[4], - result[5].strftime("%d.%m.%Y") if result[5] is not None else None, + result[5], self._servers.get_server_by_id(result[6]), result[7], result[8], diff --git a/kdb-bot/src/bot_graphql/mutations/server_config_mutation.py b/kdb-bot/src/bot_graphql/mutations/server_config_mutation.py index 94a04b4f..1f179d4a 100644 --- a/kdb-bot/src/bot_graphql/mutations/server_config_mutation.py +++ b/kdb-bot/src/bot_graphql/mutations/server_config_mutation.py @@ -72,6 +72,9 @@ class ServerConfigMutation(QueryABC): server_config.xp_per_achievement = ( input["xpPerAchievement"] if "xpPerAchievement" in input else server_config.xp_per_achievement ) + server_config.xp_for_birthday = ( + input["xpForBirthday"] if "xpForBirthday" in input else server_config.xp_for_birthday + ) server_config.afk_command_channel_id = ( input["afkCommandChannelId"] if "afkCommandChannelId" in input else server_config.afk_command_channel_id ) diff --git a/kdb-bot/src/modules/base/base_module.py b/kdb-bot/src/modules/base/base_module.py index 626ea4ef..949fa4ad 100644 --- a/kdb-bot/src/modules/base/base_module.py +++ b/kdb-bot/src/modules/base/base_module.py @@ -5,7 +5,9 @@ from cpl_discord.discord_event_types_enum import DiscordEventTypesEnum from cpl_discord.service.discord_collection_abc import DiscordCollectionABC from bot_core.abc.module_abc import ModuleABC +from bot_core.abc.task_abc import TaskABC from bot_core.configuration.feature_flags_enum import FeatureFlagsEnum +from modules.base.birthday_watcher import BirthdayWatcher from modules.base.command.afk_command import AFKCommand from modules.base.command.game_server_group import GameServerGroup from modules.base.command.help_command import HelpCommand @@ -56,6 +58,7 @@ class BaseModule(ModuleABC): services.add_transient(BaseReactionHandler) services.add_singleton(EventService) services.add_transient(UserWarningsService) + services.add_singleton(TaskABC, BirthdayWatcher) # forms services.add_transient(BugReportForm) diff --git a/kdb-bot/src/modules/base/birthday_watcher.py b/kdb-bot/src/modules/base/birthday_watcher.py new file mode 100644 index 00000000..7b19638a --- /dev/null +++ b/kdb-bot/src/modules/base/birthday_watcher.py @@ -0,0 +1,67 @@ +import datetime + +from cpl_core.configuration import ConfigurationABC +from cpl_core.database.context import DatabaseContextABC +from cpl_discord.service import DiscordBotServiceABC +from cpl_translation import TranslatePipe +from discord.ext import tasks + +from bot_core.abc.task_abc import TaskABC +from bot_core.logging.task_logger import TaskLogger +from bot_core.service.message_service import MessageService +from bot_data.abc.user_repository_abc import UserRepositoryABC +from bot_data.model.server_config import ServerConfig + + +class BirthdayWatcher(TaskABC): + def __init__( + self, + config: ConfigurationABC, + logger: TaskLogger, + bot: DiscordBotServiceABC, + db: DatabaseContextABC, + users: UserRepositoryABC, + message_service: MessageService, + t: TranslatePipe, + ): + TaskABC.__init__(self) + + self._config = config + self._logger = logger + self._bot = bot + self._db = db + self._users = users + self._message_service = message_service + self._t = t + + self.watch.start() + + @tasks.loop(time=datetime.time(hour=8, minute=0)) + async def watch(self): + self._logger.info(__name__, "Watching birthdays") + try: + today = datetime.date.today() + users = self._users.get_users().where(lambda x: x.birthday is not None) + for user in users: + if user.birthday.day != today.day or user.birthday.month != today.month: + continue + + settings: ServerConfig = self._config.get_configuration(f"ServerConfig_{user.server.discord_id}") + + user.xp += settings.xp_for_birthday + self._users.update_user(user) + self._db.save_changes() + + guild = self._bot.get_guild(user.server.discord_id) + member = guild.get_member(user.discord_id) + await self._message_service.send_channel_message( + self._bot.get_channel(settings.notification_chat_id), + self._t.transform("modules.base.user.birthday.has_birthday").format(member.mention), + is_persistent=True, + ) + except Exception as e: + self._logger.error(__name__, f"Watching birthdays failed", e) + + @watch.before_loop + async def wait(self): + await self._wait_until_ready() diff --git a/kdb-bot/src/modules/special_offers/steam_offer_watcher.py b/kdb-bot/src/modules/special_offers/steam_offer_watcher.py index 7830d43e..0aedda1d 100644 --- a/kdb-bot/src/modules/special_offers/steam_offer_watcher.py +++ b/kdb-bot/src/modules/special_offers/steam_offer_watcher.py @@ -1,5 +1,5 @@ import asyncio -from datetime import datetime +import datetime import bs4 import discord @@ -48,9 +48,6 @@ class SteamOfferWatcher(TaskABC): self.watch.start() - def start(self): - self.watch.start() - @staticmethod def _get_max_count() -> int: count = 0 @@ -110,7 +107,7 @@ class SteamOfferWatcher(TaskABC): new_offers = List(SteamSpecialOffer) # sale_count = self._get_max_count() + 100 - sale_count = 1500 # only look at first 1500 + sale_count = 500 # only look at first 500 self._logger.debug(__name__, f"Get special offers from 0 to {sale_count}") for i in range(0, sale_count, 100): new_offers.extend(self._get_games_from_page(i, 100)) @@ -124,7 +121,7 @@ class SteamOfferWatcher(TaskABC): title=offer.name, url=self._urls[offer.name], color=int("ef9d0d", 16), - timestamp=datetime.now(), + timestamp=datetime.datetime.now(), ) embed.add_field( @@ -180,7 +177,7 @@ class SteamOfferWatcher(TaskABC): self._logger.trace(__name__, "Finished watching") return offers_for_notifications - @tasks.loop(minutes=60) + @tasks.loop(time=datetime.time(hour=16, minute=30)) async def watch(self): self._logger.info(__name__, "Watching steam special offers") try: @@ -206,14 +203,5 @@ class SteamOfferWatcher(TaskABC): self._logger.error(__name__, f"Steam offer watcher failed", e) @watch.before_loop - async def before_printer(self): - self._logger.debug(__name__, f"Waiting before checking steam special offers") - await self._bot.wait_until_ready() - - async def wait(): - is_ready = self._config.get_configuration("IS_READY") - if is_ready != "true": - await asyncio.sleep(1) - await wait() - - await wait() + async def wait(self): + await self._wait_until_ready() diff --git a/kdb-web/src/app/models/config/server-config.model.ts b/kdb-web/src/app/models/config/server-config.model.ts index e6cd2cdf..616dbecc 100644 --- a/kdb-web/src/app/models/config/server-config.model.ts +++ b/kdb-web/src/app/models/config/server-config.model.ts @@ -12,6 +12,7 @@ export interface ServerConfig extends DataWithHistory { xpPerOntimeHour?: number; xpPerEventParticipation?: number; xpPerAchievement?: number; + xpForBirthday?: number; afkCommandChannelId?: string; helpVoiceChannelId?: string; teamChannelId?: string; diff --git a/kdb-web/src/app/models/graphql/mutations.model.ts b/kdb-web/src/app/models/graphql/mutations.model.ts index 23340f2e..853d4178 100644 --- a/kdb-web/src/app/models/graphql/mutations.model.ts +++ b/kdb-web/src/app/models/graphql/mutations.model.ts @@ -256,6 +256,7 @@ export class Mutations { $xpPerOntimeHour: Int, $xpPerEventParticipation: Int, $xpPerAchievement: Int, + $xpForBirthday: Int, $afkCommandChannelId: String, $helpVoiceChannelId: String, $teamChannelId: String, @@ -280,6 +281,7 @@ export class Mutations { xpPerOntimeHour: $xpPerOntimeHour, xpPerEventParticipation: $xpPerEventParticipation, xpPerAchievement: $xpPerAchievement, + xpForBirthday: $xpForBirthday, afkCommandChannelId: $afkCommandChannelId, helpVoiceChannelId: $helpVoiceChannelId, teamChannelId: $teamChannelId, @@ -302,6 +304,7 @@ export class Mutations { xpPerOntimeHour xpPerEventParticipation xpPerAchievement + xpForBirthday afkCommandChannelId helpVoiceChannelId teamChannelId diff --git a/kdb-web/src/app/models/graphql/queries.model.ts b/kdb-web/src/app/models/graphql/queries.model.ts index dbf49e10..bbc6a408 100644 --- a/kdb-web/src/app/models/graphql/queries.model.ts +++ b/kdb-web/src/app/models/graphql/queries.model.ts @@ -525,6 +525,7 @@ export class Queries { xpPerOntimeHour xpPerEventParticipation xpPerAchievement + xpForBirthday afkCommandChannelId helpVoiceChannelId teamChannelId diff --git a/kdb-web/src/app/modules/view/server/config/components/config/config.component.html b/kdb-web/src/app/modules/view/server/config/components/config/config.component.html index 114f559f..8bc387f3 100644 --- a/kdb-web/src/app/modules/view/server/config/components/config/config.component.html +++ b/kdb-web/src/app/modules/view/server/config/components/config/config.component.html @@ -82,6 +82,14 @@ +
+
+
{{'view.server.config.bot.xp_for_birthday' | translate}}:
+
+
+
+
{{'view.server.config.bot.afk_command_channel_id' | translate}}:
diff --git a/kdb-web/src/app/modules/view/server/config/components/config/config.component.ts b/kdb-web/src/app/modules/view/server/config/components/config/config.component.ts index f295b57e..0c39cd02 100644 --- a/kdb-web/src/app/modules/view/server/config/components/config/config.component.ts +++ b/kdb-web/src/app/modules/view/server/config/components/config/config.component.ts @@ -118,6 +118,7 @@ export class ConfigComponent implements OnInit { xpPerOntimeHour: this.config.xpPerOntimeHour, xpPerEventParticipation: this.config.xpPerEventParticipation, xpPerAchievement: this.config.xpPerAchievement, + xpForBirthday: this.config.xpForBirthday, afkCommandChannelId: this.config.afkCommandChannelId, helpVoiceChannelId: this.config.helpVoiceChannelId, teamChannelId: this.config.teamChannelId, diff --git a/kdb-web/src/assets/i18n/de.json b/kdb-web/src/assets/i18n/de.json index b1a1d87a..ade9226c 100644 --- a/kdb-web/src/assets/i18n/de.json +++ b/kdb-web/src/assets/i18n/de.json @@ -433,6 +433,7 @@ "notification_chat_id": "Benachrichtungskanal", "short_role_name_only_set_highest_role": "Bei Rollen Kürzeln nur die höchste Rolle verwenden", "team_channel_id": "Team chat", + "xp_for_birthday": "XP für Geburtstag", "xp_per_achievement": "XP für Errungenschaft", "xp_per_event_participation": "XP für Event Teilnahme", "xp_per_message": "XP für eine Nachricht", diff --git a/kdb-web/src/assets/i18n/en.json b/kdb-web/src/assets/i18n/en.json index 5acc6c23..36d7f324 100644 --- a/kdb-web/src/assets/i18n/en.json +++ b/kdb-web/src/assets/i18n/en.json @@ -433,6 +433,7 @@ "notification_chat_id": "Notification channel", "short_role_name_only_set_highest_role": "For role abbreviations use only the highest role", "team_channel_id": "Team chat", + "xp_for_birthday": "XP for birthday", "xp_per_achievement": "XP for achievement", "xp_per_event_participation": "XP for event participation", "xp_per_message": "XP for message", -- 2.45.2 From 030fedfcfbbcaff23d037a91138a347a2d2e42cd Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Fri, 13 Oct 2023 15:07:33 +0200 Subject: [PATCH 09/58] Updated deps #404 --- kdb-bot/src/bot/bot.json | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/kdb-bot/src/bot/bot.json b/kdb-bot/src/bot/bot.json index 54db031a..a61ca0a2 100644 --- a/kdb-bot/src/bot/bot.json +++ b/kdb-bot/src/bot/bot.json @@ -16,22 +16,22 @@ "LicenseName": "MIT", "LicenseDescription": "MIT, see LICENSE for more details.", "Dependencies": [ - "cpl-core==2023.4.0.post5", + "cpl-core==2023.10.0", "cpl-translation==2023.4.0.post1", - "cpl-query==2023.4.0.post1", - "cpl-discord==2023.4.0.post3", - "Flask==2.3.2", - "Flask-Classful==0.14.2", + "cpl-query==2023.10.0", + "cpl-discord==2023.10.0", + "Flask==3.0.0", + "Flask-Classful==0.16.0", "Flask-Cors==4.0.0", "PyJWT==2.8.0", "waitress==2.1.2", - "Flask-SocketIO==5.3.4", + "Flask-SocketIO==5.3.6", "eventlet==0.33.3", "requests-oauthlib==1.3.1", - "icmplib==3.0.3", + "icmplib==3.0.4", "ariadne==0.20.1", - "cryptography==41.0.2", - "discord>=2.3.2" + "cryptography==41.0.4", + "discord==2.3.2" ], "DevDependencies": [ "cpl-cli==2023.4.0.post3", -- 2.45.2 From f710f6ad6c664216daa35a8c1d0e41a1560ac61c Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Fri, 13 Oct 2023 15:08:11 +0200 Subject: [PATCH 10/58] Build new version #404 --- kdb-bot/src/bot/__init__.py | 4 +-- kdb-bot/src/bot/bot.json | 4 +-- kdb-bot/src/bot/extension/__init__.py | 4 +-- kdb-bot/src/bot_api/__init__.py | 4 +-- kdb-bot/src/bot_api/abc/__init__.py | 4 +-- kdb-bot/src/bot_api/bot-api.json | 4 +-- kdb-bot/src/bot_api/configuration/__init__.py | 4 +-- kdb-bot/src/bot_api/controller/__init__.py | 4 +-- kdb-bot/src/bot_api/event/__init__.py | 4 +-- kdb-bot/src/bot_api/exception/__init__.py | 4 +-- kdb-bot/src/bot_api/filter/__init__.py | 4 +-- .../src/bot_api/filter/discord/__init__.py | 4 +-- kdb-bot/src/bot_api/logging/__init__.py | 4 +-- kdb-bot/src/bot_api/model/__init__.py | 4 +-- kdb-bot/src/bot_api/model/discord/__init__.py | 4 +-- kdb-bot/src/bot_api/route/__init__.py | 4 +-- kdb-bot/src/bot_api/service/__init__.py | 4 +-- kdb-bot/src/bot_api/transformer/__init__.py | 4 +-- kdb-bot/src/bot_core/__init__.py | 4 +-- kdb-bot/src/bot_core/abc/__init__.py | 4 +-- kdb-bot/src/bot_core/bot-core.json | 4 +-- .../src/bot_core/configuration/__init__.py | 4 +-- .../src/bot_core/core_extension/__init__.py | 4 +-- kdb-bot/src/bot_core/events/__init__.py | 4 +-- kdb-bot/src/bot_core/exception/__init__.py | 4 +-- kdb-bot/src/bot_core/helper/__init__.py | 4 +-- kdb-bot/src/bot_core/logging/__init__.py | 4 +-- kdb-bot/src/bot_core/pipes/__init__.py | 4 +-- kdb-bot/src/bot_core/service/__init__.py | 4 +-- kdb-bot/src/bot_data/__init__.py | 4 +-- kdb-bot/src/bot_data/abc/__init__.py | 4 +-- kdb-bot/src/bot_data/bot-data.json | 4 +-- kdb-bot/src/bot_data/migration/__init__.py | 4 +-- kdb-bot/src/bot_data/model/__init__.py | 4 +-- kdb-bot/src/bot_data/service/__init__.py | 4 +-- kdb-bot/src/bot_graphql/__init__.py | 4 +-- kdb-bot/src/bot_graphql/abc/__init__.py | 4 +-- kdb-bot/src/bot_graphql/bot-graphql.json | 4 +-- kdb-bot/src/bot_graphql/filter/__init__.py | 4 +-- kdb-bot/src/bot_graphql/model/__init__.py | 4 +-- kdb-bot/src/bot_graphql/mutations/__init__.py | 4 +-- kdb-bot/src/bot_graphql/queries/__init__.py | 4 +-- .../bot_graphql/queries/discord/__init__.py | 4 +-- kdb-bot/src/modules/achievements/__init__.py | 4 +-- .../modules/achievements/achievements.json | 8 +++--- .../modules/achievements/commands/__init__.py | 4 +-- .../modules/achievements/events/__init__.py | 4 +-- .../modules/achievements/model/__init__.py | 4 +-- kdb-bot/src/modules/auto_role/__init__.py | 4 +-- kdb-bot/src/modules/auto_role/auto-role.json | 4 +-- .../src/modules/auto_role/command/__init__.py | 4 +-- .../src/modules/auto_role/events/__init__.py | 4 +-- .../src/modules/auto_role/helper/__init__.py | 4 +-- kdb-bot/src/modules/base/__init__.py | 4 +-- kdb-bot/src/modules/base/base.json | 4 +-- kdb-bot/src/modules/base/command/__init__.py | 4 +-- kdb-bot/src/modules/base/events/__init__.py | 4 +-- kdb-bot/src/modules/base/forms/__init__.py | 4 +-- kdb-bot/src/modules/base/helper/__init__.py | 4 +-- kdb-bot/src/modules/base/model/__init__.py | 4 +-- kdb-bot/src/modules/base/service/__init__.py | 4 +-- kdb-bot/src/modules/base/thread/__init__.py | 4 +-- kdb-bot/src/modules/boot_log/__init__.py | 4 +-- kdb-bot/src/modules/boot_log/boot-log.json | 4 +-- kdb-bot/src/modules/config/__init__.py | 4 +-- kdb-bot/src/modules/config/config.json | 8 +++--- kdb-bot/src/modules/config/events/__init__.py | 4 +-- .../src/modules/config/service/__init__.py | 4 +-- kdb-bot/src/modules/database/__init__.py | 4 +-- kdb-bot/src/modules/database/database.json | 4 +-- kdb-bot/src/modules/level/__init__.py | 4 +-- kdb-bot/src/modules/level/command/__init__.py | 4 +-- .../modules/level/configuration/__init__.py | 4 +-- kdb-bot/src/modules/level/events/__init__.py | 4 +-- kdb-bot/src/modules/level/level.json | 4 +-- kdb-bot/src/modules/level/service/__init__.py | 4 +-- kdb-bot/src/modules/permission/__init__.py | 4 +-- .../src/modules/permission/abc/__init__.py | 4 +-- .../src/modules/permission/permission.json | 4 +-- .../modules/permission/service/__init__.py | 4 +-- .../src/modules/short_role_name/__init__.py | 4 +-- .../short_role_name/events/__init__.py | 4 +-- .../short_role_name/service/__init__.py | 4 +-- .../short_role_name/short-role-name.json | 8 +++--- .../src/modules/special_offers/__init__.py | 25 +++++++++++++++++++ .../special_offers/special-offers.json | 8 +++--- kdb-bot/src/modules/technician/__init__.py | 4 +-- .../modules/technician/command/__init__.py | 4 +-- .../src/modules/technician/technician.json | 4 +-- kdb-bot/tools/checks/checks.json | 4 +-- kdb-bot/tools/get_version/get-version.json | 4 +-- kdb-bot/tools/post_build/post-build.json | 4 +-- kdb-bot/tools/set_version/set-version.json | 4 +-- 93 files changed, 217 insertions(+), 192 deletions(-) diff --git a/kdb-bot/src/bot/__init__.py b/kdb-bot/src/bot/__init__.py index 19b2ab5c..17f979c1 100644 --- a/kdb-bot/src/bot/__init__.py +++ b/kdb-bot/src/bot/__init__.py @@ -15,7 +15,7 @@ __title__ = "bot" __author__ = "Sven Heidemann" __license__ = "MIT" __copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de" -__version__ = "1.1.10" +__version__ = "1.2.0" 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="10") +version_info = VersionInfo(major="1", minor="2", micro="0") diff --git a/kdb-bot/src/bot/bot.json b/kdb-bot/src/bot/bot.json index a61ca0a2..c7bbec88 100644 --- a/kdb-bot/src/bot/bot.json +++ b/kdb-bot/src/bot/bot.json @@ -3,8 +3,8 @@ "Name": "bot", "Version": { "Major": "1", - "Minor": "1", - "Micro": "10" + "Minor": "2", + "Micro": "0" }, "Author": "Sven Heidemann", "AuthorEmail": "sven.heidemann@sh-edraft.de", diff --git a/kdb-bot/src/bot/extension/__init__.py b/kdb-bot/src/bot/extension/__init__.py index 613907d1..56d79a66 100644 --- a/kdb-bot/src/bot/extension/__init__.py +++ b/kdb-bot/src/bot/extension/__init__.py @@ -15,7 +15,7 @@ __title__ = "bot.extension" __author__ = "Sven Heidemann" __license__ = "MIT" __copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de" -__version__ = "1.1.10" +__version__ = "1.2.0" 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="10") +version_info = VersionInfo(major="1", minor="2", micro="0") diff --git a/kdb-bot/src/bot_api/__init__.py b/kdb-bot/src/bot_api/__init__.py index bc48f01b..6a63c058 100644 --- a/kdb-bot/src/bot_api/__init__.py +++ b/kdb-bot/src/bot_api/__init__.py @@ -15,7 +15,7 @@ __title__ = "bot_api" __author__ = "Sven Heidemann" __license__ = "MIT" __copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de" -__version__ = "1.1.10" +__version__ = "1.2.0" 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="10") +version_info = VersionInfo(major="1", minor="2", micro="0") diff --git a/kdb-bot/src/bot_api/abc/__init__.py b/kdb-bot/src/bot_api/abc/__init__.py index 6213503f..2133612b 100644 --- a/kdb-bot/src/bot_api/abc/__init__.py +++ b/kdb-bot/src/bot_api/abc/__init__.py @@ -15,7 +15,7 @@ __title__ = "bot_api.abc" __author__ = "Sven Heidemann" __license__ = "MIT" __copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de" -__version__ = "1.1.10" +__version__ = "1.2.0" 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="10") +version_info = VersionInfo(major="1", minor="2", micro="0") diff --git a/kdb-bot/src/bot_api/bot-api.json b/kdb-bot/src/bot_api/bot-api.json index cc6404cc..a4529c34 100644 --- a/kdb-bot/src/bot_api/bot-api.json +++ b/kdb-bot/src/bot_api/bot-api.json @@ -3,8 +3,8 @@ "Name": "bot-api", "Version": { "Major": "1", - "Minor": "1", - "Micro": "10" + "Minor": "2", + "Micro": "0" }, "Author": "", "AuthorEmail": "", diff --git a/kdb-bot/src/bot_api/configuration/__init__.py b/kdb-bot/src/bot_api/configuration/__init__.py index f71552cc..36ddf985 100644 --- a/kdb-bot/src/bot_api/configuration/__init__.py +++ b/kdb-bot/src/bot_api/configuration/__init__.py @@ -15,7 +15,7 @@ __title__ = "bot_api.configuration" __author__ = "Sven Heidemann" __license__ = "MIT" __copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de" -__version__ = "1.1.10" +__version__ = "1.2.0" 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="10") +version_info = VersionInfo(major="1", minor="2", micro="0") diff --git a/kdb-bot/src/bot_api/controller/__init__.py b/kdb-bot/src/bot_api/controller/__init__.py index 7739be1a..71f6b6d6 100644 --- a/kdb-bot/src/bot_api/controller/__init__.py +++ b/kdb-bot/src/bot_api/controller/__init__.py @@ -15,7 +15,7 @@ __title__ = "bot_api.controller" __author__ = "Sven Heidemann" __license__ = "MIT" __copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de" -__version__ = "1.1.10" +__version__ = "1.2.0" 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="10") +version_info = VersionInfo(major="1", minor="2", micro="0") diff --git a/kdb-bot/src/bot_api/event/__init__.py b/kdb-bot/src/bot_api/event/__init__.py index afcad881..9b08b3f9 100644 --- a/kdb-bot/src/bot_api/event/__init__.py +++ b/kdb-bot/src/bot_api/event/__init__.py @@ -15,7 +15,7 @@ __title__ = "bot_api.event" __author__ = "Sven Heidemann" __license__ = "MIT" __copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de" -__version__ = "1.1.10" +__version__ = "1.2.0" 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="10") +version_info = VersionInfo(major="1", minor="2", micro="0") diff --git a/kdb-bot/src/bot_api/exception/__init__.py b/kdb-bot/src/bot_api/exception/__init__.py index 2b9e3b21..472e48c6 100644 --- a/kdb-bot/src/bot_api/exception/__init__.py +++ b/kdb-bot/src/bot_api/exception/__init__.py @@ -15,7 +15,7 @@ __title__ = "bot_api.exception" __author__ = "Sven Heidemann" __license__ = "MIT" __copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de" -__version__ = "1.1.10" +__version__ = "1.2.0" 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="10") +version_info = VersionInfo(major="1", minor="2", micro="0") diff --git a/kdb-bot/src/bot_api/filter/__init__.py b/kdb-bot/src/bot_api/filter/__init__.py index bf6ccb2e..4629177d 100644 --- a/kdb-bot/src/bot_api/filter/__init__.py +++ b/kdb-bot/src/bot_api/filter/__init__.py @@ -15,7 +15,7 @@ __title__ = "bot_api.filter" __author__ = "Sven Heidemann" __license__ = "MIT" __copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de" -__version__ = "1.1.10" +__version__ = "1.2.0" 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="10") +version_info = VersionInfo(major="1", minor="2", micro="0") diff --git a/kdb-bot/src/bot_api/filter/discord/__init__.py b/kdb-bot/src/bot_api/filter/discord/__init__.py index 4c116cef..81083cb5 100644 --- a/kdb-bot/src/bot_api/filter/discord/__init__.py +++ b/kdb-bot/src/bot_api/filter/discord/__init__.py @@ -15,7 +15,7 @@ __title__ = "bot_api.filter.discord" __author__ = "Sven Heidemann" __license__ = "MIT" __copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de" -__version__ = "1.1.10" +__version__ = "1.2.0" 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="10") +version_info = VersionInfo(major="1", minor="2", micro="0") diff --git a/kdb-bot/src/bot_api/logging/__init__.py b/kdb-bot/src/bot_api/logging/__init__.py index de51a5e8..28229873 100644 --- a/kdb-bot/src/bot_api/logging/__init__.py +++ b/kdb-bot/src/bot_api/logging/__init__.py @@ -15,7 +15,7 @@ __title__ = "bot_api.logging" __author__ = "Sven Heidemann" __license__ = "MIT" __copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de" -__version__ = "1.1.10" +__version__ = "1.2.0" 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="10") +version_info = VersionInfo(major="1", minor="2", micro="0") diff --git a/kdb-bot/src/bot_api/model/__init__.py b/kdb-bot/src/bot_api/model/__init__.py index 6738fef5..428e3ced 100644 --- a/kdb-bot/src/bot_api/model/__init__.py +++ b/kdb-bot/src/bot_api/model/__init__.py @@ -15,7 +15,7 @@ __title__ = "bot_api.model" __author__ = "Sven Heidemann" __license__ = "MIT" __copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de" -__version__ = "1.1.10" +__version__ = "1.2.0" 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="10") +version_info = VersionInfo(major="1", minor="2", micro="0") diff --git a/kdb-bot/src/bot_api/model/discord/__init__.py b/kdb-bot/src/bot_api/model/discord/__init__.py index cc131151..0b731ed3 100644 --- a/kdb-bot/src/bot_api/model/discord/__init__.py +++ b/kdb-bot/src/bot_api/model/discord/__init__.py @@ -15,7 +15,7 @@ __title__ = "bot_api.model.discord" __author__ = "Sven Heidemann" __license__ = "MIT" __copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de" -__version__ = "1.1.10" +__version__ = "1.2.0" 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="10") +version_info = VersionInfo(major="1", minor="2", micro="0") diff --git a/kdb-bot/src/bot_api/route/__init__.py b/kdb-bot/src/bot_api/route/__init__.py index 388aa4b0..81792f2e 100644 --- a/kdb-bot/src/bot_api/route/__init__.py +++ b/kdb-bot/src/bot_api/route/__init__.py @@ -15,7 +15,7 @@ __title__ = "bot_api.route" __author__ = "Sven Heidemann" __license__ = "MIT" __copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de" -__version__ = "1.1.10" +__version__ = "1.2.0" 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="10") +version_info = VersionInfo(major="1", minor="2", micro="0") diff --git a/kdb-bot/src/bot_api/service/__init__.py b/kdb-bot/src/bot_api/service/__init__.py index 90c30c61..234af1ca 100644 --- a/kdb-bot/src/bot_api/service/__init__.py +++ b/kdb-bot/src/bot_api/service/__init__.py @@ -15,7 +15,7 @@ __title__ = "bot_api.service" __author__ = "Sven Heidemann" __license__ = "MIT" __copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de" -__version__ = "1.1.10" +__version__ = "1.2.0" 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="10") +version_info = VersionInfo(major="1", minor="2", micro="0") diff --git a/kdb-bot/src/bot_api/transformer/__init__.py b/kdb-bot/src/bot_api/transformer/__init__.py index 4e1c7916..f1f8e791 100644 --- a/kdb-bot/src/bot_api/transformer/__init__.py +++ b/kdb-bot/src/bot_api/transformer/__init__.py @@ -15,7 +15,7 @@ __title__ = "bot_api.transformer" __author__ = "Sven Heidemann" __license__ = "MIT" __copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de" -__version__ = "1.1.10" +__version__ = "1.2.0" 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="10") +version_info = VersionInfo(major="1", minor="2", micro="0") diff --git a/kdb-bot/src/bot_core/__init__.py b/kdb-bot/src/bot_core/__init__.py index 805ee627..762b31f9 100644 --- a/kdb-bot/src/bot_core/__init__.py +++ b/kdb-bot/src/bot_core/__init__.py @@ -15,7 +15,7 @@ __title__ = "bot_core" __author__ = "Sven Heidemann" __license__ = "MIT" __copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de" -__version__ = "1.1.10" +__version__ = "1.2.0" 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="10") +version_info = VersionInfo(major="1", minor="2", micro="0") diff --git a/kdb-bot/src/bot_core/abc/__init__.py b/kdb-bot/src/bot_core/abc/__init__.py index f6eea2b3..09549563 100644 --- a/kdb-bot/src/bot_core/abc/__init__.py +++ b/kdb-bot/src/bot_core/abc/__init__.py @@ -15,7 +15,7 @@ __title__ = "bot_core.abc" __author__ = "Sven Heidemann" __license__ = "MIT" __copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de" -__version__ = "1.1.10" +__version__ = "1.2.0" 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="10") +version_info = VersionInfo(major="1", minor="2", micro="0") diff --git a/kdb-bot/src/bot_core/bot-core.json b/kdb-bot/src/bot_core/bot-core.json index c8a158d2..9cf7075d 100644 --- a/kdb-bot/src/bot_core/bot-core.json +++ b/kdb-bot/src/bot_core/bot-core.json @@ -3,8 +3,8 @@ "Name": "bot-core", "Version": { "Major": "1", - "Minor": "1", - "Micro": "10" + "Minor": "2", + "Micro": "0" }, "Author": "Sven Heidemann", "AuthorEmail": "sven.heidemann@sh-edraft.de", diff --git a/kdb-bot/src/bot_core/configuration/__init__.py b/kdb-bot/src/bot_core/configuration/__init__.py index 5e342ba4..609f8642 100644 --- a/kdb-bot/src/bot_core/configuration/__init__.py +++ b/kdb-bot/src/bot_core/configuration/__init__.py @@ -15,7 +15,7 @@ __title__ = "bot_core.configuration" __author__ = "Sven Heidemann" __license__ = "MIT" __copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de" -__version__ = "1.1.10" +__version__ = "1.2.0" 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="10") +version_info = VersionInfo(major="1", minor="2", micro="0") diff --git a/kdb-bot/src/bot_core/core_extension/__init__.py b/kdb-bot/src/bot_core/core_extension/__init__.py index 97f48599..3ce1acb8 100644 --- a/kdb-bot/src/bot_core/core_extension/__init__.py +++ b/kdb-bot/src/bot_core/core_extension/__init__.py @@ -15,7 +15,7 @@ __title__ = "bot_core.core_extension" __author__ = "Sven Heidemann" __license__ = "MIT" __copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de" -__version__ = "1.1.10" +__version__ = "1.2.0" 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="10") +version_info = VersionInfo(major="1", minor="2", micro="0") diff --git a/kdb-bot/src/bot_core/events/__init__.py b/kdb-bot/src/bot_core/events/__init__.py index e5c7148f..a0543256 100644 --- a/kdb-bot/src/bot_core/events/__init__.py +++ b/kdb-bot/src/bot_core/events/__init__.py @@ -15,7 +15,7 @@ __title__ = "bot_core.events" __author__ = "Sven Heidemann" __license__ = "MIT" __copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de" -__version__ = "1.1.10" +__version__ = "1.2.0" 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="10") +version_info = VersionInfo(major="1", minor="2", micro="0") diff --git a/kdb-bot/src/bot_core/exception/__init__.py b/kdb-bot/src/bot_core/exception/__init__.py index 4b561eeb..8e7daf7e 100644 --- a/kdb-bot/src/bot_core/exception/__init__.py +++ b/kdb-bot/src/bot_core/exception/__init__.py @@ -15,7 +15,7 @@ __title__ = "bot_core.exception" __author__ = "Sven Heidemann" __license__ = "MIT" __copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de" -__version__ = "1.1.10" +__version__ = "1.2.0" 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="10") +version_info = VersionInfo(major="1", minor="2", micro="0") diff --git a/kdb-bot/src/bot_core/helper/__init__.py b/kdb-bot/src/bot_core/helper/__init__.py index cc9f6ade..b597c6fd 100644 --- a/kdb-bot/src/bot_core/helper/__init__.py +++ b/kdb-bot/src/bot_core/helper/__init__.py @@ -15,7 +15,7 @@ __title__ = "bot_core.helper" __author__ = "Sven Heidemann" __license__ = "MIT" __copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de" -__version__ = "1.1.10" +__version__ = "1.2.0" 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="10") +version_info = VersionInfo(major="1", minor="2", micro="0") diff --git a/kdb-bot/src/bot_core/logging/__init__.py b/kdb-bot/src/bot_core/logging/__init__.py index 8564fabb..1622cb57 100644 --- a/kdb-bot/src/bot_core/logging/__init__.py +++ b/kdb-bot/src/bot_core/logging/__init__.py @@ -15,7 +15,7 @@ __title__ = "bot_core.logging" __author__ = "Sven Heidemann" __license__ = "MIT" __copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de" -__version__ = "1.1.10" +__version__ = "1.2.0" 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="10") +version_info = VersionInfo(major="1", minor="2", micro="0") diff --git a/kdb-bot/src/bot_core/pipes/__init__.py b/kdb-bot/src/bot_core/pipes/__init__.py index 9bde3a5f..9b035bbb 100644 --- a/kdb-bot/src/bot_core/pipes/__init__.py +++ b/kdb-bot/src/bot_core/pipes/__init__.py @@ -15,7 +15,7 @@ __title__ = "bot_core.pipes" __author__ = "Sven Heidemann" __license__ = "MIT" __copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de" -__version__ = "1.1.10" +__version__ = "1.2.0" 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="10") +version_info = VersionInfo(major="1", minor="2", micro="0") diff --git a/kdb-bot/src/bot_core/service/__init__.py b/kdb-bot/src/bot_core/service/__init__.py index 895cf293..74bbfed6 100644 --- a/kdb-bot/src/bot_core/service/__init__.py +++ b/kdb-bot/src/bot_core/service/__init__.py @@ -15,7 +15,7 @@ __title__ = "bot_core.service" __author__ = "Sven Heidemann" __license__ = "MIT" __copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de" -__version__ = "1.1.10" +__version__ = "1.2.0" 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="10") +version_info = VersionInfo(major="1", minor="2", micro="0") diff --git a/kdb-bot/src/bot_data/__init__.py b/kdb-bot/src/bot_data/__init__.py index 7f7f0a26..dba7fc2c 100644 --- a/kdb-bot/src/bot_data/__init__.py +++ b/kdb-bot/src/bot_data/__init__.py @@ -15,7 +15,7 @@ __title__ = "bot_data" __author__ = "Sven Heidemann" __license__ = "MIT" __copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de" -__version__ = "1.1.10" +__version__ = "1.2.0" 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="10") +version_info = VersionInfo(major="1", minor="2", micro="0") diff --git a/kdb-bot/src/bot_data/abc/__init__.py b/kdb-bot/src/bot_data/abc/__init__.py index bcdb8b20..4341c756 100644 --- a/kdb-bot/src/bot_data/abc/__init__.py +++ b/kdb-bot/src/bot_data/abc/__init__.py @@ -15,7 +15,7 @@ __title__ = "bot_data.abc" __author__ = "Sven Heidemann" __license__ = "MIT" __copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de" -__version__ = "1.1.10" +__version__ = "1.2.0" 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="10") +version_info = VersionInfo(major="1", minor="2", micro="0") diff --git a/kdb-bot/src/bot_data/bot-data.json b/kdb-bot/src/bot_data/bot-data.json index 3e0dac07..8300b491 100644 --- a/kdb-bot/src/bot_data/bot-data.json +++ b/kdb-bot/src/bot_data/bot-data.json @@ -3,8 +3,8 @@ "Name": "bot-data", "Version": { "Major": "1", - "Minor": "1", - "Micro": "10" + "Minor": "2", + "Micro": "0" }, "Author": "Sven Heidemann", "AuthorEmail": "sven.heidemann@sh-edraft.de", diff --git a/kdb-bot/src/bot_data/migration/__init__.py b/kdb-bot/src/bot_data/migration/__init__.py index 2999899d..fb9a7c01 100644 --- a/kdb-bot/src/bot_data/migration/__init__.py +++ b/kdb-bot/src/bot_data/migration/__init__.py @@ -15,7 +15,7 @@ __title__ = "bot_data.migration" __author__ = "Sven Heidemann" __license__ = "MIT" __copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de" -__version__ = "1.1.10" +__version__ = "1.2.0" 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="10") +version_info = VersionInfo(major="1", minor="2", micro="0") diff --git a/kdb-bot/src/bot_data/model/__init__.py b/kdb-bot/src/bot_data/model/__init__.py index c06c1f3e..fc71a463 100644 --- a/kdb-bot/src/bot_data/model/__init__.py +++ b/kdb-bot/src/bot_data/model/__init__.py @@ -15,7 +15,7 @@ __title__ = "bot_data.model" __author__ = "Sven Heidemann" __license__ = "MIT" __copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de" -__version__ = "1.1.10" +__version__ = "1.2.0" 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="10") +version_info = VersionInfo(major="1", minor="2", micro="0") diff --git a/kdb-bot/src/bot_data/service/__init__.py b/kdb-bot/src/bot_data/service/__init__.py index da13a82b..d393f1f1 100644 --- a/kdb-bot/src/bot_data/service/__init__.py +++ b/kdb-bot/src/bot_data/service/__init__.py @@ -15,7 +15,7 @@ __title__ = "bot_data.service" __author__ = "Sven Heidemann" __license__ = "MIT" __copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de" -__version__ = "1.1.10" +__version__ = "1.2.0" 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="10") +version_info = VersionInfo(major="1", minor="2", micro="0") diff --git a/kdb-bot/src/bot_graphql/__init__.py b/kdb-bot/src/bot_graphql/__init__.py index c6369011..963709cb 100644 --- a/kdb-bot/src/bot_graphql/__init__.py +++ b/kdb-bot/src/bot_graphql/__init__.py @@ -15,7 +15,7 @@ __title__ = "bot_graphql" __author__ = "Sven Heidemann" __license__ = "MIT" __copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de" -__version__ = "1.1.10" +__version__ = "1.2.0" 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="10") +version_info = VersionInfo(major="1", minor="2", micro="0") diff --git a/kdb-bot/src/bot_graphql/abc/__init__.py b/kdb-bot/src/bot_graphql/abc/__init__.py index 4c6777fd..31668cc0 100644 --- a/kdb-bot/src/bot_graphql/abc/__init__.py +++ b/kdb-bot/src/bot_graphql/abc/__init__.py @@ -15,7 +15,7 @@ __title__ = "bot_graphql.abc" __author__ = "Sven Heidemann" __license__ = "MIT" __copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de" -__version__ = "1.1.10" +__version__ = "1.2.0" 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="10") +version_info = VersionInfo(major="1", minor="2", micro="0") diff --git a/kdb-bot/src/bot_graphql/bot-graphql.json b/kdb-bot/src/bot_graphql/bot-graphql.json index 4a9505a7..552f4f7d 100644 --- a/kdb-bot/src/bot_graphql/bot-graphql.json +++ b/kdb-bot/src/bot_graphql/bot-graphql.json @@ -3,8 +3,8 @@ "Name": "bot-data", "Version": { "Major": "1", - "Minor": "1", - "Micro": "10" + "Minor": "2", + "Micro": "0" }, "Author": "Sven Heidemann", "AuthorEmail": "sven.heidemann@sh-edraft.de", diff --git a/kdb-bot/src/bot_graphql/filter/__init__.py b/kdb-bot/src/bot_graphql/filter/__init__.py index 1d67bf12..0d5e9d05 100644 --- a/kdb-bot/src/bot_graphql/filter/__init__.py +++ b/kdb-bot/src/bot_graphql/filter/__init__.py @@ -15,7 +15,7 @@ __title__ = "bot_graphql.filter" __author__ = "Sven Heidemann" __license__ = "MIT" __copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de" -__version__ = "1.1.10" +__version__ = "1.2.0" 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="10") +version_info = VersionInfo(major="1", minor="2", micro="0") diff --git a/kdb-bot/src/bot_graphql/model/__init__.py b/kdb-bot/src/bot_graphql/model/__init__.py index bb404809..5ba9978f 100644 --- a/kdb-bot/src/bot_graphql/model/__init__.py +++ b/kdb-bot/src/bot_graphql/model/__init__.py @@ -15,7 +15,7 @@ __title__ = "bot_graphql.model" __author__ = "Sven Heidemann" __license__ = "MIT" __copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de" -__version__ = "1.1.10" +__version__ = "1.2.0" 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="10") +version_info = VersionInfo(major="1", minor="2", micro="0") diff --git a/kdb-bot/src/bot_graphql/mutations/__init__.py b/kdb-bot/src/bot_graphql/mutations/__init__.py index 38c4b97b..180b6b7b 100644 --- a/kdb-bot/src/bot_graphql/mutations/__init__.py +++ b/kdb-bot/src/bot_graphql/mutations/__init__.py @@ -15,7 +15,7 @@ __title__ = "bot_graphql.mutations" __author__ = "Sven Heidemann" __license__ = "MIT" __copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de" -__version__ = "1.1.10" +__version__ = "1.2.0" 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="10") +version_info = VersionInfo(major="1", minor="2", micro="0") diff --git a/kdb-bot/src/bot_graphql/queries/__init__.py b/kdb-bot/src/bot_graphql/queries/__init__.py index 6709693b..9cdf0a5a 100644 --- a/kdb-bot/src/bot_graphql/queries/__init__.py +++ b/kdb-bot/src/bot_graphql/queries/__init__.py @@ -15,7 +15,7 @@ __title__ = "bot_graphql.queries" __author__ = "Sven Heidemann" __license__ = "MIT" __copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de" -__version__ = "1.1.10" +__version__ = "1.2.0" 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="10") +version_info = VersionInfo(major="1", minor="2", micro="0") diff --git a/kdb-bot/src/bot_graphql/queries/discord/__init__.py b/kdb-bot/src/bot_graphql/queries/discord/__init__.py index 813ca26f..662e0b21 100644 --- a/kdb-bot/src/bot_graphql/queries/discord/__init__.py +++ b/kdb-bot/src/bot_graphql/queries/discord/__init__.py @@ -15,7 +15,7 @@ __title__ = "bot_graphql.queries.discord" __author__ = "Sven Heidemann" __license__ = "MIT" __copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de" -__version__ = "1.1.10" +__version__ = "1.2.0" 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="10") +version_info = VersionInfo(major="1", minor="2", micro="0") diff --git a/kdb-bot/src/modules/achievements/__init__.py b/kdb-bot/src/modules/achievements/__init__.py index 4fe7a734..865470f0 100644 --- a/kdb-bot/src/modules/achievements/__init__.py +++ b/kdb-bot/src/modules/achievements/__init__.py @@ -15,7 +15,7 @@ __title__ = "modules.achievements" __author__ = "Sven Heidemann" __license__ = "MIT" __copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de" -__version__ = "1.1.10" +__version__ = "1.2.0" 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="10") +version_info = VersionInfo(major="1", minor="2", micro="0") diff --git a/kdb-bot/src/modules/achievements/achievements.json b/kdb-bot/src/modules/achievements/achievements.json index 033548c6..64851517 100644 --- a/kdb-bot/src/modules/achievements/achievements.json +++ b/kdb-bot/src/modules/achievements/achievements.json @@ -3,8 +3,8 @@ "Name": "achievements", "Version": { "Major": "1", - "Minor": "1", - "Micro": "10" + "Minor": "2", + "Micro": "0" }, "Author": "Sven Heidemann", "AuthorEmail": "sven.heidemann@sh-edraft.de", @@ -16,10 +16,10 @@ "LicenseName": "MIT", "LicenseDescription": "MIT, see LICENSE for more details.", "Dependencies": [ - "cpl-core>=1.1.7" + "cpl-core>=1.2.0" ], "DevDependencies": [ - "cpl-cli>=1.1.7" + "cpl-cli>=1.2.0" ], "PythonVersion": ">=3.10.4", "PythonPath": {}, diff --git a/kdb-bot/src/modules/achievements/commands/__init__.py b/kdb-bot/src/modules/achievements/commands/__init__.py index 9ad697ae..1294f61b 100644 --- a/kdb-bot/src/modules/achievements/commands/__init__.py +++ b/kdb-bot/src/modules/achievements/commands/__init__.py @@ -15,7 +15,7 @@ __title__ = "modules.achievements.commands" __author__ = "Sven Heidemann" __license__ = "MIT" __copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de" -__version__ = "1.1.10" +__version__ = "1.2.0" 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="10") +version_info = VersionInfo(major="1", minor="2", micro="0") diff --git a/kdb-bot/src/modules/achievements/events/__init__.py b/kdb-bot/src/modules/achievements/events/__init__.py index d59751a8..a7e73387 100644 --- a/kdb-bot/src/modules/achievements/events/__init__.py +++ b/kdb-bot/src/modules/achievements/events/__init__.py @@ -15,7 +15,7 @@ __title__ = "modules.achievements.events" __author__ = "Sven Heidemann" __license__ = "MIT" __copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de" -__version__ = "1.1.10" +__version__ = "1.2.0" 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="10") +version_info = VersionInfo(major="1", minor="2", micro="0") diff --git a/kdb-bot/src/modules/achievements/model/__init__.py b/kdb-bot/src/modules/achievements/model/__init__.py index 1166e952..3887011a 100644 --- a/kdb-bot/src/modules/achievements/model/__init__.py +++ b/kdb-bot/src/modules/achievements/model/__init__.py @@ -15,7 +15,7 @@ __title__ = "modules.achievements.model" __author__ = "Sven Heidemann" __license__ = "MIT" __copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de" -__version__ = "1.1.10" +__version__ = "1.2.0" 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="10") +version_info = VersionInfo(major="1", minor="2", micro="0") diff --git a/kdb-bot/src/modules/auto_role/__init__.py b/kdb-bot/src/modules/auto_role/__init__.py index 4d641f35..17736b45 100644 --- a/kdb-bot/src/modules/auto_role/__init__.py +++ b/kdb-bot/src/modules/auto_role/__init__.py @@ -15,7 +15,7 @@ __title__ = "modules.auto_role" __author__ = "Sven Heidemann" __license__ = "MIT" __copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de" -__version__ = "1.1.10" +__version__ = "1.2.0" 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="10") +version_info = VersionInfo(major="1", minor="2", micro="0") diff --git a/kdb-bot/src/modules/auto_role/auto-role.json b/kdb-bot/src/modules/auto_role/auto-role.json index 2a78346e..81afa64e 100644 --- a/kdb-bot/src/modules/auto_role/auto-role.json +++ b/kdb-bot/src/modules/auto_role/auto-role.json @@ -3,8 +3,8 @@ "Name": "auto-role", "Version": { "Major": "1", - "Minor": "1", - "Micro": "10" + "Minor": "2", + "Micro": "0" }, "Author": "", "AuthorEmail": "", diff --git a/kdb-bot/src/modules/auto_role/command/__init__.py b/kdb-bot/src/modules/auto_role/command/__init__.py index 3a096291..8044c8a1 100644 --- a/kdb-bot/src/modules/auto_role/command/__init__.py +++ b/kdb-bot/src/modules/auto_role/command/__init__.py @@ -15,7 +15,7 @@ __title__ = "modules.auto_role.command" __author__ = "Sven Heidemann" __license__ = "MIT" __copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de" -__version__ = "1.1.10" +__version__ = "1.2.0" 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="10") +version_info = VersionInfo(major="1", minor="2", micro="0") diff --git a/kdb-bot/src/modules/auto_role/events/__init__.py b/kdb-bot/src/modules/auto_role/events/__init__.py index 30f60d27..9309ac26 100644 --- a/kdb-bot/src/modules/auto_role/events/__init__.py +++ b/kdb-bot/src/modules/auto_role/events/__init__.py @@ -15,7 +15,7 @@ __title__ = "modules.auto_role.events" __author__ = "Sven Heidemann" __license__ = "MIT" __copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de" -__version__ = "1.1.10" +__version__ = "1.2.0" 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="10") +version_info = VersionInfo(major="1", minor="2", micro="0") diff --git a/kdb-bot/src/modules/auto_role/helper/__init__.py b/kdb-bot/src/modules/auto_role/helper/__init__.py index 3e020087..a35ecba7 100644 --- a/kdb-bot/src/modules/auto_role/helper/__init__.py +++ b/kdb-bot/src/modules/auto_role/helper/__init__.py @@ -15,7 +15,7 @@ __title__ = "modules.auto_role.helper" __author__ = "Sven Heidemann" __license__ = "MIT" __copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de" -__version__ = "1.1.10" +__version__ = "1.2.0" 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="10") +version_info = VersionInfo(major="1", minor="2", micro="0") diff --git a/kdb-bot/src/modules/base/__init__.py b/kdb-bot/src/modules/base/__init__.py index 3314d082..e21909e8 100644 --- a/kdb-bot/src/modules/base/__init__.py +++ b/kdb-bot/src/modules/base/__init__.py @@ -15,7 +15,7 @@ __title__ = "modules.base" __author__ = "Sven Heidemann" __license__ = "MIT" __copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de" -__version__ = "1.1.10" +__version__ = "1.2.0" 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="10") +version_info = VersionInfo(major="1", minor="2", micro="0") diff --git a/kdb-bot/src/modules/base/base.json b/kdb-bot/src/modules/base/base.json index e7f69ff0..18cc6283 100644 --- a/kdb-bot/src/modules/base/base.json +++ b/kdb-bot/src/modules/base/base.json @@ -3,8 +3,8 @@ "Name": "base", "Version": { "Major": "1", - "Minor": "1", - "Micro": "10" + "Minor": "2", + "Micro": "0" }, "Author": "", "AuthorEmail": "", diff --git a/kdb-bot/src/modules/base/command/__init__.py b/kdb-bot/src/modules/base/command/__init__.py index 68f7c289..f5ed1fc1 100644 --- a/kdb-bot/src/modules/base/command/__init__.py +++ b/kdb-bot/src/modules/base/command/__init__.py @@ -15,7 +15,7 @@ __title__ = "modules.base.command" __author__ = "Sven Heidemann" __license__ = "MIT" __copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de" -__version__ = "1.1.10" +__version__ = "1.2.0" 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="10") +version_info = VersionInfo(major="1", minor="2", micro="0") diff --git a/kdb-bot/src/modules/base/events/__init__.py b/kdb-bot/src/modules/base/events/__init__.py index 8a040853..b1bc682c 100644 --- a/kdb-bot/src/modules/base/events/__init__.py +++ b/kdb-bot/src/modules/base/events/__init__.py @@ -15,7 +15,7 @@ __title__ = "modules.base.events" __author__ = "Sven Heidemann" __license__ = "MIT" __copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de" -__version__ = "1.1.10" +__version__ = "1.2.0" 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="10") +version_info = VersionInfo(major="1", minor="2", micro="0") diff --git a/kdb-bot/src/modules/base/forms/__init__.py b/kdb-bot/src/modules/base/forms/__init__.py index ca431fb0..1c884422 100644 --- a/kdb-bot/src/modules/base/forms/__init__.py +++ b/kdb-bot/src/modules/base/forms/__init__.py @@ -15,7 +15,7 @@ __title__ = "modules.base.forms" __author__ = "Sven Heidemann" __license__ = "MIT" __copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de" -__version__ = "1.1.10" +__version__ = "1.2.0" 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="10") +version_info = VersionInfo(major="1", minor="2", micro="0") diff --git a/kdb-bot/src/modules/base/helper/__init__.py b/kdb-bot/src/modules/base/helper/__init__.py index 5cc98776..ebb8d084 100644 --- a/kdb-bot/src/modules/base/helper/__init__.py +++ b/kdb-bot/src/modules/base/helper/__init__.py @@ -15,7 +15,7 @@ __title__ = "modules.base.helper" __author__ = "Sven Heidemann" __license__ = "MIT" __copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de" -__version__ = "1.1.10" +__version__ = "1.2.0" 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="10") +version_info = VersionInfo(major="1", minor="2", micro="0") diff --git a/kdb-bot/src/modules/base/model/__init__.py b/kdb-bot/src/modules/base/model/__init__.py index 53cc22a8..55bb1b35 100644 --- a/kdb-bot/src/modules/base/model/__init__.py +++ b/kdb-bot/src/modules/base/model/__init__.py @@ -15,7 +15,7 @@ __title__ = "modules.base.model" __author__ = "Sven Heidemann" __license__ = "MIT" __copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de" -__version__ = "1.1.10" +__version__ = "1.2.0" 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="10") +version_info = VersionInfo(major="1", minor="2", micro="0") diff --git a/kdb-bot/src/modules/base/service/__init__.py b/kdb-bot/src/modules/base/service/__init__.py index d231bef4..6a949706 100644 --- a/kdb-bot/src/modules/base/service/__init__.py +++ b/kdb-bot/src/modules/base/service/__init__.py @@ -15,7 +15,7 @@ __title__ = "modules.base.service" __author__ = "Sven Heidemann" __license__ = "MIT" __copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de" -__version__ = "1.1.10" +__version__ = "1.2.0" 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="10") +version_info = VersionInfo(major="1", minor="2", micro="0") diff --git a/kdb-bot/src/modules/base/thread/__init__.py b/kdb-bot/src/modules/base/thread/__init__.py index cc75ad70..df1ac34b 100644 --- a/kdb-bot/src/modules/base/thread/__init__.py +++ b/kdb-bot/src/modules/base/thread/__init__.py @@ -15,7 +15,7 @@ __title__ = "modules.base.thread" __author__ = "Sven Heidemann" __license__ = "MIT" __copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de" -__version__ = "1.1.10" +__version__ = "1.2.0" 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="10") +version_info = VersionInfo(major="1", minor="2", micro="0") diff --git a/kdb-bot/src/modules/boot_log/__init__.py b/kdb-bot/src/modules/boot_log/__init__.py index c1f30e96..f1a9cdf7 100644 --- a/kdb-bot/src/modules/boot_log/__init__.py +++ b/kdb-bot/src/modules/boot_log/__init__.py @@ -15,7 +15,7 @@ __title__ = "modules.boot_log" __author__ = "Sven Heidemann" __license__ = "MIT" __copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de" -__version__ = "1.1.10" +__version__ = "1.2.0" 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="10") +version_info = VersionInfo(major="1", minor="2", micro="0") diff --git a/kdb-bot/src/modules/boot_log/boot-log.json b/kdb-bot/src/modules/boot_log/boot-log.json index 444f31fd..4a62d1ac 100644 --- a/kdb-bot/src/modules/boot_log/boot-log.json +++ b/kdb-bot/src/modules/boot_log/boot-log.json @@ -3,8 +3,8 @@ "Name": "boot-log", "Version": { "Major": "1", - "Minor": "1", - "Micro": "10" + "Minor": "2", + "Micro": "0" }, "Author": "", "AuthorEmail": "", diff --git a/kdb-bot/src/modules/config/__init__.py b/kdb-bot/src/modules/config/__init__.py index fcdb875f..af1aee22 100644 --- a/kdb-bot/src/modules/config/__init__.py +++ b/kdb-bot/src/modules/config/__init__.py @@ -15,7 +15,7 @@ __title__ = "modules.config" __author__ = "Sven Heidemann" __license__ = "MIT" __copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de" -__version__ = "1.1.10" +__version__ = "1.2.0" 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="10") +version_info = VersionInfo(major="1", minor="2", micro="0") diff --git a/kdb-bot/src/modules/config/config.json b/kdb-bot/src/modules/config/config.json index 5dcc1695..cd8a4e09 100644 --- a/kdb-bot/src/modules/config/config.json +++ b/kdb-bot/src/modules/config/config.json @@ -3,8 +3,8 @@ "Name": "config", "Version": { "Major": "1", - "Minor": "1", - "Micro": "10" + "Minor": "2", + "Micro": "0" }, "Author": "", "AuthorEmail": "", @@ -16,10 +16,10 @@ "LicenseName": "", "LicenseDescription": "", "Dependencies": [ - "cpl-core>=1.1.7" + "cpl-core>=1.2.0" ], "DevDependencies": [ - "cpl-cli>=1.1.7" + "cpl-cli>=1.2.0" ], "PythonVersion": ">=3.10.4", "PythonPath": { diff --git a/kdb-bot/src/modules/config/events/__init__.py b/kdb-bot/src/modules/config/events/__init__.py index 7596e849..81b9f17e 100644 --- a/kdb-bot/src/modules/config/events/__init__.py +++ b/kdb-bot/src/modules/config/events/__init__.py @@ -15,7 +15,7 @@ __title__ = "modules.config.events" __author__ = "Sven Heidemann" __license__ = "MIT" __copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de" -__version__ = "1.1.10" +__version__ = "1.2.0" 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="10") +version_info = VersionInfo(major="1", minor="2", micro="0") diff --git a/kdb-bot/src/modules/config/service/__init__.py b/kdb-bot/src/modules/config/service/__init__.py index 61e61e9c..049525d1 100644 --- a/kdb-bot/src/modules/config/service/__init__.py +++ b/kdb-bot/src/modules/config/service/__init__.py @@ -15,7 +15,7 @@ __title__ = "modules.config.service" __author__ = "Sven Heidemann" __license__ = "MIT" __copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de" -__version__ = "1.1.10" +__version__ = "1.2.0" 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="10") +version_info = VersionInfo(major="1", minor="2", micro="0") diff --git a/kdb-bot/src/modules/database/__init__.py b/kdb-bot/src/modules/database/__init__.py index 769f117f..fce928b7 100644 --- a/kdb-bot/src/modules/database/__init__.py +++ b/kdb-bot/src/modules/database/__init__.py @@ -15,7 +15,7 @@ __title__ = "modules.database" __author__ = "Sven Heidemann" __license__ = "MIT" __copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de" -__version__ = "1.1.10" +__version__ = "1.2.0" 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="10") +version_info = VersionInfo(major="1", minor="2", micro="0") diff --git a/kdb-bot/src/modules/database/database.json b/kdb-bot/src/modules/database/database.json index c82f9f24..3c617eb0 100644 --- a/kdb-bot/src/modules/database/database.json +++ b/kdb-bot/src/modules/database/database.json @@ -3,8 +3,8 @@ "Name": "database", "Version": { "Major": "1", - "Minor": "1", - "Micro": "10" + "Minor": "2", + "Micro": "0" }, "Author": "Sven Heidemann", "AuthorEmail": "sven.heidemann@sh-edraft.de", diff --git a/kdb-bot/src/modules/level/__init__.py b/kdb-bot/src/modules/level/__init__.py index 241d5bed..9a54c17e 100644 --- a/kdb-bot/src/modules/level/__init__.py +++ b/kdb-bot/src/modules/level/__init__.py @@ -15,7 +15,7 @@ __title__ = "modules.level" __author__ = "Sven Heidemann" __license__ = "MIT" __copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de" -__version__ = "1.1.10" +__version__ = "1.2.0" 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="10") +version_info = VersionInfo(major="1", minor="2", micro="0") diff --git a/kdb-bot/src/modules/level/command/__init__.py b/kdb-bot/src/modules/level/command/__init__.py index b06b3010..f1e31901 100644 --- a/kdb-bot/src/modules/level/command/__init__.py +++ b/kdb-bot/src/modules/level/command/__init__.py @@ -15,7 +15,7 @@ __title__ = "modules.level.command" __author__ = "Sven Heidemann" __license__ = "MIT" __copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de" -__version__ = "1.1.10" +__version__ = "1.2.0" 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="10") +version_info = VersionInfo(major="1", minor="2", micro="0") diff --git a/kdb-bot/src/modules/level/configuration/__init__.py b/kdb-bot/src/modules/level/configuration/__init__.py index d830fb2a..a7104b3f 100644 --- a/kdb-bot/src/modules/level/configuration/__init__.py +++ b/kdb-bot/src/modules/level/configuration/__init__.py @@ -15,7 +15,7 @@ __title__ = "modules.level.configuration" __author__ = "Sven Heidemann" __license__ = "MIT" __copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de" -__version__ = "1.1.10" +__version__ = "1.2.0" 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="10") +version_info = VersionInfo(major="1", minor="2", micro="0") diff --git a/kdb-bot/src/modules/level/events/__init__.py b/kdb-bot/src/modules/level/events/__init__.py index 97ebcf9c..e6c57145 100644 --- a/kdb-bot/src/modules/level/events/__init__.py +++ b/kdb-bot/src/modules/level/events/__init__.py @@ -15,7 +15,7 @@ __title__ = "modules.level.events" __author__ = "Sven Heidemann" __license__ = "MIT" __copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de" -__version__ = "1.1.10" +__version__ = "1.2.0" 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="10") +version_info = VersionInfo(major="1", minor="2", micro="0") diff --git a/kdb-bot/src/modules/level/level.json b/kdb-bot/src/modules/level/level.json index 01ca6ac4..f4d7e68f 100644 --- a/kdb-bot/src/modules/level/level.json +++ b/kdb-bot/src/modules/level/level.json @@ -3,8 +3,8 @@ "Name": "level", "Version": { "Major": "1", - "Minor": "1", - "Micro": "10" + "Minor": "2", + "Micro": "0" }, "Author": "", "AuthorEmail": "", diff --git a/kdb-bot/src/modules/level/service/__init__.py b/kdb-bot/src/modules/level/service/__init__.py index 6c623e08..cda7dc5f 100644 --- a/kdb-bot/src/modules/level/service/__init__.py +++ b/kdb-bot/src/modules/level/service/__init__.py @@ -15,7 +15,7 @@ __title__ = "modules.level.service" __author__ = "Sven Heidemann" __license__ = "MIT" __copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de" -__version__ = "1.1.10" +__version__ = "1.2.0" 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="10") +version_info = VersionInfo(major="1", minor="2", micro="0") diff --git a/kdb-bot/src/modules/permission/__init__.py b/kdb-bot/src/modules/permission/__init__.py index f722d617..a0fc4fc7 100644 --- a/kdb-bot/src/modules/permission/__init__.py +++ b/kdb-bot/src/modules/permission/__init__.py @@ -15,7 +15,7 @@ __title__ = "modules.permission" __author__ = "Sven Heidemann" __license__ = "MIT" __copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de" -__version__ = "1.1.10" +__version__ = "1.2.0" 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="10") +version_info = VersionInfo(major="1", minor="2", micro="0") diff --git a/kdb-bot/src/modules/permission/abc/__init__.py b/kdb-bot/src/modules/permission/abc/__init__.py index f527d830..6379f88e 100644 --- a/kdb-bot/src/modules/permission/abc/__init__.py +++ b/kdb-bot/src/modules/permission/abc/__init__.py @@ -15,7 +15,7 @@ __title__ = "modules.permission.abc" __author__ = "Sven Heidemann" __license__ = "MIT" __copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de" -__version__ = "1.1.10" +__version__ = "1.2.0" 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="10") +version_info = VersionInfo(major="1", minor="2", micro="0") diff --git a/kdb-bot/src/modules/permission/permission.json b/kdb-bot/src/modules/permission/permission.json index 2ea792a8..3a708347 100644 --- a/kdb-bot/src/modules/permission/permission.json +++ b/kdb-bot/src/modules/permission/permission.json @@ -3,8 +3,8 @@ "Name": "permission", "Version": { "Major": "1", - "Minor": "1", - "Micro": "10" + "Minor": "2", + "Micro": "0" }, "Author": "", "AuthorEmail": "", diff --git a/kdb-bot/src/modules/permission/service/__init__.py b/kdb-bot/src/modules/permission/service/__init__.py index 7518517d..db82db07 100644 --- a/kdb-bot/src/modules/permission/service/__init__.py +++ b/kdb-bot/src/modules/permission/service/__init__.py @@ -15,7 +15,7 @@ __title__ = "modules.permission.service" __author__ = "Sven Heidemann" __license__ = "MIT" __copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de" -__version__ = "1.1.10" +__version__ = "1.2.0" 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="10") +version_info = VersionInfo(major="1", minor="2", micro="0") diff --git a/kdb-bot/src/modules/short_role_name/__init__.py b/kdb-bot/src/modules/short_role_name/__init__.py index 349e00ae..46278ac8 100644 --- a/kdb-bot/src/modules/short_role_name/__init__.py +++ b/kdb-bot/src/modules/short_role_name/__init__.py @@ -15,7 +15,7 @@ __title__ = "modules.short_role_name" __author__ = "Sven Heidemann" __license__ = "MIT" __copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de" -__version__ = "1.1.10" +__version__ = "1.2.0" 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="10") +version_info = VersionInfo(major="1", minor="2", micro="0") diff --git a/kdb-bot/src/modules/short_role_name/events/__init__.py b/kdb-bot/src/modules/short_role_name/events/__init__.py index 500818f9..eb81e544 100644 --- a/kdb-bot/src/modules/short_role_name/events/__init__.py +++ b/kdb-bot/src/modules/short_role_name/events/__init__.py @@ -15,7 +15,7 @@ __title__ = "modules.short_role_name.events" __author__ = "Sven Heidemann" __license__ = "MIT" __copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de" -__version__ = "1.1.10" +__version__ = "1.2.0" 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="10") +version_info = VersionInfo(major="1", minor="2", micro="0") diff --git a/kdb-bot/src/modules/short_role_name/service/__init__.py b/kdb-bot/src/modules/short_role_name/service/__init__.py index 4f98c6a7..c5716cd3 100644 --- a/kdb-bot/src/modules/short_role_name/service/__init__.py +++ b/kdb-bot/src/modules/short_role_name/service/__init__.py @@ -15,7 +15,7 @@ __title__ = "modules.short_role_name.service" __author__ = "Sven Heidemann" __license__ = "MIT" __copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de" -__version__ = "1.1.10" +__version__ = "1.2.0" 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="10") +version_info = VersionInfo(major="1", minor="2", micro="0") diff --git a/kdb-bot/src/modules/short_role_name/short-role-name.json b/kdb-bot/src/modules/short_role_name/short-role-name.json index 3cc5cce9..805e3d18 100644 --- a/kdb-bot/src/modules/short_role_name/short-role-name.json +++ b/kdb-bot/src/modules/short_role_name/short-role-name.json @@ -2,8 +2,8 @@ "ProjectSettings": { "Name": "short-role-name", "Version": { - "Major": "0", - "Minor": "0", + "Major": "1", + "Minor": "2", "Micro": "0" }, "Author": "", @@ -16,10 +16,10 @@ "LicenseName": "", "LicenseDescription": "", "Dependencies": [ - "cpl-core>=2023.4.0.post5" + "cpl-core>=1.2.0" ], "DevDependencies": [ - "cpl-cli>=2023.4.0.post3" + "cpl-cli>=1.2.0" ], "PythonVersion": ">=3.10.4", "PythonPath": { diff --git a/kdb-bot/src/modules/special_offers/__init__.py b/kdb-bot/src/modules/special_offers/__init__.py index 425ab6c1..2470352b 100644 --- a/kdb-bot/src/modules/special_offers/__init__.py +++ b/kdb-bot/src/modules/special_offers/__init__.py @@ -1 +1,26 @@ +# -*- coding: utf-8 -*- + +""" +bot sh-edraft.de Discord bot +~~~~~~~~~~~~~~~~~~~ + +Discord bot for customers of sh-edraft.de + +:copyright: (c) 2022 - 2023 sh-edraft.de +:license: MIT, see LICENSE for more details. + +""" + +__title__ = "modules.special_offers" +__author__ = "Sven Heidemann" +__license__ = "MIT" +__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de" +__version__ = "1.2.0" + +from collections import namedtuple + + # imports + +VersionInfo = namedtuple("VersionInfo", "major minor micro") +version_info = VersionInfo(major="1", minor="2", micro="0") diff --git a/kdb-bot/src/modules/special_offers/special-offers.json b/kdb-bot/src/modules/special_offers/special-offers.json index 3a1bdc9b..9d35ce51 100644 --- a/kdb-bot/src/modules/special_offers/special-offers.json +++ b/kdb-bot/src/modules/special_offers/special-offers.json @@ -2,8 +2,8 @@ "ProjectSettings": { "Name": "steam-special-offers", "Version": { - "Major": "0", - "Minor": "0", + "Major": "1", + "Minor": "2", "Micro": "0" }, "Author": "", @@ -16,10 +16,10 @@ "LicenseName": "", "LicenseDescription": "", "Dependencies": [ - "cpl-core>=2023.4.0.post5" + "cpl-core>=1.2.0" ], "DevDependencies": [ - "cpl-cli>=2023.4.0.post3" + "cpl-cli>=1.2.0" ], "PythonVersion": ">=3.10.4", "PythonPath": { diff --git a/kdb-bot/src/modules/technician/__init__.py b/kdb-bot/src/modules/technician/__init__.py index 09303612..7e184291 100644 --- a/kdb-bot/src/modules/technician/__init__.py +++ b/kdb-bot/src/modules/technician/__init__.py @@ -15,7 +15,7 @@ __title__ = "modules.technician" __author__ = "Sven Heidemann" __license__ = "MIT" __copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de" -__version__ = "1.1.10" +__version__ = "1.2.0" 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="10") +version_info = VersionInfo(major="1", minor="2", micro="0") diff --git a/kdb-bot/src/modules/technician/command/__init__.py b/kdb-bot/src/modules/technician/command/__init__.py index 7317fca2..ef7939c0 100644 --- a/kdb-bot/src/modules/technician/command/__init__.py +++ b/kdb-bot/src/modules/technician/command/__init__.py @@ -15,7 +15,7 @@ __title__ = "modules.technician.command" __author__ = "Sven Heidemann" __license__ = "MIT" __copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de" -__version__ = "1.1.10" +__version__ = "1.2.0" 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="10") +version_info = VersionInfo(major="1", minor="2", micro="0") diff --git a/kdb-bot/src/modules/technician/technician.json b/kdb-bot/src/modules/technician/technician.json index 7ae46664..24080baa 100644 --- a/kdb-bot/src/modules/technician/technician.json +++ b/kdb-bot/src/modules/technician/technician.json @@ -3,8 +3,8 @@ "Name": "technician", "Version": { "Major": "1", - "Minor": "1", - "Micro": "10" + "Minor": "2", + "Micro": "0" }, "Author": "", "AuthorEmail": "", diff --git a/kdb-bot/tools/checks/checks.json b/kdb-bot/tools/checks/checks.json index 295f0a4b..c95779e7 100644 --- a/kdb-bot/tools/checks/checks.json +++ b/kdb-bot/tools/checks/checks.json @@ -3,8 +3,8 @@ "Name": "checks", "Version": { "Major": "1", - "Minor": "1", - "Micro": "10" + "Minor": "2", + "Micro": "0" }, "Author": "Sven Heidemann", "AuthorEmail": "sven.heidemann@sh-edraft.de", diff --git a/kdb-bot/tools/get_version/get-version.json b/kdb-bot/tools/get_version/get-version.json index 0c0aacb6..bf6aa56f 100644 --- a/kdb-bot/tools/get_version/get-version.json +++ b/kdb-bot/tools/get_version/get-version.json @@ -3,8 +3,8 @@ "Name": "get-version", "Version": { "Major": "1", - "Minor": "1", - "Micro": "10" + "Minor": "2", + "Micro": "0" }, "Author": "Sven Heidemann", "AuthorEmail": "sven.heidemann@sh-edraft.de", diff --git a/kdb-bot/tools/post_build/post-build.json b/kdb-bot/tools/post_build/post-build.json index f499bc71..97cd72d1 100644 --- a/kdb-bot/tools/post_build/post-build.json +++ b/kdb-bot/tools/post_build/post-build.json @@ -3,8 +3,8 @@ "Name": "post-build", "Version": { "Major": "1", - "Minor": "1", - "Micro": "10" + "Minor": "2", + "Micro": "0" }, "Author": "Sven Heidemann", "AuthorEmail": "sven.heidemann@sh-edraft.de", diff --git a/kdb-bot/tools/set_version/set-version.json b/kdb-bot/tools/set_version/set-version.json index 6ea92728..0c2e47ff 100644 --- a/kdb-bot/tools/set_version/set-version.json +++ b/kdb-bot/tools/set_version/set-version.json @@ -3,8 +3,8 @@ "Name": "set-version", "Version": { "Major": "1", - "Minor": "1", - "Micro": "10" + "Minor": "2", + "Micro": "0" }, "Author": "Sven Heidemann", "AuthorEmail": "sven.heidemann@sh-edraft.de", -- 2.45.2 From ea1472a9eb7c619847cc5522894d44414035f730 Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Fri, 13 Oct 2023 15:09:08 +0200 Subject: [PATCH 11/58] Fixed type param for get_services #404 --- kdb-bot/src/bot/application.py | 2 +- kdb-bot/src/bot_data/service/seeder_service.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/kdb-bot/src/bot/application.py b/kdb-bot/src/bot/application.py index 257d57ff..6d1e4dd9 100644 --- a/kdb-bot/src/bot/application.py +++ b/kdb-bot/src/bot/application.py @@ -31,7 +31,7 @@ class Application(DiscordBotApplicationABC): self._translation: TranslationServiceABC = services.get_service(TranslationServiceABC) self._t: TranslatePipe = services.get_service(TranslatePipe) # internal stuff - self._tasks = services.get_services(list[TaskABC]) + self._tasks = services.get_services(TaskABC) self._feature_flags: FeatureFlagsSettings = config.get_configuration(FeatureFlagsSettings) diff --git a/kdb-bot/src/bot_data/service/seeder_service.py b/kdb-bot/src/bot_data/service/seeder_service.py index feada479..69982c09 100644 --- a/kdb-bot/src/bot_data/service/seeder_service.py +++ b/kdb-bot/src/bot_data/service/seeder_service.py @@ -19,7 +19,7 @@ class SeederService: async def seed(self): self._logger.info(__name__, f"Seed data") - for seeder in self._services.get_services(list[DataSeederABC]): + for seeder in self._services.get_services(DataSeederABC): seeder: DataSeederABC = seeder self._logger.debug(__name__, f"Starting seeder {type(seeder).__name__}") await seeder.seed() -- 2.45.2 From 0946734633ea99596bbd7ea9bc6923ac2337ad31 Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Fri, 13 Oct 2023 15:12:37 +0200 Subject: [PATCH 12/58] Removed mysql_native_password #404 --- kdb-bot/src/bot/config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kdb-bot/src/bot/config b/kdb-bot/src/bot/config index 839bbb82..aa124934 160000 --- a/kdb-bot/src/bot/config +++ b/kdb-bot/src/bot/config @@ -1 +1 @@ -Subproject commit 839bbb823a6e0c9e1443e0844446bfe240284063 +Subproject commit aa1249341910f2877522a2002df7feea95256749 -- 2.45.2 From 232429a77dbc216d675e46745971f73003c48561 Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Fri, 13 Oct 2023 15:24:02 +0200 Subject: [PATCH 13/58] Updated cpl-discord #404 --- kdb-bot/src/bot/bot.json | 2 +- kdb-bot/src/bot_api/api_module.py | 2 +- .../core_extension/core_extension_module.py | 2 +- kdb-bot/src/bot_core/core_module.py | 2 +- .../achievements/achievements_module.py | 10 ++-- .../src/modules/auto_role/auto_role_module.py | 6 +-- kdb-bot/src/modules/base/base_module.py | 52 +++++++++---------- .../src/modules/boot_log/boot_log_module.py | 2 +- kdb-bot/src/modules/config/config_module.py | 2 +- .../src/modules/database/database_module.py | 2 +- kdb-bot/src/modules/level/level_module.py | 12 ++--- .../short_role_name/short_role_name_module.py | 4 +- .../modules/technician/technician_module.py | 10 ++-- 13 files changed, 54 insertions(+), 54 deletions(-) diff --git a/kdb-bot/src/bot/bot.json b/kdb-bot/src/bot/bot.json index c7bbec88..f732df34 100644 --- a/kdb-bot/src/bot/bot.json +++ b/kdb-bot/src/bot/bot.json @@ -19,7 +19,7 @@ "cpl-core==2023.10.0", "cpl-translation==2023.4.0.post1", "cpl-query==2023.10.0", - "cpl-discord==2023.10.0", + "cpl-discord==2023.10.0.post1", "Flask==3.0.0", "Flask-Classful==0.16.0", "Flask-Cors==4.0.0", diff --git a/kdb-bot/src/bot_api/api_module.py b/kdb-bot/src/bot_api/api_module.py index 8f40f95e..b2695e12 100644 --- a/kdb-bot/src/bot_api/api_module.py +++ b/kdb-bot/src/bot_api/api_module.py @@ -48,4 +48,4 @@ class ApiModule(ModuleABC): services.add_transient(GraphQLController) # cpl-discord - self._dc.add_event(DiscordEventTypesEnum.on_ready.value, BotApiOnReadyEvent) + services.add_transient(DiscordEventTypesEnum.on_ready.value, BotApiOnReadyEvent) diff --git a/kdb-bot/src/bot_core/core_extension/core_extension_module.py b/kdb-bot/src/bot_core/core_extension/core_extension_module.py index d6cba99b..ef16529f 100644 --- a/kdb-bot/src/bot_core/core_extension/core_extension_module.py +++ b/kdb-bot/src/bot_core/core_extension/core_extension_module.py @@ -19,4 +19,4 @@ class CoreExtensionModule(ModuleABC): pass def configure_services(self, services: ServiceCollectionABC, env: ApplicationEnvironmentABC): - self._dc.add_event(DiscordEventTypesEnum.on_ready.value, CoreExtensionOnReadyEvent) + services.add_transient(DiscordEventTypesEnum.on_ready.value, CoreExtensionOnReadyEvent) diff --git a/kdb-bot/src/bot_core/core_module.py b/kdb-bot/src/bot_core/core_module.py index fcb06333..02611684 100644 --- a/kdb-bot/src/bot_core/core_module.py +++ b/kdb-bot/src/bot_core/core_module.py @@ -32,4 +32,4 @@ class CoreModule(ModuleABC): # pipes services.add_transient(DateTimeOffsetPipe) - self._dc.add_event(DiscordEventTypesEnum.on_ready.value, CoreOnReadyEvent) + services.add_transient(DiscordEventTypesEnum.on_ready.value, CoreOnReadyEvent) diff --git a/kdb-bot/src/modules/achievements/achievements_module.py b/kdb-bot/src/modules/achievements/achievements_module.py index 3860feac..8ea61396 100644 --- a/kdb-bot/src/modules/achievements/achievements_module.py +++ b/kdb-bot/src/modules/achievements/achievements_module.py @@ -26,9 +26,9 @@ class AchievementsModule(ModuleABC): services.add_transient(AchievementAttributeResolver) services.add_transient(AchievementService) - self._dc.add_command(AchievementGroup) + services.add_transient(AchievementGroup) - self._dc.add_event(DiscordEventTypesEnum.on_message.value, AchievementOnMessageEvent) - self._dc.add_event(DiscordEventTypesEnum.on_reaction_add.value, AchievementOnReactionAddEvent) - self._dc.add_event(DiscordEventTypesEnum.on_reaction_remove.value, AchievementOnReactionRemoveEvent) - self._dc.add_event(DiscordEventTypesEnum.on_voice_state_update.value, AchievementOnVoiceStateUpdateEvent) + services.add_transient(DiscordEventTypesEnum.on_message.value, AchievementOnMessageEvent) + services.add_transient(DiscordEventTypesEnum.on_reaction_add.value, AchievementOnReactionAddEvent) + services.add_transient(DiscordEventTypesEnum.on_reaction_remove.value, AchievementOnReactionRemoveEvent) + services.add_transient(DiscordEventTypesEnum.on_voice_state_update.value, AchievementOnVoiceStateUpdateEvent) diff --git a/kdb-bot/src/modules/auto_role/auto_role_module.py b/kdb-bot/src/modules/auto_role/auto_role_module.py index e23085f3..07eba97e 100644 --- a/kdb-bot/src/modules/auto_role/auto_role_module.py +++ b/kdb-bot/src/modules/auto_role/auto_role_module.py @@ -26,13 +26,13 @@ class AutoRoleModule(ModuleABC): def configure_services(self, services: ServiceCollectionABC, env: ApplicationEnvironmentABC): services.add_transient(AutoRoleReactionHandler) # commands - self._dc.add_command(AutoRoleGroup) + services.add_transient(AutoRoleGroup) # events - self._dc.add_event( + services.add_transient( DiscordEventTypesEnum.on_raw_reaction_add.value, AutoRoleOnRawReactionAddEvent, ) - self._dc.add_event( + services.add_transient( DiscordEventTypesEnum.on_raw_reaction_remove.value, AutoRoleOnRawReactionRemoveEvent, ) diff --git a/kdb-bot/src/modules/base/base_module.py b/kdb-bot/src/modules/base/base_module.py index 949fa4ad..e7d597a9 100644 --- a/kdb-bot/src/modules/base/base_module.py +++ b/kdb-bot/src/modules/base/base_module.py @@ -65,49 +65,49 @@ class BaseModule(ModuleABC): services.add_transient(ComplaintForm) # commands - self._dc.add_command(AFKCommand) - self._dc.add_command(SubmitGroup) - self._dc.add_command(HelpCommand) - self._dc.add_command(InfoCommand) - self._dc.add_command(MassMoveCommand) - self._dc.add_command(PingCommand) - self._dc.add_command(PresenceCommand) - self._dc.add_command(MakeCoffeeCommand) + services.add_transient(AFKCommand) + services.add_transient(SubmitGroup) + services.add_transient(HelpCommand) + services.add_transient(InfoCommand) + services.add_transient(MassMoveCommand) + services.add_transient(PingCommand) + services.add_transient(PresenceCommand) + services.add_transient(MakeCoffeeCommand) - self._dc.add_command(PurgeCommand) - self._dc.add_command(UserGroup) - self._dc.add_command(RegisterGroup) - self._dc.add_command(UnregisterGroup) - self._dc.add_command(GameServerGroup) + services.add_transient(PurgeCommand) + services.add_transient(UserGroup) + services.add_transient(RegisterGroup) + services.add_transient(UnregisterGroup) + services.add_transient(GameServerGroup) # events - self._dc.add_event(DiscordEventTypesEnum.on_command.value, BaseOnCommandEvent) - self._dc.add_event(DiscordEventTypesEnum.on_command_error.value, BaseOnCommandErrorEvent) - self._dc.add_event(DiscordEventTypesEnum.on_member_join.value, BaseOnMemberJoinEvent) - self._dc.add_event(DiscordEventTypesEnum.on_member_remove.value, BaseOnMemberRemoveEvent) - self._dc.add_event(DiscordEventTypesEnum.on_message.value, BaseOnMessageEvent) - self._dc.add_event(DiscordEventTypesEnum.on_message_delete.value, BaseOnMessageDeleteEvent) - self._dc.add_event(DiscordEventTypesEnum.on_raw_reaction_add.value, BaseOnRawReactionAddEvent) - self._dc.add_event( + services.add_transient(DiscordEventTypesEnum.on_command.value, BaseOnCommandEvent) + services.add_transient(DiscordEventTypesEnum.on_command_error.value, BaseOnCommandErrorEvent) + services.add_transient(DiscordEventTypesEnum.on_member_join.value, BaseOnMemberJoinEvent) + services.add_transient(DiscordEventTypesEnum.on_member_remove.value, BaseOnMemberRemoveEvent) + services.add_transient(DiscordEventTypesEnum.on_message.value, BaseOnMessageEvent) + services.add_transient(DiscordEventTypesEnum.on_message_delete.value, BaseOnMessageDeleteEvent) + services.add_transient(DiscordEventTypesEnum.on_raw_reaction_add.value, BaseOnRawReactionAddEvent) + services.add_transient( DiscordEventTypesEnum.on_raw_reaction_remove.value, BaseOnRawReactionRemoveEvent, ) - self._dc.add_event( + services.add_transient( DiscordEventTypesEnum.on_voice_state_update.value, BaseOnVoiceStateUpdateEvent, ) - self._dc.add_event( + services.add_transient( DiscordEventTypesEnum.on_voice_state_update.value, BaseOnVoiceStateUpdateEventHelpChannel, ) - self._dc.add_event( + services.add_transient( DiscordEventTypesEnum.on_voice_state_update.value, BaseOnVoiceStateUpdateEventScheduledEventBonus, ) - self._dc.add_event( + services.add_transient( DiscordEventTypesEnum.on_scheduled_event_update.value, BaseOnScheduledEventUpdateEvent, ) - self._dc.add_event( + services.add_transient( DiscordEventTypesEnum.on_guild_join.value, BaseOnGuildJoinEvent, ) diff --git a/kdb-bot/src/modules/boot_log/boot_log_module.py b/kdb-bot/src/modules/boot_log/boot_log_module.py index 94a1cc14..dde842f0 100644 --- a/kdb-bot/src/modules/boot_log/boot_log_module.py +++ b/kdb-bot/src/modules/boot_log/boot_log_module.py @@ -19,4 +19,4 @@ class BootLogModule(ModuleABC): def configure_services(self, services: ServiceCollectionABC, env: ApplicationEnvironmentABC): # commands # events - self._dc.add_event(DiscordEventTypesEnum.on_ready.value, BootLogOnReadyEvent) + services.add_transient(DiscordEventTypesEnum.on_ready.value, BootLogOnReadyEvent) diff --git a/kdb-bot/src/modules/config/config_module.py b/kdb-bot/src/modules/config/config_module.py index c55b62d1..14c16263 100644 --- a/kdb-bot/src/modules/config/config_module.py +++ b/kdb-bot/src/modules/config/config_module.py @@ -17,4 +17,4 @@ class ConfigModule(ModuleABC): pass def configure_services(self, services: ServiceCollectionABC, env: ApplicationEnvironmentABC): - self._dc.add_event(DiscordEventTypesEnum.on_ready.value, ConfigOnReadyEvent) + services.add_transient(DiscordEventTypesEnum.on_ready.value, ConfigOnReadyEvent) diff --git a/kdb-bot/src/modules/database/database_module.py b/kdb-bot/src/modules/database/database_module.py index cf478645..bd7c6c6f 100644 --- a/kdb-bot/src/modules/database/database_module.py +++ b/kdb-bot/src/modules/database/database_module.py @@ -19,4 +19,4 @@ class DatabaseModule(ModuleABC): def configure_services(self, services: ServiceCollectionABC, env: ApplicationEnvironmentABC): # commands # events - self._dc.add_event(DiscordEventTypesEnum.on_ready.value, DatabaseOnReadyEvent) + services.add_transient(DiscordEventTypesEnum.on_ready.value, DatabaseOnReadyEvent) diff --git a/kdb-bot/src/modules/level/level_module.py b/kdb-bot/src/modules/level/level_module.py index 018377f9..fced470c 100644 --- a/kdb-bot/src/modules/level/level_module.py +++ b/kdb-bot/src/modules/level/level_module.py @@ -36,14 +36,14 @@ class LevelModule(ModuleABC): services.add_transient(LevelService) # commands - self._dc.add_command(LevelGroup) + services.add_transient(LevelGroup) # events - self._dc.add_event(DiscordEventTypesEnum.on_message.value, LevelOnMessageEvent) - self._dc.add_event( + services.add_transient(DiscordEventTypesEnum.on_message.value, LevelOnMessageEvent) + services.add_transient( DiscordEventTypesEnum.on_voice_state_update.value, LevelOnVoiceStateUpdateEvent, ) - self._dc.add_event(DiscordEventTypesEnum.on_member_join.value, LevelOnMemberJoinEvent) - self._dc.add_event(DiscordEventTypesEnum.on_raw_reaction_add.value, LevelOnRawReactionAddEvent) - self._dc.add_event(DiscordEventTypesEnum.on_raw_reaction_remove.value, LevelOnRawReactionRemoveEvent) + services.add_transient(DiscordEventTypesEnum.on_member_join.value, LevelOnMemberJoinEvent) + services.add_transient(DiscordEventTypesEnum.on_raw_reaction_add.value, LevelOnRawReactionAddEvent) + services.add_transient(DiscordEventTypesEnum.on_raw_reaction_remove.value, LevelOnRawReactionRemoveEvent) diff --git a/kdb-bot/src/modules/short_role_name/short_role_name_module.py b/kdb-bot/src/modules/short_role_name/short_role_name_module.py index 3a413eb1..6eff2a02 100644 --- a/kdb-bot/src/modules/short_role_name/short_role_name_module.py +++ b/kdb-bot/src/modules/short_role_name/short_role_name_module.py @@ -25,6 +25,6 @@ class ShortRoleNameModule(ModuleABC): services.add_transient(ShortRoleNameService) # commands - self._dc.add_command(ShortRoleNameCheckCommand) + services.add_transient(ShortRoleNameCheckCommand) # events - self._dc.add_event(DiscordEventTypesEnum.on_member_update.value, ShortRoleNameOnMemberUpdateEvent) + services.add_transient(DiscordEventTypesEnum.on_member_update.value, ShortRoleNameOnMemberUpdateEvent) diff --git a/kdb-bot/src/modules/technician/technician_module.py b/kdb-bot/src/modules/technician/technician_module.py index 5d5472ba..8550b7d6 100644 --- a/kdb-bot/src/modules/technician/technician_module.py +++ b/kdb-bot/src/modules/technician/technician_module.py @@ -24,9 +24,9 @@ class TechnicianModule(ModuleABC): def configure_services(self, services: ServiceCollectionABC, env: ApplicationEnvironmentABC): services.add_transient(DataSeederABC, ApiKeySeeder) # commands - self._dc.add_command(RestartCommand) - self._dc.add_command(ShutdownCommand) - self._dc.add_command(LogCommand) - self._dc.add_command(ApiKeyGroup) - self._dc.add_command(SyncXpGroup) + services.add_transient(RestartCommand) + services.add_transient(ShutdownCommand) + services.add_transient(LogCommand) + services.add_transient(ApiKeyGroup) + services.add_transient(SyncXpGroup) # events -- 2.45.2 From eb32bec43c65f3510b8ee002c12bc1a2cb209957 Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Fri, 13 Oct 2023 15:28:54 +0200 Subject: [PATCH 14/58] Fixed task logging #404 --- kdb-bot/src/bot_core/abc/task_abc.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kdb-bot/src/bot_core/abc/task_abc.py b/kdb-bot/src/bot_core/abc/task_abc.py index 990b95b0..d068fd37 100644 --- a/kdb-bot/src/bot_core/abc/task_abc.py +++ b/kdb-bot/src/bot_core/abc/task_abc.py @@ -16,7 +16,7 @@ class TaskABC(commands.Cog): @ServiceProviderABC.inject async def _wait_until_ready(self, config: ConfigurationABC, logger: TaskLogger, bot: DiscordBotServiceABC): - logger.debug(__name__, f"Waiting before checking steam special offers") + logger.debug(__name__, f"Waiting before {type(self).__name__}") await bot.wait_until_ready() async def wait(): -- 2.45.2 From f435d3dd48b74c373d7d5e8955537a65ad93d28e Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Fri, 13 Oct 2023 17:10:00 +0200 Subject: [PATCH 15/58] Moved folders #405 --- .gitmodules | 18 +- {kdb-bot => bot}/.cpl/schematic_db_table.py | 0 {kdb-bot => bot}/.cpl/schematic_migration.py | 0 {kdb-bot => bot}/.cpl/schematic_query.py | 0 {kdb-bot => bot}/src/bot/__init__.py | 0 {kdb-bot => bot}/src/bot/application.py | 26 ++- {kdb-bot => bot}/src/bot/bot | 0 {kdb-bot => bot}/src/bot/bot.json | 0 .../src/bot/extension/__init__.py | 0 .../src/bot/extension/init_bot_extension.py | 4 +- {kdb-bot => bot}/src/bot/main.py | 0 {kdb-bot => bot}/src/bot/module_list.py | 0 {kdb-bot => bot}/src/bot/startup.py | 4 +- .../src/bot/startup_discord_extension.py | 8 +- .../src/bot/startup_migration_extension.py | 84 +++++-- .../src/bot/startup_module_extension.py | 8 +- .../src/bot/startup_settings_extension.py | 28 ++- {kdb-bot => bot}/src/bot/translation/de.json | 0 {kdb-bot => bot}/src/bot_api/__init__.py | 0 {kdb-bot => bot}/src/bot_api/abc/__init__.py | 0 .../src/bot_api/abc/auth_service_abc.py | 8 +- {kdb-bot => bot}/src/bot_api/abc/dto_abc.py | 0 .../src/bot_api/abc/select_criteria_abc.py | 4 +- .../src/bot_api/abc/transformer_abc.py | 0 {kdb-bot => bot}/src/bot_api/api.py | 17 +- {kdb-bot => bot}/src/bot_api/api_module.py | 12 +- {kdb-bot => bot}/src/bot_api/api_thread.py | 0 .../src/bot_api/app_api_extension.py | 4 +- {kdb-bot => bot}/src/bot_api/bot-api.json | 0 .../src/bot_api/configuration/__init__.py | 0 .../src/bot_api/configuration/api_settings.py | 0 .../configuration/authentication_settings.py | 4 +- .../discord_authentication_settings.py | 0 .../configuration/frontend_settings.py | 0 .../src/bot_api/controller/__init__.py | 0 .../src/bot_api/controller/auth_controller.py | 32 ++- .../controller/auth_discord_controller.py | 0 .../bot_api/controller/graphql_controller.py | 0 .../src/bot_api/controller/gui_controller.py | 0 .../src/bot_api/event/__init__.py | 0 .../bot_api/event/bot_api_on_ready_event.py | 0 .../src/bot_api/exception/__init__.py | 0 .../exception/service_error_code_enum.py | 0 .../bot_api/exception/service_exception.py | 0 .../src/bot_api/filter/__init__.py | 0 .../filter/auth_user_select_criteria.py | 4 +- .../src/bot_api/filter/discord/__init__.py | 0 .../filter/discord/server_select_criteria.py | 4 +- .../src/bot_api/json_processor.py | 0 .../src/bot_api/logging/__init__.py | 0 .../src/bot_api/logging/api_logger.py | 0 .../src/bot_api/model/__init__.py | 0 .../src/bot_api/model/auth_user_dto.py | 0 .../model/auth_user_filtered_result_dto.py | 0 .../src/bot_api/model/discord/__init__.py | 0 .../src/bot_api/model/discord/server_dto.py | 0 .../discord/server_filtered_result_dto.py | 0 .../src/bot_api/model/email_string_dto.py | 0 .../src/bot_api/model/error_dto.py | 4 +- .../src/bot_api/model/o_auth_dto.py | 0 .../src/bot_api/model/reset_password_dto.py | 0 .../src/bot_api/model/settings_dto.py | 0 .../src/bot_api/model/token_dto.py | 6 +- .../src/bot_api/model/update_auth_user_dto.py | 4 +- .../src/bot_api/model/user_dto.py | 0 .../src/bot_api/model/version_dto.py | 0 .../src/bot_api/route/__init__.py | 0 {kdb-bot => bot}/src/bot_api/route/route.py | 35 ++- .../src/bot_api/service/__init__.py | 0 .../src/bot_api/service/auth_service.py | 165 +++++++++---- .../src/bot_api/service/discord_service.py | 27 ++- .../src/bot_api/transformer/__init__.py | 0 .../transformer/auth_user_transformer.py | 16 +- .../bot_api/transformer/server_transformer.py | 4 +- {kdb-bot => bot}/src/bot_core/__init__.py | 0 {kdb-bot => bot}/src/bot_core/abc/__init__.py | 0 .../src/bot_core/abc/client_utils_abc.py | 10 +- .../bot_core/abc/custom_file_logger_abc.py | 8 +- .../src/bot_core/abc/message_service_abc.py | 4 +- .../src/bot_core/abc/module_abc.py | 0 {kdb-bot => bot}/src/bot_core/abc/task_abc.py | 4 +- {kdb-bot => bot}/src/bot_core/bot-core.json | 0 .../src/bot_core/configuration/__init__.py | 0 .../configuration/bot_logging_settings.py | 0 .../configuration/feature_flags_enum.py | 0 .../configuration/feature_flags_settings.py | 0 .../configuration/file_logging_settings.py | 4 +- .../src/bot_core/core_extension/__init__.py | 0 .../bot_core/core_extension/core_extension.py | 4 +- .../core_extension/core_extension_module.py | 12 +- .../core_extension_on_ready_event.py | 0 {kdb-bot => bot}/src/bot_core/core_module.py | 8 +- .../src/bot_core/events/__init__.py | 0 .../bot_core/events/core_on_ready_event.py | 0 .../src/bot_core/exception/__init__.py | 0 .../src/bot_core/exception/check_error.py | 0 .../src/bot_core/helper/__init__.py | 0 .../src/bot_core/helper/command_checks.py | 12 +- .../src/bot_core/helper/event_checks.py | 0 .../src/bot_core/helper/log_message_helper.py | 0 .../src/bot_core/logging/__init__.py | 0 .../src/bot_core/logging/command_logger.py | 0 .../src/bot_core/logging/database_logger.py | 0 .../src/bot_core/logging/message_logger.py | 0 .../src/bot_core/logging/task_logger.py | 0 .../src/bot_core/pipes/__init__.py | 0 .../bot_core/pipes/date_time_offset_pipe.py | 0 .../src/bot_core/service/__init__.py | 0 .../bot_core/service/client_utils_service.py | 54 ++++- .../src/bot_core/service/config_service.py | 8 +- .../service/data_integrity_service.py | 145 +++++++++--- .../src/bot_core/service/message_service.py | 88 +++++-- {kdb-bot => bot}/src/bot_data/__init__.py | 0 {kdb-bot => bot}/src/bot_data/abc/__init__.py | 0 .../abc/achievement_repository_abc.py | 4 +- .../bot_data/abc/api_key_repository_abc.py | 0 .../bot_data/abc/auth_user_repository_abc.py | 4 +- .../bot_data/abc/auto_role_repository_abc.py | 0 .../src/bot_data/abc/client_repository_abc.py | 4 +- .../src/bot_data/abc/data_seeder_abc.py | 0 .../abc/game_server_repository_abc.py | 0 .../src/bot_data/abc/history_table_abc.py | 0 .../bot_data/abc/known_user_repository_abc.py | 0 .../src/bot_data/abc/level_repository_abc.py | 0 .../src/bot_data/abc/migration_abc.py | 0 .../abc/server_config_repository_abc.py | 24 +- .../src/bot_data/abc/server_repository_abc.py | 0 .../abc/short_role_name_repository_abc.py | 0 .../abc/steam_special_offer_repository_abc.py | 0 .../src/bot_data/abc/table_with_id_abc.py | 0 .../abc/technician_config_repository_abc.py | 12 +- .../abc/user_game_ident_repository_abc.py | 0 .../user_joined_game_server_repository_abc.py | 28 ++- .../abc/user_joined_server_repository_abc.py | 12 +- ...ser_joined_voice_channel_repository_abc.py | 28 ++- ...r_message_count_per_hour_repository_abc.py | 4 +- .../src/bot_data/abc/user_repository_abc.py | 8 +- .../abc/user_warnings_repository_abc.py | 0 {kdb-bot => bot}/src/bot_data/bot-data.json | 0 {kdb-bot => bot}/src/bot_data/data_module.py | 76 ++++-- {kdb-bot => bot}/src/bot_data/db_context.py | 0 .../src/bot_data/filtered_result.py | 0 .../src/bot_data/migration/__init__.py | 0 .../migration/achievements_migration.py | 32 ++- .../bot_data/migration/api_key_migration.py | 0 .../src/bot_data/migration/api_migration.py | 0 .../migration/auto_role_fix1_migration.py | 0 .../bot_data/migration/auto_role_migration.py | 0 .../bot_data/migration/birthday_migration.py | 0 .../config_feature_flags_migration.py | 8 +- .../bot_data/migration/config_migration.py | 0 .../migration/db_history_migration.py | 0 .../migration/db_history_scripts/api_keys.sql | 0 .../auth_user_users_relation.sql | 0 .../db_history_scripts/auth_users.sql | 0 .../db_history_scripts/auto_role_rules.sql | 0 .../db_history_scripts/auto_roles.sql | 0 .../migration/db_history_scripts/clients.sql | 0 .../db_history_scripts/config/server.sql | 0 .../config/server_afk_channels.sql | 0 .../config/server_team_roles.sql | 0 .../db_history_scripts/config/technician.sql | 0 .../config/technician_ids.sql | 0 .../config/technician_ping_urls.sql | 0 .../db_history_scripts/game_servers.sql | 0 .../db_history_scripts/known_users.sql | 0 .../migration/db_history_scripts/levels.sql | 0 .../migration/db_history_scripts/servers.sql | 0 .../db_history_scripts/short_rule_names.sql | 0 .../db_history_scripts/user_game_idents.sql | 0 .../user_joined_game_servers.sql | 0 .../user_joined_servers.sql | 0 .../user_joined_voice_channel.sql | 0 .../user_message_count_per_hour.sql | 0 .../db_history_scripts/user_warnings.sql | 0 .../migration/db_history_scripts/users.sql | 0 .../migration/default_role_migration.py | 0 .../migration/fix_updates_migration.py | 4 +- .../migration/fix_user_history_migration.py | 0 .../bot_data/migration/initial_migration.py | 0 .../src/bot_data/migration/level_migration.py | 0 .../migration/remove_stats_migration.py | 0 .../migration/short_role_name_migration.py | 0 .../short_role_name_only_highest_migration.py | 0 .../src/bot_data/migration/stats_migration.py | 0 .../steam_special_offer_migration.py | 0 .../user_joined_game_server_migration.py | 0 .../user_message_count_per_hour_migration.py | 0 .../migration/user_warning_migration.py | 0 .../src/bot_data/model/__init__.py | 0 .../src/bot_data/model/achievement.py | 4 +- .../src/bot_data/model/achievement_history.py | 0 .../src/bot_data/model/api_key.py | 4 +- .../src/bot_data/model/auth_role_enum.py | 0 .../src/bot_data/model/auth_user.py | 4 +- .../model/auth_user_users_relation.py | 4 +- .../src/bot_data/model/auto_role.py | 4 +- .../src/bot_data/model/auto_role_history.py | 0 .../src/bot_data/model/auto_role_rule.py | 4 +- .../bot_data/model/auto_role_rule_history.py | 0 {kdb-bot => bot}/src/bot_data/model/client.py | 4 +- .../src/bot_data/model/client_history.py | 0 .../src/bot_data/model/game_server.py | 4 +- .../src/bot_data/model/known_user.py | 4 +- .../src/bot_data/model/known_user_history.py | 0 {kdb-bot => bot}/src/bot_data/model/level.py | 4 +- .../src/bot_data/model/level_history.py | 0 .../src/bot_data/model/migration_history.py | 0 {kdb-bot => bot}/src/bot_data/model/server.py | 4 +- .../model/server_afk_channel_ids_config.py | 4 +- .../src/bot_data/model/server_config.py | 8 +- .../bot_data/model/server_config_history.py | 4 +- .../src/bot_data/model/server_history.py | 0 .../model/server_team_role_ids_config.py | 4 +- .../src/bot_data/model/short_role_name.py | 4 +- .../bot_data/model/short_role_name_history.py | 0 .../model/short_role_name_position_enum.py | 0 .../src/bot_data/model/steam_special_offer.py | 4 +- .../bot_data/model/team_member_type_enum.py | 0 .../src/bot_data/model/technician_config.py | 4 +- .../model/technician_config_history.py | 0 .../bot_data/model/technician_id_config.py | 4 +- .../model/technician_id_config_history.py | 0 .../model/technician_ping_url_config.py | 4 +- .../technician_ping_url_config_history.py | 0 {kdb-bot => bot}/src/bot_data/model/user.py | 20 +- .../src/bot_data/model/user_game_ident.py | 4 +- .../bot_data/model/user_got_achievement.py | 4 +- .../src/bot_data/model/user_history.py | 16 +- .../bot_data/model/user_joined_game_server.py | 4 +- .../model/user_joined_game_server_history.py | 0 .../src/bot_data/model/user_joined_server.py | 4 +- .../model/user_joined_server_history.py | 0 .../model/user_joined_voice_channel.py | 4 +- .../user_joined_voice_channel_history.py | 0 .../model/user_message_count_per_hour.py | 4 +- .../src/bot_data/model/user_role_enum.py | 0 .../src/bot_data/model/user_warnings.py | 4 +- .../bot_data/model/user_warnings_history.py | 0 .../src/bot_data/service/__init__.py | 0 .../achievements_repository_service.py | 41 +++- .../service/api_key_repository_service.py | 24 +- .../service/auth_user_repository_service.py | 42 +++- .../service/auto_role_repository_service.py | 110 +++++++-- .../src/bot_data/service/cache_service.py | 0 .../service/client_repository_service.py | 29 ++- .../service/game_server_repository_service.py | 8 +- .../service/known_user_repository_service.py | 16 +- .../service/level_repository_service.py | 12 +- .../src/bot_data/service/migration_service.py | 16 +- .../src/bot_data/service/seeder_service.py | 0 .../server_config_repository_service.py | 108 +++++++-- .../bot_data/service/server_config_seeder.py | 0 .../service/server_repository_service.py | 43 +++- .../short_role_name_repository_service.py | 37 ++- .../steam_special_offer_repository_service.py | 29 ++- .../technician_config_repository_service.py | 53 +++-- .../service/technician_config_seeder.py | 13 +- .../user_game_ident_repository_service.py | 28 ++- ...r_joined_game_server_repository_service.py | 68 ++++-- .../user_joined_server_repository_service.py | 40 +++- ...joined_voice_channel_repository_service.py | 68 ++++-- ...ssage_count_per_hour_repository_service.py | 20 +- .../service/user_repository_service.py | 28 ++- .../user_warnings_repository_service.py | 17 +- {kdb-bot => bot}/src/bot_graphql/__init__.py | 0 .../src/bot_graphql/abc/__init__.py | 0 .../src/bot_graphql/abc/data_query_abc.py | 0 .../abc/data_query_with_history_abc.py | 0 .../src/bot_graphql/abc/filter_abc.py | 10 +- .../src/bot_graphql/abc/history_query_abc.py | 0 .../src/bot_graphql/abc/query_abc.py | 55 ++++- .../src/bot_graphql/bot-graphql.json | 0 .../src/bot_graphql/filter/__init__.py | 0 .../bot_graphql/filter/achievement_filter.py | 14 +- .../bot_graphql/filter/auto_role_filter.py | 13 +- .../filter/auto_role_rule_filter.py | 4 +- .../src/bot_graphql/filter/client_filter.py | 9 +- .../src/bot_graphql/filter/level_filter.py | 9 +- .../src/bot_graphql/filter/page.py | 0 .../src/bot_graphql/filter/server_filter.py | 6 +- .../filter/short_role_name_filter.py | 9 +- .../src/bot_graphql/filter/sort.py | 0 .../src/bot_graphql/filter/user_filter.py | 25 +- .../filter/user_joined_game_server_filter.py | 4 +- .../filter/user_joined_server_filter.py | 14 +- .../user_joined_voice_channel_filter.py | 18 +- .../bot_graphql/filter/user_warning_filter.py | 13 +- .../src/bot_graphql/graphql/achievement.gql | 0 .../src/bot_graphql/graphql/autoRole.gql | 0 .../src/bot_graphql/graphql/autoRoleRule.gql | 0 .../src/bot_graphql/graphql/base.gql | 0 .../src/bot_graphql/graphql/client.gql | 0 .../src/bot_graphql/graphql/discord.gql | 0 .../src/bot_graphql/graphql/featureFlags.gql | 0 .../src/bot_graphql/graphql/knownUser.gql | 0 .../src/bot_graphql/graphql/level.gql | 0 .../src/bot_graphql/graphql/mutation.gql | 0 .../src/bot_graphql/graphql/query.gql | 0 .../src/bot_graphql/graphql/server.gql | 0 .../src/bot_graphql/graphql/serverConfig.gql | 0 .../src/bot_graphql/graphql/shortRoleName.gql | 0 .../bot_graphql/graphql/technicianConfig.gql | 0 .../src/bot_graphql/graphql/user.gql | 0 .../graphql/userJoinedGameServer.gql | 0 .../bot_graphql/graphql/userJoinedServer.gql | 0 .../graphql/userJoinedVoiceChannel.gql | 0 .../src/bot_graphql/graphql/userWarning.gql | 0 .../src/bot_graphql/graphql_module.py | 44 +++- .../src/bot_graphql/graphql_service.py | 0 .../src/bot_graphql/model/__init__.py | 0 .../src/bot_graphql/model/discord.py | 0 {kdb-bot => bot}/src/bot_graphql/mutation.py | 4 +- .../src/bot_graphql/mutations/__init__.py | 0 .../mutations/achievement_mutation.py | 18 +- .../mutations/auto_role_mutation.py | 20 +- .../mutations/auto_role_rule_mutation.py | 32 ++- .../bot_graphql/mutations/level_mutation.py | 10 +- .../mutations/server_config_mutation.py | 99 ++++++-- .../mutations/short_role_name_mutation.py | 20 +- .../mutations/technician_config_mutation.py | 43 +++- .../user_joined_game_server_mutation.py | 44 +++- .../bot_graphql/mutations/user_mutation.py | 34 ++- .../src/bot_graphql/queries/__init__.py | 0 .../queries/achievement_attribute_query.py | 0 .../queries/achievement_history_query.py | 0 .../bot_graphql/queries/achievement_query.py | 4 +- .../queries/auto_role_history_query.py | 0 .../bot_graphql/queries/auto_role_query.py | 8 +- .../queries/auto_role_rule_history_query.py | 0 .../queries/auto_role_rule_query.py | 11 +- .../queries/client_history_query.py | 0 .../src/bot_graphql/queries/client_query.py | 4 +- .../bot_graphql/queries/discord/__init__.py | 0 .../queries/discord/channel_query.py | 0 .../queries/discord/discord_query.py | 0 .../queries/discord/discord_user_query.py | 0 .../queries/discord/emoji_query.py | 0 .../queries/discord/guild_query.py | 5 +- .../bot_graphql/queries/discord/role_query.py | 0 .../bot_graphql/queries/game_server_query.py | 0 .../queries/known_user_history_query.py | 0 .../bot_graphql/queries/known_user_query.py | 4 +- .../queries/level_history_query.py | 0 .../src/bot_graphql/queries/level_query.py | 4 +- .../queries/server_config_query.py | 53 ++++- .../queries/server_history_query.py | 0 .../src/bot_graphql/queries/server_query.py | 55 ++++- .../queries/short_role_name_history_query.py | 0 .../queries/short_role_name_query.py | 4 +- .../technician_config_history_query.py | 13 +- .../queries/technician_config_query.py | 25 +- .../technician_id_config_history_query.py | 0 ...echnician_ping_url_config_history_query.py | 0 .../bot_graphql/queries/user_history_query.py | 0 .../user_joined_game_server_history_query.py | 0 .../queries/user_joined_game_server_query.py | 6 +- .../user_joined_server_history_query.py | 0 .../queries/user_joined_server_query.py | 6 +- ...user_joined_voice_channel_history_query.py | 0 .../user_joined_voice_channel_query.py | 10 +- .../src/bot_graphql/queries/user_query.py | 28 ++- .../queries/user_warning_history_query.py | 0 .../bot_graphql/queries/user_warning_query.py | 4 +- {kdb-bot => bot}/src/bot_graphql/query.py | 67 ++++-- {kdb-bot => bot}/src/bot_graphql/schema.py | 4 +- {kdb-bot => bot}/src/modules/__init__.py | 0 .../src/modules/achievements/__init__.py | 0 .../achievement_attribute_resolver.py | 27 ++- .../achievements/achievement_service.py | 72 ++++-- .../modules/achievements/achievements.json | 0 .../achievements/achievements_module.py | 46 +++- .../modules/achievements/commands/__init__.py | 0 .../commands/achievements_group.py | 4 +- .../modules/achievements/events/__init__.py | 0 .../events/achievement_on_message_event.py | 8 +- .../achievement_on_reaction_add_event.py | 10 +- .../achievement_on_reaction_remove_event.py | 10 +- ...achievement_on_voice_state_update_event.py | 9 +- .../modules/achievements/model/__init__.py | 0 .../model/achievement_attribute.py | 0 .../src/modules/auto_role/__init__.py | 0 .../src/modules/auto_role/auto-role.json | 0 .../src/modules/auto_role/auto_role_module.py | 8 +- .../src/modules/auto_role/command/__init__.py | 0 .../auto_role/command/auto_role_group.py | 218 +++++++++++++----- .../src/modules/auto_role/events/__init__.py | 0 .../events/auto_role_on_raw_reaction_add.py | 8 +- .../auto_role_on_raw_reaction_remove.py | 8 +- .../src/modules/auto_role/helper/__init__.py | 0 .../helper/auto_role_reaction_handler.py | 12 +- {kdb-bot => bot}/src/modules/base/__init__.py | 0 {kdb-bot => bot}/src/modules/base/base.json | 0 .../src/modules/base/base_module.py | 40 +++- .../src/modules/base/birthday_watcher.py | 8 +- .../src/modules/base/command/__init__.py | 0 .../src/modules/base/command/afk_command.py | 12 +- .../modules/base/command/game_server_group.py | 96 ++++++-- .../src/modules/base/command/help_command.py | 4 +- .../src/modules/base/command/info_command.py | 5 +- .../base/command/make_coffee_command.py | 0 .../modules/base/command/mass_move_command.py | 4 +- .../src/modules/base/command/ping_command.py | 8 +- .../modules/base/command/presence_command.py | 8 +- .../src/modules/base/command/purge_command.py | 12 +- .../modules/base/command/register_group.py | 15 +- .../src/modules/base/command/submit_group.py | 4 +- .../modules/base/command/unregister_group.py | 8 +- .../src/modules/base/command/user_group.py | 165 +++++++++---- .../src/modules/base/events/__init__.py | 0 .../events/base_on_command_error_event.py | 16 +- .../base/events/base_on_command_event.py | 20 +- .../base/events/base_on_guild_join_event.py | 0 .../base/events/base_on_member_join_event.py | 28 ++- .../events/base_on_member_remove_event.py | 16 +- .../events/base_on_message_delete_event.py | 16 +- .../base/events/base_on_message_event.py | 20 +- .../base/events/base_on_raw_reaction_add.py | 0 .../events/base_on_raw_reaction_remove.py | 0 .../base_on_scheduled_event_update_event.py | 7 +- .../base_on_voice_state_update_event.py | 54 +++-- ...n_voice_state_update_event_help_channel.py | 12 +- ...tate_update_event_scheduled_event_bonus.py | 0 .../src/modules/base/forms/__init__.py | 0 .../src/modules/base/forms/bug_report_form.py | 12 +- .../src/modules/base/forms/complaint_form.py | 8 +- .../src/modules/base/helper/__init__.py | 0 .../base/helper/base_reaction_handler.py | 16 +- .../base/helper/voice_channel_transformer.py | 21 +- .../src/modules/base/model/__init__.py | 0 .../src/modules/base/model/active_event.py | 0 .../src/modules/base/service/__init__.py | 0 .../src/modules/base/service/event_service.py | 12 +- .../base/service/user_warnings_service.py | 103 +++++++-- .../src/modules/base/thread/__init__.py | 0 .../src/modules/boot_log/__init__.py | 0 .../src/modules/boot_log/boot-log.json | 0 .../modules/boot_log/boot_log_extension.py | 4 +- .../src/modules/boot_log/boot_log_module.py | 12 +- .../boot_log/boot_log_on_ready_event.py | 17 +- .../src/modules/config/__init__.py | 0 .../src/modules/config/config.json | 0 .../src/modules/config/config_extension.py | 4 +- .../src/modules/config/config_module.py | 8 +- .../src/modules/config/events/__init__.py | 0 .../config/events/config_on_ready_event.py | 4 +- .../src/modules/config/service/__init__.py | 0 .../src/modules/database/__init__.py | 0 .../src/modules/database/database.json | 0 .../modules/database/database_extension.py | 4 +- .../src/modules/database/database_module.py | 12 +- .../database/database_on_ready_event.py | 13 +- .../src/modules/level/__init__.py | 0 .../src/modules/level/command/__init__.py | 0 .../src/modules/level/command/level_group.py | 185 +++++++++++---- .../modules/level/configuration/__init__.py | 0 .../configuration/default_level_settings.py | 0 .../src/modules/level/default-level.json | 0 .../src/modules/level/events/__init__.py | 0 .../events/level_on_member_join_event.py | 12 +- .../level/events/level_on_message_event.py | 12 +- .../events/level_on_raw_reaction_add_event.py | 8 +- .../level_on_raw_reaction_remove_event.py | 8 +- .../level_on_voice_state_update_event.py | 12 +- {kdb-bot => bot}/src/modules/level/level.json | 0 .../src/modules/level/level_module.py | 33 ++- .../src/modules/level/level_seeder.py | 41 +++- .../src/modules/level/service/__init__.py | 0 .../modules/level/service/level_service.py | 44 +++- .../src/modules/permission/__init__.py | 0 .../src/modules/permission/abc/__init__.py | 0 .../permission/abc/permission_service_abc.py | 0 .../src/modules/permission/permission.json | 0 .../modules/permission/permission_module.py | 8 +- .../modules/permission/service/__init__.py | 0 .../permission/service/permission_service.py | 20 +- .../src/modules/short_role_name/__init__.py | 0 .../short_role_name/events/__init__.py | 0 .../short_role_name_on_member_update_event.py | 4 +- .../short_role_name/service/__init__.py | 0 .../service/short_role_name_service.py | 16 +- .../short_role_name/short-role-name.json | 0 .../short_role_name_check_command.py | 16 +- .../short_role_name/short_role_name_module.py | 21 +- .../short_role_name/short_role_name_seeder.py | 0 .../src/modules/special_offers/__init__.py | 0 .../special_offers/special-offers.json | 0 .../special_offers/special_offers_module.py | 8 +- .../special_offers/steam_offer_watcher.py | 53 ++++- .../src/modules/technician/__init__.py | 0 .../src/modules/technician/api_key_seeder.py | 4 +- .../modules/technician/command/__init__.py | 0 .../technician/command/api_key_group.py | 36 ++- .../modules/technician/command/log_command.py | 5 +- .../technician/command/restart_command.py | 4 +- .../technician/command/shutdown_command.py | 4 +- .../technician/command/sync_xp_command.py | 58 +++-- .../src/modules/technician/technician.json | 0 .../modules/technician/technician_module.py | 8 +- .../tools/checks/UserJoinedVoiceChannel.json | 0 {kdb-bot => bot}/tools/checks/__init__.py | 0 {kdb-bot => bot}/tools/checks/checks.json | 0 .../tools/checks/get_ontime_overlaps.py | 0 .../tools/get_version/__init__.py | 0 .../tools/get_version/application.py | 0 .../tools/get_version/get-version.json | 0 {kdb-bot => bot}/tools/get_version/main.py | 0 {kdb-bot => bot}/tools/get_version/startup.py | 8 +- {kdb-bot => bot}/tools/post_build/__init__.py | 0 .../tools/post_build/application.py | 0 .../tools/post_build/appsettings.json | 0 {kdb-bot => bot}/tools/post_build/main.py | 0 .../tools/post_build/post-build.json | 0 .../tools/post_build/post_build_settings.py | 8 +- .../tools/post_build/service/__init__.py | 0 .../tools/post_build/service/dependencies.py | 4 +- .../tools/post_build/service/remove_config.py | 0 {kdb-bot => bot}/tools/post_build/startup.py | 8 +- .../tools/set_version/__init__.py | 0 .../tools/set_version/application.py | 50 +++- .../tools/set_version/git_service.py | 0 {kdb-bot => bot}/tools/set_version/main.py | 0 .../tools/set_version/set-version.json | 0 {kdb-bot => bot}/tools/set_version/startup.py | 8 +- .../set_version/version_setter_service.py | 18 +- kdb-bot/LICENSE | 9 - kdb-bot/README.md | 2 - kdb-bot/cpl-workspace.json | 46 ---- kdb-bot/docker | 1 - kdb-bot/dockerfile | 21 -- kdb-bot/pyproject.toml | 2 - kdb-bot/src/bot/config | 1 - kdb-bot/src/bot_api/config | 1 - {kdb-web => web}/.browserslistrc | 0 {kdb-web => web}/.editorconfig | 0 {kdb-web => web}/.gitignore | 0 {kdb-web => web}/.prettierrc | 0 {kdb-web => web}/README.md | 0 {kdb-web => web}/angular.json | 0 {kdb-web => web}/dockerfile | 0 {kdb-web => web}/karma.conf.js | 0 {kdb-web => web}/nginx.conf.template | 0 {kdb-web => web}/package-lock.json | 0 {kdb-web => web}/package.json | 0 .../src/app/app-routing.module.ts | 0 {kdb-web => web}/src/app/app.component.html | 0 {kdb-web => web}/src/app/app.component.scss | 0 .../src/app/app.component.spec.ts | 0 {kdb-web => web}/src/app/app.component.ts | 0 {kdb-web => web}/src/app/app.module.ts | 0 .../src/app/base/component-with-table.spec.ts | 0 .../src/app/base/component-with-table.ts | 0 .../error/not-found/not-found.component.html | 0 .../error/not-found/not-found.component.scss | 0 .../not-found/not-found.component.spec.ts | 0 .../error/not-found/not-found.component.ts | 0 .../components/footer/footer.component.html | 0 .../components/footer/footer.component.scss | 0 .../footer/footer.component.spec.ts | 0 .../app/components/footer/footer.component.ts | 0 .../components/header/header.component.html | 0 .../components/header/header.component.scss | 0 .../header/header.component.spec.ts | 0 .../app/components/header/header.component.ts | 0 .../components/sidebar/sidebar.component.html | 0 .../components/sidebar/sidebar.component.scss | 0 .../sidebar/sidebar.component.spec.ts | 0 .../components/sidebar/sidebar.component.ts | 0 .../components/spinner/spinner.component.html | 0 .../components/spinner/spinner.component.scss | 0 .../spinner/spinner.component.spec.ts | 0 .../components/spinner/spinner.component.ts | 0 .../app/models/auth/admin-update-user.dto.ts | 0 .../models/auth/auth-error-messages.enum.ts | 0 .../src/app/models/auth/auth-roles.enum.ts | 0 .../app/models/auth/auth-user-atr-errors.ts | 0 .../src/app/models/auth/auth-user.dto.ts | 0 .../app/models/auth/discord-auth-url.dto.ts | 0 .../src/app/models/auth/email-string.dto.ts | 0 .../src/app/models/auth/oauth.dto.ts | 0 .../auth/register-error-messages.enum.ts | 0 .../src/app/models/auth/reset-password.dto.ts | 0 .../src/app/models/auth/token.dto.ts | 0 .../src/app/models/auth/update-user.dto.ts | 0 .../src/app/models/config/api-version.ts | 0 .../src/app/models/config/app-settings.ts | 0 .../app/models/config/feature-flags.model.ts | 0 .../app/models/config/server-config.model.ts | 0 .../src/app/models/config/settings.dto.ts | 0 .../app/models/config/software-version.dto.ts | 0 .../src/app/models/config/software-version.ts | 0 .../models/config/technician-config.model.ts | 0 .../src/app/models/data/achievement.model.ts | 0 .../src/app/models/data/auto_role.model.ts | 0 .../src/app/models/data/client.model.ts | 0 .../src/app/models/data/data.model.ts | 0 .../src/app/models/data/discord.model.ts | 0 .../src/app/models/data/level.model.ts | 0 .../src/app/models/data/server.model.ts | 0 .../app/models/data/short_role_name.model.ts | 0 .../src/app/models/data/user.model.ts | 0 .../data/user_joined_game_server.model.ts | 0 .../models/data/user_joined_server.model.ts | 0 .../data/user_joined_voice_channel.model.ts | 0 .../src/app/models/data/user_warning.model.ts | 0 .../src/app/models/error/error-dto.ts | 0 .../models/error/service-error-code.enum.ts | 0 .../app/models/graphql/filter/page.model.ts | 0 .../app/models/graphql/filter/sort.model.ts | 0 .../src/app/models/graphql/mutations.model.ts | 0 .../src/app/models/graphql/queries.model.ts | 0 .../src/app/models/graphql/query.model.ts | 0 .../src/app/models/graphql/result.model.ts | 0 .../src/app/models/graphql/variables.model.ts | 0 .../auth-user-select-criterion.dto.ts | 0 .../get-filtered-auth-users-result.dto.ts | 0 .../selection/select-criterion.model.ts | 0 .../app/models/utils/confirmation-dialog.ts | 0 .../src/app/models/utils/toast-options.ts | 0 {kdb-web => web}/src/app/models/view/theme.ts | 0 .../src/app/models/view/themes.enum.ts | 0 .../auth-users/auth-user-routing.module.ts | 0 .../admin/auth-users/auth-user.module.ts | 0 .../auth-user/auth-user.component.html | 0 .../auth-user/auth-user.component.scss | 0 .../auth-user/auth-user.component.spec.ts | 0 .../auth-user/auth-user.component.ts | 0 .../settings/settings.component.html | 0 .../settings/settings.component.scss | 0 .../settings/settings.component.spec.ts | 0 .../components/settings/settings.component.ts | 0 .../admin/settings/settings-routing.module.ts | 0 .../modules/admin/settings/settings.module.ts | 0 .../app/modules/auth/auth-routing.module.ts | 0 .../src/app/modules/auth/auth.module.ts | 0 .../auth-footer/auth-footer.component.html | 0 .../auth-footer/auth-footer.component.scss | 0 .../auth-footer/auth-footer.component.spec.ts | 0 .../auth-footer/auth-footer.component.ts | 0 .../auth-header/auth-header.component.html | 0 .../auth-header/auth-header.component.scss | 0 .../auth-header/auth-header.component.spec.ts | 0 .../auth-header/auth-header.component.ts | 0 .../forget-password.component.html | 0 .../forget-password.component.scss | 0 .../forget-password.component.spec.ts | 0 .../forget-password.component.ts | 0 .../components/login/login.component.html | 0 .../components/login/login.component.scss | 0 .../components/login/login.component.spec.ts | 0 .../auth/components/login/login.component.ts | 0 .../registration/registration.component.html | 0 .../registration/registration.component.scss | 0 .../registration.component.spec.ts | 0 .../registration/registration.component.ts | 0 .../shared/base/hideable-component.spec.ts | 0 .../modules/shared/base/hideable-component.ts | 0 .../multi-select-columns.component.html | 0 .../multi-select-columns.component.scss | 0 .../multi-select-columns.component.spec.ts | 0 .../multi-select-columns.component.ts | 0 .../config-list/config-list.component.html | 0 .../config-list/config-list.component.scss | 0 .../config-list/config-list.component.spec.ts | 0 .../config-list/config-list.component.ts | 0 .../feature-flag-list.component.html | 0 .../feature-flag-list.component.scss | 0 .../feature-flag-list.component.spec.ts | 0 .../feature-flag-list.component.ts | 0 .../hideable-column.component.html | 0 .../hideable-column.component.scss | 0 .../hideable-column.component.spec.ts | 0 .../hideable-column.component.ts | 0 .../hideable-header.component.html | 0 .../hideable-header.component.scss | 0 .../hideable-header.component.spec.ts | 0 .../hideable-header.component.ts | 0 .../history-btn/history-btn.component.html | 0 .../history-btn/history-btn.component.scss | 0 .../history-btn/history-btn.component.spec.ts | 0 .../history-btn/history-btn.component.ts | 0 .../shared/guards/auth/auth.guard.spec.ts | 0 .../modules/shared/guards/auth/auth.guard.ts | 0 .../modules/shared/pipes/auth-role.pipe.ts | 0 .../modules/shared/pipes/bool.pipe.spec.ts | 0 .../src/app/modules/shared/pipes/bool.pipe.ts | 0 .../modules/shared/pipes/ip-address.pipe.ts | 0 .../src/app/modules/shared/shared.module.ts | 0 .../change-password-routing.module.ts | 0 .../change-password/change-password.module.ts | 0 .../change-password.component.html | 0 .../change-password.component.scss | 0 .../change-password.component.spec.ts | 0 .../change-password.component.ts | 0 .../dashboard/dashboard.component.html | 0 .../dashboard/dashboard.component.scss | 0 .../dashboard/dashboard.component.spec.ts | 0 .../dashboard/dashboard.component.ts | 0 .../dashboard/dashboard-routing.module.ts | 0 .../view/dashboard/dashboard.module.ts | 0 .../achievements-routing.module.ts | 0 .../achievements/achievements.module.ts | 0 .../achievement/achievement.component.html | 0 .../achievement/achievement.component.scss | 0 .../achievement/achievement.component.spec.ts | 0 .../achievement/achievement.component.ts | 0 .../auto-role/auto-role-routing.module.ts | 0 .../view/server/auto-role/auto-role.module.ts | 0 .../auto-roles-rules.component.html | 0 .../auto-roles-rules.component.scss | 0 .../auto-roles-rules.component.spec.ts | 0 .../auto-roles-rules.component.ts | 0 .../auto-roles/auto-roles.component.html | 0 .../auto-roles/auto-roles.component.scss | 0 .../auto-roles/auto-roles.component.spec.ts | 0 .../auto-roles/auto-roles.component.ts | 0 .../components/config/config.component.html | 0 .../components/config/config.component.scss | 0 .../config/config.component.spec.ts | 0 .../components/config/config.component.ts | 0 .../server/config/config-routing.module.ts | 0 .../view/server/config/config.module.ts | 0 .../components/levels/levels.component.html | 0 .../components/levels/levels.component.scss | 0 .../levels/levels.component.spec.ts | 0 .../components/levels/levels.component.ts | 0 .../server/levels/levels-routing.module.ts | 0 .../view/server/levels/levels.module.ts | 0 .../server/members/members.component.html | 0 .../server/members/members.component.scss | 0 .../server/members/members.component.spec.ts | 0 .../view/server/members/members.component.ts | 0 .../server/profile/profile.component.html | 0 .../server/profile/profile.component.scss | 0 .../server/profile/profile.component.spec.ts | 0 .../view/server/profile/profile.component.ts | 0 .../components/client/client.component.html | 0 .../components/client/client.component.scss | 0 .../client/client.component.spec.ts | 0 .../components/client/client.component.ts | 0 .../server-dashboard.component.html | 0 .../server-dashboard.component.scss | 0 .../server-dashboard.component.spec.ts | 0 .../server-dashboard.component.ts | 0 .../view/server/server-routing.module.ts | 0 .../app/modules/view/server/server.module.ts | 0 .../short-role-names.component.html | 0 .../short-role-names.component.scss | 0 .../short-role-names.component.spec.ts | 0 .../short-role-names.component.ts | 0 .../short-role-name-routing.module.ts | 0 .../short-role-name/short-role-name.module.ts | 0 .../user-settings.component.html | 0 .../user-settings.component.scss | 0 .../user-settings.component.spec.ts | 0 .../user-settings/user-settings.component.ts | 0 .../user-settings-routing.module.ts | 0 .../user-settings/user-settings.module.ts | 0 .../app/services/auth/auth.service.spec.ts | 0 .../src/app/services/auth/auth.service.ts | 0 .../confirmation-dialog.service.spec.ts | 0 .../confirmation-dialog.service.ts | 0 .../app/services/data/data.service.spec.ts | 0 .../src/app/services/data/data.service.ts | 0 .../error-handler.service.spec.ts | 0 .../error-handler/error-handler.service.ts | 0 .../src/app/services/gui/gui.service.spec.ts | 0 .../src/app/services/gui/gui.service.ts | 0 .../src/app/services/server.service.spec.ts | 0 .../src/app/services/server.service.ts | 0 .../settings/settings.service.spec.ts | 0 .../app/services/settings/settings.service.ts | 0 .../services/sidebar/sidebar.service.spec.ts | 0 .../app/services/sidebar/sidebar.service.ts | 0 .../services/socket/socket.service.spec.ts | 0 .../src/app/services/socket/socket.service.ts | 0 .../services/spinner/spinner.service.spec.ts | 0 .../app/services/spinner/spinner.service.ts | 0 .../app/services/theme/theme.service.spec.ts | 0 .../src/app/services/theme/theme.service.ts | 0 .../app/services/toast/toast.service.spec.ts | 0 .../src/app/services/toast/toast.service.ts | 0 {kdb-web => web}/src/assets/config.json | 0 {kdb-web => web}/src/assets/i18n/de.json | 0 {kdb-web => web}/src/assets/i18n/en.json | 0 .../src/assets/images/favicon.ico | Bin {kdb-web => web}/src/assets/version.json | 0 .../environments/environment.development.ts | 0 .../src/environments/environment.prod.ts | 0 .../src/environments/environment.staging.ts | 0 .../src/environments/environment.ts | 0 {kdb-web => web}/src/favicon.ico | Bin {kdb-web => web}/src/index.html | 0 {kdb-web => web}/src/main.ts | 0 {kdb-web => web}/src/polyfills.ts | 0 {kdb-web => web}/src/styles.scss | 0 {kdb-web => web}/src/styles/constants.scss | 0 .../src/styles/primeng-fixes.scss | 0 .../src/styles/themes/default-dark-theme.scss | 0 .../styles/themes/default-light-theme.scss | 0 .../styles/themes/sh-edraft-dark-theme.scss | 0 .../styles/themes/sh-edraft-light-theme.scss | 0 {kdb-web => web}/src/test.ts | 0 {kdb-web => web}/tsconfig.app.json | 0 {kdb-web => web}/tsconfig.json | 0 {kdb-web => web}/tsconfig.spec.json | 0 {kdb-web => web}/update-version.ts | 0 807 files changed, 3801 insertions(+), 1297 deletions(-) rename {kdb-bot => bot}/.cpl/schematic_db_table.py (100%) rename {kdb-bot => bot}/.cpl/schematic_migration.py (100%) rename {kdb-bot => bot}/.cpl/schematic_query.py (100%) rename {kdb-bot => bot}/src/bot/__init__.py (100%) rename {kdb-bot => bot}/src/bot/application.py (87%) rename {kdb-bot => bot}/src/bot/bot (100%) rename {kdb-bot => bot}/src/bot/bot.json (100%) rename {kdb-bot => bot}/src/bot/extension/__init__.py (100%) rename {kdb-bot => bot}/src/bot/extension/init_bot_extension.py (79%) rename {kdb-bot => bot}/src/bot/main.py (100%) rename {kdb-bot => bot}/src/bot/module_list.py (100%) rename {kdb-bot => bot}/src/bot/startup.py (95%) rename {kdb-bot => bot}/src/bot/startup_discord_extension.py (67%) rename {kdb-bot => bot}/src/bot/startup_migration_extension.py (52%) rename {kdb-bot => bot}/src/bot/startup_module_extension.py (86%) rename {kdb-bot => bot}/src/bot/startup_settings_extension.py (64%) rename {kdb-bot => bot}/src/bot/translation/de.json (100%) rename {kdb-bot => bot}/src/bot_api/__init__.py (100%) rename {kdb-bot => bot}/src/bot_api/abc/__init__.py (100%) rename {kdb-bot => bot}/src/bot_api/abc/auth_service_abc.py (92%) rename {kdb-bot => bot}/src/bot_api/abc/dto_abc.py (100%) rename {kdb-bot => bot}/src/bot_api/abc/select_criteria_abc.py (68%) rename {kdb-bot => bot}/src/bot_api/abc/transformer_abc.py (100%) rename {kdb-bot => bot}/src/bot_api/api.py (92%) rename {kdb-bot => bot}/src/bot_api/api_module.py (86%) rename {kdb-bot => bot}/src/bot_api/api_thread.py (100%) rename {kdb-bot => bot}/src/bot_api/app_api_extension.py (93%) rename {kdb-bot => bot}/src/bot_api/bot-api.json (100%) rename {kdb-bot => bot}/src/bot_api/configuration/__init__.py (100%) rename {kdb-bot => bot}/src/bot_api/configuration/api_settings.py (100%) rename {kdb-bot => bot}/src/bot_api/configuration/authentication_settings.py (89%) rename {kdb-bot => bot}/src/bot_api/configuration/discord_authentication_settings.py (100%) rename {kdb-bot => bot}/src/bot_api/configuration/frontend_settings.py (100%) rename {kdb-bot => bot}/src/bot_api/controller/__init__.py (100%) rename {kdb-bot => bot}/src/bot_api/controller/auth_controller.py (83%) rename {kdb-bot => bot}/src/bot_api/controller/auth_discord_controller.py (100%) rename {kdb-bot => bot}/src/bot_api/controller/graphql_controller.py (100%) rename {kdb-bot => bot}/src/bot_api/controller/gui_controller.py (100%) rename {kdb-bot => bot}/src/bot_api/event/__init__.py (100%) rename {kdb-bot => bot}/src/bot_api/event/bot_api_on_ready_event.py (100%) rename {kdb-bot => bot}/src/bot_api/exception/__init__.py (100%) rename {kdb-bot => bot}/src/bot_api/exception/service_error_code_enum.py (100%) rename {kdb-bot => bot}/src/bot_api/exception/service_exception.py (100%) rename {kdb-bot => bot}/src/bot_api/filter/__init__.py (100%) rename {kdb-bot => bot}/src/bot_api/filter/auth_user_select_criteria.py (80%) rename {kdb-bot => bot}/src/bot_api/filter/discord/__init__.py (100%) rename {kdb-bot => bot}/src/bot_api/filter/discord/server_select_criteria.py (72%) rename {kdb-bot => bot}/src/bot_api/json_processor.py (100%) rename {kdb-bot => bot}/src/bot_api/logging/__init__.py (100%) rename {kdb-bot => bot}/src/bot_api/logging/api_logger.py (100%) rename {kdb-bot => bot}/src/bot_api/model/__init__.py (100%) rename {kdb-bot => bot}/src/bot_api/model/auth_user_dto.py (100%) rename {kdb-bot => bot}/src/bot_api/model/auth_user_filtered_result_dto.py (100%) rename {kdb-bot => bot}/src/bot_api/model/discord/__init__.py (100%) rename {kdb-bot => bot}/src/bot_api/model/discord/server_dto.py (100%) rename {kdb-bot => bot}/src/bot_api/model/discord/server_filtered_result_dto.py (100%) rename {kdb-bot => bot}/src/bot_api/model/email_string_dto.py (100%) rename {kdb-bot => bot}/src/bot_api/model/error_dto.py (87%) rename {kdb-bot => bot}/src/bot_api/model/o_auth_dto.py (100%) rename {kdb-bot => bot}/src/bot_api/model/reset_password_dto.py (100%) rename {kdb-bot => bot}/src/bot_api/model/settings_dto.py (100%) rename {kdb-bot => bot}/src/bot_api/model/token_dto.py (82%) rename {kdb-bot => bot}/src/bot_api/model/update_auth_user_dto.py (89%) rename {kdb-bot => bot}/src/bot_api/model/user_dto.py (100%) rename {kdb-bot => bot}/src/bot_api/model/version_dto.py (100%) rename {kdb-bot => bot}/src/bot_api/route/__init__.py (100%) rename {kdb-bot => bot}/src/bot_api/route/route.py (84%) rename {kdb-bot => bot}/src/bot_api/service/__init__.py (100%) rename {kdb-bot => bot}/src/bot_api/service/auth_service.py (82%) rename {kdb-bot => bot}/src/bot_api/service/discord_service.py (83%) rename {kdb-bot => bot}/src/bot_api/transformer/__init__.py (100%) rename {kdb-bot => bot}/src/bot_api/transformer/auth_user_transformer.py (84%) rename {kdb-bot => bot}/src/bot_api/transformer/server_transformer.py (81%) rename {kdb-bot => bot}/src/bot_core/__init__.py (100%) rename {kdb-bot => bot}/src/bot_core/abc/__init__.py (100%) rename {kdb-bot => bot}/src/bot_core/abc/client_utils_abc.py (86%) rename {kdb-bot => bot}/src/bot_core/abc/custom_file_logger_abc.py (92%) rename {kdb-bot => bot}/src/bot_core/abc/message_service_abc.py (92%) rename {kdb-bot => bot}/src/bot_core/abc/module_abc.py (100%) rename {kdb-bot => bot}/src/bot_core/abc/task_abc.py (85%) rename {kdb-bot => bot}/src/bot_core/bot-core.json (100%) rename {kdb-bot => bot}/src/bot_core/configuration/__init__.py (100%) rename {kdb-bot => bot}/src/bot_core/configuration/bot_logging_settings.py (100%) rename {kdb-bot => bot}/src/bot_core/configuration/feature_flags_enum.py (100%) rename {kdb-bot => bot}/src/bot_core/configuration/feature_flags_settings.py (100%) rename {kdb-bot => bot}/src/bot_core/configuration/file_logging_settings.py (78%) rename {kdb-bot => bot}/src/bot_core/core_extension/__init__.py (100%) rename {kdb-bot => bot}/src/bot_core/core_extension/core_extension.py (96%) rename {kdb-bot => bot}/src/bot_core/core_extension/core_extension_module.py (67%) rename {kdb-bot => bot}/src/bot_core/core_extension/core_extension_on_ready_event.py (100%) rename {kdb-bot => bot}/src/bot_core/core_module.py (87%) rename {kdb-bot => bot}/src/bot_core/events/__init__.py (100%) rename {kdb-bot => bot}/src/bot_core/events/core_on_ready_event.py (100%) rename {kdb-bot => bot}/src/bot_core/exception/__init__.py (100%) rename {kdb-bot => bot}/src/bot_core/exception/check_error.py (100%) rename {kdb-bot => bot}/src/bot_core/helper/__init__.py (100%) rename {kdb-bot => bot}/src/bot_core/helper/command_checks.py (85%) rename {kdb-bot => bot}/src/bot_core/helper/event_checks.py (100%) rename {kdb-bot => bot}/src/bot_core/helper/log_message_helper.py (100%) rename {kdb-bot => bot}/src/bot_core/logging/__init__.py (100%) rename {kdb-bot => bot}/src/bot_core/logging/command_logger.py (100%) rename {kdb-bot => bot}/src/bot_core/logging/database_logger.py (100%) rename {kdb-bot => bot}/src/bot_core/logging/message_logger.py (100%) rename {kdb-bot => bot}/src/bot_core/logging/task_logger.py (100%) rename {kdb-bot => bot}/src/bot_core/pipes/__init__.py (100%) rename {kdb-bot => bot}/src/bot_core/pipes/date_time_offset_pipe.py (100%) rename {kdb-bot => bot}/src/bot_core/service/__init__.py (100%) rename {kdb-bot => bot}/src/bot_core/service/client_utils_service.py (87%) rename {kdb-bot => bot}/src/bot_core/service/config_service.py (89%) rename {kdb-bot => bot}/src/bot_core/service/data_integrity_service.py (77%) rename {kdb-bot => bot}/src/bot_core/service/message_service.py (70%) rename {kdb-bot => bot}/src/bot_data/__init__.py (100%) rename {kdb-bot => bot}/src/bot_data/abc/__init__.py (100%) rename {kdb-bot => bot}/src/bot_data/abc/achievement_repository_abc.py (91%) rename {kdb-bot => bot}/src/bot_data/abc/api_key_repository_abc.py (100%) rename {kdb-bot => bot}/src/bot_data/abc/auth_user_repository_abc.py (94%) rename {kdb-bot => bot}/src/bot_data/abc/auto_role_repository_abc.py (100%) rename {kdb-bot => bot}/src/bot_data/abc/client_repository_abc.py (93%) rename {kdb-bot => bot}/src/bot_data/abc/data_seeder_abc.py (100%) rename {kdb-bot => bot}/src/bot_data/abc/game_server_repository_abc.py (100%) rename {kdb-bot => bot}/src/bot_data/abc/history_table_abc.py (100%) rename {kdb-bot => bot}/src/bot_data/abc/known_user_repository_abc.py (100%) rename {kdb-bot => bot}/src/bot_data/abc/level_repository_abc.py (100%) rename {kdb-bot => bot}/src/bot_data/abc/migration_abc.py (100%) rename {kdb-bot => bot}/src/bot_data/abc/server_config_repository_abc.py (64%) rename {kdb-bot => bot}/src/bot_data/abc/server_repository_abc.py (100%) rename {kdb-bot => bot}/src/bot_data/abc/short_role_name_repository_abc.py (100%) rename {kdb-bot => bot}/src/bot_data/abc/steam_special_offer_repository_abc.py (100%) rename {kdb-bot => bot}/src/bot_data/abc/table_with_id_abc.py (100%) rename {kdb-bot => bot}/src/bot_data/abc/technician_config_repository_abc.py (79%) rename {kdb-bot => bot}/src/bot_data/abc/user_game_ident_repository_abc.py (100%) rename {kdb-bot => bot}/src/bot_data/abc/user_joined_game_server_repository_abc.py (51%) rename {kdb-bot => bot}/src/bot_data/abc/user_joined_server_repository_abc.py (76%) rename {kdb-bot => bot}/src/bot_data/abc/user_joined_voice_channel_repository_abc.py (50%) rename {kdb-bot => bot}/src/bot_data/abc/user_message_count_per_hour_repository_abc.py (91%) rename {kdb-bot => bot}/src/bot_data/abc/user_repository_abc.py (81%) rename {kdb-bot => bot}/src/bot_data/abc/user_warnings_repository_abc.py (100%) rename {kdb-bot => bot}/src/bot_data/bot-data.json (100%) rename {kdb-bot => bot}/src/bot_data/data_module.py (74%) rename {kdb-bot => bot}/src/bot_data/db_context.py (100%) rename {kdb-bot => bot}/src/bot_data/filtered_result.py (100%) rename {kdb-bot => bot}/src/bot_data/migration/__init__.py (100%) rename {kdb-bot => bot}/src/bot_data/migration/achievements_migration.py (84%) rename {kdb-bot => bot}/src/bot_data/migration/api_key_migration.py (100%) rename {kdb-bot => bot}/src/bot_data/migration/api_migration.py (100%) rename {kdb-bot => bot}/src/bot_data/migration/auto_role_fix1_migration.py (100%) rename {kdb-bot => bot}/src/bot_data/migration/auto_role_migration.py (100%) rename {kdb-bot => bot}/src/bot_data/migration/birthday_migration.py (100%) rename {kdb-bot => bot}/src/bot_data/migration/config_feature_flags_migration.py (74%) rename {kdb-bot => bot}/src/bot_data/migration/config_migration.py (100%) rename {kdb-bot => bot}/src/bot_data/migration/db_history_migration.py (100%) rename {kdb-bot => bot}/src/bot_data/migration/db_history_scripts/api_keys.sql (100%) rename {kdb-bot => bot}/src/bot_data/migration/db_history_scripts/auth_user_users_relation.sql (100%) rename {kdb-bot => bot}/src/bot_data/migration/db_history_scripts/auth_users.sql (100%) rename {kdb-bot => bot}/src/bot_data/migration/db_history_scripts/auto_role_rules.sql (100%) rename {kdb-bot => bot}/src/bot_data/migration/db_history_scripts/auto_roles.sql (100%) rename {kdb-bot => bot}/src/bot_data/migration/db_history_scripts/clients.sql (100%) rename {kdb-bot => bot}/src/bot_data/migration/db_history_scripts/config/server.sql (100%) rename {kdb-bot => bot}/src/bot_data/migration/db_history_scripts/config/server_afk_channels.sql (100%) rename {kdb-bot => bot}/src/bot_data/migration/db_history_scripts/config/server_team_roles.sql (100%) rename {kdb-bot => bot}/src/bot_data/migration/db_history_scripts/config/technician.sql (100%) rename {kdb-bot => bot}/src/bot_data/migration/db_history_scripts/config/technician_ids.sql (100%) rename {kdb-bot => bot}/src/bot_data/migration/db_history_scripts/config/technician_ping_urls.sql (100%) rename {kdb-bot => bot}/src/bot_data/migration/db_history_scripts/game_servers.sql (100%) rename {kdb-bot => bot}/src/bot_data/migration/db_history_scripts/known_users.sql (100%) rename {kdb-bot => bot}/src/bot_data/migration/db_history_scripts/levels.sql (100%) rename {kdb-bot => bot}/src/bot_data/migration/db_history_scripts/servers.sql (100%) rename {kdb-bot => bot}/src/bot_data/migration/db_history_scripts/short_rule_names.sql (100%) rename {kdb-bot => bot}/src/bot_data/migration/db_history_scripts/user_game_idents.sql (100%) rename {kdb-bot => bot}/src/bot_data/migration/db_history_scripts/user_joined_game_servers.sql (100%) rename {kdb-bot => bot}/src/bot_data/migration/db_history_scripts/user_joined_servers.sql (100%) rename {kdb-bot => bot}/src/bot_data/migration/db_history_scripts/user_joined_voice_channel.sql (100%) rename {kdb-bot => bot}/src/bot_data/migration/db_history_scripts/user_message_count_per_hour.sql (100%) rename {kdb-bot => bot}/src/bot_data/migration/db_history_scripts/user_warnings.sql (100%) rename {kdb-bot => bot}/src/bot_data/migration/db_history_scripts/users.sql (100%) rename {kdb-bot => bot}/src/bot_data/migration/default_role_migration.py (100%) rename {kdb-bot => bot}/src/bot_data/migration/fix_updates_migration.py (93%) rename {kdb-bot => bot}/src/bot_data/migration/fix_user_history_migration.py (100%) rename {kdb-bot => bot}/src/bot_data/migration/initial_migration.py (100%) rename {kdb-bot => bot}/src/bot_data/migration/level_migration.py (100%) rename {kdb-bot => bot}/src/bot_data/migration/remove_stats_migration.py (100%) rename {kdb-bot => bot}/src/bot_data/migration/short_role_name_migration.py (100%) rename {kdb-bot => bot}/src/bot_data/migration/short_role_name_only_highest_migration.py (100%) rename {kdb-bot => bot}/src/bot_data/migration/stats_migration.py (100%) rename {kdb-bot => bot}/src/bot_data/migration/steam_special_offer_migration.py (100%) rename {kdb-bot => bot}/src/bot_data/migration/user_joined_game_server_migration.py (100%) rename {kdb-bot => bot}/src/bot_data/migration/user_message_count_per_hour_migration.py (100%) rename {kdb-bot => bot}/src/bot_data/migration/user_warning_migration.py (100%) rename {kdb-bot => bot}/src/bot_data/model/__init__.py (100%) rename {kdb-bot => bot}/src/bot_data/model/achievement.py (97%) rename {kdb-bot => bot}/src/bot_data/model/achievement_history.py (100%) rename {kdb-bot => bot}/src/bot_data/model/api_key.py (95%) rename {kdb-bot => bot}/src/bot_data/model/auth_role_enum.py (100%) rename {kdb-bot => bot}/src/bot_data/model/auth_user.py (98%) rename {kdb-bot => bot}/src/bot_data/model/auth_user_users_relation.py (95%) rename {kdb-bot => bot}/src/bot_data/model/auto_role.py (96%) rename {kdb-bot => bot}/src/bot_data/model/auto_role_history.py (100%) rename {kdb-bot => bot}/src/bot_data/model/auto_role_rule.py (96%) rename {kdb-bot => bot}/src/bot_data/model/auto_role_rule_history.py (100%) rename {kdb-bot => bot}/src/bot_data/model/client.py (97%) rename {kdb-bot => bot}/src/bot_data/model/client_history.py (100%) rename {kdb-bot => bot}/src/bot_data/model/game_server.py (96%) rename {kdb-bot => bot}/src/bot_data/model/known_user.py (93%) rename {kdb-bot => bot}/src/bot_data/model/known_user_history.py (100%) rename {kdb-bot => bot}/src/bot_data/model/level.py (96%) rename {kdb-bot => bot}/src/bot_data/model/level_history.py (100%) rename {kdb-bot => bot}/src/bot_data/model/migration_history.py (100%) rename {kdb-bot => bot}/src/bot_data/model/server.py (95%) rename {kdb-bot => bot}/src/bot_data/model/server_afk_channel_ids_config.py (94%) rename {kdb-bot => bot}/src/bot_data/model/server_config.py (98%) rename {kdb-bot => bot}/src/bot_data/model/server_config_history.py (96%) rename {kdb-bot => bot}/src/bot_data/model/server_history.py (100%) rename {kdb-bot => bot}/src/bot_data/model/server_team_role_ids_config.py (95%) rename {kdb-bot => bot}/src/bot_data/model/short_role_name.py (96%) rename {kdb-bot => bot}/src/bot_data/model/short_role_name_history.py (100%) rename {kdb-bot => bot}/src/bot_data/model/short_role_name_position_enum.py (100%) rename {kdb-bot => bot}/src/bot_data/model/steam_special_offer.py (96%) rename {kdb-bot => bot}/src/bot_data/model/team_member_type_enum.py (100%) rename {kdb-bot => bot}/src/bot_data/model/technician_config.py (97%) rename {kdb-bot => bot}/src/bot_data/model/technician_config_history.py (100%) rename {kdb-bot => bot}/src/bot_data/model/technician_id_config.py (94%) rename {kdb-bot => bot}/src/bot_data/model/technician_id_config_history.py (100%) rename {kdb-bot => bot}/src/bot_data/model/technician_ping_url_config.py (94%) rename {kdb-bot => bot}/src/bot_data/model/technician_ping_url_config_history.py (100%) rename {kdb-bot => bot}/src/bot_data/model/user.py (94%) rename {kdb-bot => bot}/src/bot_data/model/user_game_ident.py (96%) rename {kdb-bot => bot}/src/bot_data/model/user_got_achievement.py (95%) rename {kdb-bot => bot}/src/bot_data/model/user_history.py (89%) rename {kdb-bot => bot}/src/bot_data/model/user_joined_game_server.py (96%) rename {kdb-bot => bot}/src/bot_data/model/user_joined_game_server_history.py (100%) rename {kdb-bot => bot}/src/bot_data/model/user_joined_server.py (96%) rename {kdb-bot => bot}/src/bot_data/model/user_joined_server_history.py (100%) rename {kdb-bot => bot}/src/bot_data/model/user_joined_voice_channel.py (97%) rename {kdb-bot => bot}/src/bot_data/model/user_joined_voice_channel_history.py (100%) rename {kdb-bot => bot}/src/bot_data/model/user_message_count_per_hour.py (96%) rename {kdb-bot => bot}/src/bot_data/model/user_role_enum.py (100%) rename {kdb-bot => bot}/src/bot_data/model/user_warnings.py (95%) rename {kdb-bot => bot}/src/bot_data/model/user_warnings_history.py (100%) rename {kdb-bot => bot}/src/bot_data/service/__init__.py (100%) rename {kdb-bot => bot}/src/bot_data/service/achievements_repository_service.py (76%) rename {kdb-bot => bot}/src/bot_data/service/api_key_repository_service.py (77%) rename {kdb-bot => bot}/src/bot_data/service/auth_user_repository_service.py (84%) rename {kdb-bot => bot}/src/bot_data/service/auto_role_repository_service.py (59%) rename {kdb-bot => bot}/src/bot_data/service/cache_service.py (100%) rename {kdb-bot => bot}/src/bot_data/service/client_repository_service.py (89%) rename {kdb-bot => bot}/src/bot_data/service/game_server_repository_service.py (93%) rename {kdb-bot => bot}/src/bot_data/service/known_user_repository_service.py (83%) rename {kdb-bot => bot}/src/bot_data/service/level_repository_service.py (91%) rename {kdb-bot => bot}/src/bot_data/service/migration_service.py (78%) rename {kdb-bot => bot}/src/bot_data/service/seeder_service.py (100%) rename {kdb-bot => bot}/src/bot_data/service/server_config_repository_service.py (54%) rename {kdb-bot => bot}/src/bot_data/service/server_config_seeder.py (100%) rename {kdb-bot => bot}/src/bot_data/service/server_repository_service.py (74%) rename {kdb-bot => bot}/src/bot_data/service/short_role_name_repository_service.py (76%) rename {kdb-bot => bot}/src/bot_data/service/steam_special_offer_repository_service.py (74%) rename {kdb-bot => bot}/src/bot_data/service/technician_config_repository_service.py (69%) rename {kdb-bot => bot}/src/bot_data/service/technician_config_seeder.py (85%) rename {kdb-bot => bot}/src/bot_data/service/user_game_ident_repository_service.py (85%) rename {kdb-bot => bot}/src/bot_data/service/user_joined_game_server_repository_service.py (65%) rename {kdb-bot => bot}/src/bot_data/service/user_joined_server_repository_service.py (78%) rename {kdb-bot => bot}/src/bot_data/service/user_joined_voice_channel_repository_service.py (68%) rename {kdb-bot => bot}/src/bot_data/service/user_message_count_per_hour_repository_service.py (89%) rename {kdb-bot => bot}/src/bot_data/service/user_repository_service.py (81%) rename {kdb-bot => bot}/src/bot_data/service/user_warnings_repository_service.py (85%) rename {kdb-bot => bot}/src/bot_graphql/__init__.py (100%) rename {kdb-bot => bot}/src/bot_graphql/abc/__init__.py (100%) rename {kdb-bot => bot}/src/bot_graphql/abc/data_query_abc.py (100%) rename {kdb-bot => bot}/src/bot_graphql/abc/data_query_with_history_abc.py (100%) rename {kdb-bot => bot}/src/bot_graphql/abc/filter_abc.py (83%) rename {kdb-bot => bot}/src/bot_graphql/abc/history_query_abc.py (100%) rename {kdb-bot => bot}/src/bot_graphql/abc/query_abc.py (86%) rename {kdb-bot => bot}/src/bot_graphql/bot-graphql.json (100%) rename {kdb-bot => bot}/src/bot_graphql/filter/__init__.py (100%) rename {kdb-bot => bot}/src/bot_graphql/filter/achievement_filter.py (84%) rename {kdb-bot => bot}/src/bot_graphql/filter/auto_role_filter.py (87%) rename {kdb-bot => bot}/src/bot_graphql/filter/auto_role_rule_filter.py (93%) rename {kdb-bot => bot}/src/bot_graphql/filter/client_filter.py (84%) rename {kdb-bot => bot}/src/bot_graphql/filter/level_filter.py (84%) rename {kdb-bot => bot}/src/bot_graphql/filter/page.py (100%) rename {kdb-bot => bot}/src/bot_graphql/filter/server_filter.py (83%) rename {kdb-bot => bot}/src/bot_graphql/filter/short_role_name_filter.py (91%) rename {kdb-bot => bot}/src/bot_graphql/filter/sort.py (100%) rename {kdb-bot => bot}/src/bot_graphql/filter/user_filter.py (80%) rename {kdb-bot => bot}/src/bot_graphql/filter/user_joined_game_server_filter.py (96%) rename {kdb-bot => bot}/src/bot_graphql/filter/user_joined_server_filter.py (80%) rename {kdb-bot => bot}/src/bot_graphql/filter/user_joined_voice_channel_filter.py (82%) rename {kdb-bot => bot}/src/bot_graphql/filter/user_warning_filter.py (85%) rename {kdb-bot => bot}/src/bot_graphql/graphql/achievement.gql (100%) rename {kdb-bot => bot}/src/bot_graphql/graphql/autoRole.gql (100%) rename {kdb-bot => bot}/src/bot_graphql/graphql/autoRoleRule.gql (100%) rename {kdb-bot => bot}/src/bot_graphql/graphql/base.gql (100%) rename {kdb-bot => bot}/src/bot_graphql/graphql/client.gql (100%) rename {kdb-bot => bot}/src/bot_graphql/graphql/discord.gql (100%) rename {kdb-bot => bot}/src/bot_graphql/graphql/featureFlags.gql (100%) rename {kdb-bot => bot}/src/bot_graphql/graphql/knownUser.gql (100%) rename {kdb-bot => bot}/src/bot_graphql/graphql/level.gql (100%) rename {kdb-bot => bot}/src/bot_graphql/graphql/mutation.gql (100%) rename {kdb-bot => bot}/src/bot_graphql/graphql/query.gql (100%) rename {kdb-bot => bot}/src/bot_graphql/graphql/server.gql (100%) rename {kdb-bot => bot}/src/bot_graphql/graphql/serverConfig.gql (100%) rename {kdb-bot => bot}/src/bot_graphql/graphql/shortRoleName.gql (100%) rename {kdb-bot => bot}/src/bot_graphql/graphql/technicianConfig.gql (100%) rename {kdb-bot => bot}/src/bot_graphql/graphql/user.gql (100%) rename {kdb-bot => bot}/src/bot_graphql/graphql/userJoinedGameServer.gql (100%) rename {kdb-bot => bot}/src/bot_graphql/graphql/userJoinedServer.gql (100%) rename {kdb-bot => bot}/src/bot_graphql/graphql/userJoinedVoiceChannel.gql (100%) rename {kdb-bot => bot}/src/bot_graphql/graphql/userWarning.gql (100%) rename {kdb-bot => bot}/src/bot_graphql/graphql_module.py (93%) rename {kdb-bot => bot}/src/bot_graphql/graphql_service.py (100%) rename {kdb-bot => bot}/src/bot_graphql/model/__init__.py (100%) rename {kdb-bot => bot}/src/bot_graphql/model/discord.py (100%) rename {kdb-bot => bot}/src/bot_graphql/mutation.py (97%) rename {kdb-bot => bot}/src/bot_graphql/mutations/__init__.py (100%) rename {kdb-bot => bot}/src/bot_graphql/mutations/achievement_mutation.py (85%) rename {kdb-bot => bot}/src/bot_graphql/mutations/auto_role_mutation.py (77%) rename {kdb-bot => bot}/src/bot_graphql/mutations/auto_role_rule_mutation.py (77%) rename {kdb-bot => bot}/src/bot_graphql/mutations/level_mutation.py (91%) rename {kdb-bot => bot}/src/bot_graphql/mutations/server_config_mutation.py (67%) rename {kdb-bot => bot}/src/bot_graphql/mutations/short_role_name_mutation.py (86%) rename {kdb-bot => bot}/src/bot_graphql/mutations/technician_config_mutation.py (79%) rename {kdb-bot => bot}/src/bot_graphql/mutations/user_joined_game_server_mutation.py (86%) rename {kdb-bot => bot}/src/bot_graphql/mutations/user_mutation.py (80%) rename {kdb-bot => bot}/src/bot_graphql/queries/__init__.py (100%) rename {kdb-bot => bot}/src/bot_graphql/queries/achievement_attribute_query.py (100%) rename {kdb-bot => bot}/src/bot_graphql/queries/achievement_history_query.py (100%) rename {kdb-bot => bot}/src/bot_graphql/queries/achievement_query.py (84%) rename {kdb-bot => bot}/src/bot_graphql/queries/auto_role_history_query.py (100%) rename {kdb-bot => bot}/src/bot_graphql/queries/auto_role_query.py (91%) rename {kdb-bot => bot}/src/bot_graphql/queries/auto_role_rule_history_query.py (100%) rename {kdb-bot => bot}/src/bot_graphql/queries/auto_role_rule_query.py (81%) rename {kdb-bot => bot}/src/bot_graphql/queries/client_history_query.py (100%) rename {kdb-bot => bot}/src/bot_graphql/queries/client_query.py (94%) rename {kdb-bot => bot}/src/bot_graphql/queries/discord/__init__.py (100%) rename {kdb-bot => bot}/src/bot_graphql/queries/discord/channel_query.py (100%) rename {kdb-bot => bot}/src/bot_graphql/queries/discord/discord_query.py (100%) rename {kdb-bot => bot}/src/bot_graphql/queries/discord/discord_user_query.py (100%) rename {kdb-bot => bot}/src/bot_graphql/queries/discord/emoji_query.py (100%) rename {kdb-bot => bot}/src/bot_graphql/queries/discord/guild_query.py (88%) rename {kdb-bot => bot}/src/bot_graphql/queries/discord/role_query.py (100%) rename {kdb-bot => bot}/src/bot_graphql/queries/game_server_query.py (100%) rename {kdb-bot => bot}/src/bot_graphql/queries/known_user_history_query.py (100%) rename {kdb-bot => bot}/src/bot_graphql/queries/known_user_query.py (83%) rename {kdb-bot => bot}/src/bot_graphql/queries/level_history_query.py (100%) rename {kdb-bot => bot}/src/bot_graphql/queries/level_query.py (91%) rename {kdb-bot => bot}/src/bot_graphql/queries/server_config_query.py (53%) rename {kdb-bot => bot}/src/bot_graphql/queries/server_history_query.py (100%) rename {kdb-bot => bot}/src/bot_graphql/queries/server_query.py (72%) rename {kdb-bot => bot}/src/bot_graphql/queries/short_role_name_history_query.py (100%) rename {kdb-bot => bot}/src/bot_graphql/queries/short_role_name_query.py (82%) rename {kdb-bot => bot}/src/bot_graphql/queries/technician_config_history_query.py (60%) rename {kdb-bot => bot}/src/bot_graphql/queries/technician_config_query.py (76%) rename {kdb-bot => bot}/src/bot_graphql/queries/technician_id_config_history_query.py (100%) rename {kdb-bot => bot}/src/bot_graphql/queries/technician_ping_url_config_history_query.py (100%) rename {kdb-bot => bot}/src/bot_graphql/queries/user_history_query.py (100%) rename {kdb-bot => bot}/src/bot_graphql/queries/user_joined_game_server_history_query.py (100%) rename {kdb-bot => bot}/src/bot_graphql/queries/user_joined_game_server_query.py (90%) rename {kdb-bot => bot}/src/bot_graphql/queries/user_joined_server_history_query.py (100%) rename {kdb-bot => bot}/src/bot_graphql/queries/user_joined_server_query.py (87%) rename {kdb-bot => bot}/src/bot_graphql/queries/user_joined_voice_channel_history_query.py (100%) rename {kdb-bot => bot}/src/bot_graphql/queries/user_joined_voice_channel_query.py (85%) rename {kdb-bot => bot}/src/bot_graphql/queries/user_query.py (88%) rename {kdb-bot => bot}/src/bot_graphql/queries/user_warning_history_query.py (100%) rename {kdb-bot => bot}/src/bot_graphql/queries/user_warning_query.py (80%) rename {kdb-bot => bot}/src/bot_graphql/query.py (70%) rename {kdb-bot => bot}/src/bot_graphql/schema.py (78%) rename {kdb-bot => bot}/src/modules/__init__.py (100%) rename {kdb-bot => bot}/src/modules/achievements/__init__.py (100%) rename {kdb-bot => bot}/src/modules/achievements/achievement_attribute_resolver.py (80%) rename {kdb-bot => bot}/src/modules/achievements/achievement_service.py (68%) rename {kdb-bot => bot}/src/modules/achievements/achievements.json (100%) rename {kdb-bot => bot}/src/modules/achievements/achievements_module.py (55%) rename {kdb-bot => bot}/src/modules/achievements/commands/__init__.py (100%) rename {kdb-bot => bot}/src/modules/achievements/commands/achievements_group.py (97%) rename {kdb-bot => bot}/src/modules/achievements/events/__init__.py (100%) rename {kdb-bot => bot}/src/modules/achievements/events/achievement_on_message_event.py (94%) rename {kdb-bot => bot}/src/modules/achievements/events/achievement_on_reaction_add_event.py (90%) rename {kdb-bot => bot}/src/modules/achievements/events/achievement_on_reaction_remove_event.py (90%) rename {kdb-bot => bot}/src/modules/achievements/events/achievement_on_voice_state_update_event.py (90%) rename {kdb-bot => bot}/src/modules/achievements/model/__init__.py (100%) rename {kdb-bot => bot}/src/modules/achievements/model/achievement_attribute.py (100%) rename {kdb-bot => bot}/src/modules/auto_role/__init__.py (100%) rename {kdb-bot => bot}/src/modules/auto_role/auto-role.json (100%) rename {kdb-bot => bot}/src/modules/auto_role/auto_role_module.py (86%) rename {kdb-bot => bot}/src/modules/auto_role/command/__init__.py (100%) rename {kdb-bot => bot}/src/modules/auto_role/command/auto_role_group.py (74%) rename {kdb-bot => bot}/src/modules/auto_role/events/__init__.py (100%) rename {kdb-bot => bot}/src/modules/auto_role/events/auto_role_on_raw_reaction_add.py (89%) rename {kdb-bot => bot}/src/modules/auto_role/events/auto_role_on_raw_reaction_remove.py (89%) rename {kdb-bot => bot}/src/modules/auto_role/helper/__init__.py (100%) rename {kdb-bot => bot}/src/modules/auto_role/helper/auto_role_reaction_handler.py (88%) rename {kdb-bot => bot}/src/modules/base/__init__.py (100%) rename {kdb-bot => bot}/src/modules/base/base.json (100%) rename {kdb-bot => bot}/src/modules/base/base_module.py (81%) rename {kdb-bot => bot}/src/modules/base/birthday_watcher.py (92%) rename {kdb-bot => bot}/src/modules/base/command/__init__.py (100%) rename {kdb-bot => bot}/src/modules/base/command/afk_command.py (87%) rename {kdb-bot => bot}/src/modules/base/command/game_server_group.py (75%) rename {kdb-bot => bot}/src/modules/base/command/help_command.py (93%) rename {kdb-bot => bot}/src/modules/base/command/info_command.py (95%) rename {kdb-bot => bot}/src/modules/base/command/make_coffee_command.py (100%) rename {kdb-bot => bot}/src/modules/base/command/mass_move_command.py (96%) rename {kdb-bot => bot}/src/modules/base/command/ping_command.py (89%) rename {kdb-bot => bot}/src/modules/base/command/presence_command.py (85%) rename {kdb-bot => bot}/src/modules/base/command/purge_command.py (84%) rename {kdb-bot => bot}/src/modules/base/command/register_group.py (90%) rename {kdb-bot => bot}/src/modules/base/command/submit_group.py (93%) rename {kdb-bot => bot}/src/modules/base/command/unregister_group.py (94%) rename {kdb-bot => bot}/src/modules/base/command/user_group.py (78%) rename {kdb-bot => bot}/src/modules/base/events/__init__.py (100%) rename {kdb-bot => bot}/src/modules/base/events/base_on_command_error_event.py (94%) rename {kdb-bot => bot}/src/modules/base/events/base_on_command_event.py (86%) rename {kdb-bot => bot}/src/modules/base/events/base_on_guild_join_event.py (100%) rename {kdb-bot => bot}/src/modules/base/events/base_on_member_join_event.py (88%) rename {kdb-bot => bot}/src/modules/base/events/base_on_member_remove_event.py (90%) rename {kdb-bot => bot}/src/modules/base/events/base_on_message_delete_event.py (88%) rename {kdb-bot => bot}/src/modules/base/events/base_on_message_event.py (86%) rename {kdb-bot => bot}/src/modules/base/events/base_on_raw_reaction_add.py (100%) rename {kdb-bot => bot}/src/modules/base/events/base_on_raw_reaction_remove.py (100%) rename {kdb-bot => bot}/src/modules/base/events/base_on_scheduled_event_update_event.py (84%) rename {kdb-bot => bot}/src/modules/base/events/base_on_voice_state_update_event.py (75%) rename {kdb-bot => bot}/src/modules/base/events/base_on_voice_state_update_event_help_channel.py (92%) rename {kdb-bot => bot}/src/modules/base/events/base_on_voice_state_update_event_scheduled_event_bonus.py (100%) rename {kdb-bot => bot}/src/modules/base/forms/__init__.py (100%) rename {kdb-bot => bot}/src/modules/base/forms/bug_report_form.py (81%) rename {kdb-bot => bot}/src/modules/base/forms/complaint_form.py (90%) rename {kdb-bot => bot}/src/modules/base/helper/__init__.py (100%) rename {kdb-bot => bot}/src/modules/base/helper/base_reaction_handler.py (87%) rename {kdb-bot => bot}/src/modules/base/helper/voice_channel_transformer.py (62%) rename {kdb-bot => bot}/src/modules/base/model/__init__.py (100%) rename {kdb-bot => bot}/src/modules/base/model/active_event.py (100%) rename {kdb-bot => bot}/src/modules/base/service/__init__.py (100%) rename {kdb-bot => bot}/src/modules/base/service/event_service.py (87%) rename {kdb-bot => bot}/src/modules/base/service/user_warnings_service.py (66%) rename {kdb-bot => bot}/src/modules/base/thread/__init__.py (100%) rename {kdb-bot => bot}/src/modules/boot_log/__init__.py (100%) rename {kdb-bot => bot}/src/modules/boot_log/boot-log.json (100%) rename {kdb-bot => bot}/src/modules/boot_log/boot_log_extension.py (94%) rename {kdb-bot => bot}/src/modules/boot_log/boot_log_module.py (68%) rename {kdb-bot => bot}/src/modules/boot_log/boot_log_on_ready_event.py (88%) rename {kdb-bot => bot}/src/modules/config/__init__.py (100%) rename {kdb-bot => bot}/src/modules/config/config.json (100%) rename {kdb-bot => bot}/src/modules/config/config_extension.py (95%) rename {kdb-bot => bot}/src/modules/config/config_module.py (77%) rename {kdb-bot => bot}/src/modules/config/events/__init__.py (100%) rename {kdb-bot => bot}/src/modules/config/events/config_on_ready_event.py (85%) rename {kdb-bot => bot}/src/modules/config/service/__init__.py (100%) rename {kdb-bot => bot}/src/modules/database/__init__.py (100%) rename {kdb-bot => bot}/src/modules/database/database.json (100%) rename {kdb-bot => bot}/src/modules/database/database_extension.py (96%) rename {kdb-bot => bot}/src/modules/database/database_module.py (68%) rename {kdb-bot => bot}/src/modules/database/database_on_ready_event.py (80%) rename {kdb-bot => bot}/src/modules/level/__init__.py (100%) rename {kdb-bot => bot}/src/modules/level/command/__init__.py (100%) rename {kdb-bot => bot}/src/modules/level/command/level_group.py (81%) rename {kdb-bot => bot}/src/modules/level/configuration/__init__.py (100%) rename {kdb-bot => bot}/src/modules/level/configuration/default_level_settings.py (100%) rename {kdb-bot => bot}/src/modules/level/default-level.json (100%) rename {kdb-bot => bot}/src/modules/level/events/__init__.py (100%) rename {kdb-bot => bot}/src/modules/level/events/level_on_member_join_event.py (75%) rename {kdb-bot => bot}/src/modules/level/events/level_on_message_event.py (79%) rename {kdb-bot => bot}/src/modules/level/events/level_on_raw_reaction_add_event.py (88%) rename {kdb-bot => bot}/src/modules/level/events/level_on_raw_reaction_remove_event.py (88%) rename {kdb-bot => bot}/src/modules/level/events/level_on_voice_state_update_event.py (78%) rename {kdb-bot => bot}/src/modules/level/level.json (100%) rename {kdb-bot => bot}/src/modules/level/level_module.py (68%) rename {kdb-bot => bot}/src/modules/level/level_seeder.py (79%) rename {kdb-bot => bot}/src/modules/level/service/__init__.py (100%) rename {kdb-bot => bot}/src/modules/level/service/level_service.py (73%) rename {kdb-bot => bot}/src/modules/permission/__init__.py (100%) rename {kdb-bot => bot}/src/modules/permission/abc/__init__.py (100%) rename {kdb-bot => bot}/src/modules/permission/abc/permission_service_abc.py (100%) rename {kdb-bot => bot}/src/modules/permission/permission.json (100%) rename {kdb-bot => bot}/src/modules/permission/permission_module.py (78%) rename {kdb-bot => bot}/src/modules/permission/service/__init__.py (100%) rename {kdb-bot => bot}/src/modules/permission/service/permission_service.py (80%) rename {kdb-bot => bot}/src/modules/short_role_name/__init__.py (100%) rename {kdb-bot => bot}/src/modules/short_role_name/events/__init__.py (100%) rename {kdb-bot => bot}/src/modules/short_role_name/events/short_role_name_on_member_update_event.py (80%) rename {kdb-bot => bot}/src/modules/short_role_name/service/__init__.py (100%) rename {kdb-bot => bot}/src/modules/short_role_name/service/short_role_name_service.py (89%) rename {kdb-bot => bot}/src/modules/short_role_name/short-role-name.json (100%) rename {kdb-bot => bot}/src/modules/short_role_name/short_role_name_check_command.py (82%) rename {kdb-bot => bot}/src/modules/short_role_name/short_role_name_module.py (71%) rename {kdb-bot => bot}/src/modules/short_role_name/short_role_name_seeder.py (100%) rename {kdb-bot => bot}/src/modules/special_offers/__init__.py (100%) rename {kdb-bot => bot}/src/modules/special_offers/special-offers.json (100%) rename {kdb-bot => bot}/src/modules/special_offers/special_offers_module.py (77%) rename {kdb-bot => bot}/src/modules/special_offers/steam_offer_watcher.py (81%) rename {kdb-bot => bot}/src/modules/technician/__init__.py (100%) rename {kdb-bot => bot}/src/modules/technician/api_key_seeder.py (92%) rename {kdb-bot => bot}/src/modules/technician/command/__init__.py (100%) rename {kdb-bot => bot}/src/modules/technician/command/api_key_group.py (84%) rename {kdb-bot => bot}/src/modules/technician/command/log_command.py (96%) rename {kdb-bot => bot}/src/modules/technician/command/restart_command.py (94%) rename {kdb-bot => bot}/src/modules/technician/command/shutdown_command.py (94%) rename {kdb-bot => bot}/src/modules/technician/command/sync_xp_command.py (78%) rename {kdb-bot => bot}/src/modules/technician/technician.json (100%) rename {kdb-bot => bot}/src/modules/technician/technician_module.py (85%) rename {kdb-bot => bot}/tools/checks/UserJoinedVoiceChannel.json (100%) rename {kdb-bot => bot}/tools/checks/__init__.py (100%) rename {kdb-bot => bot}/tools/checks/checks.json (100%) rename {kdb-bot => bot}/tools/checks/get_ontime_overlaps.py (100%) rename {kdb-bot => bot}/tools/get_version/__init__.py (100%) rename {kdb-bot => bot}/tools/get_version/application.py (100%) rename {kdb-bot => bot}/tools/get_version/get-version.json (100%) rename {kdb-bot => bot}/tools/get_version/main.py (100%) rename {kdb-bot => bot}/tools/get_version/startup.py (78%) rename {kdb-bot => bot}/tools/post_build/__init__.py (100%) rename {kdb-bot => bot}/tools/post_build/application.py (100%) rename {kdb-bot => bot}/tools/post_build/appsettings.json (100%) rename {kdb-bot => bot}/tools/post_build/main.py (100%) rename {kdb-bot => bot}/tools/post_build/post-build.json (100%) rename {kdb-bot => bot}/tools/post_build/post_build_settings.py (73%) rename {kdb-bot => bot}/tools/post_build/service/__init__.py (100%) rename {kdb-bot => bot}/tools/post_build/service/dependencies.py (93%) rename {kdb-bot => bot}/tools/post_build/service/remove_config.py (100%) rename {kdb-bot => bot}/tools/post_build/startup.py (82%) rename {kdb-bot => bot}/tools/set_version/__init__.py (100%) rename {kdb-bot => bot}/tools/set_version/application.py (74%) rename {kdb-bot => bot}/tools/set_version/git_service.py (100%) rename {kdb-bot => bot}/tools/set_version/main.py (100%) rename {kdb-bot => bot}/tools/set_version/set-version.json (100%) rename {kdb-bot => bot}/tools/set_version/startup.py (82%) rename {kdb-bot => bot}/tools/set_version/version_setter_service.py (76%) delete mode 100644 kdb-bot/LICENSE delete mode 100644 kdb-bot/README.md delete mode 100644 kdb-bot/cpl-workspace.json delete mode 160000 kdb-bot/docker delete mode 100644 kdb-bot/dockerfile delete mode 100644 kdb-bot/pyproject.toml delete mode 160000 kdb-bot/src/bot/config delete mode 160000 kdb-bot/src/bot_api/config rename {kdb-web => web}/.browserslistrc (100%) rename {kdb-web => web}/.editorconfig (100%) rename {kdb-web => web}/.gitignore (100%) rename {kdb-web => web}/.prettierrc (100%) rename {kdb-web => web}/README.md (100%) rename {kdb-web => web}/angular.json (100%) rename {kdb-web => web}/dockerfile (100%) rename {kdb-web => web}/karma.conf.js (100%) rename {kdb-web => web}/nginx.conf.template (100%) rename {kdb-web => web}/package-lock.json (100%) rename {kdb-web => web}/package.json (100%) rename {kdb-web => web}/src/app/app-routing.module.ts (100%) rename {kdb-web => web}/src/app/app.component.html (100%) rename {kdb-web => web}/src/app/app.component.scss (100%) rename {kdb-web => web}/src/app/app.component.spec.ts (100%) rename {kdb-web => web}/src/app/app.component.ts (100%) rename {kdb-web => web}/src/app/app.module.ts (100%) rename {kdb-web => web}/src/app/base/component-with-table.spec.ts (100%) rename {kdb-web => web}/src/app/base/component-with-table.ts (100%) rename {kdb-web => web}/src/app/components/error/not-found/not-found.component.html (100%) rename {kdb-web => web}/src/app/components/error/not-found/not-found.component.scss (100%) rename {kdb-web => web}/src/app/components/error/not-found/not-found.component.spec.ts (100%) rename {kdb-web => web}/src/app/components/error/not-found/not-found.component.ts (100%) rename {kdb-web => web}/src/app/components/footer/footer.component.html (100%) rename {kdb-web => web}/src/app/components/footer/footer.component.scss (100%) rename {kdb-web => web}/src/app/components/footer/footer.component.spec.ts (100%) rename {kdb-web => web}/src/app/components/footer/footer.component.ts (100%) rename {kdb-web => web}/src/app/components/header/header.component.html (100%) rename {kdb-web => web}/src/app/components/header/header.component.scss (100%) rename {kdb-web => web}/src/app/components/header/header.component.spec.ts (100%) rename {kdb-web => web}/src/app/components/header/header.component.ts (100%) rename {kdb-web => web}/src/app/components/sidebar/sidebar.component.html (100%) rename {kdb-web => web}/src/app/components/sidebar/sidebar.component.scss (100%) rename {kdb-web => web}/src/app/components/sidebar/sidebar.component.spec.ts (100%) rename {kdb-web => web}/src/app/components/sidebar/sidebar.component.ts (100%) rename {kdb-web => web}/src/app/components/spinner/spinner.component.html (100%) rename {kdb-web => web}/src/app/components/spinner/spinner.component.scss (100%) rename {kdb-web => web}/src/app/components/spinner/spinner.component.spec.ts (100%) rename {kdb-web => web}/src/app/components/spinner/spinner.component.ts (100%) rename {kdb-web => web}/src/app/models/auth/admin-update-user.dto.ts (100%) rename {kdb-web => web}/src/app/models/auth/auth-error-messages.enum.ts (100%) rename {kdb-web => web}/src/app/models/auth/auth-roles.enum.ts (100%) rename {kdb-web => web}/src/app/models/auth/auth-user-atr-errors.ts (100%) rename {kdb-web => web}/src/app/models/auth/auth-user.dto.ts (100%) rename {kdb-web => web}/src/app/models/auth/discord-auth-url.dto.ts (100%) rename {kdb-web => web}/src/app/models/auth/email-string.dto.ts (100%) rename {kdb-web => web}/src/app/models/auth/oauth.dto.ts (100%) rename {kdb-web => web}/src/app/models/auth/register-error-messages.enum.ts (100%) rename {kdb-web => web}/src/app/models/auth/reset-password.dto.ts (100%) rename {kdb-web => web}/src/app/models/auth/token.dto.ts (100%) rename {kdb-web => web}/src/app/models/auth/update-user.dto.ts (100%) rename {kdb-web => web}/src/app/models/config/api-version.ts (100%) rename {kdb-web => web}/src/app/models/config/app-settings.ts (100%) rename {kdb-web => web}/src/app/models/config/feature-flags.model.ts (100%) rename {kdb-web => web}/src/app/models/config/server-config.model.ts (100%) rename {kdb-web => web}/src/app/models/config/settings.dto.ts (100%) rename {kdb-web => web}/src/app/models/config/software-version.dto.ts (100%) rename {kdb-web => web}/src/app/models/config/software-version.ts (100%) rename {kdb-web => web}/src/app/models/config/technician-config.model.ts (100%) rename {kdb-web => web}/src/app/models/data/achievement.model.ts (100%) rename {kdb-web => web}/src/app/models/data/auto_role.model.ts (100%) rename {kdb-web => web}/src/app/models/data/client.model.ts (100%) rename {kdb-web => web}/src/app/models/data/data.model.ts (100%) rename {kdb-web => web}/src/app/models/data/discord.model.ts (100%) rename {kdb-web => web}/src/app/models/data/level.model.ts (100%) rename {kdb-web => web}/src/app/models/data/server.model.ts (100%) rename {kdb-web => web}/src/app/models/data/short_role_name.model.ts (100%) rename {kdb-web => web}/src/app/models/data/user.model.ts (100%) rename {kdb-web => web}/src/app/models/data/user_joined_game_server.model.ts (100%) rename {kdb-web => web}/src/app/models/data/user_joined_server.model.ts (100%) rename {kdb-web => web}/src/app/models/data/user_joined_voice_channel.model.ts (100%) rename {kdb-web => web}/src/app/models/data/user_warning.model.ts (100%) rename {kdb-web => web}/src/app/models/error/error-dto.ts (100%) rename {kdb-web => web}/src/app/models/error/service-error-code.enum.ts (100%) rename {kdb-web => web}/src/app/models/graphql/filter/page.model.ts (100%) rename {kdb-web => web}/src/app/models/graphql/filter/sort.model.ts (100%) rename {kdb-web => web}/src/app/models/graphql/mutations.model.ts (100%) rename {kdb-web => web}/src/app/models/graphql/queries.model.ts (100%) rename {kdb-web => web}/src/app/models/graphql/query.model.ts (100%) rename {kdb-web => web}/src/app/models/graphql/result.model.ts (100%) rename {kdb-web => web}/src/app/models/graphql/variables.model.ts (100%) rename {kdb-web => web}/src/app/models/selection/auth-user/auth-user-select-criterion.dto.ts (100%) rename {kdb-web => web}/src/app/models/selection/auth-user/get-filtered-auth-users-result.dto.ts (100%) rename {kdb-web => web}/src/app/models/selection/select-criterion.model.ts (100%) rename {kdb-web => web}/src/app/models/utils/confirmation-dialog.ts (100%) rename {kdb-web => web}/src/app/models/utils/toast-options.ts (100%) rename {kdb-web => web}/src/app/models/view/theme.ts (100%) rename {kdb-web => web}/src/app/models/view/themes.enum.ts (100%) rename {kdb-web => web}/src/app/modules/admin/auth-users/auth-user-routing.module.ts (100%) rename {kdb-web => web}/src/app/modules/admin/auth-users/auth-user.module.ts (100%) rename {kdb-web => web}/src/app/modules/admin/auth-users/components/auth-user/auth-user.component.html (100%) rename {kdb-web => web}/src/app/modules/admin/auth-users/components/auth-user/auth-user.component.scss (100%) rename {kdb-web => web}/src/app/modules/admin/auth-users/components/auth-user/auth-user.component.spec.ts (100%) rename {kdb-web => web}/src/app/modules/admin/auth-users/components/auth-user/auth-user.component.ts (100%) rename {kdb-web => web}/src/app/modules/admin/settings/components/settings/settings.component.html (100%) rename {kdb-web => web}/src/app/modules/admin/settings/components/settings/settings.component.scss (100%) rename {kdb-web => web}/src/app/modules/admin/settings/components/settings/settings.component.spec.ts (100%) rename {kdb-web => web}/src/app/modules/admin/settings/components/settings/settings.component.ts (100%) rename {kdb-web => web}/src/app/modules/admin/settings/settings-routing.module.ts (100%) rename {kdb-web => web}/src/app/modules/admin/settings/settings.module.ts (100%) rename {kdb-web => web}/src/app/modules/auth/auth-routing.module.ts (100%) rename {kdb-web => web}/src/app/modules/auth/auth.module.ts (100%) rename {kdb-web => web}/src/app/modules/auth/components/auth-footer/auth-footer.component.html (100%) rename {kdb-web => web}/src/app/modules/auth/components/auth-footer/auth-footer.component.scss (100%) rename {kdb-web => web}/src/app/modules/auth/components/auth-footer/auth-footer.component.spec.ts (100%) rename {kdb-web => web}/src/app/modules/auth/components/auth-footer/auth-footer.component.ts (100%) rename {kdb-web => web}/src/app/modules/auth/components/auth-header/auth-header.component.html (100%) rename {kdb-web => web}/src/app/modules/auth/components/auth-header/auth-header.component.scss (100%) rename {kdb-web => web}/src/app/modules/auth/components/auth-header/auth-header.component.spec.ts (100%) rename {kdb-web => web}/src/app/modules/auth/components/auth-header/auth-header.component.ts (100%) rename {kdb-web => web}/src/app/modules/auth/components/forget-password/forget-password.component.html (100%) rename {kdb-web => web}/src/app/modules/auth/components/forget-password/forget-password.component.scss (100%) rename {kdb-web => web}/src/app/modules/auth/components/forget-password/forget-password.component.spec.ts (100%) rename {kdb-web => web}/src/app/modules/auth/components/forget-password/forget-password.component.ts (100%) rename {kdb-web => web}/src/app/modules/auth/components/login/login.component.html (100%) rename {kdb-web => web}/src/app/modules/auth/components/login/login.component.scss (100%) rename {kdb-web => web}/src/app/modules/auth/components/login/login.component.spec.ts (100%) rename {kdb-web => web}/src/app/modules/auth/components/login/login.component.ts (100%) rename {kdb-web => web}/src/app/modules/auth/components/registration/registration.component.html (100%) rename {kdb-web => web}/src/app/modules/auth/components/registration/registration.component.scss (100%) rename {kdb-web => web}/src/app/modules/auth/components/registration/registration.component.spec.ts (100%) rename {kdb-web => web}/src/app/modules/auth/components/registration/registration.component.ts (100%) rename {kdb-web => web}/src/app/modules/shared/base/hideable-component.spec.ts (100%) rename {kdb-web => web}/src/app/modules/shared/base/hideable-component.ts (100%) rename {kdb-web => web}/src/app/modules/shared/base/multi-select-columns/multi-select-columns.component.html (100%) rename {kdb-web => web}/src/app/modules/shared/base/multi-select-columns/multi-select-columns.component.scss (100%) rename {kdb-web => web}/src/app/modules/shared/base/multi-select-columns/multi-select-columns.component.spec.ts (100%) rename {kdb-web => web}/src/app/modules/shared/base/multi-select-columns/multi-select-columns.component.ts (100%) rename {kdb-web => web}/src/app/modules/shared/components/config-list/config-list.component.html (100%) rename {kdb-web => web}/src/app/modules/shared/components/config-list/config-list.component.scss (100%) rename {kdb-web => web}/src/app/modules/shared/components/config-list/config-list.component.spec.ts (100%) rename {kdb-web => web}/src/app/modules/shared/components/config-list/config-list.component.ts (100%) rename {kdb-web => web}/src/app/modules/shared/components/feature-flag-list/feature-flag-list.component.html (100%) rename {kdb-web => web}/src/app/modules/shared/components/feature-flag-list/feature-flag-list.component.scss (100%) rename {kdb-web => web}/src/app/modules/shared/components/feature-flag-list/feature-flag-list.component.spec.ts (100%) rename {kdb-web => web}/src/app/modules/shared/components/feature-flag-list/feature-flag-list.component.ts (100%) rename {kdb-web => web}/src/app/modules/shared/components/hideable-column/hideable-column.component.html (100%) rename {kdb-web => web}/src/app/modules/shared/components/hideable-column/hideable-column.component.scss (100%) rename {kdb-web => web}/src/app/modules/shared/components/hideable-column/hideable-column.component.spec.ts (100%) rename {kdb-web => web}/src/app/modules/shared/components/hideable-column/hideable-column.component.ts (100%) rename {kdb-web => web}/src/app/modules/shared/components/hideable-header/hideable-header.component.html (100%) rename {kdb-web => web}/src/app/modules/shared/components/hideable-header/hideable-header.component.scss (100%) rename {kdb-web => web}/src/app/modules/shared/components/hideable-header/hideable-header.component.spec.ts (100%) rename {kdb-web => web}/src/app/modules/shared/components/hideable-header/hideable-header.component.ts (100%) rename {kdb-web => web}/src/app/modules/shared/components/history-btn/history-btn.component.html (100%) rename {kdb-web => web}/src/app/modules/shared/components/history-btn/history-btn.component.scss (100%) rename {kdb-web => web}/src/app/modules/shared/components/history-btn/history-btn.component.spec.ts (100%) rename {kdb-web => web}/src/app/modules/shared/components/history-btn/history-btn.component.ts (100%) rename {kdb-web => web}/src/app/modules/shared/guards/auth/auth.guard.spec.ts (100%) rename {kdb-web => web}/src/app/modules/shared/guards/auth/auth.guard.ts (100%) rename {kdb-web => web}/src/app/modules/shared/pipes/auth-role.pipe.ts (100%) rename {kdb-web => web}/src/app/modules/shared/pipes/bool.pipe.spec.ts (100%) rename {kdb-web => web}/src/app/modules/shared/pipes/bool.pipe.ts (100%) rename {kdb-web => web}/src/app/modules/shared/pipes/ip-address.pipe.ts (100%) rename {kdb-web => web}/src/app/modules/shared/shared.module.ts (100%) rename {kdb-web => web}/src/app/modules/view/change-password/change-password-routing.module.ts (100%) rename {kdb-web => web}/src/app/modules/view/change-password/change-password.module.ts (100%) rename {kdb-web => web}/src/app/modules/view/change-password/components/change-password/change-password.component.html (100%) rename {kdb-web => web}/src/app/modules/view/change-password/components/change-password/change-password.component.scss (100%) rename {kdb-web => web}/src/app/modules/view/change-password/components/change-password/change-password.component.spec.ts (100%) rename {kdb-web => web}/src/app/modules/view/change-password/components/change-password/change-password.component.ts (100%) rename {kdb-web => web}/src/app/modules/view/dashboard/components/dashboard/dashboard.component.html (100%) rename {kdb-web => web}/src/app/modules/view/dashboard/components/dashboard/dashboard.component.scss (100%) rename {kdb-web => web}/src/app/modules/view/dashboard/components/dashboard/dashboard.component.spec.ts (100%) rename {kdb-web => web}/src/app/modules/view/dashboard/components/dashboard/dashboard.component.ts (100%) rename {kdb-web => web}/src/app/modules/view/dashboard/dashboard-routing.module.ts (100%) rename {kdb-web => web}/src/app/modules/view/dashboard/dashboard.module.ts (100%) rename {kdb-web => web}/src/app/modules/view/server/achievements/achievements-routing.module.ts (100%) rename {kdb-web => web}/src/app/modules/view/server/achievements/achievements.module.ts (100%) rename {kdb-web => web}/src/app/modules/view/server/achievements/components/achievement/achievement.component.html (100%) rename {kdb-web => web}/src/app/modules/view/server/achievements/components/achievement/achievement.component.scss (100%) rename {kdb-web => web}/src/app/modules/view/server/achievements/components/achievement/achievement.component.spec.ts (100%) rename {kdb-web => web}/src/app/modules/view/server/achievements/components/achievement/achievement.component.ts (100%) rename {kdb-web => web}/src/app/modules/view/server/auto-role/auto-role-routing.module.ts (100%) rename {kdb-web => web}/src/app/modules/view/server/auto-role/auto-role.module.ts (100%) rename {kdb-web => web}/src/app/modules/view/server/auto-role/components/auto-roles-rules/auto-roles-rules.component.html (100%) rename {kdb-web => web}/src/app/modules/view/server/auto-role/components/auto-roles-rules/auto-roles-rules.component.scss (100%) rename {kdb-web => web}/src/app/modules/view/server/auto-role/components/auto-roles-rules/auto-roles-rules.component.spec.ts (100%) rename {kdb-web => web}/src/app/modules/view/server/auto-role/components/auto-roles-rules/auto-roles-rules.component.ts (100%) rename {kdb-web => web}/src/app/modules/view/server/auto-role/components/auto-roles/auto-roles.component.html (100%) rename {kdb-web => web}/src/app/modules/view/server/auto-role/components/auto-roles/auto-roles.component.scss (100%) rename {kdb-web => web}/src/app/modules/view/server/auto-role/components/auto-roles/auto-roles.component.spec.ts (100%) rename {kdb-web => web}/src/app/modules/view/server/auto-role/components/auto-roles/auto-roles.component.ts (100%) rename {kdb-web => web}/src/app/modules/view/server/config/components/config/config.component.html (100%) rename {kdb-web => web}/src/app/modules/view/server/config/components/config/config.component.scss (100%) rename {kdb-web => web}/src/app/modules/view/server/config/components/config/config.component.spec.ts (100%) rename {kdb-web => web}/src/app/modules/view/server/config/components/config/config.component.ts (100%) rename {kdb-web => web}/src/app/modules/view/server/config/config-routing.module.ts (100%) rename {kdb-web => web}/src/app/modules/view/server/config/config.module.ts (100%) rename {kdb-web => web}/src/app/modules/view/server/levels/components/levels/levels.component.html (100%) rename {kdb-web => web}/src/app/modules/view/server/levels/components/levels/levels.component.scss (100%) rename {kdb-web => web}/src/app/modules/view/server/levels/components/levels/levels.component.spec.ts (100%) rename {kdb-web => web}/src/app/modules/view/server/levels/components/levels/levels.component.ts (100%) rename {kdb-web => web}/src/app/modules/view/server/levels/levels-routing.module.ts (100%) rename {kdb-web => web}/src/app/modules/view/server/levels/levels.module.ts (100%) rename {kdb-web => web}/src/app/modules/view/server/members/members.component.html (100%) rename {kdb-web => web}/src/app/modules/view/server/members/members.component.scss (100%) rename {kdb-web => web}/src/app/modules/view/server/members/members.component.spec.ts (100%) rename {kdb-web => web}/src/app/modules/view/server/members/members.component.ts (100%) rename {kdb-web => web}/src/app/modules/view/server/profile/profile.component.html (100%) rename {kdb-web => web}/src/app/modules/view/server/profile/profile.component.scss (100%) rename {kdb-web => web}/src/app/modules/view/server/profile/profile.component.spec.ts (100%) rename {kdb-web => web}/src/app/modules/view/server/profile/profile.component.ts (100%) rename {kdb-web => web}/src/app/modules/view/server/server-dashboard/components/client/client.component.html (100%) rename {kdb-web => web}/src/app/modules/view/server/server-dashboard/components/client/client.component.scss (100%) rename {kdb-web => web}/src/app/modules/view/server/server-dashboard/components/client/client.component.spec.ts (100%) rename {kdb-web => web}/src/app/modules/view/server/server-dashboard/components/client/client.component.ts (100%) rename {kdb-web => web}/src/app/modules/view/server/server-dashboard/server-dashboard.component.html (100%) rename {kdb-web => web}/src/app/modules/view/server/server-dashboard/server-dashboard.component.scss (100%) rename {kdb-web => web}/src/app/modules/view/server/server-dashboard/server-dashboard.component.spec.ts (100%) rename {kdb-web => web}/src/app/modules/view/server/server-dashboard/server-dashboard.component.ts (100%) rename {kdb-web => web}/src/app/modules/view/server/server-routing.module.ts (100%) rename {kdb-web => web}/src/app/modules/view/server/server.module.ts (100%) rename {kdb-web => web}/src/app/modules/view/server/short-role-name/components/short-role-names/short-role-names.component.html (100%) rename {kdb-web => web}/src/app/modules/view/server/short-role-name/components/short-role-names/short-role-names.component.scss (100%) rename {kdb-web => web}/src/app/modules/view/server/short-role-name/components/short-role-names/short-role-names.component.spec.ts (100%) rename {kdb-web => web}/src/app/modules/view/server/short-role-name/components/short-role-names/short-role-names.component.ts (100%) rename {kdb-web => web}/src/app/modules/view/server/short-role-name/short-role-name-routing.module.ts (100%) rename {kdb-web => web}/src/app/modules/view/server/short-role-name/short-role-name.module.ts (100%) rename {kdb-web => web}/src/app/modules/view/user-settings/components/user-settings/user-settings.component.html (100%) rename {kdb-web => web}/src/app/modules/view/user-settings/components/user-settings/user-settings.component.scss (100%) rename {kdb-web => web}/src/app/modules/view/user-settings/components/user-settings/user-settings.component.spec.ts (100%) rename {kdb-web => web}/src/app/modules/view/user-settings/components/user-settings/user-settings.component.ts (100%) rename {kdb-web => web}/src/app/modules/view/user-settings/user-settings-routing.module.ts (100%) rename {kdb-web => web}/src/app/modules/view/user-settings/user-settings.module.ts (100%) rename {kdb-web => web}/src/app/services/auth/auth.service.spec.ts (100%) rename {kdb-web => web}/src/app/services/auth/auth.service.ts (100%) rename {kdb-web => web}/src/app/services/confirmation-dialog/confirmation-dialog.service.spec.ts (100%) rename {kdb-web => web}/src/app/services/confirmation-dialog/confirmation-dialog.service.ts (100%) rename {kdb-web => web}/src/app/services/data/data.service.spec.ts (100%) rename {kdb-web => web}/src/app/services/data/data.service.ts (100%) rename {kdb-web => web}/src/app/services/error-handler/error-handler.service.spec.ts (100%) rename {kdb-web => web}/src/app/services/error-handler/error-handler.service.ts (100%) rename {kdb-web => web}/src/app/services/gui/gui.service.spec.ts (100%) rename {kdb-web => web}/src/app/services/gui/gui.service.ts (100%) rename {kdb-web => web}/src/app/services/server.service.spec.ts (100%) rename {kdb-web => web}/src/app/services/server.service.ts (100%) rename {kdb-web => web}/src/app/services/settings/settings.service.spec.ts (100%) rename {kdb-web => web}/src/app/services/settings/settings.service.ts (100%) rename {kdb-web => web}/src/app/services/sidebar/sidebar.service.spec.ts (100%) rename {kdb-web => web}/src/app/services/sidebar/sidebar.service.ts (100%) rename {kdb-web => web}/src/app/services/socket/socket.service.spec.ts (100%) rename {kdb-web => web}/src/app/services/socket/socket.service.ts (100%) rename {kdb-web => web}/src/app/services/spinner/spinner.service.spec.ts (100%) rename {kdb-web => web}/src/app/services/spinner/spinner.service.ts (100%) rename {kdb-web => web}/src/app/services/theme/theme.service.spec.ts (100%) rename {kdb-web => web}/src/app/services/theme/theme.service.ts (100%) rename {kdb-web => web}/src/app/services/toast/toast.service.spec.ts (100%) rename {kdb-web => web}/src/app/services/toast/toast.service.ts (100%) rename {kdb-web => web}/src/assets/config.json (100%) rename {kdb-web => web}/src/assets/i18n/de.json (100%) rename {kdb-web => web}/src/assets/i18n/en.json (100%) rename {kdb-web => web}/src/assets/images/favicon.ico (100%) rename {kdb-web => web}/src/assets/version.json (100%) rename {kdb-web => web}/src/environments/environment.development.ts (100%) rename {kdb-web => web}/src/environments/environment.prod.ts (100%) rename {kdb-web => web}/src/environments/environment.staging.ts (100%) rename {kdb-web => web}/src/environments/environment.ts (100%) rename {kdb-web => web}/src/favicon.ico (100%) rename {kdb-web => web}/src/index.html (100%) rename {kdb-web => web}/src/main.ts (100%) rename {kdb-web => web}/src/polyfills.ts (100%) rename {kdb-web => web}/src/styles.scss (100%) rename {kdb-web => web}/src/styles/constants.scss (100%) rename {kdb-web => web}/src/styles/primeng-fixes.scss (100%) rename {kdb-web => web}/src/styles/themes/default-dark-theme.scss (100%) rename {kdb-web => web}/src/styles/themes/default-light-theme.scss (100%) rename {kdb-web => web}/src/styles/themes/sh-edraft-dark-theme.scss (100%) rename {kdb-web => web}/src/styles/themes/sh-edraft-light-theme.scss (100%) rename {kdb-web => web}/src/test.ts (100%) rename {kdb-web => web}/tsconfig.app.json (100%) rename {kdb-web => web}/tsconfig.json (100%) rename {kdb-web => web}/tsconfig.spec.json (100%) rename {kdb-web => web}/update-version.ts (100%) diff --git a/.gitmodules b/.gitmodules index ca793c6c..ac5bd60d 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,9 +1,9 @@ -[submodule "kdb-bot/src/bot/config"] - path = kdb-bot/src/bot/config - url = https://git.sh-edraft.de/sh-edraft.de/kd_discord_bot.config.git -[submodule "kdb-bot/src/bot_api/config"] - path = kdb-bot/src/bot_api/config - url = https://git.sh-edraft.de/sh-edraft.de/kd_discord_bot.api.config.git -[submodule "kdb-bot/docker"] - path = kdb-bot/docker - url = https://git.sh-edraft.de/sh-edraft.de/kd_discord_bot.docker.git +[submodule "shd-bot/src/bot/config"] + path = shd-bot/src/bot/config + url = https://git.sh-edraft.de/sh-edraft.de/sh_discord_bot.config.git +[submodule "shb-bot/src/bot_api/config"] + path = shb-bot/src/bot_api/config + url = https://git.sh-edraft.de/sh-edraft.de/sh_discord_bot.api.config.git +[submodule "shb-bot/bot/docker"] + path = shb-bot/bot/docker + url = https://git.sh-edraft.de/sh-edraft.de/sh_discord_bot.docker.git diff --git a/kdb-bot/.cpl/schematic_db_table.py b/bot/.cpl/schematic_db_table.py similarity index 100% rename from kdb-bot/.cpl/schematic_db_table.py rename to bot/.cpl/schematic_db_table.py diff --git a/kdb-bot/.cpl/schematic_migration.py b/bot/.cpl/schematic_migration.py similarity index 100% rename from kdb-bot/.cpl/schematic_migration.py rename to bot/.cpl/schematic_migration.py diff --git a/kdb-bot/.cpl/schematic_query.py b/bot/.cpl/schematic_query.py similarity index 100% rename from kdb-bot/.cpl/schematic_query.py rename to bot/.cpl/schematic_query.py diff --git a/kdb-bot/src/bot/__init__.py b/bot/src/bot/__init__.py similarity index 100% rename from kdb-bot/src/bot/__init__.py rename to bot/src/bot/__init__.py diff --git a/kdb-bot/src/bot/application.py b/bot/src/bot/application.py similarity index 87% rename from kdb-bot/src/bot/application.py rename to bot/src/bot/application.py index 6d1e4dd9..4d57ff59 100644 --- a/kdb-bot/src/bot/application.py +++ b/bot/src/bot/application.py @@ -23,17 +23,25 @@ class Application(DiscordBotApplicationABC): # cpl-core self._logger: LoggerABC = services.get_service(LoggerABC) - self._data_integrity: DataIntegrityService = services.get_service(DataIntegrityService) + self._data_integrity: DataIntegrityService = services.get_service( + DataIntegrityService + ) # cpl-discord self._bot: DiscordBotServiceABC = services.get_service(DiscordBotServiceABC) - self._bot_settings: DiscordBotSettings = config.get_configuration(DiscordBotSettings) + self._bot_settings: DiscordBotSettings = config.get_configuration( + DiscordBotSettings + ) # cpl-translation - self._translation: TranslationServiceABC = services.get_service(TranslationServiceABC) + self._translation: TranslationServiceABC = services.get_service( + TranslationServiceABC + ) self._t: TranslatePipe = services.get_service(TranslatePipe) # internal stuff self._tasks = services.get_services(TaskABC) - self._feature_flags: FeatureFlagsSettings = config.get_configuration(FeatureFlagsSettings) + self._feature_flags: FeatureFlagsSettings = config.get_configuration( + FeatureFlagsSettings + ) # api if self._feature_flags.get_flag(FeatureFlagsEnum.api_module): @@ -42,7 +50,9 @@ class Application(DiscordBotApplicationABC): self._is_stopping = False async def configure(self): - self._translation.load_by_settings(self._configuration.get_configuration(TranslationSettings)) + self._translation.load_by_settings( + self._configuration.get_configuration(TranslationSettings) + ) async def main(self): try: @@ -85,4 +95,8 @@ class Application(DiscordBotApplicationABC): Console.write_line() def is_restart(self): - return True if self._configuration.get_configuration("IS_RESTART") == "true" else False + return ( + True + if self._configuration.get_configuration("IS_RESTART") == "true" + else False + ) diff --git a/kdb-bot/src/bot/bot b/bot/src/bot/bot similarity index 100% rename from kdb-bot/src/bot/bot rename to bot/src/bot/bot diff --git a/kdb-bot/src/bot/bot.json b/bot/src/bot/bot.json similarity index 100% rename from kdb-bot/src/bot/bot.json rename to bot/src/bot/bot.json diff --git a/kdb-bot/src/bot/extension/__init__.py b/bot/src/bot/extension/__init__.py similarity index 100% rename from kdb-bot/src/bot/extension/__init__.py rename to bot/src/bot/extension/__init__.py diff --git a/kdb-bot/src/bot/extension/init_bot_extension.py b/bot/src/bot/extension/init_bot_extension.py similarity index 79% rename from kdb-bot/src/bot/extension/init_bot_extension.py rename to bot/src/bot/extension/init_bot_extension.py index 04a4fcf0..c0a2feef 100644 --- a/kdb-bot/src/bot/extension/init_bot_extension.py +++ b/bot/src/bot/extension/init_bot_extension.py @@ -13,4 +13,6 @@ class InitBotExtension(ApplicationExtensionABC): async def run(self, config: ConfigurationABC, services: ServiceProviderABC): settings = config.get_configuration(TechnicianConfig) - bot: DiscordBotServiceABC = services.get_service(DiscordBotServiceABC, max_messages=settings.cache_max_messages) + bot: DiscordBotServiceABC = services.get_service( + DiscordBotServiceABC, max_messages=settings.cache_max_messages + ) diff --git a/kdb-bot/src/bot/main.py b/bot/src/bot/main.py similarity index 100% rename from kdb-bot/src/bot/main.py rename to bot/src/bot/main.py diff --git a/kdb-bot/src/bot/module_list.py b/bot/src/bot/module_list.py similarity index 100% rename from kdb-bot/src/bot/module_list.py rename to bot/src/bot/module_list.py diff --git a/kdb-bot/src/bot/startup.py b/bot/src/bot/startup.py similarity index 95% rename from kdb-bot/src/bot/startup.py rename to bot/src/bot/startup.py index 0a5422d2..8e52249f 100644 --- a/kdb-bot/src/bot/startup.py +++ b/bot/src/bot/startup.py @@ -50,7 +50,9 @@ class Startup(StartupABC): services.add_singleton(CustomFileLoggerABC, ApiLogger) services.add_translation() - services.add_db_context(DBContext, self._config.get_configuration(DatabaseSettings)) + services.add_db_context( + DBContext, self._config.get_configuration(DatabaseSettings) + ) provider = services.build_service_provider() # instantiate custom logger diff --git a/kdb-bot/src/bot/startup_discord_extension.py b/bot/src/bot/startup_discord_extension.py similarity index 67% rename from kdb-bot/src/bot/startup_discord_extension.py rename to bot/src/bot/startup_discord_extension.py index 196017dc..73411881 100644 --- a/kdb-bot/src/bot/startup_discord_extension.py +++ b/bot/src/bot/startup_discord_extension.py @@ -9,9 +9,13 @@ class StartupDiscordExtension(StartupExtensionABC): def __init__(self): pass - def configure_configuration(self, config: ConfigurationABC, env: ApplicationEnvironmentABC): + def configure_configuration( + self, config: ConfigurationABC, env: ApplicationEnvironmentABC + ): pass - def configure_services(self, services: ServiceCollectionABC, env: ApplicationEnvironmentABC): + def configure_services( + self, services: ServiceCollectionABC, env: ApplicationEnvironmentABC + ): services.add_discord() dcc = get_discord_collection(services) diff --git a/kdb-bot/src/bot/startup_migration_extension.py b/bot/src/bot/startup_migration_extension.py similarity index 52% rename from kdb-bot/src/bot/startup_migration_extension.py rename to bot/src/bot/startup_migration_extension.py index bef5cd4d..a874e2f4 100644 --- a/kdb-bot/src/bot/startup_migration_extension.py +++ b/bot/src/bot/startup_migration_extension.py @@ -10,7 +10,9 @@ 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.birthday_migration import BirthdayMigration -from bot_data.migration.config_feature_flags_migration import ConfigFeatureFlagsMigration +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 @@ -20,10 +22,14 @@ from bot_data.migration.initial_migration import InitialMigration from bot_data.migration.level_migration import LevelMigration from bot_data.migration.remove_stats_migration import RemoveStatsMigration from bot_data.migration.short_role_name_migration import ShortRoleNameMigration -from bot_data.migration.short_role_name_only_highest_migration import ShortRoleNameOnlyHighestMigration +from bot_data.migration.short_role_name_only_highest_migration import ( + ShortRoleNameOnlyHighestMigration, +) from bot_data.migration.stats_migration import StatsMigration from bot_data.migration.steam_special_offer_migration import SteamSpecialOfferMigration -from bot_data.migration.user_joined_game_server_migration import UserJoinedGameServerMigration +from bot_data.migration.user_joined_game_server_migration import ( + UserJoinedGameServerMigration, +) from bot_data.migration.user_message_count_per_hour_migration import ( UserMessageCountPerHourMigration, ) @@ -35,30 +41,66 @@ class StartupMigrationExtension(StartupExtensionABC): def __init__(self): pass - def configure_configuration(self, config: ConfigurationABC, env: ApplicationEnvironmentABC): + def configure_configuration( + self, config: ConfigurationABC, env: ApplicationEnvironmentABC + ): pass - def configure_services(self, services: ServiceCollectionABC, env: ApplicationEnvironmentABC): + def configure_services( + self, services: ServiceCollectionABC, env: ApplicationEnvironmentABC + ): services.add_transient(MigrationService) services.add_transient(MigrationABC, InitialMigration) - services.add_transient(MigrationABC, AutoRoleMigration) # 03.10.2022 #54 - 0.2.2 + services.add_transient( + MigrationABC, AutoRoleMigration + ) # 03.10.2022 #54 - 0.2.2 services.add_transient(MigrationABC, ApiMigration) # 15.10.2022 #70 - 0.3.0 services.add_transient(MigrationABC, LevelMigration) # 06.11.2022 #25 - 0.3.0 services.add_transient(MigrationABC, StatsMigration) # 09.11.2022 #46 - 0.3.0 - services.add_transient(MigrationABC, AutoRoleFix1Migration) # 30.12.2022 #151 - 0.3.0 - services.add_transient(MigrationABC, UserMessageCountPerHourMigration) # 11.01.2023 #168 - 0.3.1 + services.add_transient( + MigrationABC, AutoRoleFix1Migration + ) # 30.12.2022 #151 - 0.3.0 + services.add_transient( + MigrationABC, UserMessageCountPerHourMigration + ) # 11.01.2023 #168 - 0.3.1 services.add_transient(MigrationABC, ApiKeyMigration) # 09.02.2023 #162 - 1.0.0 - services.add_transient(MigrationABC, UserJoinedGameServerMigration) # 12.02.2023 #181 - 1.0.0 - services.add_transient(MigrationABC, RemoveStatsMigration) # 19.02.2023 #190 - 1.0.0 - services.add_transient(MigrationABC, UserWarningMigration) # 21.02.2023 #35 - 1.0.0 - 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, UserJoinedGameServerMigration + ) # 12.02.2023 #181 - 1.0.0 + services.add_transient( + MigrationABC, RemoveStatsMigration + ) # 19.02.2023 #190 - 1.0.0 + services.add_transient( + MigrationABC, UserWarningMigration + ) # 21.02.2023 #35 - 1.0.0 + 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 - services.add_transient(MigrationABC, ShortRoleNameMigration) # 28.09.2023 #378 - 1.1.7 - services.add_transient(MigrationABC, FixUpdatesMigration) # 28.09.2023 #378 - 1.1.7 - services.add_transient(MigrationABC, ShortRoleNameOnlyHighestMigration) # 02.10.2023 #391 - 1.1.9 - services.add_transient(MigrationABC, FixUserHistoryMigration) # 10.10.2023 #401 - 1.2.0 - services.add_transient(MigrationABC, BirthdayMigration) # 10.10.2023 #401 - 1.2.0 - services.add_transient(MigrationABC, SteamSpecialOfferMigration) # 10.10.2023 #188 - 1.2.0 + services.add_transient( + MigrationABC, ConfigFeatureFlagsMigration + ) # 15.08.2023 #334 - 1.1.0 + services.add_transient( + MigrationABC, DefaultRoleMigration + ) # 24.09.2023 #360 - 1.1.3 + services.add_transient( + MigrationABC, ShortRoleNameMigration + ) # 28.09.2023 #378 - 1.1.7 + services.add_transient( + MigrationABC, FixUpdatesMigration + ) # 28.09.2023 #378 - 1.1.7 + services.add_transient( + MigrationABC, ShortRoleNameOnlyHighestMigration + ) # 02.10.2023 #391 - 1.1.9 + services.add_transient( + MigrationABC, FixUserHistoryMigration + ) # 10.10.2023 #401 - 1.2.0 + services.add_transient( + MigrationABC, BirthdayMigration + ) # 10.10.2023 #401 - 1.2.0 + services.add_transient( + MigrationABC, SteamSpecialOfferMigration + ) # 10.10.2023 #188 - 1.2.0 diff --git a/kdb-bot/src/bot/startup_module_extension.py b/bot/src/bot/startup_module_extension.py similarity index 86% rename from kdb-bot/src/bot/startup_module_extension.py rename to bot/src/bot/startup_module_extension.py index 2d87319d..c3f1789e 100644 --- a/kdb-bot/src/bot/startup_module_extension.py +++ b/bot/src/bot/startup_module_extension.py @@ -18,11 +18,15 @@ class StartupModuleExtension(StartupExtensionABC): self._modules = ModuleList.get_modules() - def configure_configuration(self, config: ConfigurationABC, env: ApplicationEnvironmentABC): + def configure_configuration( + self, config: ConfigurationABC, env: ApplicationEnvironmentABC + ): self._config = config self._feature_flags = config.get_configuration(FeatureFlagsSettings) - def configure_services(self, services: ServiceCollectionABC, env: ApplicationEnvironmentABC): + def configure_services( + self, services: ServiceCollectionABC, env: ApplicationEnvironmentABC + ): provider = services.build_service_provider() dc_collection: DiscordCollectionABC = provider.get_service(DiscordCollectionABC) diff --git a/kdb-bot/src/bot/startup_settings_extension.py b/bot/src/bot/startup_settings_extension.py similarity index 64% rename from kdb-bot/src/bot/startup_settings_extension.py rename to bot/src/bot/startup_settings_extension.py index caf34f19..ad45ee9b 100644 --- a/kdb-bot/src/bot/startup_settings_extension.py +++ b/bot/src/bot/startup_settings_extension.py @@ -14,26 +14,38 @@ class StartupSettingsExtension(StartupExtensionABC): def __init__(self): self._start_time = datetime.now() - def configure_configuration(self, configuration: ConfigurationABC, environment: ApplicationEnvironmentABC): + def configure_configuration( + self, configuration: ConfigurationABC, environment: ApplicationEnvironmentABC + ): # this shit has to be done here because we need settings in subsequent startup extensions environment.set_working_directory(os.path.dirname(os.path.realpath(__file__))) configuration.add_environment_variables("KDB_") configuration.add_environment_variables("DISCORD_") configuration.add_json_file(f"config/appsettings.json", optional=False) - configuration.add_json_file(f"config/appsettings.{environment.environment_name}.json", optional=True) - configuration.add_json_file(f"config/appsettings.{environment.host_name}.json", optional=True) + configuration.add_json_file( + f"config/appsettings.{environment.environment_name}.json", optional=True + ) + configuration.add_json_file( + f"config/appsettings.{environment.host_name}.json", optional=True + ) # load feature-flags configuration.add_json_file(f"config/feature-flags.json", optional=False) - configuration.add_json_file(f"config/feature-flags.{environment.environment_name}.json", optional=True) - configuration.add_json_file(f"config/feature-flags.{environment.host_name}.json", optional=True) + configuration.add_json_file( + f"config/feature-flags.{environment.environment_name}.json", optional=True + ) + configuration.add_json_file( + f"config/feature-flags.{environment.host_name}.json", optional=True + ) configuration.add_configuration("Startup_StartTime", str(self._start_time)) self._configure_settings_with_sub_settings( configuration, BotLoggingSettings, lambda x: x.files, lambda x: x.key ) - def configure_services(self, services: ServiceCollectionABC, env: ApplicationEnvironmentABC): + def configure_services( + self, services: ServiceCollectionABC, env: ApplicationEnvironmentABC + ): pass @staticmethod @@ -45,4 +57,6 @@ class StartupSettingsExtension(StartupExtensionABC): return for sub_settings in list_atr(settings): - config.add_configuration(f"{type(sub_settings).__name__}_{atr(sub_settings)}", sub_settings) + config.add_configuration( + f"{type(sub_settings).__name__}_{atr(sub_settings)}", sub_settings + ) diff --git a/kdb-bot/src/bot/translation/de.json b/bot/src/bot/translation/de.json similarity index 100% rename from kdb-bot/src/bot/translation/de.json rename to bot/src/bot/translation/de.json diff --git a/kdb-bot/src/bot_api/__init__.py b/bot/src/bot_api/__init__.py similarity index 100% rename from kdb-bot/src/bot_api/__init__.py rename to bot/src/bot_api/__init__.py diff --git a/kdb-bot/src/bot_api/abc/__init__.py b/bot/src/bot_api/abc/__init__.py similarity index 100% rename from kdb-bot/src/bot_api/abc/__init__.py rename to bot/src/bot_api/abc/__init__.py diff --git a/kdb-bot/src/bot_api/abc/auth_service_abc.py b/bot/src/bot_api/abc/auth_service_abc.py similarity index 92% rename from kdb-bot/src/bot_api/abc/auth_service_abc.py rename to bot/src/bot_api/abc/auth_service_abc.py index 1ba5fbbb..812b3c30 100644 --- a/kdb-bot/src/bot_api/abc/auth_service_abc.py +++ b/bot/src/bot_api/abc/auth_service_abc.py @@ -40,11 +40,15 @@ class AuthServiceABC(ABC): pass @abstractmethod - async def get_filtered_auth_users_async(self, criteria: AuthUserSelectCriteria) -> AuthUserFilteredResultDTO: + async def get_filtered_auth_users_async( + self, criteria: AuthUserSelectCriteria + ) -> AuthUserFilteredResultDTO: pass @abstractmethod - async def get_auth_user_by_email_async(self, email: str, with_password: bool = False) -> AuthUserDTO: + async def get_auth_user_by_email_async( + self, email: str, with_password: bool = False + ) -> AuthUserDTO: pass @abstractmethod diff --git a/kdb-bot/src/bot_api/abc/dto_abc.py b/bot/src/bot_api/abc/dto_abc.py similarity index 100% rename from kdb-bot/src/bot_api/abc/dto_abc.py rename to bot/src/bot_api/abc/dto_abc.py diff --git a/kdb-bot/src/bot_api/abc/select_criteria_abc.py b/bot/src/bot_api/abc/select_criteria_abc.py similarity index 68% rename from kdb-bot/src/bot_api/abc/select_criteria_abc.py rename to bot/src/bot_api/abc/select_criteria_abc.py index 950b5203..2c54df69 100644 --- a/kdb-bot/src/bot_api/abc/select_criteria_abc.py +++ b/bot/src/bot_api/abc/select_criteria_abc.py @@ -3,7 +3,9 @@ from abc import ABC, abstractmethod class SelectCriteriaABC(ABC): @abstractmethod - def __init__(self, page_index: int, page_size: int, sort_direction: str, sort_column: str): + def __init__( + self, page_index: int, page_size: int, sort_direction: str, sort_column: str + ): self.page_index = page_index self.page_size = page_size self.sort_direction = sort_direction diff --git a/kdb-bot/src/bot_api/abc/transformer_abc.py b/bot/src/bot_api/abc/transformer_abc.py similarity index 100% rename from kdb-bot/src/bot_api/abc/transformer_abc.py rename to bot/src/bot_api/abc/transformer_abc.py diff --git a/kdb-bot/src/bot_api/api.py b/bot/src/bot_api/api.py similarity index 92% rename from kdb-bot/src/bot_api/api.py rename to bot/src/bot_api/api.py index dd086b2d..587f0503 100644 --- a/kdb-bot/src/bot_api/api.py +++ b/bot/src/bot_api/api.py @@ -57,7 +57,9 @@ class Api(Flask): # Added async_mode see link below # https://github.com/miguelgrinberg/Flask-SocketIO/discussions/1849 # https://stackoverflow.com/questions/39370848/flask-socket-io-sometimes-client-calls-freeze-the-server - self._socketio = SocketIO(self, cors_allowed_origins="*", path="/api/socket.io", async_mode="eventlet") + self._socketio = SocketIO( + self, cors_allowed_origins="*", path="/api/socket.io", async_mode="eventlet" + ) self._socketio.on_event("connect", self.on_connect) self._socketio.on_event("disconnect", self.on_disconnect) @@ -143,19 +145,26 @@ class Api(Flask): data = request.get_data() data = "" if len(data) == 0 else str(data.decode(encoding="utf-8")) - text = textwrap.dedent(f"Request: {request_id}:\n\tHeader:\n\t\t{headers}\n\tResponse: {data}") + text = textwrap.dedent( + f"Request: {request_id}:\n\tHeader:\n\t\t{headers}\n\tResponse: {data}" + ) self._logger.trace(__name__, text) return response def start(self): - self._logger.info(__name__, f"Starting API {self._api_settings.host}:{self._api_settings.port}") + self._logger.info( + __name__, + f"Starting API {self._api_settings.host}:{self._api_settings.port}", + ) self._register_routes() self.secret_key = CredentialManager.decrypt(self._auth_settings.secret_key) # from waitress import serve # https://docs.pylonsproject.org/projects/waitress/en/stable/arguments.html # serve(self, host=self._apt_settings.host, port=self._apt_settings.port, threads=10, connection_limit=1000, channel_timeout=10) - self._socket = eventlet.listen((self._api_settings.host, self._api_settings.port)) + self._socket = eventlet.listen( + (self._api_settings.host, self._api_settings.port) + ) wsgi.server(self._socket, self, log_output=False) def stop(self): diff --git a/kdb-bot/src/bot_api/api_module.py b/bot/src/bot_api/api_module.py similarity index 86% rename from kdb-bot/src/bot_api/api_module.py rename to bot/src/bot_api/api_module.py index b2695e12..13a28547 100644 --- a/kdb-bot/src/bot_api/api_module.py +++ b/bot/src/bot_api/api_module.py @@ -26,15 +26,21 @@ class ApiModule(ModuleABC): def __init__(self, dc: DiscordCollectionABC): ModuleABC.__init__(self, dc, FeatureFlagsEnum.api_module) - def configure_configuration(self, config: ConfigurationABC, env: ApplicationEnvironmentABC): + def configure_configuration( + self, config: ConfigurationABC, env: ApplicationEnvironmentABC + ): cwd = env.working_directory env.set_working_directory(os.path.dirname(os.path.realpath(__file__))) config.add_json_file(f"config/apisettings.json", optional=False) - config.add_json_file(f"config/apisettings.{env.environment_name}.json", optional=True) + config.add_json_file( + f"config/apisettings.{env.environment_name}.json", optional=True + ) config.add_json_file(f"config/apisettings.{env.host_name}.json", optional=True) env.set_working_directory(cwd) - def configure_services(self, services: ServiceCollectionABC, env: ApplicationEnvironmentABC): + def configure_services( + self, services: ServiceCollectionABC, env: ApplicationEnvironmentABC + ): services.add_singleton(EMailClientABC, EMailClient) services.add_singleton(ApiThread) diff --git a/kdb-bot/src/bot_api/api_thread.py b/bot/src/bot_api/api_thread.py similarity index 100% rename from kdb-bot/src/bot_api/api_thread.py rename to bot/src/bot_api/api_thread.py diff --git a/kdb-bot/src/bot_api/app_api_extension.py b/bot/src/bot_api/app_api_extension.py similarity index 93% rename from kdb-bot/src/bot_api/app_api_extension.py rename to bot/src/bot_api/app_api_extension.py index ea9fda56..da1ac033 100644 --- a/kdb-bot/src/bot_api/app_api_extension.py +++ b/bot/src/bot_api/app_api_extension.py @@ -12,7 +12,9 @@ class AppApiExtension(ApplicationExtensionABC): ApplicationExtensionABC.__init__(self) async def run(self, config: ConfigurationABC, services: ServiceProviderABC): - feature_flags: FeatureFlagsSettings = config.get_configuration(FeatureFlagsSettings) + feature_flags: FeatureFlagsSettings = config.get_configuration( + FeatureFlagsSettings + ) if not feature_flags.get_flag(FeatureFlagsEnum.api_module): return diff --git a/kdb-bot/src/bot_api/bot-api.json b/bot/src/bot_api/bot-api.json similarity index 100% rename from kdb-bot/src/bot_api/bot-api.json rename to bot/src/bot_api/bot-api.json diff --git a/kdb-bot/src/bot_api/configuration/__init__.py b/bot/src/bot_api/configuration/__init__.py similarity index 100% rename from kdb-bot/src/bot_api/configuration/__init__.py rename to bot/src/bot_api/configuration/__init__.py diff --git a/kdb-bot/src/bot_api/configuration/api_settings.py b/bot/src/bot_api/configuration/api_settings.py similarity index 100% rename from kdb-bot/src/bot_api/configuration/api_settings.py rename to bot/src/bot_api/configuration/api_settings.py diff --git a/kdb-bot/src/bot_api/configuration/authentication_settings.py b/bot/src/bot_api/configuration/authentication_settings.py similarity index 89% rename from kdb-bot/src/bot_api/configuration/authentication_settings.py rename to bot/src/bot_api/configuration/authentication_settings.py index b9c3fff2..3dfb2442 100644 --- a/kdb-bot/src/bot_api/configuration/authentication_settings.py +++ b/bot/src/bot_api/configuration/authentication_settings.py @@ -16,7 +16,9 @@ class AuthenticationSettings(ConfigurationModelABC): self._issuer = "" if issuer is None else issuer self._audience = "" if audience is None else audience self._token_expire_time = 0 if token_expire_time is None else token_expire_time - self._refresh_token_expire_time = 0 if refresh_token_expire_time is None else refresh_token_expire_time + self._refresh_token_expire_time = ( + 0 if refresh_token_expire_time is None else refresh_token_expire_time + ) @property def secret_key(self) -> str: diff --git a/kdb-bot/src/bot_api/configuration/discord_authentication_settings.py b/bot/src/bot_api/configuration/discord_authentication_settings.py similarity index 100% rename from kdb-bot/src/bot_api/configuration/discord_authentication_settings.py rename to bot/src/bot_api/configuration/discord_authentication_settings.py diff --git a/kdb-bot/src/bot_api/configuration/frontend_settings.py b/bot/src/bot_api/configuration/frontend_settings.py similarity index 100% rename from kdb-bot/src/bot_api/configuration/frontend_settings.py rename to bot/src/bot_api/configuration/frontend_settings.py diff --git a/kdb-bot/src/bot_api/controller/__init__.py b/bot/src/bot_api/controller/__init__.py similarity index 100% rename from kdb-bot/src/bot_api/controller/__init__.py rename to bot/src/bot_api/controller/__init__.py diff --git a/kdb-bot/src/bot_api/controller/auth_controller.py b/bot/src/bot_api/controller/auth_controller.py similarity index 83% rename from kdb-bot/src/bot_api/controller/auth_controller.py rename to bot/src/bot_api/controller/auth_controller.py index 983b5fb9..b5970ce4 100644 --- a/kdb-bot/src/bot_api/controller/auth_controller.py +++ b/bot/src/bot_api/controller/auth_controller.py @@ -70,7 +70,9 @@ class AuthController: @Route.post(f"{BasePath}/register") async def register(self): - dto: AuthUserDTO = JSONProcessor.process(AuthUserDTO, request.get_json(force=True, silent=True)) + dto: AuthUserDTO = JSONProcessor.process( + AuthUserDTO, request.get_json(force=True, silent=True) + ) self._auth_service.add_auth_user(dto) return "", 200 @@ -81,7 +83,9 @@ class AuthController: @Route.post(f"{BasePath}/login") async def login(self) -> Response: - dto: AuthUserDTO = JSONProcessor.process(AuthUserDTO, request.get_json(force=True, silent=True)) + dto: AuthUserDTO = JSONProcessor.process( + AuthUserDTO, request.get_json(force=True, silent=True) + ) result = await self._auth_service.login_async(dto) return jsonify(result.to_dict()) @@ -110,40 +114,52 @@ class AuthController: @Route.post(f"{BasePath}/reset-password") async def reset_password(self): - dto: ResetPasswordDTO = JSONProcessor.process(ResetPasswordDTO, request.get_json(force=True, silent=True)) + dto: ResetPasswordDTO = JSONProcessor.process( + ResetPasswordDTO, request.get_json(force=True, silent=True) + ) await self._auth_service.reset_password_async(dto) return "", 200 @Route.post(f"{BasePath}/update-user") @Route.authorize async def update_user(self): - dto: UpdateAuthUserDTO = JSONProcessor.process(UpdateAuthUserDTO, request.get_json(force=True, silent=True)) + dto: UpdateAuthUserDTO = JSONProcessor.process( + UpdateAuthUserDTO, request.get_json(force=True, silent=True) + ) await self._auth_service.update_user_async(dto) return "", 200 @Route.post(f"{BasePath}/update-user-as-admin") @Route.authorize(role=AuthRoleEnum.admin) async def update_user_as_admin(self): - dto: UpdateAuthUserDTO = JSONProcessor.process(UpdateAuthUserDTO, request.get_json(force=True, silent=True)) + dto: UpdateAuthUserDTO = JSONProcessor.process( + UpdateAuthUserDTO, request.get_json(force=True, silent=True) + ) await self._auth_service.update_user_as_admin_async(dto) return "", 200 @Route.post(f"{BasePath}/refresh") async def refresh(self) -> Response: - dto: TokenDTO = JSONProcessor.process(TokenDTO, request.get_json(force=True, silent=True)) + dto: TokenDTO = JSONProcessor.process( + TokenDTO, request.get_json(force=True, silent=True) + ) result = await self._auth_service.refresh_async(dto) return jsonify(result.to_dict()) @Route.post(f"{BasePath}/revoke") async def revoke(self): - dto: TokenDTO = JSONProcessor.process(TokenDTO, request.get_json(force=True, silent=True)) + dto: TokenDTO = JSONProcessor.process( + TokenDTO, request.get_json(force=True, silent=True) + ) await self._auth_service.revoke_async(dto) return "", 200 @Route.post(f"{BasePath}/delete-user") @Route.authorize(role=AuthRoleEnum.admin) async def delete_user(self): - dto: AuthUserDTO = JSONProcessor.process(AuthUserDTO, request.get_json(force=True, silent=True)) + dto: AuthUserDTO = JSONProcessor.process( + AuthUserDTO, request.get_json(force=True, silent=True) + ) await self._auth_service.delete_auth_user_async(dto) return "", 200 diff --git a/kdb-bot/src/bot_api/controller/auth_discord_controller.py b/bot/src/bot_api/controller/auth_discord_controller.py similarity index 100% rename from kdb-bot/src/bot_api/controller/auth_discord_controller.py rename to bot/src/bot_api/controller/auth_discord_controller.py diff --git a/kdb-bot/src/bot_api/controller/graphql_controller.py b/bot/src/bot_api/controller/graphql_controller.py similarity index 100% rename from kdb-bot/src/bot_api/controller/graphql_controller.py rename to bot/src/bot_api/controller/graphql_controller.py diff --git a/kdb-bot/src/bot_api/controller/gui_controller.py b/bot/src/bot_api/controller/gui_controller.py similarity index 100% rename from kdb-bot/src/bot_api/controller/gui_controller.py rename to bot/src/bot_api/controller/gui_controller.py diff --git a/kdb-bot/src/bot_api/event/__init__.py b/bot/src/bot_api/event/__init__.py similarity index 100% rename from kdb-bot/src/bot_api/event/__init__.py rename to bot/src/bot_api/event/__init__.py diff --git a/kdb-bot/src/bot_api/event/bot_api_on_ready_event.py b/bot/src/bot_api/event/bot_api_on_ready_event.py similarity index 100% rename from kdb-bot/src/bot_api/event/bot_api_on_ready_event.py rename to bot/src/bot_api/event/bot_api_on_ready_event.py diff --git a/kdb-bot/src/bot_api/exception/__init__.py b/bot/src/bot_api/exception/__init__.py similarity index 100% rename from kdb-bot/src/bot_api/exception/__init__.py rename to bot/src/bot_api/exception/__init__.py diff --git a/kdb-bot/src/bot_api/exception/service_error_code_enum.py b/bot/src/bot_api/exception/service_error_code_enum.py similarity index 100% rename from kdb-bot/src/bot_api/exception/service_error_code_enum.py rename to bot/src/bot_api/exception/service_error_code_enum.py diff --git a/kdb-bot/src/bot_api/exception/service_exception.py b/bot/src/bot_api/exception/service_exception.py similarity index 100% rename from kdb-bot/src/bot_api/exception/service_exception.py rename to bot/src/bot_api/exception/service_exception.py diff --git a/kdb-bot/src/bot_api/filter/__init__.py b/bot/src/bot_api/filter/__init__.py similarity index 100% rename from kdb-bot/src/bot_api/filter/__init__.py rename to bot/src/bot_api/filter/__init__.py diff --git a/kdb-bot/src/bot_api/filter/auth_user_select_criteria.py b/bot/src/bot_api/filter/auth_user_select_criteria.py similarity index 80% rename from kdb-bot/src/bot_api/filter/auth_user_select_criteria.py rename to bot/src/bot_api/filter/auth_user_select_criteria.py index eaa2ee7f..b19b8ead 100644 --- a/kdb-bot/src/bot_api/filter/auth_user_select_criteria.py +++ b/bot/src/bot_api/filter/auth_user_select_criteria.py @@ -13,7 +13,9 @@ class AuthUserSelectCriteria(SelectCriteriaABC): email: str, auth_role: int, ): - SelectCriteriaABC.__init__(self, page_index, page_size, sort_direction, sort_column) + SelectCriteriaABC.__init__( + self, page_index, page_size, sort_direction, sort_column + ) self.first_name = first_name self.last_name = last_name diff --git a/kdb-bot/src/bot_api/filter/discord/__init__.py b/bot/src/bot_api/filter/discord/__init__.py similarity index 100% rename from kdb-bot/src/bot_api/filter/discord/__init__.py rename to bot/src/bot_api/filter/discord/__init__.py diff --git a/kdb-bot/src/bot_api/filter/discord/server_select_criteria.py b/bot/src/bot_api/filter/discord/server_select_criteria.py similarity index 72% rename from kdb-bot/src/bot_api/filter/discord/server_select_criteria.py rename to bot/src/bot_api/filter/discord/server_select_criteria.py index 5f194809..73196b60 100644 --- a/kdb-bot/src/bot_api/filter/discord/server_select_criteria.py +++ b/bot/src/bot_api/filter/discord/server_select_criteria.py @@ -10,6 +10,8 @@ class ServerSelectCriteria(SelectCriteriaABC): sort_column: str, name: str, ): - SelectCriteriaABC.__init__(self, page_index, page_size, sort_direction, sort_column) + SelectCriteriaABC.__init__( + self, page_index, page_size, sort_direction, sort_column + ) self.name = name diff --git a/kdb-bot/src/bot_api/json_processor.py b/bot/src/bot_api/json_processor.py similarity index 100% rename from kdb-bot/src/bot_api/json_processor.py rename to bot/src/bot_api/json_processor.py diff --git a/kdb-bot/src/bot_api/logging/__init__.py b/bot/src/bot_api/logging/__init__.py similarity index 100% rename from kdb-bot/src/bot_api/logging/__init__.py rename to bot/src/bot_api/logging/__init__.py diff --git a/kdb-bot/src/bot_api/logging/api_logger.py b/bot/src/bot_api/logging/api_logger.py similarity index 100% rename from kdb-bot/src/bot_api/logging/api_logger.py rename to bot/src/bot_api/logging/api_logger.py diff --git a/kdb-bot/src/bot_api/model/__init__.py b/bot/src/bot_api/model/__init__.py similarity index 100% rename from kdb-bot/src/bot_api/model/__init__.py rename to bot/src/bot_api/model/__init__.py diff --git a/kdb-bot/src/bot_api/model/auth_user_dto.py b/bot/src/bot_api/model/auth_user_dto.py similarity index 100% rename from kdb-bot/src/bot_api/model/auth_user_dto.py rename to bot/src/bot_api/model/auth_user_dto.py diff --git a/kdb-bot/src/bot_api/model/auth_user_filtered_result_dto.py b/bot/src/bot_api/model/auth_user_filtered_result_dto.py similarity index 100% rename from kdb-bot/src/bot_api/model/auth_user_filtered_result_dto.py rename to bot/src/bot_api/model/auth_user_filtered_result_dto.py diff --git a/kdb-bot/src/bot_api/model/discord/__init__.py b/bot/src/bot_api/model/discord/__init__.py similarity index 100% rename from kdb-bot/src/bot_api/model/discord/__init__.py rename to bot/src/bot_api/model/discord/__init__.py diff --git a/kdb-bot/src/bot_api/model/discord/server_dto.py b/bot/src/bot_api/model/discord/server_dto.py similarity index 100% rename from kdb-bot/src/bot_api/model/discord/server_dto.py rename to bot/src/bot_api/model/discord/server_dto.py diff --git a/kdb-bot/src/bot_api/model/discord/server_filtered_result_dto.py b/bot/src/bot_api/model/discord/server_filtered_result_dto.py similarity index 100% rename from kdb-bot/src/bot_api/model/discord/server_filtered_result_dto.py rename to bot/src/bot_api/model/discord/server_filtered_result_dto.py diff --git a/kdb-bot/src/bot_api/model/email_string_dto.py b/bot/src/bot_api/model/email_string_dto.py similarity index 100% rename from kdb-bot/src/bot_api/model/email_string_dto.py rename to bot/src/bot_api/model/email_string_dto.py diff --git a/kdb-bot/src/bot_api/model/error_dto.py b/bot/src/bot_api/model/error_dto.py similarity index 87% rename from kdb-bot/src/bot_api/model/error_dto.py rename to bot/src/bot_api/model/error_dto.py index 867e581c..c864dece 100644 --- a/kdb-bot/src/bot_api/model/error_dto.py +++ b/bot/src/bot_api/model/error_dto.py @@ -11,7 +11,9 @@ class ErrorDTO(DtoABC): def __init__(self, error_code: Optional[ServiceErrorCode], message: str): DtoABC.__init__(self) - self._error_code = ServiceErrorCode.Unknown if error_code is None else error_code + self._error_code = ( + ServiceErrorCode.Unknown if error_code is None else error_code + ) self._message = message @property diff --git a/kdb-bot/src/bot_api/model/o_auth_dto.py b/bot/src/bot_api/model/o_auth_dto.py similarity index 100% rename from kdb-bot/src/bot_api/model/o_auth_dto.py rename to bot/src/bot_api/model/o_auth_dto.py diff --git a/kdb-bot/src/bot_api/model/reset_password_dto.py b/bot/src/bot_api/model/reset_password_dto.py similarity index 100% rename from kdb-bot/src/bot_api/model/reset_password_dto.py rename to bot/src/bot_api/model/reset_password_dto.py diff --git a/kdb-bot/src/bot_api/model/settings_dto.py b/bot/src/bot_api/model/settings_dto.py similarity index 100% rename from kdb-bot/src/bot_api/model/settings_dto.py rename to bot/src/bot_api/model/settings_dto.py diff --git a/kdb-bot/src/bot_api/model/token_dto.py b/bot/src/bot_api/model/token_dto.py similarity index 82% rename from kdb-bot/src/bot_api/model/token_dto.py rename to bot/src/bot_api/model/token_dto.py index 88ff8501..f8c98922 100644 --- a/kdb-bot/src/bot_api/model/token_dto.py +++ b/bot/src/bot_api/model/token_dto.py @@ -27,4 +27,8 @@ class TokenDTO(DtoABC): self._first_login = values["firstLogin"] def to_dict(self) -> dict: - return {"token": self._token, "refreshToken": self._refresh_token, "firstLogin": self._first_login} + return { + "token": self._token, + "refreshToken": self._refresh_token, + "firstLogin": self._first_login, + } diff --git a/kdb-bot/src/bot_api/model/update_auth_user_dto.py b/bot/src/bot_api/model/update_auth_user_dto.py similarity index 89% rename from kdb-bot/src/bot_api/model/update_auth_user_dto.py rename to bot/src/bot_api/model/update_auth_user_dto.py index 28e57768..d8361171 100644 --- a/kdb-bot/src/bot_api/model/update_auth_user_dto.py +++ b/bot/src/bot_api/model/update_auth_user_dto.py @@ -34,7 +34,9 @@ class UpdateAuthUserDTO(DtoABC): def from_dict(self, values: dict): self._auth_user = AuthUserDTO().from_dict(values["authUser"]) self._new_auth_user = AuthUserDTO().from_dict(values["newAuthUser"]) - self._change_password = False if "changePassword" not in values else bool(values["changePassword"]) + self._change_password = ( + False if "changePassword" not in values else bool(values["changePassword"]) + ) def to_dict(self) -> dict: return { diff --git a/kdb-bot/src/bot_api/model/user_dto.py b/bot/src/bot_api/model/user_dto.py similarity index 100% rename from kdb-bot/src/bot_api/model/user_dto.py rename to bot/src/bot_api/model/user_dto.py diff --git a/kdb-bot/src/bot_api/model/version_dto.py b/bot/src/bot_api/model/version_dto.py similarity index 100% rename from kdb-bot/src/bot_api/model/version_dto.py rename to bot/src/bot_api/model/version_dto.py diff --git a/kdb-bot/src/bot_api/route/__init__.py b/bot/src/bot_api/route/__init__.py similarity index 100% rename from kdb-bot/src/bot_api/route/__init__.py rename to bot/src/bot_api/route/__init__.py diff --git a/kdb-bot/src/bot_api/route/route.py b/bot/src/bot_api/route/route.py similarity index 84% rename from kdb-bot/src/bot_api/route/route.py rename to bot/src/bot_api/route/route.py index 74278f28..3b0fbc96 100644 --- a/kdb-bot/src/bot_api/route/route.py +++ b/bot/src/bot_api/route/route.py @@ -25,7 +25,12 @@ class Route: @classmethod @ServiceProviderABC.inject - def init_authorize(cls, env: ApplicationEnvironmentABC, auth_users: AuthUserRepositoryABC, auth: AuthServiceABC): + def init_authorize( + cls, + env: ApplicationEnvironmentABC, + auth_users: AuthUserRepositoryABC, + auth: AuthServiceABC, + ): cls._auth_users = auth_users cls._auth = auth cls._env = env.environment_name @@ -52,9 +57,17 @@ class Route: return user @classmethod - def authorize(cls, f: Callable = None, role: AuthRoleEnum = None, skip_in_dev=False, by_api_key=False): + def authorize( + cls, + f: Callable = None, + role: AuthRoleEnum = None, + skip_in_dev=False, + by_api_key=False, + ): if f is None: - return functools.partial(cls.authorize, role=role, skip_in_dev=skip_in_dev, by_api_key=by_api_key) + return functools.partial( + cls.authorize, role=role, skip_in_dev=skip_in_dev, by_api_key=by_api_key + ) @wraps(f) async def decorator(*args, **kwargs): @@ -65,7 +78,9 @@ class Route: api_key = None if "Authorization" in request.headers: if " " not in request.headers.get("Authorization"): - ex = ServiceException(ServiceErrorCode.Unauthorized, f"Token not set") + ex = ServiceException( + ServiceErrorCode.Unauthorized, f"Token not set" + ) error = ErrorDTO(ex.error_code, ex.message) return jsonify(error.to_dict()), 401 @@ -87,7 +102,9 @@ class Route: return jsonify(e), 500 if not valid: - ex = ServiceException(ServiceErrorCode.Unauthorized, f"API-Key invalid") + ex = ServiceException( + ServiceErrorCode.Unauthorized, f"API-Key invalid" + ) error = ErrorDTO(ex.error_code, ex.message) return jsonify(error.to_dict()), 401 @@ -99,7 +116,9 @@ class Route: return jsonify(error.to_dict()), 401 if cls._auth_users is None or cls._auth is None: - ex = ServiceException(ServiceErrorCode.Unauthorized, f"Authorize is not initialized") + ex = ServiceException( + ServiceErrorCode.Unauthorized, f"Authorize is not initialized" + ) error = ErrorDTO(ex.error_code, ex.message) return jsonify(error.to_dict()), 401 @@ -121,7 +140,9 @@ class Route: return jsonify(error.to_dict()), 401 if role is not None and user.auth_role.value < role.value: - ex = ServiceException(ServiceErrorCode.Unauthorized, f"Role {role} required") + ex = ServiceException( + ServiceErrorCode.Unauthorized, f"Role {role} required" + ) error = ErrorDTO(ex.error_code, ex.message) return jsonify(error.to_dict()), 403 diff --git a/kdb-bot/src/bot_api/service/__init__.py b/bot/src/bot_api/service/__init__.py similarity index 100% rename from kdb-bot/src/bot_api/service/__init__.py rename to bot/src/bot_api/service/__init__.py diff --git a/kdb-bot/src/bot_api/service/auth_service.py b/bot/src/bot_api/service/auth_service.py similarity index 82% rename from kdb-bot/src/bot_api/service/auth_service.py rename to bot/src/bot_api/service/auth_service.py index 94410b52..ec93775e 100644 --- a/kdb-bot/src/bot_api/service/auth_service.py +++ b/bot/src/bot_api/service/auth_service.py @@ -90,7 +90,9 @@ class AuthService(AuthServiceABC): def _get_api_key_str(self, api_key: ApiKey) -> str: return hashlib.sha256( - f"{api_key.identifier}:{api_key.key}+{self._auth_settings.secret_key}".encode("utf-8") + f"{api_key.identifier}:{api_key.key}+{self._auth_settings.secret_key}".encode( + "utf-8" + ) ).hexdigest() def generate_token(self, user: AuthUser) -> str: @@ -99,7 +101,8 @@ class AuthService(AuthServiceABC): "user_id": user.id, "email": user.email, "role": user.auth_role.value, - "exp": datetime.now(tz=timezone.utc) + timedelta(days=self._auth_settings.token_expire_time), + "exp": datetime.now(tz=timezone.utc) + + timedelta(days=self._auth_settings.token_expire_time), "iss": self._auth_settings.issuer, "aud": self._auth_settings.audience, }, @@ -155,7 +158,9 @@ class AuthService(AuthServiceABC): def _create_and_save_refresh_token(self, user: AuthUser) -> str: token = str(uuid.uuid4()) user.refresh_token = token - user.refresh_token_expire_time = datetime.now() + timedelta(days=self._auth_settings.refresh_token_expire_time) + user.refresh_token_expire_time = datetime.now() + timedelta( + days=self._auth_settings.refresh_token_expire_time + ) self._auth_users.update_auth_user(user) self._db.save_changes() return token @@ -188,8 +193,12 @@ class AuthService(AuthServiceABC): self._send_link_mail( user.email, - self._t.transform("api.auth.confirmation.subject").format(user.first_name, user.last_name), - self._t.transform("api.auth.confirmation.message").format(url, user.confirmation_id), + self._t.transform("api.auth.confirmation.subject").format( + user.first_name, user.last_name + ), + self._t.transform("api.auth.confirmation.message").format( + url, user.confirmation_id + ), ) def _send_forgot_password_id_to_user(self, user: AuthUser): @@ -199,28 +208,38 @@ class AuthService(AuthServiceABC): self._send_link_mail( user.email, - self._t.transform("api.auth.forgot_password.subject").format(user.first_name, user.last_name), - self._t.transform("api.auth.forgot_password.message").format(url, user.forgot_password_id), + self._t.transform("api.auth.forgot_password.subject").format( + user.first_name, user.last_name + ), + self._t.transform("api.auth.forgot_password.message").format( + url, user.forgot_password_id + ), ) async def get_all_auth_users_async(self) -> List[AuthUserDTO]: result = self._auth_users.get_all_auth_users().select(lambda x: AUT.to_dto(x)) return List(AuthUserDTO, result) - async def get_filtered_auth_users_async(self, criteria: AuthUserSelectCriteria) -> AuthUserFilteredResultDTO: + async def get_filtered_auth_users_async( + self, criteria: AuthUserSelectCriteria + ) -> AuthUserFilteredResultDTO: users = self._auth_users.get_filtered_auth_users(criteria) result = users.result.select(lambda x: AUT.to_dto(x)) return AuthUserFilteredResultDTO(List(AuthUserDTO, result), users.total_count) - async def get_auth_user_by_email_async(self, email: str, with_password: bool = False) -> AuthUserDTO: + async def get_auth_user_by_email_async( + self, email: str, with_password: bool = False + ) -> AuthUserDTO: try: # todo: check if logged in user is admin then send mail user = self._auth_users.get_auth_user_by_email(email) return AUT.to_dto(user, password=user.password if with_password else None) except Exception as e: self._logger.error(__name__, f"AuthUser not found", e) - raise ServiceException(ServiceErrorCode.InvalidData, f"User not found {email}") + raise ServiceException( + ServiceErrorCode.InvalidData, f"User not found {email}" + ) async def find_auth_user_by_email_async(self, email: str) -> Optional[AuthUser]: user = self._auth_users.find_auth_user_by_email(email) @@ -238,16 +257,22 @@ class AuthService(AuthServiceABC): user.password_salt = uuid.uuid4() user.password = self._hash_sha256(user_dto.password, user.password_salt) if not self._is_email_valid(user.email): - raise ServiceException(ServiceErrorCode.InvalidData, "Invalid E-Mail address") + raise ServiceException( + ServiceErrorCode.InvalidData, "Invalid E-Mail address" + ) try: user.confirmation_id = uuid.uuid4() self._auth_users.add_auth_user(user) self._send_confirmation_id_to_user(user) self._db.save_changes() - self._logger.info(__name__, f"Added auth user with E-Mail: {user_dto.email}") + self._logger.info( + __name__, f"Added auth user with E-Mail: {user_dto.email}" + ) except Exception as e: - self._logger.error(__name__, f"Cannot add user with E-Mail {user_dto.email}", e) + self._logger.error( + __name__, f"Cannot add user with E-Mail {user_dto.email}", e + ) raise ServiceException(ServiceErrorCode.UnableToAdd, "Invalid E-Mail") async def add_auth_user_by_oauth_async(self, dto: OAuthDTO): @@ -263,14 +288,20 @@ class AuthService(AuthServiceABC): db_user.first_name = dto.user.first_name db_user.last_name = dto.user.last_name db_user.password_salt = uuid.uuid4() - db_user.password = self._hash_sha256(dto.user.password, db_user.password_salt) + db_user.password = self._hash_sha256( + dto.user.password, db_user.password_salt + ) db_user.oauth_id = None db_user.confirmation_id = uuid.uuid4() self._send_confirmation_id_to_user(db_user) self._auth_users.update_auth_user(db_user) - self._logger.info(__name__, f"Added auth user with E-Mail: {dto.user.email}") + self._logger.info( + __name__, f"Added auth user with E-Mail: {dto.user.email}" + ) except Exception as e: - self._logger.error(__name__, f"Cannot add user with E-Mail {dto.user.email}", e) + self._logger.error( + __name__, f"Cannot add user with E-Mail {dto.user.email}", e + ) raise ServiceException(ServiceErrorCode.UnableToAdd, "Invalid E-Mail") self._db.save_changes() @@ -280,14 +311,16 @@ class AuthService(AuthServiceABC): raise ServiceException(ServiceErrorCode.InvalidData, f"User is empty") if update_user_dto.auth_user is None: - raise ServiceException(ServiceErrorCode.InvalidData, f"Existing user is empty") + raise ServiceException( + ServiceErrorCode.InvalidData, f"Existing user is empty" + ) if update_user_dto.new_auth_user is None: raise ServiceException(ServiceErrorCode.InvalidData, f"New user is empty") - if not self._is_email_valid(update_user_dto.auth_user.email) or not self._is_email_valid( - update_user_dto.new_auth_user.email - ): + if not self._is_email_valid( + update_user_dto.auth_user.email + ) or not self._is_email_valid(update_user_dto.new_auth_user.email): raise ServiceException(ServiceErrorCode.InvalidData, f"Invalid E-Mail") user = self._auth_users.find_auth_user_by_email(update_user_dto.auth_user.email) @@ -300,7 +333,8 @@ class AuthService(AuthServiceABC): # update first name if ( update_user_dto.new_auth_user.first_name is not None - and update_user_dto.auth_user.first_name != update_user_dto.new_auth_user.first_name + and update_user_dto.auth_user.first_name + != update_user_dto.new_auth_user.first_name ): user.first_name = update_user_dto.new_auth_user.first_name @@ -308,7 +342,8 @@ class AuthService(AuthServiceABC): if ( update_user_dto.new_auth_user.last_name is not None and update_user_dto.new_auth_user.last_name != "" - and update_user_dto.auth_user.last_name != update_user_dto.new_auth_user.last_name + and update_user_dto.auth_user.last_name + != update_user_dto.new_auth_user.last_name ): user.last_name = update_user_dto.new_auth_user.last_name @@ -318,22 +353,33 @@ class AuthService(AuthServiceABC): and update_user_dto.new_auth_user.email != "" and update_user_dto.auth_user.email != update_user_dto.new_auth_user.email ): - user_by_new_e_mail = self._auth_users.find_auth_user_by_email(update_user_dto.new_auth_user.email) + user_by_new_e_mail = self._auth_users.find_auth_user_by_email( + update_user_dto.new_auth_user.email + ) if user_by_new_e_mail is not None: - raise ServiceException(ServiceErrorCode.InvalidUser, "User already exists") + raise ServiceException( + ServiceErrorCode.InvalidUser, "User already exists" + ) user.email = update_user_dto.new_auth_user.email - update_user_dto.auth_user.password = self._hash_sha256(update_user_dto.auth_user.password, user.password_salt) + update_user_dto.auth_user.password = self._hash_sha256( + update_user_dto.auth_user.password, user.password_salt + ) if update_user_dto.auth_user.password != user.password: raise ServiceException(ServiceErrorCode.InvalidUser, "Wrong password") # update password if ( update_user_dto.new_auth_user.password is not None - and self._hash_sha256(update_user_dto.new_auth_user.password, user.password_salt) != user.password + and self._hash_sha256( + update_user_dto.new_auth_user.password, user.password_salt + ) + != user.password ): user.password_salt = uuid.uuid4() - user.password = self._hash_sha256(update_user_dto.new_auth_user.password, user.password_salt) + user.password = self._hash_sha256( + update_user_dto.new_auth_user.password, user.password_salt + ) self._auth_users.update_auth_user(user) self._db.save_changes() @@ -343,23 +389,31 @@ class AuthService(AuthServiceABC): raise ServiceException(ServiceErrorCode.InvalidData, f"User is empty") if update_user_dto.auth_user is None: - raise ServiceException(ServiceErrorCode.InvalidData, f"Existing user is empty") + raise ServiceException( + ServiceErrorCode.InvalidData, f"Existing user is empty" + ) if update_user_dto.new_auth_user is None: raise ServiceException(ServiceErrorCode.InvalidData, f"New user is empty") - if not self._is_email_valid(update_user_dto.auth_user.email) or not self._is_email_valid( - update_user_dto.new_auth_user.email - ): + if not self._is_email_valid( + update_user_dto.auth_user.email + ) or not self._is_email_valid(update_user_dto.new_auth_user.email): raise ServiceException(ServiceErrorCode.InvalidData, f"Invalid E-Mail") user = self._auth_users.find_auth_user_by_email(update_user_dto.auth_user.email) if user is None: raise ServiceException(ServiceErrorCode.InvalidUser, "User not found") - if user.confirmation_id is not None and update_user_dto.new_auth_user.is_confirmed: + if ( + user.confirmation_id is not None + and update_user_dto.new_auth_user.is_confirmed + ): user.confirmation_id = None - elif user.confirmation_id is None and not update_user_dto.new_auth_user.is_confirmed: + elif ( + user.confirmation_id is None + and not update_user_dto.new_auth_user.is_confirmed + ): user.confirmation_id = uuid.uuid4() # else # raise ServiceException(ServiceErrorCode.InvalidUser, 'E-Mail not confirmed') @@ -367,7 +421,8 @@ class AuthService(AuthServiceABC): # update first name if ( update_user_dto.new_auth_user.first_name is not None - and update_user_dto.auth_user.first_name != update_user_dto.new_auth_user.first_name + and update_user_dto.auth_user.first_name + != update_user_dto.new_auth_user.first_name ): user.first_name = update_user_dto.new_auth_user.first_name @@ -375,7 +430,8 @@ class AuthService(AuthServiceABC): if ( update_user_dto.new_auth_user.last_name is not None and update_user_dto.new_auth_user.last_name != "" - and update_user_dto.auth_user.last_name != update_user_dto.new_auth_user.last_name + and update_user_dto.auth_user.last_name + != update_user_dto.new_auth_user.last_name ): user.last_name = update_user_dto.new_auth_user.last_name @@ -385,19 +441,28 @@ class AuthService(AuthServiceABC): and update_user_dto.new_auth_user.email != "" and update_user_dto.auth_user.email != update_user_dto.new_auth_user.email ): - user_by_new_e_mail = self._auth_users.find_auth_user_by_email(update_user_dto.new_auth_user.email) + user_by_new_e_mail = self._auth_users.find_auth_user_by_email( + update_user_dto.new_auth_user.email + ) if user_by_new_e_mail is not None: - raise ServiceException(ServiceErrorCode.InvalidUser, "User already exists") + raise ServiceException( + ServiceErrorCode.InvalidUser, "User already exists" + ) user.email = update_user_dto.new_auth_user.email # update password if ( update_user_dto.new_auth_user.password is not None and update_user_dto.change_password - and user.password != self._hash_sha256(update_user_dto.new_auth_user.password, user.password_salt) + and user.password + != self._hash_sha256( + update_user_dto.new_auth_user.password, user.password_salt + ) ): user.password_salt = uuid.uuid4() - user.password = self._hash_sha256(update_user_dto.new_auth_user.password, user.password_salt) + user.password = self._hash_sha256( + update_user_dto.new_auth_user.password, user.password_salt + ) # update role if ( @@ -416,7 +481,9 @@ class AuthService(AuthServiceABC): self._db.save_changes() except Exception as e: self._logger.error(__name__, f"Cannot delete user", e) - raise ServiceException(ServiceErrorCode.UnableToDelete, f"Cannot delete user by mail {email}") + raise ServiceException( + ServiceErrorCode.UnableToDelete, f"Cannot delete user by mail {email}" + ) async def delete_auth_user_async(self, user_dto: AuthUser): try: @@ -500,7 +567,9 @@ class AuthService(AuthServiceABC): if user.id in user_ids: continue - self._auth_users.add_auth_user_user_rel(AuthUserUsersRelation(db_user, user)) + self._auth_users.add_auth_user_user_rel( + AuthUserUsersRelation(db_user, user) + ) if db_user.confirmation_id is not None and not added_user: raise ServiceException(ServiceErrorCode.Forbidden, "E-Mail not verified") @@ -530,13 +599,19 @@ class AuthService(AuthServiceABC): ): raise ServiceException(ServiceErrorCode.InvalidData, "Token expired") - return TokenDTO(self.generate_token(user), self._create_and_save_refresh_token(user)) + return TokenDTO( + self.generate_token(user), self._create_and_save_refresh_token(user) + ) except Exception as e: self._logger.error(__name__, f"Refreshing token failed", e) return TokenDTO("", "") async def revoke_async(self, token_dto: TokenDTO): - if token_dto is None or token_dto.token is None or token_dto.refresh_token is None: + if ( + token_dto is None + or token_dto.token is None + or token_dto.refresh_token is None + ): raise ServiceException(ServiceErrorCode.InvalidData, "Token not set") try: @@ -589,7 +664,9 @@ class AuthService(AuthServiceABC): ) if user.confirmation_id is not None: - raise ServiceException(ServiceErrorCode.InvalidUser, f"E-Mail not confirmed") + raise ServiceException( + ServiceErrorCode.InvalidUser, f"E-Mail not confirmed" + ) if user.password is None or rp_dto.password == "": raise ServiceException(ServiceErrorCode.InvalidData, f"Password not set") diff --git a/kdb-bot/src/bot_api/service/discord_service.py b/bot/src/bot_api/service/discord_service.py similarity index 83% rename from kdb-bot/src/bot_api/service/discord_service.py rename to bot/src/bot_api/service/discord_service.py index 386b3046..21e0df82 100644 --- a/kdb-bot/src/bot_api/service/discord_service.py +++ b/bot/src/bot_api/service/discord_service.py @@ -53,13 +53,17 @@ class DiscordService: if role != AuthRoleEnum.admin: auth_user = self._auth_users.find_auth_user_by_email(token["email"]) if auth_user is not None: - user_ids = auth_user.users.select(lambda x: x.server is not None and x.server.id) + user_ids = auth_user.users.select( + lambda x: x.server is not None and x.server.id + ) servers = servers.where(lambda x: x.id in user_ids) servers = List(ServerDTO, servers) return servers.select(self._to_dto).where(lambda x: x.name != "") - async def get_filtered_servers_async(self, criteria: ServerSelectCriteria) -> ServerFilteredResultDTO: + async def get_filtered_servers_async( + self, criteria: ServerSelectCriteria + ) -> ServerFilteredResultDTO: token = self._auth.get_decoded_token_from_request() if token is None or "email" not in token or "role" not in token: raise ServiceException(ServiceErrorCode.InvalidData, "Token invalid") @@ -70,15 +74,22 @@ class DiscordService: if role != AuthRoleEnum.admin: auth_user = self._auth_users.find_auth_user_by_email(token["email"]) if auth_user is not None: - user_ids = auth_user.users.select(lambda x: x.server is not None and x.server.id) - filtered_result.result = filtered_result.result.where(lambda x: x.id in user_ids) + user_ids = auth_user.users.select( + lambda x: x.server is not None and x.server.id + ) + filtered_result.result = filtered_result.result.where( + lambda x: x.id in user_ids + ) - servers: List = filtered_result.result.select(self._to_dto).where(lambda x: x.name != "") + servers: List = filtered_result.result.select(self._to_dto).where( + lambda x: x.name != "" + ) result = List(ServerDTO, servers) if criteria.name is not None and criteria.name != "": result = result.where( - lambda x: criteria.name.lower() in x.name.lower() or x.name.lower() == criteria.name.lower() + lambda x: criteria.name.lower() in x.name.lower() + or x.name.lower() == criteria.name.lower() ) return ServerFilteredResultDTO(List(ServerDTO, result), servers.count()) @@ -87,5 +98,7 @@ class DiscordService: server = self._servers.get_server_by_id(id) guild = self._bot.get_guild(server.discord_id) - server_dto = ServerTransformer.to_dto(server, guild.name, guild.member_count, guild.icon) + server_dto = ServerTransformer.to_dto( + server, guild.name, guild.member_count, guild.icon + ) return server_dto diff --git a/kdb-bot/src/bot_api/transformer/__init__.py b/bot/src/bot_api/transformer/__init__.py similarity index 100% rename from kdb-bot/src/bot_api/transformer/__init__.py rename to bot/src/bot_api/transformer/__init__.py diff --git a/kdb-bot/src/bot_api/transformer/auth_user_transformer.py b/bot/src/bot_api/transformer/auth_user_transformer.py similarity index 84% rename from kdb-bot/src/bot_api/transformer/auth_user_transformer.py rename to bot/src/bot_api/transformer/auth_user_transformer.py index 9e52fec3..83633520 100644 --- a/kdb-bot/src/bot_api/transformer/auth_user_transformer.py +++ b/bot/src/bot_api/transformer/auth_user_transformer.py @@ -27,27 +27,35 @@ class AuthUserTransformer(TransformerABC): None, None, datetime.now(), - AuthRoleEnum.normal if dto.auth_role is None else AuthRoleEnum(dto.auth_role), + AuthRoleEnum.normal + if dto.auth_role is None + else AuthRoleEnum(dto.auth_role), auth_user_id=0 if dto.id is None else dto.id, ) @staticmethod @ServiceProviderABC.inject - def _is_technician(user: User, bot: DiscordBotServiceABC, permissions: PermissionServiceABC): + def _is_technician( + user: User, bot: DiscordBotServiceABC, permissions: PermissionServiceABC + ): guild = bot.get_guild(user.server.discord_id) member = guild.get_member(user.discord_id) return permissions.is_member_technician(member) @staticmethod @ServiceProviderABC.inject - def _is_admin(user: User, bot: DiscordBotServiceABC, permissions: PermissionServiceABC): + def _is_admin( + user: User, bot: DiscordBotServiceABC, permissions: PermissionServiceABC + ): guild = bot.get_guild(user.server.discord_id) member = guild.get_member(user.discord_id) return permissions.is_member_admin(member) @staticmethod @ServiceProviderABC.inject - def _is_moderator(user: User, bot: DiscordBotServiceABC, permissions: PermissionServiceABC): + def _is_moderator( + user: User, bot: DiscordBotServiceABC, permissions: PermissionServiceABC + ): guild = bot.get_guild(user.server.discord_id) member = guild.get_member(user.discord_id) return permissions.is_member_moderator(member) diff --git a/kdb-bot/src/bot_api/transformer/server_transformer.py b/bot/src/bot_api/transformer/server_transformer.py similarity index 81% rename from kdb-bot/src/bot_api/transformer/server_transformer.py rename to bot/src/bot_api/transformer/server_transformer.py index bffba8e1..f4ca5d6f 100644 --- a/kdb-bot/src/bot_api/transformer/server_transformer.py +++ b/bot/src/bot_api/transformer/server_transformer.py @@ -13,7 +13,9 @@ class ServerTransformer(TransformerABC): return Server(dto.discord_id) @staticmethod - def to_dto(db: Server, name: str, member_count: int, icon_url: Optional[discord.Asset]) -> ServerDTO: + def to_dto( + db: Server, name: str, member_count: int, icon_url: Optional[discord.Asset] + ) -> ServerDTO: return ServerDTO( db.id, db.discord_id, diff --git a/kdb-bot/src/bot_core/__init__.py b/bot/src/bot_core/__init__.py similarity index 100% rename from kdb-bot/src/bot_core/__init__.py rename to bot/src/bot_core/__init__.py diff --git a/kdb-bot/src/bot_core/abc/__init__.py b/bot/src/bot_core/abc/__init__.py similarity index 100% rename from kdb-bot/src/bot_core/abc/__init__.py rename to bot/src/bot_core/abc/__init__.py diff --git a/kdb-bot/src/bot_core/abc/client_utils_abc.py b/bot/src/bot_core/abc/client_utils_abc.py similarity index 86% rename from kdb-bot/src/bot_core/abc/client_utils_abc.py rename to bot/src/bot_core/abc/client_utils_abc.py index 045228cb..9dd50401 100644 --- a/kdb-bot/src/bot_core/abc/client_utils_abc.py +++ b/bot/src/bot_core/abc/client_utils_abc.py @@ -45,7 +45,9 @@ class ClientUtilsABC(ABC): pass @abstractmethod - def get_auto_complete_list(self, _l: List, current: str, select: Callable = None) -> List: + def get_auto_complete_list( + self, _l: List, current: str, select: Callable = None + ) -> List: pass @abstractmethod @@ -64,7 +66,11 @@ class ClientUtilsABC(ABC): @abstractmethod async def react_to_message_by_auto_role_rule( - self, discord_channel_id: int, discord_message_id: int, rule: AutoRoleRule, guild: discord.Guild + self, + discord_channel_id: int, + discord_message_id: int, + rule: AutoRoleRule, + guild: discord.Guild, ): pass diff --git a/kdb-bot/src/bot_core/abc/custom_file_logger_abc.py b/bot/src/bot_core/abc/custom_file_logger_abc.py similarity index 92% rename from kdb-bot/src/bot_core/abc/custom_file_logger_abc.py rename to bot/src/bot_core/abc/custom_file_logger_abc.py index 2b2bbe0a..670b90e6 100644 --- a/kdb-bot/src/bot_core/abc/custom_file_logger_abc.py +++ b/bot/src/bot_core/abc/custom_file_logger_abc.py @@ -18,7 +18,9 @@ class CustomFileLoggerABC(Logger, ABC): env: ApplicationEnvironmentABC, ): self._key = key - self._settings: LoggingSettings = config.get_configuration(f"{FileLoggingSettings.__name__}_{key}") + self._settings: LoggingSettings = config.get_configuration( + f"{FileLoggingSettings.__name__}_{key}" + ) Logger.__init__(self, self._settings, time_format, env) self._begin_log() @@ -32,7 +34,9 @@ class CustomFileLoggerABC(Logger, ABC): self.info(__name__, f"Starting...") self._console = LoggingLevelEnum(console_level) - def _get_string(self, name_list_as_str: str, level: LoggingLevelEnum, message: str) -> str: + def _get_string( + self, name_list_as_str: str, level: LoggingLevelEnum, message: str + ) -> str: names = name_list_as_str.split(" ") log_level = level.name string = f"<{self._get_datetime_now()}> [ {log_level} ]" diff --git a/kdb-bot/src/bot_core/abc/message_service_abc.py b/bot/src/bot_core/abc/message_service_abc.py similarity index 92% rename from kdb-bot/src/bot_core/abc/message_service_abc.py rename to bot/src/bot_core/abc/message_service_abc.py index 3dada9a3..019c8b6a 100644 --- a/kdb-bot/src/bot_core/abc/message_service_abc.py +++ b/bot/src/bot_core/abc/message_service_abc.py @@ -13,7 +13,9 @@ class MessageServiceABC(ABC): pass @abstractmethod - async def delete_messages(self, messages: List[discord.Message], guild_id: int, without_tracking=False): + async def delete_messages( + self, messages: List[discord.Message], guild_id: int, without_tracking=False + ): pass @abstractmethod diff --git a/kdb-bot/src/bot_core/abc/module_abc.py b/bot/src/bot_core/abc/module_abc.py similarity index 100% rename from kdb-bot/src/bot_core/abc/module_abc.py rename to bot/src/bot_core/abc/module_abc.py diff --git a/kdb-bot/src/bot_core/abc/task_abc.py b/bot/src/bot_core/abc/task_abc.py similarity index 85% rename from kdb-bot/src/bot_core/abc/task_abc.py rename to bot/src/bot_core/abc/task_abc.py index d068fd37..bb684d8e 100644 --- a/kdb-bot/src/bot_core/abc/task_abc.py +++ b/bot/src/bot_core/abc/task_abc.py @@ -15,7 +15,9 @@ class TaskABC(commands.Cog): commands.Cog.__init__(self) @ServiceProviderABC.inject - async def _wait_until_ready(self, config: ConfigurationABC, logger: TaskLogger, bot: DiscordBotServiceABC): + async def _wait_until_ready( + self, config: ConfigurationABC, logger: TaskLogger, bot: DiscordBotServiceABC + ): logger.debug(__name__, f"Waiting before {type(self).__name__}") await bot.wait_until_ready() diff --git a/kdb-bot/src/bot_core/bot-core.json b/bot/src/bot_core/bot-core.json similarity index 100% rename from kdb-bot/src/bot_core/bot-core.json rename to bot/src/bot_core/bot-core.json diff --git a/kdb-bot/src/bot_core/configuration/__init__.py b/bot/src/bot_core/configuration/__init__.py similarity index 100% rename from kdb-bot/src/bot_core/configuration/__init__.py rename to bot/src/bot_core/configuration/__init__.py diff --git a/kdb-bot/src/bot_core/configuration/bot_logging_settings.py b/bot/src/bot_core/configuration/bot_logging_settings.py similarity index 100% rename from kdb-bot/src/bot_core/configuration/bot_logging_settings.py rename to bot/src/bot_core/configuration/bot_logging_settings.py diff --git a/kdb-bot/src/bot_core/configuration/feature_flags_enum.py b/bot/src/bot_core/configuration/feature_flags_enum.py similarity index 100% rename from kdb-bot/src/bot_core/configuration/feature_flags_enum.py rename to bot/src/bot_core/configuration/feature_flags_enum.py diff --git a/kdb-bot/src/bot_core/configuration/feature_flags_settings.py b/bot/src/bot_core/configuration/feature_flags_settings.py similarity index 100% rename from kdb-bot/src/bot_core/configuration/feature_flags_settings.py rename to bot/src/bot_core/configuration/feature_flags_settings.py diff --git a/kdb-bot/src/bot_core/configuration/file_logging_settings.py b/bot/src/bot_core/configuration/file_logging_settings.py similarity index 78% rename from kdb-bot/src/bot_core/configuration/file_logging_settings.py rename to bot/src/bot_core/configuration/file_logging_settings.py index 46028aa5..1e694363 100644 --- a/kdb-bot/src/bot_core/configuration/file_logging_settings.py +++ b/bot/src/bot_core/configuration/file_logging_settings.py @@ -10,7 +10,9 @@ class FileLoggingSettings(LoggingSettings): console_log_level: LoggingLevelEnum = None, file_log_level: LoggingLevelEnum = None, ): - LoggingSettings.__init__(self, path, filename, console_log_level, file_log_level) + LoggingSettings.__init__( + self, path, filename, console_log_level, file_log_level + ) self._key = key diff --git a/kdb-bot/src/bot_core/core_extension/__init__.py b/bot/src/bot_core/core_extension/__init__.py similarity index 100% rename from kdb-bot/src/bot_core/core_extension/__init__.py rename to bot/src/bot_core/core_extension/__init__.py diff --git a/kdb-bot/src/bot_core/core_extension/core_extension.py b/bot/src/bot_core/core_extension/core_extension.py similarity index 96% rename from kdb-bot/src/bot_core/core_extension/core_extension.py rename to bot/src/bot_core/core_extension/core_extension.py index de5a1781..ede39c5c 100644 --- a/kdb-bot/src/bot_core/core_extension/core_extension.py +++ b/bot/src/bot_core/core_extension/core_extension.py @@ -17,7 +17,9 @@ class CoreExtension(ApplicationExtensionABC): ApplicationExtensionABC.__init__(self) async def run(self, config: ConfigurationABC, services: ServiceProviderABC): - feature_flags: FeatureFlagsSettings = config.get_configuration(FeatureFlagsSettings) + feature_flags: FeatureFlagsSettings = config.get_configuration( + FeatureFlagsSettings + ) if not feature_flags.get_flag(FeatureFlagsEnum.core_module): return diff --git a/kdb-bot/src/bot_core/core_extension/core_extension_module.py b/bot/src/bot_core/core_extension/core_extension_module.py similarity index 67% rename from kdb-bot/src/bot_core/core_extension/core_extension_module.py rename to bot/src/bot_core/core_extension/core_extension_module.py index ef16529f..e780a721 100644 --- a/kdb-bot/src/bot_core/core_extension/core_extension_module.py +++ b/bot/src/bot_core/core_extension/core_extension_module.py @@ -15,8 +15,14 @@ class CoreExtensionModule(ModuleABC): def __init__(self, dc: DiscordCollectionABC): ModuleABC.__init__(self, dc, FeatureFlagsEnum.core_extension_module) - def configure_configuration(self, config: ConfigurationABC, env: ApplicationEnvironmentABC): + def configure_configuration( + self, config: ConfigurationABC, env: ApplicationEnvironmentABC + ): pass - def configure_services(self, services: ServiceCollectionABC, env: ApplicationEnvironmentABC): - services.add_transient(DiscordEventTypesEnum.on_ready.value, CoreExtensionOnReadyEvent) + def configure_services( + self, services: ServiceCollectionABC, env: ApplicationEnvironmentABC + ): + services.add_transient( + DiscordEventTypesEnum.on_ready.value, CoreExtensionOnReadyEvent + ) diff --git a/kdb-bot/src/bot_core/core_extension/core_extension_on_ready_event.py b/bot/src/bot_core/core_extension/core_extension_on_ready_event.py similarity index 100% rename from kdb-bot/src/bot_core/core_extension/core_extension_on_ready_event.py rename to bot/src/bot_core/core_extension/core_extension_on_ready_event.py diff --git a/kdb-bot/src/bot_core/core_module.py b/bot/src/bot_core/core_module.py similarity index 87% rename from kdb-bot/src/bot_core/core_module.py rename to bot/src/bot_core/core_module.py index 02611684..def17448 100644 --- a/kdb-bot/src/bot_core/core_module.py +++ b/bot/src/bot_core/core_module.py @@ -20,10 +20,14 @@ class CoreModule(ModuleABC): def __init__(self, dc: DiscordCollectionABC): ModuleABC.__init__(self, dc, FeatureFlagsEnum.core_module) - def configure_configuration(self, config: ConfigurationABC, env: ApplicationEnvironmentABC): + def configure_configuration( + self, config: ConfigurationABC, env: ApplicationEnvironmentABC + ): pass - def configure_services(self, services: ServiceCollectionABC, env: ApplicationEnvironmentABC): + def configure_services( + self, services: ServiceCollectionABC, env: ApplicationEnvironmentABC + ): services.add_transient(ConfigService) services.add_transient(MessageServiceABC, MessageService) services.add_transient(ClientUtilsABC, ClientUtilsService) diff --git a/kdb-bot/src/bot_core/events/__init__.py b/bot/src/bot_core/events/__init__.py similarity index 100% rename from kdb-bot/src/bot_core/events/__init__.py rename to bot/src/bot_core/events/__init__.py diff --git a/kdb-bot/src/bot_core/events/core_on_ready_event.py b/bot/src/bot_core/events/core_on_ready_event.py similarity index 100% rename from kdb-bot/src/bot_core/events/core_on_ready_event.py rename to bot/src/bot_core/events/core_on_ready_event.py diff --git a/kdb-bot/src/bot_core/exception/__init__.py b/bot/src/bot_core/exception/__init__.py similarity index 100% rename from kdb-bot/src/bot_core/exception/__init__.py rename to bot/src/bot_core/exception/__init__.py diff --git a/kdb-bot/src/bot_core/exception/check_error.py b/bot/src/bot_core/exception/check_error.py similarity index 100% rename from kdb-bot/src/bot_core/exception/check_error.py rename to bot/src/bot_core/exception/check_error.py diff --git a/kdb-bot/src/bot_core/helper/__init__.py b/bot/src/bot_core/helper/__init__.py similarity index 100% rename from kdb-bot/src/bot_core/helper/__init__.py rename to bot/src/bot_core/helper/__init__.py diff --git a/kdb-bot/src/bot_core/helper/command_checks.py b/bot/src/bot_core/helper/command_checks.py similarity index 85% rename from kdb-bot/src/bot_core/helper/command_checks.py rename to bot/src/bot_core/helper/command_checks.py index e2048409..b6e6672c 100644 --- a/kdb-bot/src/bot_core/helper/command_checks.py +++ b/bot/src/bot_core/helper/command_checks.py @@ -44,7 +44,9 @@ class CommandChecks: async def check_is_member_admin(ctx: Context): has_permission = cls._permissions.is_member_admin(ctx.author) if not has_permission: - await cls._message_service.send_ctx_msg(ctx, cls._t.transform("common.no_permission_message")) + await cls._message_service.send_ctx_msg( + ctx, cls._t.transform("common.no_permission_message") + ) raise CheckError(f"Member {ctx.author.name} is not admin") return has_permission @@ -56,7 +58,9 @@ class CommandChecks: async def check_is_member_technician(ctx: Context): has_permission = cls._permissions.is_member_technician(ctx.author) if not has_permission: - await cls._message_service.send_ctx_msg(ctx, cls._t.transform("common.no_permission_message")) + await cls._message_service.send_ctx_msg( + ctx, cls._t.transform("common.no_permission_message") + ) raise CheckError(f"Member {ctx.author.name} is not technician") return has_permission @@ -68,7 +72,9 @@ class CommandChecks: async def check_is_member_moderator(ctx: Context): has_permission = cls._permissions.is_member_moderator(ctx.author) if not has_permission: - await cls._message_service.send_ctx_msg(ctx, cls._t.transform("common.no_permission_message")) + await cls._message_service.send_ctx_msg( + ctx, cls._t.transform("common.no_permission_message") + ) raise CheckError(f"Member {ctx.author.name} is not moderator") return has_permission diff --git a/kdb-bot/src/bot_core/helper/event_checks.py b/bot/src/bot_core/helper/event_checks.py similarity index 100% rename from kdb-bot/src/bot_core/helper/event_checks.py rename to bot/src/bot_core/helper/event_checks.py diff --git a/kdb-bot/src/bot_core/helper/log_message_helper.py b/bot/src/bot_core/helper/log_message_helper.py similarity index 100% rename from kdb-bot/src/bot_core/helper/log_message_helper.py rename to bot/src/bot_core/helper/log_message_helper.py diff --git a/kdb-bot/src/bot_core/logging/__init__.py b/bot/src/bot_core/logging/__init__.py similarity index 100% rename from kdb-bot/src/bot_core/logging/__init__.py rename to bot/src/bot_core/logging/__init__.py diff --git a/kdb-bot/src/bot_core/logging/command_logger.py b/bot/src/bot_core/logging/command_logger.py similarity index 100% rename from kdb-bot/src/bot_core/logging/command_logger.py rename to bot/src/bot_core/logging/command_logger.py diff --git a/kdb-bot/src/bot_core/logging/database_logger.py b/bot/src/bot_core/logging/database_logger.py similarity index 100% rename from kdb-bot/src/bot_core/logging/database_logger.py rename to bot/src/bot_core/logging/database_logger.py diff --git a/kdb-bot/src/bot_core/logging/message_logger.py b/bot/src/bot_core/logging/message_logger.py similarity index 100% rename from kdb-bot/src/bot_core/logging/message_logger.py rename to bot/src/bot_core/logging/message_logger.py diff --git a/kdb-bot/src/bot_core/logging/task_logger.py b/bot/src/bot_core/logging/task_logger.py similarity index 100% rename from kdb-bot/src/bot_core/logging/task_logger.py rename to bot/src/bot_core/logging/task_logger.py diff --git a/kdb-bot/src/bot_core/pipes/__init__.py b/bot/src/bot_core/pipes/__init__.py similarity index 100% rename from kdb-bot/src/bot_core/pipes/__init__.py rename to bot/src/bot_core/pipes/__init__.py diff --git a/kdb-bot/src/bot_core/pipes/date_time_offset_pipe.py b/bot/src/bot_core/pipes/date_time_offset_pipe.py similarity index 100% rename from kdb-bot/src/bot_core/pipes/date_time_offset_pipe.py rename to bot/src/bot_core/pipes/date_time_offset_pipe.py diff --git a/kdb-bot/src/bot_core/service/__init__.py b/bot/src/bot_core/service/__init__.py similarity index 100% rename from kdb-bot/src/bot_core/service/__init__.py rename to bot/src/bot_core/service/__init__.py diff --git a/kdb-bot/src/bot_core/service/client_utils_service.py b/bot/src/bot_core/service/client_utils_service.py similarity index 87% rename from kdb-bot/src/bot_core/service/client_utils_service.py rename to bot/src/bot_core/service/client_utils_service.py index e5bd200a..b215386c 100644 --- a/kdb-bot/src/bot_core/service/client_utils_service.py +++ b/bot/src/bot_core/service/client_utils_service.py @@ -62,28 +62,36 @@ class ClientUtilsService(ClientUtilsABC): def received_command(self, guild_id: int): server = self._servers.get_server_by_discord_id(guild_id) - client = self._clients.find_client_by_discord_id_and_server_id(self._bot.user.id, server.id) + client = self._clients.find_client_by_discord_id_and_server_id( + self._bot.user.id, server.id + ) client.received_command_count += 1 self._clients.update_client(client) self._db.save_changes() def moved_user(self, guild_id: int): server = self._servers.get_server_by_discord_id(guild_id) - client = self._clients.find_client_by_discord_id_and_server_id(self._bot.user.id, server.id) + client = self._clients.find_client_by_discord_id_and_server_id( + self._bot.user.id, server.id + ) client.moved_users_count += 1 self._clients.update_client(client) self._db.save_changes() def moved_users(self, guild_id: int, count: int): server = self._servers.get_server_by_discord_id(guild_id) - client = self._clients.find_client_by_discord_id_and_server_id(self._bot.user.id, server.id) + client = self._clients.find_client_by_discord_id_and_server_id( + self._bot.user.id, server.id + ) client.moved_users_count += count self._clients.update_client(client) self._db.save_changes() def get_client(self, dc_ic: int, guild_id: int): server = self._servers.get_server_by_discord_id(guild_id) - client = self._clients.find_client_by_discord_id_and_server_id(self._bot.user.id, server.id) + client = self._clients.find_client_by_discord_id_and_server_id( + self._bot.user.id, server.id + ) return client async def check_if_bot_is_ready_yet(self) -> bool: @@ -121,7 +129,9 @@ class ClientUtilsService(ClientUtilsABC): await self._bot.change_presence(activity=discord.Game(name=name)) self._logger.info(__name__, f"Set presence {name}") - def get_auto_complete_list(self, _l: List, current: str, select: Callable = None) -> List: + def get_auto_complete_list( + self, _l: List, current: str, select: Callable = None + ) -> List: if current != "": if select is None: select = lambda x: x @@ -144,7 +154,9 @@ class ClientUtilsService(ClientUtilsABC): ) -> bool: umcph = None try: - umcph = self._umcphs.find_user_message_count_per_hour_by_user_id_and_date(user.id, created_at) + umcph = self._umcphs.find_user_message_count_per_hour_by_user_id_and_date( + user.id, created_at + ) if umcph is None: self._umcphs.add_user_message_count_per_hour( UserMessageCountPerHour( @@ -157,7 +169,11 @@ class ClientUtilsService(ClientUtilsABC): self._db.save_changes() - umcph = self._umcphs.get_user_message_count_per_hour_by_user_id_and_date(user.id, created_at) + umcph = ( + self._umcphs.get_user_message_count_per_hour_by_user_id_and_date( + user.id, created_at + ) + ) except Exception as e: self._logger.error( __name__, @@ -189,20 +205,30 @@ class ClientUtilsService(ClientUtilsABC): def get_ontime_for_user(self, user: User) -> float: return round( - self._user_joined_voice_channel.get_user_joined_voice_channels_by_user_id(user.id) + self._user_joined_voice_channel.get_user_joined_voice_channels_by_user_id( + user.id + ) .where(lambda x: x.leaved_on is not None and x.joined_on is not None) .sum(lambda join: (join.leaved_on - join.joined_on).total_seconds() / 3600), 2, ) async def react_to_message_by_auto_role_rule( - self, discord_channel_id: int, discord_message_id: int, rule: AutoRoleRule, guild: discord.Guild + self, + discord_channel_id: int, + discord_message_id: int, + rule: AutoRoleRule, + guild: discord.Guild, ): try: guild: Guild = self._bot.guilds.where(lambda g: g == guild).single() channel = guild.get_channel(discord_channel_id) message = await channel.fetch_message(discord_message_id) - emoji = List(discord.Emoji, guild.emojis).where(lambda x: x.name == rule.emoji_name).single() + emoji = ( + List(discord.Emoji, guild.emojis) + .where(lambda x: x.name == rule.emoji_name) + .single() + ) if emoji is None: self._logger.debug(__name__, f"Emoji {rule.emoji_name} not found") @@ -222,7 +248,9 @@ class ClientUtilsService(ClientUtilsABC): 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}") + settings: ServerConfig = self._config.get_configuration( + f"ServerConfig_{server.discord_id}" + ) if settings.default_role_id is None: return @@ -234,4 +262,6 @@ class ClientUtilsService(ClientUtilsABC): 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) + self._logger.error( + __name__, f"Cannot check for default role for member {member.id}", e + ) diff --git a/kdb-bot/src/bot_core/service/config_service.py b/bot/src/bot_core/service/config_service.py similarity index 89% rename from kdb-bot/src/bot_core/service/config_service.py rename to bot/src/bot_core/service/config_service.py index 6aa29b83..657d972d 100644 --- a/kdb-bot/src/bot_core/service/config_service.py +++ b/bot/src/bot_core/service/config_service.py @@ -28,7 +28,10 @@ class ConfigService: def reload_technician_config(self): 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)) + 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): @@ -36,5 +39,6 @@ class ConfigService: 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 + f"{type(server_config).__name__}_{server_config.server.discord_id}", + server_config, ) diff --git a/kdb-bot/src/bot_core/service/data_integrity_service.py b/bot/src/bot_core/service/data_integrity_service.py similarity index 77% rename from kdb-bot/src/bot_core/service/data_integrity_service.py rename to bot/src/bot_core/service/data_integrity_service.py index 9a2e613e..f7090636 100644 --- a/kdb-bot/src/bot_core/service/data_integrity_service.py +++ b/bot/src/bot_core/service/data_integrity_service.py @@ -11,7 +11,9 @@ 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 from bot_data.abc.known_user_repository_abc import KnownUserRepositoryABC -from bot_data.abc.user_joined_game_server_repository_abc import UserJoinedGameServerRepositoryABC +from bot_data.abc.user_joined_game_server_repository_abc import ( + UserJoinedGameServerRepositoryABC, +) from bot_data.abc.user_joined_server_repository_abc import UserJoinedServerRepositoryABC from bot_data.abc.user_joined_voice_channel_repository_abc import ( UserJoinedVoiceChannelRepositoryABC, @@ -65,12 +67,16 @@ class DataIntegrityService: self._is_for_shutdown = False def _check_known_users(self): - self._logger.debug(__name__, f"Start checking KnownUsers table, {len(self._bot.users)}") + self._logger.debug( + __name__, f"Start checking KnownUsers table, {len(self._bot.users)}" + ) for u in self._bot.users: u: discord.User = u try: if u.bot: - self._logger.trace(__name__, f"User {u.id} is ignored, because its a bot") + self._logger.trace( + __name__, f"User {u.id} is ignored, because its a bot" + ) continue user = self._known_users.find_user_by_discord_id(u.id) @@ -123,7 +129,9 @@ class DataIntegrityService: try: server: Server = self._servers.find_server_by_discord_id(g.id) if server is None: - self._logger.fatal(__name__, f"Server not found in database: {g.id}") + self._logger.fatal( + __name__, f"Server not found in database: {g.id}" + ) client = self._clients.find_client_by_server_id(server.id) if client is not None: @@ -134,7 +142,9 @@ class DataIntegrityService: f"Client for server {g.id} not found in database: {self._bot.user.id}", ) self._logger.debug(__name__, f"Add client: {self._bot.user.id}") - self._clients.add_client(Client(self._bot.user.id, 0, 0, 0, 0, 0, server)) + self._clients.add_client( + Client(self._bot.user.id, 0, 0, 0, 0, 0, server) + ) self._db_context.save_changes() client = self._clients.find_client_by_server_id(server.id) @@ -160,15 +170,21 @@ class DataIntegrityService: try: server = self._servers.find_server_by_discord_id(g.id) if server is None: - self._logger.fatal(__name__, f"Server not found in database: {g.id}") + self._logger.fatal( + __name__, f"Server not found in database: {g.id}" + ) for u in g.members: u: Union[discord.Member, discord.User] = u if u.bot: - self._logger.trace(__name__, f"User {u.id} is ignored, because its a bot") + self._logger.trace( + __name__, f"User {u.id} is ignored, because its a bot" + ) continue - user = self._users.find_user_by_discord_id_and_server_id(u.id, server.id) + user = self._users.find_user_by_discord_id_and_server_id( + u.id, server.id + ) if user is not None: continue @@ -192,20 +208,30 @@ class DataIntegrityService: server = self._servers.find_server_by_discord_id(guild.id) if server is None: - self._logger.fatal(__name__, f"Server not found in database: {guild.id}") + self._logger.fatal( + __name__, f"Server not found in database: {guild.id}" + ) try: for u in guild.members: u: discord.User = u if u.bot: - self._logger.trace(__name__, f"User {u.id} is ignored, because its a bot") + self._logger.trace( + __name__, f"User {u.id} is ignored, because its a bot" + ) continue - user = self._users.find_user_by_discord_id_and_server_id(u.id, server.id) + user = self._users.find_user_by_discord_id_and_server_id( + u.id, server.id + ) if user is None: - self._logger.fatal(__name__, f"User not found in database: {u.id}") + self._logger.fatal( + __name__, f"User not found in database: {u.id}" + ) - join = self._user_joins.find_active_user_joined_server_by_user_id(user.id) + join = self._user_joins.find_active_user_joined_server_by_user_id( + user.id + ) if join is not None: continue @@ -255,24 +281,36 @@ class DataIntegrityService: self._logger.debug(__name__, f"Start checking UserJoinedVoiceChannel table") for guild in self._bot.guilds: guild: discord.Guild = guild - settings: ServerConfig = self._config.get_configuration(f"ServerConfig_{guild.id}") + settings: ServerConfig = self._config.get_configuration( + f"ServerConfig_{guild.id}" + ) server = self._servers.find_server_by_discord_id(guild.id) if server is None: - self._logger.fatal(__name__, f"Server not found in database: {guild.id}") + self._logger.fatal( + __name__, f"Server not found in database: {guild.id}" + ) try: # close open voice states for member in guild.members: if member.bot: - self._logger.trace(__name__, f"User {member.id} is ignored, because its a bot") + self._logger.trace( + __name__, f"User {member.id} is ignored, because its a bot" + ) continue - user = self._users.find_user_by_discord_id_and_server_id(member.id, server.id) + user = self._users.find_user_by_discord_id_and_server_id( + member.id, server.id + ) if user is None: - self._logger.fatal(__name__, f"User not found in database: {member.id}") + self._logger.fatal( + __name__, f"User not found in database: {member.id}" + ) - joins = self._user_joins_vc.find_active_user_joined_voice_channels_by_user_id(user.id) + joins = self._user_joins_vc.find_active_user_joined_voice_channels_by_user_id( + user.id + ) if joins is None or len(joins) == 0: continue @@ -286,7 +324,9 @@ class DataIntegrityService: if ( (join.leaved_on - join.joined_on).total_seconds() / 60 / 60 ) > settings.max_voice_state_hours: - join.leaved_on = join.joined_on + timedelta(hours=settings.max_voice_state_hours) + join.leaved_on = join.joined_on + timedelta( + hours=settings.max_voice_state_hours + ) self._user_joins_vc.update_user_joined_voice_channel(join) @@ -301,17 +341,28 @@ class DataIntegrityService: # add open voice states for member in guild.members: if member.bot: - self._logger.trace(__name__, f"User {member.id} is ignored, because its a bot") + self._logger.trace( + __name__, f"User {member.id} is ignored, because its a bot" + ) continue - if member.voice is None or member.voice.channel.id in settings.afk_channel_ids: + if ( + member.voice is None + or member.voice.channel.id in settings.afk_channel_ids + ): continue - user = self._users.find_user_by_discord_id_and_server_id(member.id, server.id) + user = self._users.find_user_by_discord_id_and_server_id( + member.id, server.id + ) if user is None: - self._logger.fatal(__name__, f"User not found in database: {member.id}") + self._logger.fatal( + __name__, f"User not found in database: {member.id}" + ) - join = UserJoinedVoiceChannel(user, member.voice.channel.id, datetime.now()) + join = UserJoinedVoiceChannel( + user, member.voice.channel.id, datetime.now() + ) self._user_joins_vc.add_user_joined_voice_channel(join) self._db_context.save_changes() @@ -325,19 +376,29 @@ class DataIntegrityService: server = self._servers.find_server_by_discord_id(guild.id) if server is None: - self._logger.fatal(__name__, f"Server not found in database: {guild.id}") + self._logger.fatal( + __name__, f"Server not found in database: {guild.id}" + ) try: for member in guild.members: if member.bot: - self._logger.trace(__name__, f"User {member.id} is ignored, because its a bot") + self._logger.trace( + __name__, f"User {member.id} is ignored, because its a bot" + ) continue - user = self._users.find_user_by_discord_id_and_server_id(member.id, server.id) + user = self._users.find_user_by_discord_id_and_server_id( + member.id, server.id + ) if user is None: - self._logger.fatal(__name__, f"User not found in database: {member.id}") + self._logger.fatal( + __name__, f"User not found in database: {member.id}" + ) - joins = self._user_joined_gs.find_active_user_joined_game_servers_by_user_id(user.id) + joins = self._user_joined_gs.find_active_user_joined_game_servers_by_user_id( + user.id + ) if joins is None or len(joins) == 0: continue @@ -347,12 +408,16 @@ class DataIntegrityService: f"Active UserJoinedGameServer found in database: {guild.id}:{member.id}@{join.joined_on}", ) join.leaved_on = datetime.now() - settings: ServerConfig = self._config.get_configuration(f"ServerConfig_{guild.id}") + settings: ServerConfig = self._config.get_configuration( + f"ServerConfig_{guild.id}" + ) if ( (join.leaved_on - join.joined_on).total_seconds() / 60 / 60 ) > settings.max_voice_state_hours: - join.leaved_on = join.joined_on + timedelta(hours=settings.max_voice_state_hours) + join.leaved_on = join.joined_on + timedelta( + hours=settings.max_voice_state_hours + ) self._user_joined_gs.update_user_joined_game_server(join) if self._is_for_shutdown: @@ -369,16 +434,24 @@ class DataIntegrityService: for guild in self._bot.guilds: server = self._servers.find_server_by_discord_id(guild.id) if server is None: - self._logger.fatal(__name__, f"Server not found in database: {guild.id}") + self._logger.fatal( + __name__, f"Server not found in database: {guild.id}" + ) for member in guild.members: if member.bot: - self._logger.trace(__name__, f"User {member.id} is ignored, because its a bot") + self._logger.trace( + __name__, f"User {member.id} is ignored, because its a bot" + ) continue - user = self._users.find_user_by_discord_id_and_server_id(member.id, server.id) + user = self._users.find_user_by_discord_id_and_server_id( + member.id, server.id + ) if user is None: - self._logger.fatal(__name__, f"User not found in database: {member.id}") + self._logger.fatal( + __name__, f"User not found in database: {member.id}" + ) await self._achievements.validate_achievements_for_user(user) diff --git a/kdb-bot/src/bot_core/service/message_service.py b/bot/src/bot_core/service/message_service.py similarity index 70% rename from kdb-bot/src/bot_core/service/message_service.py rename to bot/src/bot_core/service/message_service.py index 9140742f..060d5495 100644 --- a/kdb-bot/src/bot_core/service/message_service.py +++ b/bot/src/bot_core/service/message_service.py @@ -31,15 +31,23 @@ class MessageService(MessageServiceABC): self._clients = clients self._db = db - async def delete_messages(self, messages: List[discord.Message], guild_id: int, without_tracking=False): + async def delete_messages( + self, messages: List[discord.Message], guild_id: int, without_tracking=False + ): self._logger.debug(__name__, f"Try to delete {messages.count()} messages") - server_st: ServerConfig = self._config.get_configuration(f"ServerConfig_{guild_id}") + server_st: ServerConfig = self._config.get_configuration( + f"ServerConfig_{guild_id}" + ) await asyncio.sleep(server_st.message_delete_timer) for message in messages: - await self.delete_message(message, mass_delete=True, without_tracking=without_tracking) + await self.delete_message( + message, mass_delete=True, without_tracking=without_tracking + ) self._logger.debug(__name__, "Deleting messages finished") - async def delete_message(self, message: discord.Message, mass_delete=False, without_tracking=False): + async def delete_message( + self, message: discord.Message, mass_delete=False, without_tracking=False + ): guild_id = ( message.guild.id if message.guild is not None @@ -50,7 +58,9 @@ class MessageService(MessageServiceABC): else None ) - server_st: ServerConfig = self._config.get_configuration(f"ServerConfig_{guild_id}") + server_st: ServerConfig = self._config.get_configuration( + f"ServerConfig_{guild_id}" + ) if not mass_delete: await asyncio.sleep(server_st.message_delete_timer) self._logger.debug( @@ -64,7 +74,9 @@ class MessageService(MessageServiceABC): self._logger.error(__name__, f"Deleting message failed", e) else: if not without_tracking: - self._clients.append_deleted_message_count(self._bot.user.id, guild_id, 1) + self._clients.append_deleted_message_count( + self._bot.user.id, guild_id, 1 + ) self._db.save_changes() self._logger.info(__name__, f"Deleted message {message}") @@ -76,7 +88,9 @@ class MessageService(MessageServiceABC): wait_before_delete: int = None, without_tracking=False, ): - self._logger.debug(__name__, f"Try to send message\n\t{message}\n\tto: {channel}") + self._logger.debug( + __name__, f"Try to send message\n\t{message}\n\tto: {channel}" + ) msg = None try: if isinstance(message, discord.Embed): @@ -86,11 +100,15 @@ class MessageService(MessageServiceABC): else: msg = await channel.send(message) except Exception as e: - self._logger.error(__name__, f"Send message to channel {channel.id} failed", e) + self._logger.error( + __name__, f"Send message to channel {channel.id} failed", e + ) else: self._logger.info(__name__, f"Sent message to channel {channel.id}") if not without_tracking: - self._clients.append_sent_message_count(self._bot.user.id, channel.guild.id, 1) + self._clients.append_sent_message_count( + self._bot.user.id, channel.guild.id, 1 + ) self._db.save_changes() if wait_before_delete is not None: @@ -107,17 +125,23 @@ class MessageService(MessageServiceABC): receiver: Union[discord.User, discord.Member], without_tracking=False, ): - self._logger.debug(__name__, f"Try to send message\n\t{message}\n\tto: {receiver}") + self._logger.debug( + __name__, f"Try to send message\n\t{message}\n\tto: {receiver}" + ) try: if isinstance(message, discord.Embed): msg = await receiver.send(embed=message) else: msg = await receiver.send(message) except Exception as e: - self._logger.error(__name__, f"Send message to user {receiver.id} failed", e) + self._logger.error( + __name__, f"Send message to user {receiver.id} failed", e + ) else: if not without_tracking: - self._clients.append_sent_message_count(self._bot.user.id, receiver.guild.id, 1) + self._clients.append_sent_message_count( + self._bot.user.id, receiver.guild.id, 1 + ) self._db.save_changes() self._logger.info(__name__, f"Sent message to user {receiver.id}") @@ -136,7 +160,9 @@ class MessageService(MessageServiceABC): self._logger.debug(__name__, f"Message: {message}") return None - self._logger.debug(__name__, f"Try to send message\t\t{message}\n\tto: {ctx.channel}") + self._logger.debug( + __name__, f"Try to send message\t\t{message}\n\tto: {ctx.channel}" + ) msg = None try: if isinstance(message, discord.Embed): @@ -144,11 +170,15 @@ class MessageService(MessageServiceABC): else: msg = await ctx.send(message, file=file, ephemeral=not is_public) except Exception as e: - self._logger.error(__name__, f"Send message to channel {ctx.channel.id} failed", e) + self._logger.error( + __name__, f"Send message to channel {ctx.channel.id} failed", e + ) else: self._logger.info(__name__, f"Sent message to channel {ctx.channel.id}") if not without_tracking and ctx.guild is not None: - self._clients.append_sent_message_count(self._bot.user.id, ctx.guild.id, 1) + self._clients.append_sent_message_count( + self._bot.user.id, ctx.guild.id, 1 + ) self._db.save_changes() if wait_before_delete is not None: @@ -177,18 +207,30 @@ class MessageService(MessageServiceABC): self._logger.debug(__name__, f"Message: {message}") return - self._logger.debug(__name__, f"Try to send message\t\t{message}\n\tto: {interaction.channel}") + self._logger.debug( + __name__, f"Try to send message\t\t{message}\n\tto: {interaction.channel}" + ) try: if isinstance(message, discord.Embed): - await interaction.response.send_message(embed=message, ephemeral=not is_public, **kwargs) + await interaction.response.send_message( + embed=message, ephemeral=not is_public, **kwargs + ) else: - await interaction.response.send_message(message, ephemeral=not is_public, **kwargs) + await interaction.response.send_message( + message, ephemeral=not is_public, **kwargs + ) except Exception as e: - self._logger.error(__name__, f"Send message to channel {interaction.channel.id} failed", e) + self._logger.error( + __name__, f"Send message to channel {interaction.channel.id} failed", e + ) else: - self._logger.info(__name__, f"Sent message to channel {interaction.channel.id}") + self._logger.info( + __name__, f"Sent message to channel {interaction.channel.id}" + ) if not without_tracking and interaction.guild is not None: - self._clients.append_sent_message_count(self._bot.user.id, interaction.guild.id, 1) + self._clients.append_sent_message_count( + self._bot.user.id, interaction.guild.id, 1 + ) self._db.save_changes() if wait_before_delete is not None: @@ -197,4 +239,6 @@ class MessageService(MessageServiceABC): if is_persistent: return - await self.delete_message(await interaction.original_response(), without_tracking) + await self.delete_message( + await interaction.original_response(), without_tracking + ) diff --git a/kdb-bot/src/bot_data/__init__.py b/bot/src/bot_data/__init__.py similarity index 100% rename from kdb-bot/src/bot_data/__init__.py rename to bot/src/bot_data/__init__.py diff --git a/kdb-bot/src/bot_data/abc/__init__.py b/bot/src/bot_data/abc/__init__.py similarity index 100% rename from kdb-bot/src/bot_data/abc/__init__.py rename to bot/src/bot_data/abc/__init__.py diff --git a/kdb-bot/src/bot_data/abc/achievement_repository_abc.py b/bot/src/bot_data/abc/achievement_repository_abc.py similarity index 91% rename from kdb-bot/src/bot_data/abc/achievement_repository_abc.py rename to bot/src/bot_data/abc/achievement_repository_abc.py index ff3014fe..e1cc6c4e 100644 --- a/kdb-bot/src/bot_data/abc/achievement_repository_abc.py +++ b/bot/src/bot_data/abc/achievement_repository_abc.py @@ -28,7 +28,9 @@ class AchievementRepositoryABC(ABC): pass @abstractmethod - def get_user_got_achievements_by_achievement_id(self, achievement_id: int) -> List[Achievement]: + def get_user_got_achievements_by_achievement_id( + self, achievement_id: int + ) -> List[Achievement]: pass @abstractmethod diff --git a/kdb-bot/src/bot_data/abc/api_key_repository_abc.py b/bot/src/bot_data/abc/api_key_repository_abc.py similarity index 100% rename from kdb-bot/src/bot_data/abc/api_key_repository_abc.py rename to bot/src/bot_data/abc/api_key_repository_abc.py diff --git a/kdb-bot/src/bot_data/abc/auth_user_repository_abc.py b/bot/src/bot_data/abc/auth_user_repository_abc.py similarity index 94% rename from kdb-bot/src/bot_data/abc/auth_user_repository_abc.py rename to bot/src/bot_data/abc/auth_user_repository_abc.py index 9d9b06ec..0dc7eeaf 100644 --- a/kdb-bot/src/bot_data/abc/auth_user_repository_abc.py +++ b/bot/src/bot_data/abc/auth_user_repository_abc.py @@ -23,7 +23,9 @@ class AuthUserRepositoryABC(ABC): pass @abstractmethod - def get_filtered_auth_users(self, criteria: AuthUserSelectCriteria) -> FilteredResult: + def get_filtered_auth_users( + self, criteria: AuthUserSelectCriteria + ) -> FilteredResult: pass @abstractmethod diff --git a/kdb-bot/src/bot_data/abc/auto_role_repository_abc.py b/bot/src/bot_data/abc/auto_role_repository_abc.py similarity index 100% rename from kdb-bot/src/bot_data/abc/auto_role_repository_abc.py rename to bot/src/bot_data/abc/auto_role_repository_abc.py diff --git a/kdb-bot/src/bot_data/abc/client_repository_abc.py b/bot/src/bot_data/abc/client_repository_abc.py similarity index 93% rename from kdb-bot/src/bot_data/abc/client_repository_abc.py rename to bot/src/bot_data/abc/client_repository_abc.py index 3b9f9132..40cf8033 100644 --- a/kdb-bot/src/bot_data/abc/client_repository_abc.py +++ b/bot/src/bot_data/abc/client_repository_abc.py @@ -36,7 +36,9 @@ class ClientRepositoryABC(ABC): pass @abstractmethod - def find_client_by_discord_id_and_server_id(self, discord_id: int, server_id: int) -> Optional[Client]: + def find_client_by_discord_id_and_server_id( + self, discord_id: int, server_id: int + ) -> Optional[Client]: pass @abstractmethod diff --git a/kdb-bot/src/bot_data/abc/data_seeder_abc.py b/bot/src/bot_data/abc/data_seeder_abc.py similarity index 100% rename from kdb-bot/src/bot_data/abc/data_seeder_abc.py rename to bot/src/bot_data/abc/data_seeder_abc.py diff --git a/kdb-bot/src/bot_data/abc/game_server_repository_abc.py b/bot/src/bot_data/abc/game_server_repository_abc.py similarity index 100% rename from kdb-bot/src/bot_data/abc/game_server_repository_abc.py rename to bot/src/bot_data/abc/game_server_repository_abc.py diff --git a/kdb-bot/src/bot_data/abc/history_table_abc.py b/bot/src/bot_data/abc/history_table_abc.py similarity index 100% rename from kdb-bot/src/bot_data/abc/history_table_abc.py rename to bot/src/bot_data/abc/history_table_abc.py diff --git a/kdb-bot/src/bot_data/abc/known_user_repository_abc.py b/bot/src/bot_data/abc/known_user_repository_abc.py similarity index 100% rename from kdb-bot/src/bot_data/abc/known_user_repository_abc.py rename to bot/src/bot_data/abc/known_user_repository_abc.py diff --git a/kdb-bot/src/bot_data/abc/level_repository_abc.py b/bot/src/bot_data/abc/level_repository_abc.py similarity index 100% rename from kdb-bot/src/bot_data/abc/level_repository_abc.py rename to bot/src/bot_data/abc/level_repository_abc.py diff --git a/kdb-bot/src/bot_data/abc/migration_abc.py b/bot/src/bot_data/abc/migration_abc.py similarity index 100% rename from kdb-bot/src/bot_data/abc/migration_abc.py rename to bot/src/bot_data/abc/migration_abc.py diff --git a/kdb-bot/src/bot_data/abc/server_config_repository_abc.py b/bot/src/bot_data/abc/server_config_repository_abc.py similarity index 64% rename from kdb-bot/src/bot_data/abc/server_config_repository_abc.py rename to bot/src/bot_data/abc/server_config_repository_abc.py index f66fdc89..6a5cd127 100644 --- a/kdb-bot/src/bot_data/abc/server_config_repository_abc.py +++ b/bot/src/bot_data/abc/server_config_repository_abc.py @@ -35,25 +35,37 @@ class ServerConfigRepositoryABC(ABC): pass @abstractmethod - def add_server_team_role_id_config(self, server_team_role_id: ServerTeamRoleIdsConfig): + def add_server_team_role_id_config( + self, server_team_role_id: ServerTeamRoleIdsConfig + ): pass @abstractmethod - def update_server_team_role_id_config(self, server_team_role_id: ServerTeamRoleIdsConfig): + def update_server_team_role_id_config( + self, server_team_role_id: ServerTeamRoleIdsConfig + ): pass @abstractmethod - def delete_server_team_role_id_config(self, server_team_role_id: ServerTeamRoleIdsConfig): + def delete_server_team_role_id_config( + self, server_team_role_id: ServerTeamRoleIdsConfig + ): pass @abstractmethod - def add_server_afk_channel_config(self, server_afk_channel: ServerAFKChannelIdsConfig): + def add_server_afk_channel_config( + self, server_afk_channel: ServerAFKChannelIdsConfig + ): pass @abstractmethod - def update_server_afk_channel_config(self, server_afk_channel: ServerAFKChannelIdsConfig): + def update_server_afk_channel_config( + self, server_afk_channel: ServerAFKChannelIdsConfig + ): pass @abstractmethod - def delete_server_afk_channel_config(self, server_afk_channel: ServerAFKChannelIdsConfig): + def delete_server_afk_channel_config( + self, server_afk_channel: ServerAFKChannelIdsConfig + ): pass diff --git a/kdb-bot/src/bot_data/abc/server_repository_abc.py b/bot/src/bot_data/abc/server_repository_abc.py similarity index 100% rename from kdb-bot/src/bot_data/abc/server_repository_abc.py rename to bot/src/bot_data/abc/server_repository_abc.py diff --git a/kdb-bot/src/bot_data/abc/short_role_name_repository_abc.py b/bot/src/bot_data/abc/short_role_name_repository_abc.py similarity index 100% rename from kdb-bot/src/bot_data/abc/short_role_name_repository_abc.py rename to bot/src/bot_data/abc/short_role_name_repository_abc.py diff --git a/kdb-bot/src/bot_data/abc/steam_special_offer_repository_abc.py b/bot/src/bot_data/abc/steam_special_offer_repository_abc.py similarity index 100% rename from kdb-bot/src/bot_data/abc/steam_special_offer_repository_abc.py rename to bot/src/bot_data/abc/steam_special_offer_repository_abc.py diff --git a/kdb-bot/src/bot_data/abc/table_with_id_abc.py b/bot/src/bot_data/abc/table_with_id_abc.py similarity index 100% rename from kdb-bot/src/bot_data/abc/table_with_id_abc.py rename to bot/src/bot_data/abc/table_with_id_abc.py diff --git a/kdb-bot/src/bot_data/abc/technician_config_repository_abc.py b/bot/src/bot_data/abc/technician_config_repository_abc.py similarity index 79% rename from kdb-bot/src/bot_data/abc/technician_config_repository_abc.py rename to bot/src/bot_data/abc/technician_config_repository_abc.py index 25c88d96..364af9b6 100644 --- a/kdb-bot/src/bot_data/abc/technician_config_repository_abc.py +++ b/bot/src/bot_data/abc/technician_config_repository_abc.py @@ -43,13 +43,19 @@ class TechnicianConfigRepositoryABC(ABC): pass @abstractmethod - def add_technician_ping_url_config(self, technician_ping_url: TechnicianPingUrlConfig): + def add_technician_ping_url_config( + self, technician_ping_url: TechnicianPingUrlConfig + ): pass @abstractmethod - def update_technician_ping_url_config(self, technician_ping_url: TechnicianPingUrlConfig): + def update_technician_ping_url_config( + self, technician_ping_url: TechnicianPingUrlConfig + ): pass @abstractmethod - def delete_technician_ping_url_config(self, technician_ping_url: TechnicianPingUrlConfig): + def delete_technician_ping_url_config( + self, technician_ping_url: TechnicianPingUrlConfig + ): pass diff --git a/kdb-bot/src/bot_data/abc/user_game_ident_repository_abc.py b/bot/src/bot_data/abc/user_game_ident_repository_abc.py similarity index 100% rename from kdb-bot/src/bot_data/abc/user_game_ident_repository_abc.py rename to bot/src/bot_data/abc/user_game_ident_repository_abc.py diff --git a/kdb-bot/src/bot_data/abc/user_joined_game_server_repository_abc.py b/bot/src/bot_data/abc/user_joined_game_server_repository_abc.py similarity index 51% rename from kdb-bot/src/bot_data/abc/user_joined_game_server_repository_abc.py rename to bot/src/bot_data/abc/user_joined_game_server_repository_abc.py index 97a0358b..c6c3cfcf 100644 --- a/kdb-bot/src/bot_data/abc/user_joined_game_server_repository_abc.py +++ b/bot/src/bot_data/abc/user_joined_game_server_repository_abc.py @@ -20,31 +20,45 @@ class UserJoinedGameServerRepositoryABC(ABC): pass @abstractmethod - def get_user_joined_game_servers_by_user_id(self, user_id: int) -> List[UserJoinedGameServer]: + def get_user_joined_game_servers_by_user_id( + self, user_id: int + ) -> List[UserJoinedGameServer]: pass @abstractmethod - def get_active_user_joined_game_server_by_user_id(self, user_id: int) -> UserJoinedGameServer: + def get_active_user_joined_game_server_by_user_id( + self, user_id: int + ) -> UserJoinedGameServer: pass @abstractmethod - def find_active_user_joined_game_server_by_user_id(self, user_id: int) -> Optional[UserJoinedGameServer]: + def find_active_user_joined_game_server_by_user_id( + self, user_id: int + ) -> Optional[UserJoinedGameServer]: pass @abstractmethod - def find_active_user_joined_game_servers_by_user_id(self, user_id: int) -> List[Optional[UserJoinedGameServer]]: + def find_active_user_joined_game_servers_by_user_id( + self, user_id: int + ) -> List[Optional[UserJoinedGameServer]]: pass @abstractmethod - def add_user_joined_game_server(self, user_joined_game_server: UserJoinedGameServer): + def add_user_joined_game_server( + self, user_joined_game_server: UserJoinedGameServer + ): pass @abstractmethod - def update_user_joined_game_server(self, user_joined_game_server: UserJoinedGameServer): + def update_user_joined_game_server( + self, user_joined_game_server: UserJoinedGameServer + ): pass @abstractmethod - def delete_user_joined_game_server(self, user_joined_game_server: UserJoinedGameServer): + def delete_user_joined_game_server( + self, user_joined_game_server: UserJoinedGameServer + ): pass @abstractmethod diff --git a/kdb-bot/src/bot_data/abc/user_joined_server_repository_abc.py b/bot/src/bot_data/abc/user_joined_server_repository_abc.py similarity index 76% rename from kdb-bot/src/bot_data/abc/user_joined_server_repository_abc.py rename to bot/src/bot_data/abc/user_joined_server_repository_abc.py index cbc3a718..d317b7b2 100644 --- a/kdb-bot/src/bot_data/abc/user_joined_server_repository_abc.py +++ b/bot/src/bot_data/abc/user_joined_server_repository_abc.py @@ -24,15 +24,21 @@ class UserJoinedServerRepositoryABC(ABC): pass @abstractmethod - def get_user_joined_servers_by_user_id(self, user_id: int) -> list[UserJoinedServer]: + def get_user_joined_servers_by_user_id( + self, user_id: int + ) -> list[UserJoinedServer]: pass @abstractmethod - def get_active_user_joined_server_by_user_id(self, user_id: int) -> UserJoinedServer: + def get_active_user_joined_server_by_user_id( + self, user_id: int + ) -> UserJoinedServer: pass @abstractmethod - def find_active_user_joined_server_by_user_id(self, user_id: int) -> Optional[UserJoinedServer]: + def find_active_user_joined_server_by_user_id( + self, user_id: int + ) -> Optional[UserJoinedServer]: pass @abstractmethod diff --git a/kdb-bot/src/bot_data/abc/user_joined_voice_channel_repository_abc.py b/bot/src/bot_data/abc/user_joined_voice_channel_repository_abc.py similarity index 50% rename from kdb-bot/src/bot_data/abc/user_joined_voice_channel_repository_abc.py rename to bot/src/bot_data/abc/user_joined_voice_channel_repository_abc.py index 7ce7e01a..793cfe33 100644 --- a/kdb-bot/src/bot_data/abc/user_joined_voice_channel_repository_abc.py +++ b/bot/src/bot_data/abc/user_joined_voice_channel_repository_abc.py @@ -19,31 +19,45 @@ class UserJoinedVoiceChannelRepositoryABC(ABC): pass @abstractmethod - def get_user_joined_voice_channels_by_user_id(self, user_id: int) -> List[UserJoinedVoiceChannel]: + def get_user_joined_voice_channels_by_user_id( + self, user_id: int + ) -> List[UserJoinedVoiceChannel]: pass @abstractmethod - def get_active_user_joined_voice_channel_by_user_id(self, user_id: int) -> UserJoinedVoiceChannel: + def get_active_user_joined_voice_channel_by_user_id( + self, user_id: int + ) -> UserJoinedVoiceChannel: pass @abstractmethod - def find_active_user_joined_voice_channel_by_user_id(self, user_id: int) -> Optional[UserJoinedVoiceChannel]: + def find_active_user_joined_voice_channel_by_user_id( + self, user_id: int + ) -> Optional[UserJoinedVoiceChannel]: pass @abstractmethod - def find_active_user_joined_voice_channels_by_user_id(self, user_id: int) -> List[Optional[UserJoinedVoiceChannel]]: + def find_active_user_joined_voice_channels_by_user_id( + self, user_id: int + ) -> List[Optional[UserJoinedVoiceChannel]]: pass @abstractmethod - def add_user_joined_voice_channel(self, user_joined_voice_channel: UserJoinedVoiceChannel): + def add_user_joined_voice_channel( + self, user_joined_voice_channel: UserJoinedVoiceChannel + ): pass @abstractmethod - def update_user_joined_voice_channel(self, user_joined_voice_channel: UserJoinedVoiceChannel): + def update_user_joined_voice_channel( + self, user_joined_voice_channel: UserJoinedVoiceChannel + ): pass @abstractmethod - def delete_user_joined_voice_channel(self, user_joined_voice_channel: UserJoinedVoiceChannel): + def delete_user_joined_voice_channel( + self, user_joined_voice_channel: UserJoinedVoiceChannel + ): pass @abstractmethod diff --git a/kdb-bot/src/bot_data/abc/user_message_count_per_hour_repository_abc.py b/bot/src/bot_data/abc/user_message_count_per_hour_repository_abc.py similarity index 91% rename from kdb-bot/src/bot_data/abc/user_message_count_per_hour_repository_abc.py rename to bot/src/bot_data/abc/user_message_count_per_hour_repository_abc.py index 59108387..778177fa 100644 --- a/kdb-bot/src/bot_data/abc/user_message_count_per_hour_repository_abc.py +++ b/bot/src/bot_data/abc/user_message_count_per_hour_repository_abc.py @@ -17,7 +17,9 @@ class UserMessageCountPerHourRepositoryABC(ABC): pass @abstractmethod - def find_user_message_count_per_hour_by_user_id(self, user_id: int) -> Optional[UserMessageCountPerHour]: + def find_user_message_count_per_hour_by_user_id( + self, user_id: int + ) -> Optional[UserMessageCountPerHour]: pass @abstractmethod diff --git a/kdb-bot/src/bot_data/abc/user_repository_abc.py b/bot/src/bot_data/abc/user_repository_abc.py similarity index 81% rename from kdb-bot/src/bot_data/abc/user_repository_abc.py rename to bot/src/bot_data/abc/user_repository_abc.py index 0e3ced21..1605e24d 100644 --- a/kdb-bot/src/bot_data/abc/user_repository_abc.py +++ b/bot/src/bot_data/abc/user_repository_abc.py @@ -32,11 +32,15 @@ class UserRepositoryABC(ABC): pass @abstractmethod - def get_user_by_discord_id_and_server_id(self, discord_id: int, server_id: int) -> User: + def get_user_by_discord_id_and_server_id( + self, discord_id: int, server_id: int + ) -> User: pass @abstractmethod - def find_user_by_discord_id_and_server_id(self, discord_id: int, server_id: int) -> Optional[User]: + def find_user_by_discord_id_and_server_id( + self, discord_id: int, server_id: int + ) -> Optional[User]: pass @abstractmethod diff --git a/kdb-bot/src/bot_data/abc/user_warnings_repository_abc.py b/bot/src/bot_data/abc/user_warnings_repository_abc.py similarity index 100% rename from kdb-bot/src/bot_data/abc/user_warnings_repository_abc.py rename to bot/src/bot_data/abc/user_warnings_repository_abc.py diff --git a/kdb-bot/src/bot_data/bot-data.json b/bot/src/bot_data/bot-data.json similarity index 100% rename from kdb-bot/src/bot_data/bot-data.json rename to bot/src/bot_data/bot-data.json diff --git a/kdb-bot/src/bot_data/data_module.py b/bot/src/bot_data/data_module.py similarity index 74% rename from kdb-bot/src/bot_data/data_module.py rename to bot/src/bot_data/data_module.py index 378216ed..ad38d4f6 100644 --- a/kdb-bot/src/bot_data/data_module.py +++ b/bot/src/bot_data/data_module.py @@ -17,10 +17,14 @@ from bot_data.abc.level_repository_abc import LevelRepositoryABC from bot_data.abc.server_config_repository_abc import ServerConfigRepositoryABC from bot_data.abc.server_repository_abc import ServerRepositoryABC from bot_data.abc.short_role_name_repository_abc import ShortRoleNameRepositoryABC -from bot_data.abc.steam_special_offer_repository_abc import SteamSpecialOfferRepositoryABC +from bot_data.abc.steam_special_offer_repository_abc import ( + SteamSpecialOfferRepositoryABC, +) from bot_data.abc.technician_config_repository_abc import TechnicianConfigRepositoryABC from bot_data.abc.user_game_ident_repository_abc import UserGameIdentRepositoryABC -from bot_data.abc.user_joined_game_server_repository_abc import UserJoinedGameServerRepositoryABC +from bot_data.abc.user_joined_game_server_repository_abc import ( + UserJoinedGameServerRepositoryABC, +) from bot_data.abc.user_joined_server_repository_abc import UserJoinedServerRepositoryABC from bot_data.abc.user_joined_voice_channel_repository_abc import ( UserJoinedVoiceChannelRepositoryABC, @@ -30,7 +34,9 @@ from bot_data.abc.user_message_count_per_hour_repository_abc import ( ) from bot_data.abc.user_repository_abc import UserRepositoryABC from bot_data.abc.user_warnings_repository_abc import UserWarningsRepositoryABC -from bot_data.service.achievements_repository_service import AchievementRepositoryService +from bot_data.service.achievements_repository_service import ( + AchievementRepositoryService, +) from bot_data.service.api_key_repository_service import ApiKeyRepositoryService from bot_data.service.auth_user_repository_service import AuthUserRepositoryService from bot_data.service.auto_role_repository_service import AutoRoleRepositoryService @@ -40,15 +46,27 @@ from bot_data.service.game_server_repository_service import GameServerRepository from bot_data.service.known_user_repository_service import KnownUserRepositoryService from bot_data.service.level_repository_service import LevelRepositoryService from bot_data.service.seeder_service import SeederService -from bot_data.service.server_config_repository_service import ServerConfigRepositoryService +from bot_data.service.server_config_repository_service import ( + ServerConfigRepositoryService, +) from bot_data.service.server_config_seeder import ServerConfigSeeder from bot_data.service.server_repository_service import ServerRepositoryService -from bot_data.service.short_role_name_repository_service import ShortRoleNameRepositoryService -from bot_data.service.steam_special_offer_repository_service import SteamSpecialOfferRepositoryService -from bot_data.service.technician_config_repository_service import TechnicianConfigRepositoryService +from bot_data.service.short_role_name_repository_service import ( + ShortRoleNameRepositoryService, +) +from bot_data.service.steam_special_offer_repository_service import ( + SteamSpecialOfferRepositoryService, +) +from bot_data.service.technician_config_repository_service import ( + TechnicianConfigRepositoryService, +) from bot_data.service.technician_config_seeder import TechnicianConfigSeeder -from bot_data.service.user_game_ident_repository_service import UserGameIdentRepositoryService -from bot_data.service.user_joined_game_server_repository_service import UserJoinedGameServerRepositoryService +from bot_data.service.user_game_ident_repository_service import ( + UserGameIdentRepositoryService, +) +from bot_data.service.user_joined_game_server_repository_service import ( + UserJoinedGameServerRepositoryService, +) from bot_data.service.user_joined_server_repository_service import ( UserJoinedServerRepositoryService, ) @@ -59,17 +77,23 @@ from bot_data.service.user_message_count_per_hour_repository_service import ( UserMessageCountPerHourRepositoryService, ) from bot_data.service.user_repository_service import UserRepositoryService -from bot_data.service.user_warnings_repository_service import UserWarningsRepositoryService +from bot_data.service.user_warnings_repository_service import ( + UserWarningsRepositoryService, +) class DataModule(ModuleABC): def __init__(self, dc: DiscordCollectionABC): ModuleABC.__init__(self, dc, FeatureFlagsEnum.data_module) - def configure_configuration(self, config: ConfigurationABC, env: ApplicationEnvironmentABC): + def configure_configuration( + self, config: ConfigurationABC, env: ApplicationEnvironmentABC + ): pass - def configure_services(self, services: ServiceCollectionABC, env: ApplicationEnvironmentABC): + def configure_services( + self, services: ServiceCollectionABC, env: ApplicationEnvironmentABC + ): services.add_singleton(CacheService) services.add_transient(ApiKeyRepositoryABC, ApiKeyRepositoryService) @@ -78,9 +102,15 @@ class DataModule(ModuleABC): services.add_transient(UserRepositoryABC, UserRepositoryService) services.add_transient(ClientRepositoryABC, ClientRepositoryService) services.add_transient(KnownUserRepositoryABC, KnownUserRepositoryService) - services.add_transient(UserJoinedServerRepositoryABC, UserJoinedServerRepositoryService) - services.add_transient(UserJoinedVoiceChannelRepositoryABC, UserJoinedVoiceChannelRepositoryService) - services.add_transient(UserJoinedGameServerRepositoryABC, UserJoinedGameServerRepositoryService) + services.add_transient( + UserJoinedServerRepositoryABC, UserJoinedServerRepositoryService + ) + services.add_transient( + UserJoinedVoiceChannelRepositoryABC, UserJoinedVoiceChannelRepositoryService + ) + services.add_transient( + UserJoinedGameServerRepositoryABC, UserJoinedGameServerRepositoryService + ) services.add_transient(AutoRoleRepositoryABC, AutoRoleRepositoryService) services.add_transient(LevelRepositoryABC, LevelRepositoryService) services.add_transient(UserWarningsRepositoryABC, UserWarningsRepositoryService) @@ -89,12 +119,20 @@ class DataModule(ModuleABC): UserMessageCountPerHourRepositoryService, ) services.add_transient(GameServerRepositoryABC, GameServerRepositoryService) - services.add_transient(UserGameIdentRepositoryABC, UserGameIdentRepositoryService) + services.add_transient( + UserGameIdentRepositoryABC, UserGameIdentRepositoryService + ) services.add_transient(AchievementRepositoryABC, AchievementRepositoryService) - services.add_transient(TechnicianConfigRepositoryABC, TechnicianConfigRepositoryService) + services.add_transient( + TechnicianConfigRepositoryABC, TechnicianConfigRepositoryService + ) services.add_transient(ServerConfigRepositoryABC, ServerConfigRepositoryService) - services.add_transient(ShortRoleNameRepositoryABC, ShortRoleNameRepositoryService) - services.add_transient(SteamSpecialOfferRepositoryABC, SteamSpecialOfferRepositoryService) + services.add_transient( + ShortRoleNameRepositoryABC, ShortRoleNameRepositoryService + ) + services.add_transient( + SteamSpecialOfferRepositoryABC, SteamSpecialOfferRepositoryService + ) services.add_transient(SeederService) services.add_transient(DataSeederABC, TechnicianConfigSeeder) diff --git a/kdb-bot/src/bot_data/db_context.py b/bot/src/bot_data/db_context.py similarity index 100% rename from kdb-bot/src/bot_data/db_context.py rename to bot/src/bot_data/db_context.py diff --git a/kdb-bot/src/bot_data/filtered_result.py b/bot/src/bot_data/filtered_result.py similarity index 100% rename from kdb-bot/src/bot_data/filtered_result.py rename to bot/src/bot_data/filtered_result.py diff --git a/kdb-bot/src/bot_data/migration/__init__.py b/bot/src/bot_data/migration/__init__.py similarity index 100% rename from kdb-bot/src/bot_data/migration/__init__.py rename to bot/src/bot_data/migration/__init__.py diff --git a/kdb-bot/src/bot_data/migration/achievements_migration.py b/bot/src/bot_data/migration/achievements_migration.py similarity index 84% rename from kdb-bot/src/bot_data/migration/achievements_migration.py rename to bot/src/bot_data/migration/achievements_migration.py index f3a454d3..b58299c2 100644 --- a/kdb-bot/src/bot_data/migration/achievements_migration.py +++ b/bot/src/bot_data/migration/achievements_migration.py @@ -74,12 +74,30 @@ class AchievementsMigration(MigrationABC): # A join table history between users and achievements is not necessary. - self._cursor.execute(str(f"""ALTER TABLE Users ADD MessageCount BIGINT NOT NULL DEFAULT 0 AFTER XP;""")) - self._cursor.execute(str(f"""ALTER TABLE Users ADD ReactionCount BIGINT NOT NULL DEFAULT 0 AFTER XP;""")) - self._cursor.execute(str(f"""ALTER TABLE UsersHistory ADD MessageCount BIGINT NOT NULL DEFAULT 0 AFTER XP;""")) - self._cursor.execute(str(f"""ALTER TABLE UsersHistory ADD ReactionCount BIGINT NOT NULL DEFAULT 0 AFTER XP;""")) + self._cursor.execute( + str( + f"""ALTER TABLE Users ADD MessageCount BIGINT NOT NULL DEFAULT 0 AFTER XP;""" + ) + ) + self._cursor.execute( + str( + f"""ALTER TABLE Users ADD ReactionCount BIGINT NOT NULL DEFAULT 0 AFTER XP;""" + ) + ) + self._cursor.execute( + str( + f"""ALTER TABLE UsersHistory ADD MessageCount BIGINT NOT NULL DEFAULT 0 AFTER XP;""" + ) + ) + self._cursor.execute( + str( + f"""ALTER TABLE UsersHistory ADD ReactionCount BIGINT NOT NULL DEFAULT 0 AFTER XP;""" + ) + ) - self._cursor.execute(str(f"""DROP TRIGGER IF EXISTS `TR_AchievementsUpdate`;""")) + self._cursor.execute( + str(f"""DROP TRIGGER IF EXISTS `TR_AchievementsUpdate`;""") + ) self._cursor.execute( str( f""" @@ -99,7 +117,9 @@ class AchievementsMigration(MigrationABC): ) ) - self._cursor.execute(str(f"""DROP TRIGGER IF EXISTS `TR_AchievementsDelete`;""")) + self._cursor.execute( + str(f"""DROP TRIGGER IF EXISTS `TR_AchievementsDelete`;""") + ) self._cursor.execute( str( diff --git a/kdb-bot/src/bot_data/migration/api_key_migration.py b/bot/src/bot_data/migration/api_key_migration.py similarity index 100% rename from kdb-bot/src/bot_data/migration/api_key_migration.py rename to bot/src/bot_data/migration/api_key_migration.py diff --git a/kdb-bot/src/bot_data/migration/api_migration.py b/bot/src/bot_data/migration/api_migration.py similarity index 100% rename from kdb-bot/src/bot_data/migration/api_migration.py rename to bot/src/bot_data/migration/api_migration.py diff --git a/kdb-bot/src/bot_data/migration/auto_role_fix1_migration.py b/bot/src/bot_data/migration/auto_role_fix1_migration.py similarity index 100% rename from kdb-bot/src/bot_data/migration/auto_role_fix1_migration.py rename to bot/src/bot_data/migration/auto_role_fix1_migration.py diff --git a/kdb-bot/src/bot_data/migration/auto_role_migration.py b/bot/src/bot_data/migration/auto_role_migration.py similarity index 100% rename from kdb-bot/src/bot_data/migration/auto_role_migration.py rename to bot/src/bot_data/migration/auto_role_migration.py diff --git a/kdb-bot/src/bot_data/migration/birthday_migration.py b/bot/src/bot_data/migration/birthday_migration.py similarity index 100% rename from kdb-bot/src/bot_data/migration/birthday_migration.py rename to bot/src/bot_data/migration/birthday_migration.py diff --git a/kdb-bot/src/bot_data/migration/config_feature_flags_migration.py b/bot/src/bot_data/migration/config_feature_flags_migration.py similarity index 74% rename from kdb-bot/src/bot_data/migration/config_feature_flags_migration.py rename to bot/src/bot_data/migration/config_feature_flags_migration.py index f9046565..a4654bb1 100644 --- a/kdb-bot/src/bot_data/migration/config_feature_flags_migration.py +++ b/bot/src/bot_data/migration/config_feature_flags_migration.py @@ -16,11 +16,15 @@ class ConfigFeatureFlagsMigration(MigrationABC): self._logger.debug(__name__, "Running upgrade") self._cursor.execute( - str("""ALTER TABLE CFG_Technician ADD FeatureFlags JSON NULL DEFAULT ('{}') AFTER CacheMaxMessages;""") + 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;""") + str( + """ALTER TABLE CFG_Server ADD FeatureFlags JSON NULL DEFAULT ('{}') AFTER LoginMessageChannelId;""" + ) ) def downgrade(self): diff --git a/kdb-bot/src/bot_data/migration/config_migration.py b/bot/src/bot_data/migration/config_migration.py similarity index 100% rename from kdb-bot/src/bot_data/migration/config_migration.py rename to bot/src/bot_data/migration/config_migration.py diff --git a/kdb-bot/src/bot_data/migration/db_history_migration.py b/bot/src/bot_data/migration/db_history_migration.py similarity index 100% rename from kdb-bot/src/bot_data/migration/db_history_migration.py rename to bot/src/bot_data/migration/db_history_migration.py diff --git a/kdb-bot/src/bot_data/migration/db_history_scripts/api_keys.sql b/bot/src/bot_data/migration/db_history_scripts/api_keys.sql similarity index 100% rename from kdb-bot/src/bot_data/migration/db_history_scripts/api_keys.sql rename to bot/src/bot_data/migration/db_history_scripts/api_keys.sql diff --git a/kdb-bot/src/bot_data/migration/db_history_scripts/auth_user_users_relation.sql b/bot/src/bot_data/migration/db_history_scripts/auth_user_users_relation.sql similarity index 100% rename from kdb-bot/src/bot_data/migration/db_history_scripts/auth_user_users_relation.sql rename to bot/src/bot_data/migration/db_history_scripts/auth_user_users_relation.sql diff --git a/kdb-bot/src/bot_data/migration/db_history_scripts/auth_users.sql b/bot/src/bot_data/migration/db_history_scripts/auth_users.sql similarity index 100% rename from kdb-bot/src/bot_data/migration/db_history_scripts/auth_users.sql rename to bot/src/bot_data/migration/db_history_scripts/auth_users.sql diff --git a/kdb-bot/src/bot_data/migration/db_history_scripts/auto_role_rules.sql b/bot/src/bot_data/migration/db_history_scripts/auto_role_rules.sql similarity index 100% rename from kdb-bot/src/bot_data/migration/db_history_scripts/auto_role_rules.sql rename to bot/src/bot_data/migration/db_history_scripts/auto_role_rules.sql diff --git a/kdb-bot/src/bot_data/migration/db_history_scripts/auto_roles.sql b/bot/src/bot_data/migration/db_history_scripts/auto_roles.sql similarity index 100% rename from kdb-bot/src/bot_data/migration/db_history_scripts/auto_roles.sql rename to bot/src/bot_data/migration/db_history_scripts/auto_roles.sql diff --git a/kdb-bot/src/bot_data/migration/db_history_scripts/clients.sql b/bot/src/bot_data/migration/db_history_scripts/clients.sql similarity index 100% rename from kdb-bot/src/bot_data/migration/db_history_scripts/clients.sql rename to bot/src/bot_data/migration/db_history_scripts/clients.sql diff --git a/kdb-bot/src/bot_data/migration/db_history_scripts/config/server.sql b/bot/src/bot_data/migration/db_history_scripts/config/server.sql similarity index 100% rename from kdb-bot/src/bot_data/migration/db_history_scripts/config/server.sql rename to bot/src/bot_data/migration/db_history_scripts/config/server.sql diff --git a/kdb-bot/src/bot_data/migration/db_history_scripts/config/server_afk_channels.sql b/bot/src/bot_data/migration/db_history_scripts/config/server_afk_channels.sql similarity index 100% rename from kdb-bot/src/bot_data/migration/db_history_scripts/config/server_afk_channels.sql rename to bot/src/bot_data/migration/db_history_scripts/config/server_afk_channels.sql diff --git a/kdb-bot/src/bot_data/migration/db_history_scripts/config/server_team_roles.sql b/bot/src/bot_data/migration/db_history_scripts/config/server_team_roles.sql similarity index 100% rename from kdb-bot/src/bot_data/migration/db_history_scripts/config/server_team_roles.sql rename to bot/src/bot_data/migration/db_history_scripts/config/server_team_roles.sql diff --git a/kdb-bot/src/bot_data/migration/db_history_scripts/config/technician.sql b/bot/src/bot_data/migration/db_history_scripts/config/technician.sql similarity index 100% rename from kdb-bot/src/bot_data/migration/db_history_scripts/config/technician.sql rename to bot/src/bot_data/migration/db_history_scripts/config/technician.sql diff --git a/kdb-bot/src/bot_data/migration/db_history_scripts/config/technician_ids.sql b/bot/src/bot_data/migration/db_history_scripts/config/technician_ids.sql similarity index 100% rename from kdb-bot/src/bot_data/migration/db_history_scripts/config/technician_ids.sql rename to bot/src/bot_data/migration/db_history_scripts/config/technician_ids.sql diff --git a/kdb-bot/src/bot_data/migration/db_history_scripts/config/technician_ping_urls.sql b/bot/src/bot_data/migration/db_history_scripts/config/technician_ping_urls.sql similarity index 100% rename from kdb-bot/src/bot_data/migration/db_history_scripts/config/technician_ping_urls.sql rename to bot/src/bot_data/migration/db_history_scripts/config/technician_ping_urls.sql diff --git a/kdb-bot/src/bot_data/migration/db_history_scripts/game_servers.sql b/bot/src/bot_data/migration/db_history_scripts/game_servers.sql similarity index 100% rename from kdb-bot/src/bot_data/migration/db_history_scripts/game_servers.sql rename to bot/src/bot_data/migration/db_history_scripts/game_servers.sql diff --git a/kdb-bot/src/bot_data/migration/db_history_scripts/known_users.sql b/bot/src/bot_data/migration/db_history_scripts/known_users.sql similarity index 100% rename from kdb-bot/src/bot_data/migration/db_history_scripts/known_users.sql rename to bot/src/bot_data/migration/db_history_scripts/known_users.sql diff --git a/kdb-bot/src/bot_data/migration/db_history_scripts/levels.sql b/bot/src/bot_data/migration/db_history_scripts/levels.sql similarity index 100% rename from kdb-bot/src/bot_data/migration/db_history_scripts/levels.sql rename to bot/src/bot_data/migration/db_history_scripts/levels.sql diff --git a/kdb-bot/src/bot_data/migration/db_history_scripts/servers.sql b/bot/src/bot_data/migration/db_history_scripts/servers.sql similarity index 100% rename from kdb-bot/src/bot_data/migration/db_history_scripts/servers.sql rename to bot/src/bot_data/migration/db_history_scripts/servers.sql diff --git a/kdb-bot/src/bot_data/migration/db_history_scripts/short_rule_names.sql b/bot/src/bot_data/migration/db_history_scripts/short_rule_names.sql similarity index 100% rename from kdb-bot/src/bot_data/migration/db_history_scripts/short_rule_names.sql rename to bot/src/bot_data/migration/db_history_scripts/short_rule_names.sql diff --git a/kdb-bot/src/bot_data/migration/db_history_scripts/user_game_idents.sql b/bot/src/bot_data/migration/db_history_scripts/user_game_idents.sql similarity index 100% rename from kdb-bot/src/bot_data/migration/db_history_scripts/user_game_idents.sql rename to bot/src/bot_data/migration/db_history_scripts/user_game_idents.sql diff --git a/kdb-bot/src/bot_data/migration/db_history_scripts/user_joined_game_servers.sql b/bot/src/bot_data/migration/db_history_scripts/user_joined_game_servers.sql similarity index 100% rename from kdb-bot/src/bot_data/migration/db_history_scripts/user_joined_game_servers.sql rename to bot/src/bot_data/migration/db_history_scripts/user_joined_game_servers.sql diff --git a/kdb-bot/src/bot_data/migration/db_history_scripts/user_joined_servers.sql b/bot/src/bot_data/migration/db_history_scripts/user_joined_servers.sql similarity index 100% rename from kdb-bot/src/bot_data/migration/db_history_scripts/user_joined_servers.sql rename to bot/src/bot_data/migration/db_history_scripts/user_joined_servers.sql diff --git a/kdb-bot/src/bot_data/migration/db_history_scripts/user_joined_voice_channel.sql b/bot/src/bot_data/migration/db_history_scripts/user_joined_voice_channel.sql similarity index 100% rename from kdb-bot/src/bot_data/migration/db_history_scripts/user_joined_voice_channel.sql rename to bot/src/bot_data/migration/db_history_scripts/user_joined_voice_channel.sql diff --git a/kdb-bot/src/bot_data/migration/db_history_scripts/user_message_count_per_hour.sql b/bot/src/bot_data/migration/db_history_scripts/user_message_count_per_hour.sql similarity index 100% rename from kdb-bot/src/bot_data/migration/db_history_scripts/user_message_count_per_hour.sql rename to bot/src/bot_data/migration/db_history_scripts/user_message_count_per_hour.sql diff --git a/kdb-bot/src/bot_data/migration/db_history_scripts/user_warnings.sql b/bot/src/bot_data/migration/db_history_scripts/user_warnings.sql similarity index 100% rename from kdb-bot/src/bot_data/migration/db_history_scripts/user_warnings.sql rename to bot/src/bot_data/migration/db_history_scripts/user_warnings.sql diff --git a/kdb-bot/src/bot_data/migration/db_history_scripts/users.sql b/bot/src/bot_data/migration/db_history_scripts/users.sql similarity index 100% rename from kdb-bot/src/bot_data/migration/db_history_scripts/users.sql rename to bot/src/bot_data/migration/db_history_scripts/users.sql diff --git a/kdb-bot/src/bot_data/migration/default_role_migration.py b/bot/src/bot_data/migration/default_role_migration.py similarity index 100% rename from kdb-bot/src/bot_data/migration/default_role_migration.py rename to bot/src/bot_data/migration/default_role_migration.py diff --git a/kdb-bot/src/bot_data/migration/fix_updates_migration.py b/bot/src/bot_data/migration/fix_updates_migration.py similarity index 93% rename from kdb-bot/src/bot_data/migration/fix_updates_migration.py rename to bot/src/bot_data/migration/fix_updates_migration.py index f4d5e020..9f2420e3 100644 --- a/kdb-bot/src/bot_data/migration/fix_updates_migration.py +++ b/bot/src/bot_data/migration/fix_updates_migration.py @@ -47,5 +47,7 @@ class FixUpdatesMigration(MigrationABC): """ ) ) - self._cursor.execute("ALTER TABLE CFG_TechnicianHistory DROP COLUMN FeatureFlags;") + self._cursor.execute( + "ALTER TABLE CFG_TechnicianHistory DROP COLUMN FeatureFlags;" + ) self._cursor.execute("ALTER TABLE CFG_ServerHistory DROP COLUMN FeatureFlags;") diff --git a/kdb-bot/src/bot_data/migration/fix_user_history_migration.py b/bot/src/bot_data/migration/fix_user_history_migration.py similarity index 100% rename from kdb-bot/src/bot_data/migration/fix_user_history_migration.py rename to bot/src/bot_data/migration/fix_user_history_migration.py diff --git a/kdb-bot/src/bot_data/migration/initial_migration.py b/bot/src/bot_data/migration/initial_migration.py similarity index 100% rename from kdb-bot/src/bot_data/migration/initial_migration.py rename to bot/src/bot_data/migration/initial_migration.py diff --git a/kdb-bot/src/bot_data/migration/level_migration.py b/bot/src/bot_data/migration/level_migration.py similarity index 100% rename from kdb-bot/src/bot_data/migration/level_migration.py rename to bot/src/bot_data/migration/level_migration.py diff --git a/kdb-bot/src/bot_data/migration/remove_stats_migration.py b/bot/src/bot_data/migration/remove_stats_migration.py similarity index 100% rename from kdb-bot/src/bot_data/migration/remove_stats_migration.py rename to bot/src/bot_data/migration/remove_stats_migration.py diff --git a/kdb-bot/src/bot_data/migration/short_role_name_migration.py b/bot/src/bot_data/migration/short_role_name_migration.py similarity index 100% rename from kdb-bot/src/bot_data/migration/short_role_name_migration.py rename to bot/src/bot_data/migration/short_role_name_migration.py diff --git a/kdb-bot/src/bot_data/migration/short_role_name_only_highest_migration.py b/bot/src/bot_data/migration/short_role_name_only_highest_migration.py similarity index 100% rename from kdb-bot/src/bot_data/migration/short_role_name_only_highest_migration.py rename to bot/src/bot_data/migration/short_role_name_only_highest_migration.py diff --git a/kdb-bot/src/bot_data/migration/stats_migration.py b/bot/src/bot_data/migration/stats_migration.py similarity index 100% rename from kdb-bot/src/bot_data/migration/stats_migration.py rename to bot/src/bot_data/migration/stats_migration.py diff --git a/kdb-bot/src/bot_data/migration/steam_special_offer_migration.py b/bot/src/bot_data/migration/steam_special_offer_migration.py similarity index 100% rename from kdb-bot/src/bot_data/migration/steam_special_offer_migration.py rename to bot/src/bot_data/migration/steam_special_offer_migration.py diff --git a/kdb-bot/src/bot_data/migration/user_joined_game_server_migration.py b/bot/src/bot_data/migration/user_joined_game_server_migration.py similarity index 100% rename from kdb-bot/src/bot_data/migration/user_joined_game_server_migration.py rename to bot/src/bot_data/migration/user_joined_game_server_migration.py diff --git a/kdb-bot/src/bot_data/migration/user_message_count_per_hour_migration.py b/bot/src/bot_data/migration/user_message_count_per_hour_migration.py similarity index 100% rename from kdb-bot/src/bot_data/migration/user_message_count_per_hour_migration.py rename to bot/src/bot_data/migration/user_message_count_per_hour_migration.py diff --git a/kdb-bot/src/bot_data/migration/user_warning_migration.py b/bot/src/bot_data/migration/user_warning_migration.py similarity index 100% rename from kdb-bot/src/bot_data/migration/user_warning_migration.py rename to bot/src/bot_data/migration/user_warning_migration.py diff --git a/kdb-bot/src/bot_data/model/__init__.py b/bot/src/bot_data/model/__init__.py similarity index 100% rename from kdb-bot/src/bot_data/model/__init__.py rename to bot/src/bot_data/model/__init__.py diff --git a/kdb-bot/src/bot_data/model/achievement.py b/bot/src/bot_data/model/achievement.py similarity index 97% rename from kdb-bot/src/bot_data/model/achievement.py rename to bot/src/bot_data/model/achievement.py index ebce645d..97a3e059 100644 --- a/kdb-bot/src/bot_data/model/achievement.py +++ b/bot/src/bot_data/model/achievement.py @@ -34,7 +34,9 @@ class Achievement(TableABC): TableABC.__init__(self) self._created_at = created_at if created_at is not None else self._created_at - self._modified_at = modified_at if modified_at is not None else self._modified_at + self._modified_at = ( + modified_at if modified_at is not None else self._modified_at + ) @ServiceProviderABC.inject def _is_operator_valid(self, operator, service: ServiceProviderABC) -> bool: diff --git a/kdb-bot/src/bot_data/model/achievement_history.py b/bot/src/bot_data/model/achievement_history.py similarity index 100% rename from kdb-bot/src/bot_data/model/achievement_history.py rename to bot/src/bot_data/model/achievement_history.py diff --git a/kdb-bot/src/bot_data/model/api_key.py b/bot/src/bot_data/model/api_key.py similarity index 95% rename from kdb-bot/src/bot_data/model/api_key.py rename to bot/src/bot_data/model/api_key.py index d63c4d1b..20abc12d 100644 --- a/kdb-bot/src/bot_data/model/api_key.py +++ b/bot/src/bot_data/model/api_key.py @@ -23,7 +23,9 @@ class ApiKey(TableABC): TableABC.__init__(self) self._created_at = created_at if created_at is not None else self._created_at - self._modified_at = modified_at if modified_at is not None else self._modified_at + self._modified_at = ( + modified_at if modified_at is not None else self._modified_at + ) @property def id(self) -> int: diff --git a/kdb-bot/src/bot_data/model/auth_role_enum.py b/bot/src/bot_data/model/auth_role_enum.py similarity index 100% rename from kdb-bot/src/bot_data/model/auth_role_enum.py rename to bot/src/bot_data/model/auth_role_enum.py diff --git a/kdb-bot/src/bot_data/model/auth_user.py b/bot/src/bot_data/model/auth_user.py similarity index 98% rename from kdb-bot/src/bot_data/model/auth_user.py rename to bot/src/bot_data/model/auth_user.py index 47bdf41a..cdc6d8a2 100644 --- a/kdb-bot/src/bot_data/model/auth_user.py +++ b/bot/src/bot_data/model/auth_user.py @@ -49,7 +49,9 @@ class AuthUser(TableABC): TableABC.__init__(self) self._created_at = created_at if created_at is not None else self._created_at - self._modified_at = modified_at if modified_at is not None else self._modified_at + self._modified_at = ( + modified_at if modified_at is not None else self._modified_at + ) @property def id(self) -> int: diff --git a/kdb-bot/src/bot_data/model/auth_user_users_relation.py b/bot/src/bot_data/model/auth_user_users_relation.py similarity index 95% rename from kdb-bot/src/bot_data/model/auth_user_users_relation.py rename to bot/src/bot_data/model/auth_user_users_relation.py index 23b9ceab..25e66301 100644 --- a/kdb-bot/src/bot_data/model/auth_user_users_relation.py +++ b/bot/src/bot_data/model/auth_user_users_relation.py @@ -19,7 +19,9 @@ class AuthUserUsersRelation(TableABC): TableABC.__init__(self) self._created_at = created_at if created_at is not None else self._created_at - self._modified_at = modified_at if modified_at is not None else self._modified_at + self._modified_at = ( + modified_at if modified_at is not None else self._modified_at + ) @property def auth_user(self) -> AuthUser: diff --git a/kdb-bot/src/bot_data/model/auto_role.py b/bot/src/bot_data/model/auto_role.py similarity index 96% rename from kdb-bot/src/bot_data/model/auto_role.py rename to bot/src/bot_data/model/auto_role.py index a1ff7934..e8b446c7 100644 --- a/kdb-bot/src/bot_data/model/auto_role.py +++ b/bot/src/bot_data/model/auto_role.py @@ -25,7 +25,9 @@ class AutoRole(TableABC): TableABC.__init__(self) self._created_at = created_at if created_at is not None else self._created_at - self._modified_at = modified_at if modified_at is not None else self._modified_at + self._modified_at = ( + modified_at if modified_at is not None else self._modified_at + ) @property def id(self) -> int: diff --git a/kdb-bot/src/bot_data/model/auto_role_history.py b/bot/src/bot_data/model/auto_role_history.py similarity index 100% rename from kdb-bot/src/bot_data/model/auto_role_history.py rename to bot/src/bot_data/model/auto_role_history.py diff --git a/kdb-bot/src/bot_data/model/auto_role_rule.py b/bot/src/bot_data/model/auto_role_rule.py similarity index 96% rename from kdb-bot/src/bot_data/model/auto_role_rule.py rename to bot/src/bot_data/model/auto_role_rule.py index 8729b6ec..f90fd86f 100644 --- a/kdb-bot/src/bot_data/model/auto_role_rule.py +++ b/bot/src/bot_data/model/auto_role_rule.py @@ -24,7 +24,9 @@ class AutoRoleRule(TableABC): TableABC.__init__(self) self._created_at = created_at if created_at is not None else self._created_at - self._modified_at = modified_at if modified_at is not None else self._modified_at + self._modified_at = ( + modified_at if modified_at is not None else self._modified_at + ) @property def id(self) -> int: diff --git a/kdb-bot/src/bot_data/model/auto_role_rule_history.py b/bot/src/bot_data/model/auto_role_rule_history.py similarity index 100% rename from kdb-bot/src/bot_data/model/auto_role_rule_history.py rename to bot/src/bot_data/model/auto_role_rule_history.py diff --git a/kdb-bot/src/bot_data/model/client.py b/bot/src/bot_data/model/client.py similarity index 97% rename from kdb-bot/src/bot_data/model/client.py rename to bot/src/bot_data/model/client.py index b6c163c9..e8c56adf 100644 --- a/kdb-bot/src/bot_data/model/client.py +++ b/bot/src/bot_data/model/client.py @@ -32,7 +32,9 @@ class Client(TableABC): TableABC.__init__(self) self._created_at = created_at if created_at is not None else self._created_at - self._modified_at = modified_at if modified_at is not None else self._modified_at + self._modified_at = ( + modified_at if modified_at is not None else self._modified_at + ) @property def id(self) -> int: diff --git a/kdb-bot/src/bot_data/model/client_history.py b/bot/src/bot_data/model/client_history.py similarity index 100% rename from kdb-bot/src/bot_data/model/client_history.py rename to bot/src/bot_data/model/client_history.py diff --git a/kdb-bot/src/bot_data/model/game_server.py b/bot/src/bot_data/model/game_server.py similarity index 96% rename from kdb-bot/src/bot_data/model/game_server.py rename to bot/src/bot_data/model/game_server.py index eeea20d8..8cc510af 100644 --- a/kdb-bot/src/bot_data/model/game_server.py +++ b/bot/src/bot_data/model/game_server.py @@ -23,7 +23,9 @@ class GameServer(TableABC): TableABC.__init__(self) self._created_at = created_at if created_at is not None else self._created_at - self._modified_at = modified_at if modified_at is not None else self._modified_at + self._modified_at = ( + modified_at if modified_at is not None else self._modified_at + ) @property def id(self) -> int: diff --git a/kdb-bot/src/bot_data/model/known_user.py b/bot/src/bot_data/model/known_user.py similarity index 93% rename from kdb-bot/src/bot_data/model/known_user.py rename to bot/src/bot_data/model/known_user.py index 37d375f0..e07bcf83 100644 --- a/kdb-bot/src/bot_data/model/known_user.py +++ b/bot/src/bot_data/model/known_user.py @@ -16,7 +16,9 @@ class KnownUser(TableABC): TableABC.__init__(self) self._created_at = created_at if created_at is not None else self._created_at - self._modified_at = modified_at if modified_at is not None else self._modified_at + self._modified_at = ( + modified_at if modified_at is not None else self._modified_at + ) @property def id(self) -> int: diff --git a/kdb-bot/src/bot_data/model/known_user_history.py b/bot/src/bot_data/model/known_user_history.py similarity index 100% rename from kdb-bot/src/bot_data/model/known_user_history.py rename to bot/src/bot_data/model/known_user_history.py diff --git a/kdb-bot/src/bot_data/model/level.py b/bot/src/bot_data/model/level.py similarity index 96% rename from kdb-bot/src/bot_data/model/level.py rename to bot/src/bot_data/model/level.py index a20d268b..bdad1826 100644 --- a/kdb-bot/src/bot_data/model/level.py +++ b/bot/src/bot_data/model/level.py @@ -27,7 +27,9 @@ class Level(TableABC): TableABC.__init__(self) self._created_at = created_at if created_at is not None else self._created_at - self._modified_at = modified_at if modified_at is not None else self._modified_at + self._modified_at = ( + modified_at if modified_at is not None else self._modified_at + ) @property def id(self) -> int: diff --git a/kdb-bot/src/bot_data/model/level_history.py b/bot/src/bot_data/model/level_history.py similarity index 100% rename from kdb-bot/src/bot_data/model/level_history.py rename to bot/src/bot_data/model/level_history.py diff --git a/kdb-bot/src/bot_data/model/migration_history.py b/bot/src/bot_data/model/migration_history.py similarity index 100% rename from kdb-bot/src/bot_data/model/migration_history.py rename to bot/src/bot_data/model/migration_history.py diff --git a/kdb-bot/src/bot_data/model/server.py b/bot/src/bot_data/model/server.py similarity index 95% rename from kdb-bot/src/bot_data/model/server.py rename to bot/src/bot_data/model/server.py index d86c6e97..5ae54ca7 100644 --- a/kdb-bot/src/bot_data/model/server.py +++ b/bot/src/bot_data/model/server.py @@ -18,7 +18,9 @@ class Server(TableABC): TableABC.__init__(self) self._created_at = created_at if created_at is not None else self._created_at - self._modified_at = modified_at if modified_at is not None else self._modified_at + self._modified_at = ( + modified_at if modified_at is not None else self._modified_at + ) @property def id(self) -> int: diff --git a/kdb-bot/src/bot_data/model/server_afk_channel_ids_config.py b/bot/src/bot_data/model/server_afk_channel_ids_config.py similarity index 94% rename from kdb-bot/src/bot_data/model/server_afk_channel_ids_config.py rename to bot/src/bot_data/model/server_afk_channel_ids_config.py index 9b182426..2c9042d9 100644 --- a/kdb-bot/src/bot_data/model/server_afk_channel_ids_config.py +++ b/bot/src/bot_data/model/server_afk_channel_ids_config.py @@ -18,7 +18,9 @@ class ServerAFKChannelIdsConfig(TableABC): TableABC.__init__(self) self._created_at = created_at if created_at is not None else self._created_at - self._modified_at = modified_at if modified_at is not None else self._modified_at + self._modified_at = ( + modified_at if modified_at is not None else self._modified_at + ) @property def channel_id(self) -> int: diff --git a/kdb-bot/src/bot_data/model/server_config.py b/bot/src/bot_data/model/server_config.py similarity index 98% rename from kdb-bot/src/bot_data/model/server_config.py rename to bot/src/bot_data/model/server_config.py index cf220355..3453de2f 100644 --- a/kdb-bot/src/bot_data/model/server_config.py +++ b/bot/src/bot_data/model/server_config.py @@ -56,7 +56,9 @@ class ServerConfig(TableABC, ConfigurationModelABC): self._team_channel_id = team_channel_id self._login_message_channel_id = login_message_channel_id self._default_role_id = default_role_id - self._short_role_name_only_set_highest_role = short_role_name_only_set_highest_role + self._short_role_name_only_set_highest_role = ( + short_role_name_only_set_highest_role + ) self._game_offer_notification_chat_id = game_offer_notification_chat_id self._feature_flags = feature_flags @@ -66,7 +68,9 @@ class ServerConfig(TableABC, ConfigurationModelABC): TableABC.__init__(self) self._created_at = created_at if created_at is not None else self._created_at - self._modified_at = modified_at if modified_at is not None else self._modified_at + self._modified_at = ( + modified_at if modified_at is not None else self._modified_at + ) @staticmethod def new(guild: Guild, server: Server) -> "ServerConfig": diff --git a/kdb-bot/src/bot_data/model/server_config_history.py b/bot/src/bot_data/model/server_config_history.py similarity index 96% rename from kdb-bot/src/bot_data/model/server_config_history.py rename to bot/src/bot_data/model/server_config_history.py index 6364f2eb..009491bd 100644 --- a/kdb-bot/src/bot_data/model/server_config_history.py +++ b/bot/src/bot_data/model/server_config_history.py @@ -43,7 +43,9 @@ class ServerConfigHistory(HistoryTableABC): self._team_channel_id = team_channel_id self._login_message_channel_id = login_message_channel_id self._default_role_id = default_role_id - self._short_role_name_only_set_highest_role = short_role_name_only_set_highest_role + self._short_role_name_only_set_highest_role = ( + short_role_name_only_set_highest_role + ) self._feature_flags = feature_flags self._server_id = server_id diff --git a/kdb-bot/src/bot_data/model/server_history.py b/bot/src/bot_data/model/server_history.py similarity index 100% rename from kdb-bot/src/bot_data/model/server_history.py rename to bot/src/bot_data/model/server_history.py diff --git a/kdb-bot/src/bot_data/model/server_team_role_ids_config.py b/bot/src/bot_data/model/server_team_role_ids_config.py similarity index 95% rename from kdb-bot/src/bot_data/model/server_team_role_ids_config.py rename to bot/src/bot_data/model/server_team_role_ids_config.py index dfd870dd..7be73531 100644 --- a/kdb-bot/src/bot_data/model/server_team_role_ids_config.py +++ b/bot/src/bot_data/model/server_team_role_ids_config.py @@ -22,7 +22,9 @@ class ServerTeamRoleIdsConfig(TableABC): TableABC.__init__(self) self._created_at = created_at if created_at is not None else self._created_at - self._modified_at = modified_at if modified_at is not None else self._modified_at + self._modified_at = ( + modified_at if modified_at is not None else self._modified_at + ) @property def id(self) -> int: diff --git a/kdb-bot/src/bot_data/model/short_role_name.py b/bot/src/bot_data/model/short_role_name.py similarity index 96% rename from kdb-bot/src/bot_data/model/short_role_name.py rename to bot/src/bot_data/model/short_role_name.py index 4ddef4f1..d03b6ddc 100644 --- a/kdb-bot/src/bot_data/model/short_role_name.py +++ b/bot/src/bot_data/model/short_role_name.py @@ -27,7 +27,9 @@ class ShortRoleName(TableABC): TableABC.__init__(self) self._created_at = created_at if created_at is not None else self._created_at - self._modified_at = modified_at if modified_at is not None else self._modified_at + self._modified_at = ( + modified_at if modified_at is not None else self._modified_at + ) @property def id(self) -> int: diff --git a/kdb-bot/src/bot_data/model/short_role_name_history.py b/bot/src/bot_data/model/short_role_name_history.py similarity index 100% rename from kdb-bot/src/bot_data/model/short_role_name_history.py rename to bot/src/bot_data/model/short_role_name_history.py diff --git a/kdb-bot/src/bot_data/model/short_role_name_position_enum.py b/bot/src/bot_data/model/short_role_name_position_enum.py similarity index 100% rename from kdb-bot/src/bot_data/model/short_role_name_position_enum.py rename to bot/src/bot_data/model/short_role_name_position_enum.py diff --git a/kdb-bot/src/bot_data/model/steam_special_offer.py b/bot/src/bot_data/model/steam_special_offer.py similarity index 96% rename from kdb-bot/src/bot_data/model/steam_special_offer.py rename to bot/src/bot_data/model/steam_special_offer.py index 76301dc4..0b7e6927 100644 --- a/kdb-bot/src/bot_data/model/steam_special_offer.py +++ b/bot/src/bot_data/model/steam_special_offer.py @@ -22,7 +22,9 @@ class SteamSpecialOffer(TableABC): TableABC.__init__(self) self._created_at = created_at if created_at is not None else self._created_at - self._modified_at = modified_at if modified_at is not None else self._modified_at + self._modified_at = ( + modified_at if modified_at is not None else self._modified_at + ) @property def id(self) -> int: diff --git a/kdb-bot/src/bot_data/model/team_member_type_enum.py b/bot/src/bot_data/model/team_member_type_enum.py similarity index 100% rename from kdb-bot/src/bot_data/model/team_member_type_enum.py rename to bot/src/bot_data/model/team_member_type_enum.py diff --git a/kdb-bot/src/bot_data/model/technician_config.py b/bot/src/bot_data/model/technician_config.py similarity index 97% rename from kdb-bot/src/bot_data/model/technician_config.py rename to bot/src/bot_data/model/technician_config.py index 1390f4b8..9aab8628 100644 --- a/kdb-bot/src/bot_data/model/technician_config.py +++ b/bot/src/bot_data/model/technician_config.py @@ -33,7 +33,9 @@ class TechnicianConfig(TableABC, ConfigurationModelABC): TableABC.__init__(self) self._created_at = created_at if created_at is not None else self._created_at - self._modified_at = modified_at if modified_at is not None else self._modified_at + self._modified_at = ( + modified_at if modified_at is not None else self._modified_at + ) @property def id(self) -> int: diff --git a/kdb-bot/src/bot_data/model/technician_config_history.py b/bot/src/bot_data/model/technician_config_history.py similarity index 100% rename from kdb-bot/src/bot_data/model/technician_config_history.py rename to bot/src/bot_data/model/technician_config_history.py diff --git a/kdb-bot/src/bot_data/model/technician_id_config.py b/bot/src/bot_data/model/technician_id_config.py similarity index 94% rename from kdb-bot/src/bot_data/model/technician_id_config.py rename to bot/src/bot_data/model/technician_id_config.py index 6ba5f581..7db76b4b 100644 --- a/kdb-bot/src/bot_data/model/technician_id_config.py +++ b/bot/src/bot_data/model/technician_id_config.py @@ -16,7 +16,9 @@ class TechnicianIdConfig(TableABC): TableABC.__init__(self) self._created_at = created_at if created_at is not None else self._created_at - self._modified_at = modified_at if modified_at is not None else self._modified_at + self._modified_at = ( + modified_at if modified_at is not None else self._modified_at + ) @property def id(self) -> int: diff --git a/kdb-bot/src/bot_data/model/technician_id_config_history.py b/bot/src/bot_data/model/technician_id_config_history.py similarity index 100% rename from kdb-bot/src/bot_data/model/technician_id_config_history.py rename to bot/src/bot_data/model/technician_id_config_history.py diff --git a/kdb-bot/src/bot_data/model/technician_ping_url_config.py b/bot/src/bot_data/model/technician_ping_url_config.py similarity index 94% rename from kdb-bot/src/bot_data/model/technician_ping_url_config.py rename to bot/src/bot_data/model/technician_ping_url_config.py index 31983624..bcc63b97 100644 --- a/kdb-bot/src/bot_data/model/technician_ping_url_config.py +++ b/bot/src/bot_data/model/technician_ping_url_config.py @@ -16,7 +16,9 @@ class TechnicianPingUrlConfig(TableABC): TableABC.__init__(self) self._created_at = created_at if created_at is not None else self._created_at - self._modified_at = modified_at if modified_at is not None else self._modified_at + self._modified_at = ( + modified_at if modified_at is not None else self._modified_at + ) @property def id(self) -> int: diff --git a/kdb-bot/src/bot_data/model/technician_ping_url_config_history.py b/bot/src/bot_data/model/technician_ping_url_config_history.py similarity index 100% rename from kdb-bot/src/bot_data/model/technician_ping_url_config_history.py rename to bot/src/bot_data/model/technician_ping_url_config_history.py diff --git a/kdb-bot/src/bot_data/model/user.py b/bot/src/bot_data/model/user.py similarity index 94% rename from kdb-bot/src/bot_data/model/user.py rename to bot/src/bot_data/model/user.py index 310ecc08..d1e7d514 100644 --- a/kdb-bot/src/bot_data/model/user.py +++ b/bot/src/bot_data/model/user.py @@ -33,7 +33,9 @@ class User(TableABC): TableABC.__init__(self) self._created_at = created_at if created_at is not None else self._created_at - self._modified_at = modified_at if modified_at is not None else self._modified_at + self._modified_at = ( + modified_at if modified_at is not None else self._modified_at + ) @property def id(self) -> int: @@ -115,9 +117,13 @@ class User(TableABC): self, services: ServiceProviderABC, ) -> bool: - from bot_data.abc.user_joined_server_repository_abc import UserJoinedServerRepositoryABC + from bot_data.abc.user_joined_server_repository_abc import ( + UserJoinedServerRepositoryABC, + ) - ujs: UserJoinedServerRepositoryABC = services.get_service(UserJoinedServerRepositoryABC) + ujs: UserJoinedServerRepositoryABC = services.get_service( + UserJoinedServerRepositoryABC + ) return ujs.find_active_user_joined_server_by_user_id(self.id) is None @property @@ -126,9 +132,13 @@ class User(TableABC): self, services: ServiceProviderABC, ) -> List["UserGameIdent"]: - from bot_data.abc.user_game_ident_repository_abc import UserGameIdentRepositoryABC + from bot_data.abc.user_game_ident_repository_abc import ( + UserGameIdentRepositoryABC, + ) - game_idents_repo: UserGameIdentRepositoryABC = services.get_service(UserGameIdentRepositoryABC) + game_idents_repo: UserGameIdentRepositoryABC = services.get_service( + UserGameIdentRepositoryABC + ) return game_idents_repo.get_user_game_idents_by_user_id(self.id) @staticmethod diff --git a/kdb-bot/src/bot_data/model/user_game_ident.py b/bot/src/bot_data/model/user_game_ident.py similarity index 96% rename from kdb-bot/src/bot_data/model/user_game_ident.py rename to bot/src/bot_data/model/user_game_ident.py index 79468d13..11d88a66 100644 --- a/kdb-bot/src/bot_data/model/user_game_ident.py +++ b/bot/src/bot_data/model/user_game_ident.py @@ -23,7 +23,9 @@ class UserGameIdent(TableABC): TableABC.__init__(self) self._created_at = created_at if created_at is not None else self._created_at - self._modified_at = modified_at if modified_at is not None else self._modified_at + self._modified_at = ( + modified_at if modified_at is not None else self._modified_at + ) @property def id(self) -> int: diff --git a/kdb-bot/src/bot_data/model/user_got_achievement.py b/bot/src/bot_data/model/user_got_achievement.py similarity index 95% rename from kdb-bot/src/bot_data/model/user_got_achievement.py rename to bot/src/bot_data/model/user_got_achievement.py index d2c37cf5..373bfe05 100644 --- a/kdb-bot/src/bot_data/model/user_got_achievement.py +++ b/bot/src/bot_data/model/user_got_achievement.py @@ -22,7 +22,9 @@ class UserGotAchievement(TableABC): TableABC.__init__(self) self._created_at = created_at if created_at is not None else self._created_at - self._modified_at = modified_at if modified_at is not None else self._modified_at + self._modified_at = ( + modified_at if modified_at is not None else self._modified_at + ) @property def id(self) -> int: diff --git a/kdb-bot/src/bot_data/model/user_history.py b/bot/src/bot_data/model/user_history.py similarity index 89% rename from kdb-bot/src/bot_data/model/user_history.py rename to bot/src/bot_data/model/user_history.py index 2bf39954..461550fe 100644 --- a/kdb-bot/src/bot_data/model/user_history.py +++ b/bot/src/bot_data/model/user_history.py @@ -60,9 +60,13 @@ class UserHistory(HistoryTableABC): self, services: ServiceProviderABC, ) -> bool: - from bot_data.abc.user_joined_server_repository_abc import UserJoinedServerRepositoryABC + from bot_data.abc.user_joined_server_repository_abc import ( + UserJoinedServerRepositoryABC, + ) - ujs: UserJoinedServerRepositoryABC = services.get_service(UserJoinedServerRepositoryABC) + ujs: UserJoinedServerRepositoryABC = services.get_service( + UserJoinedServerRepositoryABC + ) return ujs.find_active_user_joined_server_by_user_id(self.id) is None @property @@ -71,7 +75,11 @@ class UserHistory(HistoryTableABC): self, services: ServiceProviderABC, ) -> List["UserGameIdent"]: - from bot_data.abc.user_game_ident_repository_abc import UserGameIdentRepositoryABC + from bot_data.abc.user_game_ident_repository_abc import ( + UserGameIdentRepositoryABC, + ) - game_idents_repo: UserGameIdentRepositoryABC = services.get_service(UserGameIdentRepositoryABC) + game_idents_repo: UserGameIdentRepositoryABC = services.get_service( + UserGameIdentRepositoryABC + ) return game_idents_repo.get_user_game_idents_by_user_id(self.id) diff --git a/kdb-bot/src/bot_data/model/user_joined_game_server.py b/bot/src/bot_data/model/user_joined_game_server.py similarity index 96% rename from kdb-bot/src/bot_data/model/user_joined_game_server.py rename to bot/src/bot_data/model/user_joined_game_server.py index cf60229d..8cfaae11 100644 --- a/kdb-bot/src/bot_data/model/user_joined_game_server.py +++ b/bot/src/bot_data/model/user_joined_game_server.py @@ -25,7 +25,9 @@ class UserJoinedGameServer(TableABC): TableABC.__init__(self) self._created_at = created_at if created_at is not None else self._created_at - self._modified_at = modified_at if modified_at is not None else self._modified_at + self._modified_at = ( + modified_at if modified_at is not None else self._modified_at + ) @property def id(self) -> int: diff --git a/kdb-bot/src/bot_data/model/user_joined_game_server_history.py b/bot/src/bot_data/model/user_joined_game_server_history.py similarity index 100% rename from kdb-bot/src/bot_data/model/user_joined_game_server_history.py rename to bot/src/bot_data/model/user_joined_game_server_history.py diff --git a/kdb-bot/src/bot_data/model/user_joined_server.py b/bot/src/bot_data/model/user_joined_server.py similarity index 96% rename from kdb-bot/src/bot_data/model/user_joined_server.py rename to bot/src/bot_data/model/user_joined_server.py index e55cb60d..25cf2b27 100644 --- a/kdb-bot/src/bot_data/model/user_joined_server.py +++ b/bot/src/bot_data/model/user_joined_server.py @@ -22,7 +22,9 @@ class UserJoinedServer(TableABC): TableABC.__init__(self) self._created_at = created_at if created_at is not None else self._created_at - self._modified_at = modified_at if modified_at is not None else self._modified_at + self._modified_at = ( + modified_at if modified_at is not None else self._modified_at + ) @property def id(self) -> int: diff --git a/kdb-bot/src/bot_data/model/user_joined_server_history.py b/bot/src/bot_data/model/user_joined_server_history.py similarity index 100% rename from kdb-bot/src/bot_data/model/user_joined_server_history.py rename to bot/src/bot_data/model/user_joined_server_history.py diff --git a/kdb-bot/src/bot_data/model/user_joined_voice_channel.py b/bot/src/bot_data/model/user_joined_voice_channel.py similarity index 97% rename from kdb-bot/src/bot_data/model/user_joined_voice_channel.py rename to bot/src/bot_data/model/user_joined_voice_channel.py index 3b938452..5764b5e8 100644 --- a/kdb-bot/src/bot_data/model/user_joined_voice_channel.py +++ b/bot/src/bot_data/model/user_joined_voice_channel.py @@ -26,7 +26,9 @@ class UserJoinedVoiceChannel(TableABC): TableABC.__init__(self) self._created_at = created_at if created_at is not None else self._created_at - self._modified_at = modified_at if modified_at is not None else self._modified_at + self._modified_at = ( + modified_at if modified_at is not None else self._modified_at + ) @property def id(self) -> int: diff --git a/kdb-bot/src/bot_data/model/user_joined_voice_channel_history.py b/bot/src/bot_data/model/user_joined_voice_channel_history.py similarity index 100% rename from kdb-bot/src/bot_data/model/user_joined_voice_channel_history.py rename to bot/src/bot_data/model/user_joined_voice_channel_history.py diff --git a/kdb-bot/src/bot_data/model/user_message_count_per_hour.py b/bot/src/bot_data/model/user_message_count_per_hour.py similarity index 96% rename from kdb-bot/src/bot_data/model/user_message_count_per_hour.py rename to bot/src/bot_data/model/user_message_count_per_hour.py index 7815ffa4..be0fdddc 100644 --- a/kdb-bot/src/bot_data/model/user_message_count_per_hour.py +++ b/bot/src/bot_data/model/user_message_count_per_hour.py @@ -24,7 +24,9 @@ class UserMessageCountPerHour(TableABC): TableABC.__init__(self) self._created_at = created_at if created_at is not None else self._created_at - self._modified_at = modified_at if modified_at is not None else self._modified_at + self._modified_at = ( + modified_at if modified_at is not None else self._modified_at + ) @property def id(self) -> int: diff --git a/kdb-bot/src/bot_data/model/user_role_enum.py b/bot/src/bot_data/model/user_role_enum.py similarity index 100% rename from kdb-bot/src/bot_data/model/user_role_enum.py rename to bot/src/bot_data/model/user_role_enum.py diff --git a/kdb-bot/src/bot_data/model/user_warnings.py b/bot/src/bot_data/model/user_warnings.py similarity index 95% rename from kdb-bot/src/bot_data/model/user_warnings.py rename to bot/src/bot_data/model/user_warnings.py index 99610a5f..bd1e290c 100644 --- a/kdb-bot/src/bot_data/model/user_warnings.py +++ b/bot/src/bot_data/model/user_warnings.py @@ -24,7 +24,9 @@ class UserWarnings(TableABC): TableABC.__init__(self) self._created_at = created_at if created_at is not None else self._created_at - self._modified_at = modified_at if modified_at is not None else self._modified_at + self._modified_at = ( + modified_at if modified_at is not None else self._modified_at + ) @property def id(self) -> int: diff --git a/kdb-bot/src/bot_data/model/user_warnings_history.py b/bot/src/bot_data/model/user_warnings_history.py similarity index 100% rename from kdb-bot/src/bot_data/model/user_warnings_history.py rename to bot/src/bot_data/model/user_warnings_history.py diff --git a/kdb-bot/src/bot_data/service/__init__.py b/bot/src/bot_data/service/__init__.py similarity index 100% rename from kdb-bot/src/bot_data/service/__init__.py rename to bot/src/bot_data/service/__init__.py diff --git a/kdb-bot/src/bot_data/service/achievements_repository_service.py b/bot/src/bot_data/service/achievements_repository_service.py similarity index 76% rename from kdb-bot/src/bot_data/service/achievements_repository_service.py rename to bot/src/bot_data/service/achievements_repository_service.py index b848fb5a..004a4a53 100644 --- a/kdb-bot/src/bot_data/service/achievements_repository_service.py +++ b/bot/src/bot_data/service/achievements_repository_service.py @@ -49,7 +49,9 @@ class AchievementRepositoryService(AchievementRepositoryABC): def get_achievements(self) -> List[Achievement]: achievements = List(Achievement) - self._logger.trace(__name__, f"Send SQL command: {Achievement.get_select_all_string()}") + self._logger.trace( + __name__, f"Send SQL command: {Achievement.get_select_all_string()}" + ) results = self._context.select(Achievement.get_select_all_string()) for result in results: self._logger.trace(__name__, f"Get user with id {result[0]}") @@ -58,15 +60,22 @@ class AchievementRepositoryService(AchievementRepositoryABC): return achievements def get_achievement_by_id(self, id: int) -> Achievement: - self._logger.trace(__name__, f"Send SQL command: {Achievement.get_select_by_id_string(id)}") + self._logger.trace( + __name__, f"Send SQL command: {Achievement.get_select_by_id_string(id)}" + ) result = self._context.select(Achievement.get_select_by_id_string(id))[0] return self._from_result(result) 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_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)) @@ -76,26 +85,38 @@ class AchievementRepositoryService(AchievementRepositoryABC): def get_achievements_by_user_id(self, user_id: int) -> List[Achievement]: achievements = List(Achievement) achievements_joins = List(UserGotAchievement) - self._logger.trace(__name__, f"Send SQL command: {UserGotAchievement.get_select_by_user_id_string(user_id)}") - results = self._context.select(UserGotAchievement.get_select_by_user_id_string(user_id)) + self._logger.trace( + __name__, + f"Send SQL command: {UserGotAchievement.get_select_by_user_id_string(user_id)}", + ) + results = self._context.select( + UserGotAchievement.get_select_by_user_id_string(user_id) + ) for result in results: self._logger.trace(__name__, f"Got UserGotAchievement with id {result[0]}") achievements_joins.append(self._join_from_result(result)) for achievements_join in achievements_joins: - results = self._context.select(Achievement.get_select_by_id_string(achievements_join.achievement.id)) + results = self._context.select( + Achievement.get_select_by_id_string(achievements_join.achievement.id) + ) for result in results: self._logger.trace(__name__, f"Got Achievement with id {result[0]}") achievements.append(self._from_result(result)) return achievements - def get_user_got_achievements_by_achievement_id(self, achievement_id: int) -> List[Achievement]: + def get_user_got_achievements_by_achievement_id( + self, achievement_id: int + ) -> List[Achievement]: achievements_joins = List(UserGotAchievement) self._logger.trace( - __name__, f"Send SQL command: {UserGotAchievement.get_select_by_achievement_id_string(achievement_id)}" + __name__, + f"Send SQL command: {UserGotAchievement.get_select_by_achievement_id_string(achievement_id)}", + ) + results = self._context.select( + UserGotAchievement.get_select_by_achievement_id_string(achievement_id) ) - results = self._context.select(UserGotAchievement.get_select_by_achievement_id_string(achievement_id)) for result in results: self._logger.trace(__name__, f"Got UserGotAchievement with id {result[0]}") achievements_joins.append(self._join_from_result(result)) diff --git a/kdb-bot/src/bot_data/service/api_key_repository_service.py b/bot/src/bot_data/service/api_key_repository_service.py similarity index 77% rename from kdb-bot/src/bot_data/service/api_key_repository_service.py rename to bot/src/bot_data/service/api_key_repository_service.py index d4f57dfc..dfa6f72e 100644 --- a/kdb-bot/src/bot_data/service/api_key_repository_service.py +++ b/bot/src/bot_data/service/api_key_repository_service.py @@ -45,7 +45,9 @@ class ApiKeyRepositoryService(ApiKeyRepositoryABC): def get_api_keys(self) -> List[ApiKey]: api_keys = List(ApiKey) - self._logger.trace(__name__, f"Send SQL command: {ApiKey.get_select_all_string()}") + self._logger.trace( + __name__, f"Send SQL command: {ApiKey.get_select_all_string()}" + ) results = self._context.select(ApiKey.get_select_all_string()) for result in results: api_keys.append(self._api_key_from_result(result)) @@ -53,16 +55,26 @@ class ApiKeyRepositoryService(ApiKeyRepositoryABC): return api_keys def get_api_key(self, identifier: str, key: str) -> ApiKey: - self._logger.trace(__name__, f"Send SQL command: {ApiKey.get_select_string(identifier, key)}") - return self._api_key_from_result(self._context.select(ApiKey.get_select_string(identifier, key))[0]) + self._logger.trace( + __name__, f"Send SQL command: {ApiKey.get_select_string(identifier, key)}" + ) + return self._api_key_from_result( + self._context.select(ApiKey.get_select_string(identifier, key))[0] + ) def get_api_key_by_id(self, id: int) -> ApiKey: self._logger.trace(__name__, f"Send SQL command: {ApiKey.get_select_by_id(id)}") - return self._api_key_from_result(self._context.select(ApiKey.get_select_by_id(id))[0]) + return self._api_key_from_result( + self._context.select(ApiKey.get_select_by_id(id))[0] + ) def get_api_key_by_key(self, key: str) -> ApiKey: - self._logger.trace(__name__, f"Send SQL command: {ApiKey.get_select_by_key(key)}") - return self._api_key_from_result(self._context.select(ApiKey.get_select_by_key(key))[0]) + self._logger.trace( + __name__, f"Send SQL command: {ApiKey.get_select_by_key(key)}" + ) + return self._api_key_from_result( + self._context.select(ApiKey.get_select_by_key(key))[0] + ) def add_api_key(self, api_key: ApiKey): self._logger.trace(__name__, f"Send SQL command: {api_key.insert_string}") diff --git a/kdb-bot/src/bot_data/service/auth_user_repository_service.py b/bot/src/bot_data/service/auth_user_repository_service.py similarity index 84% rename from kdb-bot/src/bot_data/service/auth_user_repository_service.py rename to bot/src/bot_data/service/auth_user_repository_service.py index 00afe7ae..1b959068 100644 --- a/kdb-bot/src/bot_data/service/auth_user_repository_service.py +++ b/bot/src/bot_data/service/auth_user_repository_service.py @@ -74,7 +74,9 @@ class AuthUserRepositoryService(AuthUserRepositoryABC): def get_all_auth_users(self) -> List[AuthUser]: users = List(AuthUser) - self._logger.trace(__name__, f"Send SQL command: {AuthUser.get_select_all_string()}") + self._logger.trace( + __name__, f"Send SQL command: {AuthUser.get_select_all_string()}" + ) results = self._context.select(AuthUser.get_select_all_string()) for result in results: self._logger.trace(__name__, f"Get auth user with id {result[0]}") @@ -82,22 +84,36 @@ class AuthUserRepositoryService(AuthUserRepositoryABC): return users - def get_filtered_auth_users(self, criteria: AuthUserSelectCriteria) -> FilteredResult: + def get_filtered_auth_users( + self, criteria: AuthUserSelectCriteria + ) -> FilteredResult: users = self.get_all_auth_users() - self._logger.trace(__name__, f"Send SQL command: {AuthUser.get_select_all_string()}") + self._logger.trace( + __name__, f"Send SQL command: {AuthUser.get_select_all_string()}" + ) query = users if criteria.first_name is not None and criteria.first_name != "": - query = query.where(lambda x: criteria.first_name in x.first_name or x.first_name == criteria.first_name) + query = query.where( + lambda x: criteria.first_name in x.first_name + or x.first_name == criteria.first_name + ) if criteria.last_name is not None and criteria.last_name != "": - query = query.where(lambda x: criteria.last_name in x.last_name or x.last_name == criteria.last_name) + query = query.where( + lambda x: criteria.last_name in x.last_name + or x.last_name == criteria.last_name + ) if criteria.email is not None and criteria.email != "": - query = query.where(lambda x: criteria.email in x.email or x.email == criteria.email) + query = query.where( + lambda x: criteria.email in x.email or x.email == criteria.email + ) if criteria.auth_role is not None: - query = query.where(lambda x: x.auth_role == AuthRoleEnum(criteria.auth_role)) + query = query.where( + lambda x: x.auth_role == AuthRoleEnum(criteria.auth_role) + ) # sort if ( @@ -128,12 +144,16 @@ class AuthUserRepositoryService(AuthUserRepositoryABC): return result def get_auth_user_by_email(self, email: str) -> AuthUser: - self._logger.trace(__name__, f"Send SQL command: {AuthUser.get_select_by_email_string(email)}") + self._logger.trace( + __name__, f"Send SQL command: {AuthUser.get_select_by_email_string(email)}" + ) result = self._context.select(AuthUser.get_select_by_email_string(email))[0] return self._user_from_result(result) def find_auth_user_by_email(self, email: str) -> Optional[AuthUser]: - self._logger.trace(__name__, f"Send SQL command: {AuthUser.get_select_by_email_string(email)}") + self._logger.trace( + __name__, f"Send SQL command: {AuthUser.get_select_by_email_string(email)}" + ) result = self._context.select(AuthUser.get_select_by_email_string(email)) if result is None or len(result) == 0: return None @@ -160,7 +180,9 @@ class AuthUserRepositoryService(AuthUserRepositoryABC): __name__, f"Send SQL command: {AuthUser.get_select_by_forgot_password_id_string(id)}", ) - result = self._context.select(AuthUser.get_select_by_forgot_password_id_string(id)) + result = self._context.select( + AuthUser.get_select_by_forgot_password_id_string(id) + ) if result is None or len(result) == 0: return None diff --git a/kdb-bot/src/bot_data/service/auto_role_repository_service.py b/bot/src/bot_data/service/auto_role_repository_service.py similarity index 59% rename from kdb-bot/src/bot_data/service/auto_role_repository_service.py rename to bot/src/bot_data/service/auto_role_repository_service.py index d1599341..e739962a 100644 --- a/kdb-bot/src/bot_data/service/auto_role_repository_service.py +++ b/bot/src/bot_data/service/auto_role_repository_service.py @@ -11,7 +11,12 @@ from bot_data.model.auto_role_rule import AutoRoleRule class AutoRoleRepositoryService(AutoRoleRepositoryABC): - def __init__(self, logger: DatabaseLogger, db_context: DatabaseContextABC, servers: ServerRepositoryABC): + def __init__( + self, + logger: DatabaseLogger, + db_context: DatabaseContextABC, + servers: ServerRepositoryABC, + ): self._logger = logger self._context = db_context self._servers = servers @@ -20,26 +25,42 @@ class AutoRoleRepositoryService(AutoRoleRepositoryABC): def get_auto_roles(self) -> List[AutoRole]: auto_roles = List(AutoRole) - self._logger.trace(__name__, f"Send SQL command: {AutoRole.get_select_all_string()}") + self._logger.trace( + __name__, f"Send SQL command: {AutoRole.get_select_all_string()}" + ) results = self._context.select(AutoRole.get_select_all_string()) for result in results: auto_roles.append( AutoRole( - self._servers.get_server_by_id(result[1]), result[2], result[3], result[4], result[5], id=result[0] + self._servers.get_server_by_id(result[1]), + result[2], + result[3], + result[4], + result[5], + id=result[0], ) ) return auto_roles def get_auto_role_by_id(self, id: int) -> AutoRole: - self._logger.trace(__name__, f"Send SQL command: {AutoRole.get_select_by_id_string(id)}") + self._logger.trace( + __name__, f"Send SQL command: {AutoRole.get_select_by_id_string(id)}" + ) result = self._context.select(AutoRole.get_select_by_id_string(id))[0] return AutoRole( - self._servers.get_server_by_id(result[1]), result[2], result[3], result[4], result[5], id=result[0] + self._servers.get_server_by_id(result[1]), + result[2], + result[3], + result[4], + result[5], + id=result[0], ) def find_auto_role_by_id(self, id: int) -> Optional[AutoRole]: - self._logger.trace(__name__, f"Send SQL command: {AutoRole.get_select_by_id_string(id)}") + self._logger.trace( + __name__, f"Send SQL command: {AutoRole.get_select_by_id_string(id)}" + ) result = self._context.select(AutoRole.get_select_by_id_string(id)) if result is None or len(result) == 0: return None @@ -47,17 +68,29 @@ class AutoRoleRepositoryService(AutoRoleRepositoryABC): result = result[0] return AutoRole( - self._servers.get_server_by_id(result[1]), result[2], result[3], result[4], result[5], id=result[0] + self._servers.get_server_by_id(result[1]), + result[2], + result[3], + result[4], + result[5], + id=result[0], ) def get_auto_roles_by_server_id(self, id: int) -> List[AutoRole]: - self._logger.trace(__name__, f"Send SQL command: {AutoRole.get_select_by_server_id_string(id)}") + self._logger.trace( + __name__, f"Send SQL command: {AutoRole.get_select_by_server_id_string(id)}" + ) auto_roles = List(AutoRole) results = self._context.select(AutoRole.get_select_by_server_id_string(id)) for result in results: auto_roles.append( AutoRole( - self._servers.get_server_by_id(result[1]), result[2], result[3], result[4], result[5], id=result[0] + self._servers.get_server_by_id(result[1]), + result[2], + result[3], + result[4], + result[5], + id=result[0], ) ) @@ -70,7 +103,12 @@ class AutoRoleRepositoryService(AutoRoleRepositoryABC): ) result = self._context.select(AutoRole.get_select_by_message_id_string(id))[0] return AutoRole( - self._servers.get_server_by_id(result[1]), result[2], result[3], result[4], result[5], id=result[0] + self._servers.get_server_by_id(result[1]), + result[2], + result[3], + result[4], + result[5], + id=result[0], ) def find_auto_role_by_message_id(self, id: int) -> Optional[AutoRole]: @@ -85,7 +123,12 @@ class AutoRoleRepositoryService(AutoRoleRepositoryABC): result = result[0] return AutoRole( - self._servers.get_server_by_id(result[1]), result[2], result[3], result[4], result[5], id=result[0] + self._servers.get_server_by_id(result[1]), + result[2], + result[3], + result[4], + result[5], + id=result[0], ) def add_auto_role(self, auto_role: AutoRole): @@ -102,22 +145,36 @@ class AutoRoleRepositoryService(AutoRoleRepositoryABC): def get_auto_role_rules(self) -> List[AutoRoleRule]: auto_role_rules = List(AutoRoleRule) - self._logger.trace(__name__, f"Send SQL command: {AutoRoleRule.get_select_all_string()}") + self._logger.trace( + __name__, f"Send SQL command: {AutoRoleRule.get_select_all_string()}" + ) results = self._context.select(AutoRoleRule.get_select_all_string()) for result in results: auto_role_rules.append( AutoRoleRule( - self.get_auto_role_by_id(result[1]), result[2], result[3], result[4], result[5], id=result[0] + self.get_auto_role_by_id(result[1]), + result[2], + result[3], + result[4], + result[5], + id=result[0], ) ) return auto_role_rules def get_auto_role_rule_by_id(self, id: int) -> AutoRoleRule: - self._logger.trace(__name__, f"Send SQL command: {AutoRoleRule.get_select_by_id_string(id)}") + self._logger.trace( + __name__, f"Send SQL command: {AutoRoleRule.get_select_by_id_string(id)}" + ) result = self._context.select(AutoRoleRule.get_select_by_id_string(id))[0] return AutoRoleRule( - self.get_auto_role_by_id(result[1]), result[2], result[3], result[4], result[5], id=result[0] + self.get_auto_role_by_id(result[1]), + result[2], + result[3], + result[4], + result[5], + id=result[0], ) def get_auto_role_rules_by_auto_role_id(self, id: int) -> List[AutoRoleRule]: @@ -126,24 +183,37 @@ class AutoRoleRepositoryService(AutoRoleRepositoryABC): __name__, f"Send SQL command: {AutoRoleRule.get_select_by_auto_role_id_string(id)}", ) - results = self._context.select(AutoRoleRule.get_select_by_auto_role_id_string(id)) + results = self._context.select( + AutoRoleRule.get_select_by_auto_role_id_string(id) + ) for result in results: auto_role_rules.append( AutoRoleRule( - self.get_auto_role_by_id(result[1]), result[2], result[3], result[4], result[5], id=result[0] + self.get_auto_role_by_id(result[1]), + result[2], + result[3], + result[4], + result[5], + id=result[0], ) ) return auto_role_rules def add_auto_role_rule(self, auto_role_rule: AutoRoleRule): - self._logger.trace(__name__, f"Send SQL command: {auto_role_rule.insert_string}") + self._logger.trace( + __name__, f"Send SQL command: {auto_role_rule.insert_string}" + ) self._context.cursor.execute(auto_role_rule.insert_string) def update_auto_role_rule(self, auto_role_rule: AutoRoleRule): - self._logger.trace(__name__, f"Send SQL command: {auto_role_rule.udpate_string}") + self._logger.trace( + __name__, f"Send SQL command: {auto_role_rule.udpate_string}" + ) self._context.cursor.execute(auto_role_rule.udpate_string) def delete_auto_role_rule(self, auto_role_rule: AutoRoleRule): - self._logger.trace(__name__, f"Send SQL command: {auto_role_rule.delete_string}") + self._logger.trace( + __name__, f"Send SQL command: {auto_role_rule.delete_string}" + ) self._context.cursor.execute(auto_role_rule.delete_string) diff --git a/kdb-bot/src/bot_data/service/cache_service.py b/bot/src/bot_data/service/cache_service.py similarity index 100% rename from kdb-bot/src/bot_data/service/cache_service.py rename to bot/src/bot_data/service/cache_service.py diff --git a/kdb-bot/src/bot_data/service/client_repository_service.py b/bot/src/bot_data/service/client_repository_service.py similarity index 89% rename from kdb-bot/src/bot_data/service/client_repository_service.py rename to bot/src/bot_data/service/client_repository_service.py index 587569a0..ce92d9ad 100644 --- a/kdb-bot/src/bot_data/service/client_repository_service.py +++ b/bot/src/bot_data/service/client_repository_service.py @@ -25,7 +25,9 @@ class ClientRepositoryService(ClientRepositoryABC): def get_clients(self) -> List[Client]: clients = List(Client) - self._logger.trace(__name__, f"Send SQL command: {Client.get_select_all_string()}") + self._logger.trace( + __name__, f"Send SQL command: {Client.get_select_all_string()}" + ) results = self._context.select(Client.get_select_all_string()) for result in results: self._logger.trace(__name__, f"Get client with id {result[0]}") @@ -47,7 +49,9 @@ class ClientRepositoryService(ClientRepositoryABC): return clients def get_client_by_id(self, client_id: int) -> Client: - self._logger.trace(__name__, f"Send SQL command: {Client.get_select_by_id_string(client_id)}") + self._logger.trace( + __name__, f"Send SQL command: {Client.get_select_by_id_string(client_id)}" + ) result = self._context.select(Client.get_select_by_id_string(client_id)) return Client( result[1], @@ -64,7 +68,10 @@ class ClientRepositoryService(ClientRepositoryABC): def get_clients_by_server_id(self, server_id: int) -> List[Client]: clients = List(Client) - self._logger.trace(__name__, f"Send SQL command: {Client.get_select_by_server_id_string(server_id)}") + self._logger.trace( + __name__, + f"Send SQL command: {Client.get_select_by_server_id_string(server_id)}", + ) results = self._context.select(Client.get_select_by_server_id_string(server_id)) for result in results: clients.append( @@ -89,7 +96,9 @@ class ClientRepositoryService(ClientRepositoryABC): __name__, f"Send SQL command: {Client.get_select_by_discord_id_string(discord_id)}", ) - result = self._context.select(Client.get_select_by_discord_id_string(discord_id))[0] + result = self._context.select( + Client.get_select_by_discord_id_string(discord_id) + )[0] return Client( result[1], result[2], @@ -108,7 +117,9 @@ class ClientRepositoryService(ClientRepositoryABC): __name__, f"Send SQL command: {Client.get_select_by_discord_id_string(discord_id)}", ) - result = self._context.select(Client.get_select_by_discord_id_string(discord_id)) + result = self._context.select( + Client.get_select_by_discord_id_string(discord_id) + ) if result is None or len(result) == 0: return None @@ -151,12 +162,16 @@ class ClientRepositoryService(ClientRepositoryABC): id=result[0], ) - def find_client_by_discord_id_and_server_id(self, discord_id: int, server_id: int) -> Optional[Client]: + def find_client_by_discord_id_and_server_id( + self, discord_id: int, server_id: int + ) -> Optional[Client]: self._logger.trace( __name__, f"Send SQL command: {Client.get_select_by_discord_id_and_server_id_string(discord_id, server_id)}", ) - result = self._context.select(Client.get_select_by_discord_id_and_server_id_string(discord_id, server_id)) + result = self._context.select( + Client.get_select_by_discord_id_and_server_id_string(discord_id, server_id) + ) if result is None or len(result) == 0: return None diff --git a/kdb-bot/src/bot_data/service/game_server_repository_service.py b/bot/src/bot_data/service/game_server_repository_service.py similarity index 93% rename from kdb-bot/src/bot_data/service/game_server_repository_service.py rename to bot/src/bot_data/service/game_server_repository_service.py index 1bdd0aeb..0a87b95e 100644 --- a/kdb-bot/src/bot_data/service/game_server_repository_service.py +++ b/bot/src/bot_data/service/game_server_repository_service.py @@ -42,7 +42,9 @@ class GameServerRepositoryService(GameServerRepositoryABC): ) results = self._context.select(GameServer.get_select_all_string()) for result in results: - self._logger.trace(__name__, f"Get user-joined-game-server with id {result[0]}") + self._logger.trace( + __name__, f"Get user-joined-game-server with id {result[0]}" + ) game_servers.append(self._from_result(result)) return game_servers @@ -55,7 +57,9 @@ class GameServerRepositoryService(GameServerRepositoryABC): ) results = self._context.select(GameServer.get_select_by_server_id_string(id)) for result in results: - self._logger.trace(__name__, f"Get user-joined-game-server with id {result[0]}") + self._logger.trace( + __name__, f"Get user-joined-game-server with id {result[0]}" + ) game_servers.append(self._from_result(result)) return game_servers diff --git a/kdb-bot/src/bot_data/service/known_user_repository_service.py b/bot/src/bot_data/service/known_user_repository_service.py similarity index 83% rename from kdb-bot/src/bot_data/service/known_user_repository_service.py rename to bot/src/bot_data/service/known_user_repository_service.py index b7dc57e2..5ef2d7c5 100644 --- a/kdb-bot/src/bot_data/service/known_user_repository_service.py +++ b/bot/src/bot_data/service/known_user_repository_service.py @@ -25,7 +25,9 @@ class KnownUserRepositoryService(KnownUserRepositoryABC): def get_users(self) -> List[KnownUser]: users = List(KnownUser) - self._logger.trace(__name__, f"Send SQL command: {KnownUser.get_select_all_string()}") + self._logger.trace( + __name__, f"Send SQL command: {KnownUser.get_select_all_string()}" + ) results = self._context.select(KnownUser.get_select_all_string()) for result in results: self._logger.trace(__name__, f"Get known_user with id {result[0]}") @@ -34,7 +36,9 @@ class KnownUserRepositoryService(KnownUserRepositoryABC): return users def get_user_by_id(self, id: int) -> KnownUser: - self._logger.trace(__name__, f"Send SQL command: {KnownUser.get_select_by_id_string(id)}") + self._logger.trace( + __name__, f"Send SQL command: {KnownUser.get_select_by_id_string(id)}" + ) result = self._context.select(KnownUser.get_select_by_id_string(id)) return KnownUser(result[1], result[2], result[3], id=result[0]) @@ -43,7 +47,9 @@ class KnownUserRepositoryService(KnownUserRepositoryABC): __name__, f"Send SQL command: {KnownUser.get_select_by_discord_id_string(discord_id)}", ) - result = self._context.select(KnownUser.get_select_by_discord_id_string(discord_id))[0] + result = self._context.select( + KnownUser.get_select_by_discord_id_string(discord_id) + )[0] return KnownUser(result[1], result[2], result[3], id=result[0]) def find_user_by_discord_id(self, discord_id: int) -> Optional[KnownUser]: @@ -51,7 +57,9 @@ class KnownUserRepositoryService(KnownUserRepositoryABC): __name__, f"Send SQL command: {KnownUser.get_select_by_discord_id_string(discord_id)}", ) - result = self._context.select(KnownUser.get_select_by_discord_id_string(discord_id)) + result = self._context.select( + KnownUser.get_select_by_discord_id_string(discord_id) + ) if result is None or len(result) == 0: return None diff --git a/kdb-bot/src/bot_data/service/level_repository_service.py b/bot/src/bot_data/service/level_repository_service.py similarity index 91% rename from kdb-bot/src/bot_data/service/level_repository_service.py rename to bot/src/bot_data/service/level_repository_service.py index c713c0da..e7828104 100644 --- a/kdb-bot/src/bot_data/service/level_repository_service.py +++ b/bot/src/bot_data/service/level_repository_service.py @@ -42,7 +42,9 @@ class LevelRepositoryService(LevelRepositoryABC): def get_levels(self) -> List[Level]: levels = List(Level) - self._logger.trace(__name__, f"Send SQL command: {Level.get_select_all_string()}") + self._logger.trace( + __name__, f"Send SQL command: {Level.get_select_all_string()}" + ) results = self._context.select(Level.get_select_all_string()) for result in results: self._logger.trace(__name__, f"Get level with id {result[0]}") @@ -51,13 +53,17 @@ class LevelRepositoryService(LevelRepositoryABC): return levels def get_level_by_id(self, id: int) -> Level: - self._logger.trace(__name__, f"Send SQL command: {Level.get_select_by_id_string(id)}") + self._logger.trace( + __name__, f"Send SQL command: {Level.get_select_by_id_string(id)}" + ) result = self._context.select(Level.get_select_by_id_string(id))[0] return self._level_from_result(result) def find_level_by_id(self, id: int) -> Optional[Level]: - self._logger.trace(__name__, f"Send SQL command: {Level.get_select_by_id_string(id)}") + self._logger.trace( + __name__, f"Send SQL command: {Level.get_select_by_id_string(id)}" + ) result = self._context.select(Level.get_select_by_id_string(id)) if result is None or len(result) == 0: return None diff --git a/kdb-bot/src/bot_data/service/migration_service.py b/bot/src/bot_data/service/migration_service.py similarity index 78% rename from kdb-bot/src/bot_data/service/migration_service.py rename to bot/src/bot_data/service/migration_service.py index dc6436a7..cf6303e9 100644 --- a/kdb-bot/src/bot_data/service/migration_service.py +++ b/bot/src/bot_data/service/migration_service.py @@ -21,7 +21,9 @@ class MigrationService: self._cursor = db.cursor self._migrations: List[MigrationABC] = ( - List(type, MigrationABC.__subclasses__()).order_by(lambda x: x.name).order_by(lambda x: x.prio) + List(type, MigrationABC.__subclasses__()) + .order_by(lambda x: x.name) + .order_by(lambda x: x.prio) ) def migrate(self): @@ -38,15 +40,21 @@ class MigrationService: __name__, f"Running SQL Command: {MigrationHistory.get_select_by_id_string(migration_id)}", ) - migration_from_db = self._db.select(MigrationHistory.get_select_by_id_string(migration_id)) + migration_from_db = self._db.select( + MigrationHistory.get_select_by_id_string(migration_id) + ) if migration_from_db is not None and len(migration_from_db) > 0: continue self._logger.debug(__name__, f"Running Migration {migration_id}") - migration_as_service: MigrationABC = self._services.get_service(migration) + migration_as_service: MigrationABC = self._services.get_service( + migration + ) migration_as_service.upgrade() self._cursor.execute(MigrationHistory(migration_id).insert_string) self._db.save_changes() except Exception as e: - self._logger.error(__name__, f"Cannot get migration with id {migration}", e) + self._logger.error( + __name__, f"Cannot get migration with id {migration}", e + ) diff --git a/kdb-bot/src/bot_data/service/seeder_service.py b/bot/src/bot_data/service/seeder_service.py similarity index 100% rename from kdb-bot/src/bot_data/service/seeder_service.py rename to bot/src/bot_data/service/seeder_service.py diff --git a/kdb-bot/src/bot_data/service/server_config_repository_service.py b/bot/src/bot_data/service/server_config_repository_service.py similarity index 54% rename from kdb-bot/src/bot_data/service/server_config_repository_service.py rename to bot/src/bot_data/service/server_config_repository_service.py index 302a5752..9ff8bf10 100644 --- a/kdb-bot/src/bot_data/service/server_config_repository_service.py +++ b/bot/src/bot_data/service/server_config_repository_service.py @@ -13,7 +13,12 @@ from bot_data.model.team_member_type_enum import TeamMemberTypeEnum class ServerConfigRepositoryService(ServerConfigRepositoryABC): - def __init__(self, logger: DatabaseLogger, db_context: DatabaseContextABC, servers: ServerRepositoryABC): + def __init__( + self, + logger: DatabaseLogger, + db_context: DatabaseContextABC, + servers: ServerRepositoryABC, + ): ServerConfigRepositoryABC.__init__(self) self._logger = logger @@ -23,14 +28,24 @@ class ServerConfigRepositoryService(ServerConfigRepositoryABC): def _get_team_role_ids(self, server_id: int) -> List[ServerTeamRoleIdsConfig]: ids = List(ServerTeamRoleIdsConfig) self._logger.trace( - __name__, f"Send SQL command: {ServerTeamRoleIdsConfig.get_select_by_server_id_string(server_id)}" + __name__, + f"Send SQL command: {ServerTeamRoleIdsConfig.get_select_by_server_id_string(server_id)}", + ) + results = self._context.select( + ServerTeamRoleIdsConfig.get_select_by_server_id_string(server_id) ) - results = self._context.select(ServerTeamRoleIdsConfig.get_select_by_server_id_string(server_id)) for result in results: - self._logger.trace(__name__, f"Got ServerTeamRoleIdsConfig with id {result[0]}") + self._logger.trace( + __name__, f"Got ServerTeamRoleIdsConfig with id {result[0]}" + ) ids.append( ServerTeamRoleIdsConfig( - result[1], TeamMemberTypeEnum(result[2]), result[3], result[4], result[5], id=result[0] + result[1], + TeamMemberTypeEnum(result[2]), + result[3], + result[4], + result[5], + id=result[0], ) ) @@ -42,9 +57,13 @@ class ServerConfigRepositoryService(ServerConfigRepositoryABC): __name__, f"Send SQL command: {ServerAFKChannelIdsConfig.get_select_by_server_id_string(server_id)}", ) - results = self._context.select(ServerAFKChannelIdsConfig.get_select_by_server_id_string(server_id)) + results = self._context.select( + ServerAFKChannelIdsConfig.get_select_by_server_id_string(server_id) + ) for result in results: - self._logger.trace(__name__, f"Got ServerAFKChannelIdsConfig with id {result[0]}") + self._logger.trace( + __name__, f"Got ServerAFKChannelIdsConfig with id {result[0]}" + ) urls.append(result[1]) return urls @@ -78,20 +97,35 @@ class ServerConfigRepositoryService(ServerConfigRepositoryABC): ) 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_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_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_server_id_string(server_id)}", + ) + result = self._context.select( + ServerConfig.get_select_by_server_id_string(server_id) + )[0] return self._from_result(result) def get_server_config_by_id(self, config_id: int) -> ServerConfig: - self._logger.trace(__name__, f"Send SQL command: {ServerConfig.get_select_by_id_string(config_id)}") - result = self._context.select(ServerConfig.get_select_by_id_string(config_id))[0] + self._logger.trace( + __name__, + f"Send SQL command: {ServerConfig.get_select_by_id_string(config_id)}", + ) + result = self._context.select(ServerConfig.get_select_by_id_string(config_id))[ + 0 + ] return self._from_result(result) @@ -107,26 +141,50 @@ class ServerConfigRepositoryService(ServerConfigRepositoryABC): self._logger.trace(__name__, f"Send SQL command: {server_config.delete_string}") self._context.cursor.execute(server_config.delete_string) - def add_server_team_role_id_config(self, server_team_role_id: ServerTeamRoleIdsConfig): - self._logger.trace(__name__, f"Send SQL command: {server_team_role_id.insert_string}") + def add_server_team_role_id_config( + self, server_team_role_id: ServerTeamRoleIdsConfig + ): + self._logger.trace( + __name__, f"Send SQL command: {server_team_role_id.insert_string}" + ) self._context.cursor.execute(server_team_role_id.insert_string) - def update_server_team_role_id_config(self, server_team_role_id: ServerTeamRoleIdsConfig): - self._logger.trace(__name__, f"Send SQL command: {server_team_role_id.udpate_string}") + def update_server_team_role_id_config( + self, server_team_role_id: ServerTeamRoleIdsConfig + ): + self._logger.trace( + __name__, f"Send SQL command: {server_team_role_id.udpate_string}" + ) self._context.cursor.execute(server_team_role_id.udpate_string) - def delete_server_team_role_id_config(self, server_team_role_id: ServerTeamRoleIdsConfig): - self._logger.trace(__name__, f"Send SQL command: {server_team_role_id.delete_string}") + def delete_server_team_role_id_config( + self, server_team_role_id: ServerTeamRoleIdsConfig + ): + self._logger.trace( + __name__, f"Send SQL command: {server_team_role_id.delete_string}" + ) self._context.cursor.execute(server_team_role_id.delete_string) - def add_server_afk_channel_config(self, server_afk_channel: ServerAFKChannelIdsConfig): - self._logger.trace(__name__, f"Send SQL command: {server_afk_channel.insert_string}") + def add_server_afk_channel_config( + self, server_afk_channel: ServerAFKChannelIdsConfig + ): + self._logger.trace( + __name__, f"Send SQL command: {server_afk_channel.insert_string}" + ) self._context.cursor.execute(server_afk_channel.insert_string) - def update_server_afk_channel_config(self, server_afk_channel: ServerAFKChannelIdsConfig): - self._logger.trace(__name__, f"Send SQL command: {server_afk_channel.udpate_string}") + def update_server_afk_channel_config( + self, server_afk_channel: ServerAFKChannelIdsConfig + ): + self._logger.trace( + __name__, f"Send SQL command: {server_afk_channel.udpate_string}" + ) self._context.cursor.execute(server_afk_channel.udpate_string) - def delete_server_afk_channel_config(self, server_afk_channel: ServerAFKChannelIdsConfig): - self._logger.trace(__name__, f"Send SQL command: {server_afk_channel.delete_string}") + def delete_server_afk_channel_config( + self, server_afk_channel: ServerAFKChannelIdsConfig + ): + self._logger.trace( + __name__, f"Send SQL command: {server_afk_channel.delete_string}" + ) self._context.cursor.execute(server_afk_channel.delete_string) diff --git a/kdb-bot/src/bot_data/service/server_config_seeder.py b/bot/src/bot_data/service/server_config_seeder.py similarity index 100% rename from kdb-bot/src/bot_data/service/server_config_seeder.py rename to bot/src/bot_data/service/server_config_seeder.py diff --git a/kdb-bot/src/bot_data/service/server_repository_service.py b/bot/src/bot_data/service/server_repository_service.py similarity index 74% rename from kdb-bot/src/bot_data/service/server_repository_service.py rename to bot/src/bot_data/service/server_repository_service.py index 924cc036..43f54c3d 100644 --- a/kdb-bot/src/bot_data/service/server_repository_service.py +++ b/bot/src/bot_data/service/server_repository_service.py @@ -12,7 +12,12 @@ from bot_data.service.cache_service import CacheService class ServerRepositoryService(ServerRepositoryABC): - def __init__(self, logger: DatabaseLogger, db_context: DatabaseContextABC, cache: CacheService): + def __init__( + self, + logger: DatabaseLogger, + db_context: DatabaseContextABC, + cache: CacheService, + ): self._logger = logger self._context = db_context self._cache = cache @@ -21,7 +26,9 @@ class ServerRepositoryService(ServerRepositoryABC): def get_servers(self) -> List[Server]: servers = List(Server) - self._logger.trace(__name__, f"Send SQL command: {Server.get_select_all_string()}") + self._logger.trace( + __name__, f"Send SQL command: {Server.get_select_all_string()}" + ) results = self._context.select(Server.get_select_all_string()) for result in results: servers.append(Server(result[1], result[2], result[3], id=result[0])) @@ -31,7 +38,9 @@ class ServerRepositoryService(ServerRepositoryABC): def get_filtered_servers(self, criteria: ServerSelectCriteria) -> FilteredResult: servers = self.get_servers() - self._logger.trace(__name__, f"Send SQL command: {Server.get_select_all_string()}") + self._logger.trace( + __name__, f"Send SQL command: {Server.get_select_all_string()}" + ) query = servers # sort @@ -43,7 +52,9 @@ class ServerRepositoryService(ServerRepositoryABC): ): 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) + ) else: query = query.order_by(lambda x: getattr(x, criteria.sort_column)) @@ -55,19 +66,25 @@ class ServerRepositoryService(ServerRepositoryABC): return result def get_server_by_id(self, server_id: int) -> Server: - cs = self._cache.cached_server.where(lambda x: x.id == server_id).single_or_default() + cs = self._cache.cached_server.where( + lambda x: x.id == server_id + ).single_or_default() if cs is not None: return cs - self._logger.trace(__name__, f"Send SQL command: {Server.get_select_by_id_string(server_id)}") + self._logger.trace( + __name__, f"Send SQL command: {Server.get_select_by_id_string(server_id)}" + ) result = self._context.select(Server.get_select_by_id_string(server_id))[0] server = Server(result[1], result[2], result[3], id=result[0]) self._cache.add_server(server) return server def get_server_by_discord_id(self, discord_id: int) -> Server: - cs = self._cache.cached_server.where(lambda x: x.discord_id == discord_id).single_or_default() + cs = self._cache.cached_server.where( + lambda x: x.discord_id == discord_id + ).single_or_default() if cs is not None: return cs @@ -75,11 +92,15 @@ class ServerRepositoryService(ServerRepositoryABC): __name__, f"Send SQL command: {Server.get_select_by_discord_id_string(discord_id)}", ) - result = self._context.select(Server.get_select_by_discord_id_string(discord_id))[0] + result = self._context.select( + Server.get_select_by_discord_id_string(discord_id) + )[0] return Server(result[1], result[2], result[3], id=result[0]) def find_server_by_discord_id(self, discord_id: int) -> Optional[Server]: - cs = self._cache.cached_server.where(lambda x: x.discord_id == discord_id).single_or_default() + cs = self._cache.cached_server.where( + lambda x: x.discord_id == discord_id + ).single_or_default() if cs is not None: return cs @@ -87,7 +108,9 @@ class ServerRepositoryService(ServerRepositoryABC): __name__, f"Send SQL command: {Server.get_select_by_discord_id_string(discord_id)}", ) - result = self._context.select(Server.get_select_by_discord_id_string(discord_id)) + result = self._context.select( + Server.get_select_by_discord_id_string(discord_id) + ) if result is None or len(result) == 0: return None diff --git a/kdb-bot/src/bot_data/service/short_role_name_repository_service.py b/bot/src/bot_data/service/short_role_name_repository_service.py similarity index 76% rename from kdb-bot/src/bot_data/service/short_role_name_repository_service.py rename to bot/src/bot_data/service/short_role_name_repository_service.py index fa65077e..5b6a929e 100644 --- a/kdb-bot/src/bot_data/service/short_role_name_repository_service.py +++ b/bot/src/bot_data/service/short_role_name_repository_service.py @@ -35,7 +35,9 @@ class ShortRoleNameRepositoryService(ShortRoleNameRepositoryABC): return ShortRoleName( self._get_value_from_result(sql_result[1]), # name int(self._get_value_from_result(sql_result[2])), # role_id - ShortRoleNamePositionEnum(self._get_value_from_result(sql_result[3])), # position + ShortRoleNamePositionEnum( + self._get_value_from_result(sql_result[3]) + ), # position self._servers.get_server_by_id(sql_result[4]), # server self._get_value_from_result(sql_result[5]), # created_at self._get_value_from_result(sql_result[6]), # modified_at @@ -44,7 +46,9 @@ class ShortRoleNameRepositoryService(ShortRoleNameRepositoryABC): def get_short_role_names(self) -> List[ShortRoleName]: short_role_names = List(ShortRoleName) - self._logger.trace(__name__, f"Send SQL command: {ShortRoleName.get_select_all_string()}") + self._logger.trace( + __name__, f"Send SQL command: {ShortRoleName.get_select_all_string()}" + ) results = self._context.select(ShortRoleName.get_select_all_string()) for result in results: self._logger.trace(__name__, f"Get short_role_name with id {result[0]}") @@ -53,15 +57,22 @@ class ShortRoleNameRepositoryService(ShortRoleNameRepositoryABC): return short_role_names def get_short_role_name_by_id(self, id: int) -> ShortRoleName: - self._logger.trace(__name__, f"Send SQL command: {ShortRoleName.get_select_by_id_string(id)}") + self._logger.trace( + __name__, f"Send SQL command: {ShortRoleName.get_select_by_id_string(id)}" + ) result = self._context.select(ShortRoleName.get_select_by_id_string(id))[0] return self._short_role_name_from_result(result) def find_short_role_names_by_role_id(self, role_id: int) -> List[ShortRoleName]: short_role_names = List(ShortRoleName) - self._logger.trace(__name__, f"Send SQL command: {ShortRoleName.get_select_by_role_id_string(role_id)}") - results = self._context.select(ShortRoleName.get_select_by_role_id_string(role_id)) + self._logger.trace( + __name__, + f"Send SQL command: {ShortRoleName.get_select_by_role_id_string(role_id)}", + ) + results = self._context.select( + ShortRoleName.get_select_by_role_id_string(role_id) + ) for result in results: self._logger.trace(__name__, f"Get short_role_name with id {result[0]}") short_role_names.append(self._short_role_name_from_result(result)) @@ -74,7 +85,9 @@ class ShortRoleNameRepositoryService(ShortRoleNameRepositoryABC): __name__, f"Send SQL command: {ShortRoleName.get_select_by_server_id_string(server_id)}", ) - results = self._context.select(ShortRoleName.get_select_by_server_id_string(server_id)) + results = self._context.select( + ShortRoleName.get_select_by_server_id_string(server_id) + ) for result in results: self._logger.trace(__name__, f"Get short_role_name with id {result[0]}") @@ -83,13 +96,19 @@ class ShortRoleNameRepositoryService(ShortRoleNameRepositoryABC): return short_role_names def add_short_role_name(self, short_role_name: ShortRoleName): - self._logger.trace(__name__, f"Send SQL command: {short_role_name.insert_string}") + self._logger.trace( + __name__, f"Send SQL command: {short_role_name.insert_string}" + ) self._context.cursor.execute(short_role_name.insert_string) def update_short_role_name(self, short_role_name: ShortRoleName): - self._logger.trace(__name__, f"Send SQL command: {short_role_name.udpate_string}") + self._logger.trace( + __name__, f"Send SQL command: {short_role_name.udpate_string}" + ) self._context.cursor.execute(short_role_name.udpate_string) def delete_short_role_name(self, short_role_name: ShortRoleName): - self._logger.trace(__name__, f"Send SQL command: {short_role_name.delete_string}") + self._logger.trace( + __name__, f"Send SQL command: {short_role_name.delete_string}" + ) self._context.cursor.execute(short_role_name.delete_string) diff --git a/kdb-bot/src/bot_data/service/steam_special_offer_repository_service.py b/bot/src/bot_data/service/steam_special_offer_repository_service.py similarity index 74% rename from kdb-bot/src/bot_data/service/steam_special_offer_repository_service.py rename to bot/src/bot_data/service/steam_special_offer_repository_service.py index 94ee702d..256f01b2 100644 --- a/kdb-bot/src/bot_data/service/steam_special_offer_repository_service.py +++ b/bot/src/bot_data/service/steam_special_offer_repository_service.py @@ -5,7 +5,9 @@ from cpl_query.extension import List from bot_core.logging.database_logger import DatabaseLogger from bot_data.abc.server_repository_abc import ServerRepositoryABC -from bot_data.abc.steam_special_offer_repository_abc import SteamSpecialOfferRepositoryABC +from bot_data.abc.steam_special_offer_repository_abc import ( + SteamSpecialOfferRepositoryABC, +) from bot_data.model.steam_special_offer import SteamSpecialOffer @@ -41,7 +43,9 @@ class SteamSpecialOfferRepositoryService(SteamSpecialOfferRepositoryABC): def get_steam_special_offers(self) -> List[SteamSpecialOffer]: steam_special_offers = List(SteamSpecialOffer) - self._logger.trace(__name__, f"Send SQL command: {SteamSpecialOffer.get_select_all_string()}") + self._logger.trace( + __name__, f"Send SQL command: {SteamSpecialOffer.get_select_all_string()}" + ) results = self._context.select(SteamSpecialOffer.get_select_all_string()) for result in results: self._logger.trace(__name__, f"Get steam_special_offer with id {result[0]}") @@ -50,19 +54,30 @@ class SteamSpecialOfferRepositoryService(SteamSpecialOfferRepositoryABC): return steam_special_offers def get_steam_special_offer_by_name(self, name: str) -> SteamSpecialOffer: - self._logger.trace(__name__, f"Send SQL command: {SteamSpecialOffer.get_select_by_name_string(name)}") - result = self._context.select(SteamSpecialOffer.get_select_by_name_string(name))[0] + self._logger.trace( + __name__, + f"Send SQL command: {SteamSpecialOffer.get_select_by_name_string(name)}", + ) + result = self._context.select( + SteamSpecialOffer.get_select_by_name_string(name) + )[0] return self._steam_special_offer_from_result(result) def add_steam_special_offer(self, steam_special_offer: SteamSpecialOffer): - self._logger.trace(__name__, f"Send SQL command: {steam_special_offer.insert_string}") + self._logger.trace( + __name__, f"Send SQL command: {steam_special_offer.insert_string}" + ) self._context.cursor.execute(steam_special_offer.insert_string) def update_steam_special_offer(self, steam_special_offer: SteamSpecialOffer): - self._logger.trace(__name__, f"Send SQL command: {steam_special_offer.udpate_string}") + self._logger.trace( + __name__, f"Send SQL command: {steam_special_offer.udpate_string}" + ) self._context.cursor.execute(steam_special_offer.udpate_string) def delete_steam_special_offer(self, steam_special_offer: SteamSpecialOffer): - self._logger.trace(__name__, f"Send SQL command: {steam_special_offer.delete_string}") + self._logger.trace( + __name__, f"Send SQL command: {steam_special_offer.delete_string}" + ) self._context.cursor.execute(steam_special_offer.delete_string) diff --git a/kdb-bot/src/bot_data/service/technician_config_repository_service.py b/bot/src/bot_data/service/technician_config_repository_service.py similarity index 69% rename from kdb-bot/src/bot_data/service/technician_config_repository_service.py rename to bot/src/bot_data/service/technician_config_repository_service.py index fe32eded..3d31b415 100644 --- a/kdb-bot/src/bot_data/service/technician_config_repository_service.py +++ b/bot/src/bot_data/service/technician_config_repository_service.py @@ -19,7 +19,9 @@ class TechnicianConfigRepositoryService(TechnicianConfigRepositoryABC): def _get_technician_ids(self) -> List[int]: ids = List(int) - self._logger.trace(__name__, f"Send SQL command: {TechnicianIdConfig.get_select_all_string()}") + self._logger.trace( + __name__, f"Send SQL command: {TechnicianIdConfig.get_select_all_string()}" + ) results = self._context.select(TechnicianIdConfig.get_select_all_string()) for result in results: self._logger.trace(__name__, f"Got TechnicianId with id {result[0]}") @@ -29,7 +31,10 @@ class TechnicianConfigRepositoryService(TechnicianConfigRepositoryABC): def _get_technician_ping_urls(self) -> List[str]: urls = List(str) - self._logger.trace(__name__, f"Send SQL command: {TechnicianPingUrlConfig.get_select_all_string()}") + self._logger.trace( + __name__, + f"Send SQL command: {TechnicianPingUrlConfig.get_select_all_string()}", + ) results = self._context.select(TechnicianPingUrlConfig.get_select_all_string()) for result in results: self._logger.trace(__name__, f"Got TechnicianPingUrl with id {result[0]}") @@ -52,27 +57,37 @@ class TechnicianConfigRepositoryService(TechnicianConfigRepositoryABC): ) def does_technician_config_exists(self) -> bool: - self._logger.trace(__name__, f"Send SQL command: {TechnicianConfig.get_select_all_string()}") + self._logger.trace( + __name__, f"Send SQL command: {TechnicianConfig.get_select_all_string()}" + ) result = self._context.select(TechnicianConfig.get_select_all_string()) return len(result) > 0 def get_technician_config(self) -> TechnicianConfig: - self._logger.trace(__name__, f"Send SQL command: {TechnicianConfig.get_select_all_string()}") + self._logger.trace( + __name__, f"Send SQL command: {TechnicianConfig.get_select_all_string()}" + ) result = self._context.select(TechnicianConfig.get_select_all_string())[0] return self._from_result(result) def add_technician_config(self, technician_config: TechnicianConfig): - self._logger.trace(__name__, f"Send SQL command: {technician_config.insert_string}") + self._logger.trace( + __name__, f"Send SQL command: {technician_config.insert_string}" + ) self._context.cursor.execute(technician_config.insert_string) def update_technician_config(self, technician_config: TechnicianConfig): - self._logger.trace(__name__, f"Send SQL command: {technician_config.udpate_string}") + self._logger.trace( + __name__, f"Send SQL command: {technician_config.udpate_string}" + ) self._context.cursor.execute(technician_config.udpate_string) def delete_technician_config(self, technician_config: TechnicianConfig): - self._logger.trace(__name__, f"Send SQL command: {technician_config.delete_string}") + self._logger.trace( + __name__, f"Send SQL command: {technician_config.delete_string}" + ) self._context.cursor.execute(technician_config.delete_string) def add_technician_id_config(self, technician_id: TechnicianIdConfig): @@ -87,14 +102,26 @@ class TechnicianConfigRepositoryService(TechnicianConfigRepositoryABC): self._logger.trace(__name__, f"Send SQL command: {technician_id.delete_string}") self._context.cursor.execute(technician_id.delete_string) - def add_technician_ping_url_config(self, technician_ping_url: TechnicianPingUrlConfig): - self._logger.trace(__name__, f"Send SQL command: {technician_ping_url.insert_string}") + def add_technician_ping_url_config( + self, technician_ping_url: TechnicianPingUrlConfig + ): + self._logger.trace( + __name__, f"Send SQL command: {technician_ping_url.insert_string}" + ) self._context.cursor.execute(technician_ping_url.insert_string) - def update_technician_ping_url_config(self, technician_ping_url: TechnicianPingUrlConfig): - self._logger.trace(__name__, f"Send SQL command: {technician_ping_url.udpate_string}") + def update_technician_ping_url_config( + self, technician_ping_url: TechnicianPingUrlConfig + ): + self._logger.trace( + __name__, f"Send SQL command: {technician_ping_url.udpate_string}" + ) self._context.cursor.execute(technician_ping_url.udpate_string) - def delete_technician_ping_url_config(self, technician_ping_url: TechnicianPingUrlConfig): - self._logger.trace(__name__, f"Send SQL command: {technician_ping_url.delete_string}") + def delete_technician_ping_url_config( + self, technician_ping_url: TechnicianPingUrlConfig + ): + self._logger.trace( + __name__, f"Send SQL command: {technician_ping_url.delete_string}" + ) self._context.cursor.execute(technician_ping_url.delete_string) diff --git a/kdb-bot/src/bot_data/service/technician_config_seeder.py b/bot/src/bot_data/service/technician_config_seeder.py similarity index 85% rename from kdb-bot/src/bot_data/service/technician_config_seeder.py rename to bot/src/bot_data/service/technician_config_seeder.py index 209b3e02..09dfd3bc 100644 --- a/kdb-bot/src/bot_data/service/technician_config_seeder.py +++ b/bot/src/bot_data/service/technician_config_seeder.py @@ -34,15 +34,22 @@ class TechnicianConfigSeeder(DataSeederABC): 1000000, {}, List(int, [240160344557879316]), - List(str, ["www.google.com", "www.sh-edraft.de", "www.keksdose-gaming.de"]), + List( + str, + ["www.google.com", "www.sh-edraft.de", "www.keksdose-gaming.de"], + ), ) self._technician_config.add_technician_config(config) for technician in config.technician_ids: - self._technician_config.add_technician_id_config(TechnicianIdConfig(technician)) + self._technician_config.add_technician_id_config( + TechnicianIdConfig(technician) + ) for url in config.ping_urls: - self._technician_config.add_technician_ping_url_config(TechnicianPingUrlConfig(url)) + self._technician_config.add_technician_ping_url_config( + TechnicianPingUrlConfig(url) + ) self._db.save_changes() self._logger.debug(__name__, "Seeded technician config") diff --git a/kdb-bot/src/bot_data/service/user_game_ident_repository_service.py b/bot/src/bot_data/service/user_game_ident_repository_service.py similarity index 85% rename from kdb-bot/src/bot_data/service/user_game_ident_repository_service.py rename to bot/src/bot_data/service/user_game_ident_repository_service.py index d0dfc38b..0039d85e 100644 --- a/kdb-bot/src/bot_data/service/user_game_ident_repository_service.py +++ b/bot/src/bot_data/service/user_game_ident_repository_service.py @@ -51,13 +51,17 @@ class UserGameIdentRepositoryService(UserGameIdentRepositoryABC): return joins - def get_user_game_idents_by_game_server_id(self, game_server_id: int) -> List[UserGameIdent]: + def get_user_game_idents_by_game_server_id( + self, game_server_id: int + ) -> List[UserGameIdent]: joins = List(UserGameIdent) self._logger.trace( __name__, f"Send SQL command: {UserGameIdent.get_select_by_game_server_id_string(game_server_id)}", ) - results = self._context.select(UserGameIdent.get_select_by_game_server_id_string(game_server_id)) + results = self._context.select( + UserGameIdent.get_select_by_game_server_id_string(game_server_id) + ) for result in results: self._logger.trace(__name__, f"Get UserGameIdent with id {result[0]}") joins.append(self._from_result(result)) @@ -77,7 +81,9 @@ class UserGameIdentRepositoryService(UserGameIdentRepositoryABC): __name__, f"Send SQL command: {UserGameIdent.get_select_by_ident_string(ident)}", ) - result = self._context.select(UserGameIdent.get_select_by_ident_string(ident))[0] + result = self._context.select(UserGameIdent.get_select_by_ident_string(ident))[ + 0 + ] return self._from_result(result) def find_user_game_ident_by_ident(self, ident: str) -> Optional[UserGameIdent]: @@ -98,22 +104,30 @@ class UserGameIdentRepositoryService(UserGameIdentRepositoryABC): __name__, f"Send SQL command: {UserGameIdent.get_select_by_user_id_string(user_id)}", ) - results = self._context.select(UserGameIdent.get_select_by_user_id_string(user_id)) + results = self._context.select( + UserGameIdent.get_select_by_user_id_string(user_id) + ) for result in results: joins.append(self._from_result(result)) return joins def add_user_game_ident(self, user_game_ident: UserGameIdent): - self._logger.trace(__name__, f"Send SQL command: {user_game_ident.insert_string}") + self._logger.trace( + __name__, f"Send SQL command: {user_game_ident.insert_string}" + ) self._context.cursor.execute(user_game_ident.insert_string) def update_user_game_ident(self, user_game_ident: UserGameIdent): - self._logger.trace(__name__, f"Send SQL command: {user_game_ident.udpate_string}") + self._logger.trace( + __name__, f"Send SQL command: {user_game_ident.udpate_string}" + ) self._context.cursor.execute(user_game_ident.udpate_string) def delete_user_game_ident(self, user_game_ident: UserGameIdent): - self._logger.trace(__name__, f"Send SQL command: {user_game_ident.delete_string}") + self._logger.trace( + __name__, f"Send SQL command: {user_game_ident.delete_string}" + ) self._context.cursor.execute(user_game_ident.delete_string) def delete_user_game_ident_by_user_id(self, user_id: int): diff --git a/kdb-bot/src/bot_data/service/user_joined_game_server_repository_service.py b/bot/src/bot_data/service/user_joined_game_server_repository_service.py similarity index 65% rename from kdb-bot/src/bot_data/service/user_joined_game_server_repository_service.py rename to bot/src/bot_data/service/user_joined_game_server_repository_service.py index e9ded8ba..5f1a3627 100644 --- a/kdb-bot/src/bot_data/service/user_joined_game_server_repository_service.py +++ b/bot/src/bot_data/service/user_joined_game_server_repository_service.py @@ -46,7 +46,9 @@ class UserJoinedGameServerRepositoryService(UserJoinedGameServerRepositoryABC): ) results = self._context.select(UserJoinedGameServer.get_select_all_string()) for result in results: - self._logger.trace(__name__, f"Get user-joined-game-server with id {result[0]}") + self._logger.trace( + __name__, f"Get user-joined-game-server with id {result[0]}" + ) joins.append(self._from_result(result)) return joins @@ -56,35 +58,49 @@ class UserJoinedGameServerRepositoryService(UserJoinedGameServerRepositoryABC): __name__, f"Send SQL command: {UserJoinedGameServer.get_select_by_id_string(id)}", ) - result = self._context.select(UserJoinedGameServer.get_select_by_id_string(id))[0] + result = self._context.select(UserJoinedGameServer.get_select_by_id_string(id))[ + 0 + ] return self._from_result(result) - def get_user_joined_game_servers_by_user_id(self, user_id: int) -> List[UserJoinedGameServer]: + def get_user_joined_game_servers_by_user_id( + self, user_id: int + ) -> List[UserJoinedGameServer]: joins = List(UserJoinedGameServer) self._logger.trace( __name__, f"Send SQL command: {UserJoinedGameServer.get_select_by_user_id_string(user_id)}", ) - results = self._context.select(UserJoinedGameServer.get_select_by_user_id_string(user_id)) + results = self._context.select( + UserJoinedGameServer.get_select_by_user_id_string(user_id) + ) for result in results: joins.append(self._from_result(result)) return joins - def get_active_user_joined_game_server_by_user_id(self, user_id: int) -> UserJoinedGameServer: + def get_active_user_joined_game_server_by_user_id( + self, user_id: int + ) -> UserJoinedGameServer: self._logger.trace( __name__, f"Send SQL command: {UserJoinedGameServer.get_select_by_user_id_string(user_id)}", ) - result = self._context.select(UserJoinedGameServer.get_select_active_by_user_id_string(user_id))[0] + result = self._context.select( + UserJoinedGameServer.get_select_active_by_user_id_string(user_id) + )[0] return self._from_result(result) - def find_active_user_joined_game_server_by_user_id(self, user_id: int) -> Optional[UserJoinedGameServer]: + def find_active_user_joined_game_server_by_user_id( + self, user_id: int + ) -> Optional[UserJoinedGameServer]: self._logger.trace( __name__, f"Send SQL command: {UserJoinedGameServer.get_select_by_user_id_string(user_id)}", ) - result = self._context.select(UserJoinedGameServer.get_select_active_by_user_id_string(user_id)) + result = self._context.select( + UserJoinedGameServer.get_select_active_by_user_id_string(user_id) + ) if result is None or len(result) == 0: return None @@ -92,29 +108,45 @@ class UserJoinedGameServerRepositoryService(UserJoinedGameServerRepositoryABC): return self._from_result(result) - def find_active_user_joined_game_servers_by_user_id(self, user_id: int) -> List[Optional[UserJoinedGameServer]]: + def find_active_user_joined_game_servers_by_user_id( + self, user_id: int + ) -> List[Optional[UserJoinedGameServer]]: self._logger.trace( __name__, f"Send SQL command: {UserJoinedGameServer.get_select_active_by_user_id_string(user_id)}", ) result = List(UserJoinedGameServer) - db_results = self._context.select(UserJoinedGameServer.get_select_active_by_user_id_string(user_id)) + db_results = self._context.select( + UserJoinedGameServer.get_select_active_by_user_id_string(user_id) + ) for db_result in db_results: result.append(self._from_result(db_result)) return result - def add_user_joined_game_server(self, user_joined_game_server: UserJoinedGameServer): - self._logger.trace(__name__, f"Send SQL command: {user_joined_game_server.insert_string}") + def add_user_joined_game_server( + self, user_joined_game_server: UserJoinedGameServer + ): + self._logger.trace( + __name__, f"Send SQL command: {user_joined_game_server.insert_string}" + ) self._context.cursor.execute(user_joined_game_server.insert_string) - def update_user_joined_game_server(self, user_joined_game_server: UserJoinedGameServer): - self._logger.trace(__name__, f"Send SQL command: {user_joined_game_server.udpate_string}") + def update_user_joined_game_server( + self, user_joined_game_server: UserJoinedGameServer + ): + self._logger.trace( + __name__, f"Send SQL command: {user_joined_game_server.udpate_string}" + ) self._context.cursor.execute(user_joined_game_server.udpate_string) - def delete_user_joined_game_server(self, user_joined_game_server: UserJoinedGameServer): - self._logger.trace(__name__, f"Send SQL command: {user_joined_game_server.delete_string}") + def delete_user_joined_game_server( + self, user_joined_game_server: UserJoinedGameServer + ): + self._logger.trace( + __name__, f"Send SQL command: {user_joined_game_server.delete_string}" + ) self._context.cursor.execute(user_joined_game_server.delete_string) def delete_user_joined_game_server_by_user_id(self, user_id: int): @@ -122,4 +154,6 @@ class UserJoinedGameServerRepositoryService(UserJoinedGameServerRepositoryABC): __name__, f"Send SQL command: {UserJoinedGameServer.delete_by_user_id_string}", ) - self._context.cursor.execute(UserJoinedGameServer.delete_by_user_id_string(user_id)) + self._context.cursor.execute( + UserJoinedGameServer.delete_by_user_id_string(user_id) + ) diff --git a/kdb-bot/src/bot_data/service/user_joined_server_repository_service.py b/bot/src/bot_data/service/user_joined_server_repository_service.py similarity index 78% rename from kdb-bot/src/bot_data/service/user_joined_server_repository_service.py rename to bot/src/bot_data/service/user_joined_server_repository_service.py index abd0a17b..02d8f948 100644 --- a/kdb-bot/src/bot_data/service/user_joined_server_repository_service.py +++ b/bot/src/bot_data/service/user_joined_server_repository_service.py @@ -25,7 +25,9 @@ class UserJoinedServerRepositoryService(UserJoinedServerRepositoryABC): def get_user_joined_servers(self) -> List[UserJoinedServer]: joins = List(UserJoinedServer) - self._logger.trace(__name__, f"Send SQL command: {UserJoinedServer.get_select_all_string()}") + self._logger.trace( + __name__, f"Send SQL command: {UserJoinedServer.get_select_all_string()}" + ) results = self._context.select(UserJoinedServer.get_select_all_string()) for result in results: self._logger.trace(__name__, f"Get user-joined-server with id {result[0]}") @@ -72,13 +74,17 @@ class UserJoinedServerRepositoryService(UserJoinedServerRepositoryABC): id=result[0], ) - def get_user_joined_servers_by_user_id(self, user_id: int) -> List[UserJoinedServer]: + def get_user_joined_servers_by_user_id( + self, user_id: int + ) -> List[UserJoinedServer]: joins = List(UserJoinedServer) self._logger.trace( __name__, f"Send SQL command: {UserJoinedServer.get_select_by_user_id_string(user_id)}", ) - results = self._context.select(UserJoinedServer.get_select_by_user_id_string(user_id)) + results = self._context.select( + UserJoinedServer.get_select_by_user_id_string(user_id) + ) for result in results: joins.append( UserJoinedServer( @@ -93,12 +99,16 @@ class UserJoinedServerRepositoryService(UserJoinedServerRepositoryABC): return joins - def get_active_user_joined_server_by_user_id(self, user_id: int) -> UserJoinedServer: + def get_active_user_joined_server_by_user_id( + self, user_id: int + ) -> UserJoinedServer: self._logger.trace( __name__, f"Send SQL command: {UserJoinedServer.get_select_by_user_id_string(user_id)}", ) - result = self._context.select(UserJoinedServer.get_select_active_by_user_id_string(user_id))[0] + result = self._context.select( + UserJoinedServer.get_select_active_by_user_id_string(user_id) + )[0] return UserJoinedServer( self._users.get_user_by_id(result[1]), result[2], @@ -108,12 +118,16 @@ class UserJoinedServerRepositoryService(UserJoinedServerRepositoryABC): id=result[0], ) - def find_active_user_joined_server_by_user_id(self, user_id: int) -> Optional[UserJoinedServer]: + def find_active_user_joined_server_by_user_id( + self, user_id: int + ) -> Optional[UserJoinedServer]: self._logger.trace( __name__, f"Send SQL command: {UserJoinedServer.get_select_by_user_id_string(user_id)}", ) - result = self._context.select(UserJoinedServer.get_select_active_by_user_id_string(user_id)) + result = self._context.select( + UserJoinedServer.get_select_active_by_user_id_string(user_id) + ) if result is None or len(result) == 0: return None @@ -129,13 +143,19 @@ class UserJoinedServerRepositoryService(UserJoinedServerRepositoryABC): ) def add_user_joined_server(self, user_joined_server: UserJoinedServer): - self._logger.trace(__name__, f"Send SQL command: {user_joined_server.insert_string}") + self._logger.trace( + __name__, f"Send SQL command: {user_joined_server.insert_string}" + ) self._context.cursor.execute(user_joined_server.insert_string) def update_user_joined_server(self, user_joined_server: UserJoinedServer): - self._logger.trace(__name__, f"Send SQL command: {user_joined_server.udpate_string}") + self._logger.trace( + __name__, f"Send SQL command: {user_joined_server.udpate_string}" + ) self._context.cursor.execute(user_joined_server.udpate_string) def delete_user_joined_server(self, user_joined_server: UserJoinedServer): - self._logger.trace(__name__, f"Send SQL command: {user_joined_server.delete_string}") + self._logger.trace( + __name__, f"Send SQL command: {user_joined_server.delete_string}" + ) self._context.cursor.execute(user_joined_server.delete_string) diff --git a/kdb-bot/src/bot_data/service/user_joined_voice_channel_repository_service.py b/bot/src/bot_data/service/user_joined_voice_channel_repository_service.py similarity index 68% rename from kdb-bot/src/bot_data/service/user_joined_voice_channel_repository_service.py rename to bot/src/bot_data/service/user_joined_voice_channel_repository_service.py index c441d26a..f01216ac 100644 --- a/kdb-bot/src/bot_data/service/user_joined_voice_channel_repository_service.py +++ b/bot/src/bot_data/service/user_joined_voice_channel_repository_service.py @@ -33,7 +33,9 @@ class UserJoinedVoiceChannelRepositoryService(UserJoinedVoiceChannelRepositoryAB ) results = self._context.select(UserJoinedVoiceChannel.get_select_all_string()) for result in results: - self._logger.trace(__name__, f"Get user-joined-voice-channel with id {result[0]}") + self._logger.trace( + __name__, f"Get user-joined-voice-channel with id {result[0]}" + ) joins.append( UserJoinedVoiceChannel( self._users.get_user_by_id(result[1]), @@ -52,7 +54,9 @@ class UserJoinedVoiceChannelRepositoryService(UserJoinedVoiceChannelRepositoryAB __name__, f"Send SQL command: {UserJoinedVoiceChannel.get_select_by_id_string(id)}", ) - result = self._context.select(UserJoinedVoiceChannel.get_select_by_id_string(id))[0] + result = self._context.select( + UserJoinedVoiceChannel.get_select_by_id_string(id) + )[0] return UserJoinedVoiceChannel( self._users.get_user_by_id(result[1]), result[2], @@ -62,13 +66,17 @@ class UserJoinedVoiceChannelRepositoryService(UserJoinedVoiceChannelRepositoryAB id=result[0], ) - def get_user_joined_voice_channels_by_user_id(self, user_id: int) -> List[UserJoinedVoiceChannel]: + def get_user_joined_voice_channels_by_user_id( + self, user_id: int + ) -> List[UserJoinedVoiceChannel]: joins = List(UserJoinedVoiceChannel) self._logger.trace( __name__, f"Send SQL command: {UserJoinedVoiceChannel.get_select_by_user_id_string(user_id)}", ) - results = self._context.select(UserJoinedVoiceChannel.get_select_by_user_id_string(user_id)) + results = self._context.select( + UserJoinedVoiceChannel.get_select_by_user_id_string(user_id) + ) for result in results: joins.append( UserJoinedVoiceChannel( @@ -83,12 +91,16 @@ class UserJoinedVoiceChannelRepositoryService(UserJoinedVoiceChannelRepositoryAB return joins - def get_active_user_joined_voice_channel_by_user_id(self, user_id: int) -> UserJoinedVoiceChannel: + def get_active_user_joined_voice_channel_by_user_id( + self, user_id: int + ) -> UserJoinedVoiceChannel: self._logger.trace( __name__, f"Send SQL command: {UserJoinedVoiceChannel.get_select_by_user_id_string(user_id)}", ) - result = self._context.select(UserJoinedVoiceChannel.get_select_active_by_user_id_string(user_id))[0] + result = self._context.select( + UserJoinedVoiceChannel.get_select_active_by_user_id_string(user_id) + )[0] return UserJoinedVoiceChannel( self._users.get_user_by_id(result[1]), result[2], @@ -98,12 +110,16 @@ class UserJoinedVoiceChannelRepositoryService(UserJoinedVoiceChannelRepositoryAB id=result[0], ) - def find_active_user_joined_voice_channel_by_user_id(self, user_id: int) -> Optional[UserJoinedVoiceChannel]: + def find_active_user_joined_voice_channel_by_user_id( + self, user_id: int + ) -> Optional[UserJoinedVoiceChannel]: self._logger.trace( __name__, f"Send SQL command: {UserJoinedVoiceChannel.get_select_by_user_id_string(user_id)}", ) - result = self._context.select(UserJoinedVoiceChannel.get_select_active_by_user_id_string(user_id)) + result = self._context.select( + UserJoinedVoiceChannel.get_select_active_by_user_id_string(user_id) + ) if result is None or len(result) == 0: return None @@ -118,13 +134,17 @@ class UserJoinedVoiceChannelRepositoryService(UserJoinedVoiceChannelRepositoryAB id=result[0], ) - def find_active_user_joined_voice_channels_by_user_id(self, user_id: int) -> List[Optional[UserJoinedVoiceChannel]]: + def find_active_user_joined_voice_channels_by_user_id( + self, user_id: int + ) -> List[Optional[UserJoinedVoiceChannel]]: self._logger.trace( __name__, f"Send SQL command: {UserJoinedVoiceChannel.get_select_active_by_user_id_string(user_id)}", ) result = List(UserJoinedVoiceChannel) - db_results = self._context.select(UserJoinedVoiceChannel.get_select_active_by_user_id_string(user_id)) + db_results = self._context.select( + UserJoinedVoiceChannel.get_select_active_by_user_id_string(user_id) + ) for db_result in db_results: result.append( @@ -140,16 +160,28 @@ class UserJoinedVoiceChannelRepositoryService(UserJoinedVoiceChannelRepositoryAB return result - def add_user_joined_voice_channel(self, user_joined_voice_channel: UserJoinedVoiceChannel): - self._logger.trace(__name__, f"Send SQL command: {user_joined_voice_channel.insert_string}") + def add_user_joined_voice_channel( + self, user_joined_voice_channel: UserJoinedVoiceChannel + ): + self._logger.trace( + __name__, f"Send SQL command: {user_joined_voice_channel.insert_string}" + ) self._context.cursor.execute(user_joined_voice_channel.insert_string) - def update_user_joined_voice_channel(self, user_joined_voice_channel: UserJoinedVoiceChannel): - self._logger.trace(__name__, f"Send SQL command: {user_joined_voice_channel.udpate_string}") + def update_user_joined_voice_channel( + self, user_joined_voice_channel: UserJoinedVoiceChannel + ): + self._logger.trace( + __name__, f"Send SQL command: {user_joined_voice_channel.udpate_string}" + ) self._context.cursor.execute(user_joined_voice_channel.udpate_string) - def delete_user_joined_voice_channel(self, user_joined_voice_channel: UserJoinedVoiceChannel): - self._logger.trace(__name__, f"Send SQL command: {user_joined_voice_channel.delete_string}") + def delete_user_joined_voice_channel( + self, user_joined_voice_channel: UserJoinedVoiceChannel + ): + self._logger.trace( + __name__, f"Send SQL command: {user_joined_voice_channel.delete_string}" + ) self._context.cursor.execute(user_joined_voice_channel.delete_string) def delete_user_joined_voice_channel_by_user_id(self, user_id: int): @@ -157,4 +189,6 @@ class UserJoinedVoiceChannelRepositoryService(UserJoinedVoiceChannelRepositoryAB __name__, f"Send SQL command: {UserJoinedVoiceChannel.delete_by_user_id_string}", ) - self._context.cursor.execute(UserJoinedVoiceChannel.delete_by_user_id_string(user_id)) + self._context.cursor.execute( + UserJoinedVoiceChannel.delete_by_user_id_string(user_id) + ) diff --git a/kdb-bot/src/bot_data/service/user_message_count_per_hour_repository_service.py b/bot/src/bot_data/service/user_message_count_per_hour_repository_service.py similarity index 89% rename from kdb-bot/src/bot_data/service/user_message_count_per_hour_repository_service.py rename to bot/src/bot_data/service/user_message_count_per_hour_repository_service.py index e63db818..2ccb57e6 100644 --- a/kdb-bot/src/bot_data/service/user_message_count_per_hour_repository_service.py +++ b/bot/src/bot_data/service/user_message_count_per_hour_repository_service.py @@ -51,12 +51,16 @@ class UserMessageCountPerHourRepositoryService(UserMessageCountPerHourRepository ) results = self._context.select(UserMessageCountPerHour.get_select_all_string()) for result in results: - self._logger.trace(__name__, f"Get user message count per hour with id {result[0]}") + self._logger.trace( + __name__, f"Get user message count per hour with id {result[0]}" + ) umcphs.append(self._from_result(result)) return umcphs - def find_user_message_count_per_hour_by_user_id(self, user_id: int) -> List[Optional[UserMessageCountPerHour]]: + def find_user_message_count_per_hour_by_user_id( + self, user_id: int + ) -> List[Optional[UserMessageCountPerHour]]: umcphs = List(UserMessageCountPerHour) sql = UserMessageCountPerHour.get_select_by_user_id_string(user_id) self._logger.trace(__name__, f"Send SQL command: {sql}") @@ -65,7 +69,9 @@ class UserMessageCountPerHourRepositoryService(UserMessageCountPerHourRepository return umcphs for result in results: - self._logger.trace(__name__, f"Get user message count per hour with id {result[0]}") + self._logger.trace( + __name__, f"Get user message count per hour with id {result[0]}" + ) umcphs.append(self._from_result(result)) return umcphs @@ -73,7 +79,9 @@ class UserMessageCountPerHourRepositoryService(UserMessageCountPerHourRepository def get_user_message_count_per_hour_by_user_id_and_date( self, user_id: int, date: datetime ) -> UserMessageCountPerHour: - sql = UserMessageCountPerHour.get_select_by_user_id_and_date_string(user_id, date) + sql = UserMessageCountPerHour.get_select_by_user_id_and_date_string( + user_id, date + ) self._logger.trace(__name__, f"Send SQL command: {sql}") result = self._context.select(sql)[0] return self._from_result(result) @@ -81,7 +89,9 @@ class UserMessageCountPerHourRepositoryService(UserMessageCountPerHourRepository def find_user_message_count_per_hour_by_user_id_and_date( self, user_id: int, date: datetime ) -> Optional[UserMessageCountPerHour]: - sql = UserMessageCountPerHour.get_select_by_user_id_and_date_string(user_id, date) + sql = UserMessageCountPerHour.get_select_by_user_id_and_date_string( + user_id, date + ) self._logger.trace(__name__, f"Send SQL command: {sql}") result = self._context.select(sql) if result is None or len(result) == 0: diff --git a/kdb-bot/src/bot_data/service/user_repository_service.py b/bot/src/bot_data/service/user_repository_service.py similarity index 81% rename from kdb-bot/src/bot_data/service/user_repository_service.py rename to bot/src/bot_data/service/user_repository_service.py index 940156a8..b39cd560 100644 --- a/kdb-bot/src/bot_data/service/user_repository_service.py +++ b/bot/src/bot_data/service/user_repository_service.py @@ -39,7 +39,9 @@ class UserRepositoryService(UserRepositoryABC): def get_users(self) -> List[User]: users = List(User) - self._logger.trace(__name__, f"Send SQL command: {User.get_select_all_string()}") + self._logger.trace( + __name__, f"Send SQL command: {User.get_select_all_string()}" + ) results = self._context.select(User.get_select_all_string()) for result in results: self._logger.trace(__name__, f"Get user with id {result[0]}") @@ -48,13 +50,17 @@ class UserRepositoryService(UserRepositoryABC): return users def get_user_by_id(self, id: int) -> User: - self._logger.trace(__name__, f"Send SQL command: {User.get_select_by_id_string(id)}") + self._logger.trace( + __name__, f"Send SQL command: {User.get_select_by_id_string(id)}" + ) result = self._context.select(User.get_select_by_id_string(id))[0] return self._from_result(result) def find_user_by_id(self, id: int) -> Optional[User]: - self._logger.trace(__name__, f"Send SQL command: {User.get_select_by_id_string(id)}") + self._logger.trace( + __name__, f"Send SQL command: {User.get_select_by_id_string(id)}" + ) result = self._context.select(User.get_select_by_id_string(id)) if result is None or len(result) == 0: return None @@ -87,21 +93,29 @@ class UserRepositoryService(UserRepositoryABC): return users - def get_user_by_discord_id_and_server_id(self, discord_id: int, server_id: int) -> User: + def get_user_by_discord_id_and_server_id( + self, discord_id: int, server_id: int + ) -> User: self._logger.trace( __name__, f"Send SQL command: {User.get_select_by_discord_id_and_server_id_string(discord_id, server_id)}", ) - result = self._context.select(User.get_select_by_discord_id_and_server_id_string(discord_id, server_id))[0] + result = self._context.select( + User.get_select_by_discord_id_and_server_id_string(discord_id, server_id) + )[0] return self._from_result(result) - def find_user_by_discord_id_and_server_id(self, discord_id: int, server_id: int) -> Optional[User]: + def find_user_by_discord_id_and_server_id( + self, discord_id: int, server_id: int + ) -> Optional[User]: self._logger.trace( __name__, f"Send SQL command: {User.get_select_by_discord_id_and_server_id_string(discord_id, server_id)}", ) - result = self._context.select(User.get_select_by_discord_id_and_server_id_string(discord_id, server_id)) + result = self._context.select( + User.get_select_by_discord_id_and_server_id_string(discord_id, server_id) + ) if result is None or len(result) == 0: return None diff --git a/kdb-bot/src/bot_data/service/user_warnings_repository_service.py b/bot/src/bot_data/service/user_warnings_repository_service.py similarity index 85% rename from kdb-bot/src/bot_data/service/user_warnings_repository_service.py rename to bot/src/bot_data/service/user_warnings_repository_service.py index 34cded9b..fade2db6 100644 --- a/kdb-bot/src/bot_data/service/user_warnings_repository_service.py +++ b/bot/src/bot_data/service/user_warnings_repository_service.py @@ -47,7 +47,9 @@ class UserWarningsRepositoryService(UserWarningsRepositoryABC): def get_user_warnings(self) -> List[UserWarnings]: warnings = List(UserWarnings) - self._logger.trace(__name__, f"Send SQL command: {UserWarnings.get_select_all_string()}") + self._logger.trace( + __name__, f"Send SQL command: {UserWarnings.get_select_all_string()}" + ) results = self._context.select(UserWarnings.get_select_all_string()) for result in results: warnings.append(self._from_result(result)) @@ -55,14 +57,21 @@ class UserWarningsRepositoryService(UserWarningsRepositoryABC): return warnings def get_user_warnings_by_id(self, id: int) -> UserWarnings: - self._logger.trace(__name__, f"Send SQL command: {UserWarnings.get_select_by_id_string(id)}") + self._logger.trace( + __name__, f"Send SQL command: {UserWarnings.get_select_by_id_string(id)}" + ) result = self._context.select(UserWarnings.get_select_by_id_string(id))[0] return self._from_result(result) def get_user_warnings_by_user_id(self, user_id: int) -> List[UserWarnings]: warnings = List(UserWarnings) - self._logger.trace(__name__, f"Send SQL command: {UserWarnings.get_select_by_user_id_string(user_id)}") - results = self._context.select(UserWarnings.get_select_by_user_id_string(user_id)) + self._logger.trace( + __name__, + f"Send SQL command: {UserWarnings.get_select_by_user_id_string(user_id)}", + ) + results = self._context.select( + UserWarnings.get_select_by_user_id_string(user_id) + ) for result in results: warnings.append(self._from_result(result)) diff --git a/kdb-bot/src/bot_graphql/__init__.py b/bot/src/bot_graphql/__init__.py similarity index 100% rename from kdb-bot/src/bot_graphql/__init__.py rename to bot/src/bot_graphql/__init__.py diff --git a/kdb-bot/src/bot_graphql/abc/__init__.py b/bot/src/bot_graphql/abc/__init__.py similarity index 100% rename from kdb-bot/src/bot_graphql/abc/__init__.py rename to bot/src/bot_graphql/abc/__init__.py diff --git a/kdb-bot/src/bot_graphql/abc/data_query_abc.py b/bot/src/bot_graphql/abc/data_query_abc.py similarity index 100% rename from kdb-bot/src/bot_graphql/abc/data_query_abc.py rename to bot/src/bot_graphql/abc/data_query_abc.py diff --git a/kdb-bot/src/bot_graphql/abc/data_query_with_history_abc.py b/bot/src/bot_graphql/abc/data_query_with_history_abc.py similarity index 100% rename from kdb-bot/src/bot_graphql/abc/data_query_with_history_abc.py rename to bot/src/bot_graphql/abc/data_query_with_history_abc.py diff --git a/kdb-bot/src/bot_graphql/abc/filter_abc.py b/bot/src/bot_graphql/abc/filter_abc.py similarity index 83% rename from kdb-bot/src/bot_graphql/abc/filter_abc.py rename to bot/src/bot_graphql/abc/filter_abc.py index e0d5ff8d..aec7b1a9 100644 --- a/kdb-bot/src/bot_graphql/abc/filter_abc.py +++ b/bot/src/bot_graphql/abc/filter_abc.py @@ -24,7 +24,11 @@ class FilterABC(ABC): sig = signature(f) for param in sig.parameters.items(): parameter = param[1] - if parameter.name == "self" or parameter.name == "cls" or parameter.annotation == Parameter.empty: + if ( + parameter.name == "self" + or parameter.name == "cls" + or parameter.annotation == Parameter.empty + ): continue if issubclass(parameter.annotation, FilterABC): @@ -34,7 +38,9 @@ class FilterABC(ABC): @staticmethod @ServiceProviderABC.inject - def get_collection_filter(filter_type: type, values: dict, services: ServiceProviderABC): + def get_collection_filter( + filter_type: type, values: dict, services: ServiceProviderABC + ): filter: FilterABC = services.get_service(filter_type) filter.from_dict(values) return filter diff --git a/kdb-bot/src/bot_graphql/abc/history_query_abc.py b/bot/src/bot_graphql/abc/history_query_abc.py similarity index 100% rename from kdb-bot/src/bot_graphql/abc/history_query_abc.py rename to bot/src/bot_graphql/abc/history_query_abc.py diff --git a/kdb-bot/src/bot_graphql/abc/query_abc.py b/bot/src/bot_graphql/abc/query_abc.py similarity index 86% rename from kdb-bot/src/bot_graphql/abc/query_abc.py rename to bot/src/bot_graphql/abc/query_abc.py index 1a566a94..535bbc59 100644 --- a/kdb-bot/src/bot_graphql/abc/query_abc.py +++ b/bot/src/bot_graphql/abc/query_abc.py @@ -38,10 +38,14 @@ class QueryABC(ObjectType): def __init__(self, name: str): ObjectType.__init__(self, name) - def add_collection(self, name: str, get_collection: Callable, filter_type: type = None): + def add_collection( + self, name: str, get_collection: Callable, filter_type: type = None + ): def wrapper(*args, **kwargs): if filter_type is not None and "filter" in kwargs: - kwargs["filter"] = FilterABC.get_collection_filter(filter_type, kwargs["filter"]) + kwargs["filter"] = FilterABC.get_collection_filter( + filter_type, kwargs["filter"] + ) else: kwargs["filter"] = None @@ -94,7 +98,10 @@ class QueryABC(ObjectType): 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: + if ( + permissions.is_member_moderator(member) + and u.server.id == element.server.id + ): access = True break @@ -104,7 +111,10 @@ class QueryABC(ObjectType): 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: + if ( + permissions.is_member_moderator(member) + and u.server.id == element.server.id + ): access = True break @@ -114,7 +124,10 @@ class QueryABC(ObjectType): 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.auto_role.server.id + ): access = True break @@ -199,11 +212,18 @@ class QueryABC(ObjectType): 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: + if ( + permissions.is_member_moderator(member) + and u.server.id == element.server.id + ): access = True break - elif type(element) == dict and "key" in element and element["key"] in [e.value for e in FeatureFlagsEnum]: + 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) @@ -215,7 +235,9 @@ class QueryABC(ObjectType): return access @ServiceProviderABC.inject - def _can_user_mutate_data(self, server: Server, permission: UserRoleEnum, services: ServiceProviderABC): + def _can_user_mutate_data( + self, server: Server, permission: UserRoleEnum, services: ServiceProviderABC + ): permissions: PermissionService = services.get_service(PermissionService) bot: DiscordBotServiceABC = services.get_service(DiscordBotServiceABC) @@ -224,7 +246,9 @@ class QueryABC(ObjectType): return member = bot.get_guild(server.discord_id).get_member( - auth_user.users.where(lambda x: x.server.id == server.id).single().discord_id + auth_user.users.where(lambda x: x.server.id == server.id) + .single() + .discord_id ) check_perm = lambda x: True @@ -237,11 +261,20 @@ class QueryABC(ObjectType): check_perm = lambda x: permissions.is_member_technician(x) if not check_perm(member): - ex = ServiceException(ServiceErrorCode.Forbidden, f"User not allowed to mutate data") + ex = ServiceException( + ServiceErrorCode.Forbidden, f"User not allowed to mutate data" + ) raise ex # @FilterABC.resolve_filter_annotation - def _resolve_collection(self, collection: List, *_, filter: FilterABC = None, page: Page = None, sort: Sort = None): + def _resolve_collection( + self, + collection: List, + *_, + filter: FilterABC = None, + page: Page = None, + sort: Sort = None, + ): if filter is not None: collection = filter.filter(collection) diff --git a/kdb-bot/src/bot_graphql/bot-graphql.json b/bot/src/bot_graphql/bot-graphql.json similarity index 100% rename from kdb-bot/src/bot_graphql/bot-graphql.json rename to bot/src/bot_graphql/bot-graphql.json diff --git a/kdb-bot/src/bot_graphql/filter/__init__.py b/bot/src/bot_graphql/filter/__init__.py similarity index 100% rename from kdb-bot/src/bot_graphql/filter/__init__.py rename to bot/src/bot_graphql/filter/__init__.py diff --git a/kdb-bot/src/bot_graphql/filter/achievement_filter.py b/bot/src/bot_graphql/filter/achievement_filter.py similarity index 84% rename from kdb-bot/src/bot_graphql/filter/achievement_filter.py rename to bot/src/bot_graphql/filter/achievement_filter.py index b95e00c0..1e1afd11 100644 --- a/kdb-bot/src/bot_graphql/filter/achievement_filter.py +++ b/bot/src/bot_graphql/filter/achievement_filter.py @@ -55,10 +55,16 @@ class AchievementFilter(FilterABC): query = query.where(lambda x: x.name == self._name or self._name in x.name) if self._description is not None: - query = query.where(lambda x: x.description == self._description or self._description in x.description) + query = query.where( + lambda x: x.description == self._description + or self._description in x.description + ) if self._attribute is not None: - query = query.where(lambda x: x.attribute == self._attribute or self._attribute in x.attribute) + query = query.where( + lambda x: x.attribute == self._attribute + or self._attribute in x.attribute + ) if self._operator is not None: query = query.where(lambda x: x.operator == self._operator) @@ -67,7 +73,9 @@ class AchievementFilter(FilterABC): query = query.where(lambda x: x.value == self._value) if self._server is not None: - servers = self._server.filter(query.select(lambda x: x.server)).select(lambda x: x.id) + servers = self._server.filter(query.select(lambda x: x.server)).select( + lambda x: x.id + ) query = query.where(lambda x: x.server.id in servers) return query diff --git a/kdb-bot/src/bot_graphql/filter/auto_role_filter.py b/bot/src/bot_graphql/filter/auto_role_filter.py similarity index 87% rename from kdb-bot/src/bot_graphql/filter/auto_role_filter.py rename to bot/src/bot_graphql/filter/auto_role_filter.py index 6f17dd59..caa976d5 100644 --- a/kdb-bot/src/bot_graphql/filter/auto_role_filter.py +++ b/bot/src/bot_graphql/filter/auto_role_filter.py @@ -46,21 +46,26 @@ class AutoRoleFilter(FilterABC): if self._channel_id is not None: query = query.where( - lambda x: x.discord_channel_id == self._channel_id or str(self._channel_id) in str(x.discord_channel_id) + lambda x: x.discord_channel_id == self._channel_id + or str(self._channel_id) in str(x.discord_channel_id) ) if self._channel_name is not None: query = query.where( - lambda x: x.discord_channel_name == self._channel_name or self._channel_name in x.discord_channel_name + lambda x: x.discord_channel_name == self._channel_name + or self._channel_name in x.discord_channel_name ) if self._message_id is not None: query = query.where( - lambda x: x.discord_message_id == self._message_id or str(self._message_id) in str(x.discord_message_id) + lambda x: x.discord_message_id == self._message_id + or str(self._message_id) in str(x.discord_message_id) ) if self._server is not None: - servers = self._server.filter(query.select(lambda x: x.server)).select(lambda x: x.id) + servers = self._server.filter(query.select(lambda x: x.server)).select( + lambda x: x.id + ) query = query.where(lambda x: x.server.id in servers) return query diff --git a/kdb-bot/src/bot_graphql/filter/auto_role_rule_filter.py b/bot/src/bot_graphql/filter/auto_role_rule_filter.py similarity index 93% rename from kdb-bot/src/bot_graphql/filter/auto_role_rule_filter.py rename to bot/src/bot_graphql/filter/auto_role_rule_filter.py index b9571d8f..6d661147 100644 --- a/kdb-bot/src/bot_graphql/filter/auto_role_rule_filter.py +++ b/bot/src/bot_graphql/filter/auto_role_rule_filter.py @@ -57,7 +57,9 @@ class AutoRoleRuleFilter(FilterABC): query = query.where(get_role_name) if self._auto_role is not None: - auto_roles = self._auto_role.filter(query.select(lambda x: x.game_server)).select(lambda x: x.id) + auto_roles = self._auto_role.filter( + query.select(lambda x: x.game_server) + ).select(lambda x: x.id) query = query.where(lambda x: x.game_server.id in auto_roles) return query diff --git a/kdb-bot/src/bot_graphql/filter/client_filter.py b/bot/src/bot_graphql/filter/client_filter.py similarity index 84% rename from kdb-bot/src/bot_graphql/filter/client_filter.py rename to bot/src/bot_graphql/filter/client_filter.py index 29563600..8f46fca2 100644 --- a/kdb-bot/src/bot_graphql/filter/client_filter.py +++ b/bot/src/bot_graphql/filter/client_filter.py @@ -38,10 +38,15 @@ class ClientFilter(FilterABC): query = query.where(lambda x: x.id == self._discord_id) if self._name is not None: - query = query.where(lambda x: self._name.lower() == x.name.lower() or self._name.lower() in x.name.lower()) + query = query.where( + lambda x: self._name.lower() == x.name.lower() + or self._name.lower() in x.name.lower() + ) if self._server is not None: - servers = self._server.filter(query.select(lambda x: x.server)).select(lambda x: x.id) + servers = self._server.filter(query.select(lambda x: x.server)).select( + lambda x: x.id + ) query = query.where(lambda x: x.server.id in servers) return query diff --git a/kdb-bot/src/bot_graphql/filter/level_filter.py b/bot/src/bot_graphql/filter/level_filter.py similarity index 84% rename from kdb-bot/src/bot_graphql/filter/level_filter.py rename to bot/src/bot_graphql/filter/level_filter.py index 2ded4ad8..ebd8de39 100644 --- a/kdb-bot/src/bot_graphql/filter/level_filter.py +++ b/bot/src/bot_graphql/filter/level_filter.py @@ -33,10 +33,15 @@ class LevelFilter(FilterABC): query = query.where(lambda x: x.id == self._id) if self._name is not None: - query = query.where(lambda x: self._name.lower() == x.name.lower() or self._name.lower() in x.name.lower()) + query = query.where( + lambda x: self._name.lower() == x.name.lower() + or self._name.lower() in x.name.lower() + ) if self._server is not None: - servers = self._server.filter(query.select(lambda x: x.server)).select(lambda x: x.id) + servers = self._server.filter(query.select(lambda x: x.server)).select( + lambda x: x.id + ) query = query.where(lambda x: x.server.id in servers) return query diff --git a/kdb-bot/src/bot_graphql/filter/page.py b/bot/src/bot_graphql/filter/page.py similarity index 100% rename from kdb-bot/src/bot_graphql/filter/page.py rename to bot/src/bot_graphql/filter/page.py diff --git a/kdb-bot/src/bot_graphql/filter/server_filter.py b/bot/src/bot_graphql/filter/server_filter.py similarity index 83% rename from kdb-bot/src/bot_graphql/filter/server_filter.py rename to bot/src/bot_graphql/filter/server_filter.py index e090323e..f6384146 100644 --- a/kdb-bot/src/bot_graphql/filter/server_filter.py +++ b/bot/src/bot_graphql/filter/server_filter.py @@ -32,7 +32,8 @@ class ServerFilter(FilterABC): if self._discord_id is not None: query = query.where( - lambda x: x.discord_id == self._discord_id or str(self._discord_id) in str(x.discord_id) + lambda x: x.discord_id == self._discord_id + or str(self._discord_id) in str(x.discord_id) ) if self._name is not None: @@ -40,7 +41,8 @@ class ServerFilter(FilterABC): def where_guild(x: Guild): guild = bot.get_guild(x.discord_id) return guild is not None and ( - self._name.lower() == guild.name.lower() or self._name.lower() in guild.name.lower() + self._name.lower() == guild.name.lower() + or self._name.lower() in guild.name.lower() ) query = query.where(where_guild) diff --git a/kdb-bot/src/bot_graphql/filter/short_role_name_filter.py b/bot/src/bot_graphql/filter/short_role_name_filter.py similarity index 91% rename from kdb-bot/src/bot_graphql/filter/short_role_name_filter.py rename to bot/src/bot_graphql/filter/short_role_name_filter.py index 426e3630..2fb3b2be 100644 --- a/kdb-bot/src/bot_graphql/filter/short_role_name_filter.py +++ b/bot/src/bot_graphql/filter/short_role_name_filter.py @@ -46,7 +46,10 @@ class ShortRoleNameFilter(FilterABC): query = query.where(lambda x: x.id == self._id) if self._short_name is not None: - query = query.where(lambda x: x.short_name == self._short_name or self._short_name in x.short_name) + query = query.where( + lambda x: x.short_name == self._short_name + or self._short_name in x.short_name + ) if self._role_id is not None: query = query.where(lambda x: x.role_id == self._role_id) @@ -64,7 +67,9 @@ class ShortRoleNameFilter(FilterABC): query = query.where(lambda x: x.position.value == self._position.value) if self._server is not None: - servers = self._server.filter(query.select(lambda x: x.server)).select(lambda x: x.id) + servers = self._server.filter(query.select(lambda x: x.server)).select( + lambda x: x.id + ) query = query.where(lambda x: x.server.id in servers) return query diff --git a/kdb-bot/src/bot_graphql/filter/sort.py b/bot/src/bot_graphql/filter/sort.py similarity index 100% rename from kdb-bot/src/bot_graphql/filter/sort.py rename to bot/src/bot_graphql/filter/sort.py diff --git a/kdb-bot/src/bot_graphql/filter/user_filter.py b/bot/src/bot_graphql/filter/user_filter.py similarity index 80% rename from kdb-bot/src/bot_graphql/filter/user_filter.py rename to bot/src/bot_graphql/filter/user_filter.py index 53c130d5..7a50f6d2 100644 --- a/kdb-bot/src/bot_graphql/filter/user_filter.py +++ b/bot/src/bot_graphql/filter/user_filter.py @@ -73,7 +73,8 @@ class UserFilter(FilterABC): if self._discord_id is not None: query = query.where( - lambda x: x.discord_id == self._discord_id or str(self._discord_id) in str(x.discord_id) + lambda x: x.discord_id == self._discord_id + or str(self._discord_id) in str(x.discord_id) ) if self._name is not None: @@ -81,7 +82,9 @@ class UserFilter(FilterABC): def _get_member(user: User): guild = self._bot.get_guild(user.server.discord_id) member = guild.get_member(user.discord_id) - return member is not None and (member.name == self._name or self._name in member.name) + return member is not None and ( + member.name == self._name or self._name in member.name + ) query = query.where(_get_member) @@ -89,20 +92,30 @@ class UserFilter(FilterABC): query = query.where(lambda x: x.xp == self._xp) if self._ontime is not None: - query = query.where(lambda x: self._client_utils.get_ontime_for_user(x) == self._ontime) + query = query.where( + lambda x: self._client_utils.get_ontime_for_user(x) == self._ontime + ) if self._level is not None: - levels = self._level.filter(query.select(lambda x: self._levels.get_level(x))).select(lambda x: x.id) + levels = self._level.filter( + query.select(lambda x: self._levels.get_level(x)) + ).select(lambda x: x.id) query = query.where(lambda x: self._levels.get_level(x).id in levels) if self._server is not None: - servers = self._server.filter(query.select(lambda x: x.server)).select(lambda x: x.id) + servers = self._server.filter(query.select(lambda x: x.server)).select( + lambda x: x.id + ) query = query.where(lambda x: x.server.id in servers) if self._left_server is not None: def _has_user_left_server(user: User): - active_join = self._user_joined_servers.find_active_user_joined_server_by_user_id(user.id) + active_join = ( + self._user_joined_servers.find_active_user_joined_server_by_user_id( + user.id + ) + ) return (active_join is None) == self._left_server query = query.where(_has_user_left_server) diff --git a/kdb-bot/src/bot_graphql/filter/user_joined_game_server_filter.py b/bot/src/bot_graphql/filter/user_joined_game_server_filter.py similarity index 96% rename from kdb-bot/src/bot_graphql/filter/user_joined_game_server_filter.py rename to bot/src/bot_graphql/filter/user_joined_game_server_filter.py index 1d266a70..84297e50 100644 --- a/kdb-bot/src/bot_graphql/filter/user_joined_game_server_filter.py +++ b/bot/src/bot_graphql/filter/user_joined_game_server_filter.py @@ -42,7 +42,9 @@ class UserJoinedGameServerFilter(FilterABC): query = query.where(lambda x: x.game_server == self._game_server) if self._user is not None: - users = self._user.filter(query.select(lambda x: x.user)).select(lambda x: x.id) + users = self._user.filter(query.select(lambda x: x.user)).select( + lambda x: x.id + ) query = query.where(lambda x: x.user.id in users) return query diff --git a/kdb-bot/src/bot_graphql/filter/user_joined_server_filter.py b/bot/src/bot_graphql/filter/user_joined_server_filter.py similarity index 80% rename from kdb-bot/src/bot_graphql/filter/user_joined_server_filter.py rename to bot/src/bot_graphql/filter/user_joined_server_filter.py index 3aac7e25..dd760752 100644 --- a/kdb-bot/src/bot_graphql/filter/user_joined_server_filter.py +++ b/bot/src/bot_graphql/filter/user_joined_server_filter.py @@ -43,13 +43,21 @@ class UserJoinedServerFilter(FilterABC): query = query.where(lambda x: x.id == self._id) if self._user is not None: - users = self._user.filter(query.select(lambda x: x.user)).select(lambda x: x.id) + users = self._user.filter(query.select(lambda x: x.user)).select( + lambda x: x.id + ) query = query.where(lambda x: x.user.id in users) if self._joined_on is not None: - query = query.where(lambda x: x.joined_on == self._joined_on or self._joined_on in x.joined_on) + query = query.where( + lambda x: x.joined_on == self._joined_on + or self._joined_on in x.joined_on + ) if self._leaved_on is not None: - query = query.where(lambda x: x.leaved_on == self._leaved_on or self._leaved_on in x.leaved_on) + query = query.where( + lambda x: x.leaved_on == self._leaved_on + or self._leaved_on in x.leaved_on + ) return query diff --git a/kdb-bot/src/bot_graphql/filter/user_joined_voice_channel_filter.py b/bot/src/bot_graphql/filter/user_joined_voice_channel_filter.py similarity index 82% rename from kdb-bot/src/bot_graphql/filter/user_joined_voice_channel_filter.py rename to bot/src/bot_graphql/filter/user_joined_voice_channel_filter.py index 51ba446a..681cf038 100644 --- a/kdb-bot/src/bot_graphql/filter/user_joined_voice_channel_filter.py +++ b/bot/src/bot_graphql/filter/user_joined_voice_channel_filter.py @@ -46,7 +46,9 @@ class UserJoinedVoiceChannelFilter(FilterABC): if "leavedOn" in values: self._leaved_on = values["leavedOn"] - def filter(self, query: List[UserJoinedVoiceChannel]) -> List[UserJoinedVoiceChannel]: + def filter( + self, query: List[UserJoinedVoiceChannel] + ) -> List[UserJoinedVoiceChannel]: if self._id is not None: query = query.where(lambda x: x.id == self._id) @@ -62,13 +64,21 @@ class UserJoinedVoiceChannelFilter(FilterABC): query = query.where(get_channel_name) if self._user is not None: - users = self._user.filter(query.select(lambda x: x.user)).select(lambda x: x.id) + users = self._user.filter(query.select(lambda x: x.user)).select( + lambda x: x.id + ) query = query.where(lambda x: x.user.id in users) if self._joined_on is not None: - query = query.where(lambda x: x.joined_on == self._joined_on or self._joined_on in x.joined_on) + query = query.where( + lambda x: x.joined_on == self._joined_on + or self._joined_on in x.joined_on + ) if self._leaved_on is not None: - query = query.where(lambda x: x.leaved_on == self._leaved_on or self._leaved_on in x.leaved_on) + query = query.where( + lambda x: x.leaved_on == self._leaved_on + or self._leaved_on in x.leaved_on + ) return query diff --git a/kdb-bot/src/bot_graphql/filter/user_warning_filter.py b/bot/src/bot_graphql/filter/user_warning_filter.py similarity index 85% rename from kdb-bot/src/bot_graphql/filter/user_warning_filter.py rename to bot/src/bot_graphql/filter/user_warning_filter.py index 2c716c9e..c2d70df1 100644 --- a/kdb-bot/src/bot_graphql/filter/user_warning_filter.py +++ b/bot/src/bot_graphql/filter/user_warning_filter.py @@ -43,14 +43,21 @@ class UserWarningFilter(FilterABC): query = query.where(lambda x: x.id == self._id) if self._user is not None: - users = self._user.filter(query.select(lambda x: x.user)).select(lambda x: x.id) + users = self._user.filter(query.select(lambda x: x.user)).select( + lambda x: x.id + ) query = query.where(lambda x: x.id in users) if self._description is not None: - query = query.where(lambda x: x.description == self._description or self._description in x.description) + query = query.where( + lambda x: x.description == self._description + or self._description in x.description + ) if self._author is not None: - users = self._author.filter(query.select(lambda x: x.author)).select(lambda x: x.id) + users = self._author.filter(query.select(lambda x: x.author)).select( + lambda x: x.id + ) query = query.where(lambda x: x.id in users) return query diff --git a/kdb-bot/src/bot_graphql/graphql/achievement.gql b/bot/src/bot_graphql/graphql/achievement.gql similarity index 100% rename from kdb-bot/src/bot_graphql/graphql/achievement.gql rename to bot/src/bot_graphql/graphql/achievement.gql diff --git a/kdb-bot/src/bot_graphql/graphql/autoRole.gql b/bot/src/bot_graphql/graphql/autoRole.gql similarity index 100% rename from kdb-bot/src/bot_graphql/graphql/autoRole.gql rename to bot/src/bot_graphql/graphql/autoRole.gql diff --git a/kdb-bot/src/bot_graphql/graphql/autoRoleRule.gql b/bot/src/bot_graphql/graphql/autoRoleRule.gql similarity index 100% rename from kdb-bot/src/bot_graphql/graphql/autoRoleRule.gql rename to bot/src/bot_graphql/graphql/autoRoleRule.gql diff --git a/kdb-bot/src/bot_graphql/graphql/base.gql b/bot/src/bot_graphql/graphql/base.gql similarity index 100% rename from kdb-bot/src/bot_graphql/graphql/base.gql rename to bot/src/bot_graphql/graphql/base.gql diff --git a/kdb-bot/src/bot_graphql/graphql/client.gql b/bot/src/bot_graphql/graphql/client.gql similarity index 100% rename from kdb-bot/src/bot_graphql/graphql/client.gql rename to bot/src/bot_graphql/graphql/client.gql diff --git a/kdb-bot/src/bot_graphql/graphql/discord.gql b/bot/src/bot_graphql/graphql/discord.gql similarity index 100% rename from kdb-bot/src/bot_graphql/graphql/discord.gql rename to bot/src/bot_graphql/graphql/discord.gql diff --git a/kdb-bot/src/bot_graphql/graphql/featureFlags.gql b/bot/src/bot_graphql/graphql/featureFlags.gql similarity index 100% rename from kdb-bot/src/bot_graphql/graphql/featureFlags.gql rename to bot/src/bot_graphql/graphql/featureFlags.gql diff --git a/kdb-bot/src/bot_graphql/graphql/knownUser.gql b/bot/src/bot_graphql/graphql/knownUser.gql similarity index 100% rename from kdb-bot/src/bot_graphql/graphql/knownUser.gql rename to bot/src/bot_graphql/graphql/knownUser.gql diff --git a/kdb-bot/src/bot_graphql/graphql/level.gql b/bot/src/bot_graphql/graphql/level.gql similarity index 100% rename from kdb-bot/src/bot_graphql/graphql/level.gql rename to bot/src/bot_graphql/graphql/level.gql diff --git a/kdb-bot/src/bot_graphql/graphql/mutation.gql b/bot/src/bot_graphql/graphql/mutation.gql similarity index 100% rename from kdb-bot/src/bot_graphql/graphql/mutation.gql rename to bot/src/bot_graphql/graphql/mutation.gql diff --git a/kdb-bot/src/bot_graphql/graphql/query.gql b/bot/src/bot_graphql/graphql/query.gql similarity index 100% rename from kdb-bot/src/bot_graphql/graphql/query.gql rename to bot/src/bot_graphql/graphql/query.gql diff --git a/kdb-bot/src/bot_graphql/graphql/server.gql b/bot/src/bot_graphql/graphql/server.gql similarity index 100% rename from kdb-bot/src/bot_graphql/graphql/server.gql rename to bot/src/bot_graphql/graphql/server.gql diff --git a/kdb-bot/src/bot_graphql/graphql/serverConfig.gql b/bot/src/bot_graphql/graphql/serverConfig.gql similarity index 100% rename from kdb-bot/src/bot_graphql/graphql/serverConfig.gql rename to bot/src/bot_graphql/graphql/serverConfig.gql diff --git a/kdb-bot/src/bot_graphql/graphql/shortRoleName.gql b/bot/src/bot_graphql/graphql/shortRoleName.gql similarity index 100% rename from kdb-bot/src/bot_graphql/graphql/shortRoleName.gql rename to bot/src/bot_graphql/graphql/shortRoleName.gql diff --git a/kdb-bot/src/bot_graphql/graphql/technicianConfig.gql b/bot/src/bot_graphql/graphql/technicianConfig.gql similarity index 100% rename from kdb-bot/src/bot_graphql/graphql/technicianConfig.gql rename to bot/src/bot_graphql/graphql/technicianConfig.gql diff --git a/kdb-bot/src/bot_graphql/graphql/user.gql b/bot/src/bot_graphql/graphql/user.gql similarity index 100% rename from kdb-bot/src/bot_graphql/graphql/user.gql rename to bot/src/bot_graphql/graphql/user.gql diff --git a/kdb-bot/src/bot_graphql/graphql/userJoinedGameServer.gql b/bot/src/bot_graphql/graphql/userJoinedGameServer.gql similarity index 100% rename from kdb-bot/src/bot_graphql/graphql/userJoinedGameServer.gql rename to bot/src/bot_graphql/graphql/userJoinedGameServer.gql diff --git a/kdb-bot/src/bot_graphql/graphql/userJoinedServer.gql b/bot/src/bot_graphql/graphql/userJoinedServer.gql similarity index 100% rename from kdb-bot/src/bot_graphql/graphql/userJoinedServer.gql rename to bot/src/bot_graphql/graphql/userJoinedServer.gql diff --git a/kdb-bot/src/bot_graphql/graphql/userJoinedVoiceChannel.gql b/bot/src/bot_graphql/graphql/userJoinedVoiceChannel.gql similarity index 100% rename from kdb-bot/src/bot_graphql/graphql/userJoinedVoiceChannel.gql rename to bot/src/bot_graphql/graphql/userJoinedVoiceChannel.gql diff --git a/kdb-bot/src/bot_graphql/graphql/userWarning.gql b/bot/src/bot_graphql/graphql/userWarning.gql similarity index 100% rename from kdb-bot/src/bot_graphql/graphql/userWarning.gql rename to bot/src/bot_graphql/graphql/userWarning.gql diff --git a/kdb-bot/src/bot_graphql/graphql_module.py b/bot/src/bot_graphql/graphql_module.py similarity index 93% rename from kdb-bot/src/bot_graphql/graphql_module.py rename to bot/src/bot_graphql/graphql_module.py index 07d028c0..822556a4 100644 --- a/kdb-bot/src/bot_graphql/graphql_module.py +++ b/bot/src/bot_graphql/graphql_module.py @@ -17,7 +17,9 @@ from bot_graphql.filter.short_role_name_filter import ShortRoleNameFilter from bot_graphql.filter.user_filter import UserFilter from bot_graphql.filter.user_joined_game_server_filter import UserJoinedGameServerFilter from bot_graphql.filter.user_joined_server_filter import UserJoinedServerFilter -from bot_graphql.filter.user_joined_voice_channel_filter import UserJoinedVoiceChannelFilter +from bot_graphql.filter.user_joined_voice_channel_filter import ( + UserJoinedVoiceChannelFilter, +) from bot_graphql.filter.user_warning_filter import UserWarningFilter from bot_graphql.graphql_service import GraphQLService from bot_graphql.mutation import Mutation @@ -28,7 +30,9 @@ from bot_graphql.mutations.level_mutation import LevelMutation from bot_graphql.mutations.server_config_mutation import ServerConfigMutation from bot_graphql.mutations.short_role_name_mutation import ShortRoleNameMutation from bot_graphql.mutations.technician_config_mutation import TechnicianConfigMutation -from bot_graphql.mutations.user_joined_game_server_mutation import UserJoinedGameServerMutation +from bot_graphql.mutations.user_joined_game_server_mutation import ( + UserJoinedGameServerMutation, +) from bot_graphql.mutations.user_mutation import UserMutation from bot_graphql.queries.achievement_attribute_query import AchievementAttributeQuery from bot_graphql.queries.achievement_history_query import AchievementHistoryQuery @@ -55,17 +59,31 @@ from bot_graphql.queries.server_history_query import ServerHistoryQuery from bot_graphql.queries.server_query import ServerQuery from bot_graphql.queries.short_role_name_history_query import ShortRoleNameHistoryQuery from bot_graphql.queries.short_role_name_query import ShortRoleNameQuery -from bot_graphql.queries.technician_config_history_query import TechnicianConfigHistoryQuery +from bot_graphql.queries.technician_config_history_query import ( + TechnicianConfigHistoryQuery, +) from bot_graphql.queries.technician_config_query import TechnicianConfigQuery -from bot_graphql.queries.technician_id_config_history_query import TechnicianIdConfigHistoryQuery -from bot_graphql.queries.technician_ping_url_config_history_query import TechnicianPingUrlConfigHistoryQuery +from bot_graphql.queries.technician_id_config_history_query import ( + TechnicianIdConfigHistoryQuery, +) +from bot_graphql.queries.technician_ping_url_config_history_query import ( + TechnicianPingUrlConfigHistoryQuery, +) from bot_graphql.queries.user_history_query import UserHistoryQuery -from bot_graphql.queries.user_joined_game_server_history_query import UserJoinedGameServerHistoryQuery +from bot_graphql.queries.user_joined_game_server_history_query import ( + UserJoinedGameServerHistoryQuery, +) from bot_graphql.queries.user_joined_game_server_query import UserJoinedGameServerQuery -from bot_graphql.queries.user_joined_server_history_query import UserJoinedServerHistoryQuery +from bot_graphql.queries.user_joined_server_history_query import ( + UserJoinedServerHistoryQuery, +) from bot_graphql.queries.user_joined_server_query import UserJoinedServerQuery -from bot_graphql.queries.user_joined_voice_channel_history_query import UserJoinedVoiceChannelHistoryQuery -from bot_graphql.queries.user_joined_voice_channel_query import UserJoinedVoiceChannelQuery +from bot_graphql.queries.user_joined_voice_channel_history_query import ( + UserJoinedVoiceChannelHistoryQuery, +) +from bot_graphql.queries.user_joined_voice_channel_query import ( + UserJoinedVoiceChannelQuery, +) from bot_graphql.queries.user_query import UserQuery from bot_graphql.queries.user_warning_history_query import UserWarningHistoryQuery from bot_graphql.queries.user_warning_query import UserWarningQuery @@ -77,10 +95,14 @@ class GraphQLModule(ModuleABC): def __init__(self, dc: DiscordCollectionABC): ModuleABC.__init__(self, dc, FeatureFlagsEnum.data_module) - def configure_configuration(self, config: ConfigurationABC, env: ApplicationEnvironmentABC): + def configure_configuration( + self, config: ConfigurationABC, env: ApplicationEnvironmentABC + ): pass - def configure_services(self, services: ServiceCollectionABC, env: ApplicationEnvironmentABC): + def configure_services( + self, services: ServiceCollectionABC, env: ApplicationEnvironmentABC + ): services.add_singleton(Schema) services.add_singleton(GraphQLService) services.add_singleton(Query) diff --git a/kdb-bot/src/bot_graphql/graphql_service.py b/bot/src/bot_graphql/graphql_service.py similarity index 100% rename from kdb-bot/src/bot_graphql/graphql_service.py rename to bot/src/bot_graphql/graphql_service.py diff --git a/kdb-bot/src/bot_graphql/model/__init__.py b/bot/src/bot_graphql/model/__init__.py similarity index 100% rename from kdb-bot/src/bot_graphql/model/__init__.py rename to bot/src/bot_graphql/model/__init__.py diff --git a/kdb-bot/src/bot_graphql/model/discord.py b/bot/src/bot_graphql/model/discord.py similarity index 100% rename from kdb-bot/src/bot_graphql/model/discord.py rename to bot/src/bot_graphql/model/discord.py diff --git a/kdb-bot/src/bot_graphql/mutation.py b/bot/src/bot_graphql/mutation.py similarity index 97% rename from kdb-bot/src/bot_graphql/mutation.py rename to bot/src/bot_graphql/mutation.py index 3dc7d599..39e38cc5 100644 --- a/kdb-bot/src/bot_graphql/mutation.py +++ b/bot/src/bot_graphql/mutation.py @@ -7,7 +7,9 @@ from bot_graphql.mutations.level_mutation import LevelMutation from bot_graphql.mutations.server_config_mutation import ServerConfigMutation from bot_graphql.mutations.short_role_name_mutation import ShortRoleNameMutation from bot_graphql.mutations.technician_config_mutation import TechnicianConfigMutation -from bot_graphql.mutations.user_joined_game_server_mutation import UserJoinedGameServerMutation +from bot_graphql.mutations.user_joined_game_server_mutation import ( + UserJoinedGameServerMutation, +) from bot_graphql.mutations.user_mutation import UserMutation diff --git a/kdb-bot/src/bot_graphql/mutations/__init__.py b/bot/src/bot_graphql/mutations/__init__.py similarity index 100% rename from kdb-bot/src/bot_graphql/mutations/__init__.py rename to bot/src/bot_graphql/mutations/__init__.py diff --git a/kdb-bot/src/bot_graphql/mutations/achievement_mutation.py b/bot/src/bot_graphql/mutations/achievement_mutation.py similarity index 85% rename from kdb-bot/src/bot_graphql/mutations/achievement_mutation.py rename to bot/src/bot_graphql/mutations/achievement_mutation.py index 40975a38..2731df20 100644 --- a/kdb-bot/src/bot_graphql/mutations/achievement_mutation.py +++ b/bot/src/bot_graphql/mutations/achievement_mutation.py @@ -55,16 +55,26 @@ class AchievementMutation(QueryABC): and a.server.id == server.id ) - return self._achievements.get_achievements_by_server_id(achievement.server.id).where(get_new_achievement).last() + return ( + self._achievements.get_achievements_by_server_id(achievement.server.id) + .where(get_new_achievement) + .last() + ) def resolve_update_achievement(self, *_, input: dict): achievement = self._achievements.get_achievement_by_id(input["id"]) self._can_user_mutate_data(achievement.server, UserRoleEnum.moderator) achievement.name = input["name"] if "name" in input else achievement.name - achievement.description = input["description"] if "description" in input else achievement.description - achievement.attribute = input["attribute"] if "attribute" in input else achievement.attribute - achievement.operator = input["operator"] if "operator" in input else achievement.operator + achievement.description = ( + input["description"] if "description" in input else achievement.description + ) + achievement.attribute = ( + input["attribute"] if "attribute" in input else achievement.attribute + ) + achievement.operator = ( + input["operator"] if "operator" in input else achievement.operator + ) achievement.value = input["value"] if "value" in input else achievement.value self._achievements.update_achievement(achievement) diff --git a/kdb-bot/src/bot_graphql/mutations/auto_role_mutation.py b/bot/src/bot_graphql/mutations/auto_role_mutation.py similarity index 77% rename from kdb-bot/src/bot_graphql/mutations/auto_role_mutation.py rename to bot/src/bot_graphql/mutations/auto_role_mutation.py index d936fc6e..e4dec683 100644 --- a/kdb-bot/src/bot_graphql/mutations/auto_role_mutation.py +++ b/bot/src/bot_graphql/mutations/auto_role_mutation.py @@ -25,7 +25,11 @@ class AutoRoleMutation(QueryABC): self.set_field("deleteAutoRole", self.resolve_delete_auto_role) def resolve_create_auto_role(self, *_, input: dict): - auto_role = AutoRole(self._servers.get_server_by_id(input["serverId"]), input["channelId"], input["messageId"]) + auto_role = AutoRole( + self._servers.get_server_by_id(input["serverId"]), + input["channelId"], + input["messageId"], + ) self._can_user_mutate_data(auto_role.server, UserRoleEnum.moderator) self._auto_roles.add_auto_role(auto_role) @@ -38,14 +42,22 @@ class AutoRoleMutation(QueryABC): and x.discord_message_id == int(input["messageId"]) ) - return self._auto_roles.get_auto_roles_by_server_id(auto_role.server.id).where(get_new).last() + return ( + self._auto_roles.get_auto_roles_by_server_id(auto_role.server.id) + .where(get_new) + .last() + ) def resolve_update_auto_role(self, *_, input: dict): auto_role = self._auto_roles.get_auto_role_by_id(input["id"]) self._can_user_mutate_data(auto_role.server, UserRoleEnum.moderator) - auto_role.discord_channel_id = input["channelId"] if "channelId" in input else auto_role.discord_channel_id - auto_role.discord_message_id = input["messageId"] if "messageId" in input else auto_role.discord_message_id + auto_role.discord_channel_id = ( + input["channelId"] if "channelId" in input else auto_role.discord_channel_id + ) + auto_role.discord_message_id = ( + input["messageId"] if "messageId" in input else auto_role.discord_message_id + ) self._auto_roles.update_auto_role(auto_role) self._db.save_changes() diff --git a/kdb-bot/src/bot_graphql/mutations/auto_role_rule_mutation.py b/bot/src/bot_graphql/mutations/auto_role_rule_mutation.py similarity index 77% rename from kdb-bot/src/bot_graphql/mutations/auto_role_rule_mutation.py rename to bot/src/bot_graphql/mutations/auto_role_rule_mutation.py index 56681df9..0b880c0b 100644 --- a/kdb-bot/src/bot_graphql/mutations/auto_role_rule_mutation.py +++ b/bot/src/bot_graphql/mutations/auto_role_rule_mutation.py @@ -32,9 +32,13 @@ class AutoRoleRuleMutation(QueryABC): def resolve_create_auto_role_rule(self, *_, input: dict): auto_role_rule = AutoRoleRule( - self._auto_roles.get_auto_role_by_id(input["autoRoleId"]), input["emojiName"], input["roleId"] + self._auto_roles.get_auto_role_by_id(input["autoRoleId"]), + input["emojiName"], + input["roleId"], + ) + self._can_user_mutate_data( + auto_role_rule.auto_role.server, UserRoleEnum.moderator ) - self._can_user_mutate_data(auto_role_rule.auto_role.server, UserRoleEnum.moderator) self._auto_roles.add_auto_role_rule(auto_role_rule) self._db.save_changes() @@ -54,14 +58,26 @@ class AutoRoleRuleMutation(QueryABC): self._bot.get_guild(auto_role_rule.auto_role.server.discord_id), ) ) - return self._auto_roles.get_auto_role_rules_by_auto_role_id(auto_role_rule.auto_role.id).where(get_new).last() + return ( + self._auto_roles.get_auto_role_rules_by_auto_role_id( + auto_role_rule.auto_role.id + ) + .where(get_new) + .last() + ) def resolve_update_auto_role_rule(self, *_, input: dict): auto_role_rule = self._auto_roles.get_auto_role_rule_by_id(input["id"]) - self._can_user_mutate_data(auto_role_rule.auto_role.server, UserRoleEnum.moderator) + self._can_user_mutate_data( + auto_role_rule.auto_role.server, UserRoleEnum.moderator + ) - auto_role_rule.emoji_name = input["emojiName"] if "emojiName" in input else auto_role_rule.emoji_name - auto_role_rule.role_id = input["roleId"] if "roleId" in input else auto_role_rule.role_id + auto_role_rule.emoji_name = ( + input["emojiName"] if "emojiName" in input else auto_role_rule.emoji_name + ) + auto_role_rule.role_id = ( + input["roleId"] if "roleId" in input else auto_role_rule.role_id + ) self._auto_roles.update_auto_role_rule(auto_role_rule) self._db.save_changes() @@ -79,7 +95,9 @@ class AutoRoleRuleMutation(QueryABC): def resolve_delete_auto_role_rule(self, *_, id: int): auto_role_rule = self._auto_roles.get_auto_role_rule_by_id(id) - self._can_user_mutate_data(auto_role_rule.auto_role.server, UserRoleEnum.moderator) + self._can_user_mutate_data( + auto_role_rule.auto_role.server, UserRoleEnum.moderator + ) self._auto_roles.delete_auto_role_rule(auto_role_rule) self._db.save_changes() diff --git a/kdb-bot/src/bot_graphql/mutations/level_mutation.py b/bot/src/bot_graphql/mutations/level_mutation.py similarity index 91% rename from kdb-bot/src/bot_graphql/mutations/level_mutation.py rename to bot/src/bot_graphql/mutations/level_mutation.py index 215538b7..179cc786 100644 --- a/kdb-bot/src/bot_graphql/mutations/level_mutation.py +++ b/bot/src/bot_graphql/mutations/level_mutation.py @@ -54,7 +54,11 @@ class LevelMutation(QueryABC): ) self._bot.loop.create_task(self._level_seeder.seed()) - return self._levels.get_levels_by_server_id(level.server.id).where(get_new_level).last() + return ( + self._levels.get_levels_by_server_id(level.server.id) + .where(get_new_level) + .last() + ) def resolve_update_level(self, *_, input: dict): level = self._levels.get_level_by_id(input["id"]) @@ -63,7 +67,9 @@ class LevelMutation(QueryABC): level.name = input["name"] if "name" in input else level.name level.color = input["color"] if "color" in input else level.color level.min_xp = input["minXp"] if "minXp" in input else level.min_xp - level.permissions = input["permissions"] if "permissions" in input else level.permissions + level.permissions = ( + input["permissions"] if "permissions" in input else level.permissions + ) self._levels.update_level(level) self._db.save_changes() diff --git a/kdb-bot/src/bot_graphql/mutations/server_config_mutation.py b/bot/src/bot_graphql/mutations/server_config_mutation.py similarity index 67% rename from kdb-bot/src/bot_graphql/mutations/server_config_mutation.py rename to bot/src/bot_graphql/mutations/server_config_mutation.py index 1f179d4a..0f7df29b 100644 --- a/kdb-bot/src/bot_graphql/mutations/server_config_mutation.py +++ b/bot/src/bot_graphql/mutations/server_config_mutation.py @@ -41,28 +41,44 @@ class ServerConfigMutation(QueryABC): 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) + 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 + input["messageDeleteTimer"] + if "messageDeleteTimer" in input + else server_config.message_delete_timer ) server_config.notification_chat_id = ( - input["notificationChatId"] if "notificationChatId" in input else server_config.notification_chat_id + input["notificationChatId"] + if "notificationChatId" in input + else server_config.notification_chat_id ) server_config.max_voice_state_hours = ( - input["maxVoiceStateHours"] if "maxVoiceStateHours" in input else server_config.max_voice_state_hours + input["maxVoiceStateHours"] + if "maxVoiceStateHours" in input + else server_config.max_voice_state_hours ) server_config.xp_per_message = ( - input["xpPerMessage"] if "xpPerMessage" in input else server_config.xp_per_message + input["xpPerMessage"] + if "xpPerMessage" in input + else server_config.xp_per_message ) server_config.xp_per_reaction = ( - input["xpPerReaction"] if "xpPerReaction" in input else server_config.xp_per_reaction + input["xpPerReaction"] + if "xpPerReaction" in input + else server_config.xp_per_reaction ) server_config.max_message_xp_per_hour = ( - input["maxMessageXpPerHour"] if "maxMessageXpPerHour" in input else server_config.max_message_xp_per_hour + input["maxMessageXpPerHour"] + if "maxMessageXpPerHour" in input + else server_config.max_message_xp_per_hour ) server_config.xp_per_ontime_hour = ( - input["xpPerOntimeHour"] if "xpPerOntimeHour" in input else server_config.xp_per_ontime_hour + input["xpPerOntimeHour"] + if "xpPerOntimeHour" in input + else server_config.xp_per_ontime_hour ) server_config.xp_per_event_participation = ( input["xpPerEventParticipation"] @@ -70,19 +86,29 @@ class ServerConfigMutation(QueryABC): else server_config.xp_per_event_participation ) server_config.xp_per_achievement = ( - input["xpPerAchievement"] if "xpPerAchievement" in input else server_config.xp_per_achievement + input["xpPerAchievement"] + if "xpPerAchievement" in input + else server_config.xp_per_achievement ) server_config.xp_for_birthday = ( - input["xpForBirthday"] if "xpForBirthday" in input else server_config.xp_for_birthday + input["xpForBirthday"] + if "xpForBirthday" in input + else server_config.xp_for_birthday ) server_config.afk_command_channel_id = ( - input["afkCommandChannelId"] if "afkCommandChannelId" in input else server_config.afk_command_channel_id + input["afkCommandChannelId"] + if "afkCommandChannelId" in input + else server_config.afk_command_channel_id ) server_config.help_voice_channel_id = ( - input["helpVoiceChannelId"] if "helpVoiceChannelId" in input else server_config.help_voice_channel_id + input["helpVoiceChannelId"] + if "helpVoiceChannelId" in input + else server_config.help_voice_channel_id ) server_config.team_channel_id = ( - input["teamChannelId"] if "teamChannelId" in input else server_config.team_channel_id + input["teamChannelId"] + if "teamChannelId" in input + else server_config.team_channel_id ) server_config.login_message_channel_id = ( input["loginMessageChannelId"] @@ -90,7 +116,9 @@ class ServerConfigMutation(QueryABC): else server_config.login_message_channel_id ) server_config.default_role_id = ( - input["defaultRoleId"] if "defaultRoleId" in input else server_config.default_role_id + input["defaultRoleId"] + if "defaultRoleId" in input + else server_config.default_role_id ) server_config.short_role_name_only_set_highest_role = ( input["shortRoleNameOnlySetHighestRole"] @@ -103,7 +131,12 @@ class ServerConfigMutation(QueryABC): else server_config.game_offer_notification_chat_id ) server_config.feature_flags = ( - dict(zip([x["key"] for x in input["featureFlags"]], [x["value"] for x in input["featureFlags"]])) + 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 ) @@ -117,25 +150,33 @@ class ServerConfigMutation(QueryABC): if "moderatorRoleIds" in input: team_role_ids.extend( [ - ServerTeamRoleIdsConfig(x, TeamMemberTypeEnum.moderator, server_config.server.id) + ServerTeamRoleIdsConfig( + x, TeamMemberTypeEnum.moderator, server_config.server.id + ) for x in input["moderatorRoleIds"] ] ) else: team_role_ids.extend( - server_config.team_role_ids.where(lambda x: x.team_member_type == TeamMemberTypeEnum.moderator) + server_config.team_role_ids.where( + lambda x: x.team_member_type == TeamMemberTypeEnum.moderator + ) ) if "adminRoleIds" in input: team_role_ids.extend( [ - ServerTeamRoleIdsConfig(x, TeamMemberTypeEnum.admin, server_config.server.id) + ServerTeamRoleIdsConfig( + x, TeamMemberTypeEnum.admin, server_config.server.id + ) for x in input["adminRoleIds"] ] ) else: team_role_ids.extend( - server_config.team_role_ids.where(lambda x: x.team_member_type == TeamMemberTypeEnum.admin) + server_config.team_role_ids.where( + lambda x: x.team_member_type == TeamMemberTypeEnum.admin + ) ) self._server_configs.update_server_config(server_config) @@ -147,11 +188,15 @@ class ServerConfigMutation(QueryABC): self._update_team_role_ids(server_config) self._db.save_changes() - self._bot.loop.create_task(self._config_service.reload_server_config(server_config.server)) + self._bot.loop.create_task( + self._config_service.reload_server_config(server_config.server) + ) 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_server( + new_config.server.id + ) for channel_id in old_config.afk_channel_ids: if channel_id in new_config.afk_channel_ids: continue @@ -169,9 +214,13 @@ 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_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)): + if role_id.role_id in new_config.team_role_ids.select( + lambda x: int(x.role_id) + ): continue self._server_configs.delete_server_team_role_id_config(role_id) @@ -183,7 +232,9 @@ class ServerConfigMutation(QueryABC): raise ValueError(f"Invalid roleId") for role_id in new_config.team_role_ids: - if role_id.role_id in old_config.team_role_ids.select(lambda x: str(x.role_id)): + if role_id.role_id in old_config.team_role_ids.select( + lambda x: str(x.role_id) + ): continue self._server_configs.add_server_team_role_id_config(role_id) diff --git a/kdb-bot/src/bot_graphql/mutations/short_role_name_mutation.py b/bot/src/bot_graphql/mutations/short_role_name_mutation.py similarity index 86% rename from kdb-bot/src/bot_graphql/mutations/short_role_name_mutation.py rename to bot/src/bot_graphql/mutations/short_role_name_mutation.py index 3044af99..d3b8c910 100644 --- a/kdb-bot/src/bot_graphql/mutations/short_role_name_mutation.py +++ b/bot/src/bot_graphql/mutations/short_role_name_mutation.py @@ -41,7 +41,9 @@ class ShortRoleNameMutation(QueryABC): server, ) - result = self._short_role_names.find_short_role_names_by_role_id(short_role_name.role_id) + result = self._short_role_names.find_short_role_names_by_role_id( + short_role_name.role_id + ) if result.count() > 0: raise ValueError("Short name for role already exists") @@ -56,7 +58,9 @@ class ShortRoleNameMutation(QueryABC): ) return ( - self._short_role_names.get_short_role_names_by_server_id(short_role_name.server.id) + self._short_role_names.get_short_role_names_by_server_id( + short_role_name.server.id + ) .where(get_new_short_role_name) .last() ) @@ -65,9 +69,15 @@ class ShortRoleNameMutation(QueryABC): short_role_name = self._short_role_names.get_short_role_name_by_id(input["id"]) self._can_user_mutate_data(short_role_name.server, UserRoleEnum.moderator) - short_role_name.short_name = input["shortName"] if "shortName" in input else short_role_name.short_name - short_role_name.role_id = input["roleId"] if "roleId" in input else short_role_name.role_id - short_role_name.position = input["position"] if "position" in input else short_role_name.position + short_role_name.short_name = ( + input["shortName"] if "shortName" in input else short_role_name.short_name + ) + short_role_name.role_id = ( + input["roleId"] if "roleId" in input else short_role_name.role_id + ) + short_role_name.position = ( + input["position"] if "position" in input else short_role_name.position + ) self._short_role_names.update_short_role_name(short_role_name) self._db.save_changes() diff --git a/kdb-bot/src/bot_graphql/mutations/technician_config_mutation.py b/bot/src/bot_graphql/mutations/technician_config_mutation.py similarity index 79% rename from kdb-bot/src/bot_graphql/mutations/technician_config_mutation.py rename to bot/src/bot_graphql/mutations/technician_config_mutation.py index 434856ee..09ba300b 100644 --- a/kdb-bot/src/bot_graphql/mutations/technician_config_mutation.py +++ b/bot/src/bot_graphql/mutations/technician_config_mutation.py @@ -43,7 +43,9 @@ class TechnicianConfigMutation(QueryABC): self._bot.loop.create_task(self._tech_seeder.seed()) 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( + Route.get_user().users[0].server, UserRoleEnum.technician + ) technician_config.help_command_reference_url = ( input["helpCommandReferenceUrl"] @@ -51,17 +53,28 @@ class TechnicianConfigMutation(QueryABC): else technician_config.help_command_reference_url ) technician_config.wait_for_restart = ( - input["waitForRestart"] if "waitForRestart" in input else technician_config.wait_for_restart + input["waitForRestart"] + if "waitForRestart" in input + else technician_config.wait_for_restart ) technician_config.wait_for_shutdown = ( - input["waitForShutdown"] if "waitForShutdown" in input else technician_config.wait_for_shutdown + input["waitForShutdown"] + if "waitForShutdown" in input + else technician_config.wait_for_shutdown ) technician_config.cache_max_messages = ( - input["cacheMaxMessages"] if "cacheMaxMessages" in input else technician_config.cache_max_messages + input["cacheMaxMessages"] + if "cacheMaxMessages" in input + else technician_config.cache_max_messages ) old_feature_flags = technician_config.feature_flags technician_config.feature_flags = ( - dict(zip([x["key"] for x in input["featureFlags"]], [x["value"] for x in input["featureFlags"]])) + 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 ) @@ -70,7 +83,9 @@ class TechnicianConfigMutation(QueryABC): technician_config.feature_flags[old_flag] = False technician_config.ping_urls = ( - List(str, input["pingURLs"]) if "pingURLs" in input else technician_config.ping_urls + List(str, input["pingURLs"]) + if "pingURLs" in input + else technician_config.ping_urls ) technician_config.technician_ids = ( List(int).extend([int(x) for x in input["technicianIds"]]) @@ -95,13 +110,17 @@ class TechnicianConfigMutation(QueryABC): if url in new_config.ping_urls: continue - self._technician_configs.delete_technician_ping_url_config(TechnicianPingUrlConfig(url)) + self._technician_configs.delete_technician_ping_url_config( + TechnicianPingUrlConfig(url) + ) for url in new_config.ping_urls: if url in old_config.ping_urls: continue - self._technician_configs.add_technician_ping_url_config(TechnicianPingUrlConfig(url)) + self._technician_configs.add_technician_ping_url_config( + TechnicianPingUrlConfig(url) + ) def _update_technician_ids(self, new_config: TechnicianConfig): old_config = self._technician_configs.get_technician_config() @@ -109,7 +128,9 @@ class TechnicianConfigMutation(QueryABC): if technician_id in new_config.technician_ids: continue - self._technician_configs.delete_technician_id_config(TechnicianIdConfig(technician_id)) + self._technician_configs.delete_technician_id_config( + TechnicianIdConfig(technician_id) + ) for technician_id in new_config.technician_ids: user = self._bot.get_user(technician_id) @@ -120,4 +141,6 @@ class TechnicianConfigMutation(QueryABC): if technician_id in old_config.technician_ids: continue - self._technician_configs.add_technician_id_config(TechnicianIdConfig(technician_id)) + self._technician_configs.add_technician_id_config( + TechnicianIdConfig(technician_id) + ) diff --git a/kdb-bot/src/bot_graphql/mutations/user_joined_game_server_mutation.py b/bot/src/bot_graphql/mutations/user_joined_game_server_mutation.py similarity index 86% rename from kdb-bot/src/bot_graphql/mutations/user_joined_game_server_mutation.py rename to bot/src/bot_graphql/mutations/user_joined_game_server_mutation.py index 9225299d..d5885fd6 100644 --- a/kdb-bot/src/bot_graphql/mutations/user_joined_game_server_mutation.py +++ b/bot/src/bot_graphql/mutations/user_joined_game_server_mutation.py @@ -15,7 +15,9 @@ from bot_data.abc.api_key_repository_abc import ApiKeyRepositoryABC from bot_data.abc.game_server_repository_abc import GameServerRepositoryABC from bot_data.abc.server_repository_abc import ServerRepositoryABC from bot_data.abc.user_game_ident_repository_abc import UserGameIdentRepositoryABC -from bot_data.abc.user_joined_game_server_repository_abc import UserJoinedGameServerRepositoryABC +from bot_data.abc.user_joined_game_server_repository_abc import ( + UserJoinedGameServerRepositoryABC, +) from bot_data.abc.user_repository_abc import UserRepositoryABC from bot_data.model.api_key import ApiKey from bot_data.model.server_config import ServerConfig @@ -61,7 +63,9 @@ class UserJoinedGameServerMutation(QueryABC): def _get_api_key_str(self, api_key: ApiKey) -> str: return hashlib.sha256( - f"{api_key.identifier}:{api_key.key}+{self._auth_settings.secret_key}".encode("utf-8") + f"{api_key.identifier}:{api_key.key}+{self._auth_settings.secret_key}".encode( + "utf-8" + ) ).hexdigest() def _get_api_key(self) -> Optional[ApiKey]: @@ -80,13 +84,19 @@ class UserJoinedGameServerMutation(QueryABC): game_ident = self._user_game_idents.get_user_game_ident_by_ident(input["ident"]) user = game_ident.user - settings: ServerConfig = self._config.get_configuration(f"ServerConfig_{user.server.discord_id}") - if not FeatureFlagsSettings.get_flag_from_dict(settings.feature_flags, FeatureFlagsEnum.game_server): + settings: ServerConfig = self._config.get_configuration( + f"ServerConfig_{user.server.discord_id}" + ) + if not FeatureFlagsSettings.get_flag_from_dict( + settings.feature_flags, FeatureFlagsEnum.game_server + ): raise Exception("Feature not activated") self._can_user_mutate_data(user.server, UserRoleEnum.admin) - active = self._user_joined_game_servers.find_active_user_joined_game_server_by_user_id(user.id) + active = self._user_joined_game_servers.find_active_user_joined_game_server_by_user_id( + user.id + ) if active is not None: self._logger.debug( __name__, @@ -98,26 +108,38 @@ class UserJoinedGameServerMutation(QueryABC): self._user_joined_game_servers.add_user_joined_game_server(new) self._db.save_changes() - return self._user_joined_game_servers.get_active_user_joined_game_server_by_user_id(user.id) + return self._user_joined_game_servers.get_active_user_joined_game_server_by_user_id( + user.id + ) def resolve_user_left(self, *_, input: dict): - game_ident = self._user_game_idents.find_user_game_ident_by_ident(input["ident"]) + game_ident = self._user_game_idents.find_user_game_ident_by_ident( + input["ident"] + ) if game_ident is None: return user = game_ident.user - settings: ServerConfig = self._config.get_configuration(f"ServerConfig_{user.server.discord_id}") - if not FeatureFlagsSettings.get_flag_from_dict(settings.feature_flags, FeatureFlagsEnum.game_server): + settings: ServerConfig = self._config.get_configuration( + f"ServerConfig_{user.server.discord_id}" + ) + if not FeatureFlagsSettings.get_flag_from_dict( + settings.feature_flags, FeatureFlagsEnum.game_server + ): raise Exception("Feature not activated") self._can_user_mutate_data(user.server, UserRoleEnum.admin) - active = self._user_joined_game_servers.find_active_user_joined_game_server_by_user_id(user.id) + active = self._user_joined_game_servers.find_active_user_joined_game_server_by_user_id( + user.id + ) if active is None: return active.leaved_on = datetime.now() - settings: ServerConfig = self._config.get_configuration(f"ServerConfig_{user.server.discord_id}") + settings: ServerConfig = self._config.get_configuration( + f"ServerConfig_{user.server.discord_id}" + ) ontime = round((active.leaved_on - active.joined_on).total_seconds() / 3600, 2) old_xp = user.xp diff --git a/kdb-bot/src/bot_graphql/mutations/user_mutation.py b/bot/src/bot_graphql/mutations/user_mutation.py similarity index 80% rename from kdb-bot/src/bot_graphql/mutations/user_mutation.py rename to bot/src/bot_graphql/mutations/user_mutation.py index 9ec5f4cc..778db4f4 100644 --- a/kdb-bot/src/bot_graphql/mutations/user_mutation.py +++ b/bot/src/bot_graphql/mutations/user_mutation.py @@ -48,7 +48,9 @@ class UserMutation(QueryABC): auth_user = Route.get_user() member = self._bot.get_guild(user.server.discord_id).get_member( - auth_user.users.where(lambda x: x.server.id == user.server.id).single().discord_id + auth_user.users.where(lambda x: x.server.id == user.server.id) + .single() + .discord_id ) if member.id != user.discord_id: self._can_user_mutate_data(user.server, UserRoleEnum.moderator) @@ -62,9 +64,19 @@ class UserMutation(QueryABC): if "userWarnings" in input: self._update_user_warning(user, input["userWarnings"]) - user.xp = new_xp if new_xp is not None else input["xp"] if "xp" in input else user.xp + user.xp = ( + new_xp + if new_xp is not None + else input["xp"] + if "xp" in input + else user.xp + ) - user.birthday = datetime.strptime(input["birthday"], "%d.%m.%Y") if "birthday" in input else user.birthday + user.birthday = ( + datetime.strptime(input["birthday"], "%d.%m.%Y") + if "birthday" in input + else user.birthday + ) self._users.update_user(user) self._db.save_changes() @@ -76,15 +88,23 @@ class UserMutation(QueryABC): def _update_user_warning(self, user: User, new_warnings: dict): old_warnings = self._user_warnings.get_user_warnings_by_user_id(user.id) for warning in old_warnings: - if warning.id in [int(x["id"]) if "id" in x else None for x in new_warnings]: + if warning.id in [ + int(x["id"]) if "id" in x else None for x in new_warnings + ]: continue self._user_warning_service.remove_warnings(warning.id) for warning in new_warnings: - if "id" in warning and int(warning["id"]) in old_warnings.select(lambda x: x.id): + if "id" in warning and int(warning["id"]) in old_warnings.select( + lambda x: x.id + ): continue - member = self._bot.get_guild(user.server.discord_id).get_member(user.discord_id) + member = self._bot.get_guild(user.server.discord_id).get_member( + user.discord_id + ) author = self._users.get_user_by_id(int(warning["author"])) - self._user_warning_service.add_warnings(member, warning["description"], author.discord_id) + self._user_warning_service.add_warnings( + member, warning["description"], author.discord_id + ) diff --git a/kdb-bot/src/bot_graphql/queries/__init__.py b/bot/src/bot_graphql/queries/__init__.py similarity index 100% rename from kdb-bot/src/bot_graphql/queries/__init__.py rename to bot/src/bot_graphql/queries/__init__.py diff --git a/kdb-bot/src/bot_graphql/queries/achievement_attribute_query.py b/bot/src/bot_graphql/queries/achievement_attribute_query.py similarity index 100% rename from kdb-bot/src/bot_graphql/queries/achievement_attribute_query.py rename to bot/src/bot_graphql/queries/achievement_attribute_query.py diff --git a/kdb-bot/src/bot_graphql/queries/achievement_history_query.py b/bot/src/bot_graphql/queries/achievement_history_query.py similarity index 100% rename from kdb-bot/src/bot_graphql/queries/achievement_history_query.py rename to bot/src/bot_graphql/queries/achievement_history_query.py diff --git a/kdb-bot/src/bot_graphql/queries/achievement_query.py b/bot/src/bot_graphql/queries/achievement_query.py similarity index 84% rename from kdb-bot/src/bot_graphql/queries/achievement_query.py rename to bot/src/bot_graphql/queries/achievement_query.py index ab72fde0..f12e8657 100644 --- a/kdb-bot/src/bot_graphql/queries/achievement_query.py +++ b/bot/src/bot_graphql/queries/achievement_query.py @@ -9,7 +9,9 @@ class AchievementQuery(DataQueryWithHistoryABC): self, db: DatabaseContextABC, ): - DataQueryWithHistoryABC.__init__(self, "Achievement", "AchievementsHistory", AchievementHistory, db) + DataQueryWithHistoryABC.__init__( + self, "Achievement", "AchievementsHistory", AchievementHistory, db + ) self.set_field("id", lambda x, *_: x.id) self.set_field("name", lambda x, *_: x.name) diff --git a/kdb-bot/src/bot_graphql/queries/auto_role_history_query.py b/bot/src/bot_graphql/queries/auto_role_history_query.py similarity index 100% rename from kdb-bot/src/bot_graphql/queries/auto_role_history_query.py rename to bot/src/bot_graphql/queries/auto_role_history_query.py diff --git a/kdb-bot/src/bot_graphql/queries/auto_role_query.py b/bot/src/bot_graphql/queries/auto_role_query.py similarity index 91% rename from kdb-bot/src/bot_graphql/queries/auto_role_query.py rename to bot/src/bot_graphql/queries/auto_role_query.py index aaf694b7..ea6b9d7c 100644 --- a/kdb-bot/src/bot_graphql/queries/auto_role_query.py +++ b/bot/src/bot_graphql/queries/auto_role_query.py @@ -18,7 +18,9 @@ class AutoRoleQuery(DataQueryWithHistoryABC): servers: ServerRepositoryABC, db: DatabaseContextABC, ): - DataQueryWithHistoryABC.__init__(self, "AutoRole", "AutoRolesHistory", AutoRoleHistory, db) + DataQueryWithHistoryABC.__init__( + self, "AutoRole", "AutoRolesHistory", AutoRoleHistory, db + ) self._bot = bot self._auto_role_rules = auto_role_rules @@ -31,7 +33,9 @@ class AutoRoleQuery(DataQueryWithHistoryABC): self.set_field("server", self.resolve_server) self.add_collection( "autoRoleRule", - lambda x, *_: self._auto_role_rules.get_auto_role_rules_by_auto_role_id(x.id), + lambda x, *_: self._auto_role_rules.get_auto_role_rules_by_auto_role_id( + x.id + ), AutoRoleFilter, ) diff --git a/kdb-bot/src/bot_graphql/queries/auto_role_rule_history_query.py b/bot/src/bot_graphql/queries/auto_role_rule_history_query.py similarity index 100% rename from kdb-bot/src/bot_graphql/queries/auto_role_rule_history_query.py rename to bot/src/bot_graphql/queries/auto_role_rule_history_query.py diff --git a/kdb-bot/src/bot_graphql/queries/auto_role_rule_query.py b/bot/src/bot_graphql/queries/auto_role_rule_query.py similarity index 81% rename from kdb-bot/src/bot_graphql/queries/auto_role_rule_query.py rename to bot/src/bot_graphql/queries/auto_role_rule_query.py index e847a605..e08dc4f1 100644 --- a/kdb-bot/src/bot_graphql/queries/auto_role_rule_query.py +++ b/bot/src/bot_graphql/queries/auto_role_rule_query.py @@ -8,8 +8,15 @@ from bot_graphql.abc.data_query_with_history_abc import DataQueryWithHistoryABC class AutoRoleRuleQuery(DataQueryWithHistoryABC): - def __init__(self, bot: DiscordBotServiceABC, auto_roles: AutoRoleRepositoryABC, db: DatabaseContextABC): - DataQueryWithHistoryABC.__init__(self, "AutoRoleRule", "AutoRoleRulesHistory", AutoRoleRuleHistory, db) + def __init__( + self, + bot: DiscordBotServiceABC, + auto_roles: AutoRoleRepositoryABC, + db: DatabaseContextABC, + ): + DataQueryWithHistoryABC.__init__( + self, "AutoRoleRule", "AutoRoleRulesHistory", AutoRoleRuleHistory, db + ) self._bot = bot self._auto_roles = auto_roles diff --git a/kdb-bot/src/bot_graphql/queries/client_history_query.py b/bot/src/bot_graphql/queries/client_history_query.py similarity index 100% rename from kdb-bot/src/bot_graphql/queries/client_history_query.py rename to bot/src/bot_graphql/queries/client_history_query.py diff --git a/kdb-bot/src/bot_graphql/queries/client_query.py b/bot/src/bot_graphql/queries/client_query.py similarity index 94% rename from kdb-bot/src/bot_graphql/queries/client_query.py rename to bot/src/bot_graphql/queries/client_query.py index 6e69a369..af462202 100644 --- a/kdb-bot/src/bot_graphql/queries/client_query.py +++ b/bot/src/bot_graphql/queries/client_query.py @@ -8,7 +8,9 @@ from bot_graphql.abc.data_query_with_history_abc import DataQueryWithHistoryABC class ClientQuery(DataQueryWithHistoryABC): def __init__(self, bot: DiscordBotServiceABC, db: DatabaseContextABC): - DataQueryWithHistoryABC.__init__(self, "Client", "ClientsHistory", ClientHistory, db) + DataQueryWithHistoryABC.__init__( + self, "Client", "ClientsHistory", ClientHistory, db + ) self._bot = bot diff --git a/kdb-bot/src/bot_graphql/queries/discord/__init__.py b/bot/src/bot_graphql/queries/discord/__init__.py similarity index 100% rename from kdb-bot/src/bot_graphql/queries/discord/__init__.py rename to bot/src/bot_graphql/queries/discord/__init__.py diff --git a/kdb-bot/src/bot_graphql/queries/discord/channel_query.py b/bot/src/bot_graphql/queries/discord/channel_query.py similarity index 100% rename from kdb-bot/src/bot_graphql/queries/discord/channel_query.py rename to bot/src/bot_graphql/queries/discord/channel_query.py diff --git a/kdb-bot/src/bot_graphql/queries/discord/discord_query.py b/bot/src/bot_graphql/queries/discord/discord_query.py similarity index 100% rename from kdb-bot/src/bot_graphql/queries/discord/discord_query.py rename to bot/src/bot_graphql/queries/discord/discord_query.py diff --git a/kdb-bot/src/bot_graphql/queries/discord/discord_user_query.py b/bot/src/bot_graphql/queries/discord/discord_user_query.py similarity index 100% rename from kdb-bot/src/bot_graphql/queries/discord/discord_user_query.py rename to bot/src/bot_graphql/queries/discord/discord_user_query.py diff --git a/kdb-bot/src/bot_graphql/queries/discord/emoji_query.py b/bot/src/bot_graphql/queries/discord/emoji_query.py similarity index 100% rename from kdb-bot/src/bot_graphql/queries/discord/emoji_query.py rename to bot/src/bot_graphql/queries/discord/emoji_query.py diff --git a/kdb-bot/src/bot_graphql/queries/discord/guild_query.py b/bot/src/bot_graphql/queries/discord/guild_query.py similarity index 88% rename from kdb-bot/src/bot_graphql/queries/discord/guild_query.py rename to bot/src/bot_graphql/queries/discord/guild_query.py index 98f581f3..5393c530 100644 --- a/kdb-bot/src/bot_graphql/queries/discord/guild_query.py +++ b/bot/src/bot_graphql/queries/discord/guild_query.py @@ -20,7 +20,10 @@ class GuildQuery(QueryABC): self.set_field("channels", self._resolve_channels) self.set_field("roles", lambda g, *_: g.roles.order_by(lambda x: x.position)) self.set_field( - "emojis", lambda g, *_: List(discord.Emoji, g.emojis).order_by_descending(lambda x: x.created_at) + "emojis", + lambda g, *_: List(discord.Emoji, g.emojis).order_by_descending( + lambda x: x.created_at + ), ) def _resolve_channels(self, g: Guild, *_, filter=None): diff --git a/kdb-bot/src/bot_graphql/queries/discord/role_query.py b/bot/src/bot_graphql/queries/discord/role_query.py similarity index 100% rename from kdb-bot/src/bot_graphql/queries/discord/role_query.py rename to bot/src/bot_graphql/queries/discord/role_query.py diff --git a/kdb-bot/src/bot_graphql/queries/game_server_query.py b/bot/src/bot_graphql/queries/game_server_query.py similarity index 100% rename from kdb-bot/src/bot_graphql/queries/game_server_query.py rename to bot/src/bot_graphql/queries/game_server_query.py diff --git a/kdb-bot/src/bot_graphql/queries/known_user_history_query.py b/bot/src/bot_graphql/queries/known_user_history_query.py similarity index 100% rename from kdb-bot/src/bot_graphql/queries/known_user_history_query.py rename to bot/src/bot_graphql/queries/known_user_history_query.py diff --git a/kdb-bot/src/bot_graphql/queries/known_user_query.py b/bot/src/bot_graphql/queries/known_user_query.py similarity index 83% rename from kdb-bot/src/bot_graphql/queries/known_user_query.py rename to bot/src/bot_graphql/queries/known_user_query.py index d3435735..c6079b56 100644 --- a/kdb-bot/src/bot_graphql/queries/known_user_query.py +++ b/bot/src/bot_graphql/queries/known_user_query.py @@ -7,7 +7,9 @@ from bot_graphql.abc.data_query_with_history_abc import DataQueryWithHistoryABC class KnownUserQuery(DataQueryWithHistoryABC): def __init__(self, db: DatabaseContextABC): - DataQueryWithHistoryABC.__init__(self, "KnownUser", "KnownUsersHistory", KnownUserHistory, db) + DataQueryWithHistoryABC.__init__( + self, "KnownUser", "KnownUsersHistory", KnownUserHistory, db + ) self.set_field("id", self.resolve_id) self.set_field("discordId", self.resolve_discord_id) diff --git a/kdb-bot/src/bot_graphql/queries/level_history_query.py b/bot/src/bot_graphql/queries/level_history_query.py similarity index 100% rename from kdb-bot/src/bot_graphql/queries/level_history_query.py rename to bot/src/bot_graphql/queries/level_history_query.py diff --git a/kdb-bot/src/bot_graphql/queries/level_query.py b/bot/src/bot_graphql/queries/level_query.py similarity index 91% rename from kdb-bot/src/bot_graphql/queries/level_query.py rename to bot/src/bot_graphql/queries/level_query.py index 5f726c5b..7eef1b3f 100644 --- a/kdb-bot/src/bot_graphql/queries/level_query.py +++ b/bot/src/bot_graphql/queries/level_query.py @@ -7,7 +7,9 @@ from bot_graphql.abc.data_query_with_history_abc import DataQueryWithHistoryABC class LevelQuery(DataQueryWithHistoryABC): def __init__(self, db: DatabaseContextABC): - DataQueryWithHistoryABC.__init__(self, "Level", "LevelsHistory", LevelHistory, db) + DataQueryWithHistoryABC.__init__( + self, "Level", "LevelsHistory", LevelHistory, db + ) self.set_field("id", self.resolve_id) self.set_field("name", self.resolve_name) diff --git a/kdb-bot/src/bot_graphql/queries/server_config_query.py b/bot/src/bot_graphql/queries/server_config_query.py similarity index 53% rename from kdb-bot/src/bot_graphql/queries/server_config_query.py rename to bot/src/bot_graphql/queries/server_config_query.py index 080fd874..9c28b560 100644 --- a/kdb-bot/src/bot_graphql/queries/server_config_query.py +++ b/bot/src/bot_graphql/queries/server_config_query.py @@ -8,31 +8,60 @@ from bot_graphql.abc.data_query_with_history_abc import DataQueryWithHistoryABC class ServerConfigQuery(DataQueryWithHistoryABC): def __init__(self, db: DatabaseContextABC): - DataQueryWithHistoryABC.__init__(self, "ServerConfig", "CFG_ServerHistory", ServerConfigHistory, db) + DataQueryWithHistoryABC.__init__( + self, "ServerConfig", "CFG_ServerHistory", ServerConfigHistory, db + ) self.set_field("id", lambda config, *_: config.id) - self.set_field("messageDeleteTimer", lambda config, *_: config.message_delete_timer) - self.set_field("notificationChatId", lambda config, *_: config.notification_chat_id) - self.set_field("maxVoiceStateHours", lambda config, *_: config.max_voice_state_hours) + self.set_field( + "messageDeleteTimer", lambda config, *_: config.message_delete_timer + ) + self.set_field( + "notificationChatId", lambda config, *_: config.notification_chat_id + ) + self.set_field( + "maxVoiceStateHours", lambda config, *_: config.max_voice_state_hours + ) self.set_field("xpPerMessage", lambda config, *_: config.xp_per_message) self.set_field("xpPerReaction", lambda config, *_: config.xp_per_reaction) - self.set_field("maxMessageXpPerHour", lambda config, *_: config.max_message_xp_per_hour) + self.set_field( + "maxMessageXpPerHour", lambda config, *_: config.max_message_xp_per_hour + ) self.set_field("xpPerOntimeHour", lambda config, *_: config.xp_per_ontime_hour) - self.set_field("xpPerEventParticipation", lambda config, *_: config.xp_per_event_participation) + self.set_field( + "xpPerEventParticipation", + lambda config, *_: config.xp_per_event_participation, + ) self.set_field("xpPerAchievement", lambda config, *_: config.xp_per_achievement) self.set_field("xpForBirthday", lambda config, *_: config.xp_for_birthday) - self.set_field("afkCommandChannelId", lambda config, *_: config.afk_command_channel_id) - self.set_field("helpVoiceChannelId", lambda config, *_: config.help_voice_channel_id) + self.set_field( + "afkCommandChannelId", lambda config, *_: config.afk_command_channel_id + ) + self.set_field( + "helpVoiceChannelId", lambda config, *_: config.help_voice_channel_id + ) self.set_field("teamChannelId", lambda config, *_: config.team_channel_id) - self.set_field("loginMessageChannelId", lambda config, *_: config.login_message_channel_id) + self.set_field( + "loginMessageChannelId", lambda config, *_: config.login_message_channel_id + ) self.set_field("defaultRoleId", lambda config, *_: config.default_role_id) self.set_field( - "shortRoleNameOnlySetHighestRole", lambda config, *_: config.short_role_name_only_set_highest_role + "shortRoleNameOnlySetHighestRole", + lambda config, *_: config.short_role_name_only_set_highest_role, + ) + self.set_field( + "gameOfferNotificationChatId", + lambda config, *_: config.game_offer_notification_chat_id, ) - self.set_field("gameOfferNotificationChatId", lambda config, *_: config.game_offer_notification_chat_id) self.add_collection( "featureFlag", - lambda config, *_: List(any, [{"key": x, "value": config.feature_flags[x]} for x in config.feature_flags]), + lambda config, *_: List( + any, + [ + {"key": x, "value": config.feature_flags[x]} + for x in config.feature_flags + ], + ), ) self.set_field("afkChannelIds", lambda config, *_: config.afk_channel_ids) self.set_field( diff --git a/kdb-bot/src/bot_graphql/queries/server_history_query.py b/bot/src/bot_graphql/queries/server_history_query.py similarity index 100% rename from kdb-bot/src/bot_graphql/queries/server_history_query.py rename to bot/src/bot_graphql/queries/server_history_query.py diff --git a/kdb-bot/src/bot_graphql/queries/server_query.py b/bot/src/bot_graphql/queries/server_query.py similarity index 72% rename from kdb-bot/src/bot_graphql/queries/server_query.py rename to bot/src/bot_graphql/queries/server_query.py index 6ba77149..67879229 100644 --- a/kdb-bot/src/bot_graphql/queries/server_query.py +++ b/bot/src/bot_graphql/queries/server_query.py @@ -12,7 +12,9 @@ from bot_data.abc.level_repository_abc import LevelRepositoryABC from bot_data.abc.server_config_repository_abc import ServerConfigRepositoryABC from bot_data.abc.short_role_name_repository_abc import ShortRoleNameRepositoryABC from bot_data.abc.user_joined_server_repository_abc import UserJoinedServerRepositoryABC -from bot_data.abc.user_joined_voice_channel_repository_abc import UserJoinedVoiceChannelRepositoryABC +from bot_data.abc.user_joined_voice_channel_repository_abc import ( + UserJoinedVoiceChannelRepositoryABC, +) from bot_data.abc.user_repository_abc import UserRepositoryABC from bot_data.model.server import Server from bot_data.model.server_config import ServerConfig @@ -43,7 +45,9 @@ class ServerQuery(DataQueryWithHistoryABC): short_role_names: ShortRoleNameRepositoryABC, server_configs: ServerConfigRepositoryABC, ): - DataQueryWithHistoryABC.__init__(self, "Server", "ServersHistory", ServerHistory, db) + DataQueryWithHistoryABC.__init__( + self, "Server", "ServersHistory", ServerHistory, db + ) self._config = config self._bot = bot @@ -65,22 +69,45 @@ class ServerQuery(DataQueryWithHistoryABC): AutoRoleFilter, ) self.add_collection( - "client", lambda server, *_: self._clients.get_clients_by_server_id(server.id), ClientFilter + "client", + lambda server, *_: self._clients.get_clients_by_server_id(server.id), + ClientFilter, ) - self.add_collection("level", lambda server, *_: self._levels.get_levels_by_server_id(server.id), LevelFilter) - self.add_collection("user", lambda server, *_: self._users.get_users_by_server_id(server.id), UserFilter) - self.add_collection("gameServer", lambda server, *_: game_servers.get_game_servers_by_server_id(server.id)) self.add_collection( - "achievement", lambda server, *_: achievements.get_achievements_by_server_id(server.id), AchievementFilter + "level", + lambda server, *_: self._levels.get_levels_by_server_id(server.id), + LevelFilter, + ) + self.add_collection( + "user", + lambda server, *_: self._users.get_users_by_server_id(server.id), + UserFilter, + ) + self.add_collection( + "gameServer", + lambda server, *_: game_servers.get_game_servers_by_server_id(server.id), + ) + self.add_collection( + "achievement", + lambda server, *_: achievements.get_achievements_by_server_id(server.id), + AchievementFilter, ) self.add_collection( "shortRoleName", - lambda server, *_: short_role_names.get_short_role_names_by_server_id(server.id), + lambda server, *_: short_role_names.get_short_role_names_by_server_id( + server.id + ), ShortRoleNameFilter, ) - self.set_field("config", lambda server, *_: server_configs.get_server_config_by_server(server.id)) self.set_field( - "hasFeatureFlag", lambda server, *_, **kwargs: self._resolve_has_feature_flag(server, *_, **kwargs) + "config", + lambda server, *_: server_configs.get_server_config_by_server(server.id), + ) + self.set_field( + "hasFeatureFlag", + lambda server, *_, **kwargs: self._resolve_has_feature_flag( + server, *_, **kwargs + ), ) @staticmethod @@ -100,10 +127,14 @@ class ServerQuery(DataQueryWithHistoryABC): return server.icon_url def _resolve_has_feature_flag(self, server: Server, *_, **kwargs): - settings: ServerConfig = self._config.get_configuration(f"ServerConfig_{server.discord_id}") + settings: ServerConfig = self._config.get_configuration( + f"ServerConfig_{server.discord_id}" + ) if "flag" not in kwargs: return False return { "key": kwargs["flag"], - "value": FeatureFlagsSettings.get_flag_from_dict(settings.feature_flags, FeatureFlagsEnum(kwargs["flag"])), + "value": FeatureFlagsSettings.get_flag_from_dict( + settings.feature_flags, FeatureFlagsEnum(kwargs["flag"]) + ), } diff --git a/kdb-bot/src/bot_graphql/queries/short_role_name_history_query.py b/bot/src/bot_graphql/queries/short_role_name_history_query.py similarity index 100% rename from kdb-bot/src/bot_graphql/queries/short_role_name_history_query.py rename to bot/src/bot_graphql/queries/short_role_name_history_query.py diff --git a/kdb-bot/src/bot_graphql/queries/short_role_name_query.py b/bot/src/bot_graphql/queries/short_role_name_query.py similarity index 82% rename from kdb-bot/src/bot_graphql/queries/short_role_name_query.py rename to bot/src/bot_graphql/queries/short_role_name_query.py index 75d07ac6..6191aadd 100644 --- a/kdb-bot/src/bot_graphql/queries/short_role_name_query.py +++ b/bot/src/bot_graphql/queries/short_role_name_query.py @@ -9,7 +9,9 @@ class ShortRoleNameQuery(DataQueryWithHistoryABC): self, db: DatabaseContextABC, ): - DataQueryWithHistoryABC.__init__(self, "ShortRoleName", "ShortRoleNamesHistory", ShortRoleNameHistory, db) + DataQueryWithHistoryABC.__init__( + self, "ShortRoleName", "ShortRoleNamesHistory", ShortRoleNameHistory, db + ) self.set_field("id", lambda x, *_: x.id) self.set_field("shortName", lambda x, *_: x.short_name) diff --git a/kdb-bot/src/bot_graphql/queries/technician_config_history_query.py b/bot/src/bot_graphql/queries/technician_config_history_query.py similarity index 60% rename from kdb-bot/src/bot_graphql/queries/technician_config_history_query.py rename to bot/src/bot_graphql/queries/technician_config_history_query.py index a63f88f8..41ebbb54 100644 --- a/kdb-bot/src/bot_graphql/queries/technician_config_history_query.py +++ b/bot/src/bot_graphql/queries/technician_config_history_query.py @@ -7,11 +7,20 @@ class TechnicianConfigHistoryQuery(HistoryQueryABC): def __init__(self): HistoryQueryABC.__init__(self, "TechnicianConfig") - self.set_field("helpCommandReferenceUrl", lambda config, *_: config.help_command_reference_url) + self.set_field( + "helpCommandReferenceUrl", + lambda config, *_: config.help_command_reference_url, + ) self.set_field("waitForRestart", lambda config, *_: config.wait_for_restart) self.set_field("waitForShutdown", lambda config, *_: config.wait_for_shutdown) self.set_field("cacheMaxMessages", lambda config, *_: config.cache_max_messages) self.add_collection( "featureFlag", - lambda config, *_: List(any, [{"key": x, "value": config.feature_flags[x]} for x in config.feature_flags]), + lambda config, *_: List( + any, + [ + {"key": x, "value": config.feature_flags[x]} + for x in config.feature_flags + ], + ), ) diff --git a/kdb-bot/src/bot_graphql/queries/technician_config_query.py b/bot/src/bot_graphql/queries/technician_config_query.py similarity index 76% rename from kdb-bot/src/bot_graphql/queries/technician_config_query.py rename to bot/src/bot_graphql/queries/technician_config_query.py index 2d8bb8f9..a6363d9b 100644 --- a/kdb-bot/src/bot_graphql/queries/technician_config_query.py +++ b/bot/src/bot_graphql/queries/technician_config_query.py @@ -4,21 +4,38 @@ from cpl_query.extension import List from bot_data.abc.table_with_id_abc import TableWithIdABC from bot_data.model.technician_config_history import TechnicianConfigHistory from bot_data.model.technician_id_config_history import TechnicianIdConfigHistory -from bot_data.model.technician_ping_url_config_history import TechnicianPingUrlConfigHistory +from bot_data.model.technician_ping_url_config_history import ( + TechnicianPingUrlConfigHistory, +) from bot_graphql.abc.data_query_with_history_abc import DataQueryWithHistoryABC class TechnicianConfigQuery(DataQueryWithHistoryABC): def __init__(self, db: DatabaseContextABC): - DataQueryWithHistoryABC.__init__(self, "TechnicianConfig", "CFG_TechnicianHistory", TechnicianConfigHistory, db) + DataQueryWithHistoryABC.__init__( + self, + "TechnicianConfig", + "CFG_TechnicianHistory", + TechnicianConfigHistory, + db, + ) - self.set_field("helpCommandReferenceUrl", lambda config, *_: config.help_command_reference_url) + self.set_field( + "helpCommandReferenceUrl", + lambda config, *_: config.help_command_reference_url, + ) self.set_field("waitForRestart", lambda config, *_: config.wait_for_restart) self.set_field("waitForShutdown", lambda config, *_: config.wait_for_shutdown) self.set_field("cacheMaxMessages", lambda config, *_: config.cache_max_messages) self.add_collection( "featureFlag", - lambda config, *_: List(any, [{"key": x, "value": config.feature_flags[x]} for x in config.feature_flags]), + lambda config, *_: List( + any, + [ + {"key": x, "value": config.feature_flags[x]} + for x in config.feature_flags + ], + ), ) self.set_field("pingURLs", lambda config, *_: config.ping_urls) self.set_field("technicianIds", lambda config, *_: config.technician_ids) diff --git a/kdb-bot/src/bot_graphql/queries/technician_id_config_history_query.py b/bot/src/bot_graphql/queries/technician_id_config_history_query.py similarity index 100% rename from kdb-bot/src/bot_graphql/queries/technician_id_config_history_query.py rename to bot/src/bot_graphql/queries/technician_id_config_history_query.py diff --git a/kdb-bot/src/bot_graphql/queries/technician_ping_url_config_history_query.py b/bot/src/bot_graphql/queries/technician_ping_url_config_history_query.py similarity index 100% rename from kdb-bot/src/bot_graphql/queries/technician_ping_url_config_history_query.py rename to bot/src/bot_graphql/queries/technician_ping_url_config_history_query.py diff --git a/kdb-bot/src/bot_graphql/queries/user_history_query.py b/bot/src/bot_graphql/queries/user_history_query.py similarity index 100% rename from kdb-bot/src/bot_graphql/queries/user_history_query.py rename to bot/src/bot_graphql/queries/user_history_query.py diff --git a/kdb-bot/src/bot_graphql/queries/user_joined_game_server_history_query.py b/bot/src/bot_graphql/queries/user_joined_game_server_history_query.py similarity index 100% rename from kdb-bot/src/bot_graphql/queries/user_joined_game_server_history_query.py rename to bot/src/bot_graphql/queries/user_joined_game_server_history_query.py diff --git a/kdb-bot/src/bot_graphql/queries/user_joined_game_server_query.py b/bot/src/bot_graphql/queries/user_joined_game_server_query.py similarity index 90% rename from kdb-bot/src/bot_graphql/queries/user_joined_game_server_query.py rename to bot/src/bot_graphql/queries/user_joined_game_server_query.py index 6a5befaa..0ea7ceb3 100644 --- a/kdb-bot/src/bot_graphql/queries/user_joined_game_server_query.py +++ b/bot/src/bot_graphql/queries/user_joined_game_server_query.py @@ -9,7 +9,11 @@ from bot_graphql.abc.data_query_with_history_abc import DataQueryWithHistoryABC class UserJoinedGameServerQuery(DataQueryWithHistoryABC): def __init__(self, bot: DiscordBotServiceABC, db: DatabaseContextABC): DataQueryWithHistoryABC.__init__( - self, "UserJoinedGameServer", "UserJoinedGameServersHistory", UserJoinedGameServerHistory, db + self, + "UserJoinedGameServer", + "UserJoinedGameServersHistory", + UserJoinedGameServerHistory, + db, ) self._bot = bot diff --git a/kdb-bot/src/bot_graphql/queries/user_joined_server_history_query.py b/bot/src/bot_graphql/queries/user_joined_server_history_query.py similarity index 100% rename from kdb-bot/src/bot_graphql/queries/user_joined_server_history_query.py rename to bot/src/bot_graphql/queries/user_joined_server_history_query.py diff --git a/kdb-bot/src/bot_graphql/queries/user_joined_server_query.py b/bot/src/bot_graphql/queries/user_joined_server_query.py similarity index 87% rename from kdb-bot/src/bot_graphql/queries/user_joined_server_query.py rename to bot/src/bot_graphql/queries/user_joined_server_query.py index a8e236ff..db9967f4 100644 --- a/kdb-bot/src/bot_graphql/queries/user_joined_server_query.py +++ b/bot/src/bot_graphql/queries/user_joined_server_query.py @@ -8,7 +8,11 @@ from bot_graphql.abc.data_query_with_history_abc import DataQueryWithHistoryABC class UserJoinedServerQuery(DataQueryWithHistoryABC): def __init__(self, db: DatabaseContextABC): DataQueryWithHistoryABC.__init__( - self, "UserJoinedServer", "UserJoinedServersHistory", UserJoinedServerHistory, db + self, + "UserJoinedServer", + "UserJoinedServersHistory", + UserJoinedServerHistory, + db, ) self.set_field("id", self.resolve_id) diff --git a/kdb-bot/src/bot_graphql/queries/user_joined_voice_channel_history_query.py b/bot/src/bot_graphql/queries/user_joined_voice_channel_history_query.py similarity index 100% rename from kdb-bot/src/bot_graphql/queries/user_joined_voice_channel_history_query.py rename to bot/src/bot_graphql/queries/user_joined_voice_channel_history_query.py diff --git a/kdb-bot/src/bot_graphql/queries/user_joined_voice_channel_query.py b/bot/src/bot_graphql/queries/user_joined_voice_channel_query.py similarity index 85% rename from kdb-bot/src/bot_graphql/queries/user_joined_voice_channel_query.py rename to bot/src/bot_graphql/queries/user_joined_voice_channel_query.py index a5465581..15a8af9c 100644 --- a/kdb-bot/src/bot_graphql/queries/user_joined_voice_channel_query.py +++ b/bot/src/bot_graphql/queries/user_joined_voice_channel_query.py @@ -2,14 +2,20 @@ from cpl_core.database.context import DatabaseContextABC from cpl_discord.service import DiscordBotServiceABC from bot_data.model.user_joined_voice_channel import UserJoinedVoiceChannel -from bot_data.model.user_joined_voice_channel_history import UserJoinedVoiceChannelHistory +from bot_data.model.user_joined_voice_channel_history import ( + UserJoinedVoiceChannelHistory, +) from bot_graphql.abc.data_query_with_history_abc import DataQueryWithHistoryABC class UserJoinedVoiceChannelQuery(DataQueryWithHistoryABC): def __init__(self, bot: DiscordBotServiceABC, db: DatabaseContextABC): DataQueryWithHistoryABC.__init__( - self, "UserJoinedVoiceChannel", "UserJoinedVoiceChannelsHistory", UserJoinedVoiceChannelHistory, db + self, + "UserJoinedVoiceChannel", + "UserJoinedVoiceChannelsHistory", + UserJoinedVoiceChannelHistory, + db, ) self._bot = bot diff --git a/kdb-bot/src/bot_graphql/queries/user_query.py b/bot/src/bot_graphql/queries/user_query.py similarity index 88% rename from kdb-bot/src/bot_graphql/queries/user_query.py rename to bot/src/bot_graphql/queries/user_query.py index c04fbcc9..d91d5043 100644 --- a/kdb-bot/src/bot_graphql/queries/user_query.py +++ b/bot/src/bot_graphql/queries/user_query.py @@ -3,9 +3,13 @@ from cpl_discord.service import DiscordBotServiceABC from bot_core.abc.client_utils_abc import ClientUtilsABC from bot_data.abc.achievement_repository_abc import AchievementRepositoryABC -from bot_data.abc.user_joined_game_server_repository_abc import UserJoinedGameServerRepositoryABC +from bot_data.abc.user_joined_game_server_repository_abc import ( + UserJoinedGameServerRepositoryABC, +) from bot_data.abc.user_joined_server_repository_abc import UserJoinedServerRepositoryABC -from bot_data.abc.user_joined_voice_channel_repository_abc import UserJoinedVoiceChannelRepositoryABC +from bot_data.abc.user_joined_voice_channel_repository_abc import ( + UserJoinedVoiceChannelRepositoryABC, +) from bot_data.abc.user_warnings_repository_abc import UserWarningsRepositoryABC from bot_data.model.user import User from bot_data.model.user_history import UserHistory @@ -13,7 +17,9 @@ from bot_graphql.abc.data_query_with_history_abc import DataQueryWithHistoryABC from bot_graphql.filter.achievement_filter import AchievementFilter from bot_graphql.filter.user_joined_game_server_filter import UserJoinedGameServerFilter from bot_graphql.filter.user_joined_server_filter import UserJoinedServerFilter -from bot_graphql.filter.user_joined_voice_channel_filter import UserJoinedVoiceChannelFilter +from bot_graphql.filter.user_joined_voice_channel_filter import ( + UserJoinedVoiceChannelFilter, +) from bot_graphql.filter.user_warning_filter import UserWarningFilter from modules.level.service.level_service import LevelService from modules.permission.abc.permission_service_abc import PermissionServiceABC @@ -60,19 +66,27 @@ class UserQuery(DataQueryWithHistoryABC): ) self.add_collection( "joinedVoiceChannel", - lambda user, *_: self._ujvs.get_user_joined_voice_channels_by_user_id(user.id), + lambda user, *_: self._ujvs.get_user_joined_voice_channels_by_user_id( + user.id + ), UserJoinedVoiceChannelFilter, ) self.add_collection( "userJoinedGameServer", - lambda user, *_: self._user_joined_game_server.get_user_joined_game_servers_by_user_id(user.id), + lambda user, *_: self._user_joined_game_server.get_user_joined_game_servers_by_user_id( + user.id + ), UserJoinedGameServerFilter, ) self.add_collection( - "achievement", lambda user, *_: achievements.get_achievements_by_user_id(user.id), AchievementFilter + "achievement", + lambda user, *_: achievements.get_achievements_by_user_id(user.id), + AchievementFilter, ) self.add_collection( - "userWarning", lambda user, *_: user_warnings.get_user_warnings_by_user_id(user.id), UserWarningFilter + "userWarning", + lambda user, *_: user_warnings.get_user_warnings_by_user_id(user.id), + UserWarningFilter, ) self.set_field("server", self.resolve_server) diff --git a/kdb-bot/src/bot_graphql/queries/user_warning_history_query.py b/bot/src/bot_graphql/queries/user_warning_history_query.py similarity index 100% rename from kdb-bot/src/bot_graphql/queries/user_warning_history_query.py rename to bot/src/bot_graphql/queries/user_warning_history_query.py diff --git a/kdb-bot/src/bot_graphql/queries/user_warning_query.py b/bot/src/bot_graphql/queries/user_warning_query.py similarity index 80% rename from kdb-bot/src/bot_graphql/queries/user_warning_query.py rename to bot/src/bot_graphql/queries/user_warning_query.py index f6243d5e..c738e0d7 100644 --- a/kdb-bot/src/bot_graphql/queries/user_warning_query.py +++ b/bot/src/bot_graphql/queries/user_warning_query.py @@ -9,7 +9,9 @@ class UserWarningQuery(DataQueryWithHistoryABC): self, db: DatabaseContextABC, ): - DataQueryWithHistoryABC.__init__(self, "UserWarning", "UserWarningsHistory", UserWarningsHistory, db) + DataQueryWithHistoryABC.__init__( + self, "UserWarning", "UserWarningsHistory", UserWarningsHistory, db + ) self.set_field("id", lambda x, *_: x.id) self.set_field("user", lambda x, *_: x.user) diff --git a/kdb-bot/src/bot_graphql/query.py b/bot/src/bot_graphql/query.py similarity index 70% rename from kdb-bot/src/bot_graphql/query.py rename to bot/src/bot_graphql/query.py index 5ddb67dd..602fe555 100644 --- a/kdb-bot/src/bot_graphql/query.py +++ b/bot/src/bot_graphql/query.py @@ -11,9 +11,13 @@ from bot_data.abc.level_repository_abc import LevelRepositoryABC from bot_data.abc.server_repository_abc import ServerRepositoryABC from bot_data.abc.short_role_name_repository_abc import ShortRoleNameRepositoryABC from bot_data.abc.technician_config_repository_abc import TechnicianConfigRepositoryABC -from bot_data.abc.user_joined_game_server_repository_abc import UserJoinedGameServerRepositoryABC +from bot_data.abc.user_joined_game_server_repository_abc import ( + UserJoinedGameServerRepositoryABC, +) from bot_data.abc.user_joined_server_repository_abc import UserJoinedServerRepositoryABC -from bot_data.abc.user_joined_voice_channel_repository_abc import UserJoinedVoiceChannelRepositoryABC +from bot_data.abc.user_joined_voice_channel_repository_abc import ( + UserJoinedVoiceChannelRepositoryABC, +) from bot_data.abc.user_repository_abc import UserRepositoryABC from bot_data.abc.user_warnings_repository_abc import UserWarningsRepositoryABC from bot_data.model.short_role_name_position_enum import ShortRoleNamePositionEnum @@ -28,7 +32,9 @@ from bot_graphql.filter.short_role_name_filter import ShortRoleNameFilter from bot_graphql.filter.user_filter import UserFilter from bot_graphql.filter.user_joined_game_server_filter import UserJoinedGameServerFilter from bot_graphql.filter.user_joined_server_filter import UserJoinedServerFilter -from bot_graphql.filter.user_joined_voice_channel_filter import UserJoinedVoiceChannelFilter +from bot_graphql.filter.user_joined_voice_channel_filter import ( + UserJoinedVoiceChannelFilter, +) from bot_graphql.filter.user_warning_filter import UserWarningFilter from bot_graphql.model.discord import Discord from modules.achievements.achievement_service import AchievementService @@ -56,15 +62,23 @@ class Query(QueryABC): ): QueryABC.__init__(self, "Query") - self.add_collection("autoRole", lambda *_: auto_roles.get_auto_roles(), AutoRoleFilter) - self.add_collection("autoRoleRule", lambda *_: auto_roles.get_auto_role_rules(), AutoRoleRuleFilter) + self.add_collection( + "autoRole", lambda *_: auto_roles.get_auto_roles(), AutoRoleFilter + ) + self.add_collection( + "autoRoleRule", + lambda *_: auto_roles.get_auto_role_rules(), + AutoRoleRuleFilter, + ) self.add_collection("client", lambda *_: clients.get_clients(), ClientFilter) self.add_collection("knownUser", lambda *_: known_users.get_users()) self.add_collection("level", lambda *_: levels.get_levels(), LevelFilter) self.add_collection("server", lambda *_: servers.get_servers(), ServerFilter) self.add_collection("gameServer", lambda *_: game_servers.get_game_servers()) self.add_collection( - "userJoinedServer", lambda *_: user_joined_servers.get_user_joined_servers(), UserJoinedServerFilter + "userJoinedServer", + lambda *_: user_joined_servers.get_user_joined_servers(), + UserJoinedServerFilter, ) self.add_collection( "userJoinedVoiceChannel", @@ -77,15 +91,38 @@ class Query(QueryABC): UserJoinedGameServerFilter, ) self.add_collection("user", lambda *_: users.get_users(), UserFilter) - self.add_collection("achievement", lambda *_: achievements.get_achievements(), AchievementFilter) - self.add_collection("shortRoleName", lambda *_: short_role_names.get_short_role_names(), ShortRoleNameFilter) - self.add_collection("userWarning", lambda *_: user_warnings.get_user_warnings(), UserWarningFilter) + self.add_collection( + "achievement", lambda *_: achievements.get_achievements(), AchievementFilter + ) + self.add_collection( + "shortRoleName", + lambda *_: short_role_names.get_short_role_names(), + ShortRoleNameFilter, + ) + self.add_collection( + "userWarning", + lambda *_: user_warnings.get_user_warnings(), + UserWarningFilter, + ) - self.set_field("technicianConfig", lambda *_: technician_config.get_technician_config()) + self.set_field( + "technicianConfig", lambda *_: technician_config.get_technician_config() + ) - self.set_field("achievementAttributes", lambda *_: achievement_service.get_attributes()) - self.set_field("achievementOperators", lambda *_: achievement_service.get_operators()) - self.set_field("shortRoleNamePositions", lambda *_: [x.value for x in ShortRoleNamePositionEnum]) + self.set_field( + "achievementAttributes", lambda *_: achievement_service.get_attributes() + ) + self.set_field( + "achievementOperators", lambda *_: achievement_service.get_operators() + ) + self.set_field( + "shortRoleNamePositions", + lambda *_: [x.value for x in ShortRoleNamePositionEnum], + ) - self.set_field("possibleFeatureFlags", lambda *_: [e.value for e in FeatureFlagsEnum]) - self.set_field("discord", lambda *_: Discord(bot.guilds, List(any).extend(bot.users))) + self.set_field( + "possibleFeatureFlags", lambda *_: [e.value for e in FeatureFlagsEnum] + ) + self.set_field( + "discord", lambda *_: Discord(bot.guilds, List(any).extend(bot.users)) + ) diff --git a/kdb-bot/src/bot_graphql/schema.py b/bot/src/bot_graphql/schema.py similarity index 78% rename from kdb-bot/src/bot_graphql/schema.py rename to bot/src/bot_graphql/schema.py index 020efbc8..5e09a19c 100644 --- a/kdb-bot/src/bot_graphql/schema.py +++ b/bot/src/bot_graphql/schema.py @@ -10,7 +10,9 @@ from bot_graphql.query import Query class Schema: def __init__(self, query: Query, mutation: Mutation, queries: list[QueryABC]): - type_defs = load_schema_from_path(os.path.join(os.path.dirname(os.path.realpath(__file__)), "graphql/")) + type_defs = load_schema_from_path( + os.path.join(os.path.dirname(os.path.realpath(__file__)), "graphql/") + ) self._schema = make_executable_schema(type_defs, query, mutation, *queries) @property diff --git a/kdb-bot/src/modules/__init__.py b/bot/src/modules/__init__.py similarity index 100% rename from kdb-bot/src/modules/__init__.py rename to bot/src/modules/__init__.py diff --git a/kdb-bot/src/modules/achievements/__init__.py b/bot/src/modules/achievements/__init__.py similarity index 100% rename from kdb-bot/src/modules/achievements/__init__.py rename to bot/src/modules/achievements/__init__.py diff --git a/kdb-bot/src/modules/achievements/achievement_attribute_resolver.py b/bot/src/modules/achievements/achievement_attribute_resolver.py similarity index 80% rename from kdb-bot/src/modules/achievements/achievement_attribute_resolver.py rename to bot/src/modules/achievements/achievement_attribute_resolver.py index f08f1579..7de2ee0b 100644 --- a/kdb-bot/src/modules/achievements/achievement_attribute_resolver.py +++ b/bot/src/modules/achievements/achievement_attribute_resolver.py @@ -7,9 +7,13 @@ from bot_data.abc.game_server_repository_abc import GameServerRepositoryABC from bot_data.abc.known_user_repository_abc import KnownUserRepositoryABC from bot_data.abc.level_repository_abc import LevelRepositoryABC from bot_data.abc.server_repository_abc import ServerRepositoryABC -from bot_data.abc.user_joined_game_server_repository_abc import UserJoinedGameServerRepositoryABC +from bot_data.abc.user_joined_game_server_repository_abc import ( + UserJoinedGameServerRepositoryABC, +) from bot_data.abc.user_joined_server_repository_abc import UserJoinedServerRepositoryABC -from bot_data.abc.user_joined_voice_channel_repository_abc import UserJoinedVoiceChannelRepositoryABC +from bot_data.abc.user_joined_voice_channel_repository_abc import ( + UserJoinedVoiceChannelRepositoryABC, +) from bot_data.abc.user_repository_abc import UserRepositoryABC from bot_data.model.user import User @@ -42,9 +46,22 @@ class AchievementAttributeResolver: self._achievements = achievements def get_played_on_game_server(self, user: User) -> List[str]: - joins = self._user_joined_game_server.get_user_joined_game_servers_by_user_id(user.id) + joins = self._user_joined_game_server.get_user_joined_game_servers_by_user_id( + user.id + ) return joins.select(lambda x: x.game_server.name) def get_last_ontime_hours(self, user: User) -> int: - ujvs = self._user_joined_voice_channels.get_user_joined_voice_channels_by_user_id(user.id) - return int(str(ujvs.max(lambda join: (join.leaved_on - join.joined_on).total_seconds() / 3600))) + ujvs = ( + self._user_joined_voice_channels.get_user_joined_voice_channels_by_user_id( + user.id + ) + ) + return int( + str( + ujvs.max( + lambda join: (join.leaved_on - join.joined_on).total_seconds() + / 3600 + ) + ) + ) diff --git a/kdb-bot/src/modules/achievements/achievement_service.py b/bot/src/modules/achievements/achievement_service.py similarity index 68% rename from kdb-bot/src/modules/achievements/achievement_service.py rename to bot/src/modules/achievements/achievement_service.py index d7b2a455..9d3bbac5 100644 --- a/kdb-bot/src/modules/achievements/achievement_service.py +++ b/bot/src/modules/achievements/achievement_service.py @@ -12,7 +12,9 @@ from bot_data.model.achievement import Achievement from bot_data.model.server_config import ServerConfig from bot_data.model.user import User from bot_data.model.user_got_achievement import UserGotAchievement -from modules.achievements.achievement_attribute_resolver import AchievementAttributeResolver +from modules.achievements.achievement_attribute_resolver import ( + AchievementAttributeResolver, +) from modules.achievements.model.achievement_attribute import AchievementAttribute @@ -43,16 +45,24 @@ class AchievementService: self._attributes.extend( [ AchievementAttribute("xp", lambda user: user.xp, "number"), - AchievementAttribute("message_count", lambda user: user.message_count, "number"), - AchievementAttribute("reaction_count", lambda user: user.reaction_count, "number"), + AchievementAttribute( + "message_count", lambda user: user.message_count, "number" + ), + AchievementAttribute( + "reaction_count", lambda user: user.reaction_count, "number" + ), AchievementAttribute("ontime", lambda user: user.ontime, "number"), AchievementAttribute("level", lambda user: user.level, "Level"), # special cases AchievementAttribute( - "played_on_game_server", lambda user: resolver.get_played_on_game_server(user), "GameServer" + "played_on_game_server", + lambda user: resolver.get_played_on_game_server(user), + "GameServer", ), AchievementAttribute( - "last_single_ontime_hours", lambda user: resolver.get_last_ontime_hours(user), "number" + "last_single_ontime_hours", + lambda user: resolver.get_last_ontime_hours(user), + "number", ), ] ) @@ -60,10 +70,14 @@ class AchievementService: self._operators = { "==": lambda value, expected_value: value == expected_value, "!=": lambda value, expected_value: value != expected_value, - "<=": lambda value, expected_value: self._num(value) <= self._num(expected_value), - ">=": lambda value, expected_value: self._num(value) >= self._num(expected_value), - "<": lambda value, expected_value: self._num(value) < self._num(expected_value), - ">": lambda value, expected_value: self._num(value) > self._num(expected_value), + "<=": lambda value, expected_value: self._num(value) + <= self._num(expected_value), + ">=": lambda value, expected_value: self._num(value) + >= self._num(expected_value), + "<": lambda value, expected_value: self._num(value) + < self._num(expected_value), + ">": lambda value, expected_value: self._num(value) + > self._num(expected_value), "contains": lambda value, expected_value: expected_value in value, } @@ -86,37 +100,57 @@ class AchievementService: def _match(self, value: any, operator: str, expected_value: str) -> bool: return self._operators[operator](str(value), expected_value) - def has_user_achievement_already(self, user: User, achievement: Achievement) -> bool: + def has_user_achievement_already( + self, user: User, achievement: Achievement + ) -> bool: user_achievements = self._achievements.get_achievements_by_user_id(user.id) return user_achievements.where(lambda x: x.name == achievement.name).count() > 0 def has_user_achievement(self, user: User, achievement: Achievement) -> bool: - attribute: AchievementAttribute = self._attributes.where(lambda x: x.name == achievement.attribute).single() - return self._match(attribute.resolve(user), achievement.operator, achievement.value) + attribute: AchievementAttribute = self._attributes.where( + lambda x: x.name == achievement.attribute + ).single() + return self._match( + attribute.resolve(user), achievement.operator, achievement.value + ) async def validate_achievements_for_user(self, user: User): achievements = self._achievements.get_achievements_by_server_id(user.server.id) for achievement in achievements: - if self.has_user_achievement_already(user, achievement) or not self.has_user_achievement(user, achievement): + if self.has_user_achievement_already( + user, achievement + ) or not self.has_user_achievement(user, achievement): continue - self._achievements.add_user_got_achievement(UserGotAchievement(user, achievement, user.server)) + self._achievements.add_user_got_achievement( + UserGotAchievement(user, achievement, user.server) + ) self._db.save_changes() self._give_user_xp(user) - await self._send_achievement_notification(user.server.discord_id, user.discord_id, achievement.name) + await self._send_achievement_notification( + user.server.discord_id, user.discord_id, achievement.name + ) def _give_user_xp(self, user: User): - settings: ServerConfig = self._config.get_configuration(f"ServerConfig_{user.server.discord_id}") + settings: ServerConfig = self._config.get_configuration( + f"ServerConfig_{user.server.discord_id}" + ) user.xp += settings.xp_per_achievement self._users.update_user(user) self._db.save_changes() - async def _send_achievement_notification(self, guild_id: int, member_id: int, achievement_name: str): + async def _send_achievement_notification( + self, guild_id: int, member_id: int, achievement_name: str + ): member = self._bot.get_guild(guild_id).get_member(member_id) - settings: ServerConfig = self._config.get_configuration(f"ServerConfig_{guild_id}") + settings: ServerConfig = self._config.get_configuration( + f"ServerConfig_{guild_id}" + ) await self._message_service.send_channel_message( self._bot.get_channel(settings.notification_chat_id), - self._t.transform("modules.achievements.got_new_achievement").format(member.mention, achievement_name), + self._t.transform("modules.achievements.got_new_achievement").format( + member.mention, achievement_name + ), is_persistent=True, ) diff --git a/kdb-bot/src/modules/achievements/achievements.json b/bot/src/modules/achievements/achievements.json similarity index 100% rename from kdb-bot/src/modules/achievements/achievements.json rename to bot/src/modules/achievements/achievements.json diff --git a/kdb-bot/src/modules/achievements/achievements_module.py b/bot/src/modules/achievements/achievements_module.py similarity index 55% rename from kdb-bot/src/modules/achievements/achievements_module.py rename to bot/src/modules/achievements/achievements_module.py index 8ea61396..cc7c5ec6 100644 --- a/kdb-bot/src/modules/achievements/achievements_module.py +++ b/bot/src/modules/achievements/achievements_module.py @@ -6,29 +6,53 @@ from cpl_discord.service.discord_collection_abc import DiscordCollectionABC from bot_core.abc.module_abc import ModuleABC from bot_core.configuration.feature_flags_enum import FeatureFlagsEnum -from modules.achievements.achievement_attribute_resolver import AchievementAttributeResolver +from modules.achievements.achievement_attribute_resolver import ( + AchievementAttributeResolver, +) from modules.achievements.achievement_service import AchievementService from modules.achievements.commands.achievements_group import AchievementGroup -from modules.achievements.events.achievement_on_message_event import AchievementOnMessageEvent -from modules.achievements.events.achievement_on_reaction_add_event import AchievementOnReactionAddEvent -from modules.achievements.events.achievement_on_reaction_remove_event import AchievementOnReactionRemoveEvent -from modules.achievements.events.achievement_on_voice_state_update_event import AchievementOnVoiceStateUpdateEvent +from modules.achievements.events.achievement_on_message_event import ( + AchievementOnMessageEvent, +) +from modules.achievements.events.achievement_on_reaction_add_event import ( + AchievementOnReactionAddEvent, +) +from modules.achievements.events.achievement_on_reaction_remove_event import ( + AchievementOnReactionRemoveEvent, +) +from modules.achievements.events.achievement_on_voice_state_update_event import ( + AchievementOnVoiceStateUpdateEvent, +) class AchievementsModule(ModuleABC): def __init__(self, dc: DiscordCollectionABC): ModuleABC.__init__(self, dc, FeatureFlagsEnum.achievements_module) - def configure_configuration(self, config: ConfigurationABC, env: ApplicationEnvironmentABC): + def configure_configuration( + self, config: ConfigurationABC, env: ApplicationEnvironmentABC + ): pass - def configure_services(self, services: ServiceCollectionABC, env: ApplicationEnvironmentABC): + def configure_services( + self, services: ServiceCollectionABC, env: ApplicationEnvironmentABC + ): services.add_transient(AchievementAttributeResolver) services.add_transient(AchievementService) services.add_transient(AchievementGroup) - services.add_transient(DiscordEventTypesEnum.on_message.value, AchievementOnMessageEvent) - services.add_transient(DiscordEventTypesEnum.on_reaction_add.value, AchievementOnReactionAddEvent) - services.add_transient(DiscordEventTypesEnum.on_reaction_remove.value, AchievementOnReactionRemoveEvent) - services.add_transient(DiscordEventTypesEnum.on_voice_state_update.value, AchievementOnVoiceStateUpdateEvent) + services.add_transient( + DiscordEventTypesEnum.on_message.value, AchievementOnMessageEvent + ) + services.add_transient( + DiscordEventTypesEnum.on_reaction_add.value, AchievementOnReactionAddEvent + ) + services.add_transient( + DiscordEventTypesEnum.on_reaction_remove.value, + AchievementOnReactionRemoveEvent, + ) + services.add_transient( + DiscordEventTypesEnum.on_voice_state_update.value, + AchievementOnVoiceStateUpdateEvent, + ) diff --git a/kdb-bot/src/modules/achievements/commands/__init__.py b/bot/src/modules/achievements/commands/__init__.py similarity index 100% rename from kdb-bot/src/modules/achievements/commands/__init__.py rename to bot/src/modules/achievements/commands/__init__.py diff --git a/kdb-bot/src/modules/achievements/commands/achievements_group.py b/bot/src/modules/achievements/commands/achievements_group.py similarity index 97% rename from kdb-bot/src/modules/achievements/commands/achievements_group.py rename to bot/src/modules/achievements/commands/achievements_group.py index a0c73ccb..497dfe4c 100644 --- a/kdb-bot/src/modules/achievements/commands/achievements_group.py +++ b/bot/src/modules/achievements/commands/achievements_group.py @@ -54,7 +54,9 @@ class AchievementGroup(DiscordCommandABC): if ctx.guild is None: return - server_config: ServerConfig = self._config.get_configuration(f"ServerConfig_{ctx.guild.id}") + server_config: ServerConfig = self._config.get_configuration( + f"ServerConfig_{ctx.guild.id}" + ) if not FeatureFlagsSettings.get_flag_from_dict( server_config.feature_flags, FeatureFlagsEnum.achievements_module ): diff --git a/kdb-bot/src/modules/achievements/events/__init__.py b/bot/src/modules/achievements/events/__init__.py similarity index 100% rename from kdb-bot/src/modules/achievements/events/__init__.py rename to bot/src/modules/achievements/events/__init__.py diff --git a/kdb-bot/src/modules/achievements/events/achievement_on_message_event.py b/bot/src/modules/achievements/events/achievement_on_message_event.py similarity index 94% rename from kdb-bot/src/modules/achievements/events/achievement_on_message_event.py rename to bot/src/modules/achievements/events/achievement_on_message_event.py index b3564ccf..1cb6a9ee 100644 --- a/kdb-bot/src/modules/achievements/events/achievement_on_message_event.py +++ b/bot/src/modules/achievements/events/achievement_on_message_event.py @@ -43,14 +43,18 @@ class AchievementOnMessageEvent(OnMessageABC): if message.author.bot: return - server_config: ServerConfig = self._config.get_configuration(f"ServerConfig_{message.guild.id}") + server_config: ServerConfig = self._config.get_configuration( + f"ServerConfig_{message.guild.id}" + ) if not FeatureFlagsSettings.get_flag_from_dict( server_config.feature_flags, FeatureFlagsEnum.achievements_module ): return server = self._servers.get_server_by_discord_id(message.guild.id) - user = self._users.get_user_by_discord_id_and_server_id(message.author.id, server.id) + user = self._users.get_user_by_discord_id_and_server_id( + message.author.id, server.id + ) user.message_count += 1 self._users.update_user(user) diff --git a/kdb-bot/src/modules/achievements/events/achievement_on_reaction_add_event.py b/bot/src/modules/achievements/events/achievement_on_reaction_add_event.py similarity index 90% rename from kdb-bot/src/modules/achievements/events/achievement_on_reaction_add_event.py rename to bot/src/modules/achievements/events/achievement_on_reaction_add_event.py index b033b534..cb4fcec9 100644 --- a/kdb-bot/src/modules/achievements/events/achievement_on_reaction_add_event.py +++ b/bot/src/modules/achievements/events/achievement_on_reaction_add_event.py @@ -36,7 +36,11 @@ class AchievementOnReactionAddEvent(OnReactionAddABC): self._servers = servers self._users = users - async def on_reaction_add(self, reaction: discord.reaction.Reaction, user: Union[discord.Member, discord.User]): + async def on_reaction_add( + self, + reaction: discord.reaction.Reaction, + user: Union[discord.Member, discord.User], + ): if not isinstance(user, discord.Member): return @@ -46,7 +50,9 @@ class AchievementOnReactionAddEvent(OnReactionAddABC): if user.bot: return - server_config: ServerConfig = self._config.get_configuration(f"ServerConfig_{user.guild.id}") + server_config: ServerConfig = self._config.get_configuration( + f"ServerConfig_{user.guild.id}" + ) if not FeatureFlagsSettings.get_flag_from_dict( server_config.feature_flags, FeatureFlagsEnum.achievements_module ): diff --git a/kdb-bot/src/modules/achievements/events/achievement_on_reaction_remove_event.py b/bot/src/modules/achievements/events/achievement_on_reaction_remove_event.py similarity index 90% rename from kdb-bot/src/modules/achievements/events/achievement_on_reaction_remove_event.py rename to bot/src/modules/achievements/events/achievement_on_reaction_remove_event.py index bbb33f28..63aacffc 100644 --- a/kdb-bot/src/modules/achievements/events/achievement_on_reaction_remove_event.py +++ b/bot/src/modules/achievements/events/achievement_on_reaction_remove_event.py @@ -36,7 +36,11 @@ class AchievementOnReactionRemoveEvent(OnReactionRemoveABC): self._servers = servers self._users = users - async def on_reaction_remove(self, reaction: discord.reaction.Reaction, user: Union[discord.Member, discord.User]): + async def on_reaction_remove( + self, + reaction: discord.reaction.Reaction, + user: Union[discord.Member, discord.User], + ): if not isinstance(user, discord.Member): return @@ -46,7 +50,9 @@ class AchievementOnReactionRemoveEvent(OnReactionRemoveABC): if user.bot: return - server_config: ServerConfig = self._config.get_configuration(f"ServerConfig_{user.guild.id}") + server_config: ServerConfig = self._config.get_configuration( + f"ServerConfig_{user.guild.id}" + ) if not FeatureFlagsSettings.get_flag_from_dict( server_config.feature_flags, FeatureFlagsEnum.achievements_module ): diff --git a/kdb-bot/src/modules/achievements/events/achievement_on_voice_state_update_event.py b/bot/src/modules/achievements/events/achievement_on_voice_state_update_event.py similarity index 90% rename from kdb-bot/src/modules/achievements/events/achievement_on_voice_state_update_event.py rename to bot/src/modules/achievements/events/achievement_on_voice_state_update_event.py index 6f60e06e..d7c5aeb7 100644 --- a/kdb-bot/src/modules/achievements/events/achievement_on_voice_state_update_event.py +++ b/bot/src/modules/achievements/events/achievement_on_voice_state_update_event.py @@ -35,7 +35,10 @@ class AchievementOnVoiceStateUpdateEvent(OnVoiceStateUpdateABC): self._users = users async def on_voice_state_update( - self, member: discord.member.Member, before: discord.member.VoiceState, after: discord.member.VoiceState + self, + member: discord.member.Member, + before: discord.member.VoiceState, + after: discord.member.VoiceState, ): if member.guild is None: return @@ -43,7 +46,9 @@ class AchievementOnVoiceStateUpdateEvent(OnVoiceStateUpdateABC): if member.bot: return - server_config: ServerConfig = self._config.get_configuration(f"ServerConfig_{member.guild.id}") + server_config: ServerConfig = self._config.get_configuration( + f"ServerConfig_{member.guild.id}" + ) if not FeatureFlagsSettings.get_flag_from_dict( server_config.feature_flags, FeatureFlagsEnum.achievements_module ): diff --git a/kdb-bot/src/modules/achievements/model/__init__.py b/bot/src/modules/achievements/model/__init__.py similarity index 100% rename from kdb-bot/src/modules/achievements/model/__init__.py rename to bot/src/modules/achievements/model/__init__.py diff --git a/kdb-bot/src/modules/achievements/model/achievement_attribute.py b/bot/src/modules/achievements/model/achievement_attribute.py similarity index 100% rename from kdb-bot/src/modules/achievements/model/achievement_attribute.py rename to bot/src/modules/achievements/model/achievement_attribute.py diff --git a/kdb-bot/src/modules/auto_role/__init__.py b/bot/src/modules/auto_role/__init__.py similarity index 100% rename from kdb-bot/src/modules/auto_role/__init__.py rename to bot/src/modules/auto_role/__init__.py diff --git a/kdb-bot/src/modules/auto_role/auto-role.json b/bot/src/modules/auto_role/auto-role.json similarity index 100% rename from kdb-bot/src/modules/auto_role/auto-role.json rename to bot/src/modules/auto_role/auto-role.json diff --git a/kdb-bot/src/modules/auto_role/auto_role_module.py b/bot/src/modules/auto_role/auto_role_module.py similarity index 86% rename from kdb-bot/src/modules/auto_role/auto_role_module.py rename to bot/src/modules/auto_role/auto_role_module.py index 07eba97e..4fee55e8 100644 --- a/kdb-bot/src/modules/auto_role/auto_role_module.py +++ b/bot/src/modules/auto_role/auto_role_module.py @@ -20,10 +20,14 @@ class AutoRoleModule(ModuleABC): def __init__(self, dc: DiscordCollectionABC): ModuleABC.__init__(self, dc, FeatureFlagsEnum.auto_role_module) - def configure_configuration(self, config: ConfigurationABC, env: ApplicationEnvironmentABC): + def configure_configuration( + self, config: ConfigurationABC, env: ApplicationEnvironmentABC + ): pass - def configure_services(self, services: ServiceCollectionABC, env: ApplicationEnvironmentABC): + def configure_services( + self, services: ServiceCollectionABC, env: ApplicationEnvironmentABC + ): services.add_transient(AutoRoleReactionHandler) # commands services.add_transient(AutoRoleGroup) diff --git a/kdb-bot/src/modules/auto_role/command/__init__.py b/bot/src/modules/auto_role/command/__init__.py similarity index 100% rename from kdb-bot/src/modules/auto_role/command/__init__.py rename to bot/src/modules/auto_role/command/__init__.py diff --git a/kdb-bot/src/modules/auto_role/command/auto_role_group.py b/bot/src/modules/auto_role/command/auto_role_group.py similarity index 74% rename from kdb-bot/src/modules/auto_role/command/auto_role_group.py rename to bot/src/modules/auto_role/command/auto_role_group.py index 58b8532c..6e5ae53c 100644 --- a/kdb-bot/src/modules/auto_role/command/auto_role_group.py +++ b/bot/src/modules/auto_role/command/auto_role_group.py @@ -58,10 +58,14 @@ class AutoRoleGroup(DiscordCommandABC): self, interaction: discord.Interaction, current: str ) -> TList[app_commands.Choice[str]]: server = self._servers.get_server_by_discord_id(interaction.guild.id) - auto_roles = self._auto_roles.get_auto_roles_by_server_id(server.id).select(lambda x: x.id) + auto_roles = self._auto_roles.get_auto_roles_by_server_id(server.id).select( + lambda x: x.id + ) return [ app_commands.Choice(name=auto_role, value=auto_role) - for auto_role in self._client_utils.get_auto_complete_list(auto_roles, current, lambda x: x.name) + for auto_role in self._client_utils.get_auto_complete_list( + auto_roles, current, lambda x: x.name + ) ] @commands.hybrid_group(name="auto-role") @@ -78,8 +82,12 @@ class AutoRoleGroup(DiscordCommandABC): if ctx.guild is None: return - server_config: ServerConfig = self._config.get_configuration(f"ServerConfig_{ctx.guild.id}") - if not FeatureFlagsSettings.get_flag_from_dict(server_config.feature_flags, FeatureFlagsEnum.auto_role_module): + server_config: ServerConfig = self._config.get_configuration( + f"ServerConfig_{ctx.guild.id}" + ) + if not FeatureFlagsSettings.get_flag_from_dict( + server_config.feature_flags, FeatureFlagsEnum.auto_role_module + ): return embed = discord.Embed( @@ -90,7 +98,9 @@ class AutoRoleGroup(DiscordCommandABC): server = self._servers.get_server_by_discord_id(ctx.guild.id) auto_roles = self._auto_roles.get_auto_roles_by_server_id(server.id) if auto_roles.count() < 1: - await self._message_service.send_ctx_msg(ctx, self._t.transform("modules.auto_role.error.nothing_found")) + await self._message_service.send_ctx_msg( + ctx, self._t.transform("modules.auto_role.error.nothing_found") + ) self._logger.trace(__name__, f"Finished command auto-role list") return @@ -118,12 +128,18 @@ class AutoRoleGroup(DiscordCommandABC): @CommandChecks.check_is_ready() @CommandChecks.check_is_member_moderator() async def add(self, ctx: Context, channel: discord.TextChannel, message_id: str): - self._logger.debug(__name__, f"Received command auto-role add {ctx} {message_id}") + self._logger.debug( + __name__, f"Received command auto-role add {ctx} {message_id}" + ) if ctx.guild is None: return - server_config: ServerConfig = self._config.get_configuration(f"ServerConfig_{ctx.guild.id}") - if not FeatureFlagsSettings.get_flag_from_dict(server_config.feature_flags, FeatureFlagsEnum.auto_role_module): + server_config: ServerConfig = self._config.get_configuration( + f"ServerConfig_{ctx.guild.id}" + ) + if not FeatureFlagsSettings.get_flag_from_dict( + server_config.feature_flags, FeatureFlagsEnum.auto_role_module + ): return message = ( @@ -135,38 +151,56 @@ class AutoRoleGroup(DiscordCommandABC): .single_or_default() ) if message is None: - self._logger.debug(__name__, f"Message with id {message_id} not found in {channel.name}") + self._logger.debug( + __name__, f"Message with id {message_id} not found in {channel.name}" + ) await self._message_service.send_ctx_msg( ctx, - self._t.transform("modules.auto_role.add.error.not_found").format(message_id, channel.mention), + self._t.transform("modules.auto_role.add.error.not_found").format( + message_id, channel.mention + ), ) self._logger.trace(__name__, f"Finished command auto-role add") return if self._auto_roles.find_auto_role_by_message_id(int(message_id)) is not None: - self._logger.debug(__name__, f"auto-role for message {message_id} already exists") + self._logger.debug( + __name__, f"auto-role for message {message_id} already exists" + ) await self._message_service.send_ctx_msg( ctx, - self._t.transform("modules.auto_role.add.error.already_exists").format(message_id), + self._t.transform("modules.auto_role.add.error.already_exists").format( + message_id + ), ) self._logger.trace(__name__, f"Finished command auto-role add") return server = self._servers.get_server_by_discord_id(ctx.guild.id) - self._auto_roles.add_auto_role(AutoRole(server, int(channel.id), int(message_id))) + self._auto_roles.add_auto_role( + AutoRole(server, int(channel.id), int(message_id)) + ) self._db_context.save_changes() - self._logger.info(__name__, f"Saved auto-role for message {message_id} at server {server}") + self._logger.info( + __name__, f"Saved auto-role for message {message_id} at server {server}" + ) await self._message_service.send_ctx_msg( ctx, self._t.transform("modules.auto_role.add.success").format(message_id) ) self._logger.trace(__name__, f"Finished command auto-role add") @add.autocomplete("message_id") - async def add_autocomplete(self, interaction: discord.Interaction, current: str) -> TList[app_commands.Choice[str]]: - channel = discord.utils.get(interaction.guild.text_channels, id=interaction.channel_id) + async def add_autocomplete( + self, interaction: discord.Interaction, current: str + ) -> TList[app_commands.Choice[str]]: + channel = discord.utils.get( + interaction.guild.text_channels, id=interaction.channel_id + ) try: channel_from_data = interaction.data["options"][0]["options"][0]["value"] - found_channel = discord.utils.get(interaction.guild.text_channels, id=int(channel_from_data)) + found_channel = discord.utils.get( + interaction.guild.text_channels, id=int(channel_from_data) + ) if found_channel is not None: channel = found_channel finally: @@ -174,7 +208,9 @@ class AutoRoleGroup(DiscordCommandABC): messages = [message async for message in channel.history(limit=10)] return [ - app_commands.Choice(name=f"{message.author}@{message.created_at}", value=str(message.id)) + app_commands.Choice( + name=f"{message.author}@{message.created_at}", value=str(message.id) + ) for message in messages if current in str(message.id) ] @@ -184,12 +220,18 @@ class AutoRoleGroup(DiscordCommandABC): @CommandChecks.check_is_ready() @CommandChecks.check_is_member_moderator() async def remove(self, ctx: Context, auto_role: int): - self._logger.debug(__name__, f"Received command auto-role remove {ctx} {auto_role}") + self._logger.debug( + __name__, f"Received command auto-role remove {ctx} {auto_role}" + ) if ctx.guild is None: return - server_config: ServerConfig = self._config.get_configuration(f"ServerConfig_{ctx.guild.id}") - if not FeatureFlagsSettings.get_flag_from_dict(server_config.feature_flags, FeatureFlagsEnum.auto_role_module): + server_config: ServerConfig = self._config.get_configuration( + f"ServerConfig_{ctx.guild.id}" + ) + if not FeatureFlagsSettings.get_flag_from_dict( + server_config.feature_flags, FeatureFlagsEnum.auto_role_module + ): return auto_role_from_db = self._auto_roles.find_auto_role_by_id(auto_role) @@ -197,12 +239,16 @@ class AutoRoleGroup(DiscordCommandABC): self._logger.debug(__name__, f"auto-role {auto_role} not found") await self._message_service.send_ctx_msg( ctx, - self._t.transform("modules.auto_role.remove.error.not_found").format(auto_role), + self._t.transform("modules.auto_role.remove.error.not_found").format( + auto_role + ), ) self._logger.trace(__name__, f"Finished command auto-role remove") return - for rule in self._auto_roles.get_auto_role_rules_by_auto_role_id(auto_role_from_db.id): + for rule in self._auto_roles.get_auto_role_rules_by_auto_role_id( + auto_role_from_db.id + ): self._auto_roles.delete_auto_role_rule(rule) self._logger.info(__name__, f"Removed auto-role rule {rule.role_id}") @@ -225,12 +271,18 @@ class AutoRoleGroup(DiscordCommandABC): @CommandChecks.check_is_ready() @CommandChecks.check_is_member_moderator() async def react(self, ctx: Context, auto_role: int): - self._logger.debug(__name__, f"Received command auto-role react {ctx} {auto_role}") + self._logger.debug( + __name__, f"Received command auto-role react {ctx} {auto_role}" + ) if ctx.guild is None: return - server_config: ServerConfig = self._config.get_configuration(f"ServerConfig_{ctx.guild.id}") - if not FeatureFlagsSettings.get_flag_from_dict(server_config.feature_flags, FeatureFlagsEnum.auto_role_module): + server_config: ServerConfig = self._config.get_configuration( + f"ServerConfig_{ctx.guild.id}" + ) + if not FeatureFlagsSettings.get_flag_from_dict( + server_config.feature_flags, FeatureFlagsEnum.auto_role_module + ): return auto_role_from_db = self._auto_roles.find_auto_role_by_id(auto_role) @@ -238,14 +290,21 @@ class AutoRoleGroup(DiscordCommandABC): self._logger.debug(__name__, f"auto-role {auto_role} not found") await self._message_service.send_ctx_msg( ctx, - self._t.transform("modules.auto_role.remove.error.not_found").format(auto_role), + self._t.transform("modules.auto_role.remove.error.not_found").format( + auto_role + ), ) self._logger.trace(__name__, f"Finished command auto-role react") return - for rule in self._auto_roles.get_auto_role_rules_by_auto_role_id(auto_role_from_db.id): + for rule in self._auto_roles.get_auto_role_rules_by_auto_role_id( + auto_role_from_db.id + ): await self._client_utils.react_to_message_by_auto_role_rule( - auto_role_from_db.discord_channel_id, auto_role_from_db.discord_message_id, rule, ctx.guild + auto_role_from_db.discord_channel_id, + auto_role_from_db.discord_message_id, + rule, + ctx.guild, ) await self._message_service.send_ctx_msg( @@ -274,8 +333,12 @@ class AutoRoleGroup(DiscordCommandABC): if ctx.guild is None: return - server_config: ServerConfig = self._config.get_configuration(f"ServerConfig_{ctx.guild.id}") - if not FeatureFlagsSettings.get_flag_from_dict(server_config.feature_flags, FeatureFlagsEnum.auto_role_module): + server_config: ServerConfig = self._config.get_configuration( + f"ServerConfig_{ctx.guild.id}" + ) + if not FeatureFlagsSettings.get_flag_from_dict( + server_config.feature_flags, FeatureFlagsEnum.auto_role_module + ): return embed = discord.Embed( @@ -328,20 +391,30 @@ class AutoRoleGroup(DiscordCommandABC): @CommandChecks.check_is_ready() @CommandChecks.check_is_member_moderator() async def add(self, ctx: Context, auto_role: int, emoji_name: str, role_id: str): - self._logger.debug(__name__, f"Received command auto-role add {ctx} {auto_role}") + self._logger.debug( + __name__, f"Received command auto-role add {ctx} {auto_role}" + ) if ctx.guild is None: return - server_config: ServerConfig = self._config.get_configuration(f"ServerConfig_{ctx.guild.id}") - if not FeatureFlagsSettings.get_flag_from_dict(server_config.feature_flags, FeatureFlagsEnum.auto_role_module): + server_config: ServerConfig = self._config.get_configuration( + f"ServerConfig_{ctx.guild.id}" + ) + if not FeatureFlagsSettings.get_flag_from_dict( + server_config.feature_flags, FeatureFlagsEnum.auto_role_module + ): return emoji = discord.utils.get(self._bot.emojis, name=emoji_name) if emoji is None: - self._logger.debug(__name__, f"auto-role rule add emoji {emoji_name} not found") + self._logger.debug( + __name__, f"auto-role rule add emoji {emoji_name} not found" + ) await self._message_service.send_ctx_msg( ctx, - self._t.transform("modules.auto_role.rule.add.error.emoji_not_found").format(emoji_name, auto_role), + self._t.transform( + "modules.auto_role.rule.add.error.emoji_not_found" + ).format(emoji_name, auto_role), ) self._logger.trace(__name__, f"Finished command auto-role add") return @@ -351,7 +424,9 @@ class AutoRoleGroup(DiscordCommandABC): self._logger.debug(__name__, f"auto-role rule add role {role_id} not found") await self._message_service.send_ctx_msg( ctx, - self._t.transform("modules.auto_role.rule.add.error.role_not_found").format(role_id, auto_role), + self._t.transform( + "modules.auto_role.rule.add.error.role_not_found" + ).format(role_id, auto_role), ) self._logger.trace(__name__, f"Finished command auto-role add") return @@ -360,7 +435,9 @@ class AutoRoleGroup(DiscordCommandABC): if auto_role_from_db is None: await self._message_service.send_ctx_msg( ctx, - self._t.transform("modules.auto_role.remove.error.not_found").format(auto_role), + self._t.transform("modules.auto_role.remove.error.not_found").format( + auto_role + ), ) self._logger.trace(__name__, f"Finished command auto-role rule add") return @@ -373,12 +450,16 @@ class AutoRoleGroup(DiscordCommandABC): ): await self._message_service.send_ctx_msg( ctx, - self._t.transform("modules.auto_role.add.error.already_exists").format(auto_role), + self._t.transform("modules.auto_role.add.error.already_exists").format( + auto_role + ), ) self._logger.trace(__name__, f"Finished command auto-role rule add") return - self._auto_roles.add_auto_role_rule(AutoRoleRule(auto_role_from_db, emoji_name, int(role_id))) + self._auto_roles.add_auto_role_rule( + AutoRoleRule(auto_role_from_db, emoji_name, int(role_id)) + ) self._db_context.save_changes() rule = ( self._auto_roles.get_auto_role_rules_by_auto_role_id(auto_role) @@ -389,26 +470,37 @@ class AutoRoleGroup(DiscordCommandABC): # as task to run in background self._bot.loop.create_task( await self._client_utils.react_to_message_by_auto_role_rule( - auto_role_from_db.discord_channel_id, auto_role_from_db.discord_message_id, rule, ctx.guild + auto_role_from_db.discord_channel_id, + auto_role_from_db.discord_message_id, + rule, + ctx.guild, ) ) await self._message_service.send_ctx_msg( ctx, - self._t.transform("modules.auto_role.rule.add.success").format(emoji, role.mention, auto_role), + self._t.transform("modules.auto_role.rule.add.success").format( + emoji, role.mention, auto_role + ), ) self._logger.trace(__name__, f"Finished command auto-role rule add") @add.autocomplete("auto_role") - async def add_autocomplete(self, interaction: discord.Interaction, current: str) -> TList[app_commands.Choice[str]]: + async def add_autocomplete( + self, interaction: discord.Interaction, current: str + ) -> TList[app_commands.Choice[str]]: return await self._auto_role_auto_complete(interaction, current) @add.autocomplete("emoji_name") - async def add_autocomplete(self, interaction: discord.Interaction, current: str) -> TList[app_commands.Choice[str]]: + async def add_autocomplete( + self, interaction: discord.Interaction, current: str + ) -> TList[app_commands.Choice[str]]: emojis = List(discord.Emoji, interaction.guild.emojis) return [ app_commands.Choice(name=emoji.name, value=emoji.name) - for emoji in self._client_utils.get_auto_complete_list(emojis, current, lambda e: e.name) + for emoji in self._client_utils.get_auto_complete_list( + emojis, current, lambda e: e.name + ) ] @add.autocomplete("role_id") @@ -418,7 +510,9 @@ class AutoRoleGroup(DiscordCommandABC): roles = List(discord.Role, interaction.guild.roles) return [ app_commands.Choice(name=role.name, value=str(role.id)) - for role in self._client_utils.get_auto_complete_list(roles, current, lambda r: r.name) + for role in self._client_utils.get_auto_complete_list( + roles, current, lambda r: r.name + ) ] @rule.command() @@ -426,12 +520,18 @@ class AutoRoleGroup(DiscordCommandABC): @CommandChecks.check_is_ready() @CommandChecks.check_is_member_moderator() async def remove(self, ctx: Context, auto_role_rule: int): - self._logger.debug(__name__, f"Received command auto-role remove {ctx} {auto_role_rule}") + self._logger.debug( + __name__, f"Received command auto-role remove {ctx} {auto_role_rule}" + ) if ctx.guild is None: return - server_config: ServerConfig = self._config.get_configuration(f"ServerConfig_{ctx.guild.id}") - if not FeatureFlagsSettings.get_flag_from_dict(server_config.feature_flags, FeatureFlagsEnum.auto_role_module): + server_config: ServerConfig = self._config.get_configuration( + f"ServerConfig_{ctx.guild.id}" + ) + if not FeatureFlagsSettings.get_flag_from_dict( + server_config.feature_flags, FeatureFlagsEnum.auto_role_module + ): return auto_role_from_db = self._auto_roles.get_auto_role_rule_by_id(auto_role_rule) @@ -439,7 +539,9 @@ class AutoRoleGroup(DiscordCommandABC): self._logger.debug(__name__, f"auto-role rule {auto_role_rule} not found") await self._message_service.send_ctx_msg( ctx, - self._t.transform("modules.auto_role.remove.error.not_found").format(auto_role_rule), + self._t.transform("modules.auto_role.remove.error.not_found").format( + auto_role_rule + ), ) self._logger.trace(__name__, f"Finished command auto-role rule remove") return @@ -449,7 +551,9 @@ class AutoRoleGroup(DiscordCommandABC): self._logger.info(__name__, f"Removed auto-role rule {auto_role_rule}") await self._message_service.send_ctx_msg( ctx, - self._t.transform("modules.auto_role.rule.remove.success").format(auto_role_rule), + self._t.transform("modules.auto_role.rule.remove.success").format( + auto_role_rule + ), ) self._logger.trace(__name__, f"Finished command auto-role remove") @@ -458,12 +562,18 @@ class AutoRoleGroup(DiscordCommandABC): self, interaction: discord.Interaction, current: str ) -> TList[app_commands.Choice[str]]: server = self._servers.get_server_by_discord_id(interaction.guild.id) - auto_roles = self._auto_roles.get_auto_roles_by_server_id(server.id).select(lambda x: x.id) - rules = auto_roles.select_many(lambda ar: self._auto_roles.get_auto_role_rules_by_auto_role_id(ar)) + auto_roles = self._auto_roles.get_auto_roles_by_server_id(server.id).select( + lambda x: x.id + ) + rules = auto_roles.select_many( + lambda ar: self._auto_roles.get_auto_role_rules_by_auto_role_id(ar) + ) return [ app_commands.Choice( name=f"{rule.id} {rule.emoji_name} {interaction.guild.get_role(int(rule.role_id))}", value=rule.id, ) - for rule in self._client_utils.get_auto_complete_list(rules, current, lambda r: r.id) + for rule in self._client_utils.get_auto_complete_list( + rules, current, lambda r: r.id + ) ] diff --git a/kdb-bot/src/modules/auto_role/events/__init__.py b/bot/src/modules/auto_role/events/__init__.py similarity index 100% rename from kdb-bot/src/modules/auto_role/events/__init__.py rename to bot/src/modules/auto_role/events/__init__.py diff --git a/kdb-bot/src/modules/auto_role/events/auto_role_on_raw_reaction_add.py b/bot/src/modules/auto_role/events/auto_role_on_raw_reaction_add.py similarity index 89% rename from kdb-bot/src/modules/auto_role/events/auto_role_on_raw_reaction_add.py rename to bot/src/modules/auto_role/events/auto_role_on_raw_reaction_add.py index f5d14804..a85fadd2 100644 --- a/kdb-bot/src/modules/auto_role/events/auto_role_on_raw_reaction_add.py +++ b/bot/src/modules/auto_role/events/auto_role_on_raw_reaction_add.py @@ -35,8 +35,12 @@ class AutoRoleOnRawReactionAddEvent(OnRawReactionAddABC): @EventChecks.check_is_ready() async def on_raw_reaction_add(self, payload: RawReactionActionEvent): self._logger.debug(__name__, f"Module {type(self)} started") - server_config: ServerConfig = self._config.get_configuration(f"ServerConfig_{payload.guild_id}") - if not FeatureFlagsSettings.get_flag_from_dict(server_config.feature_flags, FeatureFlagsEnum.auto_role_module): + server_config: ServerConfig = self._config.get_configuration( + f"ServerConfig_{payload.guild_id}" + ) + if not FeatureFlagsSettings.get_flag_from_dict( + server_config.feature_flags, FeatureFlagsEnum.auto_role_module + ): return await self._reaction_handler.handle(payload, "add") diff --git a/kdb-bot/src/modules/auto_role/events/auto_role_on_raw_reaction_remove.py b/bot/src/modules/auto_role/events/auto_role_on_raw_reaction_remove.py similarity index 89% rename from kdb-bot/src/modules/auto_role/events/auto_role_on_raw_reaction_remove.py rename to bot/src/modules/auto_role/events/auto_role_on_raw_reaction_remove.py index a174c8f5..0defd312 100644 --- a/kdb-bot/src/modules/auto_role/events/auto_role_on_raw_reaction_remove.py +++ b/bot/src/modules/auto_role/events/auto_role_on_raw_reaction_remove.py @@ -35,8 +35,12 @@ class AutoRoleOnRawReactionRemoveEvent(OnRawReactionRemoveABC): @EventChecks.check_is_ready() async def on_raw_reaction_remove(self, payload: RawReactionActionEvent): self._logger.debug(__name__, f"Module {type(self)} started") - server_config: ServerConfig = self._config.get_configuration(f"ServerConfig_{payload.guild_id}") - if not FeatureFlagsSettings.get_flag_from_dict(server_config.feature_flags, FeatureFlagsEnum.auto_role_module): + server_config: ServerConfig = self._config.get_configuration( + f"ServerConfig_{payload.guild_id}" + ) + if not FeatureFlagsSettings.get_flag_from_dict( + server_config.feature_flags, FeatureFlagsEnum.auto_role_module + ): return await self._reaction_handler.handle(payload, "remove") diff --git a/kdb-bot/src/modules/auto_role/helper/__init__.py b/bot/src/modules/auto_role/helper/__init__.py similarity index 100% rename from kdb-bot/src/modules/auto_role/helper/__init__.py rename to bot/src/modules/auto_role/helper/__init__.py diff --git a/kdb-bot/src/modules/auto_role/helper/auto_role_reaction_handler.py b/bot/src/modules/auto_role/helper/auto_role_reaction_handler.py similarity index 88% rename from kdb-bot/src/modules/auto_role/helper/auto_role_reaction_handler.py rename to bot/src/modules/auto_role/helper/auto_role_reaction_handler.py index 47ab3778..b0b59aee 100644 --- a/kdb-bot/src/modules/auto_role/helper/auto_role_reaction_handler.py +++ b/bot/src/modules/auto_role/helper/auto_role_reaction_handler.py @@ -22,7 +22,9 @@ class AutoRoleReactionHandler: self._servers = servers self._auto_roles = auto_roles - self._message_ids = self._auto_roles.get_auto_roles().select(lambda x: x.discord_message_id) + self._message_ids = self._auto_roles.get_auto_roles().select( + lambda x: x.discord_message_id + ) self._roles = self._auto_roles.get_auto_roles() async def handle(self, payload: RawReactionActionEvent, r_type=None) -> None: @@ -34,7 +36,9 @@ class AutoRoleReactionHandler: guild = self._bot.get_guild(payload.guild_id) user = guild.get_member(payload.user_id) if user is None: - self._logger.warn(__name__, f"User {payload.user_id} in {guild.name} not found - skipping") + self._logger.warn( + __name__, f"User {payload.user_id} in {guild.name} not found - skipping" + ) return if user.bot: @@ -49,7 +53,9 @@ class AutoRoleReactionHandler: self._logger.debug(__name__, f"auto-role for message not found - skipping") return - rules: List[AutoRoleRule] = self._auto_roles.get_auto_role_rules_by_auto_role_id(auto_role.id) + rules: List[ + AutoRoleRule + ] = self._auto_roles.get_auto_role_rules_by_auto_role_id(auto_role.id) if rules.count() == 0: self._logger.debug(__name__, f"auto-role rules not found - skipping") return diff --git a/kdb-bot/src/modules/base/__init__.py b/bot/src/modules/base/__init__.py similarity index 100% rename from kdb-bot/src/modules/base/__init__.py rename to bot/src/modules/base/__init__.py diff --git a/kdb-bot/src/modules/base/base.json b/bot/src/modules/base/base.json similarity index 100% rename from kdb-bot/src/modules/base/base.json rename to bot/src/modules/base/base.json diff --git a/kdb-bot/src/modules/base/base_module.py b/bot/src/modules/base/base_module.py similarity index 81% rename from kdb-bot/src/modules/base/base_module.py rename to bot/src/modules/base/base_module.py index e7d597a9..60f17173 100644 --- a/kdb-bot/src/modules/base/base_module.py +++ b/bot/src/modules/base/base_module.py @@ -30,7 +30,9 @@ from modules.base.events.base_on_message_delete_event import BaseOnMessageDelete from modules.base.events.base_on_message_event import BaseOnMessageEvent from modules.base.events.base_on_raw_reaction_add import BaseOnRawReactionAddEvent from modules.base.events.base_on_raw_reaction_remove import BaseOnRawReactionRemoveEvent -from modules.base.events.base_on_scheduled_event_update_event import BaseOnScheduledEventUpdateEvent +from modules.base.events.base_on_scheduled_event_update_event import ( + BaseOnScheduledEventUpdateEvent, +) from modules.base.events.base_on_voice_state_update_event import ( BaseOnVoiceStateUpdateEvent, ) @@ -51,10 +53,14 @@ class BaseModule(ModuleABC): def __init__(self, dc: DiscordCollectionABC): ModuleABC.__init__(self, dc, FeatureFlagsEnum.base_module) - def configure_configuration(self, config: ConfigurationABC, env: ApplicationEnvironmentABC): + def configure_configuration( + self, config: ConfigurationABC, env: ApplicationEnvironmentABC + ): pass - def configure_services(self, services: ServiceCollectionABC, env: ApplicationEnvironmentABC): + def configure_services( + self, services: ServiceCollectionABC, env: ApplicationEnvironmentABC + ): services.add_transient(BaseReactionHandler) services.add_singleton(EventService) services.add_transient(UserWarningsService) @@ -80,13 +86,27 @@ class BaseModule(ModuleABC): services.add_transient(UnregisterGroup) services.add_transient(GameServerGroup) # events - services.add_transient(DiscordEventTypesEnum.on_command.value, BaseOnCommandEvent) - services.add_transient(DiscordEventTypesEnum.on_command_error.value, BaseOnCommandErrorEvent) - services.add_transient(DiscordEventTypesEnum.on_member_join.value, BaseOnMemberJoinEvent) - services.add_transient(DiscordEventTypesEnum.on_member_remove.value, BaseOnMemberRemoveEvent) - services.add_transient(DiscordEventTypesEnum.on_message.value, BaseOnMessageEvent) - services.add_transient(DiscordEventTypesEnum.on_message_delete.value, BaseOnMessageDeleteEvent) - services.add_transient(DiscordEventTypesEnum.on_raw_reaction_add.value, BaseOnRawReactionAddEvent) + services.add_transient( + DiscordEventTypesEnum.on_command.value, BaseOnCommandEvent + ) + services.add_transient( + DiscordEventTypesEnum.on_command_error.value, BaseOnCommandErrorEvent + ) + services.add_transient( + DiscordEventTypesEnum.on_member_join.value, BaseOnMemberJoinEvent + ) + services.add_transient( + DiscordEventTypesEnum.on_member_remove.value, BaseOnMemberRemoveEvent + ) + services.add_transient( + DiscordEventTypesEnum.on_message.value, BaseOnMessageEvent + ) + services.add_transient( + DiscordEventTypesEnum.on_message_delete.value, BaseOnMessageDeleteEvent + ) + services.add_transient( + DiscordEventTypesEnum.on_raw_reaction_add.value, BaseOnRawReactionAddEvent + ) services.add_transient( DiscordEventTypesEnum.on_raw_reaction_remove.value, BaseOnRawReactionRemoveEvent, diff --git a/kdb-bot/src/modules/base/birthday_watcher.py b/bot/src/modules/base/birthday_watcher.py similarity index 92% rename from kdb-bot/src/modules/base/birthday_watcher.py rename to bot/src/modules/base/birthday_watcher.py index 7b19638a..2b01095f 100644 --- a/kdb-bot/src/modules/base/birthday_watcher.py +++ b/bot/src/modules/base/birthday_watcher.py @@ -46,7 +46,9 @@ class BirthdayWatcher(TaskABC): if user.birthday.day != today.day or user.birthday.month != today.month: continue - settings: ServerConfig = self._config.get_configuration(f"ServerConfig_{user.server.discord_id}") + settings: ServerConfig = self._config.get_configuration( + f"ServerConfig_{user.server.discord_id}" + ) user.xp += settings.xp_for_birthday self._users.update_user(user) @@ -56,7 +58,9 @@ class BirthdayWatcher(TaskABC): member = guild.get_member(user.discord_id) await self._message_service.send_channel_message( self._bot.get_channel(settings.notification_chat_id), - self._t.transform("modules.base.user.birthday.has_birthday").format(member.mention), + self._t.transform("modules.base.user.birthday.has_birthday").format( + member.mention + ), is_persistent=True, ) except Exception as e: diff --git a/kdb-bot/src/modules/base/command/__init__.py b/bot/src/modules/base/command/__init__.py similarity index 100% rename from kdb-bot/src/modules/base/command/__init__.py rename to bot/src/modules/base/command/__init__.py diff --git a/kdb-bot/src/modules/base/command/afk_command.py b/bot/src/modules/base/command/afk_command.py similarity index 87% rename from kdb-bot/src/modules/base/command/afk_command.py rename to bot/src/modules/base/command/afk_command.py index 092c9788..924c012d 100644 --- a/kdb-bot/src/modules/base/command/afk_command.py +++ b/bot/src/modules/base/command/afk_command.py @@ -39,7 +39,9 @@ class AFKCommand(DiscordCommandABC): @CommandChecks.check_is_ready() async def afk(self, ctx: Context): self._logger.debug(__name__, f"Received command afk {ctx}") - settings: ServerConfig = self._config.get_configuration(f"ServerConfig_{ctx.guild.id}") + settings: ServerConfig = self._config.get_configuration( + f"ServerConfig_{ctx.guild.id}" + ) if ctx.author.voice is None or ctx.author.voice.channel is None: await self._message_service.send_ctx_msg( @@ -50,7 +52,9 @@ class AFKCommand(DiscordCommandABC): return self._bot.loop.create_task( - self._message_service.send_ctx_msg(ctx, self._t.transform("modules.base.afk_command_move_message")) + self._message_service.send_ctx_msg( + ctx, self._t.transform("modules.base.afk_command_move_message") + ) ) channel: VoiceChannel = ctx.guild.get_channel(settings.afk_command_channel_id) try: @@ -62,6 +66,8 @@ class AFKCommand(DiscordCommandABC): f"Cannot move user {ctx.author.id} to channel {ctx.channel.id}", e, ) - await self._message_service.send_ctx_msg(ctx, self._t.transform("common.no_permission_message")) + await self._message_service.send_ctx_msg( + ctx, self._t.transform("common.no_permission_message") + ) self._logger.trace(__name__, f"Finished afk command") diff --git a/kdb-bot/src/modules/base/command/game_server_group.py b/bot/src/modules/base/command/game_server_group.py similarity index 75% rename from kdb-bot/src/modules/base/command/game_server_group.py rename to bot/src/modules/base/command/game_server_group.py index b822f3de..051db38e 100644 --- a/kdb-bot/src/modules/base/command/game_server_group.py +++ b/bot/src/modules/base/command/game_server_group.py @@ -76,9 +76,15 @@ class GameServerGroup(DiscordCommandABC): if ctx.guild is None: return - settings: ServerConfig = self._config.get_configuration(f"ServerConfig_{ctx.guild.id}") - if not FeatureFlagsSettings.get_flag_from_dict(settings.feature_flags, FeatureFlagsEnum.game_server): - await self._message_service.send_ctx_msg(ctx, self._t.transform("common.feature_not_activated")) + settings: ServerConfig = self._config.get_configuration( + f"ServerConfig_{ctx.guild.id}" + ) + if not FeatureFlagsSettings.get_flag_from_dict( + settings.feature_flags, FeatureFlagsEnum.game_server + ): + await self._message_service.send_ctx_msg( + ctx, self._t.transform("common.feature_not_activated") + ) return server = self._servers.get_server_by_discord_id(ctx.guild.id) @@ -107,7 +113,11 @@ class GameServerGroup(DiscordCommandABC): value=game_server_name, inline=True, ) - embed.add_field(name=self._t.transform("modules.base.game_server.list.api_key"), value=api_key, inline=True) + embed.add_field( + name=self._t.transform("modules.base.game_server.list.api_key"), + value=api_key, + inline=True, + ) await self._message_service.send_ctx_msg(ctx, embed, wait_before_delete=wait) self._logger.trace(__name__, f"Finished command game_server list") @@ -117,14 +127,22 @@ class GameServerGroup(DiscordCommandABC): @CommandChecks.check_is_ready() @CommandChecks.check_is_member_admin() async def add(self, ctx: Context, name: str, api_key_id: int): - self._logger.debug(__name__, f"Received command game-server add {ctx}: {name} {api_key_id}") + self._logger.debug( + __name__, f"Received command game-server add {ctx}: {name} {api_key_id}" + ) if ctx.guild is None: return - settings: ServerConfig = self._config.get_configuration(f"ServerConfig_{ctx.guild.id}") - if not FeatureFlagsSettings.get_flag_from_dict(settings.feature_flags, FeatureFlagsEnum.game_server): - await self._message_service.send_ctx_msg(ctx, self._t.transform("common.feature_not_activated")) + settings: ServerConfig = self._config.get_configuration( + f"ServerConfig_{ctx.guild.id}" + ) + if not FeatureFlagsSettings.get_flag_from_dict( + settings.feature_flags, FeatureFlagsEnum.game_server + ): + await self._message_service.send_ctx_msg( + ctx, self._t.transform("common.feature_not_activated") + ) return server = self._servers.get_server_by_discord_id(ctx.guild.id) @@ -148,7 +166,9 @@ class GameServerGroup(DiscordCommandABC): return [ app_commands.Choice(name=f"{key.identifier}: {key.key}", value=key.id) - for key in self._client_utils.get_auto_complete_list(keys, current, lambda x: x.key) + for key in self._client_utils.get_auto_complete_list( + keys, current, lambda x: x.key + ) ] @game_server.command() @@ -161,26 +181,38 @@ class GameServerGroup(DiscordCommandABC): if ctx.guild is None: return - settings: ServerConfig = self._config.get_configuration(f"ServerConfig_{ctx.guild.id}") - if not FeatureFlagsSettings.get_flag_from_dict(settings.feature_flags, FeatureFlagsEnum.game_server): - await self._message_service.send_ctx_msg(ctx, self._t.transform("common.feature_not_activated")) + settings: ServerConfig = self._config.get_configuration( + f"ServerConfig_{ctx.guild.id}" + ) + if not FeatureFlagsSettings.get_flag_from_dict( + settings.feature_flags, FeatureFlagsEnum.game_server + ): + await self._message_service.send_ctx_msg( + ctx, self._t.transform("common.feature_not_activated") + ) return game_server = self._game_servers.get_game_server_by_id(id) self._game_servers.delete_game_server(game_server) self._db.save_changes() - await self._message_service.send_ctx_msg(ctx, self._t.transform("modules.base.game_server.remove.success")) + await self._message_service.send_ctx_msg( + ctx, self._t.transform("modules.base.game_server.remove.success") + ) self._logger.trace(__name__, f"Finished command game-server remove") @remove.autocomplete("id") - async def id_autocomplete(self, interaction: discord.Interaction, current: str) -> TList[app_commands.Choice[str]]: + async def id_autocomplete( + self, interaction: discord.Interaction, current: str + ) -> TList[app_commands.Choice[str]]: server = self._servers.get_server_by_discord_id(interaction.guild.id) game_servers = self._game_servers.get_game_servers_by_server_id(server.id) return [ app_commands.Choice(name=gs.name, value=gs.id) - for gs in self._client_utils.get_auto_complete_list(game_servers, current, lambda x: x.name) + for gs in self._client_utils.get_auto_complete_list( + game_servers, current, lambda x: x.name + ) ] @game_server.command(name="list-members") @@ -193,33 +225,51 @@ class GameServerGroup(DiscordCommandABC): if ctx.guild is None: return - settings: ServerConfig = self._config.get_configuration(f"ServerConfig_{ctx.guild.id}") - if not FeatureFlagsSettings.get_flag_from_dict(settings.feature_flags, FeatureFlagsEnum.game_server): - await self._message_service.send_ctx_msg(ctx, self._t.transform("common.feature_not_activated")) + settings: ServerConfig = self._config.get_configuration( + f"ServerConfig_{ctx.guild.id}" + ) + if not FeatureFlagsSettings.get_flag_from_dict( + settings.feature_flags, FeatureFlagsEnum.game_server + ): + await self._message_service.send_ctx_msg( + ctx, self._t.transform("common.feature_not_activated") + ) return game_server = self._game_servers.get_game_server_by_id(id) - game_idents = self._user_game_idents.get_user_game_idents_by_game_server_id(game_server.id) + game_idents = self._user_game_idents.get_user_game_idents_by_game_server_id( + game_server.id + ) users = "" for game_ident in game_idents: users += f"\n{game_ident.user.name}" embed = discord.Embed( title=self._t.transform("modules.base.game_server.list_members.title"), - description=self._t.transform("modules.base.game_server.list_members.description"), + description=self._t.transform( + "modules.base.game_server.list_members.description" + ), color=int("ef9d0d", 16), ) - embed.add_field(name=self._t.transform("modules.base.game_server.list_members.users"), value=users, inline=True) + embed.add_field( + name=self._t.transform("modules.base.game_server.list_members.users"), + value=users, + inline=True, + ) await self._message_service.send_ctx_msg(ctx, embed, wait_before_delete=wait) self._logger.trace(__name__, f"Finished command game-server remove") @list_members.autocomplete("id") - async def id_autocomplete(self, interaction: discord.Interaction, current: str) -> TList[app_commands.Choice[str]]: + async def id_autocomplete( + self, interaction: discord.Interaction, current: str + ) -> TList[app_commands.Choice[str]]: server = self._servers.get_server_by_discord_id(interaction.guild.id) game_servers = self._game_servers.get_game_servers_by_server_id(server.id) return [ app_commands.Choice(name=gs.name, value=gs.id) - for gs in self._client_utils.get_auto_complete_list(game_servers, current, lambda x: x.name) + for gs in self._client_utils.get_auto_complete_list( + game_servers, current, lambda x: x.name + ) ] diff --git a/kdb-bot/src/modules/base/command/help_command.py b/bot/src/modules/base/command/help_command.py similarity index 93% rename from kdb-bot/src/modules/base/command/help_command.py rename to bot/src/modules/base/command/help_command.py index beb63e77..e97dc198 100644 --- a/kdb-bot/src/modules/base/command/help_command.py +++ b/bot/src/modules/base/command/help_command.py @@ -50,6 +50,8 @@ class HelpCommand(DiscordCommandABC): self._logger.trace(__name__, f"Finished help command") @help.autocomplete("persistent_flag") - async def help_autocomplete(self, interaction: discord.Interaction, current: str) -> List[app_commands.Choice[str]]: + async def help_autocomplete( + self, interaction: discord.Interaction, current: str + ) -> List[app_commands.Choice[str]]: flags = ["--stay"] return [app_commands.Choice(name=key, value=key) for key in flags] diff --git a/kdb-bot/src/modules/base/command/info_command.py b/bot/src/modules/base/command/info_command.py similarity index 95% rename from kdb-bot/src/modules/base/command/info_command.py rename to bot/src/modules/base/command/info_command.py index e228be84..11290c05 100644 --- a/kdb-bot/src/modules/base/command/info_command.py +++ b/bot/src/modules/base/command/info_command.py @@ -55,7 +55,10 @@ class InfoCommand(DiscordCommandABC): ) start_time = self._config.get_configuration("Bot_StartTime") ontime = round( - (datetime.now() - datetime.strptime(start_time, "%Y-%m-%d %H:%M:%S.%f")).total_seconds() / 3600, + ( + datetime.now() - datetime.strptime(start_time, "%Y-%m-%d %H:%M:%S.%f") + ).total_seconds() + / 3600, 2, ) embed.add_field( diff --git a/kdb-bot/src/modules/base/command/make_coffee_command.py b/bot/src/modules/base/command/make_coffee_command.py similarity index 100% rename from kdb-bot/src/modules/base/command/make_coffee_command.py rename to bot/src/modules/base/command/make_coffee_command.py diff --git a/kdb-bot/src/modules/base/command/mass_move_command.py b/bot/src/modules/base/command/mass_move_command.py similarity index 96% rename from kdb-bot/src/modules/base/command/mass_move_command.py rename to bot/src/modules/base/command/mass_move_command.py index 4dd835d2..cedbaa03 100644 --- a/kdb-bot/src/modules/base/command/mass_move_command.py +++ b/bot/src/modules/base/command/mass_move_command.py @@ -58,7 +58,9 @@ class MassMoveCommand(DiscordCommandABC): await self._message_service.send_ctx_msg( ctx, - self._t.transform("modules.base.mass_move.moved").format(channel_from.mention, channel_to.mention), + self._t.transform("modules.base.mass_move.moved").format( + channel_from.mention, channel_to.mention + ), ) self._logger.trace(__name__, f"Finished mass-move command") diff --git a/kdb-bot/src/modules/base/command/ping_command.py b/bot/src/modules/base/command/ping_command.py similarity index 89% rename from kdb-bot/src/modules/base/command/ping_command.py rename to bot/src/modules/base/command/ping_command.py index ca0a14ac..69aff5cf 100644 --- a/kdb-bot/src/modules/base/command/ping_command.py +++ b/bot/src/modules/base/command/ping_command.py @@ -58,8 +58,12 @@ class PingCommand(DiscordCommandABC): color=int("ef9d0d", 16), ) for server in self._settings.ping_urls: - embed.add_field(name=server, value=f"{self._get_ping(server)} ms", inline=False) + embed.add_field( + name=server, value=f"{self._get_ping(server)} ms", inline=False + ) await self._message_service.send_ctx_msg(ctx, embed) else: - await self._message_service.send_ctx_msg(ctx, self._t.transform("modules.base.pong")) + await self._message_service.send_ctx_msg( + ctx, self._t.transform("modules.base.pong") + ) self._logger.trace(__name__, f"Finished ping command") diff --git a/kdb-bot/src/modules/base/command/presence_command.py b/bot/src/modules/base/command/presence_command.py similarity index 85% rename from kdb-bot/src/modules/base/command/presence_command.py rename to bot/src/modules/base/command/presence_command.py index a314b4aa..688e3d20 100644 --- a/kdb-bot/src/modules/base/command/presence_command.py +++ b/bot/src/modules/base/command/presence_command.py @@ -34,7 +34,9 @@ class PresenceCommand(DiscordCommandABC): if text == "": await self._bot.change_presence(activity=None) - await self._message_service.send_ctx_msg(ctx, self._t.transform("modules.base.presence.removed")) + await self._message_service.send_ctx_msg( + ctx, self._t.transform("modules.base.presence.removed") + ) return if len(text) > 128: @@ -44,6 +46,8 @@ class PresenceCommand(DiscordCommandABC): return await self._bot.change_presence(activity=discord.Game(name=text)) - await self._message_service.send_ctx_msg(ctx, self._t.transform("modules.base.presence.changed")) + await self._message_service.send_ctx_msg( + ctx, self._t.transform("modules.base.presence.changed") + ) self._logger.trace(__name__, f"Finished presence command") diff --git a/kdb-bot/src/modules/base/command/purge_command.py b/bot/src/modules/base/command/purge_command.py similarity index 84% rename from kdb-bot/src/modules/base/command/purge_command.py rename to bot/src/modules/base/command/purge_command.py index 9816e29f..ff40f718 100644 --- a/kdb-bot/src/modules/base/command/purge_command.py +++ b/bot/src/modules/base/command/purge_command.py @@ -41,14 +41,20 @@ class PurgeCommand(DiscordCommandABC): @CommandChecks.check_is_member_moderator() async def purge(self, ctx: Context): self._logger.debug(__name__, f"Received command purge {ctx}") - server_settings: ServerConfig = self._config.get_configuration(f"ServerConfig_{ctx.guild.id}") + server_settings: ServerConfig = self._config.get_configuration( + f"ServerConfig_{ctx.guild.id}" + ) - await self._message_service.send_ctx_msg(ctx, self._t.transform("modules.moderator.purge_message")) + await self._message_service.send_ctx_msg( + ctx, self._t.transform("modules.moderator.purge_message") + ) await asyncio.sleep(server_settings.message_delete_timer) try: await ctx.channel.purge() except Exception as e: self._logger.error(__name__, f"Cannot purge channel {ctx.channel.id}", e) - await self._message_service.send_ctx_msg(ctx, self._t.transform("common.bot_has_no_permission_message")) + await self._message_service.send_ctx_msg( + ctx, self._t.transform("common.bot_has_no_permission_message") + ) self._logger.trace(__name__, f"Finished purge command") diff --git a/kdb-bot/src/modules/base/command/register_group.py b/bot/src/modules/base/command/register_group.py similarity index 90% rename from kdb-bot/src/modules/base/command/register_group.py rename to bot/src/modules/base/command/register_group.py index dc3fed15..4fc94ac3 100644 --- a/kdb-bot/src/modules/base/command/register_group.py +++ b/bot/src/modules/base/command/register_group.py @@ -59,16 +59,21 @@ class RegisterGroup(DiscordCommandABC): @commands.guild_only() @CommandChecks.check_is_ready() @CommandChecks.check_is_member_moderator() - async def minecraft(self, ctx: Context, member: discord.Member, game_server: int, name: str): + async def minecraft( + self, ctx: Context, member: discord.Member, game_server: int, name: str + ): self._logger.debug(__name__, f"Received command register minecraft {ctx}") minecraft_id = None try: self._logger.debug(__name__, f"Try to get minecraft id for {name}") - response = requests.get(url=f"https://api.mojang.com/users/profiles/minecraft/{name}") + response = requests.get( + url=f"https://api.mojang.com/users/profiles/minecraft/{name}" + ) if len(response.content) == 0: await self._message_service.send_interaction_msg( - ctx.interaction, self._t.transform("modules.base.register.not_found") + ctx.interaction, + self._t.transform("modules.base.register.not_found"), ) return @@ -105,5 +110,7 @@ class RegisterGroup(DiscordCommandABC): return [ app_commands.Choice(name=gs.name, value=gs.id) - for gs in self._client_utils.get_auto_complete_list(game_servers, current, lambda x: x.name) + for gs in self._client_utils.get_auto_complete_list( + game_servers, current, lambda x: x.name + ) ] diff --git a/kdb-bot/src/modules/base/command/submit_group.py b/bot/src/modules/base/command/submit_group.py similarity index 93% rename from kdb-bot/src/modules/base/command/submit_group.py rename to bot/src/modules/base/command/submit_group.py index ad1570e3..b832b7c2 100644 --- a/kdb-bot/src/modules/base/command/submit_group.py +++ b/bot/src/modules/base/command/submit_group.py @@ -11,7 +11,9 @@ from modules.base.forms.complaint_form import ComplaintForm class SubmitGroup(DiscordCommandABC): - def __init__(self, services: ServiceProviderABC, logger: LoggerABC, bot: DiscordBotServiceABC): + def __init__( + self, services: ServiceProviderABC, logger: LoggerABC, bot: DiscordBotServiceABC + ): DiscordCommandABC.__init__(self) self._services = services diff --git a/kdb-bot/src/modules/base/command/unregister_group.py b/bot/src/modules/base/command/unregister_group.py similarity index 94% rename from kdb-bot/src/modules/base/command/unregister_group.py rename to bot/src/modules/base/command/unregister_group.py index 4d5f796a..3f4e2c1d 100644 --- a/kdb-bot/src/modules/base/command/unregister_group.py +++ b/bot/src/modules/base/command/unregister_group.py @@ -62,7 +62,9 @@ class UnregisterGroup(DiscordCommandABC): server = self._servers.get_server_by_discord_id(ctx.guild.id) user = self._users.get_user_by_discord_id_and_server_id(member.id, server.id) - ident = user.game_idents.where(lambda x: x.game_server.id == game_server).single() + ident = user.game_idents.where( + lambda x: x.game_server.id == game_server + ).single() self._user_game_idents.delete_user_game_ident(ident) self._users.update_user(user) self._db.save_changes() @@ -82,5 +84,7 @@ class UnregisterGroup(DiscordCommandABC): return [ app_commands.Choice(name=gs.name, value=gs.id) - for gs in self._client_utils.get_auto_complete_list(game_servers, current, lambda x: x.name) + for gs in self._client_utils.get_auto_complete_list( + game_servers, current, lambda x: x.name + ) ] diff --git a/kdb-bot/src/modules/base/command/user_group.py b/bot/src/modules/base/command/user_group.py similarity index 78% rename from kdb-bot/src/modules/base/command/user_group.py rename to bot/src/modules/base/command/user_group.py index 7f8a6510..5ed217e7 100644 --- a/kdb-bot/src/modules/base/command/user_group.py +++ b/bot/src/modules/base/command/user_group.py @@ -111,7 +111,9 @@ class UserGroup(DiscordCommandABC): type = "add" if not is_remove else "remove" await self._message_service.send_interaction_msg( ctx.interaction, - self._t.transform(f"modules.base.user.{type}.{atr.lower()}").format(atr, value, member.mention), + self._t.transform(f"modules.base.user.{type}.{atr.lower()}").format( + atr, value, member.mention + ), ) @commands.hybrid_group() @@ -123,10 +125,15 @@ class UserGroup(DiscordCommandABC): @commands.guild_only() @CommandChecks.check_is_ready() async def birthday(self, ctx: Context, day: int, month: int, year: int): - self._logger.debug(__name__, f"Received command user birthday {ctx}:{ctx.author},{day}:{month}:{year}") + self._logger.debug( + __name__, + f"Received command user birthday {ctx}:{ctx.author},{day}:{month}:{year}", + ) date = datetime.date(year, month, day) server = self._servers.get_server_by_discord_id(ctx.guild.id) - user = self._users.get_user_by_discord_id_and_server_id(ctx.author.id, server.id) + user = self._users.get_user_by_discord_id_and_server_id( + ctx.author.id, server.id + ) user.birthday = date self._users.update_user(user) self._db.save_changes() @@ -134,11 +141,15 @@ class UserGroup(DiscordCommandABC): ctx.interaction, self._t.transform("modules.base.user.birthday.success") ) # notify team to prevent multiple entries every day - settings: ServerConfig = self._config.get_configuration(f"ServerConfig_{ctx.guild.id}") + settings: ServerConfig = self._config.get_configuration( + f"ServerConfig_{ctx.guild.id}" + ) channel = ctx.guild.get_channel(settings.team_channel_id) await self._message_service.send_channel_message( channel, - self._t.transform("modules.base.user.birthday.success_team").format(ctx.author.mention, date), + self._t.transform("modules.base.user.birthday.success_team").format( + ctx.author.mention, date + ), is_persistent=True, ) self._logger.trace(__name__, f"Finished user-info command") @@ -177,12 +188,18 @@ class UserGroup(DiscordCommandABC): @user.command() @commands.guild_only() @CommandChecks.check_is_ready() - async def info(self, ctx: Context, member: Optional[discord.Member] = None, *, wait: int = None): - self._logger.debug(__name__, f"Received command user-info {ctx}:{member},{wait}") + async def info( + self, ctx: Context, member: Optional[discord.Member] = None, *, wait: int = None + ): + self._logger.debug( + __name__, f"Received command user-info {ctx}:{member},{wait}" + ) is_mod = self._permissions.is_member_moderator(ctx.author) if member is not None and not is_mod: - await self._message_service.send_ctx_msg(ctx, self._t.transform("common.no_permission_message")) + await self._message_service.send_ctx_msg( + ctx, self._t.transform("common.no_permission_message") + ) return if member is None or not isinstance(member, discord.Member): @@ -192,10 +209,16 @@ class UserGroup(DiscordCommandABC): user = self._users.find_user_by_discord_id_and_server_id(member.id, server.id) joins = self._user_joined_servers.get_user_joined_servers_by_user_id(user.id) - embed = discord.Embed(title=member.name, description=member.name, color=int("ef9d0d", 16)) + embed = discord.Embed( + title=member.name, description=member.name, color=int("ef9d0d", 16) + ) - embed.add_field(name=self._t.transform("modules.base.user.atr.id"), value=member.id) - embed.add_field(name=self._t.transform("modules.base.user.atr.name"), value=member.name) + embed.add_field( + name=self._t.transform("modules.base.user.atr.id"), value=member.id + ) + embed.add_field( + name=self._t.transform("modules.base.user.atr.name"), value=member.name + ) embed.add_field( name=self._t.transform("modules.base.user.atr.discord_join"), value=self._date.transform(member.created_at), @@ -206,7 +229,9 @@ class UserGroup(DiscordCommandABC): value=self._date.transform(member.joined_at), inline=False, ) - embed.add_field(name=self._t.transform("modules.base.user.atr.xp"), value=str(user.xp)) + embed.add_field( + name=self._t.transform("modules.base.user.atr.xp"), value=str(user.xp) + ) embed.add_field( name=self._t.transform("modules.base.user.atr.ontime"), value=str(self._client_utils.get_ontime_for_user(user)), @@ -256,7 +281,9 @@ class UserGroup(DiscordCommandABC): ) # send to interaction because of sensitive data - await self._message_service.send_interaction_msg(ctx.interaction, embed, wait_before_delete=wait) + await self._message_service.send_interaction_msg( + ctx.interaction, embed, wait_before_delete=wait + ) self._logger.trace(__name__, f"Finished user-info command") @user.command() @@ -267,7 +294,9 @@ class UserGroup(DiscordCommandABC): is_mod = self._permissions.is_member_moderator(ctx.author) if member is not None and not is_mod: - await self._message_service.send_ctx_msg(ctx, self._t.transform("common.no_permission_message")) + await self._message_service.send_ctx_msg( + ctx, self._t.transform("common.no_permission_message") + ) return if member is None or not isinstance(member, discord.Member): @@ -291,18 +320,26 @@ class UserGroup(DiscordCommandABC): await self._message_service.send_interaction_msg( ctx.interaction, - self._t.transform(f"modules.base.user.get.{atr.lower()}").format(member.mention, value), + self._t.transform(f"modules.base.user.get.{atr.lower()}").format( + member.mention, value + ), ) @get.autocomplete("atr") - async def get_autocomplete(self, interaction: discord.Interaction, current: str) -> TList[app_commands.Choice[str]]: - return [app_commands.Choice(name=value, value=key) for key, value in self._atr_TList] + async def get_autocomplete( + self, interaction: discord.Interaction, current: str + ) -> TList[app_commands.Choice[str]]: + return [ + app_commands.Choice(name=value, value=key) for key, value in self._atr_TList + ] @user.command() @commands.guild_only() @CommandChecks.check_is_ready() @CommandChecks.check_is_member_moderator() - async def set(self, ctx: Context, atr: str, value: int, member: discord.Member = None): + async def set( + self, ctx: Context, atr: str, value: int, member: discord.Member = None + ): self._logger.debug(__name__, f"Received command user-set {atr} {ctx}:{member}") if member is None or not isinstance(member, discord.Member): @@ -315,7 +352,9 @@ class UserGroup(DiscordCommandABC): try: user.xp = value except TypeError as te: - self._logger.error(__name__, f"String value couldn't be converted to int", te) + self._logger.error( + __name__, f"String value couldn't be converted to int", te + ) await self._message_service.send_interaction_msg( ctx.interaction, self._t.transform("modules.base.user.set.error.type_error"), @@ -335,11 +374,15 @@ class UserGroup(DiscordCommandABC): await self._message_service.send_interaction_msg( ctx.interaction, - self._t.transform(f"modules.base.user.set.{atr.lower()}").format(member.mention, value), + self._t.transform(f"modules.base.user.set.{atr.lower()}").format( + member.mention, value + ), ) @set.autocomplete("atr") - async def set_autocomplete(self, interaction: discord.Interaction, current: str) -> TList[app_commands.Choice[str]]: + async def set_autocomplete( + self, interaction: discord.Interaction, current: str + ) -> TList[app_commands.Choice[str]]: atr_TList = [("xp", self._atr_dict["xp"])] return [app_commands.Choice(name=value, value=key) for key, value in atr_TList] @@ -347,12 +390,18 @@ class UserGroup(DiscordCommandABC): @commands.guild_only() @CommandChecks.check_is_ready() @CommandChecks.check_is_member_moderator() - async def add(self, ctx: Context, atr: str, value: int, member: discord.Member = None): - self._logger.debug(__name__, f"Received command user-add {atr}-={value} {ctx}:{member}") + async def add( + self, ctx: Context, atr: str, value: int, member: discord.Member = None + ): + self._logger.debug( + __name__, f"Received command user-add {atr}-={value} {ctx}:{member}" + ) await self._handle_atr_calc(ctx, atr, value, member) @add.autocomplete("atr") - async def set_autocomplete(self, interaction: discord.Interaction, current: str) -> TList[app_commands.Choice[str]]: + async def set_autocomplete( + self, interaction: discord.Interaction, current: str + ) -> TList[app_commands.Choice[str]]: atr_TList = [("xp", self._atr_dict["xp"])] return [app_commands.Choice(name=value, value=key) for key, value in atr_TList] @@ -360,12 +409,18 @@ class UserGroup(DiscordCommandABC): @commands.guild_only() @CommandChecks.check_is_ready() @CommandChecks.check_is_member_moderator() - async def remove(self, ctx: Context, atr: str, value: int, member: discord.Member = None): - self._logger.debug(__name__, f"Received command user-remove {atr}-={value} {ctx}:{member}") + async def remove( + self, ctx: Context, atr: str, value: int, member: discord.Member = None + ): + self._logger.debug( + __name__, f"Received command user-remove {atr}-={value} {ctx}:{member}" + ) await self._handle_atr_calc(ctx, atr, value, member, is_remove=True) @remove.autocomplete("atr") - async def set_autocomplete(self, interaction: discord.Interaction, current: str) -> TList[app_commands.Choice[str]]: + async def set_autocomplete( + self, interaction: discord.Interaction, current: str + ) -> TList[app_commands.Choice[str]]: atr_TList = [("xp", self._atr_dict["xp"])] return [app_commands.Choice(name=value, value=key) for key, value in atr_TList] @@ -374,7 +429,9 @@ class UserGroup(DiscordCommandABC): @CommandChecks.check_is_ready() @CommandChecks.check_is_member_moderator() async def reset(self, ctx: Context, atr: str, member: discord.Member = None): - self._logger.debug(__name__, f"Received command user-reset {atr} {ctx}:{member}") + self._logger.debug( + __name__, f"Received command user-reset {atr} {ctx}:{member}" + ) if member is None or not isinstance(member, discord.Member): member = ctx.author @@ -389,7 +446,9 @@ class UserGroup(DiscordCommandABC): await self._level.check_level(member) elif atr == "ontime": - self._user_joined_voice_channel.delete_user_joined_voice_channel_by_user_id(user.id) + self._user_joined_voice_channel.delete_user_joined_voice_channel_by_user_id( + user.id + ) self._db.save_changes() else: @@ -401,14 +460,18 @@ class UserGroup(DiscordCommandABC): await self._message_service.send_interaction_msg( ctx.interaction, - self._t.transform(f"modules.base.user.reset.{atr.lower()}").format(atr, member.mention), + self._t.transform(f"modules.base.user.reset.{atr.lower()}").format( + atr, member.mention + ), ) @reset.autocomplete("atr") async def reset_autocomplete( self, interaction: discord.Interaction, current: str ) -> TList[app_commands.Choice[str]]: - return [app_commands.Choice(name=value, value=key) for key, value in self._atr_TList] + return [ + app_commands.Choice(name=value, value=key) for key, value in self._atr_TList + ] @user.group() @commands.guild_only() @@ -420,13 +483,17 @@ class UserGroup(DiscordCommandABC): @CommandChecks.check_is_ready() @CommandChecks.check_is_member_moderator() async def show(self, ctx: Context, member: discord.Member, wait: int = None): - self._logger.debug(__name__, f"Received command user warning show {ctx}:{member}") + self._logger.debug( + __name__, f"Received command user warning show {ctx}:{member}" + ) server = self._servers.find_server_by_discord_id(ctx.guild.id) user = self._users.find_user_by_discord_id_and_server_id(member.id, server.id) embed = discord.Embed( - title=member.name, description=self._t.transform("modules.base.user.atr.warnings"), color=int("ef9d0d", 16) + title=member.name, + description=self._t.transform("modules.base.user.atr.warnings"), + color=int("ef9d0d", 16), ) warnings = self._user_warnings.get_user_warnings_by_user_id(user.id) @@ -448,7 +515,9 @@ class UserGroup(DiscordCommandABC): value=warnings_description_string, inline=True, ) - await self._message_service.send_interaction_msg(ctx.interaction, embed, wait_before_delete=wait) + await self._message_service.send_interaction_msg( + ctx.interaction, embed, wait_before_delete=wait + ) self._logger.trace(__name__, f"Finished user warning show command") @warning.command() @@ -456,13 +525,21 @@ class UserGroup(DiscordCommandABC): @CommandChecks.check_is_ready() @CommandChecks.check_is_member_moderator() async def add(self, ctx: Context, member: discord.Member, description: str): - self._logger.debug(__name__, f"Received command user warning add {ctx}:{member},{description}") + self._logger.debug( + __name__, f"Received command user warning add {ctx}:{member},{description}" + ) try: - await self._user_warnings_service.add_warnings_async(member, description, ctx.author.id) - await self._message_service.send_ctx_msg(ctx, self._t.transform("modules.base.warnings.add.success")) + await self._user_warnings_service.add_warnings_async( + member, description, ctx.author.id + ) + await self._message_service.send_ctx_msg( + ctx, self._t.transform("modules.base.warnings.add.success") + ) except Exception as e: self._logger.error(__name__, f"Adding user warning failed", e) - await self._message_service.send_ctx_msg(ctx, self._t.transform("modules.base.warnings.add.failed")) + await self._message_service.send_ctx_msg( + ctx, self._t.transform("modules.base.warnings.add.failed") + ) self._logger.trace(__name__, f"Finished user warning add command") @warning.command() @@ -470,11 +547,17 @@ class UserGroup(DiscordCommandABC): @CommandChecks.check_is_ready() @CommandChecks.check_is_member_moderator() async def remove(self, ctx: Context, warning_id: int): - self._logger.debug(__name__, f"Received command user warning remove {ctx}:{warning_id}") + self._logger.debug( + __name__, f"Received command user warning remove {ctx}:{warning_id}" + ) try: await self._user_warnings_service.remove_warnings_async(warning_id) - await self._message_service.send_ctx_msg(ctx, self._t.transform("modules.base.warnings.remove.success")) + await self._message_service.send_ctx_msg( + ctx, self._t.transform("modules.base.warnings.remove.success") + ) except Exception as e: self._logger.error(__name__, f"Removing user warning failed", e) - await self._message_service.send_ctx_msg(ctx, self._t.transform("modules.base.warnings.remove.failed")) + await self._message_service.send_ctx_msg( + ctx, self._t.transform("modules.base.warnings.remove.failed") + ) self._logger.trace(__name__, f"Finished user warning remove command") diff --git a/kdb-bot/src/modules/base/events/__init__.py b/bot/src/modules/base/events/__init__.py similarity index 100% rename from kdb-bot/src/modules/base/events/__init__.py rename to bot/src/modules/base/events/__init__.py diff --git a/kdb-bot/src/modules/base/events/base_on_command_error_event.py b/bot/src/modules/base/events/base_on_command_error_event.py similarity index 94% rename from kdb-bot/src/modules/base/events/base_on_command_error_event.py rename to bot/src/modules/base/events/base_on_command_error_event.py index d5aab492..5a4628f6 100644 --- a/kdb-bot/src/modules/base/events/base_on_command_error_event.py +++ b/bot/src/modules/base/events/base_on_command_error_event.py @@ -167,7 +167,9 @@ class BaseOnCommandErrorEvent(OnCommandErrorABC): ) elif isinstance(error, commands.NotOwner): - await self._messenger.send_ctx_msg(ctx, self._t.transform("common.errors.not_owner"), without_tracking=True) + await self._messenger.send_ctx_msg( + ctx, self._t.transform("common.errors.not_owner"), without_tracking=True + ) elif isinstance(error, commands.MissingPermissions): await self._messenger.send_ctx_msg( @@ -259,13 +261,19 @@ class BaseOnCommandErrorEvent(OnCommandErrorABC): self._t.transform("common.errors.command_error"), without_tracking=True, ) - message = self._t.transform("modules.base.technician_command_error_message").format( + message = self._t.transform( + "modules.base.technician_command_error_message" + ).format( ctx.command, ctx.author, error, - datetime.datetime.now().strftime(self._time_format_settings.date_time_format), + datetime.datetime.now().strftime( + self._time_format_settings.date_time_format + ), uid, ) for t in self._tech_settings.technician_ids: member = self._bot.get_user(t) - await self._messenger.send_dm_message(message, member, without_tracking=True) + await self._messenger.send_dm_message( + message, member, without_tracking=True + ) diff --git a/kdb-bot/src/modules/base/events/base_on_command_event.py b/bot/src/modules/base/events/base_on_command_event.py similarity index 86% rename from kdb-bot/src/modules/base/events/base_on_command_event.py rename to bot/src/modules/base/events/base_on_command_event.py index 407a875f..149426d5 100644 --- a/kdb-bot/src/modules/base/events/base_on_command_event.py +++ b/bot/src/modules/base/events/base_on_command_event.py @@ -49,7 +49,9 @@ class BaseOnCommandEvent(OnCommandABC): self._clients.append_received_command_count(self._bot.user.id, g_id, 1) self._db.save_changes() except Exception as e: - self._logger.error(__name__, f"Cannot edit client {self._bot.user.id}@{g_id}", e) + self._logger.error( + __name__, f"Cannot edit client {self._bot.user.id}@{g_id}", e + ) def _handle_message_for_xp(self, message: discord.Message): dc_user_id = message.author.id @@ -61,7 +63,9 @@ class BaseOnCommandEvent(OnCommandABC): user: Optional[User] = None try: - user = self._users.get_user_by_discord_id_and_server_id(dc_user_id, server.id) + user = self._users.get_user_by_discord_id_and_server_id( + dc_user_id, server.id + ) except Exception as e: self._logger.error(__name__, f"Cannot get user {dc_user_id}", e) return @@ -70,17 +74,23 @@ class BaseOnCommandEvent(OnCommandABC): self._logger.error(__name__, f"User not found {dc_user_id}") return - settings: ServerConfig = self._config.get_configuration(f"ServerConfig_{message.guild.id}") + settings: ServerConfig = self._config.get_configuration( + f"ServerConfig_{message.guild.id}" + ) old_xp = user.xp user.xp += settings.xp_per_message self._users.update_user(user) self._db.save_changes() - self._logger.debug(__name__, f"User {user} sent message. xp: from {old_xp} to {user.xp}") + self._logger.debug( + __name__, f"User {user} sent message. xp: from {old_xp} to {user.xp}" + ) async def on_command(self, ctx: Context): self._logger.debug(__name__, f"Module {type(self)} started") - self._logger.info(__name__, f"Received command: {ctx.command} from {ctx.channel}") + self._logger.info( + __name__, f"Received command: {ctx.command} from {ctx.channel}" + ) if ctx is None or ctx.guild is None: return self._append_received_command_count(ctx.guild.id) diff --git a/kdb-bot/src/modules/base/events/base_on_guild_join_event.py b/bot/src/modules/base/events/base_on_guild_join_event.py similarity index 100% rename from kdb-bot/src/modules/base/events/base_on_guild_join_event.py rename to bot/src/modules/base/events/base_on_guild_join_event.py diff --git a/kdb-bot/src/modules/base/events/base_on_member_join_event.py b/bot/src/modules/base/events/base_on_member_join_event.py similarity index 88% rename from kdb-bot/src/modules/base/events/base_on_member_join_event.py rename to bot/src/modules/base/events/base_on_member_join_event.py index a09772d6..99939a27 100644 --- a/kdb-bot/src/modules/base/events/base_on_member_join_event.py +++ b/bot/src/modules/base/events/base_on_member_join_event.py @@ -66,7 +66,9 @@ class BaseOnMemberJoinEvent(OnMemberJoinABC): except Exception as e: self._logger.error(__name__, f"Cannot get user {member.id}", e) - async def _add_if_not_exists_user_async(self, member: Union[discord.User, discord.Member]): + async def _add_if_not_exists_user_async( + self, member: Union[discord.User, discord.Member] + ): self._logger.debug(__name__, f"Check if user exists {member}") await self._messenger.send_dm_message( self._t.transform("modules.base.welcome_message").format(member.guild.name), @@ -75,28 +77,40 @@ class BaseOnMemberJoinEvent(OnMemberJoinABC): try: server = self._servers.get_server_by_discord_id(member.guild.id) - user = self._users.find_user_by_discord_id_and_server_id(member.id, server.id) + user = self._users.find_user_by_discord_id_and_server_id( + member.id, server.id + ) if user is not None: - self._user_joins.add_user_joined_server(UserJoinedServer(user, datetime.now())) + self._user_joins.add_user_joined_server( + UserJoinedServer(user, datetime.now()) + ) self._db.save_changes() return self._logger.debug(__name__, f"Add user: {member.id}") self._users.add_user(User(member.id, 0, 0, 0, server)) self._db.save_changes() - user = self._users.get_user_by_discord_id_and_server_id(member.id, server.id) - self._user_joins.add_user_joined_server(UserJoinedServer(user, datetime.now())) + user = self._users.get_user_by_discord_id_and_server_id( + member.id, server.id + ) + self._user_joins.add_user_joined_server( + UserJoinedServer(user, datetime.now()) + ) self._db.save_changes() except Exception as e: self._logger.error(__name__, f"Cannot get user {member.id}", e) async def _notify_team(self, member: discord.Member): self._logger.debug(__name__, f"Notify team that a member left") - settings: ServerConfig = self._config.get_configuration(f"ServerConfig_{member.guild.id}") + settings: ServerConfig = self._config.get_configuration( + f"ServerConfig_{member.guild.id}" + ) channel = member.guild.get_channel(settings.team_channel_id) await self._messenger.send_channel_message( channel, - self._t.transform("modules.base.welcome_message_for_team").format(member.mention), + self._t.transform("modules.base.welcome_message_for_team").format( + member.mention + ), is_persistent=True, ) self._logger.trace(__name__, f"Notified team that a member left") diff --git a/kdb-bot/src/modules/base/events/base_on_member_remove_event.py b/bot/src/modules/base/events/base_on_member_remove_event.py similarity index 90% rename from kdb-bot/src/modules/base/events/base_on_member_remove_event.py rename to bot/src/modules/base/events/base_on_member_remove_event.py index adfe7e87..ed6a02df 100644 --- a/kdb-bot/src/modules/base/events/base_on_member_remove_event.py +++ b/bot/src/modules/base/events/base_on_member_remove_event.py @@ -41,12 +41,16 @@ class BaseOnMemberRemoveEvent(OnMemberRemoveABC): async def _remove_user(self, member: Union[discord.User, discord.Member]): self._logger.debug(__name__, f"Remove user {member}") - await self._message_service.send_dm_message(self._t.transform("modules.base.goodbye_message"), member) + await self._message_service.send_dm_message( + self._t.transform("modules.base.goodbye_message"), member + ) try: server = self._servers.get_server_by_discord_id(member.guild.id) - user = self._users.find_user_by_discord_id_and_server_id(member.id, server.id) + user = self._users.find_user_by_discord_id_and_server_id( + member.id, server.id + ) if user is None: self._logger.error(__name__, f"Cannot find user {member}") return @@ -60,11 +64,15 @@ class BaseOnMemberRemoveEvent(OnMemberRemoveABC): async def _notify_team(self, member: discord.Member): self._logger.debug(__name__, f"Notify team that a member left") - settings: ServerConfig = self._config.get_configuration(f"ServerConfig_{member.guild.id}") + settings: ServerConfig = self._config.get_configuration( + f"ServerConfig_{member.guild.id}" + ) channel = member.guild.get_channel(settings.team_channel_id) await self._message_service.send_channel_message( channel, - self._t.transform("modules.base.member_left_message").format(member.mention), + self._t.transform("modules.base.member_left_message").format( + member.mention + ), is_persistent=True, ) self._logger.trace(__name__, f"Notified team that a member left") diff --git a/kdb-bot/src/modules/base/events/base_on_message_delete_event.py b/bot/src/modules/base/events/base_on_message_delete_event.py similarity index 88% rename from kdb-bot/src/modules/base/events/base_on_message_delete_event.py rename to bot/src/modules/base/events/base_on_message_delete_event.py index 3d3aad1c..c3bcd022 100644 --- a/kdb-bot/src/modules/base/events/base_on_message_delete_event.py +++ b/bot/src/modules/base/events/base_on_message_delete_event.py @@ -40,7 +40,9 @@ class BaseOnMessageDeleteEvent(OnMessageDeleteABC): self._clients.append_deleted_message_count(self._bot.user.id, g_id, 1) self._db.save_changes() except Exception as e: - self._logger.error(__name__, f"Cannot edit client {self._bot.user.id}@{g_id}", e) + self._logger.error( + __name__, f"Cannot edit client {self._bot.user.id}@{g_id}", e + ) def _handle_message_delete(self, message: discord.Message): dc_user_id = message.author.id @@ -52,7 +54,9 @@ class BaseOnMessageDeleteEvent(OnMessageDeleteABC): user: Optional[User] = None try: - user = self._users.find_user_by_discord_id_and_server_id(dc_user_id, server.id) + user = self._users.find_user_by_discord_id_and_server_id( + dc_user_id, server.id + ) except Exception as e: self._logger.error(__name__, f"Cannot get user {dc_user_id}", e) return @@ -61,7 +65,9 @@ class BaseOnMessageDeleteEvent(OnMessageDeleteABC): self._logger.error(__name__, f"User not found {dc_user_id}") return - settings: ServerConfig = self._config.get_configuration(f"ServerConfig_{message.guild.id}") + settings: ServerConfig = self._config.get_configuration( + f"ServerConfig_{message.guild.id}" + ) old_xp = user.xp user.xp -= settings.xp_per_message self._users.update_user(user) @@ -77,7 +83,9 @@ class BaseOnMessageDeleteEvent(OnMessageDeleteABC): if message is None or message.guild is None: return - self._logger.info(__name__, f"Received message: {LogMessageHelper.get_log_string(message)}") + self._logger.info( + __name__, f"Received message: {LogMessageHelper.get_log_string(message)}" + ) self._append_deleted_message_count(message.guild.id) if not message.author.bot: diff --git a/kdb-bot/src/modules/base/events/base_on_message_event.py b/bot/src/modules/base/events/base_on_message_event.py similarity index 86% rename from kdb-bot/src/modules/base/events/base_on_message_event.py rename to bot/src/modules/base/events/base_on_message_event.py index e6531385..438b10b8 100644 --- a/kdb-bot/src/modules/base/events/base_on_message_event.py +++ b/bot/src/modules/base/events/base_on_message_event.py @@ -45,7 +45,9 @@ class BaseOnMessageEvent(OnMessageABC): self._clients.append_received_message_count(self._bot.user.id, g_id, 1) self._db.save_changes() except Exception as e: - self._logger.error(__name__, f"Cannot edit client {self._bot.user.id}@{g_id}", e) + self._logger.error( + __name__, f"Cannot edit client {self._bot.user.id}@{g_id}", e + ) def _handle_message_for_xp(self, message: discord.Message): dc_user_id = message.author.id @@ -57,7 +59,9 @@ class BaseOnMessageEvent(OnMessageABC): user: Optional[User] = None try: - user = self._users.find_user_by_discord_id_and_server_id(dc_user_id, server.id) + user = self._users.find_user_by_discord_id_and_server_id( + dc_user_id, server.id + ) except Exception as e: self._logger.error(__name__, f"Cannot get user {dc_user_id}", e) return @@ -66,7 +70,9 @@ class BaseOnMessageEvent(OnMessageABC): self._logger.error(__name__, f"User not found {dc_user_id}") return - settings: ServerConfig = self._config.get_configuration(f"ServerConfig_{server.discord_id}") + settings: ServerConfig = self._config.get_configuration( + f"ServerConfig_{server.discord_id}" + ) if self._client_utils.is_message_xp_count_by_hour_higher_that_max_message_count_per_hour( message.created_at, user, settings ): @@ -77,7 +83,9 @@ class BaseOnMessageEvent(OnMessageABC): self._users.update_user(user) self._db.save_changes() - self._logger.debug(__name__, f"User {user} sent message. xp: from {old_xp} to {user.xp}") + self._logger.debug( + __name__, f"User {user} sent message. xp: from {old_xp} to {user.xp}" + ) @EventChecks.check_is_ready() async def on_message(self, message: discord.Message): @@ -85,7 +93,9 @@ class BaseOnMessageEvent(OnMessageABC): if message is None or message.guild is None: return - self._logger.info(__name__, f"Received message: {LogMessageHelper.get_log_string(message)}") + self._logger.info( + __name__, f"Received message: {LogMessageHelper.get_log_string(message)}" + ) self._append_received_message_count(message.guild.id) if not message.author.bot: diff --git a/kdb-bot/src/modules/base/events/base_on_raw_reaction_add.py b/bot/src/modules/base/events/base_on_raw_reaction_add.py similarity index 100% rename from kdb-bot/src/modules/base/events/base_on_raw_reaction_add.py rename to bot/src/modules/base/events/base_on_raw_reaction_add.py diff --git a/kdb-bot/src/modules/base/events/base_on_raw_reaction_remove.py b/bot/src/modules/base/events/base_on_raw_reaction_remove.py similarity index 100% rename from kdb-bot/src/modules/base/events/base_on_raw_reaction_remove.py rename to bot/src/modules/base/events/base_on_raw_reaction_remove.py diff --git a/kdb-bot/src/modules/base/events/base_on_scheduled_event_update_event.py b/bot/src/modules/base/events/base_on_scheduled_event_update_event.py similarity index 84% rename from kdb-bot/src/modules/base/events/base_on_scheduled_event_update_event.py rename to bot/src/modules/base/events/base_on_scheduled_event_update_event.py index 640a9a80..f3dfda00 100644 --- a/kdb-bot/src/modules/base/events/base_on_scheduled_event_update_event.py +++ b/bot/src/modules/base/events/base_on_scheduled_event_update_event.py @@ -21,7 +21,9 @@ class BaseOnScheduledEventUpdateEvent(OnScheduledEventUpdateABC): self._bot = bot self._events = events - async def on_scheduled_event_update(self, before: discord.ScheduledEvent, after: discord.ScheduledEvent): + async def on_scheduled_event_update( + self, before: discord.ScheduledEvent, after: discord.ScheduledEvent + ): self._logger.debug(__name__, f"Module {type(self)} started") # save started event @@ -33,7 +35,8 @@ class BaseOnScheduledEventUpdateEvent(OnScheduledEventUpdateABC): self._events.give_xp_for_event_participation(member, active_event) # delete stopped event if before.status != after.status and ( - after.status.value == EventStatus.cancelled.value or after.status.value == EventStatus.completed.value + after.status.value == EventStatus.cancelled.value + or after.status.value == EventStatus.completed.value ): event = self._events.get_active_event(after) if event is None: diff --git a/kdb-bot/src/modules/base/events/base_on_voice_state_update_event.py b/bot/src/modules/base/events/base_on_voice_state_update_event.py similarity index 75% rename from kdb-bot/src/modules/base/events/base_on_voice_state_update_event.py rename to bot/src/modules/base/events/base_on_voice_state_update_event.py index 6fb0c113..5a5e25ab 100644 --- a/kdb-bot/src/modules/base/events/base_on_voice_state_update_event.py +++ b/bot/src/modules/base/events/base_on_voice_state_update_event.py @@ -45,10 +45,14 @@ class BaseOnVoiceStateUpdateEvent(OnVoiceStateUpdateABC): self._logger.info(__name__, f"Module {type(self)} loaded") - def _update_voice_state(self, joined: bool, dc_user_id: int, channel_id: int, server: Server): + def _update_voice_state( + self, joined: bool, dc_user_id: int, channel_id: int, server: Server + ): user: Optional[User] = None try: - user = self._users.get_user_by_discord_id_and_server_id(dc_user_id, server.id) + user = self._users.get_user_by_discord_id_and_server_id( + dc_user_id, server.id + ) except Exception as e: self._logger.error(__name__, f"Cannot get user {dc_user_id}", e) return @@ -64,9 +68,13 @@ class BaseOnVoiceStateUpdateEvent(OnVoiceStateUpdateABC): self._db.save_changes() return - settings: ServerConfig = self._config.get_configuration(f"ServerConfig_{server.discord_id}") + settings: ServerConfig = self._config.get_configuration( + f"ServerConfig_{server.discord_id}" + ) - join = self._user_joins_vc.get_active_user_joined_voice_channel_by_user_id(user.id) + join = self._user_joins_vc.get_active_user_joined_voice_channel_by_user_id( + user.id + ) join.leaved_on = datetime.now() old_xp = user.xp @@ -95,7 +103,9 @@ class BaseOnVoiceStateUpdateEvent(OnVoiceStateUpdateABC): __name__, f"Detected on_voice_state_update {member.id} from {before} to {after}", ) - settings: ServerConfig = self._config.get_configuration(f"ServerConfig_{member.guild.id}") + settings: ServerConfig = self._config.get_configuration( + f"ServerConfig_{member.guild.id}" + ) server = self._servers.get_server_by_discord_id(member.guild.id) try: @@ -123,18 +133,36 @@ class BaseOnVoiceStateUpdateEvent(OnVoiceStateUpdateABC): # channel to channel elif before.channel is not None and after.channel is not None: # joined - if before.channel.id in settings.afk_channel_ids and after.channel.id not in settings.afk_channel_ids: - self._logger.trace(__name__, f"User {member.id} joined {after.channel}") + if ( + before.channel.id in settings.afk_channel_ids + and after.channel.id not in settings.afk_channel_ids + ): + self._logger.trace( + __name__, f"User {member.id} joined {after.channel}" + ) self._update_voice_state(True, member.id, after.channel.id, server) # left - elif after.channel.id in settings.afk_channel_ids and before.channel.id not in settings.afk_channel_ids: - self._logger.trace(__name__, f"User {member.id} left {before.channel}") - self._update_voice_state(False, member.id, before.channel.id, server) + elif ( + after.channel.id in settings.afk_channel_ids + and before.channel.id not in settings.afk_channel_ids + ): + self._logger.trace( + __name__, f"User {member.id} left {before.channel}" + ) + self._update_voice_state( + False, member.id, before.channel.id, server + ) else: - self._logger.trace(__name__, f"User {member.id} switched to {after.channel}") - self._update_voice_state(False, member.id, before.channel.id, server) + self._logger.trace( + __name__, f"User {member.id} switched to {after.channel}" + ) + self._update_voice_state( + False, member.id, before.channel.id, server + ) self._update_voice_state(True, member.id, after.channel.id, server) except Exception as e: - self._logger.error(__name__, f"Cannot handle voice state for user {member.id}", e) + self._logger.error( + __name__, f"Cannot handle voice state for user {member.id}", e + ) diff --git a/kdb-bot/src/modules/base/events/base_on_voice_state_update_event_help_channel.py b/bot/src/modules/base/events/base_on_voice_state_update_event_help_channel.py similarity index 92% rename from kdb-bot/src/modules/base/events/base_on_voice_state_update_event_help_channel.py rename to bot/src/modules/base/events/base_on_voice_state_update_event_help_channel.py index 3e1b3da0..d1d24e07 100644 --- a/kdb-bot/src/modules/base/events/base_on_voice_state_update_event_help_channel.py +++ b/bot/src/modules/base/events/base_on_voice_state_update_event_help_channel.py @@ -33,11 +33,15 @@ class BaseOnVoiceStateUpdateEventHelpChannel(OnVoiceStateUpdateABC): async def _notify_team(self, member: discord.Member): self._logger.debug(__name__, f"Notify team that a member needs help") - settings: ServerConfig = self._config.get_configuration(f"ServerConfig_{member.guild.id}") + settings: ServerConfig = self._config.get_configuration( + f"ServerConfig_{member.guild.id}" + ) channel = member.guild.get_channel(settings.team_channel_id) await self._message_service.send_channel_message( channel, - self._t.transform("modules.base.member_joined_help_voice_channel").format(member.mention), + self._t.transform("modules.base.member_joined_help_voice_channel").format( + member.mention + ), is_persistent=True, ) self._logger.trace(__name__, f"Notified team that a member need help") @@ -51,7 +55,9 @@ class BaseOnVoiceStateUpdateEventHelpChannel(OnVoiceStateUpdateABC): ): self._logger.debug(__name__, f"Module {type(self)} started") server = self._servers.get_server_by_discord_id(member.guild.id) - settings: ServerConfig = self._config.get_configuration(f"ServerConfig_{server.discord_id}") + settings: ServerConfig = self._config.get_configuration( + f"ServerConfig_{server.discord_id}" + ) if after.channel is None or after.channel.id != settings.help_voice_channel_id: return diff --git a/kdb-bot/src/modules/base/events/base_on_voice_state_update_event_scheduled_event_bonus.py b/bot/src/modules/base/events/base_on_voice_state_update_event_scheduled_event_bonus.py similarity index 100% rename from kdb-bot/src/modules/base/events/base_on_voice_state_update_event_scheduled_event_bonus.py rename to bot/src/modules/base/events/base_on_voice_state_update_event_scheduled_event_bonus.py diff --git a/kdb-bot/src/modules/base/forms/__init__.py b/bot/src/modules/base/forms/__init__.py similarity index 100% rename from kdb-bot/src/modules/base/forms/__init__.py rename to bot/src/modules/base/forms/__init__.py diff --git a/kdb-bot/src/modules/base/forms/bug_report_form.py b/bot/src/modules/base/forms/bug_report_form.py similarity index 81% rename from kdb-bot/src/modules/base/forms/bug_report_form.py rename to bot/src/modules/base/forms/bug_report_form.py index 185fd51f..88fc6cab 100644 --- a/kdb-bot/src/modules/base/forms/bug_report_form.py +++ b/bot/src/modules/base/forms/bug_report_form.py @@ -10,7 +10,9 @@ from bot_data.model.technician_config import TechnicianConfig class BugReportForm(ui.Modal): - description = ui.TextInput(label="Report a bug", required=True, style=TextStyle.long) + description = ui.TextInput( + label="Report a bug", required=True, style=TextStyle.long + ) def __init__( self, @@ -38,10 +40,14 @@ class BugReportForm(ui.Modal): for t in self._technician_config.technician_ids: member = self._bot.get_user(t) await self._message_service.send_dm_message( - self._t.transform("modules.base.bug.message").format(interaction.user.mention, self.description.value), + self._t.transform("modules.base.bug.message").format( + interaction.user.mention, self.description.value + ), member, without_tracking=True, ) - await self._message_service.send_interaction_msg(interaction, self._t.transform("modules.base.bug.response")) + await self._message_service.send_interaction_msg( + interaction, self._t.transform("modules.base.bug.response") + ) self._logger.trace(__name__, f"Finished bug report form") diff --git a/kdb-bot/src/modules/base/forms/complaint_form.py b/bot/src/modules/base/forms/complaint_form.py similarity index 90% rename from kdb-bot/src/modules/base/forms/complaint_form.py rename to bot/src/modules/base/forms/complaint_form.py index b0d77813..cb39e23c 100644 --- a/kdb-bot/src/modules/base/forms/complaint_form.py +++ b/bot/src/modules/base/forms/complaint_form.py @@ -10,7 +10,9 @@ from bot_data.model.server_config import ServerConfig class ComplaintForm(ui.Modal): - description = ui.TextInput(label="Complain about something", required=True, style=TextStyle.long) + description = ui.TextInput( + label="Complain about something", required=True, style=TextStyle.long + ) def __init__( self, @@ -32,7 +34,9 @@ class ComplaintForm(ui.Modal): async def on_submit(self, interaction: discord.Interaction): self._logger.debug(__name__, f"Started complaint command form") - settings: ServerConfig = self._config.get_configuration(f"ServerConfig_{interaction.guild.id}") + settings: ServerConfig = self._config.get_configuration( + f"ServerConfig_{interaction.guild.id}" + ) channel = interaction.guild.get_channel(settings.team_channel_id) await self._message_service.send_channel_message( channel, diff --git a/kdb-bot/src/modules/base/helper/__init__.py b/bot/src/modules/base/helper/__init__.py similarity index 100% rename from kdb-bot/src/modules/base/helper/__init__.py rename to bot/src/modules/base/helper/__init__.py diff --git a/kdb-bot/src/modules/base/helper/base_reaction_handler.py b/bot/src/modules/base/helper/base_reaction_handler.py similarity index 87% rename from kdb-bot/src/modules/base/helper/base_reaction_handler.py rename to bot/src/modules/base/helper/base_reaction_handler.py index d2cb1581..e63f4412 100644 --- a/kdb-bot/src/modules/base/helper/base_reaction_handler.py +++ b/bot/src/modules/base/helper/base_reaction_handler.py @@ -38,7 +38,9 @@ class BaseReactionHandler: guild = self._bot.get_guild(payload.guild_id) member = guild.get_member(payload.user_id) if member is None: - self._logger.warn(__name__, f"User {payload.user_id} in {guild.name} not found - skipping") + self._logger.warn( + __name__, f"User {payload.user_id} in {guild.name} not found - skipping" + ) return try: @@ -60,8 +62,12 @@ class BaseReactionHandler: self._logger.debug(__name__, f"Skipping reaction handling") return except Exception as e: - self._logger.error(__name__, f"Getting message for reaction logging failed", e) - self._logger.info(__name__, f"{log_msg} to message {payload.message_id}") + self._logger.error( + __name__, f"Getting message for reaction logging failed", e + ) + self._logger.info( + __name__, f"{log_msg} to message {payload.message_id}" + ) except Exception as e: self._logger.error(__name__, f"Reaction logging failed", e) @@ -70,7 +76,9 @@ class BaseReactionHandler: server = self._servers.get_server_by_discord_id(guild.id) user = self._users.get_user_by_discord_id_and_server_id(member.id, server.id) - settings: ServerConfig = self._config.get_configuration(f"ServerConfig_{guild.id}") + settings: ServerConfig = self._config.get_configuration( + f"ServerConfig_{guild.id}" + ) if r_type == "add": if self._client_utils.is_message_xp_count_by_hour_higher_that_max_message_count_per_hour( diff --git a/kdb-bot/src/modules/base/helper/voice_channel_transformer.py b/bot/src/modules/base/helper/voice_channel_transformer.py similarity index 62% rename from kdb-bot/src/modules/base/helper/voice_channel_transformer.py rename to bot/src/modules/base/helper/voice_channel_transformer.py index a9ee5df0..f7fa205f 100644 --- a/kdb-bot/src/modules/base/helper/voice_channel_transformer.py +++ b/bot/src/modules/base/helper/voice_channel_transformer.py @@ -8,7 +8,9 @@ from bot_core.abc.client_utils_abc import ClientUtilsABC class VoiceChannelTransformer(Transformer): - async def transform(self, interaction: Interaction, value: str, /) -> discord.VoiceChannel: + async def transform( + self, interaction: Interaction, value: str, / + ) -> discord.VoiceChannel: voice_channel = ( List(discord.VoiceChannel, interaction.guild.voice_channels) .where(lambda x: str(x.id) == value) @@ -16,15 +18,24 @@ class VoiceChannelTransformer(Transformer): ) return voice_channel - async def autocomplete(self, interaction: Interaction, current: str, /) -> list[Choice[str]]: + async def autocomplete( + self, interaction: Interaction, current: str, / + ) -> list[Choice[str]]: @ServiceProviderABC.inject def get_client_utils(client_utils: ClientUtilsABC) -> ClientUtilsABC: return client_utils - voice_channels = List(discord.Role, interaction.guild.voice_channels).where(lambda x: len(x.members) > 0) + voice_channels = List(discord.Role, interaction.guild.voice_channels).where( + lambda x: len(x.members) > 0 + ) return [ app_commands.Choice( - name=f"{vc.name}" if vc.category is None else f"{vc.name}: {vc.category.name}", value=vc.name + name=f"{vc.name}" + if vc.category is None + else f"{vc.name}: {vc.category.name}", + value=vc.name, + ) + for vc in get_client_utils().get_auto_complete_list( + voice_channels, current, lambda x: x.name ) - for vc in get_client_utils().get_auto_complete_list(voice_channels, current, lambda x: x.name) ] diff --git a/kdb-bot/src/modules/base/model/__init__.py b/bot/src/modules/base/model/__init__.py similarity index 100% rename from kdb-bot/src/modules/base/model/__init__.py rename to bot/src/modules/base/model/__init__.py diff --git a/kdb-bot/src/modules/base/model/active_event.py b/bot/src/modules/base/model/active_event.py similarity index 100% rename from kdb-bot/src/modules/base/model/active_event.py rename to bot/src/modules/base/model/active_event.py diff --git a/kdb-bot/src/modules/base/service/__init__.py b/bot/src/modules/base/service/__init__.py similarity index 100% rename from kdb-bot/src/modules/base/service/__init__.py rename to bot/src/modules/base/service/__init__.py diff --git a/kdb-bot/src/modules/base/service/event_service.py b/bot/src/modules/base/service/event_service.py similarity index 87% rename from kdb-bot/src/modules/base/service/event_service.py rename to bot/src/modules/base/service/event_service.py index 30b19d96..51cf211c 100644 --- a/kdb-bot/src/modules/base/service/event_service.py +++ b/bot/src/modules/base/service/event_service.py @@ -36,7 +36,9 @@ class EventService: self._active_events.add(event) def get_active_event(self, event: discord.ScheduledEvent) -> Optional[ActiveEvent]: - return self._active_events.where(lambda x: x.event.id == event.id).single_or_default() + return self._active_events.where( + lambda x: x.event.id == event.id + ).single_or_default() def get_active_event_by_channel_id(self, channel_id: int) -> Optional[ActiveEvent]: return self._active_events.where( @@ -49,14 +51,18 @@ class EventService: self._active_events.remove(event) - def give_xp_for_event_participation(self, member: discord.Member, active_event: ActiveEvent): + def give_xp_for_event_participation( + self, member: discord.Member, active_event: ActiveEvent + ): server = self._servers.get_server_by_discord_id(member.guild.id) user = self._users.get_user_by_discord_id_and_server_id(member.id, server.id) if active_event.participants.any(lambda x: x.id == user.id): self._logger.debug(__name__, f"Module {type(self)} stopped") return - settings: ServerConfig = self._config.get_configuration(f"ServerConfig_{server.discord_id}") + settings: ServerConfig = self._config.get_configuration( + f"ServerConfig_{server.discord_id}" + ) user.xp += settings.xp_per_event_participation self._users.update_user(user) self._db.save_changes() diff --git a/kdb-bot/src/modules/base/service/user_warnings_service.py b/bot/src/modules/base/service/user_warnings_service.py similarity index 66% rename from kdb-bot/src/modules/base/service/user_warnings_service.py rename to bot/src/modules/base/service/user_warnings_service.py index d69659e6..54c394c7 100644 --- a/kdb-bot/src/modules/base/service/user_warnings_service.py +++ b/bot/src/modules/base/service/user_warnings_service.py @@ -46,101 +46,154 @@ class UserWarningsService: self._t = t self._permissions = permissions - async def notify_team(self, member: discord.Member, description: str, removed=False): + async def notify_team( + self, member: discord.Member, description: str, removed=False + ): try: - settings: ServerConfig = self._config.get_configuration(f"ServerConfig_{member.guild.id}") + settings: ServerConfig = self._config.get_configuration( + f"ServerConfig_{member.guild.id}" + ) channel = member.guild.get_channel(settings.team_channel_id) if removed: - translation = self._t.transform("modules.base.warnings.team_removed").format( - description, member.mention - ) + translation = self._t.transform( + "modules.base.warnings.team_removed" + ).format(description, member.mention) else: - translation = self._t.transform("modules.base.warnings.team_warned").format(member.mention, description) + translation = self._t.transform( + "modules.base.warnings.team_warned" + ).format(member.mention, description) self._bot.loop.create_task( - self._message_service.send_channel_message(channel, translation, is_persistent=True) + self._message_service.send_channel_message( + channel, translation, is_persistent=True + ) ) except Exception as e: - self._logger.error(__name__, f"Team notification for user warning failed!", e) + self._logger.error( + __name__, f"Team notification for user warning failed!", e + ) async def notify_user(self, member: discord.Member, message: str): try: # run as task to keep the interaction alive - self._bot.loop.create_task(self._message_service.send_dm_message(message, member)) + self._bot.loop.create_task( + self._message_service.send_dm_message(message, member) + ) except Exception as e: - self._logger.error(__name__, f"User notification for user warning failed!", e) + self._logger.error( + __name__, f"User notification for user warning failed!", e + ) async def check_for_warnings(self, member: discord.Member, user: User): existing_warnings = self._warnings.get_user_warnings_by_user_id(user.id) if existing_warnings.count() == 1: - await self.notify_user(member, self._t.transform("modules.base.warnings.first")) + await self.notify_user( + member, self._t.transform("modules.base.warnings.first") + ) elif existing_warnings.count() == 2: server = self._servers.get_server_by_discord_id(member.guild.id) - user = self._users.get_user_by_discord_id_and_server_id(member.id, server.id) + user = self._users.get_user_by_discord_id_and_server_id( + member.id, server.id + ) level = self._level_service.get_level(user) - levels = self._levels.get_levels_by_server_id(server.id).order_by(lambda l: l.min_xp) + levels = self._levels.get_levels_by_server_id(server.id).order_by( + lambda l: l.min_xp + ) - new_level = levels.where(lambda l: l.min_xp < level.min_xp).last_or_default() + new_level = levels.where( + lambda l: l.min_xp < level.min_xp + ).last_or_default() if new_level is not None: user.xp = new_level.min_xp self._users.update_user(user) self._db.save_changes() - await self.notify_user(member, self._t.transform("modules.base.warnings.second")) + await self.notify_user( + member, self._t.transform("modules.base.warnings.second") + ) elif existing_warnings.count() == 3: server = self._servers.get_server_by_discord_id(member.guild.id) - user = self._users.get_user_by_discord_id_and_server_id(member.id, server.id) + user = self._users.get_user_by_discord_id_and_server_id( + member.id, server.id + ) levels = self._levels.get_levels_by_server_id(server.id) - new_level = levels.where(lambda l: l.min_xp > 0).order_by(lambda l: l.min_xp).last_or_default() + new_level = ( + levels.where(lambda l: l.min_xp > 0) + .order_by(lambda l: l.min_xp) + .last_or_default() + ) if new_level is not None: user.xp = new_level.min_xp self._users.update_user(user) self._db.save_changes() - await self.notify_user(member, self._t.transform("modules.base.warnings.third")) + await self.notify_user( + member, self._t.transform("modules.base.warnings.third") + ) elif existing_warnings.count() >= 4: user.xp = 0 self._users.update_user(user) self._db.save_changes() - await self.notify_team(member, self._t.transform("modules.base.warnings.kick").format(member.mention)) + await self.notify_team( + member, + self._t.transform("modules.base.warnings.kick").format(member.mention), + ) await member.kick() async def _notify_after_add(self, member: discord.Member, warning: UserWarnings): server = self._servers.get_server_by_discord_id(member.guild.id) user = self._users.get_user_by_discord_id_and_server_id(member.id, server.id) - await self.notify_user(member, self._t.transform("modules.base.warnings.warned").format(warning.description)) + await self.notify_user( + member, + self._t.transform("modules.base.warnings.warned").format( + warning.description + ), + ) await self.notify_team(member, warning.description) await self.check_for_warnings(member, user) - def _add_warnings(self, member: discord.Member, description: str, author_id: int = None): + def _add_warnings( + self, member: discord.Member, description: str, author_id: int = None + ): server = self._servers.get_server_by_discord_id(member.guild.id) user = self._users.get_user_by_discord_id_and_server_id(member.id, server.id) author = None if author_id is not None: - author = self._users.get_user_by_discord_id_and_server_id(author_id, server.id) + author = self._users.get_user_by_discord_id_and_server_id( + author_id, server.id + ) warning = UserWarnings(description, user, author) self._warnings.add_user_warnings(warning) self._db.save_changes() return warning - def add_warnings(self, member: discord.Member, description: str, author_id: int = None): + def add_warnings( + self, member: discord.Member, description: str, author_id: int = None + ): warning = self._add_warnings(member, description, author_id) self._bot.loop.create_task(self._notify_after_add(member, warning)) - async def add_warnings_async(self, member: discord.Member, description: str, author_id: int = None): + async def add_warnings_async( + self, member: discord.Member, description: str, author_id: int = None + ): warning = self._add_warnings(member, description, author_id) await self._notify_after_add(member, warning) async def _notify_after_remove(self, warning: UserWarnings): guild = self._bot.get_guild(warning.user.server.discord_id) member = guild.get_member(warning.user.discord_id) - await self.notify_user(member, self._t.transform("modules.base.warnings.removed").format(warning.description)) + await self.notify_user( + member, + self._t.transform("modules.base.warnings.removed").format( + warning.description + ), + ) await self.notify_team(member, warning.description, removed=True) def _remove_warnings(self, id: int): diff --git a/kdb-bot/src/modules/base/thread/__init__.py b/bot/src/modules/base/thread/__init__.py similarity index 100% rename from kdb-bot/src/modules/base/thread/__init__.py rename to bot/src/modules/base/thread/__init__.py diff --git a/kdb-bot/src/modules/boot_log/__init__.py b/bot/src/modules/boot_log/__init__.py similarity index 100% rename from kdb-bot/src/modules/boot_log/__init__.py rename to bot/src/modules/boot_log/__init__.py diff --git a/kdb-bot/src/modules/boot_log/boot-log.json b/bot/src/modules/boot_log/boot-log.json similarity index 100% rename from kdb-bot/src/modules/boot_log/boot-log.json rename to bot/src/modules/boot_log/boot-log.json diff --git a/kdb-bot/src/modules/boot_log/boot_log_extension.py b/bot/src/modules/boot_log/boot_log_extension.py similarity index 94% rename from kdb-bot/src/modules/boot_log/boot_log_extension.py rename to bot/src/modules/boot_log/boot_log_extension.py index 62b7c6c7..e0f59082 100644 --- a/kdb-bot/src/modules/boot_log/boot_log_extension.py +++ b/bot/src/modules/boot_log/boot_log_extension.py @@ -14,7 +14,9 @@ class BootLogExtension(ApplicationExtensionABC): pass async def run(self, config: ConfigurationABC, services: ServiceProviderABC): - feature_flags: FeatureFlagsSettings = config.get_configuration(FeatureFlagsSettings) + feature_flags: FeatureFlagsSettings = config.get_configuration( + FeatureFlagsSettings + ) if not feature_flags.get_flag(FeatureFlagsEnum.boot_log_module): return logger: LoggerABC = services.get_service(LoggerABC) diff --git a/kdb-bot/src/modules/boot_log/boot_log_module.py b/bot/src/modules/boot_log/boot_log_module.py similarity index 68% rename from kdb-bot/src/modules/boot_log/boot_log_module.py rename to bot/src/modules/boot_log/boot_log_module.py index dde842f0..0701876f 100644 --- a/kdb-bot/src/modules/boot_log/boot_log_module.py +++ b/bot/src/modules/boot_log/boot_log_module.py @@ -13,10 +13,16 @@ class BootLogModule(ModuleABC): def __init__(self, dc: DiscordCollectionABC): ModuleABC.__init__(self, dc, FeatureFlagsEnum.boot_log_module) - def configure_configuration(self, config: ConfigurationABC, env: ApplicationEnvironmentABC): + def configure_configuration( + self, config: ConfigurationABC, env: ApplicationEnvironmentABC + ): pass - def configure_services(self, services: ServiceCollectionABC, env: ApplicationEnvironmentABC): + def configure_services( + self, services: ServiceCollectionABC, env: ApplicationEnvironmentABC + ): # commands # events - services.add_transient(DiscordEventTypesEnum.on_ready.value, BootLogOnReadyEvent) + services.add_transient( + DiscordEventTypesEnum.on_ready.value, BootLogOnReadyEvent + ) diff --git a/kdb-bot/src/modules/boot_log/boot_log_on_ready_event.py b/bot/src/modules/boot_log/boot_log_on_ready_event.py similarity index 88% rename from kdb-bot/src/modules/boot_log/boot_log_on_ready_event.py rename to bot/src/modules/boot_log/boot_log_on_ready_event.py index 4c8aeec7..f0962bae 100644 --- a/kdb-bot/src/modules/boot_log/boot_log_on_ready_event.py +++ b/bot/src/modules/boot_log/boot_log_on_ready_event.py @@ -45,7 +45,10 @@ class BootLogOnReadyEvent(OnReadyABC): try: start_time = self._config.get_configuration("Bot_StartTime") init_time = round( - (datetime.now() - datetime.strptime(start_time, "%Y-%m-%d %H:%M:%S.%f")).total_seconds(), + ( + datetime.now() + - datetime.strptime(start_time, "%Y-%m-%d %H:%M:%S.%f") + ).total_seconds(), 2, ) self._config.add_configuration("InitTime", str(init_time)) @@ -56,7 +59,9 @@ class BootLogOnReadyEvent(OnReadyABC): # print error if initialisation took way too long elif init_time >= 90: - self._logger.error(__name__, "It takes far too long to start the bot!!!") + self._logger.error( + __name__, "It takes far too long to start the bot!!!" + ) except Exception as e: self._logger.error(__name__, "Init time calculation failed", e) return @@ -65,7 +70,9 @@ class BootLogOnReadyEvent(OnReadyABC): g: guild = g self._logger.debug(__name__, f"Server detected: {g.id}") - server_config: ServerConfig = self._config.get_configuration(f"ServerConfig_{g.id}") + server_config: ServerConfig = self._config.get_configuration( + f"ServerConfig_{g.id}" + ) if server_config is None: self._logger.error(__name__, f"Config ServerConfig_{g.id} not found!") return @@ -78,7 +85,9 @@ class BootLogOnReadyEvent(OnReadyABC): self._bot.loop.create_task( self._message_service.send_channel_message( self._bot.get_channel(server_config.login_message_channel_id), - self._t.transform("modules.boot_log.login_message").format(init_time), + self._t.transform("modules.boot_log.login_message").format( + init_time + ), ) ) diff --git a/kdb-bot/src/modules/config/__init__.py b/bot/src/modules/config/__init__.py similarity index 100% rename from kdb-bot/src/modules/config/__init__.py rename to bot/src/modules/config/__init__.py diff --git a/kdb-bot/src/modules/config/config.json b/bot/src/modules/config/config.json similarity index 100% rename from kdb-bot/src/modules/config/config.json rename to bot/src/modules/config/config.json diff --git a/kdb-bot/src/modules/config/config_extension.py b/bot/src/modules/config/config_extension.py similarity index 95% rename from kdb-bot/src/modules/config/config_extension.py rename to bot/src/modules/config/config_extension.py index ce164180..f11ba6ad 100644 --- a/kdb-bot/src/modules/config/config_extension.py +++ b/bot/src/modules/config/config_extension.py @@ -13,7 +13,9 @@ class ConfigExtension(ApplicationExtensionABC): pass async def run(self, config: ConfigurationABC, services: ServiceProviderABC): - feature_flags: FeatureFlagsSettings = config.get_configuration(FeatureFlagsSettings) + feature_flags: FeatureFlagsSettings = config.get_configuration( + FeatureFlagsSettings + ) if not feature_flags.get_flag(FeatureFlagsEnum.config_module): return logger: LoggerABC = services.get_service(LoggerABC) diff --git a/kdb-bot/src/modules/config/config_module.py b/bot/src/modules/config/config_module.py similarity index 77% rename from kdb-bot/src/modules/config/config_module.py rename to bot/src/modules/config/config_module.py index 14c16263..a8180637 100644 --- a/kdb-bot/src/modules/config/config_module.py +++ b/bot/src/modules/config/config_module.py @@ -13,8 +13,12 @@ class ConfigModule(ModuleABC): def __init__(self, dc: DiscordCollectionABC): ModuleABC.__init__(self, dc, FeatureFlagsEnum.config_module) - def configure_configuration(self, config: ConfigurationABC, env: ApplicationEnvironmentABC): + def configure_configuration( + self, config: ConfigurationABC, env: ApplicationEnvironmentABC + ): pass - def configure_services(self, services: ServiceCollectionABC, env: ApplicationEnvironmentABC): + def configure_services( + self, services: ServiceCollectionABC, env: ApplicationEnvironmentABC + ): services.add_transient(DiscordEventTypesEnum.on_ready.value, ConfigOnReadyEvent) diff --git a/kdb-bot/src/modules/config/events/__init__.py b/bot/src/modules/config/events/__init__.py similarity index 100% rename from kdb-bot/src/modules/config/events/__init__.py rename to bot/src/modules/config/events/__init__.py diff --git a/kdb-bot/src/modules/config/events/config_on_ready_event.py b/bot/src/modules/config/events/config_on_ready_event.py similarity index 85% rename from kdb-bot/src/modules/config/events/config_on_ready_event.py rename to bot/src/modules/config/events/config_on_ready_event.py index 14ad229a..ddec8ccf 100644 --- a/kdb-bot/src/modules/config/events/config_on_ready_event.py +++ b/bot/src/modules/config/events/config_on_ready_event.py @@ -26,4 +26,6 @@ class ConfigOnReadyEvent(OnReadyABC): async def on_ready(self): for guild in self._bot.guilds: - await self._config_service.reload_server_config(self._servers.get_server_by_discord_id(guild.id)) + await self._config_service.reload_server_config( + self._servers.get_server_by_discord_id(guild.id) + ) diff --git a/kdb-bot/src/modules/config/service/__init__.py b/bot/src/modules/config/service/__init__.py similarity index 100% rename from kdb-bot/src/modules/config/service/__init__.py rename to bot/src/modules/config/service/__init__.py diff --git a/kdb-bot/src/modules/database/__init__.py b/bot/src/modules/database/__init__.py similarity index 100% rename from kdb-bot/src/modules/database/__init__.py rename to bot/src/modules/database/__init__.py diff --git a/kdb-bot/src/modules/database/database.json b/bot/src/modules/database/database.json similarity index 100% rename from kdb-bot/src/modules/database/database.json rename to bot/src/modules/database/database.json diff --git a/kdb-bot/src/modules/database/database_extension.py b/bot/src/modules/database/database_extension.py similarity index 96% rename from kdb-bot/src/modules/database/database_extension.py rename to bot/src/modules/database/database_extension.py index 1c26e70b..de874826 100644 --- a/kdb-bot/src/modules/database/database_extension.py +++ b/bot/src/modules/database/database_extension.py @@ -17,7 +17,9 @@ class DatabaseExtension(ApplicationExtensionABC): pass async def run(self, config: ConfigurationABC, services: ServiceProviderABC): - feature_flags: FeatureFlagsSettings = config.get_configuration(FeatureFlagsSettings) + feature_flags: FeatureFlagsSettings = config.get_configuration( + FeatureFlagsSettings + ) if not feature_flags.get_flag(FeatureFlagsEnum.data_module): return logger: LoggerABC = services.get_service(DatabaseLogger) diff --git a/kdb-bot/src/modules/database/database_module.py b/bot/src/modules/database/database_module.py similarity index 68% rename from kdb-bot/src/modules/database/database_module.py rename to bot/src/modules/database/database_module.py index bd7c6c6f..65b98988 100644 --- a/kdb-bot/src/modules/database/database_module.py +++ b/bot/src/modules/database/database_module.py @@ -13,10 +13,16 @@ class DatabaseModule(ModuleABC): def __init__(self, dc: DiscordCollectionABC): ModuleABC.__init__(self, dc, FeatureFlagsEnum.database_module) - def configure_configuration(self, config: ConfigurationABC, env: ApplicationEnvironmentABC): + def configure_configuration( + self, config: ConfigurationABC, env: ApplicationEnvironmentABC + ): pass - def configure_services(self, services: ServiceCollectionABC, env: ApplicationEnvironmentABC): + def configure_services( + self, services: ServiceCollectionABC, env: ApplicationEnvironmentABC + ): # commands # events - services.add_transient(DiscordEventTypesEnum.on_ready.value, DatabaseOnReadyEvent) + services.add_transient( + DiscordEventTypesEnum.on_ready.value, DatabaseOnReadyEvent + ) diff --git a/kdb-bot/src/modules/database/database_on_ready_event.py b/bot/src/modules/database/database_on_ready_event.py similarity index 80% rename from kdb-bot/src/modules/database/database_on_ready_event.py rename to bot/src/modules/database/database_on_ready_event.py index 5c3bd775..9b76de38 100644 --- a/kdb-bot/src/modules/database/database_on_ready_event.py +++ b/bot/src/modules/database/database_on_ready_event.py @@ -29,18 +29,25 @@ class DatabaseOnReadyEvent(OnReadyABC): try: start_time = self._config.get_configuration("Database_StartTime") init_time = round( - (datetime.now() - datetime.strptime(start_time, "%Y-%m-%d %H:%M:%S.%f")).total_seconds(), + ( + datetime.now() + - datetime.strptime(start_time, "%Y-%m-%d %H:%M:%S.%f") + ).total_seconds(), 2, ) self._config.add_configuration("Database_InitTime", str(init_time)) self._logger.debug(__name__, f"Database Init time: {init_time}s") # print warning if initialisation took too long if init_time >= 30: - self._logger.warn(__name__, "It takes too long to prepare the database!") + self._logger.warn( + __name__, "It takes too long to prepare the database!" + ) # print error if initialisation took way too long elif init_time >= 90: - self._logger.error(__name__, "It takes far too long to prepare the database!!!") + self._logger.error( + __name__, "It takes far too long to prepare the database!!!" + ) except Exception as e: # self._logger.error(__name__, "Database init time calculation failed", e) return diff --git a/kdb-bot/src/modules/level/__init__.py b/bot/src/modules/level/__init__.py similarity index 100% rename from kdb-bot/src/modules/level/__init__.py rename to bot/src/modules/level/__init__.py diff --git a/kdb-bot/src/modules/level/command/__init__.py b/bot/src/modules/level/command/__init__.py similarity index 100% rename from kdb-bot/src/modules/level/command/__init__.py rename to bot/src/modules/level/command/__init__.py diff --git a/kdb-bot/src/modules/level/command/level_group.py b/bot/src/modules/level/command/level_group.py similarity index 81% rename from kdb-bot/src/modules/level/command/level_group.py rename to bot/src/modules/level/command/level_group.py index 50e03692..e5dca679 100644 --- a/kdb-bot/src/modules/level/command/level_group.py +++ b/bot/src/modules/level/command/level_group.py @@ -108,13 +108,17 @@ class LevelGroup(DiscordCommandABC): except Exception as e: self._logger.error(__name__, f"Level seeding failed", e) - await self._message_service.send_ctx_msg(ctx, self._t.transform("modules.level.seeding_failed")) + await self._message_service.send_ctx_msg( + ctx, self._t.transform("modules.level.seeding_failed") + ) async def _level_auto_complete( self, interaction: discord.Interaction, current: str ) -> TList[app_commands.Choice[str]]: server = self._servers.get_server_by_discord_id(interaction.guild.id) - levels = self._levels.get_levels_by_server_id(server.id).select(lambda l: l.name) + levels = self._levels.get_levels_by_server_id(server.id).select( + lambda l: l.name + ) return [ app_commands.Choice(name=level, value=level) for level in self._client_utils.get_auto_complete_list(levels, current) @@ -134,14 +138,20 @@ class LevelGroup(DiscordCommandABC): if ctx.guild is None: return - server_config: ServerConfig = self._config.get_configuration(f"ServerConfig_{ctx.guild.id}") - if not FeatureFlagsSettings.get_flag_from_dict(server_config.feature_flags, FeatureFlagsEnum.level_module): + server_config: ServerConfig = self._config.get_configuration( + f"ServerConfig_{ctx.guild.id}" + ) + if not FeatureFlagsSettings.get_flag_from_dict( + server_config.feature_flags, FeatureFlagsEnum.level_module + ): return server = self._servers.get_server_by_discord_id(ctx.guild.id) levels = self._levels.get_levels_by_server_id(server.id) if levels.count() < 1: - await self._message_service.send_ctx_msg(ctx, self._t.transform("modules.level.error.nothing_found")) + await self._message_service.send_ctx_msg( + ctx, self._t.transform("modules.level.error.nothing_found") + ) self._logger.trace(__name__, f"Finished command level list") return @@ -163,7 +173,9 @@ class LevelGroup(DiscordCommandABC): value=level_name, inline=True, ) - embed.add_field(name=self._t.transform("modules.level.list.min_xp"), value=xp, inline=True) + embed.add_field( + name=self._t.transform("modules.level.list.min_xp"), value=xp, inline=True + ) embed.add_field( name=self._t.transform("modules.level.list.permission_int"), value=permissions, @@ -176,13 +188,19 @@ class LevelGroup(DiscordCommandABC): @commands.guild_only() @CommandChecks.check_is_ready() @CommandChecks.check_is_member_admin() - async def create(self, ctx: Context, name: str, color: str, min_xp: int, permissions: int): + async def create( + self, ctx: Context, name: str, color: str, min_xp: int, permissions: int + ): self._logger.debug(__name__, f"Received command level create {ctx}") if ctx.guild is None: return - server_config: ServerConfig = self._config.get_configuration(f"ServerConfig_{ctx.guild.id}") - if not FeatureFlagsSettings.get_flag_from_dict(server_config.feature_flags, FeatureFlagsEnum.level_module): + server_config: ServerConfig = self._config.get_configuration( + f"ServerConfig_{ctx.guild.id}" + ) + if not FeatureFlagsSettings.get_flag_from_dict( + server_config.feature_flags, FeatureFlagsEnum.level_module + ): return try: @@ -208,19 +226,26 @@ class LevelGroup(DiscordCommandABC): self._logger.debug(__name__, f"Level with name {level.name} already exists") await self._message_service.send_ctx_msg( ctx, - self._t.transform("modules.level.error.level_with_name_already_exists").format(level.name), + self._t.transform( + "modules.level.error.level_with_name_already_exists" + ).format(level.name), ) - elif levels.where(lambda l: l.min_xp == level.min_xp).first_or_default() is not None: + elif ( + levels.where(lambda l: l.min_xp == level.min_xp).first_or_default() + is not None + ): self._logger.debug( __name__, f"Level with min_xp {level.min_xp} already exists {level.name}", ) - found_level = levels.where(lambda l: l.min_xp == level.min_xp).first_or_default() + found_level = levels.where( + lambda l: l.min_xp == level.min_xp + ).first_or_default() await self._message_service.send_ctx_msg( ctx, - self._t.transform("modules.level.error.level_with_xp_already_exists").format( - found_level.name, found_level.min_xp - ), + self._t.transform( + "modules.level.error.level_with_xp_already_exists" + ).format(found_level.name, found_level.min_xp), ) else: try: @@ -239,7 +264,9 @@ class LevelGroup(DiscordCommandABC): else: await self._message_service.send_ctx_msg( ctx, - self._t.transform("modules.level.create.created").format(name, permissions), + self._t.transform("modules.level.create.created").format( + name, permissions + ), ) await self._seed_levels(ctx) @@ -276,13 +303,19 @@ class LevelGroup(DiscordCommandABC): if ctx.guild is None: return - server_config: ServerConfig = self._config.get_configuration(f"ServerConfig_{ctx.guild.id}") - if not FeatureFlagsSettings.get_flag_from_dict(server_config.feature_flags, FeatureFlagsEnum.level_module): + server_config: ServerConfig = self._config.get_configuration( + f"ServerConfig_{ctx.guild.id}" + ) + if not FeatureFlagsSettings.get_flag_from_dict( + server_config.feature_flags, FeatureFlagsEnum.level_module + ): return server = self._servers.get_server_by_discord_id(ctx.guild.id) level_from_db = ( - self._levels.get_levels_by_server_id(server.id).where(lambda l: l.name == level).single_or_default() + self._levels.get_levels_by_server_id(server.id) + .where(lambda l: l.name == level) + .single_or_default() ) if level_from_db is None: await self._message_service.send_ctx_msg( @@ -316,9 +349,13 @@ class LevelGroup(DiscordCommandABC): except Exception as e: await self._message_service.send_ctx_msg( ctx, - self._t.transform("modules.level.edit.permission_invalid").format(permissions), + self._t.transform("modules.level.edit.permission_invalid").format( + permissions + ), + ) + self._logger.error( + __name__, f"Error parsing permissions {permissions}", e ) - self._logger.error(__name__, f"Error parsing permissions {permissions}", e) return try: @@ -340,7 +377,9 @@ class LevelGroup(DiscordCommandABC): e, ) else: - await self._message_service.send_ctx_msg(ctx, self._t.transform("modules.level.edit.edited").format(level)) + await self._message_service.send_ctx_msg( + ctx, self._t.transform("modules.level.edit.edited").format(level) + ) await self._seed_levels(ctx) self._logger.trace(__name__, f"Finished command level edit") @@ -374,13 +413,19 @@ class LevelGroup(DiscordCommandABC): if ctx.guild is None: return - server_config: ServerConfig = self._config.get_configuration(f"ServerConfig_{ctx.guild.id}") - if not FeatureFlagsSettings.get_flag_from_dict(server_config.feature_flags, FeatureFlagsEnum.level_module): + server_config: ServerConfig = self._config.get_configuration( + f"ServerConfig_{ctx.guild.id}" + ) + if not FeatureFlagsSettings.get_flag_from_dict( + server_config.feature_flags, FeatureFlagsEnum.level_module + ): return server = self._servers.get_server_by_discord_id(ctx.guild.id) level_from_db = ( - self._levels.get_levels_by_server_id(server.id).where(lambda l: l.name == level).first_or_default() + self._levels.get_levels_by_server_id(server.id) + .where(lambda l: l.name == level) + .first_or_default() ) if level_from_db is None: self._logger.debug(__name__, f"level {level} not found") @@ -395,7 +440,9 @@ class LevelGroup(DiscordCommandABC): self._levels.delete_level(level_from_db) self._db.save_changes() guild: Guild = self._bot.guilds.where(lambda g: g == ctx.guild).single() - role: Role = guild.roles.where(lambda r: r.name == level).single_or_default() + role: Role = guild.roles.where( + lambda r: r.name == level + ).single_or_default() if role is not None: await role.delete() self._logger.info(__name__, f"Removed level {level}") @@ -424,8 +471,12 @@ class LevelGroup(DiscordCommandABC): if ctx.guild is None: return - server_config: ServerConfig = self._config.get_configuration(f"ServerConfig_{ctx.guild.id}") - if not FeatureFlagsSettings.get_flag_from_dict(server_config.feature_flags, FeatureFlagsEnum.level_module): + server_config: ServerConfig = self._config.get_configuration( + f"ServerConfig_{ctx.guild.id}" + ) + if not FeatureFlagsSettings.get_flag_from_dict( + server_config.feature_flags, FeatureFlagsEnum.level_module + ): return if member.bot: @@ -434,12 +485,16 @@ class LevelGroup(DiscordCommandABC): server = self._servers.get_server_by_discord_id(ctx.guild.id) user = self._users.get_user_by_discord_id_and_server_id(member.id, server.id) level = self._level_service.get_level(user) - levels = self._levels.get_levels_by_server_id(server.id).order_by(lambda l: l.min_xp) + levels = self._levels.get_levels_by_server_id(server.id).order_by( + lambda l: l.min_xp + ) if level == levels.first(): await self._message_service.send_ctx_msg( ctx, - self._t.transform("modules.level.down.already_first").format(member.mention), + self._t.transform("modules.level.down.already_first").format( + member.mention + ), ) self._logger.trace(__name__, f"Finished command level down") return @@ -451,11 +506,15 @@ class LevelGroup(DiscordCommandABC): self._db.save_changes() await self._message_service.send_ctx_msg( ctx, - self._t.transform("modules.level.down.success").format(member.mention, new_level.name), + self._t.transform("modules.level.down.success").format( + member.mention, new_level.name + ), ) await self._level_service.set_level(user) except Exception as e: - self._logger.error(__name__, f"Cannot level down {member.name} with level {level.name}", e) + self._logger.error( + __name__, f"Cannot level down {member.name} with level {level.name}", e + ) await self._message_service.send_ctx_msg( ctx, self._t.transform("modules.level.down.failed").format(member.mention), @@ -472,8 +531,12 @@ class LevelGroup(DiscordCommandABC): if ctx.guild is None: return - server_config: ServerConfig = self._config.get_configuration(f"ServerConfig_{ctx.guild.id}") - if not FeatureFlagsSettings.get_flag_from_dict(server_config.feature_flags, FeatureFlagsEnum.level_module): + server_config: ServerConfig = self._config.get_configuration( + f"ServerConfig_{ctx.guild.id}" + ) + if not FeatureFlagsSettings.get_flag_from_dict( + server_config.feature_flags, FeatureFlagsEnum.level_module + ): return if member.bot: @@ -482,12 +545,16 @@ class LevelGroup(DiscordCommandABC): server = self._servers.get_server_by_discord_id(ctx.guild.id) user = self._users.get_user_by_discord_id_and_server_id(member.id, server.id) level = self._level_service.get_level(user) - levels = self._levels.get_levels_by_server_id(server.id).order_by(lambda l: l.min_xp) + levels = self._levels.get_levels_by_server_id(server.id).order_by( + lambda l: l.min_xp + ) if level.name == levels.last().name: await self._message_service.send_ctx_msg( ctx, - self._t.transform("modules.level.up.already_last").format(member.mention), + self._t.transform("modules.level.up.already_last").format( + member.mention + ), ) self._logger.trace(__name__, f"Finished command level up") return @@ -499,11 +566,15 @@ class LevelGroup(DiscordCommandABC): self._db.save_changes() await self._message_service.send_ctx_msg( ctx, - self._t.transform("modules.level.up.success").format(member.mention, new_level.name), + self._t.transform("modules.level.up.success").format( + member.mention, new_level.name + ), ) await self._level_service.set_level(user) except Exception as e: - self._logger.error(__name__, f"Cannot level up {member.name} with level {level.name}", e) + self._logger.error( + __name__, f"Cannot level up {member.name} with level {level.name}", e + ) await self._message_service.send_ctx_msg( ctx, self._t.transform("modules.level.up.failed").format(member.mention) ) @@ -519,8 +590,12 @@ class LevelGroup(DiscordCommandABC): if ctx.guild is None: return - server_config: ServerConfig = self._config.get_configuration(f"ServerConfig_{ctx.guild.id}") - if not FeatureFlagsSettings.get_flag_from_dict(server_config.feature_flags, FeatureFlagsEnum.level_module): + server_config: ServerConfig = self._config.get_configuration( + f"ServerConfig_{ctx.guild.id}" + ) + if not FeatureFlagsSettings.get_flag_from_dict( + server_config.feature_flags, FeatureFlagsEnum.level_module + ): return if member.bot: @@ -529,7 +604,11 @@ class LevelGroup(DiscordCommandABC): server = self._servers.get_server_by_discord_id(ctx.guild.id) user = self._users.get_user_by_discord_id_and_server_id(member.id, server.id) current_level = self._level_service.get_level(user) - new_level = self._levels.get_levels_by_server_id(server.id).where(lambda l: l.name == level).single_or_default() + new_level = ( + self._levels.get_levels_by_server_id(server.id) + .where(lambda l: l.name == level) + .single_or_default() + ) if new_level is None: await self._message_service.send_ctx_msg( @@ -541,7 +620,9 @@ class LevelGroup(DiscordCommandABC): if current_level.name == level: await self._message_service.send_ctx_msg( ctx, - self._t.transform("modules.level.set.already_level").format(member.mention, level), + self._t.transform("modules.level.set.already_level").format( + member.mention, level + ), ) self._logger.trace(__name__, f"Finished command level set") return @@ -552,11 +633,15 @@ class LevelGroup(DiscordCommandABC): self._db.save_changes() await self._message_service.send_ctx_msg( ctx, - self._t.transform("modules.level.set.success").format(member.mention, new_level.name), + self._t.transform("modules.level.set.success").format( + member.mention, new_level.name + ), ) await self._level_service.set_level(user) except Exception as e: - self._logger.error(__name__, f"Cannot set level {level} for {member.name}", e) + self._logger.error( + __name__, f"Cannot set level {level} for {member.name}", e + ) await self._message_service.send_ctx_msg( ctx, self._t.transform("modules.level.set.failed").format(member.mention), @@ -565,7 +650,9 @@ class LevelGroup(DiscordCommandABC): self._logger.trace(__name__, f"Finished command level set") @set.autocomplete("level") - async def set_autocomplete(self, interaction: discord.Interaction, current: str) -> TList[app_commands.Choice[str]]: + async def set_autocomplete( + self, interaction: discord.Interaction, current: str + ) -> TList[app_commands.Choice[str]]: return await self._level_auto_complete(interaction, current) @level.command() @@ -577,8 +664,12 @@ class LevelGroup(DiscordCommandABC): if ctx.guild is None: return - server_config: ServerConfig = self._config.get_configuration(f"ServerConfig_{ctx.guild.id}") - if not FeatureFlagsSettings.get_flag_from_dict(server_config.feature_flags, FeatureFlagsEnum.level_module): + server_config: ServerConfig = self._config.get_configuration( + f"ServerConfig_{ctx.guild.id}" + ) + if not FeatureFlagsSettings.get_flag_from_dict( + server_config.feature_flags, FeatureFlagsEnum.level_module + ): return await self._seed_levels(ctx) diff --git a/kdb-bot/src/modules/level/configuration/__init__.py b/bot/src/modules/level/configuration/__init__.py similarity index 100% rename from kdb-bot/src/modules/level/configuration/__init__.py rename to bot/src/modules/level/configuration/__init__.py diff --git a/kdb-bot/src/modules/level/configuration/default_level_settings.py b/bot/src/modules/level/configuration/default_level_settings.py similarity index 100% rename from kdb-bot/src/modules/level/configuration/default_level_settings.py rename to bot/src/modules/level/configuration/default_level_settings.py diff --git a/kdb-bot/src/modules/level/default-level.json b/bot/src/modules/level/default-level.json similarity index 100% rename from kdb-bot/src/modules/level/default-level.json rename to bot/src/modules/level/default-level.json diff --git a/kdb-bot/src/modules/level/events/__init__.py b/bot/src/modules/level/events/__init__.py similarity index 100% rename from kdb-bot/src/modules/level/events/__init__.py rename to bot/src/modules/level/events/__init__.py diff --git a/kdb-bot/src/modules/level/events/level_on_member_join_event.py b/bot/src/modules/level/events/level_on_member_join_event.py similarity index 75% rename from kdb-bot/src/modules/level/events/level_on_member_join_event.py rename to bot/src/modules/level/events/level_on_member_join_event.py index 7113f761..94f74841 100644 --- a/kdb-bot/src/modules/level/events/level_on_member_join_event.py +++ b/bot/src/modules/level/events/level_on_member_join_event.py @@ -11,7 +11,9 @@ from modules.level.service.level_service import LevelService class LevelOnMemberJoinEvent(OnMemberJoinABC): - def __init__(self, config: ConfigurationABC, logger: MessageLogger, level: LevelService): + def __init__( + self, config: ConfigurationABC, logger: MessageLogger, level: LevelService + ): OnMemberJoinABC.__init__(self) self._config = config self._logger = logger @@ -20,8 +22,12 @@ class LevelOnMemberJoinEvent(OnMemberJoinABC): @EventChecks.check_is_ready() async def on_member_join(self, member: discord.Member): self._logger.debug(__name__, f"Module {type(self)} started") - server_config: ServerConfig = self._config.get_configuration(f"ServerConfig_{member.guild.id}") - if not FeatureFlagsSettings.get_flag_from_dict(server_config.feature_flags, FeatureFlagsEnum.level_module): + server_config: ServerConfig = self._config.get_configuration( + f"ServerConfig_{member.guild.id}" + ) + if not FeatureFlagsSettings.get_flag_from_dict( + server_config.feature_flags, FeatureFlagsEnum.level_module + ): return await self._level.check_level(member) diff --git a/kdb-bot/src/modules/level/events/level_on_message_event.py b/bot/src/modules/level/events/level_on_message_event.py similarity index 79% rename from kdb-bot/src/modules/level/events/level_on_message_event.py rename to bot/src/modules/level/events/level_on_message_event.py index 4c98706f..94141f78 100644 --- a/kdb-bot/src/modules/level/events/level_on_message_event.py +++ b/bot/src/modules/level/events/level_on_message_event.py @@ -11,7 +11,9 @@ from modules.level.service.level_service import LevelService class LevelOnMessageEvent(OnMessageABC): - def __init__(self, config: ConfigurationABC, logger: MessageLogger, level: LevelService): + def __init__( + self, config: ConfigurationABC, logger: MessageLogger, level: LevelService + ): OnMessageABC.__init__(self) self._config = config self._logger = logger @@ -26,8 +28,12 @@ class LevelOnMessageEvent(OnMessageABC): if message.author.bot: return - server_config: ServerConfig = self._config.get_configuration(f"ServerConfig_{message.guild.id}") - if not FeatureFlagsSettings.get_flag_from_dict(server_config.feature_flags, FeatureFlagsEnum.level_module): + server_config: ServerConfig = self._config.get_configuration( + f"ServerConfig_{message.guild.id}" + ) + if not FeatureFlagsSettings.get_flag_from_dict( + server_config.feature_flags, FeatureFlagsEnum.level_module + ): return try: diff --git a/kdb-bot/src/modules/level/events/level_on_raw_reaction_add_event.py b/bot/src/modules/level/events/level_on_raw_reaction_add_event.py similarity index 88% rename from kdb-bot/src/modules/level/events/level_on_raw_reaction_add_event.py rename to bot/src/modules/level/events/level_on_raw_reaction_add_event.py index bffc56ef..b59ce939 100644 --- a/kdb-bot/src/modules/level/events/level_on_raw_reaction_add_event.py +++ b/bot/src/modules/level/events/level_on_raw_reaction_add_event.py @@ -29,8 +29,12 @@ class LevelOnRawReactionAddEvent(OnRawReactionAddABC): @EventChecks.check_is_ready() async def on_raw_reaction_add(self, payload: RawReactionActionEvent): self._logger.debug(__name__, f"Module {type(self)} started") - server_config: ServerConfig = self._config.get_configuration(f"ServerConfig_{payload.guild_id}") - if not FeatureFlagsSettings.get_flag_from_dict(server_config.feature_flags, FeatureFlagsEnum.level_module): + server_config: ServerConfig = self._config.get_configuration( + f"ServerConfig_{payload.guild_id}" + ) + if not FeatureFlagsSettings.get_flag_from_dict( + server_config.feature_flags, FeatureFlagsEnum.level_module + ): return try: diff --git a/kdb-bot/src/modules/level/events/level_on_raw_reaction_remove_event.py b/bot/src/modules/level/events/level_on_raw_reaction_remove_event.py similarity index 88% rename from kdb-bot/src/modules/level/events/level_on_raw_reaction_remove_event.py rename to bot/src/modules/level/events/level_on_raw_reaction_remove_event.py index fa94e334..fceccd0b 100644 --- a/kdb-bot/src/modules/level/events/level_on_raw_reaction_remove_event.py +++ b/bot/src/modules/level/events/level_on_raw_reaction_remove_event.py @@ -29,8 +29,12 @@ class LevelOnRawReactionRemoveEvent(OnRawReactionRemoveABC): @EventChecks.check_is_ready() async def on_raw_reaction_remove(self, payload: RawReactionActionEvent): self._logger.debug(__name__, f"Module {type(self)} started") - server_config: ServerConfig = self._config.get_configuration(f"ServerConfig_{payload.guild_id}") - if not FeatureFlagsSettings.get_flag_from_dict(server_config.feature_flags, FeatureFlagsEnum.level_module): + server_config: ServerConfig = self._config.get_configuration( + f"ServerConfig_{payload.guild_id}" + ) + if not FeatureFlagsSettings.get_flag_from_dict( + server_config.feature_flags, FeatureFlagsEnum.level_module + ): return try: diff --git a/kdb-bot/src/modules/level/events/level_on_voice_state_update_event.py b/bot/src/modules/level/events/level_on_voice_state_update_event.py similarity index 78% rename from kdb-bot/src/modules/level/events/level_on_voice_state_update_event.py rename to bot/src/modules/level/events/level_on_voice_state_update_event.py index 9a0b5978..c529311c 100644 --- a/kdb-bot/src/modules/level/events/level_on_voice_state_update_event.py +++ b/bot/src/modules/level/events/level_on_voice_state_update_event.py @@ -11,7 +11,9 @@ from modules.level.service.level_service import LevelService class LevelOnVoiceStateUpdateEvent(OnVoiceStateUpdateABC): - def __init__(self, config: ConfigurationABC, logger: LoggerABC, level: LevelService): + def __init__( + self, config: ConfigurationABC, logger: LoggerABC, level: LevelService + ): OnVoiceStateUpdateABC.__init__(self) self._config = config self._logger = logger @@ -27,8 +29,12 @@ class LevelOnVoiceStateUpdateEvent(OnVoiceStateUpdateABC): after: discord.VoiceState, ): self._logger.debug(__name__, f"Module {type(self)} started") - server_config: ServerConfig = self._config.get_configuration(f"ServerConfig_{member.guild.id}") - if not FeatureFlagsSettings.get_flag_from_dict(server_config.feature_flags, FeatureFlagsEnum.level_module): + server_config: ServerConfig = self._config.get_configuration( + f"ServerConfig_{member.guild.id}" + ) + if not FeatureFlagsSettings.get_flag_from_dict( + server_config.feature_flags, FeatureFlagsEnum.level_module + ): return await self._level.check_level(member) diff --git a/kdb-bot/src/modules/level/level.json b/bot/src/modules/level/level.json similarity index 100% rename from kdb-bot/src/modules/level/level.json rename to bot/src/modules/level/level.json diff --git a/kdb-bot/src/modules/level/level_module.py b/bot/src/modules/level/level_module.py similarity index 68% rename from kdb-bot/src/modules/level/level_module.py rename to bot/src/modules/level/level_module.py index fced470c..19e04459 100644 --- a/kdb-bot/src/modules/level/level_module.py +++ b/bot/src/modules/level/level_module.py @@ -12,8 +12,12 @@ from bot_data.abc.data_seeder_abc import DataSeederABC from modules.level.command.level_group import LevelGroup from modules.level.events.level_on_member_join_event import LevelOnMemberJoinEvent from modules.level.events.level_on_message_event import LevelOnMessageEvent -from modules.level.events.level_on_raw_reaction_add_event import LevelOnRawReactionAddEvent -from modules.level.events.level_on_raw_reaction_remove_event import LevelOnRawReactionRemoveEvent +from modules.level.events.level_on_raw_reaction_add_event import ( + LevelOnRawReactionAddEvent, +) +from modules.level.events.level_on_raw_reaction_remove_event import ( + LevelOnRawReactionRemoveEvent, +) from modules.level.events.level_on_voice_state_update_event import ( LevelOnVoiceStateUpdateEvent, ) @@ -25,13 +29,17 @@ class LevelModule(ModuleABC): def __init__(self, dc: DiscordCollectionABC): ModuleABC.__init__(self, dc, FeatureFlagsEnum.level_module) - def configure_configuration(self, config: ConfigurationABC, env: ApplicationEnvironmentABC): + def configure_configuration( + self, config: ConfigurationABC, env: ApplicationEnvironmentABC + ): cwd = env.working_directory env.set_working_directory(os.path.dirname(os.path.realpath(__file__))) config.add_json_file(f"default-level.json", optional=False) env.set_working_directory(cwd) - def configure_services(self, services: ServiceCollectionABC, env: ApplicationEnvironmentABC): + def configure_services( + self, services: ServiceCollectionABC, env: ApplicationEnvironmentABC + ): services.add_transient(DataSeederABC, LevelSeeder) services.add_transient(LevelService) @@ -39,11 +47,20 @@ class LevelModule(ModuleABC): services.add_transient(LevelGroup) # events - services.add_transient(DiscordEventTypesEnum.on_message.value, LevelOnMessageEvent) + services.add_transient( + DiscordEventTypesEnum.on_message.value, LevelOnMessageEvent + ) services.add_transient( DiscordEventTypesEnum.on_voice_state_update.value, LevelOnVoiceStateUpdateEvent, ) - services.add_transient(DiscordEventTypesEnum.on_member_join.value, LevelOnMemberJoinEvent) - services.add_transient(DiscordEventTypesEnum.on_raw_reaction_add.value, LevelOnRawReactionAddEvent) - services.add_transient(DiscordEventTypesEnum.on_raw_reaction_remove.value, LevelOnRawReactionRemoveEvent) + services.add_transient( + DiscordEventTypesEnum.on_member_join.value, LevelOnMemberJoinEvent + ) + services.add_transient( + DiscordEventTypesEnum.on_raw_reaction_add.value, LevelOnRawReactionAddEvent + ) + services.add_transient( + DiscordEventTypesEnum.on_raw_reaction_remove.value, + LevelOnRawReactionRemoveEvent, + ) diff --git a/kdb-bot/src/modules/level/level_seeder.py b/bot/src/modules/level/level_seeder.py similarity index 79% rename from kdb-bot/src/modules/level/level_seeder.py rename to bot/src/modules/level/level_seeder.py index 19c7b773..e0f81148 100644 --- a/kdb-bot/src/modules/level/level_seeder.py +++ b/bot/src/modules/level/level_seeder.py @@ -46,7 +46,10 @@ class LevelSeeder(DataSeederABC): async def _create_level(self, level: Level, guild: Guild, server: Server): level.server = server try: - if guild.roles.where(lambda r: r.name == level.name).first_or_default() is None: + if ( + guild.roles.where(lambda r: r.name == level.name).first_or_default() + is None + ): await guild.create_role( name=level.name, colour=Colour(int(level.color, 16)), @@ -57,7 +60,11 @@ class LevelSeeder(DataSeederABC): self._logger.debug(__name__, f"Created role {level.name}") levels = self._levels.find_levels_by_server_id(server.id) - if levels is None or levels.where(lambda l: l.name == level.name).first_or_default() is None: + if ( + levels is None + or levels.where(lambda l: l.name == level.name).first_or_default() + is None + ): self._levels.add_level(level) self._logger.debug(__name__, f"Saved level {level.name}") self._db.save_changes() @@ -71,12 +78,21 @@ class LevelSeeder(DataSeederABC): async def seed(self): # create levels for guild in self._bot.guilds: - server_config: ServerConfig = self._config.get_configuration(f"ServerConfig_{guild.id}") - if not FeatureFlagsSettings.get_flag_from_dict(server_config.feature_flags, FeatureFlagsEnum.level_module): + server_config: ServerConfig = self._config.get_configuration( + f"ServerConfig_{guild.id}" + ) + if not FeatureFlagsSettings.get_flag_from_dict( + server_config.feature_flags, FeatureFlagsEnum.level_module + ): continue created_default = False - if guild.roles.where(lambda r: r.name == self._level_header).first_or_default() is None: + if ( + guild.roles.where( + lambda r: r.name == self._level_header + ).first_or_default() + is None + ): await guild.create_role(name=self._level_header) server = self._servers.find_server_by_discord_id(guild.id) @@ -102,13 +118,20 @@ class LevelSeeder(DataSeederABC): continue levels = levels.order_by_descending(lambda l: l.min_xp) - position_above_levels = guild.roles.where(lambda r: r.name == self._level_header).single().position + position_above_levels = ( + guild.roles.where(lambda r: r.name == self._level_header) + .single() + .position + ) for role in guild.roles.order_by_descending(lambda r: r.position): if levels.where(lambda l: l.name == role.name).count() == 0: continue new_position = position_above_levels - ( - levels.index_of(levels.where(lambda l: l.name == role.name).single()) + 1 + levels.index_of( + levels.where(lambda l: l.name == role.name).single() + ) + + 1 ) if new_position <= 0: new_position = 1 @@ -119,7 +142,9 @@ class LevelSeeder(DataSeederABC): ) await role.edit(position=new_position) except Exception as e: - self._logger.error(__name__, f"Cannot change position of {role.name}", e) + self._logger.error( + __name__, f"Cannot change position of {role.name}", e + ) for m in guild.members: await self._level.check_level(m) diff --git a/kdb-bot/src/modules/level/service/__init__.py b/bot/src/modules/level/service/__init__.py similarity index 100% rename from kdb-bot/src/modules/level/service/__init__.py rename to bot/src/modules/level/service/__init__.py diff --git a/kdb-bot/src/modules/level/service/level_service.py b/bot/src/modules/level/service/level_service.py similarity index 73% rename from kdb-bot/src/modules/level/service/level_service.py rename to bot/src/modules/level/service/level_service.py index e85c1719..258bec27 100644 --- a/kdb-bot/src/modules/level/service/level_service.py +++ b/bot/src/modules/level/service/level_service.py @@ -43,7 +43,9 @@ class LevelService: if user.xp < 0: return levels_by_server.order_by(lambda l: l.min_xp).first() - levels = levels_by_server.order_by(lambda l: l.min_xp).where(lambda l: user.xp >= l.min_xp) + levels = levels_by_server.order_by(lambda l: l.min_xp).where( + lambda l: user.xp >= l.min_xp + ) if levels.count() == 0: return levels_by_server.order_by(lambda l: l.min_xp).last() @@ -51,8 +53,12 @@ class LevelService: return levels.last() async def set_level(self, user: User): - level_names = self._levels.get_levels_by_server_id(user.server.id).select(lambda l: l.name) - guild: Guild = self._bot.guilds.where(lambda g: g.id == user.server.discord_id).single() + level_names = self._levels.get_levels_by_server_id(user.server.id).select( + lambda l: l.name + ) + guild: Guild = self._bot.guilds.where( + lambda g: g.id == user.server.discord_id + ).single() member: Member = guild.members.where(lambda m: m.id == user.discord_id).single() level = self.get_level(user) @@ -63,25 +69,39 @@ class LevelService: notification_needed = False for role in member.roles.where(lambda r: r.name in level_names.to_list()): try: - self._logger.debug(__name__, f"Try to remove role {role.name} from {member.name}") + self._logger.debug( + __name__, f"Try to remove role {role.name} from {member.name}" + ) await member.remove_roles(role) notification_needed = True - self._logger.info(__name__, f"Removed role {role.name} from {member.name}") + self._logger.info( + __name__, f"Removed role {role.name} from {member.name}" + ) except Exception as e: - self._logger.error(__name__, f"Removing role {role.name} from {member.name} failed!", e) + self._logger.error( + __name__, f"Removing role {role.name} from {member.name} failed!", e + ) try: - self._logger.debug(__name__, f"Try to add role {level_role.name} to {member.name}") + self._logger.debug( + __name__, f"Try to add role {level_role.name} to {member.name}" + ) await member.add_roles(level_role) self._logger.info(__name__, f"Add role {level_role.name} to {member.name}") except Exception as e: - self._logger.error(__name__, f"Adding role {level_role.name} to {member.name} failed!", e) + self._logger.error( + __name__, f"Adding role {level_role.name} to {member.name} failed!", e + ) if notification_needed: - settings: ServerConfig = self._config.get_configuration(f"ServerConfig_{guild.id}") + settings: ServerConfig = self._config.get_configuration( + f"ServerConfig_{guild.id}" + ) await self._message_service.send_channel_message( self._bot.get_channel(settings.notification_chat_id), - self._t.transform("modules.level.new_level_message").format(member.mention, level.name), + self._t.transform("modules.level.new_level_message").format( + member.mention, level.name + ), is_persistent=True, ) @@ -92,7 +112,9 @@ class LevelService: server = self._servers.get_server_by_discord_id(member.guild.id) user = self._users.find_user_by_discord_id_and_server_id(member.id, server.id) if user is None: - self._logger.warn(__name__, f"User not found {member.guild.name}@{member.name}") + self._logger.warn( + __name__, f"User not found {member.guild.name}@{member.name}" + ) return await self.set_level(user) diff --git a/kdb-bot/src/modules/permission/__init__.py b/bot/src/modules/permission/__init__.py similarity index 100% rename from kdb-bot/src/modules/permission/__init__.py rename to bot/src/modules/permission/__init__.py diff --git a/kdb-bot/src/modules/permission/abc/__init__.py b/bot/src/modules/permission/abc/__init__.py similarity index 100% rename from kdb-bot/src/modules/permission/abc/__init__.py rename to bot/src/modules/permission/abc/__init__.py diff --git a/kdb-bot/src/modules/permission/abc/permission_service_abc.py b/bot/src/modules/permission/abc/permission_service_abc.py similarity index 100% rename from kdb-bot/src/modules/permission/abc/permission_service_abc.py rename to bot/src/modules/permission/abc/permission_service_abc.py diff --git a/kdb-bot/src/modules/permission/permission.json b/bot/src/modules/permission/permission.json similarity index 100% rename from kdb-bot/src/modules/permission/permission.json rename to bot/src/modules/permission/permission.json diff --git a/kdb-bot/src/modules/permission/permission_module.py b/bot/src/modules/permission/permission_module.py similarity index 78% rename from kdb-bot/src/modules/permission/permission_module.py rename to bot/src/modules/permission/permission_module.py index 75da783e..fb6c509d 100644 --- a/kdb-bot/src/modules/permission/permission_module.py +++ b/bot/src/modules/permission/permission_module.py @@ -13,10 +13,14 @@ class PermissionModule(ModuleABC): def __init__(self, dc: DiscordCollectionABC): ModuleABC.__init__(self, dc, FeatureFlagsEnum.permission_module) - def configure_configuration(self, config: ConfigurationABC, env: ApplicationEnvironmentABC): + def configure_configuration( + self, config: ConfigurationABC, env: ApplicationEnvironmentABC + ): pass - def configure_services(self, services: ServiceCollectionABC, env: ApplicationEnvironmentABC): + def configure_services( + self, services: ServiceCollectionABC, env: ApplicationEnvironmentABC + ): services.add_transient(PermissionServiceABC, PermissionService) # commands # events diff --git a/kdb-bot/src/modules/permission/service/__init__.py b/bot/src/modules/permission/service/__init__.py similarity index 100% rename from kdb-bot/src/modules/permission/service/__init__.py rename to bot/src/modules/permission/service/__init__.py diff --git a/kdb-bot/src/modules/permission/service/permission_service.py b/bot/src/modules/permission/service/permission_service.py similarity index 80% rename from kdb-bot/src/modules/permission/service/permission_service.py rename to bot/src/modules/permission/service/permission_service.py index 9ac28c55..c75175e7 100644 --- a/kdb-bot/src/modules/permission/service/permission_service.py +++ b/bot/src/modules/permission/service/permission_service.py @@ -28,18 +28,22 @@ class PermissionService(PermissionServiceABC): self._server_configs = server_configs self._technician_configs = technician_configs - def _has_member_role(self, member: discord.Member, team_member_type: TeamMemberTypeEnum) -> bool: + def _has_member_role( + self, member: discord.Member, team_member_type: TeamMemberTypeEnum + ) -> bool: if member is None or member.guild is None: return False - self._logger.debug(__name__, f"Checking is member {member.name} {team_member_type.value}") + self._logger.debug( + __name__, f"Checking is member {member.name} {team_member_type.value}" + ) try: server = self._servers.get_server_by_discord_id(member.guild.id) config = self._server_configs.get_server_config_by_server(server.id) - roles = config.team_role_ids.where(lambda x: x.team_member_type == team_member_type).select( - lambda x: member.guild.get_role(x.role_id) - ) + roles = config.team_role_ids.where( + lambda x: x.team_member_type == team_member_type + ).select(lambda x: member.guild.get_role(x.role_id)) for role in roles: if role not in member.roles: continue @@ -54,9 +58,9 @@ class PermissionService(PermissionServiceABC): return self._has_member_role(member, TeamMemberTypeEnum.admin) def is_member_moderator(self, member: discord.Member) -> bool: - return self._has_member_role(member, TeamMemberTypeEnum.moderator) or self._has_member_role( - member, TeamMemberTypeEnum.admin - ) + return self._has_member_role( + member, TeamMemberTypeEnum.moderator + ) or self._has_member_role(member, TeamMemberTypeEnum.admin) def is_member_technician(self, member: discord.Member) -> bool: if member is None or member.guild is None: diff --git a/kdb-bot/src/modules/short_role_name/__init__.py b/bot/src/modules/short_role_name/__init__.py similarity index 100% rename from kdb-bot/src/modules/short_role_name/__init__.py rename to bot/src/modules/short_role_name/__init__.py diff --git a/kdb-bot/src/modules/short_role_name/events/__init__.py b/bot/src/modules/short_role_name/events/__init__.py similarity index 100% rename from kdb-bot/src/modules/short_role_name/events/__init__.py rename to bot/src/modules/short_role_name/events/__init__.py diff --git a/kdb-bot/src/modules/short_role_name/events/short_role_name_on_member_update_event.py b/bot/src/modules/short_role_name/events/short_role_name_on_member_update_event.py similarity index 80% rename from kdb-bot/src/modules/short_role_name/events/short_role_name_on_member_update_event.py rename to bot/src/modules/short_role_name/events/short_role_name_on_member_update_event.py index 6b942ed1..574b3379 100644 --- a/kdb-bot/src/modules/short_role_name/events/short_role_name_on_member_update_event.py +++ b/bot/src/modules/short_role_name/events/short_role_name_on_member_update_event.py @@ -9,6 +9,8 @@ class ShortRoleNameOnMemberUpdateEvent(OnMemberUpdateABC): OnMemberUpdateABC.__init__(self) self._service = service - async def on_member_update(self, before: discord.member.Member, after: discord.member.Member): + async def on_member_update( + self, before: discord.member.Member, after: discord.member.Member + ): if before.roles != after.roles or before.name != after.name: await self._service.check_short_role_names(after) diff --git a/kdb-bot/src/modules/short_role_name/service/__init__.py b/bot/src/modules/short_role_name/service/__init__.py similarity index 100% rename from kdb-bot/src/modules/short_role_name/service/__init__.py rename to bot/src/modules/short_role_name/service/__init__.py diff --git a/kdb-bot/src/modules/short_role_name/service/short_role_name_service.py b/bot/src/modules/short_role_name/service/short_role_name_service.py similarity index 89% rename from kdb-bot/src/modules/short_role_name/service/short_role_name_service.py rename to bot/src/modules/short_role_name/service/short_role_name_service.py index 5a2e8af8..f85f2d01 100644 --- a/kdb-bot/src/modules/short_role_name/service/short_role_name_service.py +++ b/bot/src/modules/short_role_name/service/short_role_name_service.py @@ -32,8 +32,12 @@ class ShortRoleNameService: async def check_short_role_names(self, member: discord.Member): self._logger.debug(__name__, f"Started short role name check for {member.id}") - settings: ServerConfig = self._config.get_configuration(f"ServerConfig_{member.guild.id}") - if not FeatureFlagsSettings.get_flag_from_dict(settings.feature_flags, FeatureFlagsEnum.short_role_name): + settings: ServerConfig = self._config.get_configuration( + f"ServerConfig_{member.guild.id}" + ) + if not FeatureFlagsSettings.get_flag_from_dict( + settings.feature_flags, FeatureFlagsEnum.short_role_name + ): self._logger.debug(__name__, f"Feature not active") return @@ -45,12 +49,16 @@ class ShortRoleNameService: new_nick = member.nick if member.nick is not None else member.name member_roles = List(discord.Role, member.roles) highest_role: Optional[discord.Role] = ( - member_roles.last_or_default() if settings.short_role_name_only_set_highest_role else None + member_roles.last_or_default() + if settings.short_role_name_only_set_highest_role + else None ) member_role_ids = member_roles.select(lambda x: x.id) server = self._server.get_server_by_discord_id(member.guild.id) - for short_role_name in self._short_role_names.get_short_role_names_by_server_id(server.id): + for short_role_name in self._short_role_names.get_short_role_names_by_server_id( + server.id + ): short_role_name: ShortRoleName = short_role_name new_nick = new_nick.replace(f" [{short_role_name.short_name}]", "") diff --git a/kdb-bot/src/modules/short_role_name/short-role-name.json b/bot/src/modules/short_role_name/short-role-name.json similarity index 100% rename from kdb-bot/src/modules/short_role_name/short-role-name.json rename to bot/src/modules/short_role_name/short-role-name.json diff --git a/kdb-bot/src/modules/short_role_name/short_role_name_check_command.py b/bot/src/modules/short_role_name/short_role_name_check_command.py similarity index 82% rename from kdb-bot/src/modules/short_role_name/short_role_name_check_command.py rename to bot/src/modules/short_role_name/short_role_name_check_command.py index 663be0f1..feb35a99 100644 --- a/kdb-bot/src/modules/short_role_name/short_role_name_check_command.py +++ b/bot/src/modules/short_role_name/short_role_name_check_command.py @@ -47,14 +47,22 @@ class ShortRoleNameCheckCommand(DiscordCommandABC): if ctx.guild is None: return - settings: ServerConfig = self._config.get_configuration(f"ServerConfig_{ctx.guild.id}") - if not FeatureFlagsSettings.get_flag_from_dict(settings.feature_flags, FeatureFlagsEnum.short_role_name): - await self._message_service.send_ctx_msg(ctx, self._t.transform("common.feature_not_activated")) + settings: ServerConfig = self._config.get_configuration( + f"ServerConfig_{ctx.guild.id}" + ) + if not FeatureFlagsSettings.get_flag_from_dict( + settings.feature_flags, FeatureFlagsEnum.short_role_name + ): + await self._message_service.send_ctx_msg( + ctx, self._t.transform("common.feature_not_activated") + ) return for member in ctx.guild.members: await self._service.check_short_role_names(member) - await self._message_service.send_ctx_msg(ctx, self._t.transform("modules.short_role_name.checked_message")) + await self._message_service.send_ctx_msg( + ctx, self._t.transform("modules.short_role_name.checked_message") + ) self._logger.trace(__name__, f"Finished purge command") diff --git a/kdb-bot/src/modules/short_role_name/short_role_name_module.py b/bot/src/modules/short_role_name/short_role_name_module.py similarity index 71% rename from kdb-bot/src/modules/short_role_name/short_role_name_module.py rename to bot/src/modules/short_role_name/short_role_name_module.py index 6eff2a02..224e52d9 100644 --- a/kdb-bot/src/modules/short_role_name/short_role_name_module.py +++ b/bot/src/modules/short_role_name/short_role_name_module.py @@ -7,9 +7,13 @@ from cpl_discord.service.discord_collection_abc import DiscordCollectionABC from bot_core.abc.module_abc import ModuleABC from bot_core.configuration.feature_flags_enum import FeatureFlagsEnum from bot_data.abc.data_seeder_abc import DataSeederABC -from modules.short_role_name.events.short_role_name_on_member_update_event import ShortRoleNameOnMemberUpdateEvent +from modules.short_role_name.events.short_role_name_on_member_update_event import ( + ShortRoleNameOnMemberUpdateEvent, +) from modules.short_role_name.service.short_role_name_service import ShortRoleNameService -from modules.short_role_name.short_role_name_check_command import ShortRoleNameCheckCommand +from modules.short_role_name.short_role_name_check_command import ( + ShortRoleNameCheckCommand, +) from modules.short_role_name.short_role_name_seeder import ShortRoleNameSeeder @@ -17,14 +21,21 @@ class ShortRoleNameModule(ModuleABC): def __init__(self, dc: DiscordCollectionABC): ModuleABC.__init__(self, dc, FeatureFlagsEnum.short_role_name_module) - def configure_configuration(self, config: ConfigurationABC, env: ApplicationEnvironmentABC): + def configure_configuration( + self, config: ConfigurationABC, env: ApplicationEnvironmentABC + ): pass - def configure_services(self, services: ServiceCollectionABC, env: ApplicationEnvironmentABC): + def configure_services( + self, services: ServiceCollectionABC, env: ApplicationEnvironmentABC + ): services.add_transient(DataSeederABC, ShortRoleNameSeeder) services.add_transient(ShortRoleNameService) # commands services.add_transient(ShortRoleNameCheckCommand) # events - services.add_transient(DiscordEventTypesEnum.on_member_update.value, ShortRoleNameOnMemberUpdateEvent) + services.add_transient( + DiscordEventTypesEnum.on_member_update.value, + ShortRoleNameOnMemberUpdateEvent, + ) diff --git a/kdb-bot/src/modules/short_role_name/short_role_name_seeder.py b/bot/src/modules/short_role_name/short_role_name_seeder.py similarity index 100% rename from kdb-bot/src/modules/short_role_name/short_role_name_seeder.py rename to bot/src/modules/short_role_name/short_role_name_seeder.py diff --git a/kdb-bot/src/modules/special_offers/__init__.py b/bot/src/modules/special_offers/__init__.py similarity index 100% rename from kdb-bot/src/modules/special_offers/__init__.py rename to bot/src/modules/special_offers/__init__.py diff --git a/kdb-bot/src/modules/special_offers/special-offers.json b/bot/src/modules/special_offers/special-offers.json similarity index 100% rename from kdb-bot/src/modules/special_offers/special-offers.json rename to bot/src/modules/special_offers/special-offers.json diff --git a/kdb-bot/src/modules/special_offers/special_offers_module.py b/bot/src/modules/special_offers/special_offers_module.py similarity index 77% rename from kdb-bot/src/modules/special_offers/special_offers_module.py rename to bot/src/modules/special_offers/special_offers_module.py index e64108b5..4a35120d 100644 --- a/kdb-bot/src/modules/special_offers/special_offers_module.py +++ b/bot/src/modules/special_offers/special_offers_module.py @@ -13,10 +13,14 @@ class SteamSpecialOffersModule(ModuleABC): def __init__(self, dc: DiscordCollectionABC): ModuleABC.__init__(self, dc, FeatureFlagsEnum.steam_special_offers_module) - def configure_configuration(self, config: ConfigurationABC, env: ApplicationEnvironmentABC): + def configure_configuration( + self, config: ConfigurationABC, env: ApplicationEnvironmentABC + ): pass - def configure_services(self, services: ServiceCollectionABC, env: ApplicationEnvironmentABC): + def configure_services( + self, services: ServiceCollectionABC, env: ApplicationEnvironmentABC + ): services.add_singleton(TaskABC, SteamOfferWatcher) # commands # events diff --git a/kdb-bot/src/modules/special_offers/steam_offer_watcher.py b/bot/src/modules/special_offers/steam_offer_watcher.py similarity index 81% rename from kdb-bot/src/modules/special_offers/steam_offer_watcher.py rename to bot/src/modules/special_offers/steam_offer_watcher.py index 0aedda1d..b31e6a6a 100644 --- a/kdb-bot/src/modules/special_offers/steam_offer_watcher.py +++ b/bot/src/modules/special_offers/steam_offer_watcher.py @@ -16,7 +16,9 @@ from bot_core.configuration.feature_flags_enum import FeatureFlagsEnum from bot_core.configuration.feature_flags_settings import FeatureFlagsSettings from bot_core.logging.task_logger import TaskLogger from bot_core.service.message_service import MessageService -from bot_data.abc.steam_special_offer_repository_abc import SteamSpecialOfferRepositoryABC +from bot_data.abc.steam_special_offer_repository_abc import ( + SteamSpecialOfferRepositoryABC, +) from bot_data.model.server_config import ServerConfig from bot_data.model.steam_special_offer import SteamSpecialOffer @@ -51,7 +53,9 @@ class SteamOfferWatcher(TaskABC): @staticmethod def _get_max_count() -> int: count = 0 - result = requests.get(f"https://store.steampowered.com/search/results?specials=1") + result = requests.get( + f"https://store.steampowered.com/search/results?specials=1" + ) soup = bs4.BeautifulSoup(result.text, "lxml") element = soup.find_all("div", {"class": "search_results_count"}) if len(element) < 1: @@ -73,9 +77,13 @@ class SteamOfferWatcher(TaskABC): for element in elements: name_element = element.find("span", {"class": "title"}) - original_price_element = element.find("div", {"class": "discount_original_price"}) + original_price_element = element.find( + "div", {"class": "discount_original_price"} + ) discount_element = element.find("div", {"class": "discount_pct"}) - discount_price_element = element.find("div", {"class": "discount_final_price"}) + discount_price_element = element.find( + "div", {"class": "discount_final_price"} + ) if ( name_element is None @@ -91,15 +99,25 @@ class SteamOfferWatcher(TaskABC): name = name_element.contents[0].replace("'", "`").replace('"', "`") original_price = float( - original_price_element.contents[0].replace(" ", "").replace("€", "").replace(",", ".") + original_price_element.contents[0] + .replace(" ", "") + .replace("€", "") + .replace(",", ".") ) discount = int(discount_element.contents[0].replace("%", "")) discount_price = float( - discount_price_element.contents[0].replace(" ", "").replace("€", "").replace(",", ".") + discount_price_element.contents[0] + .replace(" ", "") + .replace("€", "") + .replace(",", ".") ) games.add(SteamSpecialOffer(name, original_price, discount_price, discount)) self._urls[name] = element.attrs["href"] - self._image_urls[name] = element.find("div", {"class": "search_capsule"}).find("img").attrs["src"] + self._image_urls[name] = ( + element.find("div", {"class": "search_capsule"}) + .find("img") + .attrs["src"] + ) return games @@ -116,7 +134,9 @@ class SteamOfferWatcher(TaskABC): return new_offers - async def _send_embed_for_offer(self, offer: SteamSpecialOffer, channel_id: int) -> discord.Embed: + async def _send_embed_for_offer( + self, offer: SteamSpecialOffer, channel_id: int + ) -> discord.Embed: embed = discord.Embed( title=offer.name, url=self._urls[offer.name], @@ -130,7 +150,9 @@ class SteamOfferWatcher(TaskABC): inline=True, ) embed.add_field( - name=self._t.transform("modules.special_offers.discount"), value=f"{offer.discount_pct}%", inline=True + name=self._t.transform("modules.special_offers.discount"), + value=f"{offer.discount_pct}%", + inline=True, ) embed.add_field( name=self._t.transform("modules.special_offers.discount_price"), @@ -182,11 +204,16 @@ class SteamOfferWatcher(TaskABC): self._logger.info(__name__, "Watching steam special offers") try: offers_for_notifications = self._watch() - self._logger.debug(__name__, f"Sending offer notifications for {offers_for_notifications.count()} offers") + self._logger.debug( + __name__, + f"Sending offer notifications for {offers_for_notifications.count()} offers", + ) if self._is_new: return for guild in self._bot.guilds: - settings: ServerConfig = self._config.get_configuration(f"ServerConfig_{guild.id}") + settings: ServerConfig = self._config.get_configuration( + f"ServerConfig_{guild.id}" + ) if ( not FeatureFlagsSettings.get_flag_from_dict( settings.feature_flags, FeatureFlagsEnum.steam_special_offers @@ -197,7 +224,9 @@ class SteamOfferWatcher(TaskABC): for offer in offers_for_notifications: self._bot.loop.create_task( - self._send_embed_for_offer(offer, settings.game_offer_notification_chat_id) + self._send_embed_for_offer( + offer, settings.game_offer_notification_chat_id + ) ) except Exception as e: self._logger.error(__name__, f"Steam offer watcher failed", e) diff --git a/kdb-bot/src/modules/technician/__init__.py b/bot/src/modules/technician/__init__.py similarity index 100% rename from kdb-bot/src/modules/technician/__init__.py rename to bot/src/modules/technician/__init__.py diff --git a/kdb-bot/src/modules/technician/api_key_seeder.py b/bot/src/modules/technician/api_key_seeder.py similarity index 92% rename from kdb-bot/src/modules/technician/api_key_seeder.py rename to bot/src/modules/technician/api_key_seeder.py index f8f1305c..70792942 100644 --- a/kdb-bot/src/modules/technician/api_key_seeder.py +++ b/bot/src/modules/technician/api_key_seeder.py @@ -36,7 +36,9 @@ class ApiKeySeeder(DataSeederABC): return try: - frontend_key = ApiKey("frontend", "87f529fd-a32e-40b3-a1d1-7a1583cf3ff5", None) + frontend_key = ApiKey( + "frontend", "87f529fd-a32e-40b3-a1d1-7a1583cf3ff5", None + ) self._api_keys.add_api_key(frontend_key) self._db.save_changes() self._logger.info(__name__, f"Created frontend API-Key") diff --git a/kdb-bot/src/modules/technician/command/__init__.py b/bot/src/modules/technician/command/__init__.py similarity index 100% rename from kdb-bot/src/modules/technician/command/__init__.py rename to bot/src/modules/technician/command/__init__.py diff --git a/kdb-bot/src/modules/technician/command/api_key_group.py b/bot/src/modules/technician/command/api_key_group.py similarity index 84% rename from kdb-bot/src/modules/technician/command/api_key_group.py rename to bot/src/modules/technician/command/api_key_group.py index 11912385..f0171553 100644 --- a/kdb-bot/src/modules/technician/command/api_key_group.py +++ b/bot/src/modules/technician/command/api_key_group.py @@ -54,7 +54,9 @@ class ApiKeyGroup(DiscordCommandABC): def _get_api_key_str(self, api_key: ApiKey) -> str: return hashlib.sha256( - f"{api_key.identifier}:{api_key.key}+{self._auth_settings.secret_key}".encode("utf-8") + f"{api_key.identifier}:{api_key.key}+{self._auth_settings.secret_key}".encode( + "utf-8" + ) ).hexdigest() @commands.hybrid_group(name="api-key") @@ -67,7 +69,9 @@ class ApiKeyGroup(DiscordCommandABC): @CommandChecks.check_is_ready() @CommandChecks.check_is_member_technician() async def get(self, ctx: Context, key: str, wait: int = None): - self._logger.debug(__name__, f"Received command api-key get {ctx}: {key},{wait}") + self._logger.debug( + __name__, f"Received command api-key get {ctx}: {key},{wait}" + ) api_key = self._api_keys.get_api_key_by_key(key) await self._message_service.send_ctx_msg( @@ -79,12 +83,16 @@ class ApiKeyGroup(DiscordCommandABC): self._logger.trace(__name__, f"Finished command api-key get") @get.autocomplete("key") - async def get_autocomplete(self, interaction: discord.Interaction, current: str) -> TList[app_commands.Choice[str]]: + async def get_autocomplete( + self, interaction: discord.Interaction, current: str + ) -> TList[app_commands.Choice[str]]: keys = self._api_keys.get_api_keys() return [ app_commands.Choice(name=f"{key.identifier}: {key.key}", value=key.key) - for key in self._client_utils.get_auto_complete_list(keys, current, lambda x: x.key) + for key in self._client_utils.get_auto_complete_list( + keys, current, lambda x: x.key + ) ] @api_key.command() @@ -92,10 +100,14 @@ class ApiKeyGroup(DiscordCommandABC): @CommandChecks.check_is_ready() @CommandChecks.check_is_member_moderator() async def add(self, ctx: Context, identifier: str): - self._logger.debug(__name__, f"Received command api-key add {ctx}: {identifier}") + self._logger.debug( + __name__, f"Received command api-key add {ctx}: {identifier}" + ) server = self._servers.get_server_by_discord_id(ctx.guild.id) - user = self._users.get_user_by_discord_id_and_server_id(ctx.author.id, server.id) + user = self._users.get_user_by_discord_id_and_server_id( + ctx.author.id, server.id + ) api_key = ApiKey(identifier, str(uuid.uuid4()), user) self._api_keys.add_api_key(api_key) self._db.save_changes() @@ -125,15 +137,21 @@ class ApiKeyGroup(DiscordCommandABC): api_key = keys.single() self._api_keys.delete_api_key(api_key) self._db.save_changes() - await self._message_service.send_ctx_msg(ctx, self._t.transform("modules.technician.api_key.remove.success")) + await self._message_service.send_ctx_msg( + ctx, self._t.transform("modules.technician.api_key.remove.success") + ) self._logger.trace(__name__, f"Finished command api-key remove") @remove.autocomplete("key") - async def set_autocomplete(self, interaction: discord.Interaction, current: str) -> TList[app_commands.Choice[str]]: + async def set_autocomplete( + self, interaction: discord.Interaction, current: str + ) -> TList[app_commands.Choice[str]]: keys = self._api_keys.get_api_keys() return [ app_commands.Choice(name=f"{key.identifier}: {key.key}", value=key.key) - for key in self._client_utils.get_auto_complete_list(keys, current, lambda x: x.key) + for key in self._client_utils.get_auto_complete_list( + keys, current, lambda x: x.key + ) ] diff --git a/kdb-bot/src/modules/technician/command/log_command.py b/bot/src/modules/technician/command/log_command.py similarity index 96% rename from kdb-bot/src/modules/technician/command/log_command.py rename to bot/src/modules/technician/command/log_command.py index 2f799d61..27e8c557 100644 --- a/kdb-bot/src/modules/technician/command/log_command.py +++ b/bot/src/modules/technician/command/log_command.py @@ -98,7 +98,10 @@ class LogCommand(DiscordCommandABC): continue split_filename = file.split(".") - if f".{split_filename[len(split_filename) - 1]}" not in file_extensions: + if ( + f".{split_filename[len(split_filename) - 1]}" + not in file_extensions + ): continue files.append(os.path.join(r, file)) diff --git a/kdb-bot/src/modules/technician/command/restart_command.py b/bot/src/modules/technician/command/restart_command.py similarity index 94% rename from kdb-bot/src/modules/technician/command/restart_command.py rename to bot/src/modules/technician/command/restart_command.py index 76fda82c..102519fd 100644 --- a/kdb-bot/src/modules/technician/command/restart_command.py +++ b/bot/src/modules/technician/command/restart_command.py @@ -52,7 +52,9 @@ class RestartCommand(DiscordCommandABC): self._config.add_configuration("IS_RESTART", "true") await self._client_utils.presence_game("common.presence.restart") - await self._message_service.send_ctx_msg(ctx, self._t.transform("modules.technician.restart_message")) + await self._message_service.send_ctx_msg( + ctx, self._t.transform("modules.technician.restart_message") + ) await asyncio.sleep(self._settings.wait_for_restart) await self._data_integrity.check_data_integrity(is_for_shutdown=True) await self._bot.stop_async() diff --git a/kdb-bot/src/modules/technician/command/shutdown_command.py b/bot/src/modules/technician/command/shutdown_command.py similarity index 94% rename from kdb-bot/src/modules/technician/command/shutdown_command.py rename to bot/src/modules/technician/command/shutdown_command.py index db2f807a..5ddf9603 100644 --- a/kdb-bot/src/modules/technician/command/shutdown_command.py +++ b/bot/src/modules/technician/command/shutdown_command.py @@ -51,7 +51,9 @@ class ShutdownCommand(DiscordCommandABC): self._logger.debug(__name__, f"Received command shutdown {ctx}") await self._client_utils.presence_game("common.presence.shutdown") - await self._message_service.send_ctx_msg(ctx, self._t.transform("modules.technician.shutdown_message")) + await self._message_service.send_ctx_msg( + ctx, self._t.transform("modules.technician.shutdown_message") + ) await asyncio.sleep(self._settings.wait_for_shutdown) await self._data_integrity.check_data_integrity(is_for_shutdown=True) await self._bot.stop_async() diff --git a/kdb-bot/src/modules/technician/command/sync_xp_command.py b/bot/src/modules/technician/command/sync_xp_command.py similarity index 78% rename from kdb-bot/src/modules/technician/command/sync_xp_command.py rename to bot/src/modules/technician/command/sync_xp_command.py index e54a770f..90e97554 100644 --- a/kdb-bot/src/modules/technician/command/sync_xp_command.py +++ b/bot/src/modules/technician/command/sync_xp_command.py @@ -71,18 +71,28 @@ class SyncXpGroup(DiscordCommandABC): if ctx.guild is None: return - settings: ServerConfig = self._config.get_configuration(f"ServerConfig_{ctx.guild.id}") - if not FeatureFlagsSettings.get_flag_from_dict(settings.feature_flags, FeatureFlagsEnum.sync_xp): - await self._message_service.send_ctx_msg(ctx, self._t.transform("common.feature_not_activated")) + settings: ServerConfig = self._config.get_configuration( + f"ServerConfig_{ctx.guild.id}" + ) + if not FeatureFlagsSettings.get_flag_from_dict( + settings.feature_flags, FeatureFlagsEnum.sync_xp + ): + await self._message_service.send_ctx_msg( + ctx, self._t.transform("common.feature_not_activated") + ) return other_server = self._servers.get_server_by_id(server_id) - users_on_other_server = self._users.get_users_by_server_id(other_server.id).where(lambda x: not x.left_server) - discord_ids_on_other_server = users_on_other_server.select(lambda x: x.discord_id) + users_on_other_server = self._users.get_users_by_server_id( + other_server.id + ).where(lambda x: not x.left_server) + discord_ids_on_other_server = users_on_other_server.select( + lambda x: x.discord_id + ) - for user in self._users.get_users_by_server_id(self._servers.get_server_by_discord_id(ctx.guild.id).id).where( - lambda x: not x.left_server - ): + for user in self._users.get_users_by_server_id( + self._servers.get_server_by_discord_id(ctx.guild.id).id + ).where(lambda x: not x.left_server): try: if user.discord_id not in discord_ids_on_other_server: continue @@ -96,15 +106,21 @@ class SyncXpGroup(DiscordCommandABC): user.xp = user_on_other_server.xp self._users.update_user(user) self._db.save_changes() - await self._level_service.check_level(ctx.guild.get_member(user.discord_id)) + await self._level_service.check_level( + ctx.guild.get_member(user.discord_id) + ) except Exception as e: self._logger.error(__name__, f"Cannot sync user {user.name}", e) - await self._message_service.send_ctx_msg(ctx, self._t.transform("modules.technician.synced_message")) + await self._message_service.send_ctx_msg( + ctx, self._t.transform("modules.technician.synced_message") + ) self._logger.trace(__name__, f"Finished sync xp command") @all_members.autocomplete("server_id") - async def list_autocomplete(self, interaction: discord.Interaction, current: str) -> list[app_commands.Choice]: + async def list_autocomplete( + self, interaction: discord.Interaction, current: str + ) -> list[app_commands.Choice]: return [ app_commands.Choice(name=server.name, value=server.id) for server in self._client_utils.get_auto_complete_list( @@ -122,9 +138,15 @@ class SyncXpGroup(DiscordCommandABC): if ctx.guild is None: return - settings: ServerConfig = self._config.get_configuration(f"ServerConfig_{ctx.guild.id}") - if not FeatureFlagsSettings.get_flag_from_dict(settings.feature_flags, FeatureFlagsEnum.sync_xp): - await self._message_service.send_ctx_msg(ctx, self._t.transform("common.feature_not_activated")) + settings: ServerConfig = self._config.get_configuration( + f"ServerConfig_{ctx.guild.id}" + ) + if not FeatureFlagsSettings.get_flag_from_dict( + settings.feature_flags, FeatureFlagsEnum.sync_xp + ): + await self._message_service.send_ctx_msg( + ctx, self._t.transform("common.feature_not_activated") + ) return other_server = self._servers.get_server_by_id(server_id) @@ -147,12 +169,16 @@ class SyncXpGroup(DiscordCommandABC): except Exception as e: self._logger.error(__name__, f"Cannot sync user {user.name}", e) - await self._message_service.send_ctx_msg(ctx, self._t.transform("modules.technician.synced_message")) + await self._message_service.send_ctx_msg( + ctx, self._t.transform("modules.technician.synced_message") + ) await self._level_service.check_level(member) self._logger.trace(__name__, f"Finished sync xp command") @by_member.autocomplete("server_id") - async def list_autocomplete(self, interaction: discord.Interaction, current: str) -> list[app_commands.Choice]: + async def list_autocomplete( + self, interaction: discord.Interaction, current: str + ) -> list[app_commands.Choice]: return [ app_commands.Choice(name=server.name, value=server.id) for server in self._client_utils.get_auto_complete_list( diff --git a/kdb-bot/src/modules/technician/technician.json b/bot/src/modules/technician/technician.json similarity index 100% rename from kdb-bot/src/modules/technician/technician.json rename to bot/src/modules/technician/technician.json diff --git a/kdb-bot/src/modules/technician/technician_module.py b/bot/src/modules/technician/technician_module.py similarity index 85% rename from kdb-bot/src/modules/technician/technician_module.py rename to bot/src/modules/technician/technician_module.py index 8550b7d6..77677cc9 100644 --- a/kdb-bot/src/modules/technician/technician_module.py +++ b/bot/src/modules/technician/technician_module.py @@ -18,10 +18,14 @@ class TechnicianModule(ModuleABC): def __init__(self, dc: DiscordCollectionABC): ModuleABC.__init__(self, dc, FeatureFlagsEnum.base_module) - def configure_configuration(self, config: ConfigurationABC, env: ApplicationEnvironmentABC): + def configure_configuration( + self, config: ConfigurationABC, env: ApplicationEnvironmentABC + ): pass - def configure_services(self, services: ServiceCollectionABC, env: ApplicationEnvironmentABC): + def configure_services( + self, services: ServiceCollectionABC, env: ApplicationEnvironmentABC + ): services.add_transient(DataSeederABC, ApiKeySeeder) # commands services.add_transient(RestartCommand) diff --git a/kdb-bot/tools/checks/UserJoinedVoiceChannel.json b/bot/tools/checks/UserJoinedVoiceChannel.json similarity index 100% rename from kdb-bot/tools/checks/UserJoinedVoiceChannel.json rename to bot/tools/checks/UserJoinedVoiceChannel.json diff --git a/kdb-bot/tools/checks/__init__.py b/bot/tools/checks/__init__.py similarity index 100% rename from kdb-bot/tools/checks/__init__.py rename to bot/tools/checks/__init__.py diff --git a/kdb-bot/tools/checks/checks.json b/bot/tools/checks/checks.json similarity index 100% rename from kdb-bot/tools/checks/checks.json rename to bot/tools/checks/checks.json diff --git a/kdb-bot/tools/checks/get_ontime_overlaps.py b/bot/tools/checks/get_ontime_overlaps.py similarity index 100% rename from kdb-bot/tools/checks/get_ontime_overlaps.py rename to bot/tools/checks/get_ontime_overlaps.py diff --git a/kdb-bot/tools/get_version/__init__.py b/bot/tools/get_version/__init__.py similarity index 100% rename from kdb-bot/tools/get_version/__init__.py rename to bot/tools/get_version/__init__.py diff --git a/kdb-bot/tools/get_version/application.py b/bot/tools/get_version/application.py similarity index 100% rename from kdb-bot/tools/get_version/application.py rename to bot/tools/get_version/application.py diff --git a/kdb-bot/tools/get_version/get-version.json b/bot/tools/get_version/get-version.json similarity index 100% rename from kdb-bot/tools/get_version/get-version.json rename to bot/tools/get_version/get-version.json diff --git a/kdb-bot/tools/get_version/main.py b/bot/tools/get_version/main.py similarity index 100% rename from kdb-bot/tools/get_version/main.py rename to bot/tools/get_version/main.py diff --git a/kdb-bot/tools/get_version/startup.py b/bot/tools/get_version/startup.py similarity index 78% rename from kdb-bot/tools/get_version/startup.py rename to bot/tools/get_version/startup.py index 8cb6680f..eaa731d7 100644 --- a/kdb-bot/tools/get_version/startup.py +++ b/bot/tools/get_version/startup.py @@ -14,10 +14,14 @@ class Startup(StartupABC): def configure_configuration( self, configuration: ConfigurationABC, environment: ApplicationEnvironment ) -> ConfigurationABC: - environment.set_working_directory(os.path.abspath(os.path.join(environment.working_directory, "../../"))) + environment.set_working_directory( + os.path.abspath(os.path.join(environment.working_directory, "../../")) + ) configuration.add_json_file(f"cpl-workspace.json", optional=False, output=False) ws: WorkspaceSettings = configuration.get_configuration(WorkspaceSettings) - configuration.add_json_file(ws.projects[ws.default_project], optional=False, output=False) + configuration.add_json_file( + ws.projects[ws.default_project], optional=False, output=False + ) return configuration diff --git a/kdb-bot/tools/post_build/__init__.py b/bot/tools/post_build/__init__.py similarity index 100% rename from kdb-bot/tools/post_build/__init__.py rename to bot/tools/post_build/__init__.py diff --git a/kdb-bot/tools/post_build/application.py b/bot/tools/post_build/application.py similarity index 100% rename from kdb-bot/tools/post_build/application.py rename to bot/tools/post_build/application.py diff --git a/kdb-bot/tools/post_build/appsettings.json b/bot/tools/post_build/appsettings.json similarity index 100% rename from kdb-bot/tools/post_build/appsettings.json rename to bot/tools/post_build/appsettings.json diff --git a/kdb-bot/tools/post_build/main.py b/bot/tools/post_build/main.py similarity index 100% rename from kdb-bot/tools/post_build/main.py rename to bot/tools/post_build/main.py diff --git a/kdb-bot/tools/post_build/post-build.json b/bot/tools/post_build/post-build.json similarity index 100% rename from kdb-bot/tools/post_build/post-build.json rename to bot/tools/post_build/post-build.json diff --git a/kdb-bot/tools/post_build/post_build_settings.py b/bot/tools/post_build/post_build_settings.py similarity index 73% rename from kdb-bot/tools/post_build/post_build_settings.py rename to bot/tools/post_build/post_build_settings.py index 3c8a789e..b1d815da 100644 --- a/kdb-bot/tools/post_build/post_build_settings.py +++ b/bot/tools/post_build/post_build_settings.py @@ -24,5 +24,9 @@ class PostBuildSettings(ConfigurationModelABC): self._keep_config = settings["KeepConfigs"] self._config_paths = settings["ConfigPaths"] except Exception as e: - Console.error(f"[ ERROR ] [ {__name__} ]: Reading error in {type(self).__name__} settings") - Console.error(f"[ EXCEPTION ] [ {__name__} ]: {e} -> {traceback.format_exc()}") + Console.error( + f"[ ERROR ] [ {__name__} ]: Reading error in {type(self).__name__} settings" + ) + Console.error( + f"[ EXCEPTION ] [ {__name__} ]: {e} -> {traceback.format_exc()}" + ) diff --git a/kdb-bot/tools/post_build/service/__init__.py b/bot/tools/post_build/service/__init__.py similarity index 100% rename from kdb-bot/tools/post_build/service/__init__.py rename to bot/tools/post_build/service/__init__.py diff --git a/kdb-bot/tools/post_build/service/dependencies.py b/bot/tools/post_build/service/dependencies.py similarity index 93% rename from kdb-bot/tools/post_build/service/dependencies.py rename to bot/tools/post_build/service/dependencies.py index 060adae4..b0362257 100644 --- a/kdb-bot/tools/post_build/service/dependencies.py +++ b/bot/tools/post_build/service/dependencies.py @@ -54,7 +54,9 @@ class Dependencies: ) for project in self._workspace.projects: - project_file = os.path.join(self._env.working_directory, self._workspace.projects[project]) + project_file = os.path.join( + self._env.working_directory, self._workspace.projects[project] + ) self._config.add_json_file(project_file, output=False, optional=False) project: ProjectSettings = self._config.get_configuration(ProjectSettings) self._add_dependencies(project.dependencies) diff --git a/kdb-bot/tools/post_build/service/remove_config.py b/bot/tools/post_build/service/remove_config.py similarity index 100% rename from kdb-bot/tools/post_build/service/remove_config.py rename to bot/tools/post_build/service/remove_config.py diff --git a/kdb-bot/tools/post_build/startup.py b/bot/tools/post_build/startup.py similarity index 82% rename from kdb-bot/tools/post_build/startup.py rename to bot/tools/post_build/startup.py index 537f3f2a..6d5e484d 100644 --- a/kdb-bot/tools/post_build/startup.py +++ b/bot/tools/post_build/startup.py @@ -18,10 +18,14 @@ class Startup(StartupABC): self, configuration: ConfigurationABC, environment: ApplicationEnvironment ) -> ConfigurationABC: configuration.add_json_file(f"appsettings.json", optional=False, output=False) - environment.set_working_directory(os.path.abspath(os.path.join(environment.working_directory, "../../"))) + environment.set_working_directory( + os.path.abspath(os.path.join(environment.working_directory, "../../")) + ) configuration.add_json_file(f"cpl-workspace.json", optional=False, output=False) ws: WorkspaceSettings = configuration.get_configuration(WorkspaceSettings) - configuration.add_json_file(ws.projects[ws.default_project], optional=False, output=False) + configuration.add_json_file( + ws.projects[ws.default_project], optional=False, output=False + ) return configuration diff --git a/kdb-bot/tools/set_version/__init__.py b/bot/tools/set_version/__init__.py similarity index 100% rename from kdb-bot/tools/set_version/__init__.py rename to bot/tools/set_version/__init__.py diff --git a/kdb-bot/tools/set_version/application.py b/bot/tools/set_version/application.py similarity index 74% rename from kdb-bot/tools/set_version/application.py rename to bot/tools/set_version/application.py index 92055455..f773982c 100644 --- a/kdb-bot/tools/set_version/application.py +++ b/bot/tools/set_version/application.py @@ -22,7 +22,9 @@ class Application(ApplicationABC): self._workspace: WorkspaceSettings = config.get_configuration(WorkspaceSettings) self._git_service: GitService = self._services.get_service(GitService) - self._version_setter: VersionSetterService = self._services.get_service(VersionSetterService) + self._version_setter: VersionSetterService = self._services.get_service( + VersionSetterService + ) self._version_pipe: VersionPipe = self._services.get_service(VersionPipe) def configure(self): @@ -57,13 +59,19 @@ class Application(ApplicationABC): try: if branch.startswith("#"): self._configuration.add_json_file( - self._workspace.projects[self._workspace.default_project], optional=False, output=False + self._workspace.projects[self._workspace.default_project], + optional=False, + output=False, + ) + ps: ProjectSettings = self._configuration.get_configuration( + ProjectSettings ) - ps: ProjectSettings = self._configuration.get_configuration(ProjectSettings) version[VersionSettingsNameEnum.major.value] = ps.version.major version[VersionSettingsNameEnum.minor.value] = ps.version.minor - version[VersionSettingsNameEnum.micro.value] = f'dev{branch.split("#")[1]}' + version[ + VersionSettingsNameEnum.micro.value + ] = f'dev{branch.split("#")[1]}' else: if "." not in branch and "." in suffix: branch = suffix @@ -78,7 +86,9 @@ class Application(ApplicationABC): else: if not suffix.startswith(".") and suffix != "": suffix = f".{suffix}" - version[VersionSettingsNameEnum.micro.value] = f'{branch.split(".")[2]}{suffix}' + version[ + VersionSettingsNameEnum.micro.value + ] = f'{branch.split(".")[2]}{suffix}' except Exception as e: Console.error(f"Branch {branch} does not contain valid version") return @@ -104,21 +114,37 @@ class Application(ApplicationABC): try: skipped = [] for project in self._workspace.projects: - if project not in diff_paths and String.convert_to_snake_case(project) not in diff_paths and not force: + if ( + project not in diff_paths + and String.convert_to_snake_case(project) not in diff_paths + and not force + ): # Console.write_line(f'Skipping {project} due to missing changes') skipped.append(project) continue - Console.write_line(f"Set dependencies {self._version_pipe.transform(version)} for {project}") - self._version_setter.set_dependencies( - self._workspace.projects[project], version, "Dependencies", skipped=skipped + Console.write_line( + f"Set dependencies {self._version_pipe.transform(version)} for {project}" ) self._version_setter.set_dependencies( - self._workspace.projects[project], version, "DevDependencies", skipped=skipped + self._workspace.projects[project], + version, + "Dependencies", + skipped=skipped, + ) + self._version_setter.set_dependencies( + self._workspace.projects[project], + version, + "DevDependencies", + skipped=skipped, ) - Console.write_line(f"Set version {self._version_pipe.transform(version)} for {project}") - self._version_setter.set_version(self._workspace.projects[project], version) + Console.write_line( + f"Set version {self._version_pipe.transform(version)} for {project}" + ) + self._version_setter.set_version( + self._workspace.projects[project], version + ) except Exception as e: Console.error("Version could not be set", traceback.format_exc()) return diff --git a/kdb-bot/tools/set_version/git_service.py b/bot/tools/set_version/git_service.py similarity index 100% rename from kdb-bot/tools/set_version/git_service.py rename to bot/tools/set_version/git_service.py diff --git a/kdb-bot/tools/set_version/main.py b/bot/tools/set_version/main.py similarity index 100% rename from kdb-bot/tools/set_version/main.py rename to bot/tools/set_version/main.py diff --git a/kdb-bot/tools/set_version/set-version.json b/bot/tools/set_version/set-version.json similarity index 100% rename from kdb-bot/tools/set_version/set-version.json rename to bot/tools/set_version/set-version.json diff --git a/kdb-bot/tools/set_version/startup.py b/bot/tools/set_version/startup.py similarity index 82% rename from kdb-bot/tools/set_version/startup.py rename to bot/tools/set_version/startup.py index ce7fb47f..47898325 100644 --- a/kdb-bot/tools/set_version/startup.py +++ b/bot/tools/set_version/startup.py @@ -19,8 +19,12 @@ class Startup(StartupABC): ) -> ConfigurationABC: configuration.add_json_file("cpl-workspace.json", optional=True, output=False) if configuration.get_configuration(WorkspaceSettings) is None: - environment.set_working_directory(os.path.join(environment.working_directory, "../../")) - configuration.add_json_file("cpl-workspace.json", optional=False, output=False) + environment.set_working_directory( + os.path.join(environment.working_directory, "../../") + ) + configuration.add_json_file( + "cpl-workspace.json", optional=False, output=False + ) return configuration diff --git a/kdb-bot/tools/set_version/version_setter_service.py b/bot/tools/set_version/version_setter_service.py similarity index 76% rename from kdb-bot/tools/set_version/version_setter_service.py rename to bot/tools/set_version/version_setter_service.py index e1dfcf8a..e4b0545d 100644 --- a/kdb-bot/tools/set_version/version_setter_service.py +++ b/bot/tools/set_version/version_setter_service.py @@ -12,7 +12,9 @@ class VersionSetterService: def _read_file(self, file: str) -> dict: project_json = {} - with open(os.path.join(self._env.working_directory, file), "r", encoding="utf-8") as f: + with open( + os.path.join(self._env.working_directory, file), "r", encoding="utf-8" + ) as f: # load json project_json = json.load(f) f.close() @@ -20,7 +22,9 @@ class VersionSetterService: return project_json def _write_file(self, file: str, project_json: dict): - with open(os.path.join(self._env.working_directory, file), "w", encoding="utf-8") as f: + with open( + os.path.join(self._env.working_directory, file), "w", encoding="utf-8" + ) as f: f.write(json.dumps(project_json, indent=2)) f.close() @@ -48,14 +52,20 @@ class VersionSetterService: if ( skipped is not None - and (dep_name in skipped or String.convert_to_snake_case(dep_name) in skipped) + and ( + dep_name in skipped + or String.convert_to_snake_case(dep_name) in skipped + ) or dep_version == "" ): new_deps.append(dependency) continue new_deps.append( - dependency.replace(dep_version, f'{version["Major"]}.{version["Minor"]}.{version["Micro"]}') + dependency.replace( + dep_version, + f'{version["Major"]}.{version["Minor"]}.{version["Micro"]}', + ) ) project_json["ProjectSettings"][key] = new_deps diff --git a/kdb-bot/LICENSE b/kdb-bot/LICENSE deleted file mode 100644 index 374f2e3a..00000000 --- a/kdb-bot/LICENSE +++ /dev/null @@ -1,9 +0,0 @@ -MIT License - -Copyright (c) 2022-2023 sh-edraft.de - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/kdb-bot/README.md b/kdb-bot/README.md deleted file mode 100644 index 72b3dd33..00000000 --- a/kdb-bot/README.md +++ /dev/null @@ -1,2 +0,0 @@ -# kd_discord_bot - diff --git a/kdb-bot/cpl-workspace.json b/kdb-bot/cpl-workspace.json deleted file mode 100644 index 833b19a0..00000000 --- a/kdb-bot/cpl-workspace.json +++ /dev/null @@ -1,46 +0,0 @@ -{ - "WorkspaceSettings": { - "DefaultProject": "bot", - "Projects": { - "bot": "src/bot/bot.json", - "bot-api": "src/bot_api/bot-api.json", - "bot-core": "src/bot_core/bot-core.json", - "bot-data": "src/bot_data/bot-data.json", - "bot-graphql": "src/bot_graphql/bot-graphql.json", - "achievements": "src/modules/achievements/achievements.json", - "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", - "database": "src/modules/database/database.json", - "level": "src/modules/level/level.json", - "permission": "src/modules/permission/permission.json", - "technician": "src/modules/technician/technician.json", - "short-role-name": "src/modules/short_role_name/short-role-name.json", - "special-offers": "src/modules/special_offers/special-offers.json", - "checks": "tools/checks/checks.json", - "get-version": "tools/get_version/get-version.json", - "post-build": "tools/post_build/post-build.json", - "set-version": "tools/set_version/set-version.json" - }, - "Scripts": { - "format": "black ./", - "sv": "cpl set-version $ARGS", - "set-version": "cpl run set-version $ARGS --dev; echo '';", - "gv": "cpl get-version", - "get-version": "export VERSION=$(cpl run get-version --dev); echo $VERSION;", - "pre-build": "cpl set-version $ARGS; black ./;", - "post-build": "cpl run post-build --dev; black ./;", - "pre-prod": "cpl build", - "prod": "export KDB_ENVIRONMENT=production; export KDB_NAME=KDB-Prod; cpl start;", - "pre-stage": "cpl build", - "stage": "export KDB_ENVIRONMENT=staging; export KDB_NAME=KDB-Stage; cpl start;", - "pre-dev": "cpl build", - "dev": "export KDB_ENVIRONMENT=development; export KDB_NAME=KDB-Dev; cpl start;", - "docker-build": "cpl build $ARGS; docker build -t sh-edraft.de/kdb-bot:$(cpl gv) .;", - "dc-up": "docker-compose up -d", - "dc-down": "docker-compose down", - "docker": "cpl dc-down; cpl docker-build; cpl dc-up;" - } - } -} \ No newline at end of file diff --git a/kdb-bot/docker b/kdb-bot/docker deleted file mode 160000 index 7ae47838..00000000 --- a/kdb-bot/docker +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 7ae4783874d5aa8015d8f0da2c19c293fcd72762 diff --git a/kdb-bot/dockerfile b/kdb-bot/dockerfile deleted file mode 100644 index 478bf7e7..00000000 --- a/kdb-bot/dockerfile +++ /dev/null @@ -1,21 +0,0 @@ -# syntax=docker/dockerfile:1 -FROM python:3.10.4-alpine - -WORKDIR /app -COPY ./dist/bot/build/kdb-bot/ . -COPY ./dist/bot/build/requirements.txt . - -RUN python -m pip install --upgrade pip - -RUN apk update -RUN apk add --update alpine-sdk linux-headers -RUN apk add bash -RUN apk add nano - -RUN pip install -r requirements.txt --extra-index-url https://pip.sh-edraft.de -RUN pip install flask[async] - -# RUN pip install dnspython==2.2.1 # https://stackoverflow.com/questions/75137717/eventlet-dns-python-attribute-error-module-dns-rdtypes-has-no-attribute-any -# ^ probably fixed py package updates - -CMD [ "bash", "/app/bot/bot"] diff --git a/kdb-bot/pyproject.toml b/kdb-bot/pyproject.toml deleted file mode 100644 index e34796ec..00000000 --- a/kdb-bot/pyproject.toml +++ /dev/null @@ -1,2 +0,0 @@ -[tool.black] -line-length = 120 \ No newline at end of file diff --git a/kdb-bot/src/bot/config b/kdb-bot/src/bot/config deleted file mode 160000 index aa124934..00000000 --- a/kdb-bot/src/bot/config +++ /dev/null @@ -1 +0,0 @@ -Subproject commit aa1249341910f2877522a2002df7feea95256749 diff --git a/kdb-bot/src/bot_api/config b/kdb-bot/src/bot_api/config deleted file mode 160000 index b6ffed4d..00000000 --- a/kdb-bot/src/bot_api/config +++ /dev/null @@ -1 +0,0 @@ -Subproject commit b6ffed4da1f75f5fbad1ce7f312b67f32de010b5 diff --git a/kdb-web/.browserslistrc b/web/.browserslistrc similarity index 100% rename from kdb-web/.browserslistrc rename to web/.browserslistrc diff --git a/kdb-web/.editorconfig b/web/.editorconfig similarity index 100% rename from kdb-web/.editorconfig rename to web/.editorconfig diff --git a/kdb-web/.gitignore b/web/.gitignore similarity index 100% rename from kdb-web/.gitignore rename to web/.gitignore diff --git a/kdb-web/.prettierrc b/web/.prettierrc similarity index 100% rename from kdb-web/.prettierrc rename to web/.prettierrc diff --git a/kdb-web/README.md b/web/README.md similarity index 100% rename from kdb-web/README.md rename to web/README.md diff --git a/kdb-web/angular.json b/web/angular.json similarity index 100% rename from kdb-web/angular.json rename to web/angular.json diff --git a/kdb-web/dockerfile b/web/dockerfile similarity index 100% rename from kdb-web/dockerfile rename to web/dockerfile diff --git a/kdb-web/karma.conf.js b/web/karma.conf.js similarity index 100% rename from kdb-web/karma.conf.js rename to web/karma.conf.js diff --git a/kdb-web/nginx.conf.template b/web/nginx.conf.template similarity index 100% rename from kdb-web/nginx.conf.template rename to web/nginx.conf.template diff --git a/kdb-web/package-lock.json b/web/package-lock.json similarity index 100% rename from kdb-web/package-lock.json rename to web/package-lock.json diff --git a/kdb-web/package.json b/web/package.json similarity index 100% rename from kdb-web/package.json rename to web/package.json diff --git a/kdb-web/src/app/app-routing.module.ts b/web/src/app/app-routing.module.ts similarity index 100% rename from kdb-web/src/app/app-routing.module.ts rename to web/src/app/app-routing.module.ts diff --git a/kdb-web/src/app/app.component.html b/web/src/app/app.component.html similarity index 100% rename from kdb-web/src/app/app.component.html rename to web/src/app/app.component.html diff --git a/kdb-web/src/app/app.component.scss b/web/src/app/app.component.scss similarity index 100% rename from kdb-web/src/app/app.component.scss rename to web/src/app/app.component.scss diff --git a/kdb-web/src/app/app.component.spec.ts b/web/src/app/app.component.spec.ts similarity index 100% rename from kdb-web/src/app/app.component.spec.ts rename to web/src/app/app.component.spec.ts diff --git a/kdb-web/src/app/app.component.ts b/web/src/app/app.component.ts similarity index 100% rename from kdb-web/src/app/app.component.ts rename to web/src/app/app.component.ts diff --git a/kdb-web/src/app/app.module.ts b/web/src/app/app.module.ts similarity index 100% rename from kdb-web/src/app/app.module.ts rename to web/src/app/app.module.ts diff --git a/kdb-web/src/app/base/component-with-table.spec.ts b/web/src/app/base/component-with-table.spec.ts similarity index 100% rename from kdb-web/src/app/base/component-with-table.spec.ts rename to web/src/app/base/component-with-table.spec.ts diff --git a/kdb-web/src/app/base/component-with-table.ts b/web/src/app/base/component-with-table.ts similarity index 100% rename from kdb-web/src/app/base/component-with-table.ts rename to web/src/app/base/component-with-table.ts diff --git a/kdb-web/src/app/components/error/not-found/not-found.component.html b/web/src/app/components/error/not-found/not-found.component.html similarity index 100% rename from kdb-web/src/app/components/error/not-found/not-found.component.html rename to web/src/app/components/error/not-found/not-found.component.html diff --git a/kdb-web/src/app/components/error/not-found/not-found.component.scss b/web/src/app/components/error/not-found/not-found.component.scss similarity index 100% rename from kdb-web/src/app/components/error/not-found/not-found.component.scss rename to web/src/app/components/error/not-found/not-found.component.scss diff --git a/kdb-web/src/app/components/error/not-found/not-found.component.spec.ts b/web/src/app/components/error/not-found/not-found.component.spec.ts similarity index 100% rename from kdb-web/src/app/components/error/not-found/not-found.component.spec.ts rename to web/src/app/components/error/not-found/not-found.component.spec.ts diff --git a/kdb-web/src/app/components/error/not-found/not-found.component.ts b/web/src/app/components/error/not-found/not-found.component.ts similarity index 100% rename from kdb-web/src/app/components/error/not-found/not-found.component.ts rename to web/src/app/components/error/not-found/not-found.component.ts diff --git a/kdb-web/src/app/components/footer/footer.component.html b/web/src/app/components/footer/footer.component.html similarity index 100% rename from kdb-web/src/app/components/footer/footer.component.html rename to web/src/app/components/footer/footer.component.html diff --git a/kdb-web/src/app/components/footer/footer.component.scss b/web/src/app/components/footer/footer.component.scss similarity index 100% rename from kdb-web/src/app/components/footer/footer.component.scss rename to web/src/app/components/footer/footer.component.scss diff --git a/kdb-web/src/app/components/footer/footer.component.spec.ts b/web/src/app/components/footer/footer.component.spec.ts similarity index 100% rename from kdb-web/src/app/components/footer/footer.component.spec.ts rename to web/src/app/components/footer/footer.component.spec.ts diff --git a/kdb-web/src/app/components/footer/footer.component.ts b/web/src/app/components/footer/footer.component.ts similarity index 100% rename from kdb-web/src/app/components/footer/footer.component.ts rename to web/src/app/components/footer/footer.component.ts diff --git a/kdb-web/src/app/components/header/header.component.html b/web/src/app/components/header/header.component.html similarity index 100% rename from kdb-web/src/app/components/header/header.component.html rename to web/src/app/components/header/header.component.html diff --git a/kdb-web/src/app/components/header/header.component.scss b/web/src/app/components/header/header.component.scss similarity index 100% rename from kdb-web/src/app/components/header/header.component.scss rename to web/src/app/components/header/header.component.scss diff --git a/kdb-web/src/app/components/header/header.component.spec.ts b/web/src/app/components/header/header.component.spec.ts similarity index 100% rename from kdb-web/src/app/components/header/header.component.spec.ts rename to web/src/app/components/header/header.component.spec.ts diff --git a/kdb-web/src/app/components/header/header.component.ts b/web/src/app/components/header/header.component.ts similarity index 100% rename from kdb-web/src/app/components/header/header.component.ts rename to web/src/app/components/header/header.component.ts diff --git a/kdb-web/src/app/components/sidebar/sidebar.component.html b/web/src/app/components/sidebar/sidebar.component.html similarity index 100% rename from kdb-web/src/app/components/sidebar/sidebar.component.html rename to web/src/app/components/sidebar/sidebar.component.html diff --git a/kdb-web/src/app/components/sidebar/sidebar.component.scss b/web/src/app/components/sidebar/sidebar.component.scss similarity index 100% rename from kdb-web/src/app/components/sidebar/sidebar.component.scss rename to web/src/app/components/sidebar/sidebar.component.scss diff --git a/kdb-web/src/app/components/sidebar/sidebar.component.spec.ts b/web/src/app/components/sidebar/sidebar.component.spec.ts similarity index 100% rename from kdb-web/src/app/components/sidebar/sidebar.component.spec.ts rename to web/src/app/components/sidebar/sidebar.component.spec.ts diff --git a/kdb-web/src/app/components/sidebar/sidebar.component.ts b/web/src/app/components/sidebar/sidebar.component.ts similarity index 100% rename from kdb-web/src/app/components/sidebar/sidebar.component.ts rename to web/src/app/components/sidebar/sidebar.component.ts diff --git a/kdb-web/src/app/components/spinner/spinner.component.html b/web/src/app/components/spinner/spinner.component.html similarity index 100% rename from kdb-web/src/app/components/spinner/spinner.component.html rename to web/src/app/components/spinner/spinner.component.html diff --git a/kdb-web/src/app/components/spinner/spinner.component.scss b/web/src/app/components/spinner/spinner.component.scss similarity index 100% rename from kdb-web/src/app/components/spinner/spinner.component.scss rename to web/src/app/components/spinner/spinner.component.scss diff --git a/kdb-web/src/app/components/spinner/spinner.component.spec.ts b/web/src/app/components/spinner/spinner.component.spec.ts similarity index 100% rename from kdb-web/src/app/components/spinner/spinner.component.spec.ts rename to web/src/app/components/spinner/spinner.component.spec.ts diff --git a/kdb-web/src/app/components/spinner/spinner.component.ts b/web/src/app/components/spinner/spinner.component.ts similarity index 100% rename from kdb-web/src/app/components/spinner/spinner.component.ts rename to web/src/app/components/spinner/spinner.component.ts diff --git a/kdb-web/src/app/models/auth/admin-update-user.dto.ts b/web/src/app/models/auth/admin-update-user.dto.ts similarity index 100% rename from kdb-web/src/app/models/auth/admin-update-user.dto.ts rename to web/src/app/models/auth/admin-update-user.dto.ts diff --git a/kdb-web/src/app/models/auth/auth-error-messages.enum.ts b/web/src/app/models/auth/auth-error-messages.enum.ts similarity index 100% rename from kdb-web/src/app/models/auth/auth-error-messages.enum.ts rename to web/src/app/models/auth/auth-error-messages.enum.ts diff --git a/kdb-web/src/app/models/auth/auth-roles.enum.ts b/web/src/app/models/auth/auth-roles.enum.ts similarity index 100% rename from kdb-web/src/app/models/auth/auth-roles.enum.ts rename to web/src/app/models/auth/auth-roles.enum.ts diff --git a/kdb-web/src/app/models/auth/auth-user-atr-errors.ts b/web/src/app/models/auth/auth-user-atr-errors.ts similarity index 100% rename from kdb-web/src/app/models/auth/auth-user-atr-errors.ts rename to web/src/app/models/auth/auth-user-atr-errors.ts diff --git a/kdb-web/src/app/models/auth/auth-user.dto.ts b/web/src/app/models/auth/auth-user.dto.ts similarity index 100% rename from kdb-web/src/app/models/auth/auth-user.dto.ts rename to web/src/app/models/auth/auth-user.dto.ts diff --git a/kdb-web/src/app/models/auth/discord-auth-url.dto.ts b/web/src/app/models/auth/discord-auth-url.dto.ts similarity index 100% rename from kdb-web/src/app/models/auth/discord-auth-url.dto.ts rename to web/src/app/models/auth/discord-auth-url.dto.ts diff --git a/kdb-web/src/app/models/auth/email-string.dto.ts b/web/src/app/models/auth/email-string.dto.ts similarity index 100% rename from kdb-web/src/app/models/auth/email-string.dto.ts rename to web/src/app/models/auth/email-string.dto.ts diff --git a/kdb-web/src/app/models/auth/oauth.dto.ts b/web/src/app/models/auth/oauth.dto.ts similarity index 100% rename from kdb-web/src/app/models/auth/oauth.dto.ts rename to web/src/app/models/auth/oauth.dto.ts diff --git a/kdb-web/src/app/models/auth/register-error-messages.enum.ts b/web/src/app/models/auth/register-error-messages.enum.ts similarity index 100% rename from kdb-web/src/app/models/auth/register-error-messages.enum.ts rename to web/src/app/models/auth/register-error-messages.enum.ts diff --git a/kdb-web/src/app/models/auth/reset-password.dto.ts b/web/src/app/models/auth/reset-password.dto.ts similarity index 100% rename from kdb-web/src/app/models/auth/reset-password.dto.ts rename to web/src/app/models/auth/reset-password.dto.ts diff --git a/kdb-web/src/app/models/auth/token.dto.ts b/web/src/app/models/auth/token.dto.ts similarity index 100% rename from kdb-web/src/app/models/auth/token.dto.ts rename to web/src/app/models/auth/token.dto.ts diff --git a/kdb-web/src/app/models/auth/update-user.dto.ts b/web/src/app/models/auth/update-user.dto.ts similarity index 100% rename from kdb-web/src/app/models/auth/update-user.dto.ts rename to web/src/app/models/auth/update-user.dto.ts diff --git a/kdb-web/src/app/models/config/api-version.ts b/web/src/app/models/config/api-version.ts similarity index 100% rename from kdb-web/src/app/models/config/api-version.ts rename to web/src/app/models/config/api-version.ts diff --git a/kdb-web/src/app/models/config/app-settings.ts b/web/src/app/models/config/app-settings.ts similarity index 100% rename from kdb-web/src/app/models/config/app-settings.ts rename to web/src/app/models/config/app-settings.ts diff --git a/kdb-web/src/app/models/config/feature-flags.model.ts b/web/src/app/models/config/feature-flags.model.ts similarity index 100% rename from kdb-web/src/app/models/config/feature-flags.model.ts rename to web/src/app/models/config/feature-flags.model.ts diff --git a/kdb-web/src/app/models/config/server-config.model.ts b/web/src/app/models/config/server-config.model.ts similarity index 100% rename from kdb-web/src/app/models/config/server-config.model.ts rename to web/src/app/models/config/server-config.model.ts diff --git a/kdb-web/src/app/models/config/settings.dto.ts b/web/src/app/models/config/settings.dto.ts similarity index 100% rename from kdb-web/src/app/models/config/settings.dto.ts rename to web/src/app/models/config/settings.dto.ts diff --git a/kdb-web/src/app/models/config/software-version.dto.ts b/web/src/app/models/config/software-version.dto.ts similarity index 100% rename from kdb-web/src/app/models/config/software-version.dto.ts rename to web/src/app/models/config/software-version.dto.ts diff --git a/kdb-web/src/app/models/config/software-version.ts b/web/src/app/models/config/software-version.ts similarity index 100% rename from kdb-web/src/app/models/config/software-version.ts rename to web/src/app/models/config/software-version.ts diff --git a/kdb-web/src/app/models/config/technician-config.model.ts b/web/src/app/models/config/technician-config.model.ts similarity index 100% rename from kdb-web/src/app/models/config/technician-config.model.ts rename to web/src/app/models/config/technician-config.model.ts diff --git a/kdb-web/src/app/models/data/achievement.model.ts b/web/src/app/models/data/achievement.model.ts similarity index 100% rename from kdb-web/src/app/models/data/achievement.model.ts rename to web/src/app/models/data/achievement.model.ts diff --git a/kdb-web/src/app/models/data/auto_role.model.ts b/web/src/app/models/data/auto_role.model.ts similarity index 100% rename from kdb-web/src/app/models/data/auto_role.model.ts rename to web/src/app/models/data/auto_role.model.ts diff --git a/kdb-web/src/app/models/data/client.model.ts b/web/src/app/models/data/client.model.ts similarity index 100% rename from kdb-web/src/app/models/data/client.model.ts rename to web/src/app/models/data/client.model.ts diff --git a/kdb-web/src/app/models/data/data.model.ts b/web/src/app/models/data/data.model.ts similarity index 100% rename from kdb-web/src/app/models/data/data.model.ts rename to web/src/app/models/data/data.model.ts diff --git a/kdb-web/src/app/models/data/discord.model.ts b/web/src/app/models/data/discord.model.ts similarity index 100% rename from kdb-web/src/app/models/data/discord.model.ts rename to web/src/app/models/data/discord.model.ts diff --git a/kdb-web/src/app/models/data/level.model.ts b/web/src/app/models/data/level.model.ts similarity index 100% rename from kdb-web/src/app/models/data/level.model.ts rename to web/src/app/models/data/level.model.ts diff --git a/kdb-web/src/app/models/data/server.model.ts b/web/src/app/models/data/server.model.ts similarity index 100% rename from kdb-web/src/app/models/data/server.model.ts rename to web/src/app/models/data/server.model.ts diff --git a/kdb-web/src/app/models/data/short_role_name.model.ts b/web/src/app/models/data/short_role_name.model.ts similarity index 100% rename from kdb-web/src/app/models/data/short_role_name.model.ts rename to web/src/app/models/data/short_role_name.model.ts diff --git a/kdb-web/src/app/models/data/user.model.ts b/web/src/app/models/data/user.model.ts similarity index 100% rename from kdb-web/src/app/models/data/user.model.ts rename to web/src/app/models/data/user.model.ts diff --git a/kdb-web/src/app/models/data/user_joined_game_server.model.ts b/web/src/app/models/data/user_joined_game_server.model.ts similarity index 100% rename from kdb-web/src/app/models/data/user_joined_game_server.model.ts rename to web/src/app/models/data/user_joined_game_server.model.ts diff --git a/kdb-web/src/app/models/data/user_joined_server.model.ts b/web/src/app/models/data/user_joined_server.model.ts similarity index 100% rename from kdb-web/src/app/models/data/user_joined_server.model.ts rename to web/src/app/models/data/user_joined_server.model.ts diff --git a/kdb-web/src/app/models/data/user_joined_voice_channel.model.ts b/web/src/app/models/data/user_joined_voice_channel.model.ts similarity index 100% rename from kdb-web/src/app/models/data/user_joined_voice_channel.model.ts rename to web/src/app/models/data/user_joined_voice_channel.model.ts diff --git a/kdb-web/src/app/models/data/user_warning.model.ts b/web/src/app/models/data/user_warning.model.ts similarity index 100% rename from kdb-web/src/app/models/data/user_warning.model.ts rename to web/src/app/models/data/user_warning.model.ts diff --git a/kdb-web/src/app/models/error/error-dto.ts b/web/src/app/models/error/error-dto.ts similarity index 100% rename from kdb-web/src/app/models/error/error-dto.ts rename to web/src/app/models/error/error-dto.ts diff --git a/kdb-web/src/app/models/error/service-error-code.enum.ts b/web/src/app/models/error/service-error-code.enum.ts similarity index 100% rename from kdb-web/src/app/models/error/service-error-code.enum.ts rename to web/src/app/models/error/service-error-code.enum.ts diff --git a/kdb-web/src/app/models/graphql/filter/page.model.ts b/web/src/app/models/graphql/filter/page.model.ts similarity index 100% rename from kdb-web/src/app/models/graphql/filter/page.model.ts rename to web/src/app/models/graphql/filter/page.model.ts diff --git a/kdb-web/src/app/models/graphql/filter/sort.model.ts b/web/src/app/models/graphql/filter/sort.model.ts similarity index 100% rename from kdb-web/src/app/models/graphql/filter/sort.model.ts rename to web/src/app/models/graphql/filter/sort.model.ts diff --git a/kdb-web/src/app/models/graphql/mutations.model.ts b/web/src/app/models/graphql/mutations.model.ts similarity index 100% rename from kdb-web/src/app/models/graphql/mutations.model.ts rename to web/src/app/models/graphql/mutations.model.ts diff --git a/kdb-web/src/app/models/graphql/queries.model.ts b/web/src/app/models/graphql/queries.model.ts similarity index 100% rename from kdb-web/src/app/models/graphql/queries.model.ts rename to web/src/app/models/graphql/queries.model.ts diff --git a/kdb-web/src/app/models/graphql/query.model.ts b/web/src/app/models/graphql/query.model.ts similarity index 100% rename from kdb-web/src/app/models/graphql/query.model.ts rename to web/src/app/models/graphql/query.model.ts diff --git a/kdb-web/src/app/models/graphql/result.model.ts b/web/src/app/models/graphql/result.model.ts similarity index 100% rename from kdb-web/src/app/models/graphql/result.model.ts rename to web/src/app/models/graphql/result.model.ts diff --git a/kdb-web/src/app/models/graphql/variables.model.ts b/web/src/app/models/graphql/variables.model.ts similarity index 100% rename from kdb-web/src/app/models/graphql/variables.model.ts rename to web/src/app/models/graphql/variables.model.ts diff --git a/kdb-web/src/app/models/selection/auth-user/auth-user-select-criterion.dto.ts b/web/src/app/models/selection/auth-user/auth-user-select-criterion.dto.ts similarity index 100% rename from kdb-web/src/app/models/selection/auth-user/auth-user-select-criterion.dto.ts rename to web/src/app/models/selection/auth-user/auth-user-select-criterion.dto.ts diff --git a/kdb-web/src/app/models/selection/auth-user/get-filtered-auth-users-result.dto.ts b/web/src/app/models/selection/auth-user/get-filtered-auth-users-result.dto.ts similarity index 100% rename from kdb-web/src/app/models/selection/auth-user/get-filtered-auth-users-result.dto.ts rename to web/src/app/models/selection/auth-user/get-filtered-auth-users-result.dto.ts diff --git a/kdb-web/src/app/models/selection/select-criterion.model.ts b/web/src/app/models/selection/select-criterion.model.ts similarity index 100% rename from kdb-web/src/app/models/selection/select-criterion.model.ts rename to web/src/app/models/selection/select-criterion.model.ts diff --git a/kdb-web/src/app/models/utils/confirmation-dialog.ts b/web/src/app/models/utils/confirmation-dialog.ts similarity index 100% rename from kdb-web/src/app/models/utils/confirmation-dialog.ts rename to web/src/app/models/utils/confirmation-dialog.ts diff --git a/kdb-web/src/app/models/utils/toast-options.ts b/web/src/app/models/utils/toast-options.ts similarity index 100% rename from kdb-web/src/app/models/utils/toast-options.ts rename to web/src/app/models/utils/toast-options.ts diff --git a/kdb-web/src/app/models/view/theme.ts b/web/src/app/models/view/theme.ts similarity index 100% rename from kdb-web/src/app/models/view/theme.ts rename to web/src/app/models/view/theme.ts diff --git a/kdb-web/src/app/models/view/themes.enum.ts b/web/src/app/models/view/themes.enum.ts similarity index 100% rename from kdb-web/src/app/models/view/themes.enum.ts rename to web/src/app/models/view/themes.enum.ts diff --git a/kdb-web/src/app/modules/admin/auth-users/auth-user-routing.module.ts b/web/src/app/modules/admin/auth-users/auth-user-routing.module.ts similarity index 100% rename from kdb-web/src/app/modules/admin/auth-users/auth-user-routing.module.ts rename to web/src/app/modules/admin/auth-users/auth-user-routing.module.ts diff --git a/kdb-web/src/app/modules/admin/auth-users/auth-user.module.ts b/web/src/app/modules/admin/auth-users/auth-user.module.ts similarity index 100% rename from kdb-web/src/app/modules/admin/auth-users/auth-user.module.ts rename to web/src/app/modules/admin/auth-users/auth-user.module.ts diff --git a/kdb-web/src/app/modules/admin/auth-users/components/auth-user/auth-user.component.html b/web/src/app/modules/admin/auth-users/components/auth-user/auth-user.component.html similarity index 100% rename from kdb-web/src/app/modules/admin/auth-users/components/auth-user/auth-user.component.html rename to web/src/app/modules/admin/auth-users/components/auth-user/auth-user.component.html diff --git a/kdb-web/src/app/modules/admin/auth-users/components/auth-user/auth-user.component.scss b/web/src/app/modules/admin/auth-users/components/auth-user/auth-user.component.scss similarity index 100% rename from kdb-web/src/app/modules/admin/auth-users/components/auth-user/auth-user.component.scss rename to web/src/app/modules/admin/auth-users/components/auth-user/auth-user.component.scss diff --git a/kdb-web/src/app/modules/admin/auth-users/components/auth-user/auth-user.component.spec.ts b/web/src/app/modules/admin/auth-users/components/auth-user/auth-user.component.spec.ts similarity index 100% rename from kdb-web/src/app/modules/admin/auth-users/components/auth-user/auth-user.component.spec.ts rename to web/src/app/modules/admin/auth-users/components/auth-user/auth-user.component.spec.ts diff --git a/kdb-web/src/app/modules/admin/auth-users/components/auth-user/auth-user.component.ts b/web/src/app/modules/admin/auth-users/components/auth-user/auth-user.component.ts similarity index 100% rename from kdb-web/src/app/modules/admin/auth-users/components/auth-user/auth-user.component.ts rename to web/src/app/modules/admin/auth-users/components/auth-user/auth-user.component.ts diff --git a/kdb-web/src/app/modules/admin/settings/components/settings/settings.component.html b/web/src/app/modules/admin/settings/components/settings/settings.component.html similarity index 100% rename from kdb-web/src/app/modules/admin/settings/components/settings/settings.component.html rename to web/src/app/modules/admin/settings/components/settings/settings.component.html diff --git a/kdb-web/src/app/modules/admin/settings/components/settings/settings.component.scss b/web/src/app/modules/admin/settings/components/settings/settings.component.scss similarity index 100% rename from kdb-web/src/app/modules/admin/settings/components/settings/settings.component.scss rename to web/src/app/modules/admin/settings/components/settings/settings.component.scss diff --git a/kdb-web/src/app/modules/admin/settings/components/settings/settings.component.spec.ts b/web/src/app/modules/admin/settings/components/settings/settings.component.spec.ts similarity index 100% rename from kdb-web/src/app/modules/admin/settings/components/settings/settings.component.spec.ts rename to web/src/app/modules/admin/settings/components/settings/settings.component.spec.ts diff --git a/kdb-web/src/app/modules/admin/settings/components/settings/settings.component.ts b/web/src/app/modules/admin/settings/components/settings/settings.component.ts similarity index 100% rename from kdb-web/src/app/modules/admin/settings/components/settings/settings.component.ts rename to web/src/app/modules/admin/settings/components/settings/settings.component.ts diff --git a/kdb-web/src/app/modules/admin/settings/settings-routing.module.ts b/web/src/app/modules/admin/settings/settings-routing.module.ts similarity index 100% rename from kdb-web/src/app/modules/admin/settings/settings-routing.module.ts rename to web/src/app/modules/admin/settings/settings-routing.module.ts diff --git a/kdb-web/src/app/modules/admin/settings/settings.module.ts b/web/src/app/modules/admin/settings/settings.module.ts similarity index 100% rename from kdb-web/src/app/modules/admin/settings/settings.module.ts rename to web/src/app/modules/admin/settings/settings.module.ts diff --git a/kdb-web/src/app/modules/auth/auth-routing.module.ts b/web/src/app/modules/auth/auth-routing.module.ts similarity index 100% rename from kdb-web/src/app/modules/auth/auth-routing.module.ts rename to web/src/app/modules/auth/auth-routing.module.ts diff --git a/kdb-web/src/app/modules/auth/auth.module.ts b/web/src/app/modules/auth/auth.module.ts similarity index 100% rename from kdb-web/src/app/modules/auth/auth.module.ts rename to web/src/app/modules/auth/auth.module.ts diff --git a/kdb-web/src/app/modules/auth/components/auth-footer/auth-footer.component.html b/web/src/app/modules/auth/components/auth-footer/auth-footer.component.html similarity index 100% rename from kdb-web/src/app/modules/auth/components/auth-footer/auth-footer.component.html rename to web/src/app/modules/auth/components/auth-footer/auth-footer.component.html diff --git a/kdb-web/src/app/modules/auth/components/auth-footer/auth-footer.component.scss b/web/src/app/modules/auth/components/auth-footer/auth-footer.component.scss similarity index 100% rename from kdb-web/src/app/modules/auth/components/auth-footer/auth-footer.component.scss rename to web/src/app/modules/auth/components/auth-footer/auth-footer.component.scss diff --git a/kdb-web/src/app/modules/auth/components/auth-footer/auth-footer.component.spec.ts b/web/src/app/modules/auth/components/auth-footer/auth-footer.component.spec.ts similarity index 100% rename from kdb-web/src/app/modules/auth/components/auth-footer/auth-footer.component.spec.ts rename to web/src/app/modules/auth/components/auth-footer/auth-footer.component.spec.ts diff --git a/kdb-web/src/app/modules/auth/components/auth-footer/auth-footer.component.ts b/web/src/app/modules/auth/components/auth-footer/auth-footer.component.ts similarity index 100% rename from kdb-web/src/app/modules/auth/components/auth-footer/auth-footer.component.ts rename to web/src/app/modules/auth/components/auth-footer/auth-footer.component.ts diff --git a/kdb-web/src/app/modules/auth/components/auth-header/auth-header.component.html b/web/src/app/modules/auth/components/auth-header/auth-header.component.html similarity index 100% rename from kdb-web/src/app/modules/auth/components/auth-header/auth-header.component.html rename to web/src/app/modules/auth/components/auth-header/auth-header.component.html diff --git a/kdb-web/src/app/modules/auth/components/auth-header/auth-header.component.scss b/web/src/app/modules/auth/components/auth-header/auth-header.component.scss similarity index 100% rename from kdb-web/src/app/modules/auth/components/auth-header/auth-header.component.scss rename to web/src/app/modules/auth/components/auth-header/auth-header.component.scss diff --git a/kdb-web/src/app/modules/auth/components/auth-header/auth-header.component.spec.ts b/web/src/app/modules/auth/components/auth-header/auth-header.component.spec.ts similarity index 100% rename from kdb-web/src/app/modules/auth/components/auth-header/auth-header.component.spec.ts rename to web/src/app/modules/auth/components/auth-header/auth-header.component.spec.ts diff --git a/kdb-web/src/app/modules/auth/components/auth-header/auth-header.component.ts b/web/src/app/modules/auth/components/auth-header/auth-header.component.ts similarity index 100% rename from kdb-web/src/app/modules/auth/components/auth-header/auth-header.component.ts rename to web/src/app/modules/auth/components/auth-header/auth-header.component.ts diff --git a/kdb-web/src/app/modules/auth/components/forget-password/forget-password.component.html b/web/src/app/modules/auth/components/forget-password/forget-password.component.html similarity index 100% rename from kdb-web/src/app/modules/auth/components/forget-password/forget-password.component.html rename to web/src/app/modules/auth/components/forget-password/forget-password.component.html diff --git a/kdb-web/src/app/modules/auth/components/forget-password/forget-password.component.scss b/web/src/app/modules/auth/components/forget-password/forget-password.component.scss similarity index 100% rename from kdb-web/src/app/modules/auth/components/forget-password/forget-password.component.scss rename to web/src/app/modules/auth/components/forget-password/forget-password.component.scss diff --git a/kdb-web/src/app/modules/auth/components/forget-password/forget-password.component.spec.ts b/web/src/app/modules/auth/components/forget-password/forget-password.component.spec.ts similarity index 100% rename from kdb-web/src/app/modules/auth/components/forget-password/forget-password.component.spec.ts rename to web/src/app/modules/auth/components/forget-password/forget-password.component.spec.ts diff --git a/kdb-web/src/app/modules/auth/components/forget-password/forget-password.component.ts b/web/src/app/modules/auth/components/forget-password/forget-password.component.ts similarity index 100% rename from kdb-web/src/app/modules/auth/components/forget-password/forget-password.component.ts rename to web/src/app/modules/auth/components/forget-password/forget-password.component.ts diff --git a/kdb-web/src/app/modules/auth/components/login/login.component.html b/web/src/app/modules/auth/components/login/login.component.html similarity index 100% rename from kdb-web/src/app/modules/auth/components/login/login.component.html rename to web/src/app/modules/auth/components/login/login.component.html diff --git a/kdb-web/src/app/modules/auth/components/login/login.component.scss b/web/src/app/modules/auth/components/login/login.component.scss similarity index 100% rename from kdb-web/src/app/modules/auth/components/login/login.component.scss rename to web/src/app/modules/auth/components/login/login.component.scss diff --git a/kdb-web/src/app/modules/auth/components/login/login.component.spec.ts b/web/src/app/modules/auth/components/login/login.component.spec.ts similarity index 100% rename from kdb-web/src/app/modules/auth/components/login/login.component.spec.ts rename to web/src/app/modules/auth/components/login/login.component.spec.ts diff --git a/kdb-web/src/app/modules/auth/components/login/login.component.ts b/web/src/app/modules/auth/components/login/login.component.ts similarity index 100% rename from kdb-web/src/app/modules/auth/components/login/login.component.ts rename to web/src/app/modules/auth/components/login/login.component.ts diff --git a/kdb-web/src/app/modules/auth/components/registration/registration.component.html b/web/src/app/modules/auth/components/registration/registration.component.html similarity index 100% rename from kdb-web/src/app/modules/auth/components/registration/registration.component.html rename to web/src/app/modules/auth/components/registration/registration.component.html diff --git a/kdb-web/src/app/modules/auth/components/registration/registration.component.scss b/web/src/app/modules/auth/components/registration/registration.component.scss similarity index 100% rename from kdb-web/src/app/modules/auth/components/registration/registration.component.scss rename to web/src/app/modules/auth/components/registration/registration.component.scss diff --git a/kdb-web/src/app/modules/auth/components/registration/registration.component.spec.ts b/web/src/app/modules/auth/components/registration/registration.component.spec.ts similarity index 100% rename from kdb-web/src/app/modules/auth/components/registration/registration.component.spec.ts rename to web/src/app/modules/auth/components/registration/registration.component.spec.ts diff --git a/kdb-web/src/app/modules/auth/components/registration/registration.component.ts b/web/src/app/modules/auth/components/registration/registration.component.ts similarity index 100% rename from kdb-web/src/app/modules/auth/components/registration/registration.component.ts rename to web/src/app/modules/auth/components/registration/registration.component.ts diff --git a/kdb-web/src/app/modules/shared/base/hideable-component.spec.ts b/web/src/app/modules/shared/base/hideable-component.spec.ts similarity index 100% rename from kdb-web/src/app/modules/shared/base/hideable-component.spec.ts rename to web/src/app/modules/shared/base/hideable-component.spec.ts diff --git a/kdb-web/src/app/modules/shared/base/hideable-component.ts b/web/src/app/modules/shared/base/hideable-component.ts similarity index 100% rename from kdb-web/src/app/modules/shared/base/hideable-component.ts rename to web/src/app/modules/shared/base/hideable-component.ts diff --git a/kdb-web/src/app/modules/shared/base/multi-select-columns/multi-select-columns.component.html b/web/src/app/modules/shared/base/multi-select-columns/multi-select-columns.component.html similarity index 100% rename from kdb-web/src/app/modules/shared/base/multi-select-columns/multi-select-columns.component.html rename to web/src/app/modules/shared/base/multi-select-columns/multi-select-columns.component.html diff --git a/kdb-web/src/app/modules/shared/base/multi-select-columns/multi-select-columns.component.scss b/web/src/app/modules/shared/base/multi-select-columns/multi-select-columns.component.scss similarity index 100% rename from kdb-web/src/app/modules/shared/base/multi-select-columns/multi-select-columns.component.scss rename to web/src/app/modules/shared/base/multi-select-columns/multi-select-columns.component.scss diff --git a/kdb-web/src/app/modules/shared/base/multi-select-columns/multi-select-columns.component.spec.ts b/web/src/app/modules/shared/base/multi-select-columns/multi-select-columns.component.spec.ts similarity index 100% rename from kdb-web/src/app/modules/shared/base/multi-select-columns/multi-select-columns.component.spec.ts rename to web/src/app/modules/shared/base/multi-select-columns/multi-select-columns.component.spec.ts diff --git a/kdb-web/src/app/modules/shared/base/multi-select-columns/multi-select-columns.component.ts b/web/src/app/modules/shared/base/multi-select-columns/multi-select-columns.component.ts similarity index 100% rename from kdb-web/src/app/modules/shared/base/multi-select-columns/multi-select-columns.component.ts rename to web/src/app/modules/shared/base/multi-select-columns/multi-select-columns.component.ts diff --git a/kdb-web/src/app/modules/shared/components/config-list/config-list.component.html b/web/src/app/modules/shared/components/config-list/config-list.component.html similarity index 100% rename from kdb-web/src/app/modules/shared/components/config-list/config-list.component.html rename to web/src/app/modules/shared/components/config-list/config-list.component.html diff --git a/kdb-web/src/app/modules/shared/components/config-list/config-list.component.scss b/web/src/app/modules/shared/components/config-list/config-list.component.scss similarity index 100% rename from kdb-web/src/app/modules/shared/components/config-list/config-list.component.scss rename to web/src/app/modules/shared/components/config-list/config-list.component.scss diff --git a/kdb-web/src/app/modules/shared/components/config-list/config-list.component.spec.ts b/web/src/app/modules/shared/components/config-list/config-list.component.spec.ts similarity index 100% rename from kdb-web/src/app/modules/shared/components/config-list/config-list.component.spec.ts rename to web/src/app/modules/shared/components/config-list/config-list.component.spec.ts diff --git a/kdb-web/src/app/modules/shared/components/config-list/config-list.component.ts b/web/src/app/modules/shared/components/config-list/config-list.component.ts similarity index 100% rename from kdb-web/src/app/modules/shared/components/config-list/config-list.component.ts rename to web/src/app/modules/shared/components/config-list/config-list.component.ts diff --git a/kdb-web/src/app/modules/shared/components/feature-flag-list/feature-flag-list.component.html b/web/src/app/modules/shared/components/feature-flag-list/feature-flag-list.component.html similarity index 100% rename from kdb-web/src/app/modules/shared/components/feature-flag-list/feature-flag-list.component.html rename to web/src/app/modules/shared/components/feature-flag-list/feature-flag-list.component.html diff --git a/kdb-web/src/app/modules/shared/components/feature-flag-list/feature-flag-list.component.scss b/web/src/app/modules/shared/components/feature-flag-list/feature-flag-list.component.scss similarity index 100% rename from kdb-web/src/app/modules/shared/components/feature-flag-list/feature-flag-list.component.scss rename to web/src/app/modules/shared/components/feature-flag-list/feature-flag-list.component.scss diff --git a/kdb-web/src/app/modules/shared/components/feature-flag-list/feature-flag-list.component.spec.ts b/web/src/app/modules/shared/components/feature-flag-list/feature-flag-list.component.spec.ts similarity index 100% rename from kdb-web/src/app/modules/shared/components/feature-flag-list/feature-flag-list.component.spec.ts rename to web/src/app/modules/shared/components/feature-flag-list/feature-flag-list.component.spec.ts diff --git a/kdb-web/src/app/modules/shared/components/feature-flag-list/feature-flag-list.component.ts b/web/src/app/modules/shared/components/feature-flag-list/feature-flag-list.component.ts similarity index 100% rename from kdb-web/src/app/modules/shared/components/feature-flag-list/feature-flag-list.component.ts rename to web/src/app/modules/shared/components/feature-flag-list/feature-flag-list.component.ts diff --git a/kdb-web/src/app/modules/shared/components/hideable-column/hideable-column.component.html b/web/src/app/modules/shared/components/hideable-column/hideable-column.component.html similarity index 100% rename from kdb-web/src/app/modules/shared/components/hideable-column/hideable-column.component.html rename to web/src/app/modules/shared/components/hideable-column/hideable-column.component.html diff --git a/kdb-web/src/app/modules/shared/components/hideable-column/hideable-column.component.scss b/web/src/app/modules/shared/components/hideable-column/hideable-column.component.scss similarity index 100% rename from kdb-web/src/app/modules/shared/components/hideable-column/hideable-column.component.scss rename to web/src/app/modules/shared/components/hideable-column/hideable-column.component.scss diff --git a/kdb-web/src/app/modules/shared/components/hideable-column/hideable-column.component.spec.ts b/web/src/app/modules/shared/components/hideable-column/hideable-column.component.spec.ts similarity index 100% rename from kdb-web/src/app/modules/shared/components/hideable-column/hideable-column.component.spec.ts rename to web/src/app/modules/shared/components/hideable-column/hideable-column.component.spec.ts diff --git a/kdb-web/src/app/modules/shared/components/hideable-column/hideable-column.component.ts b/web/src/app/modules/shared/components/hideable-column/hideable-column.component.ts similarity index 100% rename from kdb-web/src/app/modules/shared/components/hideable-column/hideable-column.component.ts rename to web/src/app/modules/shared/components/hideable-column/hideable-column.component.ts diff --git a/kdb-web/src/app/modules/shared/components/hideable-header/hideable-header.component.html b/web/src/app/modules/shared/components/hideable-header/hideable-header.component.html similarity index 100% rename from kdb-web/src/app/modules/shared/components/hideable-header/hideable-header.component.html rename to web/src/app/modules/shared/components/hideable-header/hideable-header.component.html diff --git a/kdb-web/src/app/modules/shared/components/hideable-header/hideable-header.component.scss b/web/src/app/modules/shared/components/hideable-header/hideable-header.component.scss similarity index 100% rename from kdb-web/src/app/modules/shared/components/hideable-header/hideable-header.component.scss rename to web/src/app/modules/shared/components/hideable-header/hideable-header.component.scss diff --git a/kdb-web/src/app/modules/shared/components/hideable-header/hideable-header.component.spec.ts b/web/src/app/modules/shared/components/hideable-header/hideable-header.component.spec.ts similarity index 100% rename from kdb-web/src/app/modules/shared/components/hideable-header/hideable-header.component.spec.ts rename to web/src/app/modules/shared/components/hideable-header/hideable-header.component.spec.ts diff --git a/kdb-web/src/app/modules/shared/components/hideable-header/hideable-header.component.ts b/web/src/app/modules/shared/components/hideable-header/hideable-header.component.ts similarity index 100% rename from kdb-web/src/app/modules/shared/components/hideable-header/hideable-header.component.ts rename to web/src/app/modules/shared/components/hideable-header/hideable-header.component.ts diff --git a/kdb-web/src/app/modules/shared/components/history-btn/history-btn.component.html b/web/src/app/modules/shared/components/history-btn/history-btn.component.html similarity index 100% rename from kdb-web/src/app/modules/shared/components/history-btn/history-btn.component.html rename to web/src/app/modules/shared/components/history-btn/history-btn.component.html diff --git a/kdb-web/src/app/modules/shared/components/history-btn/history-btn.component.scss b/web/src/app/modules/shared/components/history-btn/history-btn.component.scss similarity index 100% rename from kdb-web/src/app/modules/shared/components/history-btn/history-btn.component.scss rename to web/src/app/modules/shared/components/history-btn/history-btn.component.scss diff --git a/kdb-web/src/app/modules/shared/components/history-btn/history-btn.component.spec.ts b/web/src/app/modules/shared/components/history-btn/history-btn.component.spec.ts similarity index 100% rename from kdb-web/src/app/modules/shared/components/history-btn/history-btn.component.spec.ts rename to web/src/app/modules/shared/components/history-btn/history-btn.component.spec.ts diff --git a/kdb-web/src/app/modules/shared/components/history-btn/history-btn.component.ts b/web/src/app/modules/shared/components/history-btn/history-btn.component.ts similarity index 100% rename from kdb-web/src/app/modules/shared/components/history-btn/history-btn.component.ts rename to web/src/app/modules/shared/components/history-btn/history-btn.component.ts diff --git a/kdb-web/src/app/modules/shared/guards/auth/auth.guard.spec.ts b/web/src/app/modules/shared/guards/auth/auth.guard.spec.ts similarity index 100% rename from kdb-web/src/app/modules/shared/guards/auth/auth.guard.spec.ts rename to web/src/app/modules/shared/guards/auth/auth.guard.spec.ts diff --git a/kdb-web/src/app/modules/shared/guards/auth/auth.guard.ts b/web/src/app/modules/shared/guards/auth/auth.guard.ts similarity index 100% rename from kdb-web/src/app/modules/shared/guards/auth/auth.guard.ts rename to web/src/app/modules/shared/guards/auth/auth.guard.ts diff --git a/kdb-web/src/app/modules/shared/pipes/auth-role.pipe.ts b/web/src/app/modules/shared/pipes/auth-role.pipe.ts similarity index 100% rename from kdb-web/src/app/modules/shared/pipes/auth-role.pipe.ts rename to web/src/app/modules/shared/pipes/auth-role.pipe.ts diff --git a/kdb-web/src/app/modules/shared/pipes/bool.pipe.spec.ts b/web/src/app/modules/shared/pipes/bool.pipe.spec.ts similarity index 100% rename from kdb-web/src/app/modules/shared/pipes/bool.pipe.spec.ts rename to web/src/app/modules/shared/pipes/bool.pipe.spec.ts diff --git a/kdb-web/src/app/modules/shared/pipes/bool.pipe.ts b/web/src/app/modules/shared/pipes/bool.pipe.ts similarity index 100% rename from kdb-web/src/app/modules/shared/pipes/bool.pipe.ts rename to web/src/app/modules/shared/pipes/bool.pipe.ts diff --git a/kdb-web/src/app/modules/shared/pipes/ip-address.pipe.ts b/web/src/app/modules/shared/pipes/ip-address.pipe.ts similarity index 100% rename from kdb-web/src/app/modules/shared/pipes/ip-address.pipe.ts rename to web/src/app/modules/shared/pipes/ip-address.pipe.ts diff --git a/kdb-web/src/app/modules/shared/shared.module.ts b/web/src/app/modules/shared/shared.module.ts similarity index 100% rename from kdb-web/src/app/modules/shared/shared.module.ts rename to web/src/app/modules/shared/shared.module.ts diff --git a/kdb-web/src/app/modules/view/change-password/change-password-routing.module.ts b/web/src/app/modules/view/change-password/change-password-routing.module.ts similarity index 100% rename from kdb-web/src/app/modules/view/change-password/change-password-routing.module.ts rename to web/src/app/modules/view/change-password/change-password-routing.module.ts diff --git a/kdb-web/src/app/modules/view/change-password/change-password.module.ts b/web/src/app/modules/view/change-password/change-password.module.ts similarity index 100% rename from kdb-web/src/app/modules/view/change-password/change-password.module.ts rename to web/src/app/modules/view/change-password/change-password.module.ts diff --git a/kdb-web/src/app/modules/view/change-password/components/change-password/change-password.component.html b/web/src/app/modules/view/change-password/components/change-password/change-password.component.html similarity index 100% rename from kdb-web/src/app/modules/view/change-password/components/change-password/change-password.component.html rename to web/src/app/modules/view/change-password/components/change-password/change-password.component.html diff --git a/kdb-web/src/app/modules/view/change-password/components/change-password/change-password.component.scss b/web/src/app/modules/view/change-password/components/change-password/change-password.component.scss similarity index 100% rename from kdb-web/src/app/modules/view/change-password/components/change-password/change-password.component.scss rename to web/src/app/modules/view/change-password/components/change-password/change-password.component.scss diff --git a/kdb-web/src/app/modules/view/change-password/components/change-password/change-password.component.spec.ts b/web/src/app/modules/view/change-password/components/change-password/change-password.component.spec.ts similarity index 100% rename from kdb-web/src/app/modules/view/change-password/components/change-password/change-password.component.spec.ts rename to web/src/app/modules/view/change-password/components/change-password/change-password.component.spec.ts diff --git a/kdb-web/src/app/modules/view/change-password/components/change-password/change-password.component.ts b/web/src/app/modules/view/change-password/components/change-password/change-password.component.ts similarity index 100% rename from kdb-web/src/app/modules/view/change-password/components/change-password/change-password.component.ts rename to web/src/app/modules/view/change-password/components/change-password/change-password.component.ts diff --git a/kdb-web/src/app/modules/view/dashboard/components/dashboard/dashboard.component.html b/web/src/app/modules/view/dashboard/components/dashboard/dashboard.component.html similarity index 100% rename from kdb-web/src/app/modules/view/dashboard/components/dashboard/dashboard.component.html rename to web/src/app/modules/view/dashboard/components/dashboard/dashboard.component.html diff --git a/kdb-web/src/app/modules/view/dashboard/components/dashboard/dashboard.component.scss b/web/src/app/modules/view/dashboard/components/dashboard/dashboard.component.scss similarity index 100% rename from kdb-web/src/app/modules/view/dashboard/components/dashboard/dashboard.component.scss rename to web/src/app/modules/view/dashboard/components/dashboard/dashboard.component.scss diff --git a/kdb-web/src/app/modules/view/dashboard/components/dashboard/dashboard.component.spec.ts b/web/src/app/modules/view/dashboard/components/dashboard/dashboard.component.spec.ts similarity index 100% rename from kdb-web/src/app/modules/view/dashboard/components/dashboard/dashboard.component.spec.ts rename to web/src/app/modules/view/dashboard/components/dashboard/dashboard.component.spec.ts diff --git a/kdb-web/src/app/modules/view/dashboard/components/dashboard/dashboard.component.ts b/web/src/app/modules/view/dashboard/components/dashboard/dashboard.component.ts similarity index 100% rename from kdb-web/src/app/modules/view/dashboard/components/dashboard/dashboard.component.ts rename to web/src/app/modules/view/dashboard/components/dashboard/dashboard.component.ts diff --git a/kdb-web/src/app/modules/view/dashboard/dashboard-routing.module.ts b/web/src/app/modules/view/dashboard/dashboard-routing.module.ts similarity index 100% rename from kdb-web/src/app/modules/view/dashboard/dashboard-routing.module.ts rename to web/src/app/modules/view/dashboard/dashboard-routing.module.ts diff --git a/kdb-web/src/app/modules/view/dashboard/dashboard.module.ts b/web/src/app/modules/view/dashboard/dashboard.module.ts similarity index 100% rename from kdb-web/src/app/modules/view/dashboard/dashboard.module.ts rename to web/src/app/modules/view/dashboard/dashboard.module.ts diff --git a/kdb-web/src/app/modules/view/server/achievements/achievements-routing.module.ts b/web/src/app/modules/view/server/achievements/achievements-routing.module.ts similarity index 100% rename from kdb-web/src/app/modules/view/server/achievements/achievements-routing.module.ts rename to web/src/app/modules/view/server/achievements/achievements-routing.module.ts diff --git a/kdb-web/src/app/modules/view/server/achievements/achievements.module.ts b/web/src/app/modules/view/server/achievements/achievements.module.ts similarity index 100% rename from kdb-web/src/app/modules/view/server/achievements/achievements.module.ts rename to web/src/app/modules/view/server/achievements/achievements.module.ts diff --git a/kdb-web/src/app/modules/view/server/achievements/components/achievement/achievement.component.html b/web/src/app/modules/view/server/achievements/components/achievement/achievement.component.html similarity index 100% rename from kdb-web/src/app/modules/view/server/achievements/components/achievement/achievement.component.html rename to web/src/app/modules/view/server/achievements/components/achievement/achievement.component.html diff --git a/kdb-web/src/app/modules/view/server/achievements/components/achievement/achievement.component.scss b/web/src/app/modules/view/server/achievements/components/achievement/achievement.component.scss similarity index 100% rename from kdb-web/src/app/modules/view/server/achievements/components/achievement/achievement.component.scss rename to web/src/app/modules/view/server/achievements/components/achievement/achievement.component.scss diff --git a/kdb-web/src/app/modules/view/server/achievements/components/achievement/achievement.component.spec.ts b/web/src/app/modules/view/server/achievements/components/achievement/achievement.component.spec.ts similarity index 100% rename from kdb-web/src/app/modules/view/server/achievements/components/achievement/achievement.component.spec.ts rename to web/src/app/modules/view/server/achievements/components/achievement/achievement.component.spec.ts diff --git a/kdb-web/src/app/modules/view/server/achievements/components/achievement/achievement.component.ts b/web/src/app/modules/view/server/achievements/components/achievement/achievement.component.ts similarity index 100% rename from kdb-web/src/app/modules/view/server/achievements/components/achievement/achievement.component.ts rename to web/src/app/modules/view/server/achievements/components/achievement/achievement.component.ts diff --git a/kdb-web/src/app/modules/view/server/auto-role/auto-role-routing.module.ts b/web/src/app/modules/view/server/auto-role/auto-role-routing.module.ts similarity index 100% rename from kdb-web/src/app/modules/view/server/auto-role/auto-role-routing.module.ts rename to web/src/app/modules/view/server/auto-role/auto-role-routing.module.ts diff --git a/kdb-web/src/app/modules/view/server/auto-role/auto-role.module.ts b/web/src/app/modules/view/server/auto-role/auto-role.module.ts similarity index 100% rename from kdb-web/src/app/modules/view/server/auto-role/auto-role.module.ts rename to web/src/app/modules/view/server/auto-role/auto-role.module.ts diff --git a/kdb-web/src/app/modules/view/server/auto-role/components/auto-roles-rules/auto-roles-rules.component.html b/web/src/app/modules/view/server/auto-role/components/auto-roles-rules/auto-roles-rules.component.html similarity index 100% rename from kdb-web/src/app/modules/view/server/auto-role/components/auto-roles-rules/auto-roles-rules.component.html rename to web/src/app/modules/view/server/auto-role/components/auto-roles-rules/auto-roles-rules.component.html diff --git a/kdb-web/src/app/modules/view/server/auto-role/components/auto-roles-rules/auto-roles-rules.component.scss b/web/src/app/modules/view/server/auto-role/components/auto-roles-rules/auto-roles-rules.component.scss similarity index 100% rename from kdb-web/src/app/modules/view/server/auto-role/components/auto-roles-rules/auto-roles-rules.component.scss rename to web/src/app/modules/view/server/auto-role/components/auto-roles-rules/auto-roles-rules.component.scss diff --git a/kdb-web/src/app/modules/view/server/auto-role/components/auto-roles-rules/auto-roles-rules.component.spec.ts b/web/src/app/modules/view/server/auto-role/components/auto-roles-rules/auto-roles-rules.component.spec.ts similarity index 100% rename from kdb-web/src/app/modules/view/server/auto-role/components/auto-roles-rules/auto-roles-rules.component.spec.ts rename to web/src/app/modules/view/server/auto-role/components/auto-roles-rules/auto-roles-rules.component.spec.ts diff --git a/kdb-web/src/app/modules/view/server/auto-role/components/auto-roles-rules/auto-roles-rules.component.ts b/web/src/app/modules/view/server/auto-role/components/auto-roles-rules/auto-roles-rules.component.ts similarity index 100% rename from kdb-web/src/app/modules/view/server/auto-role/components/auto-roles-rules/auto-roles-rules.component.ts rename to web/src/app/modules/view/server/auto-role/components/auto-roles-rules/auto-roles-rules.component.ts diff --git a/kdb-web/src/app/modules/view/server/auto-role/components/auto-roles/auto-roles.component.html b/web/src/app/modules/view/server/auto-role/components/auto-roles/auto-roles.component.html similarity index 100% rename from kdb-web/src/app/modules/view/server/auto-role/components/auto-roles/auto-roles.component.html rename to web/src/app/modules/view/server/auto-role/components/auto-roles/auto-roles.component.html diff --git a/kdb-web/src/app/modules/view/server/auto-role/components/auto-roles/auto-roles.component.scss b/web/src/app/modules/view/server/auto-role/components/auto-roles/auto-roles.component.scss similarity index 100% rename from kdb-web/src/app/modules/view/server/auto-role/components/auto-roles/auto-roles.component.scss rename to web/src/app/modules/view/server/auto-role/components/auto-roles/auto-roles.component.scss diff --git a/kdb-web/src/app/modules/view/server/auto-role/components/auto-roles/auto-roles.component.spec.ts b/web/src/app/modules/view/server/auto-role/components/auto-roles/auto-roles.component.spec.ts similarity index 100% rename from kdb-web/src/app/modules/view/server/auto-role/components/auto-roles/auto-roles.component.spec.ts rename to web/src/app/modules/view/server/auto-role/components/auto-roles/auto-roles.component.spec.ts diff --git a/kdb-web/src/app/modules/view/server/auto-role/components/auto-roles/auto-roles.component.ts b/web/src/app/modules/view/server/auto-role/components/auto-roles/auto-roles.component.ts similarity index 100% rename from kdb-web/src/app/modules/view/server/auto-role/components/auto-roles/auto-roles.component.ts rename to web/src/app/modules/view/server/auto-role/components/auto-roles/auto-roles.component.ts diff --git a/kdb-web/src/app/modules/view/server/config/components/config/config.component.html b/web/src/app/modules/view/server/config/components/config/config.component.html similarity index 100% rename from kdb-web/src/app/modules/view/server/config/components/config/config.component.html rename to web/src/app/modules/view/server/config/components/config/config.component.html diff --git a/kdb-web/src/app/modules/view/server/config/components/config/config.component.scss b/web/src/app/modules/view/server/config/components/config/config.component.scss similarity index 100% rename from kdb-web/src/app/modules/view/server/config/components/config/config.component.scss rename to web/src/app/modules/view/server/config/components/config/config.component.scss diff --git a/kdb-web/src/app/modules/view/server/config/components/config/config.component.spec.ts b/web/src/app/modules/view/server/config/components/config/config.component.spec.ts similarity index 100% rename from kdb-web/src/app/modules/view/server/config/components/config/config.component.spec.ts rename to web/src/app/modules/view/server/config/components/config/config.component.spec.ts diff --git a/kdb-web/src/app/modules/view/server/config/components/config/config.component.ts b/web/src/app/modules/view/server/config/components/config/config.component.ts similarity index 100% rename from kdb-web/src/app/modules/view/server/config/components/config/config.component.ts rename to web/src/app/modules/view/server/config/components/config/config.component.ts diff --git a/kdb-web/src/app/modules/view/server/config/config-routing.module.ts b/web/src/app/modules/view/server/config/config-routing.module.ts similarity index 100% rename from kdb-web/src/app/modules/view/server/config/config-routing.module.ts rename to web/src/app/modules/view/server/config/config-routing.module.ts diff --git a/kdb-web/src/app/modules/view/server/config/config.module.ts b/web/src/app/modules/view/server/config/config.module.ts similarity index 100% rename from kdb-web/src/app/modules/view/server/config/config.module.ts rename to web/src/app/modules/view/server/config/config.module.ts diff --git a/kdb-web/src/app/modules/view/server/levels/components/levels/levels.component.html b/web/src/app/modules/view/server/levels/components/levels/levels.component.html similarity index 100% rename from kdb-web/src/app/modules/view/server/levels/components/levels/levels.component.html rename to web/src/app/modules/view/server/levels/components/levels/levels.component.html diff --git a/kdb-web/src/app/modules/view/server/levels/components/levels/levels.component.scss b/web/src/app/modules/view/server/levels/components/levels/levels.component.scss similarity index 100% rename from kdb-web/src/app/modules/view/server/levels/components/levels/levels.component.scss rename to web/src/app/modules/view/server/levels/components/levels/levels.component.scss diff --git a/kdb-web/src/app/modules/view/server/levels/components/levels/levels.component.spec.ts b/web/src/app/modules/view/server/levels/components/levels/levels.component.spec.ts similarity index 100% rename from kdb-web/src/app/modules/view/server/levels/components/levels/levels.component.spec.ts rename to web/src/app/modules/view/server/levels/components/levels/levels.component.spec.ts diff --git a/kdb-web/src/app/modules/view/server/levels/components/levels/levels.component.ts b/web/src/app/modules/view/server/levels/components/levels/levels.component.ts similarity index 100% rename from kdb-web/src/app/modules/view/server/levels/components/levels/levels.component.ts rename to web/src/app/modules/view/server/levels/components/levels/levels.component.ts diff --git a/kdb-web/src/app/modules/view/server/levels/levels-routing.module.ts b/web/src/app/modules/view/server/levels/levels-routing.module.ts similarity index 100% rename from kdb-web/src/app/modules/view/server/levels/levels-routing.module.ts rename to web/src/app/modules/view/server/levels/levels-routing.module.ts diff --git a/kdb-web/src/app/modules/view/server/levels/levels.module.ts b/web/src/app/modules/view/server/levels/levels.module.ts similarity index 100% rename from kdb-web/src/app/modules/view/server/levels/levels.module.ts rename to web/src/app/modules/view/server/levels/levels.module.ts diff --git a/kdb-web/src/app/modules/view/server/members/members.component.html b/web/src/app/modules/view/server/members/members.component.html similarity index 100% rename from kdb-web/src/app/modules/view/server/members/members.component.html rename to web/src/app/modules/view/server/members/members.component.html diff --git a/kdb-web/src/app/modules/view/server/members/members.component.scss b/web/src/app/modules/view/server/members/members.component.scss similarity index 100% rename from kdb-web/src/app/modules/view/server/members/members.component.scss rename to web/src/app/modules/view/server/members/members.component.scss diff --git a/kdb-web/src/app/modules/view/server/members/members.component.spec.ts b/web/src/app/modules/view/server/members/members.component.spec.ts similarity index 100% rename from kdb-web/src/app/modules/view/server/members/members.component.spec.ts rename to web/src/app/modules/view/server/members/members.component.spec.ts diff --git a/kdb-web/src/app/modules/view/server/members/members.component.ts b/web/src/app/modules/view/server/members/members.component.ts similarity index 100% rename from kdb-web/src/app/modules/view/server/members/members.component.ts rename to web/src/app/modules/view/server/members/members.component.ts diff --git a/kdb-web/src/app/modules/view/server/profile/profile.component.html b/web/src/app/modules/view/server/profile/profile.component.html similarity index 100% rename from kdb-web/src/app/modules/view/server/profile/profile.component.html rename to web/src/app/modules/view/server/profile/profile.component.html diff --git a/kdb-web/src/app/modules/view/server/profile/profile.component.scss b/web/src/app/modules/view/server/profile/profile.component.scss similarity index 100% rename from kdb-web/src/app/modules/view/server/profile/profile.component.scss rename to web/src/app/modules/view/server/profile/profile.component.scss diff --git a/kdb-web/src/app/modules/view/server/profile/profile.component.spec.ts b/web/src/app/modules/view/server/profile/profile.component.spec.ts similarity index 100% rename from kdb-web/src/app/modules/view/server/profile/profile.component.spec.ts rename to web/src/app/modules/view/server/profile/profile.component.spec.ts diff --git a/kdb-web/src/app/modules/view/server/profile/profile.component.ts b/web/src/app/modules/view/server/profile/profile.component.ts similarity index 100% rename from kdb-web/src/app/modules/view/server/profile/profile.component.ts rename to web/src/app/modules/view/server/profile/profile.component.ts diff --git a/kdb-web/src/app/modules/view/server/server-dashboard/components/client/client.component.html b/web/src/app/modules/view/server/server-dashboard/components/client/client.component.html similarity index 100% rename from kdb-web/src/app/modules/view/server/server-dashboard/components/client/client.component.html rename to web/src/app/modules/view/server/server-dashboard/components/client/client.component.html diff --git a/kdb-web/src/app/modules/view/server/server-dashboard/components/client/client.component.scss b/web/src/app/modules/view/server/server-dashboard/components/client/client.component.scss similarity index 100% rename from kdb-web/src/app/modules/view/server/server-dashboard/components/client/client.component.scss rename to web/src/app/modules/view/server/server-dashboard/components/client/client.component.scss diff --git a/kdb-web/src/app/modules/view/server/server-dashboard/components/client/client.component.spec.ts b/web/src/app/modules/view/server/server-dashboard/components/client/client.component.spec.ts similarity index 100% rename from kdb-web/src/app/modules/view/server/server-dashboard/components/client/client.component.spec.ts rename to web/src/app/modules/view/server/server-dashboard/components/client/client.component.spec.ts diff --git a/kdb-web/src/app/modules/view/server/server-dashboard/components/client/client.component.ts b/web/src/app/modules/view/server/server-dashboard/components/client/client.component.ts similarity index 100% rename from kdb-web/src/app/modules/view/server/server-dashboard/components/client/client.component.ts rename to web/src/app/modules/view/server/server-dashboard/components/client/client.component.ts diff --git a/kdb-web/src/app/modules/view/server/server-dashboard/server-dashboard.component.html b/web/src/app/modules/view/server/server-dashboard/server-dashboard.component.html similarity index 100% rename from kdb-web/src/app/modules/view/server/server-dashboard/server-dashboard.component.html rename to web/src/app/modules/view/server/server-dashboard/server-dashboard.component.html diff --git a/kdb-web/src/app/modules/view/server/server-dashboard/server-dashboard.component.scss b/web/src/app/modules/view/server/server-dashboard/server-dashboard.component.scss similarity index 100% rename from kdb-web/src/app/modules/view/server/server-dashboard/server-dashboard.component.scss rename to web/src/app/modules/view/server/server-dashboard/server-dashboard.component.scss diff --git a/kdb-web/src/app/modules/view/server/server-dashboard/server-dashboard.component.spec.ts b/web/src/app/modules/view/server/server-dashboard/server-dashboard.component.spec.ts similarity index 100% rename from kdb-web/src/app/modules/view/server/server-dashboard/server-dashboard.component.spec.ts rename to web/src/app/modules/view/server/server-dashboard/server-dashboard.component.spec.ts diff --git a/kdb-web/src/app/modules/view/server/server-dashboard/server-dashboard.component.ts b/web/src/app/modules/view/server/server-dashboard/server-dashboard.component.ts similarity index 100% rename from kdb-web/src/app/modules/view/server/server-dashboard/server-dashboard.component.ts rename to web/src/app/modules/view/server/server-dashboard/server-dashboard.component.ts diff --git a/kdb-web/src/app/modules/view/server/server-routing.module.ts b/web/src/app/modules/view/server/server-routing.module.ts similarity index 100% rename from kdb-web/src/app/modules/view/server/server-routing.module.ts rename to web/src/app/modules/view/server/server-routing.module.ts diff --git a/kdb-web/src/app/modules/view/server/server.module.ts b/web/src/app/modules/view/server/server.module.ts similarity index 100% rename from kdb-web/src/app/modules/view/server/server.module.ts rename to web/src/app/modules/view/server/server.module.ts diff --git a/kdb-web/src/app/modules/view/server/short-role-name/components/short-role-names/short-role-names.component.html b/web/src/app/modules/view/server/short-role-name/components/short-role-names/short-role-names.component.html similarity index 100% rename from kdb-web/src/app/modules/view/server/short-role-name/components/short-role-names/short-role-names.component.html rename to web/src/app/modules/view/server/short-role-name/components/short-role-names/short-role-names.component.html diff --git a/kdb-web/src/app/modules/view/server/short-role-name/components/short-role-names/short-role-names.component.scss b/web/src/app/modules/view/server/short-role-name/components/short-role-names/short-role-names.component.scss similarity index 100% rename from kdb-web/src/app/modules/view/server/short-role-name/components/short-role-names/short-role-names.component.scss rename to web/src/app/modules/view/server/short-role-name/components/short-role-names/short-role-names.component.scss diff --git a/kdb-web/src/app/modules/view/server/short-role-name/components/short-role-names/short-role-names.component.spec.ts b/web/src/app/modules/view/server/short-role-name/components/short-role-names/short-role-names.component.spec.ts similarity index 100% rename from kdb-web/src/app/modules/view/server/short-role-name/components/short-role-names/short-role-names.component.spec.ts rename to web/src/app/modules/view/server/short-role-name/components/short-role-names/short-role-names.component.spec.ts diff --git a/kdb-web/src/app/modules/view/server/short-role-name/components/short-role-names/short-role-names.component.ts b/web/src/app/modules/view/server/short-role-name/components/short-role-names/short-role-names.component.ts similarity index 100% rename from kdb-web/src/app/modules/view/server/short-role-name/components/short-role-names/short-role-names.component.ts rename to web/src/app/modules/view/server/short-role-name/components/short-role-names/short-role-names.component.ts diff --git a/kdb-web/src/app/modules/view/server/short-role-name/short-role-name-routing.module.ts b/web/src/app/modules/view/server/short-role-name/short-role-name-routing.module.ts similarity index 100% rename from kdb-web/src/app/modules/view/server/short-role-name/short-role-name-routing.module.ts rename to web/src/app/modules/view/server/short-role-name/short-role-name-routing.module.ts diff --git a/kdb-web/src/app/modules/view/server/short-role-name/short-role-name.module.ts b/web/src/app/modules/view/server/short-role-name/short-role-name.module.ts similarity index 100% rename from kdb-web/src/app/modules/view/server/short-role-name/short-role-name.module.ts rename to web/src/app/modules/view/server/short-role-name/short-role-name.module.ts diff --git a/kdb-web/src/app/modules/view/user-settings/components/user-settings/user-settings.component.html b/web/src/app/modules/view/user-settings/components/user-settings/user-settings.component.html similarity index 100% rename from kdb-web/src/app/modules/view/user-settings/components/user-settings/user-settings.component.html rename to web/src/app/modules/view/user-settings/components/user-settings/user-settings.component.html diff --git a/kdb-web/src/app/modules/view/user-settings/components/user-settings/user-settings.component.scss b/web/src/app/modules/view/user-settings/components/user-settings/user-settings.component.scss similarity index 100% rename from kdb-web/src/app/modules/view/user-settings/components/user-settings/user-settings.component.scss rename to web/src/app/modules/view/user-settings/components/user-settings/user-settings.component.scss diff --git a/kdb-web/src/app/modules/view/user-settings/components/user-settings/user-settings.component.spec.ts b/web/src/app/modules/view/user-settings/components/user-settings/user-settings.component.spec.ts similarity index 100% rename from kdb-web/src/app/modules/view/user-settings/components/user-settings/user-settings.component.spec.ts rename to web/src/app/modules/view/user-settings/components/user-settings/user-settings.component.spec.ts diff --git a/kdb-web/src/app/modules/view/user-settings/components/user-settings/user-settings.component.ts b/web/src/app/modules/view/user-settings/components/user-settings/user-settings.component.ts similarity index 100% rename from kdb-web/src/app/modules/view/user-settings/components/user-settings/user-settings.component.ts rename to web/src/app/modules/view/user-settings/components/user-settings/user-settings.component.ts diff --git a/kdb-web/src/app/modules/view/user-settings/user-settings-routing.module.ts b/web/src/app/modules/view/user-settings/user-settings-routing.module.ts similarity index 100% rename from kdb-web/src/app/modules/view/user-settings/user-settings-routing.module.ts rename to web/src/app/modules/view/user-settings/user-settings-routing.module.ts diff --git a/kdb-web/src/app/modules/view/user-settings/user-settings.module.ts b/web/src/app/modules/view/user-settings/user-settings.module.ts similarity index 100% rename from kdb-web/src/app/modules/view/user-settings/user-settings.module.ts rename to web/src/app/modules/view/user-settings/user-settings.module.ts diff --git a/kdb-web/src/app/services/auth/auth.service.spec.ts b/web/src/app/services/auth/auth.service.spec.ts similarity index 100% rename from kdb-web/src/app/services/auth/auth.service.spec.ts rename to web/src/app/services/auth/auth.service.spec.ts diff --git a/kdb-web/src/app/services/auth/auth.service.ts b/web/src/app/services/auth/auth.service.ts similarity index 100% rename from kdb-web/src/app/services/auth/auth.service.ts rename to web/src/app/services/auth/auth.service.ts diff --git a/kdb-web/src/app/services/confirmation-dialog/confirmation-dialog.service.spec.ts b/web/src/app/services/confirmation-dialog/confirmation-dialog.service.spec.ts similarity index 100% rename from kdb-web/src/app/services/confirmation-dialog/confirmation-dialog.service.spec.ts rename to web/src/app/services/confirmation-dialog/confirmation-dialog.service.spec.ts diff --git a/kdb-web/src/app/services/confirmation-dialog/confirmation-dialog.service.ts b/web/src/app/services/confirmation-dialog/confirmation-dialog.service.ts similarity index 100% rename from kdb-web/src/app/services/confirmation-dialog/confirmation-dialog.service.ts rename to web/src/app/services/confirmation-dialog/confirmation-dialog.service.ts diff --git a/kdb-web/src/app/services/data/data.service.spec.ts b/web/src/app/services/data/data.service.spec.ts similarity index 100% rename from kdb-web/src/app/services/data/data.service.spec.ts rename to web/src/app/services/data/data.service.spec.ts diff --git a/kdb-web/src/app/services/data/data.service.ts b/web/src/app/services/data/data.service.ts similarity index 100% rename from kdb-web/src/app/services/data/data.service.ts rename to web/src/app/services/data/data.service.ts diff --git a/kdb-web/src/app/services/error-handler/error-handler.service.spec.ts b/web/src/app/services/error-handler/error-handler.service.spec.ts similarity index 100% rename from kdb-web/src/app/services/error-handler/error-handler.service.spec.ts rename to web/src/app/services/error-handler/error-handler.service.spec.ts diff --git a/kdb-web/src/app/services/error-handler/error-handler.service.ts b/web/src/app/services/error-handler/error-handler.service.ts similarity index 100% rename from kdb-web/src/app/services/error-handler/error-handler.service.ts rename to web/src/app/services/error-handler/error-handler.service.ts diff --git a/kdb-web/src/app/services/gui/gui.service.spec.ts b/web/src/app/services/gui/gui.service.spec.ts similarity index 100% rename from kdb-web/src/app/services/gui/gui.service.spec.ts rename to web/src/app/services/gui/gui.service.spec.ts diff --git a/kdb-web/src/app/services/gui/gui.service.ts b/web/src/app/services/gui/gui.service.ts similarity index 100% rename from kdb-web/src/app/services/gui/gui.service.ts rename to web/src/app/services/gui/gui.service.ts diff --git a/kdb-web/src/app/services/server.service.spec.ts b/web/src/app/services/server.service.spec.ts similarity index 100% rename from kdb-web/src/app/services/server.service.spec.ts rename to web/src/app/services/server.service.spec.ts diff --git a/kdb-web/src/app/services/server.service.ts b/web/src/app/services/server.service.ts similarity index 100% rename from kdb-web/src/app/services/server.service.ts rename to web/src/app/services/server.service.ts diff --git a/kdb-web/src/app/services/settings/settings.service.spec.ts b/web/src/app/services/settings/settings.service.spec.ts similarity index 100% rename from kdb-web/src/app/services/settings/settings.service.spec.ts rename to web/src/app/services/settings/settings.service.spec.ts diff --git a/kdb-web/src/app/services/settings/settings.service.ts b/web/src/app/services/settings/settings.service.ts similarity index 100% rename from kdb-web/src/app/services/settings/settings.service.ts rename to web/src/app/services/settings/settings.service.ts diff --git a/kdb-web/src/app/services/sidebar/sidebar.service.spec.ts b/web/src/app/services/sidebar/sidebar.service.spec.ts similarity index 100% rename from kdb-web/src/app/services/sidebar/sidebar.service.spec.ts rename to web/src/app/services/sidebar/sidebar.service.spec.ts diff --git a/kdb-web/src/app/services/sidebar/sidebar.service.ts b/web/src/app/services/sidebar/sidebar.service.ts similarity index 100% rename from kdb-web/src/app/services/sidebar/sidebar.service.ts rename to web/src/app/services/sidebar/sidebar.service.ts diff --git a/kdb-web/src/app/services/socket/socket.service.spec.ts b/web/src/app/services/socket/socket.service.spec.ts similarity index 100% rename from kdb-web/src/app/services/socket/socket.service.spec.ts rename to web/src/app/services/socket/socket.service.spec.ts diff --git a/kdb-web/src/app/services/socket/socket.service.ts b/web/src/app/services/socket/socket.service.ts similarity index 100% rename from kdb-web/src/app/services/socket/socket.service.ts rename to web/src/app/services/socket/socket.service.ts diff --git a/kdb-web/src/app/services/spinner/spinner.service.spec.ts b/web/src/app/services/spinner/spinner.service.spec.ts similarity index 100% rename from kdb-web/src/app/services/spinner/spinner.service.spec.ts rename to web/src/app/services/spinner/spinner.service.spec.ts diff --git a/kdb-web/src/app/services/spinner/spinner.service.ts b/web/src/app/services/spinner/spinner.service.ts similarity index 100% rename from kdb-web/src/app/services/spinner/spinner.service.ts rename to web/src/app/services/spinner/spinner.service.ts diff --git a/kdb-web/src/app/services/theme/theme.service.spec.ts b/web/src/app/services/theme/theme.service.spec.ts similarity index 100% rename from kdb-web/src/app/services/theme/theme.service.spec.ts rename to web/src/app/services/theme/theme.service.spec.ts diff --git a/kdb-web/src/app/services/theme/theme.service.ts b/web/src/app/services/theme/theme.service.ts similarity index 100% rename from kdb-web/src/app/services/theme/theme.service.ts rename to web/src/app/services/theme/theme.service.ts diff --git a/kdb-web/src/app/services/toast/toast.service.spec.ts b/web/src/app/services/toast/toast.service.spec.ts similarity index 100% rename from kdb-web/src/app/services/toast/toast.service.spec.ts rename to web/src/app/services/toast/toast.service.spec.ts diff --git a/kdb-web/src/app/services/toast/toast.service.ts b/web/src/app/services/toast/toast.service.ts similarity index 100% rename from kdb-web/src/app/services/toast/toast.service.ts rename to web/src/app/services/toast/toast.service.ts diff --git a/kdb-web/src/assets/config.json b/web/src/assets/config.json similarity index 100% rename from kdb-web/src/assets/config.json rename to web/src/assets/config.json diff --git a/kdb-web/src/assets/i18n/de.json b/web/src/assets/i18n/de.json similarity index 100% rename from kdb-web/src/assets/i18n/de.json rename to web/src/assets/i18n/de.json diff --git a/kdb-web/src/assets/i18n/en.json b/web/src/assets/i18n/en.json similarity index 100% rename from kdb-web/src/assets/i18n/en.json rename to web/src/assets/i18n/en.json diff --git a/kdb-web/src/assets/images/favicon.ico b/web/src/assets/images/favicon.ico similarity index 100% rename from kdb-web/src/assets/images/favicon.ico rename to web/src/assets/images/favicon.ico diff --git a/kdb-web/src/assets/version.json b/web/src/assets/version.json similarity index 100% rename from kdb-web/src/assets/version.json rename to web/src/assets/version.json diff --git a/kdb-web/src/environments/environment.development.ts b/web/src/environments/environment.development.ts similarity index 100% rename from kdb-web/src/environments/environment.development.ts rename to web/src/environments/environment.development.ts diff --git a/kdb-web/src/environments/environment.prod.ts b/web/src/environments/environment.prod.ts similarity index 100% rename from kdb-web/src/environments/environment.prod.ts rename to web/src/environments/environment.prod.ts diff --git a/kdb-web/src/environments/environment.staging.ts b/web/src/environments/environment.staging.ts similarity index 100% rename from kdb-web/src/environments/environment.staging.ts rename to web/src/environments/environment.staging.ts diff --git a/kdb-web/src/environments/environment.ts b/web/src/environments/environment.ts similarity index 100% rename from kdb-web/src/environments/environment.ts rename to web/src/environments/environment.ts diff --git a/kdb-web/src/favicon.ico b/web/src/favicon.ico similarity index 100% rename from kdb-web/src/favicon.ico rename to web/src/favicon.ico diff --git a/kdb-web/src/index.html b/web/src/index.html similarity index 100% rename from kdb-web/src/index.html rename to web/src/index.html diff --git a/kdb-web/src/main.ts b/web/src/main.ts similarity index 100% rename from kdb-web/src/main.ts rename to web/src/main.ts diff --git a/kdb-web/src/polyfills.ts b/web/src/polyfills.ts similarity index 100% rename from kdb-web/src/polyfills.ts rename to web/src/polyfills.ts diff --git a/kdb-web/src/styles.scss b/web/src/styles.scss similarity index 100% rename from kdb-web/src/styles.scss rename to web/src/styles.scss diff --git a/kdb-web/src/styles/constants.scss b/web/src/styles/constants.scss similarity index 100% rename from kdb-web/src/styles/constants.scss rename to web/src/styles/constants.scss diff --git a/kdb-web/src/styles/primeng-fixes.scss b/web/src/styles/primeng-fixes.scss similarity index 100% rename from kdb-web/src/styles/primeng-fixes.scss rename to web/src/styles/primeng-fixes.scss diff --git a/kdb-web/src/styles/themes/default-dark-theme.scss b/web/src/styles/themes/default-dark-theme.scss similarity index 100% rename from kdb-web/src/styles/themes/default-dark-theme.scss rename to web/src/styles/themes/default-dark-theme.scss diff --git a/kdb-web/src/styles/themes/default-light-theme.scss b/web/src/styles/themes/default-light-theme.scss similarity index 100% rename from kdb-web/src/styles/themes/default-light-theme.scss rename to web/src/styles/themes/default-light-theme.scss diff --git a/kdb-web/src/styles/themes/sh-edraft-dark-theme.scss b/web/src/styles/themes/sh-edraft-dark-theme.scss similarity index 100% rename from kdb-web/src/styles/themes/sh-edraft-dark-theme.scss rename to web/src/styles/themes/sh-edraft-dark-theme.scss diff --git a/kdb-web/src/styles/themes/sh-edraft-light-theme.scss b/web/src/styles/themes/sh-edraft-light-theme.scss similarity index 100% rename from kdb-web/src/styles/themes/sh-edraft-light-theme.scss rename to web/src/styles/themes/sh-edraft-light-theme.scss diff --git a/kdb-web/src/test.ts b/web/src/test.ts similarity index 100% rename from kdb-web/src/test.ts rename to web/src/test.ts diff --git a/kdb-web/tsconfig.app.json b/web/tsconfig.app.json similarity index 100% rename from kdb-web/tsconfig.app.json rename to web/tsconfig.app.json diff --git a/kdb-web/tsconfig.json b/web/tsconfig.json similarity index 100% rename from kdb-web/tsconfig.json rename to web/tsconfig.json diff --git a/kdb-web/tsconfig.spec.json b/web/tsconfig.spec.json similarity index 100% rename from kdb-web/tsconfig.spec.json rename to web/tsconfig.spec.json diff --git a/kdb-web/update-version.ts b/web/update-version.ts similarity index 100% rename from kdb-web/update-version.ts rename to web/update-version.ts -- 2.45.2 From 3a7daf8b42a36c0b3012936ffab4e84e6e9d533b Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Sun, 15 Oct 2023 11:07:31 +0200 Subject: [PATCH 16/58] Fixed submodules #405 --- .gitmodules | 12 +++++------ bot/LICENSE | 9 +++++++++ bot/README.md | 2 ++ bot/cpl-workspace.json | 46 ++++++++++++++++++++++++++++++++++++++++++ bot/dockerfile | 21 +++++++++++++++++++ bot/pyproject.toml | 2 ++ 6 files changed, 86 insertions(+), 6 deletions(-) create mode 100644 bot/LICENSE create mode 100644 bot/README.md create mode 100644 bot/cpl-workspace.json create mode 100644 bot/dockerfile create mode 100644 bot/pyproject.toml diff --git a/.gitmodules b/.gitmodules index ac5bd60d..f72ea2ba 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,9 +1,9 @@ -[submodule "shd-bot/src/bot/config"] - path = shd-bot/src/bot/config +[submodule "bot/src/bot/config"] + path = bot/src/bot/config url = https://git.sh-edraft.de/sh-edraft.de/sh_discord_bot.config.git -[submodule "shb-bot/src/bot_api/config"] - path = shb-bot/src/bot_api/config +[submodule "bot/src/bot_api/config"] + path = bot/src/bot_api/config url = https://git.sh-edraft.de/sh-edraft.de/sh_discord_bot.api.config.git -[submodule "shb-bot/bot/docker"] - path = shb-bot/bot/docker +[submodule "bot/docker"] + path = bot/docker url = https://git.sh-edraft.de/sh-edraft.de/sh_discord_bot.docker.git diff --git a/bot/LICENSE b/bot/LICENSE new file mode 100644 index 00000000..374f2e3a --- /dev/null +++ b/bot/LICENSE @@ -0,0 +1,9 @@ +MIT License + +Copyright (c) 2022-2023 sh-edraft.de + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/bot/README.md b/bot/README.md new file mode 100644 index 00000000..72b3dd33 --- /dev/null +++ b/bot/README.md @@ -0,0 +1,2 @@ +# kd_discord_bot + diff --git a/bot/cpl-workspace.json b/bot/cpl-workspace.json new file mode 100644 index 00000000..833b19a0 --- /dev/null +++ b/bot/cpl-workspace.json @@ -0,0 +1,46 @@ +{ + "WorkspaceSettings": { + "DefaultProject": "bot", + "Projects": { + "bot": "src/bot/bot.json", + "bot-api": "src/bot_api/bot-api.json", + "bot-core": "src/bot_core/bot-core.json", + "bot-data": "src/bot_data/bot-data.json", + "bot-graphql": "src/bot_graphql/bot-graphql.json", + "achievements": "src/modules/achievements/achievements.json", + "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", + "database": "src/modules/database/database.json", + "level": "src/modules/level/level.json", + "permission": "src/modules/permission/permission.json", + "technician": "src/modules/technician/technician.json", + "short-role-name": "src/modules/short_role_name/short-role-name.json", + "special-offers": "src/modules/special_offers/special-offers.json", + "checks": "tools/checks/checks.json", + "get-version": "tools/get_version/get-version.json", + "post-build": "tools/post_build/post-build.json", + "set-version": "tools/set_version/set-version.json" + }, + "Scripts": { + "format": "black ./", + "sv": "cpl set-version $ARGS", + "set-version": "cpl run set-version $ARGS --dev; echo '';", + "gv": "cpl get-version", + "get-version": "export VERSION=$(cpl run get-version --dev); echo $VERSION;", + "pre-build": "cpl set-version $ARGS; black ./;", + "post-build": "cpl run post-build --dev; black ./;", + "pre-prod": "cpl build", + "prod": "export KDB_ENVIRONMENT=production; export KDB_NAME=KDB-Prod; cpl start;", + "pre-stage": "cpl build", + "stage": "export KDB_ENVIRONMENT=staging; export KDB_NAME=KDB-Stage; cpl start;", + "pre-dev": "cpl build", + "dev": "export KDB_ENVIRONMENT=development; export KDB_NAME=KDB-Dev; cpl start;", + "docker-build": "cpl build $ARGS; docker build -t sh-edraft.de/kdb-bot:$(cpl gv) .;", + "dc-up": "docker-compose up -d", + "dc-down": "docker-compose down", + "docker": "cpl dc-down; cpl docker-build; cpl dc-up;" + } + } +} \ No newline at end of file diff --git a/bot/dockerfile b/bot/dockerfile new file mode 100644 index 00000000..478bf7e7 --- /dev/null +++ b/bot/dockerfile @@ -0,0 +1,21 @@ +# syntax=docker/dockerfile:1 +FROM python:3.10.4-alpine + +WORKDIR /app +COPY ./dist/bot/build/kdb-bot/ . +COPY ./dist/bot/build/requirements.txt . + +RUN python -m pip install --upgrade pip + +RUN apk update +RUN apk add --update alpine-sdk linux-headers +RUN apk add bash +RUN apk add nano + +RUN pip install -r requirements.txt --extra-index-url https://pip.sh-edraft.de +RUN pip install flask[async] + +# RUN pip install dnspython==2.2.1 # https://stackoverflow.com/questions/75137717/eventlet-dns-python-attribute-error-module-dns-rdtypes-has-no-attribute-any +# ^ probably fixed py package updates + +CMD [ "bash", "/app/bot/bot"] diff --git a/bot/pyproject.toml b/bot/pyproject.toml new file mode 100644 index 00000000..e34796ec --- /dev/null +++ b/bot/pyproject.toml @@ -0,0 +1,2 @@ +[tool.black] +line-length = 120 \ No newline at end of file -- 2.45.2 From be6361f619cc14156dfd58e917799e2360248ace Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Sun, 15 Oct 2023 11:30:29 +0200 Subject: [PATCH 17/58] Formatted stuff #405 --- .gitea/workflows/deploy_dev.yaml | 12 +- .gitea/workflows/deploy_prod.yaml | 12 +- bot/cpl-workspace.json | 8 +- bot/dockerfile | 2 +- bot/src/bot/application.py | 26 +-- bot/src/bot/extension/init_bot_extension.py | 4 +- bot/src/bot/startup.py | 4 +- bot/src/bot/startup_discord_extension.py | 8 +- bot/src/bot/startup_migration_extension.py | 72 ++---- bot/src/bot/startup_module_extension.py | 8 +- bot/src/bot/startup_settings_extension.py | 28 +-- bot/src/bot_api/abc/auth_service_abc.py | 8 +- bot/src/bot_api/abc/select_criteria_abc.py | 4 +- bot/src/bot_api/api.py | 12 +- bot/src/bot_api/api_module.py | 12 +- bot/src/bot_api/app_api_extension.py | 4 +- .../configuration/authentication_settings.py | 4 +- bot/src/bot_api/controller/auth_controller.py | 32 +-- .../filter/auth_user_select_criteria.py | 4 +- .../filter/discord/server_select_criteria.py | 4 +- bot/src/bot_api/model/error_dto.py | 4 +- bot/src/bot_api/model/update_auth_user_dto.py | 4 +- bot/src/bot_api/route/route.py | 20 +- bot/src/bot_api/service/auth_service.py | 165 ++++---------- bot/src/bot_api/service/discord_service.py | 27 +-- .../transformer/auth_user_transformer.py | 16 +- .../bot_api/transformer/server_transformer.py | 4 +- bot/src/bot_core/abc/client_utils_abc.py | 4 +- .../bot_core/abc/custom_file_logger_abc.py | 8 +- bot/src/bot_core/abc/message_service_abc.py | 4 +- bot/src/bot_core/abc/task_abc.py | 4 +- .../configuration/file_logging_settings.py | 4 +- .../bot_core/core_extension/core_extension.py | 4 +- .../core_extension/core_extension_module.py | 12 +- bot/src/bot_core/core_module.py | 8 +- bot/src/bot_core/helper/command_checks.py | 12 +- .../bot_core/service/client_utils_service.py | 48 +--- .../service/data_integrity_service.py | 141 +++--------- bot/src/bot_core/service/message_service.py | 88 ++------ .../abc/achievement_repository_abc.py | 4 +- .../bot_data/abc/auth_user_repository_abc.py | 4 +- bot/src/bot_data/abc/client_repository_abc.py | 4 +- .../abc/server_config_repository_abc.py | 24 +- .../abc/technician_config_repository_abc.py | 12 +- .../user_joined_game_server_repository_abc.py | 28 +-- .../abc/user_joined_server_repository_abc.py | 12 +- ...ser_joined_voice_channel_repository_abc.py | 28 +-- ...r_message_count_per_hour_repository_abc.py | 4 +- bot/src/bot_data/abc/user_repository_abc.py | 8 +- bot/src/bot_data/data_module.py | 36 +-- .../migration/achievements_migration.py | 32 +-- .../config_feature_flags_migration.py | 8 +- .../migration/fix_updates_migration.py | 4 +- bot/src/bot_data/model/achievement.py | 4 +- bot/src/bot_data/model/api_key.py | 4 +- bot/src/bot_data/model/auth_user.py | 4 +- .../model/auth_user_users_relation.py | 4 +- bot/src/bot_data/model/auto_role.py | 4 +- bot/src/bot_data/model/auto_role_rule.py | 4 +- bot/src/bot_data/model/client.py | 4 +- bot/src/bot_data/model/game_server.py | 4 +- bot/src/bot_data/model/known_user.py | 4 +- bot/src/bot_data/model/level.py | 4 +- bot/src/bot_data/model/server.py | 4 +- .../model/server_afk_channel_ids_config.py | 4 +- bot/src/bot_data/model/server_config.py | 8 +- .../bot_data/model/server_config_history.py | 4 +- .../model/server_team_role_ids_config.py | 4 +- bot/src/bot_data/model/short_role_name.py | 4 +- bot/src/bot_data/model/steam_special_offer.py | 4 +- bot/src/bot_data/model/technician_config.py | 4 +- .../bot_data/model/technician_id_config.py | 4 +- .../model/technician_ping_url_config.py | 4 +- bot/src/bot_data/model/user.py | 12 +- bot/src/bot_data/model/user_game_ident.py | 4 +- .../bot_data/model/user_got_achievement.py | 4 +- bot/src/bot_data/model/user_history.py | 8 +- .../bot_data/model/user_joined_game_server.py | 4 +- bot/src/bot_data/model/user_joined_server.py | 4 +- .../model/user_joined_voice_channel.py | 4 +- .../model/user_message_count_per_hour.py | 4 +- bot/src/bot_data/model/user_warnings.py | 4 +- .../achievements_repository_service.py | 28 +-- .../service/api_key_repository_service.py | 24 +- .../service/auth_user_repository_service.py | 42 +--- .../service/auto_role_repository_service.py | 40 +--- .../service/client_repository_service.py | 24 +- .../service/game_server_repository_service.py | 8 +- .../service/known_user_repository_service.py | 16 +- .../service/level_repository_service.py | 12 +- bot/src/bot_data/service/migration_service.py | 16 +- .../server_config_repository_service.py | 76 ++----- .../service/server_repository_service.py | 36 +-- .../short_role_name_repository_service.py | 32 +-- .../steam_special_offer_repository_service.py | 20 +- .../technician_config_repository_service.py | 48 +--- .../service/technician_config_seeder.py | 8 +- .../user_game_ident_repository_service.py | 28 +-- ...r_joined_game_server_repository_service.py | 68 ++---- .../user_joined_server_repository_service.py | 40 +--- ...joined_voice_channel_repository_service.py | 68 ++---- ...ssage_count_per_hour_repository_service.py | 20 +- .../service/user_repository_service.py | 28 +-- .../user_warnings_repository_service.py | 12 +- bot/src/bot_graphql/abc/filter_abc.py | 10 +- bot/src/bot_graphql/abc/query_abc.py | 46 +--- .../bot_graphql/filter/achievement_filter.py | 14 +- .../bot_graphql/filter/auto_role_filter.py | 13 +- .../filter/auto_role_rule_filter.py | 4 +- bot/src/bot_graphql/filter/client_filter.py | 9 +- bot/src/bot_graphql/filter/level_filter.py | 9 +- bot/src/bot_graphql/filter/server_filter.py | 6 +- .../filter/short_role_name_filter.py | 9 +- bot/src/bot_graphql/filter/user_filter.py | 25 +-- .../filter/user_joined_game_server_filter.py | 4 +- .../filter/user_joined_server_filter.py | 14 +- .../user_joined_voice_channel_filter.py | 18 +- .../bot_graphql/filter/user_warning_filter.py | 13 +- bot/src/bot_graphql/graphql_module.py | 8 +- .../mutations/achievement_mutation.py | 18 +- .../mutations/auto_role_mutation.py | 14 +- .../mutations/auto_role_rule_mutation.py | 28 +-- .../bot_graphql/mutations/level_mutation.py | 10 +- .../mutations/server_config_mutation.py | 92 ++------ .../mutations/short_role_name_mutation.py | 20 +- .../mutations/technician_config_mutation.py | 36 +-- .../user_joined_game_server_mutation.py | 40 +--- .../bot_graphql/mutations/user_mutation.py | 34 +-- .../bot_graphql/queries/achievement_query.py | 4 +- .../bot_graphql/queries/auto_role_query.py | 8 +- .../queries/auto_role_rule_query.py | 4 +- bot/src/bot_graphql/queries/client_query.py | 4 +- .../queries/discord/guild_query.py | 4 +- .../bot_graphql/queries/known_user_query.py | 4 +- bot/src/bot_graphql/queries/level_query.py | 4 +- .../queries/server_config_query.py | 37 +--- bot/src/bot_graphql/queries/server_query.py | 20 +- .../queries/short_role_name_query.py | 4 +- .../technician_config_history_query.py | 5 +- .../queries/technician_config_query.py | 5 +- bot/src/bot_graphql/queries/user_query.py | 8 +- .../bot_graphql/queries/user_warning_query.py | 4 +- bot/src/bot_graphql/query.py | 28 +-- bot/src/bot_graphql/schema.py | 4 +- .../achievement_attribute_resolver.py | 19 +- .../achievements/achievement_service.py | 60 ++--- .../achievements/achievements_module.py | 16 +- .../commands/achievements_group.py | 4 +- .../events/achievement_on_message_event.py | 8 +- .../achievement_on_reaction_add_event.py | 4 +- .../achievement_on_reaction_remove_event.py | 4 +- ...achievement_on_voice_state_update_event.py | 4 +- bot/src/modules/auto_role/auto_role_module.py | 8 +- .../auto_role/command/auto_role_group.py | 208 +++++------------- .../events/auto_role_on_raw_reaction_add.py | 8 +- .../auto_role_on_raw_reaction_remove.py | 8 +- .../helper/auto_role_reaction_handler.py | 12 +- bot/src/modules/base/base_module.py | 36 +-- bot/src/modules/base/birthday_watcher.py | 8 +- bot/src/modules/base/command/afk_command.py | 12 +- .../modules/base/command/game_server_group.py | 84 ++----- bot/src/modules/base/command/help_command.py | 4 +- bot/src/modules/base/command/info_command.py | 5 +- .../modules/base/command/mass_move_command.py | 4 +- bot/src/modules/base/command/ping_command.py | 8 +- .../modules/base/command/presence_command.py | 8 +- bot/src/modules/base/command/purge_command.py | 12 +- .../modules/base/command/register_group.py | 12 +- bot/src/modules/base/command/submit_group.py | 4 +- .../modules/base/command/unregister_group.py | 8 +- bot/src/modules/base/command/user_group.py | 156 ++++--------- .../events/base_on_command_error_event.py | 16 +- .../base/events/base_on_command_event.py | 20 +- .../base/events/base_on_member_join_event.py | 28 +-- .../events/base_on_member_remove_event.py | 16 +- .../events/base_on_message_delete_event.py | 16 +- .../base/events/base_on_message_event.py | 20 +- .../base_on_scheduled_event_update_event.py | 7 +- .../base_on_voice_state_update_event.py | 54 ++--- ...n_voice_state_update_event_help_channel.py | 12 +- bot/src/modules/base/forms/bug_report_form.py | 12 +- bot/src/modules/base/forms/complaint_form.py | 8 +- .../base/helper/base_reaction_handler.py | 16 +- .../base/helper/voice_channel_transformer.py | 20 +- bot/src/modules/base/service/event_service.py | 12 +- .../base/service/user_warnings_service.py | 92 ++------ .../modules/boot_log/boot_log_extension.py | 4 +- bot/src/modules/boot_log/boot_log_module.py | 12 +- .../boot_log/boot_log_on_ready_event.py | 17 +- bot/src/modules/config/config_extension.py | 4 +- bot/src/modules/config/config_module.py | 8 +- .../config/events/config_on_ready_event.py | 4 +- .../modules/database/database_extension.py | 4 +- bot/src/modules/database/database_module.py | 12 +- .../database/database_on_ready_event.py | 13 +- bot/src/modules/level/command/level_group.py | 185 ++++------------ .../events/level_on_member_join_event.py | 12 +- .../level/events/level_on_message_event.py | 12 +- .../events/level_on_raw_reaction_add_event.py | 8 +- .../level_on_raw_reaction_remove_event.py | 8 +- .../level_on_voice_state_update_event.py | 12 +- bot/src/modules/level/level_module.py | 20 +- bot/src/modules/level/level_seeder.py | 41 +--- .../modules/level/service/level_service.py | 44 +--- .../modules/permission/permission_module.py | 8 +- .../permission/service/permission_service.py | 20 +- .../short_role_name_on_member_update_event.py | 4 +- .../service/short_role_name_service.py | 16 +- .../short_role_name_check_command.py | 16 +- .../short_role_name/short_role_name_module.py | 8 +- .../special_offers/special_offers_module.py | 8 +- .../special_offers/steam_offer_watcher.py | 40 +--- bot/src/modules/technician/api_key_seeder.py | 4 +- .../technician/command/api_key_group.py | 36 +-- .../modules/technician/command/log_command.py | 5 +- .../technician/command/restart_command.py | 4 +- .../technician/command/shutdown_command.py | 4 +- .../technician/command/sync_xp_command.py | 58 ++--- .../modules/technician/technician_module.py | 8 +- bot/tools/get_version/startup.py | 8 +- bot/tools/post_build/post_build_settings.py | 8 +- bot/tools/post_build/service/dependencies.py | 4 +- bot/tools/post_build/startup.py | 8 +- bot/tools/set_version/application.py | 34 +-- bot/tools/set_version/startup.py | 8 +- .../set_version/version_setter_service.py | 13 +- 226 files changed, 1083 insertions(+), 3252 deletions(-) diff --git a/.gitea/workflows/deploy_dev.yaml b/.gitea/workflows/deploy_dev.yaml index 7d1db445..5b7485a1 100644 --- a/.gitea/workflows/deploy_dev.yaml +++ b/.gitea/workflows/deploy_dev.yaml @@ -24,17 +24,17 @@ jobs: uses: https://github.com/actions/checkout@v3 - name: Shutdown stack - run: docker stack rm kdb_staging + run: docker stack rm sdb_staging - name: Prepare bot build run: | - cd kdb-bot + cd bot pip install --extra-index-url https://pip.sh-edraft.de cpl-cli cpl i - name: Build docker bot run: | - cd kdb-bot + cd bot docker image prune -f cpl docker-build @@ -43,13 +43,13 @@ jobs: - name: Prepare web build run: | - cd kdb-web + cd web npm install -g ts-node npm i - name: Build docker web run: | - cd kdb-web + cd web docker image prune -f npm run docker-build @@ -60,6 +60,6 @@ jobs: portainer-username: "gitea_job" portainer-password: "${{ secrets.docker_job }}" portainer-endpoint: 2 - name: kdb_staging + name: sdb_staging file: ./docker-compose.staging.yml variables: '{}' diff --git a/.gitea/workflows/deploy_prod.yaml b/.gitea/workflows/deploy_prod.yaml index 08273018..bf530ed8 100644 --- a/.gitea/workflows/deploy_prod.yaml +++ b/.gitea/workflows/deploy_prod.yaml @@ -24,17 +24,17 @@ jobs: uses: https://github.com/actions/checkout@v3 - name: Shutdown stack - run: docker stack rm kdb_prod + run: docker stack rm sdb_prod - name: Prepare bot build run: | - cd kdb-bot + cd bot pip install --extra-index-url https://pip.sh-edraft.de cpl-cli cpl i - name: Build docker bot run: | - cd kdb-bot + cd bot docker image prune -f cpl docker-build @@ -43,13 +43,13 @@ jobs: - name: Prepare web build run: | - cd kdb-web + cd web npm install -g ts-node npm i - name: Build docker web run: | - cd kdb-web + cd web docker image prune -f npm run docker-build @@ -60,6 +60,6 @@ jobs: portainer-username: "gitea_job" portainer-password: "${{ secrets.docker_job }}" portainer-endpoint: 2 - name: kdb_prod + name: sdb_prod file: ./docker-compose.yml variables: '{}' diff --git a/bot/cpl-workspace.json b/bot/cpl-workspace.json index 833b19a0..d08ceb87 100644 --- a/bot/cpl-workspace.json +++ b/bot/cpl-workspace.json @@ -32,12 +32,12 @@ "pre-build": "cpl set-version $ARGS; black ./;", "post-build": "cpl run post-build --dev; black ./;", "pre-prod": "cpl build", - "prod": "export KDB_ENVIRONMENT=production; export KDB_NAME=KDB-Prod; cpl start;", + "prod": "export SDB_ENVIRONMENT=production; export SDB_NAME=SDB-Prod; cpl start;", "pre-stage": "cpl build", - "stage": "export KDB_ENVIRONMENT=staging; export KDB_NAME=KDB-Stage; cpl start;", + "stage": "export SDB_ENVIRONMENT=staging; export SDB_NAME=SDB-Stage; cpl start;", "pre-dev": "cpl build", - "dev": "export KDB_ENVIRONMENT=development; export KDB_NAME=KDB-Dev; cpl start;", - "docker-build": "cpl build $ARGS; docker build -t sh-edraft.de/kdb-bot:$(cpl gv) .;", + "dev": "export SDB_ENVIRONMENT=development; export SDB_NAME=SDB-Dev; cpl start;", + "docker-build": "cpl build $ARGS; docker build -t sh-edraft.de/sdb-bot:$(cpl gv) .;", "dc-up": "docker-compose up -d", "dc-down": "docker-compose down", "docker": "cpl dc-down; cpl docker-build; cpl dc-up;" diff --git a/bot/dockerfile b/bot/dockerfile index 478bf7e7..ad507c89 100644 --- a/bot/dockerfile +++ b/bot/dockerfile @@ -2,7 +2,7 @@ FROM python:3.10.4-alpine WORKDIR /app -COPY ./dist/bot/build/kdb-bot/ . +COPY ./dist/bot/build/bot/ . COPY ./dist/bot/build/requirements.txt . RUN python -m pip install --upgrade pip diff --git a/bot/src/bot/application.py b/bot/src/bot/application.py index 4d57ff59..6d1e4dd9 100644 --- a/bot/src/bot/application.py +++ b/bot/src/bot/application.py @@ -23,25 +23,17 @@ class Application(DiscordBotApplicationABC): # cpl-core self._logger: LoggerABC = services.get_service(LoggerABC) - self._data_integrity: DataIntegrityService = services.get_service( - DataIntegrityService - ) + self._data_integrity: DataIntegrityService = services.get_service(DataIntegrityService) # cpl-discord self._bot: DiscordBotServiceABC = services.get_service(DiscordBotServiceABC) - self._bot_settings: DiscordBotSettings = config.get_configuration( - DiscordBotSettings - ) + self._bot_settings: DiscordBotSettings = config.get_configuration(DiscordBotSettings) # cpl-translation - self._translation: TranslationServiceABC = services.get_service( - TranslationServiceABC - ) + self._translation: TranslationServiceABC = services.get_service(TranslationServiceABC) self._t: TranslatePipe = services.get_service(TranslatePipe) # internal stuff self._tasks = services.get_services(TaskABC) - self._feature_flags: FeatureFlagsSettings = config.get_configuration( - FeatureFlagsSettings - ) + self._feature_flags: FeatureFlagsSettings = config.get_configuration(FeatureFlagsSettings) # api if self._feature_flags.get_flag(FeatureFlagsEnum.api_module): @@ -50,9 +42,7 @@ class Application(DiscordBotApplicationABC): self._is_stopping = False async def configure(self): - self._translation.load_by_settings( - self._configuration.get_configuration(TranslationSettings) - ) + self._translation.load_by_settings(self._configuration.get_configuration(TranslationSettings)) async def main(self): try: @@ -95,8 +85,4 @@ class Application(DiscordBotApplicationABC): Console.write_line() def is_restart(self): - return ( - True - if self._configuration.get_configuration("IS_RESTART") == "true" - else False - ) + return True if self._configuration.get_configuration("IS_RESTART") == "true" else False diff --git a/bot/src/bot/extension/init_bot_extension.py b/bot/src/bot/extension/init_bot_extension.py index c0a2feef..04a4fcf0 100644 --- a/bot/src/bot/extension/init_bot_extension.py +++ b/bot/src/bot/extension/init_bot_extension.py @@ -13,6 +13,4 @@ class InitBotExtension(ApplicationExtensionABC): async def run(self, config: ConfigurationABC, services: ServiceProviderABC): settings = config.get_configuration(TechnicianConfig) - bot: DiscordBotServiceABC = services.get_service( - DiscordBotServiceABC, max_messages=settings.cache_max_messages - ) + bot: DiscordBotServiceABC = services.get_service(DiscordBotServiceABC, max_messages=settings.cache_max_messages) diff --git a/bot/src/bot/startup.py b/bot/src/bot/startup.py index 8e52249f..0a5422d2 100644 --- a/bot/src/bot/startup.py +++ b/bot/src/bot/startup.py @@ -50,9 +50,7 @@ class Startup(StartupABC): services.add_singleton(CustomFileLoggerABC, ApiLogger) services.add_translation() - services.add_db_context( - DBContext, self._config.get_configuration(DatabaseSettings) - ) + services.add_db_context(DBContext, self._config.get_configuration(DatabaseSettings)) provider = services.build_service_provider() # instantiate custom logger diff --git a/bot/src/bot/startup_discord_extension.py b/bot/src/bot/startup_discord_extension.py index 73411881..196017dc 100644 --- a/bot/src/bot/startup_discord_extension.py +++ b/bot/src/bot/startup_discord_extension.py @@ -9,13 +9,9 @@ class StartupDiscordExtension(StartupExtensionABC): def __init__(self): pass - def configure_configuration( - self, config: ConfigurationABC, env: ApplicationEnvironmentABC - ): + def configure_configuration(self, config: ConfigurationABC, env: ApplicationEnvironmentABC): pass - def configure_services( - self, services: ServiceCollectionABC, env: ApplicationEnvironmentABC - ): + def configure_services(self, services: ServiceCollectionABC, env: ApplicationEnvironmentABC): services.add_discord() dcc = get_discord_collection(services) diff --git a/bot/src/bot/startup_migration_extension.py b/bot/src/bot/startup_migration_extension.py index a874e2f4..206262fb 100644 --- a/bot/src/bot/startup_migration_extension.py +++ b/bot/src/bot/startup_migration_extension.py @@ -41,66 +41,30 @@ class StartupMigrationExtension(StartupExtensionABC): def __init__(self): pass - def configure_configuration( - self, config: ConfigurationABC, env: ApplicationEnvironmentABC - ): + def configure_configuration(self, config: ConfigurationABC, env: ApplicationEnvironmentABC): pass - def configure_services( - self, services: ServiceCollectionABC, env: ApplicationEnvironmentABC - ): + def configure_services(self, services: ServiceCollectionABC, env: ApplicationEnvironmentABC): services.add_transient(MigrationService) services.add_transient(MigrationABC, InitialMigration) - services.add_transient( - MigrationABC, AutoRoleMigration - ) # 03.10.2022 #54 - 0.2.2 + services.add_transient(MigrationABC, AutoRoleMigration) # 03.10.2022 #54 - 0.2.2 services.add_transient(MigrationABC, ApiMigration) # 15.10.2022 #70 - 0.3.0 services.add_transient(MigrationABC, LevelMigration) # 06.11.2022 #25 - 0.3.0 services.add_transient(MigrationABC, StatsMigration) # 09.11.2022 #46 - 0.3.0 - services.add_transient( - MigrationABC, AutoRoleFix1Migration - ) # 30.12.2022 #151 - 0.3.0 - services.add_transient( - MigrationABC, UserMessageCountPerHourMigration - ) # 11.01.2023 #168 - 0.3.1 + services.add_transient(MigrationABC, AutoRoleFix1Migration) # 30.12.2022 #151 - 0.3.0 + services.add_transient(MigrationABC, UserMessageCountPerHourMigration) # 11.01.2023 #168 - 0.3.1 services.add_transient(MigrationABC, ApiKeyMigration) # 09.02.2023 #162 - 1.0.0 - services.add_transient( - MigrationABC, UserJoinedGameServerMigration - ) # 12.02.2023 #181 - 1.0.0 - services.add_transient( - MigrationABC, RemoveStatsMigration - ) # 19.02.2023 #190 - 1.0.0 - services.add_transient( - MigrationABC, UserWarningMigration - ) # 21.02.2023 #35 - 1.0.0 - 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, UserJoinedGameServerMigration) # 12.02.2023 #181 - 1.0.0 + services.add_transient(MigrationABC, RemoveStatsMigration) # 19.02.2023 #190 - 1.0.0 + services.add_transient(MigrationABC, UserWarningMigration) # 21.02.2023 #35 - 1.0.0 + 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 - services.add_transient( - MigrationABC, ShortRoleNameMigration - ) # 28.09.2023 #378 - 1.1.7 - services.add_transient( - MigrationABC, FixUpdatesMigration - ) # 28.09.2023 #378 - 1.1.7 - services.add_transient( - MigrationABC, ShortRoleNameOnlyHighestMigration - ) # 02.10.2023 #391 - 1.1.9 - services.add_transient( - MigrationABC, FixUserHistoryMigration - ) # 10.10.2023 #401 - 1.2.0 - services.add_transient( - MigrationABC, BirthdayMigration - ) # 10.10.2023 #401 - 1.2.0 - services.add_transient( - MigrationABC, SteamSpecialOfferMigration - ) # 10.10.2023 #188 - 1.2.0 + services.add_transient(MigrationABC, ConfigFeatureFlagsMigration) # 15.08.2023 #334 - 1.1.0 + services.add_transient(MigrationABC, DefaultRoleMigration) # 24.09.2023 #360 - 1.1.3 + services.add_transient(MigrationABC, ShortRoleNameMigration) # 28.09.2023 #378 - 1.1.7 + services.add_transient(MigrationABC, FixUpdatesMigration) # 28.09.2023 #378 - 1.1.7 + services.add_transient(MigrationABC, ShortRoleNameOnlyHighestMigration) # 02.10.2023 #391 - 1.1.9 + services.add_transient(MigrationABC, FixUserHistoryMigration) # 10.10.2023 #401 - 1.2.0 + services.add_transient(MigrationABC, BirthdayMigration) # 10.10.2023 #401 - 1.2.0 + services.add_transient(MigrationABC, SteamSpecialOfferMigration) # 10.10.2023 #188 - 1.2.0 diff --git a/bot/src/bot/startup_module_extension.py b/bot/src/bot/startup_module_extension.py index c3f1789e..2d87319d 100644 --- a/bot/src/bot/startup_module_extension.py +++ b/bot/src/bot/startup_module_extension.py @@ -18,15 +18,11 @@ class StartupModuleExtension(StartupExtensionABC): self._modules = ModuleList.get_modules() - def configure_configuration( - self, config: ConfigurationABC, env: ApplicationEnvironmentABC - ): + def configure_configuration(self, config: ConfigurationABC, env: ApplicationEnvironmentABC): self._config = config self._feature_flags = config.get_configuration(FeatureFlagsSettings) - def configure_services( - self, services: ServiceCollectionABC, env: ApplicationEnvironmentABC - ): + def configure_services(self, services: ServiceCollectionABC, env: ApplicationEnvironmentABC): provider = services.build_service_provider() dc_collection: DiscordCollectionABC = provider.get_service(DiscordCollectionABC) diff --git a/bot/src/bot/startup_settings_extension.py b/bot/src/bot/startup_settings_extension.py index ad45ee9b..caf34f19 100644 --- a/bot/src/bot/startup_settings_extension.py +++ b/bot/src/bot/startup_settings_extension.py @@ -14,38 +14,26 @@ class StartupSettingsExtension(StartupExtensionABC): def __init__(self): self._start_time = datetime.now() - def configure_configuration( - self, configuration: ConfigurationABC, environment: ApplicationEnvironmentABC - ): + def configure_configuration(self, configuration: ConfigurationABC, environment: ApplicationEnvironmentABC): # this shit has to be done here because we need settings in subsequent startup extensions environment.set_working_directory(os.path.dirname(os.path.realpath(__file__))) configuration.add_environment_variables("KDB_") configuration.add_environment_variables("DISCORD_") configuration.add_json_file(f"config/appsettings.json", optional=False) - configuration.add_json_file( - f"config/appsettings.{environment.environment_name}.json", optional=True - ) - configuration.add_json_file( - f"config/appsettings.{environment.host_name}.json", optional=True - ) + configuration.add_json_file(f"config/appsettings.{environment.environment_name}.json", optional=True) + configuration.add_json_file(f"config/appsettings.{environment.host_name}.json", optional=True) # load feature-flags configuration.add_json_file(f"config/feature-flags.json", optional=False) - configuration.add_json_file( - f"config/feature-flags.{environment.environment_name}.json", optional=True - ) - configuration.add_json_file( - f"config/feature-flags.{environment.host_name}.json", optional=True - ) + configuration.add_json_file(f"config/feature-flags.{environment.environment_name}.json", optional=True) + configuration.add_json_file(f"config/feature-flags.{environment.host_name}.json", optional=True) configuration.add_configuration("Startup_StartTime", str(self._start_time)) self._configure_settings_with_sub_settings( configuration, BotLoggingSettings, lambda x: x.files, lambda x: x.key ) - def configure_services( - self, services: ServiceCollectionABC, env: ApplicationEnvironmentABC - ): + def configure_services(self, services: ServiceCollectionABC, env: ApplicationEnvironmentABC): pass @staticmethod @@ -57,6 +45,4 @@ class StartupSettingsExtension(StartupExtensionABC): return for sub_settings in list_atr(settings): - config.add_configuration( - f"{type(sub_settings).__name__}_{atr(sub_settings)}", sub_settings - ) + config.add_configuration(f"{type(sub_settings).__name__}_{atr(sub_settings)}", sub_settings) diff --git a/bot/src/bot_api/abc/auth_service_abc.py b/bot/src/bot_api/abc/auth_service_abc.py index 812b3c30..1ba5fbbb 100644 --- a/bot/src/bot_api/abc/auth_service_abc.py +++ b/bot/src/bot_api/abc/auth_service_abc.py @@ -40,15 +40,11 @@ class AuthServiceABC(ABC): pass @abstractmethod - async def get_filtered_auth_users_async( - self, criteria: AuthUserSelectCriteria - ) -> AuthUserFilteredResultDTO: + async def get_filtered_auth_users_async(self, criteria: AuthUserSelectCriteria) -> AuthUserFilteredResultDTO: pass @abstractmethod - async def get_auth_user_by_email_async( - self, email: str, with_password: bool = False - ) -> AuthUserDTO: + async def get_auth_user_by_email_async(self, email: str, with_password: bool = False) -> AuthUserDTO: pass @abstractmethod diff --git a/bot/src/bot_api/abc/select_criteria_abc.py b/bot/src/bot_api/abc/select_criteria_abc.py index 2c54df69..950b5203 100644 --- a/bot/src/bot_api/abc/select_criteria_abc.py +++ b/bot/src/bot_api/abc/select_criteria_abc.py @@ -3,9 +3,7 @@ from abc import ABC, abstractmethod class SelectCriteriaABC(ABC): @abstractmethod - def __init__( - self, page_index: int, page_size: int, sort_direction: str, sort_column: str - ): + def __init__(self, page_index: int, page_size: int, sort_direction: str, sort_column: str): self.page_index = page_index self.page_size = page_size self.sort_direction = sort_direction diff --git a/bot/src/bot_api/api.py b/bot/src/bot_api/api.py index 587f0503..84184695 100644 --- a/bot/src/bot_api/api.py +++ b/bot/src/bot_api/api.py @@ -57,9 +57,7 @@ class Api(Flask): # Added async_mode see link below # https://github.com/miguelgrinberg/Flask-SocketIO/discussions/1849 # https://stackoverflow.com/questions/39370848/flask-socket-io-sometimes-client-calls-freeze-the-server - self._socketio = SocketIO( - self, cors_allowed_origins="*", path="/api/socket.io", async_mode="eventlet" - ) + self._socketio = SocketIO(self, cors_allowed_origins="*", path="/api/socket.io", async_mode="eventlet") self._socketio.on_event("connect", self.on_connect) self._socketio.on_event("disconnect", self.on_disconnect) @@ -145,9 +143,7 @@ class Api(Flask): data = request.get_data() data = "" if len(data) == 0 else str(data.decode(encoding="utf-8")) - text = textwrap.dedent( - f"Request: {request_id}:\n\tHeader:\n\t\t{headers}\n\tResponse: {data}" - ) + text = textwrap.dedent(f"Request: {request_id}:\n\tHeader:\n\t\t{headers}\n\tResponse: {data}") self._logger.trace(__name__, text) return response @@ -162,9 +158,7 @@ class Api(Flask): # from waitress import serve # https://docs.pylonsproject.org/projects/waitress/en/stable/arguments.html # serve(self, host=self._apt_settings.host, port=self._apt_settings.port, threads=10, connection_limit=1000, channel_timeout=10) - self._socket = eventlet.listen( - (self._api_settings.host, self._api_settings.port) - ) + self._socket = eventlet.listen((self._api_settings.host, self._api_settings.port)) wsgi.server(self._socket, self, log_output=False) def stop(self): diff --git a/bot/src/bot_api/api_module.py b/bot/src/bot_api/api_module.py index 13a28547..b2695e12 100644 --- a/bot/src/bot_api/api_module.py +++ b/bot/src/bot_api/api_module.py @@ -26,21 +26,15 @@ class ApiModule(ModuleABC): def __init__(self, dc: DiscordCollectionABC): ModuleABC.__init__(self, dc, FeatureFlagsEnum.api_module) - def configure_configuration( - self, config: ConfigurationABC, env: ApplicationEnvironmentABC - ): + def configure_configuration(self, config: ConfigurationABC, env: ApplicationEnvironmentABC): cwd = env.working_directory env.set_working_directory(os.path.dirname(os.path.realpath(__file__))) config.add_json_file(f"config/apisettings.json", optional=False) - config.add_json_file( - f"config/apisettings.{env.environment_name}.json", optional=True - ) + config.add_json_file(f"config/apisettings.{env.environment_name}.json", optional=True) config.add_json_file(f"config/apisettings.{env.host_name}.json", optional=True) env.set_working_directory(cwd) - def configure_services( - self, services: ServiceCollectionABC, env: ApplicationEnvironmentABC - ): + def configure_services(self, services: ServiceCollectionABC, env: ApplicationEnvironmentABC): services.add_singleton(EMailClientABC, EMailClient) services.add_singleton(ApiThread) diff --git a/bot/src/bot_api/app_api_extension.py b/bot/src/bot_api/app_api_extension.py index da1ac033..ea9fda56 100644 --- a/bot/src/bot_api/app_api_extension.py +++ b/bot/src/bot_api/app_api_extension.py @@ -12,9 +12,7 @@ class AppApiExtension(ApplicationExtensionABC): ApplicationExtensionABC.__init__(self) async def run(self, config: ConfigurationABC, services: ServiceProviderABC): - feature_flags: FeatureFlagsSettings = config.get_configuration( - FeatureFlagsSettings - ) + feature_flags: FeatureFlagsSettings = config.get_configuration(FeatureFlagsSettings) if not feature_flags.get_flag(FeatureFlagsEnum.api_module): return diff --git a/bot/src/bot_api/configuration/authentication_settings.py b/bot/src/bot_api/configuration/authentication_settings.py index 3dfb2442..b9c3fff2 100644 --- a/bot/src/bot_api/configuration/authentication_settings.py +++ b/bot/src/bot_api/configuration/authentication_settings.py @@ -16,9 +16,7 @@ class AuthenticationSettings(ConfigurationModelABC): self._issuer = "" if issuer is None else issuer self._audience = "" if audience is None else audience self._token_expire_time = 0 if token_expire_time is None else token_expire_time - self._refresh_token_expire_time = ( - 0 if refresh_token_expire_time is None else refresh_token_expire_time - ) + self._refresh_token_expire_time = 0 if refresh_token_expire_time is None else refresh_token_expire_time @property def secret_key(self) -> str: diff --git a/bot/src/bot_api/controller/auth_controller.py b/bot/src/bot_api/controller/auth_controller.py index b5970ce4..983b5fb9 100644 --- a/bot/src/bot_api/controller/auth_controller.py +++ b/bot/src/bot_api/controller/auth_controller.py @@ -70,9 +70,7 @@ class AuthController: @Route.post(f"{BasePath}/register") async def register(self): - dto: AuthUserDTO = JSONProcessor.process( - AuthUserDTO, request.get_json(force=True, silent=True) - ) + dto: AuthUserDTO = JSONProcessor.process(AuthUserDTO, request.get_json(force=True, silent=True)) self._auth_service.add_auth_user(dto) return "", 200 @@ -83,9 +81,7 @@ class AuthController: @Route.post(f"{BasePath}/login") async def login(self) -> Response: - dto: AuthUserDTO = JSONProcessor.process( - AuthUserDTO, request.get_json(force=True, silent=True) - ) + dto: AuthUserDTO = JSONProcessor.process(AuthUserDTO, request.get_json(force=True, silent=True)) result = await self._auth_service.login_async(dto) return jsonify(result.to_dict()) @@ -114,52 +110,40 @@ class AuthController: @Route.post(f"{BasePath}/reset-password") async def reset_password(self): - dto: ResetPasswordDTO = JSONProcessor.process( - ResetPasswordDTO, request.get_json(force=True, silent=True) - ) + dto: ResetPasswordDTO = JSONProcessor.process(ResetPasswordDTO, request.get_json(force=True, silent=True)) await self._auth_service.reset_password_async(dto) return "", 200 @Route.post(f"{BasePath}/update-user") @Route.authorize async def update_user(self): - dto: UpdateAuthUserDTO = JSONProcessor.process( - UpdateAuthUserDTO, request.get_json(force=True, silent=True) - ) + dto: UpdateAuthUserDTO = JSONProcessor.process(UpdateAuthUserDTO, request.get_json(force=True, silent=True)) await self._auth_service.update_user_async(dto) return "", 200 @Route.post(f"{BasePath}/update-user-as-admin") @Route.authorize(role=AuthRoleEnum.admin) async def update_user_as_admin(self): - dto: UpdateAuthUserDTO = JSONProcessor.process( - UpdateAuthUserDTO, request.get_json(force=True, silent=True) - ) + dto: UpdateAuthUserDTO = JSONProcessor.process(UpdateAuthUserDTO, request.get_json(force=True, silent=True)) await self._auth_service.update_user_as_admin_async(dto) return "", 200 @Route.post(f"{BasePath}/refresh") async def refresh(self) -> Response: - dto: TokenDTO = JSONProcessor.process( - TokenDTO, request.get_json(force=True, silent=True) - ) + dto: TokenDTO = JSONProcessor.process(TokenDTO, request.get_json(force=True, silent=True)) result = await self._auth_service.refresh_async(dto) return jsonify(result.to_dict()) @Route.post(f"{BasePath}/revoke") async def revoke(self): - dto: TokenDTO = JSONProcessor.process( - TokenDTO, request.get_json(force=True, silent=True) - ) + dto: TokenDTO = JSONProcessor.process(TokenDTO, request.get_json(force=True, silent=True)) await self._auth_service.revoke_async(dto) return "", 200 @Route.post(f"{BasePath}/delete-user") @Route.authorize(role=AuthRoleEnum.admin) async def delete_user(self): - dto: AuthUserDTO = JSONProcessor.process( - AuthUserDTO, request.get_json(force=True, silent=True) - ) + dto: AuthUserDTO = JSONProcessor.process(AuthUserDTO, request.get_json(force=True, silent=True)) await self._auth_service.delete_auth_user_async(dto) return "", 200 diff --git a/bot/src/bot_api/filter/auth_user_select_criteria.py b/bot/src/bot_api/filter/auth_user_select_criteria.py index b19b8ead..eaa2ee7f 100644 --- a/bot/src/bot_api/filter/auth_user_select_criteria.py +++ b/bot/src/bot_api/filter/auth_user_select_criteria.py @@ -13,9 +13,7 @@ class AuthUserSelectCriteria(SelectCriteriaABC): email: str, auth_role: int, ): - SelectCriteriaABC.__init__( - self, page_index, page_size, sort_direction, sort_column - ) + SelectCriteriaABC.__init__(self, page_index, page_size, sort_direction, sort_column) self.first_name = first_name self.last_name = last_name diff --git a/bot/src/bot_api/filter/discord/server_select_criteria.py b/bot/src/bot_api/filter/discord/server_select_criteria.py index 73196b60..5f194809 100644 --- a/bot/src/bot_api/filter/discord/server_select_criteria.py +++ b/bot/src/bot_api/filter/discord/server_select_criteria.py @@ -10,8 +10,6 @@ class ServerSelectCriteria(SelectCriteriaABC): sort_column: str, name: str, ): - SelectCriteriaABC.__init__( - self, page_index, page_size, sort_direction, sort_column - ) + SelectCriteriaABC.__init__(self, page_index, page_size, sort_direction, sort_column) self.name = name diff --git a/bot/src/bot_api/model/error_dto.py b/bot/src/bot_api/model/error_dto.py index c864dece..867e581c 100644 --- a/bot/src/bot_api/model/error_dto.py +++ b/bot/src/bot_api/model/error_dto.py @@ -11,9 +11,7 @@ class ErrorDTO(DtoABC): def __init__(self, error_code: Optional[ServiceErrorCode], message: str): DtoABC.__init__(self) - self._error_code = ( - ServiceErrorCode.Unknown if error_code is None else error_code - ) + self._error_code = ServiceErrorCode.Unknown if error_code is None else error_code self._message = message @property diff --git a/bot/src/bot_api/model/update_auth_user_dto.py b/bot/src/bot_api/model/update_auth_user_dto.py index d8361171..28e57768 100644 --- a/bot/src/bot_api/model/update_auth_user_dto.py +++ b/bot/src/bot_api/model/update_auth_user_dto.py @@ -34,9 +34,7 @@ class UpdateAuthUserDTO(DtoABC): def from_dict(self, values: dict): self._auth_user = AuthUserDTO().from_dict(values["authUser"]) self._new_auth_user = AuthUserDTO().from_dict(values["newAuthUser"]) - self._change_password = ( - False if "changePassword" not in values else bool(values["changePassword"]) - ) + self._change_password = False if "changePassword" not in values else bool(values["changePassword"]) def to_dict(self) -> dict: return { diff --git a/bot/src/bot_api/route/route.py b/bot/src/bot_api/route/route.py index 3b0fbc96..a72b28e3 100644 --- a/bot/src/bot_api/route/route.py +++ b/bot/src/bot_api/route/route.py @@ -65,9 +65,7 @@ class Route: by_api_key=False, ): if f is None: - return functools.partial( - cls.authorize, role=role, skip_in_dev=skip_in_dev, by_api_key=by_api_key - ) + return functools.partial(cls.authorize, role=role, skip_in_dev=skip_in_dev, by_api_key=by_api_key) @wraps(f) async def decorator(*args, **kwargs): @@ -78,9 +76,7 @@ class Route: api_key = None if "Authorization" in request.headers: if " " not in request.headers.get("Authorization"): - ex = ServiceException( - ServiceErrorCode.Unauthorized, f"Token not set" - ) + ex = ServiceException(ServiceErrorCode.Unauthorized, f"Token not set") error = ErrorDTO(ex.error_code, ex.message) return jsonify(error.to_dict()), 401 @@ -102,9 +98,7 @@ class Route: return jsonify(e), 500 if not valid: - ex = ServiceException( - ServiceErrorCode.Unauthorized, f"API-Key invalid" - ) + ex = ServiceException(ServiceErrorCode.Unauthorized, f"API-Key invalid") error = ErrorDTO(ex.error_code, ex.message) return jsonify(error.to_dict()), 401 @@ -116,9 +110,7 @@ class Route: return jsonify(error.to_dict()), 401 if cls._auth_users is None or cls._auth is None: - ex = ServiceException( - ServiceErrorCode.Unauthorized, f"Authorize is not initialized" - ) + ex = ServiceException(ServiceErrorCode.Unauthorized, f"Authorize is not initialized") error = ErrorDTO(ex.error_code, ex.message) return jsonify(error.to_dict()), 401 @@ -140,9 +132,7 @@ class Route: return jsonify(error.to_dict()), 401 if role is not None and user.auth_role.value < role.value: - ex = ServiceException( - ServiceErrorCode.Unauthorized, f"Role {role} required" - ) + ex = ServiceException(ServiceErrorCode.Unauthorized, f"Role {role} required") error = ErrorDTO(ex.error_code, ex.message) return jsonify(error.to_dict()), 403 diff --git a/bot/src/bot_api/service/auth_service.py b/bot/src/bot_api/service/auth_service.py index ec93775e..94410b52 100644 --- a/bot/src/bot_api/service/auth_service.py +++ b/bot/src/bot_api/service/auth_service.py @@ -90,9 +90,7 @@ class AuthService(AuthServiceABC): def _get_api_key_str(self, api_key: ApiKey) -> str: return hashlib.sha256( - f"{api_key.identifier}:{api_key.key}+{self._auth_settings.secret_key}".encode( - "utf-8" - ) + f"{api_key.identifier}:{api_key.key}+{self._auth_settings.secret_key}".encode("utf-8") ).hexdigest() def generate_token(self, user: AuthUser) -> str: @@ -101,8 +99,7 @@ class AuthService(AuthServiceABC): "user_id": user.id, "email": user.email, "role": user.auth_role.value, - "exp": datetime.now(tz=timezone.utc) - + timedelta(days=self._auth_settings.token_expire_time), + "exp": datetime.now(tz=timezone.utc) + timedelta(days=self._auth_settings.token_expire_time), "iss": self._auth_settings.issuer, "aud": self._auth_settings.audience, }, @@ -158,9 +155,7 @@ class AuthService(AuthServiceABC): def _create_and_save_refresh_token(self, user: AuthUser) -> str: token = str(uuid.uuid4()) user.refresh_token = token - user.refresh_token_expire_time = datetime.now() + timedelta( - days=self._auth_settings.refresh_token_expire_time - ) + user.refresh_token_expire_time = datetime.now() + timedelta(days=self._auth_settings.refresh_token_expire_time) self._auth_users.update_auth_user(user) self._db.save_changes() return token @@ -193,12 +188,8 @@ class AuthService(AuthServiceABC): self._send_link_mail( user.email, - self._t.transform("api.auth.confirmation.subject").format( - user.first_name, user.last_name - ), - self._t.transform("api.auth.confirmation.message").format( - url, user.confirmation_id - ), + self._t.transform("api.auth.confirmation.subject").format(user.first_name, user.last_name), + self._t.transform("api.auth.confirmation.message").format(url, user.confirmation_id), ) def _send_forgot_password_id_to_user(self, user: AuthUser): @@ -208,38 +199,28 @@ class AuthService(AuthServiceABC): self._send_link_mail( user.email, - self._t.transform("api.auth.forgot_password.subject").format( - user.first_name, user.last_name - ), - self._t.transform("api.auth.forgot_password.message").format( - url, user.forgot_password_id - ), + self._t.transform("api.auth.forgot_password.subject").format(user.first_name, user.last_name), + self._t.transform("api.auth.forgot_password.message").format(url, user.forgot_password_id), ) async def get_all_auth_users_async(self) -> List[AuthUserDTO]: result = self._auth_users.get_all_auth_users().select(lambda x: AUT.to_dto(x)) return List(AuthUserDTO, result) - async def get_filtered_auth_users_async( - self, criteria: AuthUserSelectCriteria - ) -> AuthUserFilteredResultDTO: + async def get_filtered_auth_users_async(self, criteria: AuthUserSelectCriteria) -> AuthUserFilteredResultDTO: users = self._auth_users.get_filtered_auth_users(criteria) result = users.result.select(lambda x: AUT.to_dto(x)) return AuthUserFilteredResultDTO(List(AuthUserDTO, result), users.total_count) - async def get_auth_user_by_email_async( - self, email: str, with_password: bool = False - ) -> AuthUserDTO: + async def get_auth_user_by_email_async(self, email: str, with_password: bool = False) -> AuthUserDTO: try: # todo: check if logged in user is admin then send mail user = self._auth_users.get_auth_user_by_email(email) return AUT.to_dto(user, password=user.password if with_password else None) except Exception as e: self._logger.error(__name__, f"AuthUser not found", e) - raise ServiceException( - ServiceErrorCode.InvalidData, f"User not found {email}" - ) + raise ServiceException(ServiceErrorCode.InvalidData, f"User not found {email}") async def find_auth_user_by_email_async(self, email: str) -> Optional[AuthUser]: user = self._auth_users.find_auth_user_by_email(email) @@ -257,22 +238,16 @@ class AuthService(AuthServiceABC): user.password_salt = uuid.uuid4() user.password = self._hash_sha256(user_dto.password, user.password_salt) if not self._is_email_valid(user.email): - raise ServiceException( - ServiceErrorCode.InvalidData, "Invalid E-Mail address" - ) + raise ServiceException(ServiceErrorCode.InvalidData, "Invalid E-Mail address") try: user.confirmation_id = uuid.uuid4() self._auth_users.add_auth_user(user) self._send_confirmation_id_to_user(user) self._db.save_changes() - self._logger.info( - __name__, f"Added auth user with E-Mail: {user_dto.email}" - ) + self._logger.info(__name__, f"Added auth user with E-Mail: {user_dto.email}") except Exception as e: - self._logger.error( - __name__, f"Cannot add user with E-Mail {user_dto.email}", e - ) + self._logger.error(__name__, f"Cannot add user with E-Mail {user_dto.email}", e) raise ServiceException(ServiceErrorCode.UnableToAdd, "Invalid E-Mail") async def add_auth_user_by_oauth_async(self, dto: OAuthDTO): @@ -288,20 +263,14 @@ class AuthService(AuthServiceABC): db_user.first_name = dto.user.first_name db_user.last_name = dto.user.last_name db_user.password_salt = uuid.uuid4() - db_user.password = self._hash_sha256( - dto.user.password, db_user.password_salt - ) + db_user.password = self._hash_sha256(dto.user.password, db_user.password_salt) db_user.oauth_id = None db_user.confirmation_id = uuid.uuid4() self._send_confirmation_id_to_user(db_user) self._auth_users.update_auth_user(db_user) - self._logger.info( - __name__, f"Added auth user with E-Mail: {dto.user.email}" - ) + self._logger.info(__name__, f"Added auth user with E-Mail: {dto.user.email}") except Exception as e: - self._logger.error( - __name__, f"Cannot add user with E-Mail {dto.user.email}", e - ) + self._logger.error(__name__, f"Cannot add user with E-Mail {dto.user.email}", e) raise ServiceException(ServiceErrorCode.UnableToAdd, "Invalid E-Mail") self._db.save_changes() @@ -311,16 +280,14 @@ class AuthService(AuthServiceABC): raise ServiceException(ServiceErrorCode.InvalidData, f"User is empty") if update_user_dto.auth_user is None: - raise ServiceException( - ServiceErrorCode.InvalidData, f"Existing user is empty" - ) + raise ServiceException(ServiceErrorCode.InvalidData, f"Existing user is empty") if update_user_dto.new_auth_user is None: raise ServiceException(ServiceErrorCode.InvalidData, f"New user is empty") - if not self._is_email_valid( - update_user_dto.auth_user.email - ) or not self._is_email_valid(update_user_dto.new_auth_user.email): + if not self._is_email_valid(update_user_dto.auth_user.email) or not self._is_email_valid( + update_user_dto.new_auth_user.email + ): raise ServiceException(ServiceErrorCode.InvalidData, f"Invalid E-Mail") user = self._auth_users.find_auth_user_by_email(update_user_dto.auth_user.email) @@ -333,8 +300,7 @@ class AuthService(AuthServiceABC): # update first name if ( update_user_dto.new_auth_user.first_name is not None - and update_user_dto.auth_user.first_name - != update_user_dto.new_auth_user.first_name + and update_user_dto.auth_user.first_name != update_user_dto.new_auth_user.first_name ): user.first_name = update_user_dto.new_auth_user.first_name @@ -342,8 +308,7 @@ class AuthService(AuthServiceABC): if ( update_user_dto.new_auth_user.last_name is not None and update_user_dto.new_auth_user.last_name != "" - and update_user_dto.auth_user.last_name - != update_user_dto.new_auth_user.last_name + and update_user_dto.auth_user.last_name != update_user_dto.new_auth_user.last_name ): user.last_name = update_user_dto.new_auth_user.last_name @@ -353,33 +318,22 @@ class AuthService(AuthServiceABC): and update_user_dto.new_auth_user.email != "" and update_user_dto.auth_user.email != update_user_dto.new_auth_user.email ): - user_by_new_e_mail = self._auth_users.find_auth_user_by_email( - update_user_dto.new_auth_user.email - ) + user_by_new_e_mail = self._auth_users.find_auth_user_by_email(update_user_dto.new_auth_user.email) if user_by_new_e_mail is not None: - raise ServiceException( - ServiceErrorCode.InvalidUser, "User already exists" - ) + raise ServiceException(ServiceErrorCode.InvalidUser, "User already exists") user.email = update_user_dto.new_auth_user.email - update_user_dto.auth_user.password = self._hash_sha256( - update_user_dto.auth_user.password, user.password_salt - ) + update_user_dto.auth_user.password = self._hash_sha256(update_user_dto.auth_user.password, user.password_salt) if update_user_dto.auth_user.password != user.password: raise ServiceException(ServiceErrorCode.InvalidUser, "Wrong password") # update password if ( update_user_dto.new_auth_user.password is not None - and self._hash_sha256( - update_user_dto.new_auth_user.password, user.password_salt - ) - != user.password + and self._hash_sha256(update_user_dto.new_auth_user.password, user.password_salt) != user.password ): user.password_salt = uuid.uuid4() - user.password = self._hash_sha256( - update_user_dto.new_auth_user.password, user.password_salt - ) + user.password = self._hash_sha256(update_user_dto.new_auth_user.password, user.password_salt) self._auth_users.update_auth_user(user) self._db.save_changes() @@ -389,31 +343,23 @@ class AuthService(AuthServiceABC): raise ServiceException(ServiceErrorCode.InvalidData, f"User is empty") if update_user_dto.auth_user is None: - raise ServiceException( - ServiceErrorCode.InvalidData, f"Existing user is empty" - ) + raise ServiceException(ServiceErrorCode.InvalidData, f"Existing user is empty") if update_user_dto.new_auth_user is None: raise ServiceException(ServiceErrorCode.InvalidData, f"New user is empty") - if not self._is_email_valid( - update_user_dto.auth_user.email - ) or not self._is_email_valid(update_user_dto.new_auth_user.email): + if not self._is_email_valid(update_user_dto.auth_user.email) or not self._is_email_valid( + update_user_dto.new_auth_user.email + ): raise ServiceException(ServiceErrorCode.InvalidData, f"Invalid E-Mail") user = self._auth_users.find_auth_user_by_email(update_user_dto.auth_user.email) if user is None: raise ServiceException(ServiceErrorCode.InvalidUser, "User not found") - if ( - user.confirmation_id is not None - and update_user_dto.new_auth_user.is_confirmed - ): + if user.confirmation_id is not None and update_user_dto.new_auth_user.is_confirmed: user.confirmation_id = None - elif ( - user.confirmation_id is None - and not update_user_dto.new_auth_user.is_confirmed - ): + elif user.confirmation_id is None and not update_user_dto.new_auth_user.is_confirmed: user.confirmation_id = uuid.uuid4() # else # raise ServiceException(ServiceErrorCode.InvalidUser, 'E-Mail not confirmed') @@ -421,8 +367,7 @@ class AuthService(AuthServiceABC): # update first name if ( update_user_dto.new_auth_user.first_name is not None - and update_user_dto.auth_user.first_name - != update_user_dto.new_auth_user.first_name + and update_user_dto.auth_user.first_name != update_user_dto.new_auth_user.first_name ): user.first_name = update_user_dto.new_auth_user.first_name @@ -430,8 +375,7 @@ class AuthService(AuthServiceABC): if ( update_user_dto.new_auth_user.last_name is not None and update_user_dto.new_auth_user.last_name != "" - and update_user_dto.auth_user.last_name - != update_user_dto.new_auth_user.last_name + and update_user_dto.auth_user.last_name != update_user_dto.new_auth_user.last_name ): user.last_name = update_user_dto.new_auth_user.last_name @@ -441,28 +385,19 @@ class AuthService(AuthServiceABC): and update_user_dto.new_auth_user.email != "" and update_user_dto.auth_user.email != update_user_dto.new_auth_user.email ): - user_by_new_e_mail = self._auth_users.find_auth_user_by_email( - update_user_dto.new_auth_user.email - ) + user_by_new_e_mail = self._auth_users.find_auth_user_by_email(update_user_dto.new_auth_user.email) if user_by_new_e_mail is not None: - raise ServiceException( - ServiceErrorCode.InvalidUser, "User already exists" - ) + raise ServiceException(ServiceErrorCode.InvalidUser, "User already exists") user.email = update_user_dto.new_auth_user.email # update password if ( update_user_dto.new_auth_user.password is not None and update_user_dto.change_password - and user.password - != self._hash_sha256( - update_user_dto.new_auth_user.password, user.password_salt - ) + and user.password != self._hash_sha256(update_user_dto.new_auth_user.password, user.password_salt) ): user.password_salt = uuid.uuid4() - user.password = self._hash_sha256( - update_user_dto.new_auth_user.password, user.password_salt - ) + user.password = self._hash_sha256(update_user_dto.new_auth_user.password, user.password_salt) # update role if ( @@ -481,9 +416,7 @@ class AuthService(AuthServiceABC): self._db.save_changes() except Exception as e: self._logger.error(__name__, f"Cannot delete user", e) - raise ServiceException( - ServiceErrorCode.UnableToDelete, f"Cannot delete user by mail {email}" - ) + raise ServiceException(ServiceErrorCode.UnableToDelete, f"Cannot delete user by mail {email}") async def delete_auth_user_async(self, user_dto: AuthUser): try: @@ -567,9 +500,7 @@ class AuthService(AuthServiceABC): if user.id in user_ids: continue - self._auth_users.add_auth_user_user_rel( - AuthUserUsersRelation(db_user, user) - ) + self._auth_users.add_auth_user_user_rel(AuthUserUsersRelation(db_user, user)) if db_user.confirmation_id is not None and not added_user: raise ServiceException(ServiceErrorCode.Forbidden, "E-Mail not verified") @@ -599,19 +530,13 @@ class AuthService(AuthServiceABC): ): raise ServiceException(ServiceErrorCode.InvalidData, "Token expired") - return TokenDTO( - self.generate_token(user), self._create_and_save_refresh_token(user) - ) + return TokenDTO(self.generate_token(user), self._create_and_save_refresh_token(user)) except Exception as e: self._logger.error(__name__, f"Refreshing token failed", e) return TokenDTO("", "") async def revoke_async(self, token_dto: TokenDTO): - if ( - token_dto is None - or token_dto.token is None - or token_dto.refresh_token is None - ): + if token_dto is None or token_dto.token is None or token_dto.refresh_token is None: raise ServiceException(ServiceErrorCode.InvalidData, "Token not set") try: @@ -664,9 +589,7 @@ class AuthService(AuthServiceABC): ) if user.confirmation_id is not None: - raise ServiceException( - ServiceErrorCode.InvalidUser, f"E-Mail not confirmed" - ) + raise ServiceException(ServiceErrorCode.InvalidUser, f"E-Mail not confirmed") if user.password is None or rp_dto.password == "": raise ServiceException(ServiceErrorCode.InvalidData, f"Password not set") diff --git a/bot/src/bot_api/service/discord_service.py b/bot/src/bot_api/service/discord_service.py index 21e0df82..386b3046 100644 --- a/bot/src/bot_api/service/discord_service.py +++ b/bot/src/bot_api/service/discord_service.py @@ -53,17 +53,13 @@ class DiscordService: if role != AuthRoleEnum.admin: auth_user = self._auth_users.find_auth_user_by_email(token["email"]) if auth_user is not None: - user_ids = auth_user.users.select( - lambda x: x.server is not None and x.server.id - ) + user_ids = auth_user.users.select(lambda x: x.server is not None and x.server.id) servers = servers.where(lambda x: x.id in user_ids) servers = List(ServerDTO, servers) return servers.select(self._to_dto).where(lambda x: x.name != "") - async def get_filtered_servers_async( - self, criteria: ServerSelectCriteria - ) -> ServerFilteredResultDTO: + async def get_filtered_servers_async(self, criteria: ServerSelectCriteria) -> ServerFilteredResultDTO: token = self._auth.get_decoded_token_from_request() if token is None or "email" not in token or "role" not in token: raise ServiceException(ServiceErrorCode.InvalidData, "Token invalid") @@ -74,22 +70,15 @@ class DiscordService: if role != AuthRoleEnum.admin: auth_user = self._auth_users.find_auth_user_by_email(token["email"]) if auth_user is not None: - user_ids = auth_user.users.select( - lambda x: x.server is not None and x.server.id - ) - filtered_result.result = filtered_result.result.where( - lambda x: x.id in user_ids - ) + user_ids = auth_user.users.select(lambda x: x.server is not None and x.server.id) + filtered_result.result = filtered_result.result.where(lambda x: x.id in user_ids) - servers: List = filtered_result.result.select(self._to_dto).where( - lambda x: x.name != "" - ) + servers: List = filtered_result.result.select(self._to_dto).where(lambda x: x.name != "") result = List(ServerDTO, servers) if criteria.name is not None and criteria.name != "": result = result.where( - lambda x: criteria.name.lower() in x.name.lower() - or x.name.lower() == criteria.name.lower() + lambda x: criteria.name.lower() in x.name.lower() or x.name.lower() == criteria.name.lower() ) return ServerFilteredResultDTO(List(ServerDTO, result), servers.count()) @@ -98,7 +87,5 @@ class DiscordService: server = self._servers.get_server_by_id(id) guild = self._bot.get_guild(server.discord_id) - server_dto = ServerTransformer.to_dto( - server, guild.name, guild.member_count, guild.icon - ) + server_dto = ServerTransformer.to_dto(server, guild.name, guild.member_count, guild.icon) return server_dto diff --git a/bot/src/bot_api/transformer/auth_user_transformer.py b/bot/src/bot_api/transformer/auth_user_transformer.py index 83633520..9e52fec3 100644 --- a/bot/src/bot_api/transformer/auth_user_transformer.py +++ b/bot/src/bot_api/transformer/auth_user_transformer.py @@ -27,35 +27,27 @@ class AuthUserTransformer(TransformerABC): None, None, datetime.now(), - AuthRoleEnum.normal - if dto.auth_role is None - else AuthRoleEnum(dto.auth_role), + AuthRoleEnum.normal if dto.auth_role is None else AuthRoleEnum(dto.auth_role), auth_user_id=0 if dto.id is None else dto.id, ) @staticmethod @ServiceProviderABC.inject - def _is_technician( - user: User, bot: DiscordBotServiceABC, permissions: PermissionServiceABC - ): + def _is_technician(user: User, bot: DiscordBotServiceABC, permissions: PermissionServiceABC): guild = bot.get_guild(user.server.discord_id) member = guild.get_member(user.discord_id) return permissions.is_member_technician(member) @staticmethod @ServiceProviderABC.inject - def _is_admin( - user: User, bot: DiscordBotServiceABC, permissions: PermissionServiceABC - ): + def _is_admin(user: User, bot: DiscordBotServiceABC, permissions: PermissionServiceABC): guild = bot.get_guild(user.server.discord_id) member = guild.get_member(user.discord_id) return permissions.is_member_admin(member) @staticmethod @ServiceProviderABC.inject - def _is_moderator( - user: User, bot: DiscordBotServiceABC, permissions: PermissionServiceABC - ): + def _is_moderator(user: User, bot: DiscordBotServiceABC, permissions: PermissionServiceABC): guild = bot.get_guild(user.server.discord_id) member = guild.get_member(user.discord_id) return permissions.is_member_moderator(member) diff --git a/bot/src/bot_api/transformer/server_transformer.py b/bot/src/bot_api/transformer/server_transformer.py index f4ca5d6f..bffba8e1 100644 --- a/bot/src/bot_api/transformer/server_transformer.py +++ b/bot/src/bot_api/transformer/server_transformer.py @@ -13,9 +13,7 @@ class ServerTransformer(TransformerABC): return Server(dto.discord_id) @staticmethod - def to_dto( - db: Server, name: str, member_count: int, icon_url: Optional[discord.Asset] - ) -> ServerDTO: + def to_dto(db: Server, name: str, member_count: int, icon_url: Optional[discord.Asset]) -> ServerDTO: return ServerDTO( db.id, db.discord_id, diff --git a/bot/src/bot_core/abc/client_utils_abc.py b/bot/src/bot_core/abc/client_utils_abc.py index 9dd50401..fdcf5118 100644 --- a/bot/src/bot_core/abc/client_utils_abc.py +++ b/bot/src/bot_core/abc/client_utils_abc.py @@ -45,9 +45,7 @@ class ClientUtilsABC(ABC): pass @abstractmethod - def get_auto_complete_list( - self, _l: List, current: str, select: Callable = None - ) -> List: + def get_auto_complete_list(self, _l: List, current: str, select: Callable = None) -> List: pass @abstractmethod diff --git a/bot/src/bot_core/abc/custom_file_logger_abc.py b/bot/src/bot_core/abc/custom_file_logger_abc.py index 670b90e6..2b2bbe0a 100644 --- a/bot/src/bot_core/abc/custom_file_logger_abc.py +++ b/bot/src/bot_core/abc/custom_file_logger_abc.py @@ -18,9 +18,7 @@ class CustomFileLoggerABC(Logger, ABC): env: ApplicationEnvironmentABC, ): self._key = key - self._settings: LoggingSettings = config.get_configuration( - f"{FileLoggingSettings.__name__}_{key}" - ) + self._settings: LoggingSettings = config.get_configuration(f"{FileLoggingSettings.__name__}_{key}") Logger.__init__(self, self._settings, time_format, env) self._begin_log() @@ -34,9 +32,7 @@ class CustomFileLoggerABC(Logger, ABC): self.info(__name__, f"Starting...") self._console = LoggingLevelEnum(console_level) - def _get_string( - self, name_list_as_str: str, level: LoggingLevelEnum, message: str - ) -> str: + def _get_string(self, name_list_as_str: str, level: LoggingLevelEnum, message: str) -> str: names = name_list_as_str.split(" ") log_level = level.name string = f"<{self._get_datetime_now()}> [ {log_level} ]" diff --git a/bot/src/bot_core/abc/message_service_abc.py b/bot/src/bot_core/abc/message_service_abc.py index 019c8b6a..3dada9a3 100644 --- a/bot/src/bot_core/abc/message_service_abc.py +++ b/bot/src/bot_core/abc/message_service_abc.py @@ -13,9 +13,7 @@ class MessageServiceABC(ABC): pass @abstractmethod - async def delete_messages( - self, messages: List[discord.Message], guild_id: int, without_tracking=False - ): + async def delete_messages(self, messages: List[discord.Message], guild_id: int, without_tracking=False): pass @abstractmethod diff --git a/bot/src/bot_core/abc/task_abc.py b/bot/src/bot_core/abc/task_abc.py index bb684d8e..d068fd37 100644 --- a/bot/src/bot_core/abc/task_abc.py +++ b/bot/src/bot_core/abc/task_abc.py @@ -15,9 +15,7 @@ class TaskABC(commands.Cog): commands.Cog.__init__(self) @ServiceProviderABC.inject - async def _wait_until_ready( - self, config: ConfigurationABC, logger: TaskLogger, bot: DiscordBotServiceABC - ): + async def _wait_until_ready(self, config: ConfigurationABC, logger: TaskLogger, bot: DiscordBotServiceABC): logger.debug(__name__, f"Waiting before {type(self).__name__}") await bot.wait_until_ready() diff --git a/bot/src/bot_core/configuration/file_logging_settings.py b/bot/src/bot_core/configuration/file_logging_settings.py index 1e694363..46028aa5 100644 --- a/bot/src/bot_core/configuration/file_logging_settings.py +++ b/bot/src/bot_core/configuration/file_logging_settings.py @@ -10,9 +10,7 @@ class FileLoggingSettings(LoggingSettings): console_log_level: LoggingLevelEnum = None, file_log_level: LoggingLevelEnum = None, ): - LoggingSettings.__init__( - self, path, filename, console_log_level, file_log_level - ) + LoggingSettings.__init__(self, path, filename, console_log_level, file_log_level) self._key = key diff --git a/bot/src/bot_core/core_extension/core_extension.py b/bot/src/bot_core/core_extension/core_extension.py index ede39c5c..de5a1781 100644 --- a/bot/src/bot_core/core_extension/core_extension.py +++ b/bot/src/bot_core/core_extension/core_extension.py @@ -17,9 +17,7 @@ class CoreExtension(ApplicationExtensionABC): ApplicationExtensionABC.__init__(self) async def run(self, config: ConfigurationABC, services: ServiceProviderABC): - feature_flags: FeatureFlagsSettings = config.get_configuration( - FeatureFlagsSettings - ) + feature_flags: FeatureFlagsSettings = config.get_configuration(FeatureFlagsSettings) if not feature_flags.get_flag(FeatureFlagsEnum.core_module): return diff --git a/bot/src/bot_core/core_extension/core_extension_module.py b/bot/src/bot_core/core_extension/core_extension_module.py index e780a721..ef16529f 100644 --- a/bot/src/bot_core/core_extension/core_extension_module.py +++ b/bot/src/bot_core/core_extension/core_extension_module.py @@ -15,14 +15,8 @@ class CoreExtensionModule(ModuleABC): def __init__(self, dc: DiscordCollectionABC): ModuleABC.__init__(self, dc, FeatureFlagsEnum.core_extension_module) - def configure_configuration( - self, config: ConfigurationABC, env: ApplicationEnvironmentABC - ): + def configure_configuration(self, config: ConfigurationABC, env: ApplicationEnvironmentABC): pass - def configure_services( - self, services: ServiceCollectionABC, env: ApplicationEnvironmentABC - ): - services.add_transient( - DiscordEventTypesEnum.on_ready.value, CoreExtensionOnReadyEvent - ) + def configure_services(self, services: ServiceCollectionABC, env: ApplicationEnvironmentABC): + services.add_transient(DiscordEventTypesEnum.on_ready.value, CoreExtensionOnReadyEvent) diff --git a/bot/src/bot_core/core_module.py b/bot/src/bot_core/core_module.py index def17448..02611684 100644 --- a/bot/src/bot_core/core_module.py +++ b/bot/src/bot_core/core_module.py @@ -20,14 +20,10 @@ class CoreModule(ModuleABC): def __init__(self, dc: DiscordCollectionABC): ModuleABC.__init__(self, dc, FeatureFlagsEnum.core_module) - def configure_configuration( - self, config: ConfigurationABC, env: ApplicationEnvironmentABC - ): + def configure_configuration(self, config: ConfigurationABC, env: ApplicationEnvironmentABC): pass - def configure_services( - self, services: ServiceCollectionABC, env: ApplicationEnvironmentABC - ): + def configure_services(self, services: ServiceCollectionABC, env: ApplicationEnvironmentABC): services.add_transient(ConfigService) services.add_transient(MessageServiceABC, MessageService) services.add_transient(ClientUtilsABC, ClientUtilsService) diff --git a/bot/src/bot_core/helper/command_checks.py b/bot/src/bot_core/helper/command_checks.py index b6e6672c..e2048409 100644 --- a/bot/src/bot_core/helper/command_checks.py +++ b/bot/src/bot_core/helper/command_checks.py @@ -44,9 +44,7 @@ class CommandChecks: async def check_is_member_admin(ctx: Context): has_permission = cls._permissions.is_member_admin(ctx.author) if not has_permission: - await cls._message_service.send_ctx_msg( - ctx, cls._t.transform("common.no_permission_message") - ) + await cls._message_service.send_ctx_msg(ctx, cls._t.transform("common.no_permission_message")) raise CheckError(f"Member {ctx.author.name} is not admin") return has_permission @@ -58,9 +56,7 @@ class CommandChecks: async def check_is_member_technician(ctx: Context): has_permission = cls._permissions.is_member_technician(ctx.author) if not has_permission: - await cls._message_service.send_ctx_msg( - ctx, cls._t.transform("common.no_permission_message") - ) + await cls._message_service.send_ctx_msg(ctx, cls._t.transform("common.no_permission_message")) raise CheckError(f"Member {ctx.author.name} is not technician") return has_permission @@ -72,9 +68,7 @@ class CommandChecks: async def check_is_member_moderator(ctx: Context): has_permission = cls._permissions.is_member_moderator(ctx.author) if not has_permission: - await cls._message_service.send_ctx_msg( - ctx, cls._t.transform("common.no_permission_message") - ) + await cls._message_service.send_ctx_msg(ctx, cls._t.transform("common.no_permission_message")) raise CheckError(f"Member {ctx.author.name} is not moderator") return has_permission diff --git a/bot/src/bot_core/service/client_utils_service.py b/bot/src/bot_core/service/client_utils_service.py index b215386c..e0272390 100644 --- a/bot/src/bot_core/service/client_utils_service.py +++ b/bot/src/bot_core/service/client_utils_service.py @@ -62,36 +62,28 @@ class ClientUtilsService(ClientUtilsABC): def received_command(self, guild_id: int): server = self._servers.get_server_by_discord_id(guild_id) - client = self._clients.find_client_by_discord_id_and_server_id( - self._bot.user.id, server.id - ) + client = self._clients.find_client_by_discord_id_and_server_id(self._bot.user.id, server.id) client.received_command_count += 1 self._clients.update_client(client) self._db.save_changes() def moved_user(self, guild_id: int): server = self._servers.get_server_by_discord_id(guild_id) - client = self._clients.find_client_by_discord_id_and_server_id( - self._bot.user.id, server.id - ) + client = self._clients.find_client_by_discord_id_and_server_id(self._bot.user.id, server.id) client.moved_users_count += 1 self._clients.update_client(client) self._db.save_changes() def moved_users(self, guild_id: int, count: int): server = self._servers.get_server_by_discord_id(guild_id) - client = self._clients.find_client_by_discord_id_and_server_id( - self._bot.user.id, server.id - ) + client = self._clients.find_client_by_discord_id_and_server_id(self._bot.user.id, server.id) client.moved_users_count += count self._clients.update_client(client) self._db.save_changes() def get_client(self, dc_ic: int, guild_id: int): server = self._servers.get_server_by_discord_id(guild_id) - client = self._clients.find_client_by_discord_id_and_server_id( - self._bot.user.id, server.id - ) + client = self._clients.find_client_by_discord_id_and_server_id(self._bot.user.id, server.id) return client async def check_if_bot_is_ready_yet(self) -> bool: @@ -129,9 +121,7 @@ class ClientUtilsService(ClientUtilsABC): await self._bot.change_presence(activity=discord.Game(name=name)) self._logger.info(__name__, f"Set presence {name}") - def get_auto_complete_list( - self, _l: List, current: str, select: Callable = None - ) -> List: + def get_auto_complete_list(self, _l: List, current: str, select: Callable = None) -> List: if current != "": if select is None: select = lambda x: x @@ -154,9 +144,7 @@ class ClientUtilsService(ClientUtilsABC): ) -> bool: umcph = None try: - umcph = self._umcphs.find_user_message_count_per_hour_by_user_id_and_date( - user.id, created_at - ) + umcph = self._umcphs.find_user_message_count_per_hour_by_user_id_and_date(user.id, created_at) if umcph is None: self._umcphs.add_user_message_count_per_hour( UserMessageCountPerHour( @@ -169,11 +157,7 @@ class ClientUtilsService(ClientUtilsABC): self._db.save_changes() - umcph = ( - self._umcphs.get_user_message_count_per_hour_by_user_id_and_date( - user.id, created_at - ) - ) + umcph = self._umcphs.get_user_message_count_per_hour_by_user_id_and_date(user.id, created_at) except Exception as e: self._logger.error( __name__, @@ -205,9 +189,7 @@ class ClientUtilsService(ClientUtilsABC): def get_ontime_for_user(self, user: User) -> float: return round( - self._user_joined_voice_channel.get_user_joined_voice_channels_by_user_id( - user.id - ) + self._user_joined_voice_channel.get_user_joined_voice_channels_by_user_id(user.id) .where(lambda x: x.leaved_on is not None and x.joined_on is not None) .sum(lambda join: (join.leaved_on - join.joined_on).total_seconds() / 3600), 2, @@ -224,11 +206,7 @@ class ClientUtilsService(ClientUtilsABC): guild: Guild = self._bot.guilds.where(lambda g: g == guild).single() channel = guild.get_channel(discord_channel_id) message = await channel.fetch_message(discord_message_id) - emoji = ( - List(discord.Emoji, guild.emojis) - .where(lambda x: x.name == rule.emoji_name) - .single() - ) + emoji = List(discord.Emoji, guild.emojis).where(lambda x: x.name == rule.emoji_name).single() if emoji is None: self._logger.debug(__name__, f"Emoji {rule.emoji_name} not found") @@ -248,9 +226,7 @@ class ClientUtilsService(ClientUtilsABC): 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}" - ) + settings: ServerConfig = self._config.get_configuration(f"ServerConfig_{server.discord_id}") if settings.default_role_id is None: return @@ -262,6 +238,4 @@ class ClientUtilsService(ClientUtilsABC): 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 - ) + self._logger.error(__name__, f"Cannot check for default role for member {member.id}", e) diff --git a/bot/src/bot_core/service/data_integrity_service.py b/bot/src/bot_core/service/data_integrity_service.py index f7090636..fc044a9d 100644 --- a/bot/src/bot_core/service/data_integrity_service.py +++ b/bot/src/bot_core/service/data_integrity_service.py @@ -67,16 +67,12 @@ class DataIntegrityService: self._is_for_shutdown = False def _check_known_users(self): - self._logger.debug( - __name__, f"Start checking KnownUsers table, {len(self._bot.users)}" - ) + self._logger.debug(__name__, f"Start checking KnownUsers table, {len(self._bot.users)}") for u in self._bot.users: u: discord.User = u try: if u.bot: - self._logger.trace( - __name__, f"User {u.id} is ignored, because its a bot" - ) + self._logger.trace(__name__, f"User {u.id} is ignored, because its a bot") continue user = self._known_users.find_user_by_discord_id(u.id) @@ -129,9 +125,7 @@ class DataIntegrityService: try: server: Server = self._servers.find_server_by_discord_id(g.id) if server is None: - self._logger.fatal( - __name__, f"Server not found in database: {g.id}" - ) + self._logger.fatal(__name__, f"Server not found in database: {g.id}") client = self._clients.find_client_by_server_id(server.id) if client is not None: @@ -142,9 +136,7 @@ class DataIntegrityService: f"Client for server {g.id} not found in database: {self._bot.user.id}", ) self._logger.debug(__name__, f"Add client: {self._bot.user.id}") - self._clients.add_client( - Client(self._bot.user.id, 0, 0, 0, 0, 0, server) - ) + self._clients.add_client(Client(self._bot.user.id, 0, 0, 0, 0, 0, server)) self._db_context.save_changes() client = self._clients.find_client_by_server_id(server.id) @@ -170,21 +162,15 @@ class DataIntegrityService: try: server = self._servers.find_server_by_discord_id(g.id) if server is None: - self._logger.fatal( - __name__, f"Server not found in database: {g.id}" - ) + self._logger.fatal(__name__, f"Server not found in database: {g.id}") for u in g.members: u: Union[discord.Member, discord.User] = u if u.bot: - self._logger.trace( - __name__, f"User {u.id} is ignored, because its a bot" - ) + self._logger.trace(__name__, f"User {u.id} is ignored, because its a bot") continue - user = self._users.find_user_by_discord_id_and_server_id( - u.id, server.id - ) + user = self._users.find_user_by_discord_id_and_server_id(u.id, server.id) if user is not None: continue @@ -208,30 +194,20 @@ class DataIntegrityService: server = self._servers.find_server_by_discord_id(guild.id) if server is None: - self._logger.fatal( - __name__, f"Server not found in database: {guild.id}" - ) + self._logger.fatal(__name__, f"Server not found in database: {guild.id}") try: for u in guild.members: u: discord.User = u if u.bot: - self._logger.trace( - __name__, f"User {u.id} is ignored, because its a bot" - ) + self._logger.trace(__name__, f"User {u.id} is ignored, because its a bot") continue - user = self._users.find_user_by_discord_id_and_server_id( - u.id, server.id - ) + user = self._users.find_user_by_discord_id_and_server_id(u.id, server.id) if user is None: - self._logger.fatal( - __name__, f"User not found in database: {u.id}" - ) + self._logger.fatal(__name__, f"User not found in database: {u.id}") - join = self._user_joins.find_active_user_joined_server_by_user_id( - user.id - ) + join = self._user_joins.find_active_user_joined_server_by_user_id(user.id) if join is not None: continue @@ -281,36 +257,24 @@ class DataIntegrityService: self._logger.debug(__name__, f"Start checking UserJoinedVoiceChannel table") for guild in self._bot.guilds: guild: discord.Guild = guild - settings: ServerConfig = self._config.get_configuration( - f"ServerConfig_{guild.id}" - ) + settings: ServerConfig = self._config.get_configuration(f"ServerConfig_{guild.id}") server = self._servers.find_server_by_discord_id(guild.id) if server is None: - self._logger.fatal( - __name__, f"Server not found in database: {guild.id}" - ) + self._logger.fatal(__name__, f"Server not found in database: {guild.id}") try: # close open voice states for member in guild.members: if member.bot: - self._logger.trace( - __name__, f"User {member.id} is ignored, because its a bot" - ) + self._logger.trace(__name__, f"User {member.id} is ignored, because its a bot") continue - user = self._users.find_user_by_discord_id_and_server_id( - member.id, server.id - ) + user = self._users.find_user_by_discord_id_and_server_id(member.id, server.id) if user is None: - self._logger.fatal( - __name__, f"User not found in database: {member.id}" - ) + self._logger.fatal(__name__, f"User not found in database: {member.id}") - joins = self._user_joins_vc.find_active_user_joined_voice_channels_by_user_id( - user.id - ) + joins = self._user_joins_vc.find_active_user_joined_voice_channels_by_user_id(user.id) if joins is None or len(joins) == 0: continue @@ -324,9 +288,7 @@ class DataIntegrityService: if ( (join.leaved_on - join.joined_on).total_seconds() / 60 / 60 ) > settings.max_voice_state_hours: - join.leaved_on = join.joined_on + timedelta( - hours=settings.max_voice_state_hours - ) + join.leaved_on = join.joined_on + timedelta(hours=settings.max_voice_state_hours) self._user_joins_vc.update_user_joined_voice_channel(join) @@ -341,28 +303,17 @@ class DataIntegrityService: # add open voice states for member in guild.members: if member.bot: - self._logger.trace( - __name__, f"User {member.id} is ignored, because its a bot" - ) + self._logger.trace(__name__, f"User {member.id} is ignored, because its a bot") continue - if ( - member.voice is None - or member.voice.channel.id in settings.afk_channel_ids - ): + if member.voice is None or member.voice.channel.id in settings.afk_channel_ids: continue - user = self._users.find_user_by_discord_id_and_server_id( - member.id, server.id - ) + user = self._users.find_user_by_discord_id_and_server_id(member.id, server.id) if user is None: - self._logger.fatal( - __name__, f"User not found in database: {member.id}" - ) + self._logger.fatal(__name__, f"User not found in database: {member.id}") - join = UserJoinedVoiceChannel( - user, member.voice.channel.id, datetime.now() - ) + join = UserJoinedVoiceChannel(user, member.voice.channel.id, datetime.now()) self._user_joins_vc.add_user_joined_voice_channel(join) self._db_context.save_changes() @@ -376,29 +327,19 @@ class DataIntegrityService: server = self._servers.find_server_by_discord_id(guild.id) if server is None: - self._logger.fatal( - __name__, f"Server not found in database: {guild.id}" - ) + self._logger.fatal(__name__, f"Server not found in database: {guild.id}") try: for member in guild.members: if member.bot: - self._logger.trace( - __name__, f"User {member.id} is ignored, because its a bot" - ) + self._logger.trace(__name__, f"User {member.id} is ignored, because its a bot") continue - user = self._users.find_user_by_discord_id_and_server_id( - member.id, server.id - ) + user = self._users.find_user_by_discord_id_and_server_id(member.id, server.id) if user is None: - self._logger.fatal( - __name__, f"User not found in database: {member.id}" - ) + self._logger.fatal(__name__, f"User not found in database: {member.id}") - joins = self._user_joined_gs.find_active_user_joined_game_servers_by_user_id( - user.id - ) + joins = self._user_joined_gs.find_active_user_joined_game_servers_by_user_id(user.id) if joins is None or len(joins) == 0: continue @@ -408,16 +349,12 @@ class DataIntegrityService: f"Active UserJoinedGameServer found in database: {guild.id}:{member.id}@{join.joined_on}", ) join.leaved_on = datetime.now() - settings: ServerConfig = self._config.get_configuration( - f"ServerConfig_{guild.id}" - ) + settings: ServerConfig = self._config.get_configuration(f"ServerConfig_{guild.id}") if ( (join.leaved_on - join.joined_on).total_seconds() / 60 / 60 ) > settings.max_voice_state_hours: - join.leaved_on = join.joined_on + timedelta( - hours=settings.max_voice_state_hours - ) + join.leaved_on = join.joined_on + timedelta(hours=settings.max_voice_state_hours) self._user_joined_gs.update_user_joined_game_server(join) if self._is_for_shutdown: @@ -434,24 +371,16 @@ class DataIntegrityService: for guild in self._bot.guilds: server = self._servers.find_server_by_discord_id(guild.id) if server is None: - self._logger.fatal( - __name__, f"Server not found in database: {guild.id}" - ) + self._logger.fatal(__name__, f"Server not found in database: {guild.id}") for member in guild.members: if member.bot: - self._logger.trace( - __name__, f"User {member.id} is ignored, because its a bot" - ) + self._logger.trace(__name__, f"User {member.id} is ignored, because its a bot") continue - user = self._users.find_user_by_discord_id_and_server_id( - member.id, server.id - ) + user = self._users.find_user_by_discord_id_and_server_id(member.id, server.id) if user is None: - self._logger.fatal( - __name__, f"User not found in database: {member.id}" - ) + self._logger.fatal(__name__, f"User not found in database: {member.id}") await self._achievements.validate_achievements_for_user(user) diff --git a/bot/src/bot_core/service/message_service.py b/bot/src/bot_core/service/message_service.py index 060d5495..9140742f 100644 --- a/bot/src/bot_core/service/message_service.py +++ b/bot/src/bot_core/service/message_service.py @@ -31,23 +31,15 @@ class MessageService(MessageServiceABC): self._clients = clients self._db = db - async def delete_messages( - self, messages: List[discord.Message], guild_id: int, without_tracking=False - ): + async def delete_messages(self, messages: List[discord.Message], guild_id: int, without_tracking=False): self._logger.debug(__name__, f"Try to delete {messages.count()} messages") - server_st: ServerConfig = self._config.get_configuration( - f"ServerConfig_{guild_id}" - ) + server_st: ServerConfig = self._config.get_configuration(f"ServerConfig_{guild_id}") await asyncio.sleep(server_st.message_delete_timer) for message in messages: - await self.delete_message( - message, mass_delete=True, without_tracking=without_tracking - ) + await self.delete_message(message, mass_delete=True, without_tracking=without_tracking) self._logger.debug(__name__, "Deleting messages finished") - async def delete_message( - self, message: discord.Message, mass_delete=False, without_tracking=False - ): + async def delete_message(self, message: discord.Message, mass_delete=False, without_tracking=False): guild_id = ( message.guild.id if message.guild is not None @@ -58,9 +50,7 @@ class MessageService(MessageServiceABC): else None ) - server_st: ServerConfig = self._config.get_configuration( - f"ServerConfig_{guild_id}" - ) + server_st: ServerConfig = self._config.get_configuration(f"ServerConfig_{guild_id}") if not mass_delete: await asyncio.sleep(server_st.message_delete_timer) self._logger.debug( @@ -74,9 +64,7 @@ class MessageService(MessageServiceABC): self._logger.error(__name__, f"Deleting message failed", e) else: if not without_tracking: - self._clients.append_deleted_message_count( - self._bot.user.id, guild_id, 1 - ) + self._clients.append_deleted_message_count(self._bot.user.id, guild_id, 1) self._db.save_changes() self._logger.info(__name__, f"Deleted message {message}") @@ -88,9 +76,7 @@ class MessageService(MessageServiceABC): wait_before_delete: int = None, without_tracking=False, ): - self._logger.debug( - __name__, f"Try to send message\n\t{message}\n\tto: {channel}" - ) + self._logger.debug(__name__, f"Try to send message\n\t{message}\n\tto: {channel}") msg = None try: if isinstance(message, discord.Embed): @@ -100,15 +86,11 @@ class MessageService(MessageServiceABC): else: msg = await channel.send(message) except Exception as e: - self._logger.error( - __name__, f"Send message to channel {channel.id} failed", e - ) + self._logger.error(__name__, f"Send message to channel {channel.id} failed", e) else: self._logger.info(__name__, f"Sent message to channel {channel.id}") if not without_tracking: - self._clients.append_sent_message_count( - self._bot.user.id, channel.guild.id, 1 - ) + self._clients.append_sent_message_count(self._bot.user.id, channel.guild.id, 1) self._db.save_changes() if wait_before_delete is not None: @@ -125,23 +107,17 @@ class MessageService(MessageServiceABC): receiver: Union[discord.User, discord.Member], without_tracking=False, ): - self._logger.debug( - __name__, f"Try to send message\n\t{message}\n\tto: {receiver}" - ) + self._logger.debug(__name__, f"Try to send message\n\t{message}\n\tto: {receiver}") try: if isinstance(message, discord.Embed): msg = await receiver.send(embed=message) else: msg = await receiver.send(message) except Exception as e: - self._logger.error( - __name__, f"Send message to user {receiver.id} failed", e - ) + self._logger.error(__name__, f"Send message to user {receiver.id} failed", e) else: if not without_tracking: - self._clients.append_sent_message_count( - self._bot.user.id, receiver.guild.id, 1 - ) + self._clients.append_sent_message_count(self._bot.user.id, receiver.guild.id, 1) self._db.save_changes() self._logger.info(__name__, f"Sent message to user {receiver.id}") @@ -160,9 +136,7 @@ class MessageService(MessageServiceABC): self._logger.debug(__name__, f"Message: {message}") return None - self._logger.debug( - __name__, f"Try to send message\t\t{message}\n\tto: {ctx.channel}" - ) + self._logger.debug(__name__, f"Try to send message\t\t{message}\n\tto: {ctx.channel}") msg = None try: if isinstance(message, discord.Embed): @@ -170,15 +144,11 @@ class MessageService(MessageServiceABC): else: msg = await ctx.send(message, file=file, ephemeral=not is_public) except Exception as e: - self._logger.error( - __name__, f"Send message to channel {ctx.channel.id} failed", e - ) + self._logger.error(__name__, f"Send message to channel {ctx.channel.id} failed", e) else: self._logger.info(__name__, f"Sent message to channel {ctx.channel.id}") if not without_tracking and ctx.guild is not None: - self._clients.append_sent_message_count( - self._bot.user.id, ctx.guild.id, 1 - ) + self._clients.append_sent_message_count(self._bot.user.id, ctx.guild.id, 1) self._db.save_changes() if wait_before_delete is not None: @@ -207,30 +177,18 @@ class MessageService(MessageServiceABC): self._logger.debug(__name__, f"Message: {message}") return - self._logger.debug( - __name__, f"Try to send message\t\t{message}\n\tto: {interaction.channel}" - ) + self._logger.debug(__name__, f"Try to send message\t\t{message}\n\tto: {interaction.channel}") try: if isinstance(message, discord.Embed): - await interaction.response.send_message( - embed=message, ephemeral=not is_public, **kwargs - ) + await interaction.response.send_message(embed=message, ephemeral=not is_public, **kwargs) else: - await interaction.response.send_message( - message, ephemeral=not is_public, **kwargs - ) + await interaction.response.send_message(message, ephemeral=not is_public, **kwargs) except Exception as e: - self._logger.error( - __name__, f"Send message to channel {interaction.channel.id} failed", e - ) + self._logger.error(__name__, f"Send message to channel {interaction.channel.id} failed", e) else: - self._logger.info( - __name__, f"Sent message to channel {interaction.channel.id}" - ) + self._logger.info(__name__, f"Sent message to channel {interaction.channel.id}") if not without_tracking and interaction.guild is not None: - self._clients.append_sent_message_count( - self._bot.user.id, interaction.guild.id, 1 - ) + self._clients.append_sent_message_count(self._bot.user.id, interaction.guild.id, 1) self._db.save_changes() if wait_before_delete is not None: @@ -239,6 +197,4 @@ class MessageService(MessageServiceABC): if is_persistent: return - await self.delete_message( - await interaction.original_response(), without_tracking - ) + await self.delete_message(await interaction.original_response(), without_tracking) diff --git a/bot/src/bot_data/abc/achievement_repository_abc.py b/bot/src/bot_data/abc/achievement_repository_abc.py index e1cc6c4e..ff3014fe 100644 --- a/bot/src/bot_data/abc/achievement_repository_abc.py +++ b/bot/src/bot_data/abc/achievement_repository_abc.py @@ -28,9 +28,7 @@ class AchievementRepositoryABC(ABC): pass @abstractmethod - def get_user_got_achievements_by_achievement_id( - self, achievement_id: int - ) -> List[Achievement]: + def get_user_got_achievements_by_achievement_id(self, achievement_id: int) -> List[Achievement]: pass @abstractmethod diff --git a/bot/src/bot_data/abc/auth_user_repository_abc.py b/bot/src/bot_data/abc/auth_user_repository_abc.py index 0dc7eeaf..9d9b06ec 100644 --- a/bot/src/bot_data/abc/auth_user_repository_abc.py +++ b/bot/src/bot_data/abc/auth_user_repository_abc.py @@ -23,9 +23,7 @@ class AuthUserRepositoryABC(ABC): pass @abstractmethod - def get_filtered_auth_users( - self, criteria: AuthUserSelectCriteria - ) -> FilteredResult: + def get_filtered_auth_users(self, criteria: AuthUserSelectCriteria) -> FilteredResult: pass @abstractmethod diff --git a/bot/src/bot_data/abc/client_repository_abc.py b/bot/src/bot_data/abc/client_repository_abc.py index 40cf8033..3b9f9132 100644 --- a/bot/src/bot_data/abc/client_repository_abc.py +++ b/bot/src/bot_data/abc/client_repository_abc.py @@ -36,9 +36,7 @@ class ClientRepositoryABC(ABC): pass @abstractmethod - def find_client_by_discord_id_and_server_id( - self, discord_id: int, server_id: int - ) -> Optional[Client]: + def find_client_by_discord_id_and_server_id(self, discord_id: int, server_id: int) -> Optional[Client]: pass @abstractmethod diff --git a/bot/src/bot_data/abc/server_config_repository_abc.py b/bot/src/bot_data/abc/server_config_repository_abc.py index 6a5cd127..f66fdc89 100644 --- a/bot/src/bot_data/abc/server_config_repository_abc.py +++ b/bot/src/bot_data/abc/server_config_repository_abc.py @@ -35,37 +35,25 @@ class ServerConfigRepositoryABC(ABC): pass @abstractmethod - def add_server_team_role_id_config( - self, server_team_role_id: ServerTeamRoleIdsConfig - ): + def add_server_team_role_id_config(self, server_team_role_id: ServerTeamRoleIdsConfig): pass @abstractmethod - def update_server_team_role_id_config( - self, server_team_role_id: ServerTeamRoleIdsConfig - ): + def update_server_team_role_id_config(self, server_team_role_id: ServerTeamRoleIdsConfig): pass @abstractmethod - def delete_server_team_role_id_config( - self, server_team_role_id: ServerTeamRoleIdsConfig - ): + def delete_server_team_role_id_config(self, server_team_role_id: ServerTeamRoleIdsConfig): pass @abstractmethod - def add_server_afk_channel_config( - self, server_afk_channel: ServerAFKChannelIdsConfig - ): + def add_server_afk_channel_config(self, server_afk_channel: ServerAFKChannelIdsConfig): pass @abstractmethod - def update_server_afk_channel_config( - self, server_afk_channel: ServerAFKChannelIdsConfig - ): + def update_server_afk_channel_config(self, server_afk_channel: ServerAFKChannelIdsConfig): pass @abstractmethod - def delete_server_afk_channel_config( - self, server_afk_channel: ServerAFKChannelIdsConfig - ): + def delete_server_afk_channel_config(self, server_afk_channel: ServerAFKChannelIdsConfig): pass diff --git a/bot/src/bot_data/abc/technician_config_repository_abc.py b/bot/src/bot_data/abc/technician_config_repository_abc.py index 364af9b6..25c88d96 100644 --- a/bot/src/bot_data/abc/technician_config_repository_abc.py +++ b/bot/src/bot_data/abc/technician_config_repository_abc.py @@ -43,19 +43,13 @@ class TechnicianConfigRepositoryABC(ABC): pass @abstractmethod - def add_technician_ping_url_config( - self, technician_ping_url: TechnicianPingUrlConfig - ): + def add_technician_ping_url_config(self, technician_ping_url: TechnicianPingUrlConfig): pass @abstractmethod - def update_technician_ping_url_config( - self, technician_ping_url: TechnicianPingUrlConfig - ): + def update_technician_ping_url_config(self, technician_ping_url: TechnicianPingUrlConfig): pass @abstractmethod - def delete_technician_ping_url_config( - self, technician_ping_url: TechnicianPingUrlConfig - ): + def delete_technician_ping_url_config(self, technician_ping_url: TechnicianPingUrlConfig): pass diff --git a/bot/src/bot_data/abc/user_joined_game_server_repository_abc.py b/bot/src/bot_data/abc/user_joined_game_server_repository_abc.py index c6c3cfcf..97a0358b 100644 --- a/bot/src/bot_data/abc/user_joined_game_server_repository_abc.py +++ b/bot/src/bot_data/abc/user_joined_game_server_repository_abc.py @@ -20,45 +20,31 @@ class UserJoinedGameServerRepositoryABC(ABC): pass @abstractmethod - def get_user_joined_game_servers_by_user_id( - self, user_id: int - ) -> List[UserJoinedGameServer]: + def get_user_joined_game_servers_by_user_id(self, user_id: int) -> List[UserJoinedGameServer]: pass @abstractmethod - def get_active_user_joined_game_server_by_user_id( - self, user_id: int - ) -> UserJoinedGameServer: + def get_active_user_joined_game_server_by_user_id(self, user_id: int) -> UserJoinedGameServer: pass @abstractmethod - def find_active_user_joined_game_server_by_user_id( - self, user_id: int - ) -> Optional[UserJoinedGameServer]: + def find_active_user_joined_game_server_by_user_id(self, user_id: int) -> Optional[UserJoinedGameServer]: pass @abstractmethod - def find_active_user_joined_game_servers_by_user_id( - self, user_id: int - ) -> List[Optional[UserJoinedGameServer]]: + def find_active_user_joined_game_servers_by_user_id(self, user_id: int) -> List[Optional[UserJoinedGameServer]]: pass @abstractmethod - def add_user_joined_game_server( - self, user_joined_game_server: UserJoinedGameServer - ): + def add_user_joined_game_server(self, user_joined_game_server: UserJoinedGameServer): pass @abstractmethod - def update_user_joined_game_server( - self, user_joined_game_server: UserJoinedGameServer - ): + def update_user_joined_game_server(self, user_joined_game_server: UserJoinedGameServer): pass @abstractmethod - def delete_user_joined_game_server( - self, user_joined_game_server: UserJoinedGameServer - ): + def delete_user_joined_game_server(self, user_joined_game_server: UserJoinedGameServer): pass @abstractmethod diff --git a/bot/src/bot_data/abc/user_joined_server_repository_abc.py b/bot/src/bot_data/abc/user_joined_server_repository_abc.py index d317b7b2..cbc3a718 100644 --- a/bot/src/bot_data/abc/user_joined_server_repository_abc.py +++ b/bot/src/bot_data/abc/user_joined_server_repository_abc.py @@ -24,21 +24,15 @@ class UserJoinedServerRepositoryABC(ABC): pass @abstractmethod - def get_user_joined_servers_by_user_id( - self, user_id: int - ) -> list[UserJoinedServer]: + def get_user_joined_servers_by_user_id(self, user_id: int) -> list[UserJoinedServer]: pass @abstractmethod - def get_active_user_joined_server_by_user_id( - self, user_id: int - ) -> UserJoinedServer: + def get_active_user_joined_server_by_user_id(self, user_id: int) -> UserJoinedServer: pass @abstractmethod - def find_active_user_joined_server_by_user_id( - self, user_id: int - ) -> Optional[UserJoinedServer]: + def find_active_user_joined_server_by_user_id(self, user_id: int) -> Optional[UserJoinedServer]: pass @abstractmethod diff --git a/bot/src/bot_data/abc/user_joined_voice_channel_repository_abc.py b/bot/src/bot_data/abc/user_joined_voice_channel_repository_abc.py index 793cfe33..7ce7e01a 100644 --- a/bot/src/bot_data/abc/user_joined_voice_channel_repository_abc.py +++ b/bot/src/bot_data/abc/user_joined_voice_channel_repository_abc.py @@ -19,45 +19,31 @@ class UserJoinedVoiceChannelRepositoryABC(ABC): pass @abstractmethod - def get_user_joined_voice_channels_by_user_id( - self, user_id: int - ) -> List[UserJoinedVoiceChannel]: + def get_user_joined_voice_channels_by_user_id(self, user_id: int) -> List[UserJoinedVoiceChannel]: pass @abstractmethod - def get_active_user_joined_voice_channel_by_user_id( - self, user_id: int - ) -> UserJoinedVoiceChannel: + def get_active_user_joined_voice_channel_by_user_id(self, user_id: int) -> UserJoinedVoiceChannel: pass @abstractmethod - def find_active_user_joined_voice_channel_by_user_id( - self, user_id: int - ) -> Optional[UserJoinedVoiceChannel]: + def find_active_user_joined_voice_channel_by_user_id(self, user_id: int) -> Optional[UserJoinedVoiceChannel]: pass @abstractmethod - def find_active_user_joined_voice_channels_by_user_id( - self, user_id: int - ) -> List[Optional[UserJoinedVoiceChannel]]: + def find_active_user_joined_voice_channels_by_user_id(self, user_id: int) -> List[Optional[UserJoinedVoiceChannel]]: pass @abstractmethod - def add_user_joined_voice_channel( - self, user_joined_voice_channel: UserJoinedVoiceChannel - ): + def add_user_joined_voice_channel(self, user_joined_voice_channel: UserJoinedVoiceChannel): pass @abstractmethod - def update_user_joined_voice_channel( - self, user_joined_voice_channel: UserJoinedVoiceChannel - ): + def update_user_joined_voice_channel(self, user_joined_voice_channel: UserJoinedVoiceChannel): pass @abstractmethod - def delete_user_joined_voice_channel( - self, user_joined_voice_channel: UserJoinedVoiceChannel - ): + def delete_user_joined_voice_channel(self, user_joined_voice_channel: UserJoinedVoiceChannel): pass @abstractmethod diff --git a/bot/src/bot_data/abc/user_message_count_per_hour_repository_abc.py b/bot/src/bot_data/abc/user_message_count_per_hour_repository_abc.py index 778177fa..59108387 100644 --- a/bot/src/bot_data/abc/user_message_count_per_hour_repository_abc.py +++ b/bot/src/bot_data/abc/user_message_count_per_hour_repository_abc.py @@ -17,9 +17,7 @@ class UserMessageCountPerHourRepositoryABC(ABC): pass @abstractmethod - def find_user_message_count_per_hour_by_user_id( - self, user_id: int - ) -> Optional[UserMessageCountPerHour]: + def find_user_message_count_per_hour_by_user_id(self, user_id: int) -> Optional[UserMessageCountPerHour]: pass @abstractmethod diff --git a/bot/src/bot_data/abc/user_repository_abc.py b/bot/src/bot_data/abc/user_repository_abc.py index 1605e24d..0e3ced21 100644 --- a/bot/src/bot_data/abc/user_repository_abc.py +++ b/bot/src/bot_data/abc/user_repository_abc.py @@ -32,15 +32,11 @@ class UserRepositoryABC(ABC): pass @abstractmethod - def get_user_by_discord_id_and_server_id( - self, discord_id: int, server_id: int - ) -> User: + def get_user_by_discord_id_and_server_id(self, discord_id: int, server_id: int) -> User: pass @abstractmethod - def find_user_by_discord_id_and_server_id( - self, discord_id: int, server_id: int - ) -> Optional[User]: + def find_user_by_discord_id_and_server_id(self, discord_id: int, server_id: int) -> Optional[User]: pass @abstractmethod diff --git a/bot/src/bot_data/data_module.py b/bot/src/bot_data/data_module.py index ad38d4f6..cec9cb37 100644 --- a/bot/src/bot_data/data_module.py +++ b/bot/src/bot_data/data_module.py @@ -86,14 +86,10 @@ class DataModule(ModuleABC): def __init__(self, dc: DiscordCollectionABC): ModuleABC.__init__(self, dc, FeatureFlagsEnum.data_module) - def configure_configuration( - self, config: ConfigurationABC, env: ApplicationEnvironmentABC - ): + def configure_configuration(self, config: ConfigurationABC, env: ApplicationEnvironmentABC): pass - def configure_services( - self, services: ServiceCollectionABC, env: ApplicationEnvironmentABC - ): + def configure_services(self, services: ServiceCollectionABC, env: ApplicationEnvironmentABC): services.add_singleton(CacheService) services.add_transient(ApiKeyRepositoryABC, ApiKeyRepositoryService) @@ -102,15 +98,9 @@ class DataModule(ModuleABC): services.add_transient(UserRepositoryABC, UserRepositoryService) services.add_transient(ClientRepositoryABC, ClientRepositoryService) services.add_transient(KnownUserRepositoryABC, KnownUserRepositoryService) - services.add_transient( - UserJoinedServerRepositoryABC, UserJoinedServerRepositoryService - ) - services.add_transient( - UserJoinedVoiceChannelRepositoryABC, UserJoinedVoiceChannelRepositoryService - ) - services.add_transient( - UserJoinedGameServerRepositoryABC, UserJoinedGameServerRepositoryService - ) + services.add_transient(UserJoinedServerRepositoryABC, UserJoinedServerRepositoryService) + services.add_transient(UserJoinedVoiceChannelRepositoryABC, UserJoinedVoiceChannelRepositoryService) + services.add_transient(UserJoinedGameServerRepositoryABC, UserJoinedGameServerRepositoryService) services.add_transient(AutoRoleRepositoryABC, AutoRoleRepositoryService) services.add_transient(LevelRepositoryABC, LevelRepositoryService) services.add_transient(UserWarningsRepositoryABC, UserWarningsRepositoryService) @@ -119,20 +109,12 @@ class DataModule(ModuleABC): UserMessageCountPerHourRepositoryService, ) services.add_transient(GameServerRepositoryABC, GameServerRepositoryService) - services.add_transient( - UserGameIdentRepositoryABC, UserGameIdentRepositoryService - ) + services.add_transient(UserGameIdentRepositoryABC, UserGameIdentRepositoryService) services.add_transient(AchievementRepositoryABC, AchievementRepositoryService) - services.add_transient( - TechnicianConfigRepositoryABC, TechnicianConfigRepositoryService - ) + services.add_transient(TechnicianConfigRepositoryABC, TechnicianConfigRepositoryService) services.add_transient(ServerConfigRepositoryABC, ServerConfigRepositoryService) - services.add_transient( - ShortRoleNameRepositoryABC, ShortRoleNameRepositoryService - ) - services.add_transient( - SteamSpecialOfferRepositoryABC, SteamSpecialOfferRepositoryService - ) + services.add_transient(ShortRoleNameRepositoryABC, ShortRoleNameRepositoryService) + services.add_transient(SteamSpecialOfferRepositoryABC, SteamSpecialOfferRepositoryService) services.add_transient(SeederService) services.add_transient(DataSeederABC, TechnicianConfigSeeder) diff --git a/bot/src/bot_data/migration/achievements_migration.py b/bot/src/bot_data/migration/achievements_migration.py index b58299c2..f3a454d3 100644 --- a/bot/src/bot_data/migration/achievements_migration.py +++ b/bot/src/bot_data/migration/achievements_migration.py @@ -74,30 +74,12 @@ class AchievementsMigration(MigrationABC): # A join table history between users and achievements is not necessary. - self._cursor.execute( - str( - f"""ALTER TABLE Users ADD MessageCount BIGINT NOT NULL DEFAULT 0 AFTER XP;""" - ) - ) - self._cursor.execute( - str( - f"""ALTER TABLE Users ADD ReactionCount BIGINT NOT NULL DEFAULT 0 AFTER XP;""" - ) - ) - self._cursor.execute( - str( - f"""ALTER TABLE UsersHistory ADD MessageCount BIGINT NOT NULL DEFAULT 0 AFTER XP;""" - ) - ) - self._cursor.execute( - str( - f"""ALTER TABLE UsersHistory ADD ReactionCount BIGINT NOT NULL DEFAULT 0 AFTER XP;""" - ) - ) + self._cursor.execute(str(f"""ALTER TABLE Users ADD MessageCount BIGINT NOT NULL DEFAULT 0 AFTER XP;""")) + self._cursor.execute(str(f"""ALTER TABLE Users ADD ReactionCount BIGINT NOT NULL DEFAULT 0 AFTER XP;""")) + self._cursor.execute(str(f"""ALTER TABLE UsersHistory ADD MessageCount BIGINT NOT NULL DEFAULT 0 AFTER XP;""")) + self._cursor.execute(str(f"""ALTER TABLE UsersHistory ADD ReactionCount BIGINT NOT NULL DEFAULT 0 AFTER XP;""")) - self._cursor.execute( - str(f"""DROP TRIGGER IF EXISTS `TR_AchievementsUpdate`;""") - ) + self._cursor.execute(str(f"""DROP TRIGGER IF EXISTS `TR_AchievementsUpdate`;""")) self._cursor.execute( str( f""" @@ -117,9 +99,7 @@ class AchievementsMigration(MigrationABC): ) ) - self._cursor.execute( - str(f"""DROP TRIGGER IF EXISTS `TR_AchievementsDelete`;""") - ) + self._cursor.execute(str(f"""DROP TRIGGER IF EXISTS `TR_AchievementsDelete`;""")) self._cursor.execute( str( diff --git a/bot/src/bot_data/migration/config_feature_flags_migration.py b/bot/src/bot_data/migration/config_feature_flags_migration.py index a4654bb1..f9046565 100644 --- a/bot/src/bot_data/migration/config_feature_flags_migration.py +++ b/bot/src/bot_data/migration/config_feature_flags_migration.py @@ -16,15 +16,11 @@ class ConfigFeatureFlagsMigration(MigrationABC): self._logger.debug(__name__, "Running upgrade") self._cursor.execute( - str( - """ALTER TABLE CFG_Technician ADD FeatureFlags JSON NULL DEFAULT ('{}') AFTER CacheMaxMessages;""" - ) + 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;""" - ) + str("""ALTER TABLE CFG_Server ADD FeatureFlags JSON NULL DEFAULT ('{}') AFTER LoginMessageChannelId;""") ) def downgrade(self): diff --git a/bot/src/bot_data/migration/fix_updates_migration.py b/bot/src/bot_data/migration/fix_updates_migration.py index 9f2420e3..f4d5e020 100644 --- a/bot/src/bot_data/migration/fix_updates_migration.py +++ b/bot/src/bot_data/migration/fix_updates_migration.py @@ -47,7 +47,5 @@ class FixUpdatesMigration(MigrationABC): """ ) ) - self._cursor.execute( - "ALTER TABLE CFG_TechnicianHistory DROP COLUMN FeatureFlags;" - ) + self._cursor.execute("ALTER TABLE CFG_TechnicianHistory DROP COLUMN FeatureFlags;") self._cursor.execute("ALTER TABLE CFG_ServerHistory DROP COLUMN FeatureFlags;") diff --git a/bot/src/bot_data/model/achievement.py b/bot/src/bot_data/model/achievement.py index 97a3e059..ebce645d 100644 --- a/bot/src/bot_data/model/achievement.py +++ b/bot/src/bot_data/model/achievement.py @@ -34,9 +34,7 @@ class Achievement(TableABC): TableABC.__init__(self) self._created_at = created_at if created_at is not None else self._created_at - self._modified_at = ( - modified_at if modified_at is not None else self._modified_at - ) + self._modified_at = modified_at if modified_at is not None else self._modified_at @ServiceProviderABC.inject def _is_operator_valid(self, operator, service: ServiceProviderABC) -> bool: diff --git a/bot/src/bot_data/model/api_key.py b/bot/src/bot_data/model/api_key.py index 20abc12d..d63c4d1b 100644 --- a/bot/src/bot_data/model/api_key.py +++ b/bot/src/bot_data/model/api_key.py @@ -23,9 +23,7 @@ class ApiKey(TableABC): TableABC.__init__(self) self._created_at = created_at if created_at is not None else self._created_at - self._modified_at = ( - modified_at if modified_at is not None else self._modified_at - ) + self._modified_at = modified_at if modified_at is not None else self._modified_at @property def id(self) -> int: diff --git a/bot/src/bot_data/model/auth_user.py b/bot/src/bot_data/model/auth_user.py index cdc6d8a2..47bdf41a 100644 --- a/bot/src/bot_data/model/auth_user.py +++ b/bot/src/bot_data/model/auth_user.py @@ -49,9 +49,7 @@ class AuthUser(TableABC): TableABC.__init__(self) self._created_at = created_at if created_at is not None else self._created_at - self._modified_at = ( - modified_at if modified_at is not None else self._modified_at - ) + self._modified_at = modified_at if modified_at is not None else self._modified_at @property def id(self) -> int: diff --git a/bot/src/bot_data/model/auth_user_users_relation.py b/bot/src/bot_data/model/auth_user_users_relation.py index 25e66301..23b9ceab 100644 --- a/bot/src/bot_data/model/auth_user_users_relation.py +++ b/bot/src/bot_data/model/auth_user_users_relation.py @@ -19,9 +19,7 @@ class AuthUserUsersRelation(TableABC): TableABC.__init__(self) self._created_at = created_at if created_at is not None else self._created_at - self._modified_at = ( - modified_at if modified_at is not None else self._modified_at - ) + self._modified_at = modified_at if modified_at is not None else self._modified_at @property def auth_user(self) -> AuthUser: diff --git a/bot/src/bot_data/model/auto_role.py b/bot/src/bot_data/model/auto_role.py index e8b446c7..a1ff7934 100644 --- a/bot/src/bot_data/model/auto_role.py +++ b/bot/src/bot_data/model/auto_role.py @@ -25,9 +25,7 @@ class AutoRole(TableABC): TableABC.__init__(self) self._created_at = created_at if created_at is not None else self._created_at - self._modified_at = ( - modified_at if modified_at is not None else self._modified_at - ) + self._modified_at = modified_at if modified_at is not None else self._modified_at @property def id(self) -> int: diff --git a/bot/src/bot_data/model/auto_role_rule.py b/bot/src/bot_data/model/auto_role_rule.py index f90fd86f..8729b6ec 100644 --- a/bot/src/bot_data/model/auto_role_rule.py +++ b/bot/src/bot_data/model/auto_role_rule.py @@ -24,9 +24,7 @@ class AutoRoleRule(TableABC): TableABC.__init__(self) self._created_at = created_at if created_at is not None else self._created_at - self._modified_at = ( - modified_at if modified_at is not None else self._modified_at - ) + self._modified_at = modified_at if modified_at is not None else self._modified_at @property def id(self) -> int: diff --git a/bot/src/bot_data/model/client.py b/bot/src/bot_data/model/client.py index e8c56adf..b6c163c9 100644 --- a/bot/src/bot_data/model/client.py +++ b/bot/src/bot_data/model/client.py @@ -32,9 +32,7 @@ class Client(TableABC): TableABC.__init__(self) self._created_at = created_at if created_at is not None else self._created_at - self._modified_at = ( - modified_at if modified_at is not None else self._modified_at - ) + self._modified_at = modified_at if modified_at is not None else self._modified_at @property def id(self) -> int: diff --git a/bot/src/bot_data/model/game_server.py b/bot/src/bot_data/model/game_server.py index 8cc510af..eeea20d8 100644 --- a/bot/src/bot_data/model/game_server.py +++ b/bot/src/bot_data/model/game_server.py @@ -23,9 +23,7 @@ class GameServer(TableABC): TableABC.__init__(self) self._created_at = created_at if created_at is not None else self._created_at - self._modified_at = ( - modified_at if modified_at is not None else self._modified_at - ) + self._modified_at = modified_at if modified_at is not None else self._modified_at @property def id(self) -> int: diff --git a/bot/src/bot_data/model/known_user.py b/bot/src/bot_data/model/known_user.py index e07bcf83..37d375f0 100644 --- a/bot/src/bot_data/model/known_user.py +++ b/bot/src/bot_data/model/known_user.py @@ -16,9 +16,7 @@ class KnownUser(TableABC): TableABC.__init__(self) self._created_at = created_at if created_at is not None else self._created_at - self._modified_at = ( - modified_at if modified_at is not None else self._modified_at - ) + self._modified_at = modified_at if modified_at is not None else self._modified_at @property def id(self) -> int: diff --git a/bot/src/bot_data/model/level.py b/bot/src/bot_data/model/level.py index bdad1826..a20d268b 100644 --- a/bot/src/bot_data/model/level.py +++ b/bot/src/bot_data/model/level.py @@ -27,9 +27,7 @@ class Level(TableABC): TableABC.__init__(self) self._created_at = created_at if created_at is not None else self._created_at - self._modified_at = ( - modified_at if modified_at is not None else self._modified_at - ) + self._modified_at = modified_at if modified_at is not None else self._modified_at @property def id(self) -> int: diff --git a/bot/src/bot_data/model/server.py b/bot/src/bot_data/model/server.py index 5ae54ca7..d86c6e97 100644 --- a/bot/src/bot_data/model/server.py +++ b/bot/src/bot_data/model/server.py @@ -18,9 +18,7 @@ class Server(TableABC): TableABC.__init__(self) self._created_at = created_at if created_at is not None else self._created_at - self._modified_at = ( - modified_at if modified_at is not None else self._modified_at - ) + self._modified_at = modified_at if modified_at is not None else self._modified_at @property def id(self) -> int: diff --git a/bot/src/bot_data/model/server_afk_channel_ids_config.py b/bot/src/bot_data/model/server_afk_channel_ids_config.py index 2c9042d9..9b182426 100644 --- a/bot/src/bot_data/model/server_afk_channel_ids_config.py +++ b/bot/src/bot_data/model/server_afk_channel_ids_config.py @@ -18,9 +18,7 @@ class ServerAFKChannelIdsConfig(TableABC): TableABC.__init__(self) self._created_at = created_at if created_at is not None else self._created_at - self._modified_at = ( - modified_at if modified_at is not None else self._modified_at - ) + self._modified_at = modified_at if modified_at is not None else self._modified_at @property def channel_id(self) -> int: diff --git a/bot/src/bot_data/model/server_config.py b/bot/src/bot_data/model/server_config.py index 3453de2f..cf220355 100644 --- a/bot/src/bot_data/model/server_config.py +++ b/bot/src/bot_data/model/server_config.py @@ -56,9 +56,7 @@ class ServerConfig(TableABC, ConfigurationModelABC): self._team_channel_id = team_channel_id self._login_message_channel_id = login_message_channel_id self._default_role_id = default_role_id - self._short_role_name_only_set_highest_role = ( - short_role_name_only_set_highest_role - ) + self._short_role_name_only_set_highest_role = short_role_name_only_set_highest_role self._game_offer_notification_chat_id = game_offer_notification_chat_id self._feature_flags = feature_flags @@ -68,9 +66,7 @@ class ServerConfig(TableABC, ConfigurationModelABC): TableABC.__init__(self) self._created_at = created_at if created_at is not None else self._created_at - self._modified_at = ( - modified_at if modified_at is not None else self._modified_at - ) + self._modified_at = modified_at if modified_at is not None else self._modified_at @staticmethod def new(guild: Guild, server: Server) -> "ServerConfig": diff --git a/bot/src/bot_data/model/server_config_history.py b/bot/src/bot_data/model/server_config_history.py index 009491bd..6364f2eb 100644 --- a/bot/src/bot_data/model/server_config_history.py +++ b/bot/src/bot_data/model/server_config_history.py @@ -43,9 +43,7 @@ class ServerConfigHistory(HistoryTableABC): self._team_channel_id = team_channel_id self._login_message_channel_id = login_message_channel_id self._default_role_id = default_role_id - self._short_role_name_only_set_highest_role = ( - short_role_name_only_set_highest_role - ) + self._short_role_name_only_set_highest_role = short_role_name_only_set_highest_role self._feature_flags = feature_flags self._server_id = server_id diff --git a/bot/src/bot_data/model/server_team_role_ids_config.py b/bot/src/bot_data/model/server_team_role_ids_config.py index 7be73531..dfd870dd 100644 --- a/bot/src/bot_data/model/server_team_role_ids_config.py +++ b/bot/src/bot_data/model/server_team_role_ids_config.py @@ -22,9 +22,7 @@ class ServerTeamRoleIdsConfig(TableABC): TableABC.__init__(self) self._created_at = created_at if created_at is not None else self._created_at - self._modified_at = ( - modified_at if modified_at is not None else self._modified_at - ) + self._modified_at = modified_at if modified_at is not None else self._modified_at @property def id(self) -> int: diff --git a/bot/src/bot_data/model/short_role_name.py b/bot/src/bot_data/model/short_role_name.py index d03b6ddc..4ddef4f1 100644 --- a/bot/src/bot_data/model/short_role_name.py +++ b/bot/src/bot_data/model/short_role_name.py @@ -27,9 +27,7 @@ class ShortRoleName(TableABC): TableABC.__init__(self) self._created_at = created_at if created_at is not None else self._created_at - self._modified_at = ( - modified_at if modified_at is not None else self._modified_at - ) + self._modified_at = modified_at if modified_at is not None else self._modified_at @property def id(self) -> int: diff --git a/bot/src/bot_data/model/steam_special_offer.py b/bot/src/bot_data/model/steam_special_offer.py index 0b7e6927..76301dc4 100644 --- a/bot/src/bot_data/model/steam_special_offer.py +++ b/bot/src/bot_data/model/steam_special_offer.py @@ -22,9 +22,7 @@ class SteamSpecialOffer(TableABC): TableABC.__init__(self) self._created_at = created_at if created_at is not None else self._created_at - self._modified_at = ( - modified_at if modified_at is not None else self._modified_at - ) + self._modified_at = modified_at if modified_at is not None else self._modified_at @property def id(self) -> int: diff --git a/bot/src/bot_data/model/technician_config.py b/bot/src/bot_data/model/technician_config.py index 9aab8628..1390f4b8 100644 --- a/bot/src/bot_data/model/technician_config.py +++ b/bot/src/bot_data/model/technician_config.py @@ -33,9 +33,7 @@ class TechnicianConfig(TableABC, ConfigurationModelABC): TableABC.__init__(self) self._created_at = created_at if created_at is not None else self._created_at - self._modified_at = ( - modified_at if modified_at is not None else self._modified_at - ) + self._modified_at = modified_at if modified_at is not None else self._modified_at @property def id(self) -> int: diff --git a/bot/src/bot_data/model/technician_id_config.py b/bot/src/bot_data/model/technician_id_config.py index 7db76b4b..6ba5f581 100644 --- a/bot/src/bot_data/model/technician_id_config.py +++ b/bot/src/bot_data/model/technician_id_config.py @@ -16,9 +16,7 @@ class TechnicianIdConfig(TableABC): TableABC.__init__(self) self._created_at = created_at if created_at is not None else self._created_at - self._modified_at = ( - modified_at if modified_at is not None else self._modified_at - ) + self._modified_at = modified_at if modified_at is not None else self._modified_at @property def id(self) -> int: diff --git a/bot/src/bot_data/model/technician_ping_url_config.py b/bot/src/bot_data/model/technician_ping_url_config.py index bcc63b97..31983624 100644 --- a/bot/src/bot_data/model/technician_ping_url_config.py +++ b/bot/src/bot_data/model/technician_ping_url_config.py @@ -16,9 +16,7 @@ class TechnicianPingUrlConfig(TableABC): TableABC.__init__(self) self._created_at = created_at if created_at is not None else self._created_at - self._modified_at = ( - modified_at if modified_at is not None else self._modified_at - ) + self._modified_at = modified_at if modified_at is not None else self._modified_at @property def id(self) -> int: diff --git a/bot/src/bot_data/model/user.py b/bot/src/bot_data/model/user.py index d1e7d514..ed44c58a 100644 --- a/bot/src/bot_data/model/user.py +++ b/bot/src/bot_data/model/user.py @@ -33,9 +33,7 @@ class User(TableABC): TableABC.__init__(self) self._created_at = created_at if created_at is not None else self._created_at - self._modified_at = ( - modified_at if modified_at is not None else self._modified_at - ) + self._modified_at = modified_at if modified_at is not None else self._modified_at @property def id(self) -> int: @@ -121,9 +119,7 @@ class User(TableABC): UserJoinedServerRepositoryABC, ) - ujs: UserJoinedServerRepositoryABC = services.get_service( - UserJoinedServerRepositoryABC - ) + ujs: UserJoinedServerRepositoryABC = services.get_service(UserJoinedServerRepositoryABC) return ujs.find_active_user_joined_server_by_user_id(self.id) is None @property @@ -136,9 +132,7 @@ class User(TableABC): UserGameIdentRepositoryABC, ) - game_idents_repo: UserGameIdentRepositoryABC = services.get_service( - UserGameIdentRepositoryABC - ) + game_idents_repo: UserGameIdentRepositoryABC = services.get_service(UserGameIdentRepositoryABC) return game_idents_repo.get_user_game_idents_by_user_id(self.id) @staticmethod diff --git a/bot/src/bot_data/model/user_game_ident.py b/bot/src/bot_data/model/user_game_ident.py index 11d88a66..79468d13 100644 --- a/bot/src/bot_data/model/user_game_ident.py +++ b/bot/src/bot_data/model/user_game_ident.py @@ -23,9 +23,7 @@ class UserGameIdent(TableABC): TableABC.__init__(self) self._created_at = created_at if created_at is not None else self._created_at - self._modified_at = ( - modified_at if modified_at is not None else self._modified_at - ) + self._modified_at = modified_at if modified_at is not None else self._modified_at @property def id(self) -> int: diff --git a/bot/src/bot_data/model/user_got_achievement.py b/bot/src/bot_data/model/user_got_achievement.py index 373bfe05..d2c37cf5 100644 --- a/bot/src/bot_data/model/user_got_achievement.py +++ b/bot/src/bot_data/model/user_got_achievement.py @@ -22,9 +22,7 @@ class UserGotAchievement(TableABC): TableABC.__init__(self) self._created_at = created_at if created_at is not None else self._created_at - self._modified_at = ( - modified_at if modified_at is not None else self._modified_at - ) + self._modified_at = modified_at if modified_at is not None else self._modified_at @property def id(self) -> int: diff --git a/bot/src/bot_data/model/user_history.py b/bot/src/bot_data/model/user_history.py index 461550fe..357c854a 100644 --- a/bot/src/bot_data/model/user_history.py +++ b/bot/src/bot_data/model/user_history.py @@ -64,9 +64,7 @@ class UserHistory(HistoryTableABC): UserJoinedServerRepositoryABC, ) - ujs: UserJoinedServerRepositoryABC = services.get_service( - UserJoinedServerRepositoryABC - ) + ujs: UserJoinedServerRepositoryABC = services.get_service(UserJoinedServerRepositoryABC) return ujs.find_active_user_joined_server_by_user_id(self.id) is None @property @@ -79,7 +77,5 @@ class UserHistory(HistoryTableABC): UserGameIdentRepositoryABC, ) - game_idents_repo: UserGameIdentRepositoryABC = services.get_service( - UserGameIdentRepositoryABC - ) + game_idents_repo: UserGameIdentRepositoryABC = services.get_service(UserGameIdentRepositoryABC) return game_idents_repo.get_user_game_idents_by_user_id(self.id) diff --git a/bot/src/bot_data/model/user_joined_game_server.py b/bot/src/bot_data/model/user_joined_game_server.py index 8cfaae11..cf60229d 100644 --- a/bot/src/bot_data/model/user_joined_game_server.py +++ b/bot/src/bot_data/model/user_joined_game_server.py @@ -25,9 +25,7 @@ class UserJoinedGameServer(TableABC): TableABC.__init__(self) self._created_at = created_at if created_at is not None else self._created_at - self._modified_at = ( - modified_at if modified_at is not None else self._modified_at - ) + self._modified_at = modified_at if modified_at is not None else self._modified_at @property def id(self) -> int: diff --git a/bot/src/bot_data/model/user_joined_server.py b/bot/src/bot_data/model/user_joined_server.py index 25cf2b27..e55cb60d 100644 --- a/bot/src/bot_data/model/user_joined_server.py +++ b/bot/src/bot_data/model/user_joined_server.py @@ -22,9 +22,7 @@ class UserJoinedServer(TableABC): TableABC.__init__(self) self._created_at = created_at if created_at is not None else self._created_at - self._modified_at = ( - modified_at if modified_at is not None else self._modified_at - ) + self._modified_at = modified_at if modified_at is not None else self._modified_at @property def id(self) -> int: diff --git a/bot/src/bot_data/model/user_joined_voice_channel.py b/bot/src/bot_data/model/user_joined_voice_channel.py index 5764b5e8..3b938452 100644 --- a/bot/src/bot_data/model/user_joined_voice_channel.py +++ b/bot/src/bot_data/model/user_joined_voice_channel.py @@ -26,9 +26,7 @@ class UserJoinedVoiceChannel(TableABC): TableABC.__init__(self) self._created_at = created_at if created_at is not None else self._created_at - self._modified_at = ( - modified_at if modified_at is not None else self._modified_at - ) + self._modified_at = modified_at if modified_at is not None else self._modified_at @property def id(self) -> int: diff --git a/bot/src/bot_data/model/user_message_count_per_hour.py b/bot/src/bot_data/model/user_message_count_per_hour.py index be0fdddc..7815ffa4 100644 --- a/bot/src/bot_data/model/user_message_count_per_hour.py +++ b/bot/src/bot_data/model/user_message_count_per_hour.py @@ -24,9 +24,7 @@ class UserMessageCountPerHour(TableABC): TableABC.__init__(self) self._created_at = created_at if created_at is not None else self._created_at - self._modified_at = ( - modified_at if modified_at is not None else self._modified_at - ) + self._modified_at = modified_at if modified_at is not None else self._modified_at @property def id(self) -> int: diff --git a/bot/src/bot_data/model/user_warnings.py b/bot/src/bot_data/model/user_warnings.py index bd1e290c..99610a5f 100644 --- a/bot/src/bot_data/model/user_warnings.py +++ b/bot/src/bot_data/model/user_warnings.py @@ -24,9 +24,7 @@ class UserWarnings(TableABC): TableABC.__init__(self) self._created_at = created_at if created_at is not None else self._created_at - self._modified_at = ( - modified_at if modified_at is not None else self._modified_at - ) + self._modified_at = modified_at if modified_at is not None else self._modified_at @property def id(self) -> int: diff --git a/bot/src/bot_data/service/achievements_repository_service.py b/bot/src/bot_data/service/achievements_repository_service.py index 004a4a53..d8923db5 100644 --- a/bot/src/bot_data/service/achievements_repository_service.py +++ b/bot/src/bot_data/service/achievements_repository_service.py @@ -49,9 +49,7 @@ class AchievementRepositoryService(AchievementRepositoryABC): def get_achievements(self) -> List[Achievement]: achievements = List(Achievement) - self._logger.trace( - __name__, f"Send SQL command: {Achievement.get_select_all_string()}" - ) + self._logger.trace(__name__, f"Send SQL command: {Achievement.get_select_all_string()}") results = self._context.select(Achievement.get_select_all_string()) for result in results: self._logger.trace(__name__, f"Get user with id {result[0]}") @@ -60,9 +58,7 @@ class AchievementRepositoryService(AchievementRepositoryABC): return achievements def get_achievement_by_id(self, id: int) -> Achievement: - self._logger.trace( - __name__, f"Send SQL command: {Achievement.get_select_by_id_string(id)}" - ) + self._logger.trace(__name__, f"Send SQL command: {Achievement.get_select_by_id_string(id)}") result = self._context.select(Achievement.get_select_by_id_string(id))[0] return self._from_result(result) @@ -73,9 +69,7 @@ class AchievementRepositoryService(AchievementRepositoryABC): __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) - ) + 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)) @@ -89,34 +83,26 @@ class AchievementRepositoryService(AchievementRepositoryABC): __name__, f"Send SQL command: {UserGotAchievement.get_select_by_user_id_string(user_id)}", ) - results = self._context.select( - UserGotAchievement.get_select_by_user_id_string(user_id) - ) + results = self._context.select(UserGotAchievement.get_select_by_user_id_string(user_id)) for result in results: self._logger.trace(__name__, f"Got UserGotAchievement with id {result[0]}") achievements_joins.append(self._join_from_result(result)) for achievements_join in achievements_joins: - results = self._context.select( - Achievement.get_select_by_id_string(achievements_join.achievement.id) - ) + results = self._context.select(Achievement.get_select_by_id_string(achievements_join.achievement.id)) for result in results: self._logger.trace(__name__, f"Got Achievement with id {result[0]}") achievements.append(self._from_result(result)) return achievements - def get_user_got_achievements_by_achievement_id( - self, achievement_id: int - ) -> List[Achievement]: + def get_user_got_achievements_by_achievement_id(self, achievement_id: int) -> List[Achievement]: achievements_joins = List(UserGotAchievement) self._logger.trace( __name__, f"Send SQL command: {UserGotAchievement.get_select_by_achievement_id_string(achievement_id)}", ) - results = self._context.select( - UserGotAchievement.get_select_by_achievement_id_string(achievement_id) - ) + results = self._context.select(UserGotAchievement.get_select_by_achievement_id_string(achievement_id)) for result in results: self._logger.trace(__name__, f"Got UserGotAchievement with id {result[0]}") achievements_joins.append(self._join_from_result(result)) diff --git a/bot/src/bot_data/service/api_key_repository_service.py b/bot/src/bot_data/service/api_key_repository_service.py index dfa6f72e..d4f57dfc 100644 --- a/bot/src/bot_data/service/api_key_repository_service.py +++ b/bot/src/bot_data/service/api_key_repository_service.py @@ -45,9 +45,7 @@ class ApiKeyRepositoryService(ApiKeyRepositoryABC): def get_api_keys(self) -> List[ApiKey]: api_keys = List(ApiKey) - self._logger.trace( - __name__, f"Send SQL command: {ApiKey.get_select_all_string()}" - ) + self._logger.trace(__name__, f"Send SQL command: {ApiKey.get_select_all_string()}") results = self._context.select(ApiKey.get_select_all_string()) for result in results: api_keys.append(self._api_key_from_result(result)) @@ -55,26 +53,16 @@ class ApiKeyRepositoryService(ApiKeyRepositoryABC): return api_keys def get_api_key(self, identifier: str, key: str) -> ApiKey: - self._logger.trace( - __name__, f"Send SQL command: {ApiKey.get_select_string(identifier, key)}" - ) - return self._api_key_from_result( - self._context.select(ApiKey.get_select_string(identifier, key))[0] - ) + self._logger.trace(__name__, f"Send SQL command: {ApiKey.get_select_string(identifier, key)}") + return self._api_key_from_result(self._context.select(ApiKey.get_select_string(identifier, key))[0]) def get_api_key_by_id(self, id: int) -> ApiKey: self._logger.trace(__name__, f"Send SQL command: {ApiKey.get_select_by_id(id)}") - return self._api_key_from_result( - self._context.select(ApiKey.get_select_by_id(id))[0] - ) + return self._api_key_from_result(self._context.select(ApiKey.get_select_by_id(id))[0]) def get_api_key_by_key(self, key: str) -> ApiKey: - self._logger.trace( - __name__, f"Send SQL command: {ApiKey.get_select_by_key(key)}" - ) - return self._api_key_from_result( - self._context.select(ApiKey.get_select_by_key(key))[0] - ) + self._logger.trace(__name__, f"Send SQL command: {ApiKey.get_select_by_key(key)}") + return self._api_key_from_result(self._context.select(ApiKey.get_select_by_key(key))[0]) def add_api_key(self, api_key: ApiKey): self._logger.trace(__name__, f"Send SQL command: {api_key.insert_string}") diff --git a/bot/src/bot_data/service/auth_user_repository_service.py b/bot/src/bot_data/service/auth_user_repository_service.py index 1b959068..00afe7ae 100644 --- a/bot/src/bot_data/service/auth_user_repository_service.py +++ b/bot/src/bot_data/service/auth_user_repository_service.py @@ -74,9 +74,7 @@ class AuthUserRepositoryService(AuthUserRepositoryABC): def get_all_auth_users(self) -> List[AuthUser]: users = List(AuthUser) - self._logger.trace( - __name__, f"Send SQL command: {AuthUser.get_select_all_string()}" - ) + self._logger.trace(__name__, f"Send SQL command: {AuthUser.get_select_all_string()}") results = self._context.select(AuthUser.get_select_all_string()) for result in results: self._logger.trace(__name__, f"Get auth user with id {result[0]}") @@ -84,36 +82,22 @@ class AuthUserRepositoryService(AuthUserRepositoryABC): return users - def get_filtered_auth_users( - self, criteria: AuthUserSelectCriteria - ) -> FilteredResult: + def get_filtered_auth_users(self, criteria: AuthUserSelectCriteria) -> FilteredResult: users = self.get_all_auth_users() - self._logger.trace( - __name__, f"Send SQL command: {AuthUser.get_select_all_string()}" - ) + self._logger.trace(__name__, f"Send SQL command: {AuthUser.get_select_all_string()}") query = users if criteria.first_name is not None and criteria.first_name != "": - query = query.where( - lambda x: criteria.first_name in x.first_name - or x.first_name == criteria.first_name - ) + query = query.where(lambda x: criteria.first_name in x.first_name or x.first_name == criteria.first_name) if criteria.last_name is not None and criteria.last_name != "": - query = query.where( - lambda x: criteria.last_name in x.last_name - or x.last_name == criteria.last_name - ) + query = query.where(lambda x: criteria.last_name in x.last_name or x.last_name == criteria.last_name) if criteria.email is not None and criteria.email != "": - query = query.where( - lambda x: criteria.email in x.email or x.email == criteria.email - ) + query = query.where(lambda x: criteria.email in x.email or x.email == criteria.email) if criteria.auth_role is not None: - query = query.where( - lambda x: x.auth_role == AuthRoleEnum(criteria.auth_role) - ) + query = query.where(lambda x: x.auth_role == AuthRoleEnum(criteria.auth_role)) # sort if ( @@ -144,16 +128,12 @@ class AuthUserRepositoryService(AuthUserRepositoryABC): return result def get_auth_user_by_email(self, email: str) -> AuthUser: - self._logger.trace( - __name__, f"Send SQL command: {AuthUser.get_select_by_email_string(email)}" - ) + self._logger.trace(__name__, f"Send SQL command: {AuthUser.get_select_by_email_string(email)}") result = self._context.select(AuthUser.get_select_by_email_string(email))[0] return self._user_from_result(result) def find_auth_user_by_email(self, email: str) -> Optional[AuthUser]: - self._logger.trace( - __name__, f"Send SQL command: {AuthUser.get_select_by_email_string(email)}" - ) + self._logger.trace(__name__, f"Send SQL command: {AuthUser.get_select_by_email_string(email)}") result = self._context.select(AuthUser.get_select_by_email_string(email)) if result is None or len(result) == 0: return None @@ -180,9 +160,7 @@ class AuthUserRepositoryService(AuthUserRepositoryABC): __name__, f"Send SQL command: {AuthUser.get_select_by_forgot_password_id_string(id)}", ) - result = self._context.select( - AuthUser.get_select_by_forgot_password_id_string(id) - ) + result = self._context.select(AuthUser.get_select_by_forgot_password_id_string(id)) if result is None or len(result) == 0: return None diff --git a/bot/src/bot_data/service/auto_role_repository_service.py b/bot/src/bot_data/service/auto_role_repository_service.py index e739962a..bf0d781a 100644 --- a/bot/src/bot_data/service/auto_role_repository_service.py +++ b/bot/src/bot_data/service/auto_role_repository_service.py @@ -25,9 +25,7 @@ class AutoRoleRepositoryService(AutoRoleRepositoryABC): def get_auto_roles(self) -> List[AutoRole]: auto_roles = List(AutoRole) - self._logger.trace( - __name__, f"Send SQL command: {AutoRole.get_select_all_string()}" - ) + self._logger.trace(__name__, f"Send SQL command: {AutoRole.get_select_all_string()}") results = self._context.select(AutoRole.get_select_all_string()) for result in results: auto_roles.append( @@ -44,9 +42,7 @@ class AutoRoleRepositoryService(AutoRoleRepositoryABC): return auto_roles def get_auto_role_by_id(self, id: int) -> AutoRole: - self._logger.trace( - __name__, f"Send SQL command: {AutoRole.get_select_by_id_string(id)}" - ) + self._logger.trace(__name__, f"Send SQL command: {AutoRole.get_select_by_id_string(id)}") result = self._context.select(AutoRole.get_select_by_id_string(id))[0] return AutoRole( self._servers.get_server_by_id(result[1]), @@ -58,9 +54,7 @@ class AutoRoleRepositoryService(AutoRoleRepositoryABC): ) def find_auto_role_by_id(self, id: int) -> Optional[AutoRole]: - self._logger.trace( - __name__, f"Send SQL command: {AutoRole.get_select_by_id_string(id)}" - ) + self._logger.trace(__name__, f"Send SQL command: {AutoRole.get_select_by_id_string(id)}") result = self._context.select(AutoRole.get_select_by_id_string(id)) if result is None or len(result) == 0: return None @@ -77,9 +71,7 @@ class AutoRoleRepositoryService(AutoRoleRepositoryABC): ) def get_auto_roles_by_server_id(self, id: int) -> List[AutoRole]: - self._logger.trace( - __name__, f"Send SQL command: {AutoRole.get_select_by_server_id_string(id)}" - ) + self._logger.trace(__name__, f"Send SQL command: {AutoRole.get_select_by_server_id_string(id)}") auto_roles = List(AutoRole) results = self._context.select(AutoRole.get_select_by_server_id_string(id)) for result in results: @@ -145,9 +137,7 @@ class AutoRoleRepositoryService(AutoRoleRepositoryABC): def get_auto_role_rules(self) -> List[AutoRoleRule]: auto_role_rules = List(AutoRoleRule) - self._logger.trace( - __name__, f"Send SQL command: {AutoRoleRule.get_select_all_string()}" - ) + self._logger.trace(__name__, f"Send SQL command: {AutoRoleRule.get_select_all_string()}") results = self._context.select(AutoRoleRule.get_select_all_string()) for result in results: auto_role_rules.append( @@ -164,9 +154,7 @@ class AutoRoleRepositoryService(AutoRoleRepositoryABC): return auto_role_rules def get_auto_role_rule_by_id(self, id: int) -> AutoRoleRule: - self._logger.trace( - __name__, f"Send SQL command: {AutoRoleRule.get_select_by_id_string(id)}" - ) + self._logger.trace(__name__, f"Send SQL command: {AutoRoleRule.get_select_by_id_string(id)}") result = self._context.select(AutoRoleRule.get_select_by_id_string(id))[0] return AutoRoleRule( self.get_auto_role_by_id(result[1]), @@ -183,9 +171,7 @@ class AutoRoleRepositoryService(AutoRoleRepositoryABC): __name__, f"Send SQL command: {AutoRoleRule.get_select_by_auto_role_id_string(id)}", ) - results = self._context.select( - AutoRoleRule.get_select_by_auto_role_id_string(id) - ) + results = self._context.select(AutoRoleRule.get_select_by_auto_role_id_string(id)) for result in results: auto_role_rules.append( AutoRoleRule( @@ -201,19 +187,13 @@ class AutoRoleRepositoryService(AutoRoleRepositoryABC): return auto_role_rules def add_auto_role_rule(self, auto_role_rule: AutoRoleRule): - self._logger.trace( - __name__, f"Send SQL command: {auto_role_rule.insert_string}" - ) + self._logger.trace(__name__, f"Send SQL command: {auto_role_rule.insert_string}") self._context.cursor.execute(auto_role_rule.insert_string) def update_auto_role_rule(self, auto_role_rule: AutoRoleRule): - self._logger.trace( - __name__, f"Send SQL command: {auto_role_rule.udpate_string}" - ) + self._logger.trace(__name__, f"Send SQL command: {auto_role_rule.udpate_string}") self._context.cursor.execute(auto_role_rule.udpate_string) def delete_auto_role_rule(self, auto_role_rule: AutoRoleRule): - self._logger.trace( - __name__, f"Send SQL command: {auto_role_rule.delete_string}" - ) + self._logger.trace(__name__, f"Send SQL command: {auto_role_rule.delete_string}") self._context.cursor.execute(auto_role_rule.delete_string) diff --git a/bot/src/bot_data/service/client_repository_service.py b/bot/src/bot_data/service/client_repository_service.py index ce92d9ad..e3d08ad3 100644 --- a/bot/src/bot_data/service/client_repository_service.py +++ b/bot/src/bot_data/service/client_repository_service.py @@ -25,9 +25,7 @@ class ClientRepositoryService(ClientRepositoryABC): def get_clients(self) -> List[Client]: clients = List(Client) - self._logger.trace( - __name__, f"Send SQL command: {Client.get_select_all_string()}" - ) + self._logger.trace(__name__, f"Send SQL command: {Client.get_select_all_string()}") results = self._context.select(Client.get_select_all_string()) for result in results: self._logger.trace(__name__, f"Get client with id {result[0]}") @@ -49,9 +47,7 @@ class ClientRepositoryService(ClientRepositoryABC): return clients def get_client_by_id(self, client_id: int) -> Client: - self._logger.trace( - __name__, f"Send SQL command: {Client.get_select_by_id_string(client_id)}" - ) + self._logger.trace(__name__, f"Send SQL command: {Client.get_select_by_id_string(client_id)}") result = self._context.select(Client.get_select_by_id_string(client_id)) return Client( result[1], @@ -96,9 +92,7 @@ class ClientRepositoryService(ClientRepositoryABC): __name__, f"Send SQL command: {Client.get_select_by_discord_id_string(discord_id)}", ) - result = self._context.select( - Client.get_select_by_discord_id_string(discord_id) - )[0] + result = self._context.select(Client.get_select_by_discord_id_string(discord_id))[0] return Client( result[1], result[2], @@ -117,9 +111,7 @@ class ClientRepositoryService(ClientRepositoryABC): __name__, f"Send SQL command: {Client.get_select_by_discord_id_string(discord_id)}", ) - result = self._context.select( - Client.get_select_by_discord_id_string(discord_id) - ) + result = self._context.select(Client.get_select_by_discord_id_string(discord_id)) if result is None or len(result) == 0: return None @@ -162,16 +154,12 @@ class ClientRepositoryService(ClientRepositoryABC): id=result[0], ) - def find_client_by_discord_id_and_server_id( - self, discord_id: int, server_id: int - ) -> Optional[Client]: + def find_client_by_discord_id_and_server_id(self, discord_id: int, server_id: int) -> Optional[Client]: self._logger.trace( __name__, f"Send SQL command: {Client.get_select_by_discord_id_and_server_id_string(discord_id, server_id)}", ) - result = self._context.select( - Client.get_select_by_discord_id_and_server_id_string(discord_id, server_id) - ) + result = self._context.select(Client.get_select_by_discord_id_and_server_id_string(discord_id, server_id)) if result is None or len(result) == 0: return None diff --git a/bot/src/bot_data/service/game_server_repository_service.py b/bot/src/bot_data/service/game_server_repository_service.py index 0a87b95e..1bdd0aeb 100644 --- a/bot/src/bot_data/service/game_server_repository_service.py +++ b/bot/src/bot_data/service/game_server_repository_service.py @@ -42,9 +42,7 @@ class GameServerRepositoryService(GameServerRepositoryABC): ) results = self._context.select(GameServer.get_select_all_string()) for result in results: - self._logger.trace( - __name__, f"Get user-joined-game-server with id {result[0]}" - ) + self._logger.trace(__name__, f"Get user-joined-game-server with id {result[0]}") game_servers.append(self._from_result(result)) return game_servers @@ -57,9 +55,7 @@ class GameServerRepositoryService(GameServerRepositoryABC): ) results = self._context.select(GameServer.get_select_by_server_id_string(id)) for result in results: - self._logger.trace( - __name__, f"Get user-joined-game-server with id {result[0]}" - ) + self._logger.trace(__name__, f"Get user-joined-game-server with id {result[0]}") game_servers.append(self._from_result(result)) return game_servers diff --git a/bot/src/bot_data/service/known_user_repository_service.py b/bot/src/bot_data/service/known_user_repository_service.py index 5ef2d7c5..b7dc57e2 100644 --- a/bot/src/bot_data/service/known_user_repository_service.py +++ b/bot/src/bot_data/service/known_user_repository_service.py @@ -25,9 +25,7 @@ class KnownUserRepositoryService(KnownUserRepositoryABC): def get_users(self) -> List[KnownUser]: users = List(KnownUser) - self._logger.trace( - __name__, f"Send SQL command: {KnownUser.get_select_all_string()}" - ) + self._logger.trace(__name__, f"Send SQL command: {KnownUser.get_select_all_string()}") results = self._context.select(KnownUser.get_select_all_string()) for result in results: self._logger.trace(__name__, f"Get known_user with id {result[0]}") @@ -36,9 +34,7 @@ class KnownUserRepositoryService(KnownUserRepositoryABC): return users def get_user_by_id(self, id: int) -> KnownUser: - self._logger.trace( - __name__, f"Send SQL command: {KnownUser.get_select_by_id_string(id)}" - ) + self._logger.trace(__name__, f"Send SQL command: {KnownUser.get_select_by_id_string(id)}") result = self._context.select(KnownUser.get_select_by_id_string(id)) return KnownUser(result[1], result[2], result[3], id=result[0]) @@ -47,9 +43,7 @@ class KnownUserRepositoryService(KnownUserRepositoryABC): __name__, f"Send SQL command: {KnownUser.get_select_by_discord_id_string(discord_id)}", ) - result = self._context.select( - KnownUser.get_select_by_discord_id_string(discord_id) - )[0] + result = self._context.select(KnownUser.get_select_by_discord_id_string(discord_id))[0] return KnownUser(result[1], result[2], result[3], id=result[0]) def find_user_by_discord_id(self, discord_id: int) -> Optional[KnownUser]: @@ -57,9 +51,7 @@ class KnownUserRepositoryService(KnownUserRepositoryABC): __name__, f"Send SQL command: {KnownUser.get_select_by_discord_id_string(discord_id)}", ) - result = self._context.select( - KnownUser.get_select_by_discord_id_string(discord_id) - ) + result = self._context.select(KnownUser.get_select_by_discord_id_string(discord_id)) if result is None or len(result) == 0: return None diff --git a/bot/src/bot_data/service/level_repository_service.py b/bot/src/bot_data/service/level_repository_service.py index e7828104..c713c0da 100644 --- a/bot/src/bot_data/service/level_repository_service.py +++ b/bot/src/bot_data/service/level_repository_service.py @@ -42,9 +42,7 @@ class LevelRepositoryService(LevelRepositoryABC): def get_levels(self) -> List[Level]: levels = List(Level) - self._logger.trace( - __name__, f"Send SQL command: {Level.get_select_all_string()}" - ) + self._logger.trace(__name__, f"Send SQL command: {Level.get_select_all_string()}") results = self._context.select(Level.get_select_all_string()) for result in results: self._logger.trace(__name__, f"Get level with id {result[0]}") @@ -53,17 +51,13 @@ class LevelRepositoryService(LevelRepositoryABC): return levels def get_level_by_id(self, id: int) -> Level: - self._logger.trace( - __name__, f"Send SQL command: {Level.get_select_by_id_string(id)}" - ) + self._logger.trace(__name__, f"Send SQL command: {Level.get_select_by_id_string(id)}") result = self._context.select(Level.get_select_by_id_string(id))[0] return self._level_from_result(result) def find_level_by_id(self, id: int) -> Optional[Level]: - self._logger.trace( - __name__, f"Send SQL command: {Level.get_select_by_id_string(id)}" - ) + self._logger.trace(__name__, f"Send SQL command: {Level.get_select_by_id_string(id)}") result = self._context.select(Level.get_select_by_id_string(id)) if result is None or len(result) == 0: return None diff --git a/bot/src/bot_data/service/migration_service.py b/bot/src/bot_data/service/migration_service.py index cf6303e9..dc6436a7 100644 --- a/bot/src/bot_data/service/migration_service.py +++ b/bot/src/bot_data/service/migration_service.py @@ -21,9 +21,7 @@ class MigrationService: self._cursor = db.cursor self._migrations: List[MigrationABC] = ( - List(type, MigrationABC.__subclasses__()) - .order_by(lambda x: x.name) - .order_by(lambda x: x.prio) + List(type, MigrationABC.__subclasses__()).order_by(lambda x: x.name).order_by(lambda x: x.prio) ) def migrate(self): @@ -40,21 +38,15 @@ class MigrationService: __name__, f"Running SQL Command: {MigrationHistory.get_select_by_id_string(migration_id)}", ) - migration_from_db = self._db.select( - MigrationHistory.get_select_by_id_string(migration_id) - ) + migration_from_db = self._db.select(MigrationHistory.get_select_by_id_string(migration_id)) if migration_from_db is not None and len(migration_from_db) > 0: continue self._logger.debug(__name__, f"Running Migration {migration_id}") - migration_as_service: MigrationABC = self._services.get_service( - migration - ) + migration_as_service: MigrationABC = self._services.get_service(migration) migration_as_service.upgrade() self._cursor.execute(MigrationHistory(migration_id).insert_string) self._db.save_changes() except Exception as e: - self._logger.error( - __name__, f"Cannot get migration with id {migration}", e - ) + self._logger.error(__name__, f"Cannot get migration with id {migration}", e) diff --git a/bot/src/bot_data/service/server_config_repository_service.py b/bot/src/bot_data/service/server_config_repository_service.py index 9ff8bf10..45d1aeaa 100644 --- a/bot/src/bot_data/service/server_config_repository_service.py +++ b/bot/src/bot_data/service/server_config_repository_service.py @@ -31,13 +31,9 @@ class ServerConfigRepositoryService(ServerConfigRepositoryABC): __name__, f"Send SQL command: {ServerTeamRoleIdsConfig.get_select_by_server_id_string(server_id)}", ) - results = self._context.select( - ServerTeamRoleIdsConfig.get_select_by_server_id_string(server_id) - ) + results = self._context.select(ServerTeamRoleIdsConfig.get_select_by_server_id_string(server_id)) for result in results: - self._logger.trace( - __name__, f"Got ServerTeamRoleIdsConfig with id {result[0]}" - ) + self._logger.trace(__name__, f"Got ServerTeamRoleIdsConfig with id {result[0]}") ids.append( ServerTeamRoleIdsConfig( result[1], @@ -57,13 +53,9 @@ class ServerConfigRepositoryService(ServerConfigRepositoryABC): __name__, f"Send SQL command: {ServerAFKChannelIdsConfig.get_select_by_server_id_string(server_id)}", ) - results = self._context.select( - ServerAFKChannelIdsConfig.get_select_by_server_id_string(server_id) - ) + results = self._context.select(ServerAFKChannelIdsConfig.get_select_by_server_id_string(server_id)) for result in results: - self._logger.trace( - __name__, f"Got ServerAFKChannelIdsConfig with id {result[0]}" - ) + self._logger.trace(__name__, f"Got ServerAFKChannelIdsConfig with id {result[0]}") urls.append(result[1]) return urls @@ -101,9 +93,7 @@ class ServerConfigRepositoryService(ServerConfigRepositoryABC): __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) - ) + result = self._context.select(ServerConfig.get_select_by_server_id_string(server_id)) return len(result) > 0 @@ -112,9 +102,7 @@ class ServerConfigRepositoryService(ServerConfigRepositoryABC): __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] + result = self._context.select(ServerConfig.get_select_by_server_id_string(server_id))[0] return self._from_result(result) @@ -123,9 +111,7 @@ class ServerConfigRepositoryService(ServerConfigRepositoryABC): __name__, f"Send SQL command: {ServerConfig.get_select_by_id_string(config_id)}", ) - result = self._context.select(ServerConfig.get_select_by_id_string(config_id))[ - 0 - ] + result = self._context.select(ServerConfig.get_select_by_id_string(config_id))[0] return self._from_result(result) @@ -141,50 +127,26 @@ class ServerConfigRepositoryService(ServerConfigRepositoryABC): self._logger.trace(__name__, f"Send SQL command: {server_config.delete_string}") self._context.cursor.execute(server_config.delete_string) - def add_server_team_role_id_config( - self, server_team_role_id: ServerTeamRoleIdsConfig - ): - self._logger.trace( - __name__, f"Send SQL command: {server_team_role_id.insert_string}" - ) + def add_server_team_role_id_config(self, server_team_role_id: ServerTeamRoleIdsConfig): + self._logger.trace(__name__, f"Send SQL command: {server_team_role_id.insert_string}") self._context.cursor.execute(server_team_role_id.insert_string) - def update_server_team_role_id_config( - self, server_team_role_id: ServerTeamRoleIdsConfig - ): - self._logger.trace( - __name__, f"Send SQL command: {server_team_role_id.udpate_string}" - ) + def update_server_team_role_id_config(self, server_team_role_id: ServerTeamRoleIdsConfig): + self._logger.trace(__name__, f"Send SQL command: {server_team_role_id.udpate_string}") self._context.cursor.execute(server_team_role_id.udpate_string) - def delete_server_team_role_id_config( - self, server_team_role_id: ServerTeamRoleIdsConfig - ): - self._logger.trace( - __name__, f"Send SQL command: {server_team_role_id.delete_string}" - ) + def delete_server_team_role_id_config(self, server_team_role_id: ServerTeamRoleIdsConfig): + self._logger.trace(__name__, f"Send SQL command: {server_team_role_id.delete_string}") self._context.cursor.execute(server_team_role_id.delete_string) - def add_server_afk_channel_config( - self, server_afk_channel: ServerAFKChannelIdsConfig - ): - self._logger.trace( - __name__, f"Send SQL command: {server_afk_channel.insert_string}" - ) + def add_server_afk_channel_config(self, server_afk_channel: ServerAFKChannelIdsConfig): + self._logger.trace(__name__, f"Send SQL command: {server_afk_channel.insert_string}") self._context.cursor.execute(server_afk_channel.insert_string) - def update_server_afk_channel_config( - self, server_afk_channel: ServerAFKChannelIdsConfig - ): - self._logger.trace( - __name__, f"Send SQL command: {server_afk_channel.udpate_string}" - ) + def update_server_afk_channel_config(self, server_afk_channel: ServerAFKChannelIdsConfig): + self._logger.trace(__name__, f"Send SQL command: {server_afk_channel.udpate_string}") self._context.cursor.execute(server_afk_channel.udpate_string) - def delete_server_afk_channel_config( - self, server_afk_channel: ServerAFKChannelIdsConfig - ): - self._logger.trace( - __name__, f"Send SQL command: {server_afk_channel.delete_string}" - ) + def delete_server_afk_channel_config(self, server_afk_channel: ServerAFKChannelIdsConfig): + self._logger.trace(__name__, f"Send SQL command: {server_afk_channel.delete_string}") self._context.cursor.execute(server_afk_channel.delete_string) diff --git a/bot/src/bot_data/service/server_repository_service.py b/bot/src/bot_data/service/server_repository_service.py index 43f54c3d..5817d7dc 100644 --- a/bot/src/bot_data/service/server_repository_service.py +++ b/bot/src/bot_data/service/server_repository_service.py @@ -26,9 +26,7 @@ class ServerRepositoryService(ServerRepositoryABC): def get_servers(self) -> List[Server]: servers = List(Server) - self._logger.trace( - __name__, f"Send SQL command: {Server.get_select_all_string()}" - ) + self._logger.trace(__name__, f"Send SQL command: {Server.get_select_all_string()}") results = self._context.select(Server.get_select_all_string()) for result in results: servers.append(Server(result[1], result[2], result[3], id=result[0])) @@ -38,9 +36,7 @@ class ServerRepositoryService(ServerRepositoryABC): def get_filtered_servers(self, criteria: ServerSelectCriteria) -> FilteredResult: servers = self.get_servers() - self._logger.trace( - __name__, f"Send SQL command: {Server.get_select_all_string()}" - ) + self._logger.trace(__name__, f"Send SQL command: {Server.get_select_all_string()}") query = servers # sort @@ -52,9 +48,7 @@ class ServerRepositoryService(ServerRepositoryABC): ): 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)) else: query = query.order_by(lambda x: getattr(x, criteria.sort_column)) @@ -66,25 +60,19 @@ class ServerRepositoryService(ServerRepositoryABC): return result def get_server_by_id(self, server_id: int) -> Server: - cs = self._cache.cached_server.where( - lambda x: x.id == server_id - ).single_or_default() + cs = self._cache.cached_server.where(lambda x: x.id == server_id).single_or_default() if cs is not None: return cs - self._logger.trace( - __name__, f"Send SQL command: {Server.get_select_by_id_string(server_id)}" - ) + self._logger.trace(__name__, f"Send SQL command: {Server.get_select_by_id_string(server_id)}") result = self._context.select(Server.get_select_by_id_string(server_id))[0] server = Server(result[1], result[2], result[3], id=result[0]) self._cache.add_server(server) return server def get_server_by_discord_id(self, discord_id: int) -> Server: - cs = self._cache.cached_server.where( - lambda x: x.discord_id == discord_id - ).single_or_default() + cs = self._cache.cached_server.where(lambda x: x.discord_id == discord_id).single_or_default() if cs is not None: return cs @@ -92,15 +80,11 @@ class ServerRepositoryService(ServerRepositoryABC): __name__, f"Send SQL command: {Server.get_select_by_discord_id_string(discord_id)}", ) - result = self._context.select( - Server.get_select_by_discord_id_string(discord_id) - )[0] + result = self._context.select(Server.get_select_by_discord_id_string(discord_id))[0] return Server(result[1], result[2], result[3], id=result[0]) def find_server_by_discord_id(self, discord_id: int) -> Optional[Server]: - cs = self._cache.cached_server.where( - lambda x: x.discord_id == discord_id - ).single_or_default() + cs = self._cache.cached_server.where(lambda x: x.discord_id == discord_id).single_or_default() if cs is not None: return cs @@ -108,9 +92,7 @@ class ServerRepositoryService(ServerRepositoryABC): __name__, f"Send SQL command: {Server.get_select_by_discord_id_string(discord_id)}", ) - result = self._context.select( - Server.get_select_by_discord_id_string(discord_id) - ) + result = self._context.select(Server.get_select_by_discord_id_string(discord_id)) if result is None or len(result) == 0: return None diff --git a/bot/src/bot_data/service/short_role_name_repository_service.py b/bot/src/bot_data/service/short_role_name_repository_service.py index 5b6a929e..3c4bed64 100644 --- a/bot/src/bot_data/service/short_role_name_repository_service.py +++ b/bot/src/bot_data/service/short_role_name_repository_service.py @@ -35,9 +35,7 @@ class ShortRoleNameRepositoryService(ShortRoleNameRepositoryABC): return ShortRoleName( self._get_value_from_result(sql_result[1]), # name int(self._get_value_from_result(sql_result[2])), # role_id - ShortRoleNamePositionEnum( - self._get_value_from_result(sql_result[3]) - ), # position + ShortRoleNamePositionEnum(self._get_value_from_result(sql_result[3])), # position self._servers.get_server_by_id(sql_result[4]), # server self._get_value_from_result(sql_result[5]), # created_at self._get_value_from_result(sql_result[6]), # modified_at @@ -46,9 +44,7 @@ class ShortRoleNameRepositoryService(ShortRoleNameRepositoryABC): def get_short_role_names(self) -> List[ShortRoleName]: short_role_names = List(ShortRoleName) - self._logger.trace( - __name__, f"Send SQL command: {ShortRoleName.get_select_all_string()}" - ) + self._logger.trace(__name__, f"Send SQL command: {ShortRoleName.get_select_all_string()}") results = self._context.select(ShortRoleName.get_select_all_string()) for result in results: self._logger.trace(__name__, f"Get short_role_name with id {result[0]}") @@ -57,9 +53,7 @@ class ShortRoleNameRepositoryService(ShortRoleNameRepositoryABC): return short_role_names def get_short_role_name_by_id(self, id: int) -> ShortRoleName: - self._logger.trace( - __name__, f"Send SQL command: {ShortRoleName.get_select_by_id_string(id)}" - ) + self._logger.trace(__name__, f"Send SQL command: {ShortRoleName.get_select_by_id_string(id)}") result = self._context.select(ShortRoleName.get_select_by_id_string(id))[0] return self._short_role_name_from_result(result) @@ -70,9 +64,7 @@ class ShortRoleNameRepositoryService(ShortRoleNameRepositoryABC): __name__, f"Send SQL command: {ShortRoleName.get_select_by_role_id_string(role_id)}", ) - results = self._context.select( - ShortRoleName.get_select_by_role_id_string(role_id) - ) + results = self._context.select(ShortRoleName.get_select_by_role_id_string(role_id)) for result in results: self._logger.trace(__name__, f"Get short_role_name with id {result[0]}") short_role_names.append(self._short_role_name_from_result(result)) @@ -85,9 +77,7 @@ class ShortRoleNameRepositoryService(ShortRoleNameRepositoryABC): __name__, f"Send SQL command: {ShortRoleName.get_select_by_server_id_string(server_id)}", ) - results = self._context.select( - ShortRoleName.get_select_by_server_id_string(server_id) - ) + results = self._context.select(ShortRoleName.get_select_by_server_id_string(server_id)) for result in results: self._logger.trace(__name__, f"Get short_role_name with id {result[0]}") @@ -96,19 +86,13 @@ class ShortRoleNameRepositoryService(ShortRoleNameRepositoryABC): return short_role_names def add_short_role_name(self, short_role_name: ShortRoleName): - self._logger.trace( - __name__, f"Send SQL command: {short_role_name.insert_string}" - ) + self._logger.trace(__name__, f"Send SQL command: {short_role_name.insert_string}") self._context.cursor.execute(short_role_name.insert_string) def update_short_role_name(self, short_role_name: ShortRoleName): - self._logger.trace( - __name__, f"Send SQL command: {short_role_name.udpate_string}" - ) + self._logger.trace(__name__, f"Send SQL command: {short_role_name.udpate_string}") self._context.cursor.execute(short_role_name.udpate_string) def delete_short_role_name(self, short_role_name: ShortRoleName): - self._logger.trace( - __name__, f"Send SQL command: {short_role_name.delete_string}" - ) + self._logger.trace(__name__, f"Send SQL command: {short_role_name.delete_string}") self._context.cursor.execute(short_role_name.delete_string) diff --git a/bot/src/bot_data/service/steam_special_offer_repository_service.py b/bot/src/bot_data/service/steam_special_offer_repository_service.py index 256f01b2..dfd0e7ee 100644 --- a/bot/src/bot_data/service/steam_special_offer_repository_service.py +++ b/bot/src/bot_data/service/steam_special_offer_repository_service.py @@ -43,9 +43,7 @@ class SteamSpecialOfferRepositoryService(SteamSpecialOfferRepositoryABC): def get_steam_special_offers(self) -> List[SteamSpecialOffer]: steam_special_offers = List(SteamSpecialOffer) - self._logger.trace( - __name__, f"Send SQL command: {SteamSpecialOffer.get_select_all_string()}" - ) + self._logger.trace(__name__, f"Send SQL command: {SteamSpecialOffer.get_select_all_string()}") results = self._context.select(SteamSpecialOffer.get_select_all_string()) for result in results: self._logger.trace(__name__, f"Get steam_special_offer with id {result[0]}") @@ -58,26 +56,18 @@ class SteamSpecialOfferRepositoryService(SteamSpecialOfferRepositoryABC): __name__, f"Send SQL command: {SteamSpecialOffer.get_select_by_name_string(name)}", ) - result = self._context.select( - SteamSpecialOffer.get_select_by_name_string(name) - )[0] + result = self._context.select(SteamSpecialOffer.get_select_by_name_string(name))[0] return self._steam_special_offer_from_result(result) def add_steam_special_offer(self, steam_special_offer: SteamSpecialOffer): - self._logger.trace( - __name__, f"Send SQL command: {steam_special_offer.insert_string}" - ) + self._logger.trace(__name__, f"Send SQL command: {steam_special_offer.insert_string}") self._context.cursor.execute(steam_special_offer.insert_string) def update_steam_special_offer(self, steam_special_offer: SteamSpecialOffer): - self._logger.trace( - __name__, f"Send SQL command: {steam_special_offer.udpate_string}" - ) + self._logger.trace(__name__, f"Send SQL command: {steam_special_offer.udpate_string}") self._context.cursor.execute(steam_special_offer.udpate_string) def delete_steam_special_offer(self, steam_special_offer: SteamSpecialOffer): - self._logger.trace( - __name__, f"Send SQL command: {steam_special_offer.delete_string}" - ) + self._logger.trace(__name__, f"Send SQL command: {steam_special_offer.delete_string}") self._context.cursor.execute(steam_special_offer.delete_string) diff --git a/bot/src/bot_data/service/technician_config_repository_service.py b/bot/src/bot_data/service/technician_config_repository_service.py index 3d31b415..3500bbde 100644 --- a/bot/src/bot_data/service/technician_config_repository_service.py +++ b/bot/src/bot_data/service/technician_config_repository_service.py @@ -19,9 +19,7 @@ class TechnicianConfigRepositoryService(TechnicianConfigRepositoryABC): def _get_technician_ids(self) -> List[int]: ids = List(int) - self._logger.trace( - __name__, f"Send SQL command: {TechnicianIdConfig.get_select_all_string()}" - ) + self._logger.trace(__name__, f"Send SQL command: {TechnicianIdConfig.get_select_all_string()}") results = self._context.select(TechnicianIdConfig.get_select_all_string()) for result in results: self._logger.trace(__name__, f"Got TechnicianId with id {result[0]}") @@ -57,37 +55,27 @@ class TechnicianConfigRepositoryService(TechnicianConfigRepositoryABC): ) def does_technician_config_exists(self) -> bool: - self._logger.trace( - __name__, f"Send SQL command: {TechnicianConfig.get_select_all_string()}" - ) + self._logger.trace(__name__, f"Send SQL command: {TechnicianConfig.get_select_all_string()}") result = self._context.select(TechnicianConfig.get_select_all_string()) return len(result) > 0 def get_technician_config(self) -> TechnicianConfig: - self._logger.trace( - __name__, f"Send SQL command: {TechnicianConfig.get_select_all_string()}" - ) + self._logger.trace(__name__, f"Send SQL command: {TechnicianConfig.get_select_all_string()}") result = self._context.select(TechnicianConfig.get_select_all_string())[0] return self._from_result(result) def add_technician_config(self, technician_config: TechnicianConfig): - self._logger.trace( - __name__, f"Send SQL command: {technician_config.insert_string}" - ) + self._logger.trace(__name__, f"Send SQL command: {technician_config.insert_string}") self._context.cursor.execute(technician_config.insert_string) def update_technician_config(self, technician_config: TechnicianConfig): - self._logger.trace( - __name__, f"Send SQL command: {technician_config.udpate_string}" - ) + self._logger.trace(__name__, f"Send SQL command: {technician_config.udpate_string}") self._context.cursor.execute(technician_config.udpate_string) def delete_technician_config(self, technician_config: TechnicianConfig): - self._logger.trace( - __name__, f"Send SQL command: {technician_config.delete_string}" - ) + self._logger.trace(__name__, f"Send SQL command: {technician_config.delete_string}") self._context.cursor.execute(technician_config.delete_string) def add_technician_id_config(self, technician_id: TechnicianIdConfig): @@ -102,26 +90,14 @@ class TechnicianConfigRepositoryService(TechnicianConfigRepositoryABC): self._logger.trace(__name__, f"Send SQL command: {technician_id.delete_string}") self._context.cursor.execute(technician_id.delete_string) - def add_technician_ping_url_config( - self, technician_ping_url: TechnicianPingUrlConfig - ): - self._logger.trace( - __name__, f"Send SQL command: {technician_ping_url.insert_string}" - ) + def add_technician_ping_url_config(self, technician_ping_url: TechnicianPingUrlConfig): + self._logger.trace(__name__, f"Send SQL command: {technician_ping_url.insert_string}") self._context.cursor.execute(technician_ping_url.insert_string) - def update_technician_ping_url_config( - self, technician_ping_url: TechnicianPingUrlConfig - ): - self._logger.trace( - __name__, f"Send SQL command: {technician_ping_url.udpate_string}" - ) + def update_technician_ping_url_config(self, technician_ping_url: TechnicianPingUrlConfig): + self._logger.trace(__name__, f"Send SQL command: {technician_ping_url.udpate_string}") self._context.cursor.execute(technician_ping_url.udpate_string) - def delete_technician_ping_url_config( - self, technician_ping_url: TechnicianPingUrlConfig - ): - self._logger.trace( - __name__, f"Send SQL command: {technician_ping_url.delete_string}" - ) + def delete_technician_ping_url_config(self, technician_ping_url: TechnicianPingUrlConfig): + self._logger.trace(__name__, f"Send SQL command: {technician_ping_url.delete_string}") self._context.cursor.execute(technician_ping_url.delete_string) diff --git a/bot/src/bot_data/service/technician_config_seeder.py b/bot/src/bot_data/service/technician_config_seeder.py index 09dfd3bc..3107db0a 100644 --- a/bot/src/bot_data/service/technician_config_seeder.py +++ b/bot/src/bot_data/service/technician_config_seeder.py @@ -42,14 +42,10 @@ class TechnicianConfigSeeder(DataSeederABC): self._technician_config.add_technician_config(config) for technician in config.technician_ids: - self._technician_config.add_technician_id_config( - TechnicianIdConfig(technician) - ) + self._technician_config.add_technician_id_config(TechnicianIdConfig(technician)) for url in config.ping_urls: - self._technician_config.add_technician_ping_url_config( - TechnicianPingUrlConfig(url) - ) + self._technician_config.add_technician_ping_url_config(TechnicianPingUrlConfig(url)) self._db.save_changes() self._logger.debug(__name__, "Seeded technician config") diff --git a/bot/src/bot_data/service/user_game_ident_repository_service.py b/bot/src/bot_data/service/user_game_ident_repository_service.py index 0039d85e..d0dfc38b 100644 --- a/bot/src/bot_data/service/user_game_ident_repository_service.py +++ b/bot/src/bot_data/service/user_game_ident_repository_service.py @@ -51,17 +51,13 @@ class UserGameIdentRepositoryService(UserGameIdentRepositoryABC): return joins - def get_user_game_idents_by_game_server_id( - self, game_server_id: int - ) -> List[UserGameIdent]: + def get_user_game_idents_by_game_server_id(self, game_server_id: int) -> List[UserGameIdent]: joins = List(UserGameIdent) self._logger.trace( __name__, f"Send SQL command: {UserGameIdent.get_select_by_game_server_id_string(game_server_id)}", ) - results = self._context.select( - UserGameIdent.get_select_by_game_server_id_string(game_server_id) - ) + results = self._context.select(UserGameIdent.get_select_by_game_server_id_string(game_server_id)) for result in results: self._logger.trace(__name__, f"Get UserGameIdent with id {result[0]}") joins.append(self._from_result(result)) @@ -81,9 +77,7 @@ class UserGameIdentRepositoryService(UserGameIdentRepositoryABC): __name__, f"Send SQL command: {UserGameIdent.get_select_by_ident_string(ident)}", ) - result = self._context.select(UserGameIdent.get_select_by_ident_string(ident))[ - 0 - ] + result = self._context.select(UserGameIdent.get_select_by_ident_string(ident))[0] return self._from_result(result) def find_user_game_ident_by_ident(self, ident: str) -> Optional[UserGameIdent]: @@ -104,30 +98,22 @@ class UserGameIdentRepositoryService(UserGameIdentRepositoryABC): __name__, f"Send SQL command: {UserGameIdent.get_select_by_user_id_string(user_id)}", ) - results = self._context.select( - UserGameIdent.get_select_by_user_id_string(user_id) - ) + results = self._context.select(UserGameIdent.get_select_by_user_id_string(user_id)) for result in results: joins.append(self._from_result(result)) return joins def add_user_game_ident(self, user_game_ident: UserGameIdent): - self._logger.trace( - __name__, f"Send SQL command: {user_game_ident.insert_string}" - ) + self._logger.trace(__name__, f"Send SQL command: {user_game_ident.insert_string}") self._context.cursor.execute(user_game_ident.insert_string) def update_user_game_ident(self, user_game_ident: UserGameIdent): - self._logger.trace( - __name__, f"Send SQL command: {user_game_ident.udpate_string}" - ) + self._logger.trace(__name__, f"Send SQL command: {user_game_ident.udpate_string}") self._context.cursor.execute(user_game_ident.udpate_string) def delete_user_game_ident(self, user_game_ident: UserGameIdent): - self._logger.trace( - __name__, f"Send SQL command: {user_game_ident.delete_string}" - ) + self._logger.trace(__name__, f"Send SQL command: {user_game_ident.delete_string}") self._context.cursor.execute(user_game_ident.delete_string) def delete_user_game_ident_by_user_id(self, user_id: int): diff --git a/bot/src/bot_data/service/user_joined_game_server_repository_service.py b/bot/src/bot_data/service/user_joined_game_server_repository_service.py index 5f1a3627..e9ded8ba 100644 --- a/bot/src/bot_data/service/user_joined_game_server_repository_service.py +++ b/bot/src/bot_data/service/user_joined_game_server_repository_service.py @@ -46,9 +46,7 @@ class UserJoinedGameServerRepositoryService(UserJoinedGameServerRepositoryABC): ) results = self._context.select(UserJoinedGameServer.get_select_all_string()) for result in results: - self._logger.trace( - __name__, f"Get user-joined-game-server with id {result[0]}" - ) + self._logger.trace(__name__, f"Get user-joined-game-server with id {result[0]}") joins.append(self._from_result(result)) return joins @@ -58,49 +56,35 @@ class UserJoinedGameServerRepositoryService(UserJoinedGameServerRepositoryABC): __name__, f"Send SQL command: {UserJoinedGameServer.get_select_by_id_string(id)}", ) - result = self._context.select(UserJoinedGameServer.get_select_by_id_string(id))[ - 0 - ] + result = self._context.select(UserJoinedGameServer.get_select_by_id_string(id))[0] return self._from_result(result) - def get_user_joined_game_servers_by_user_id( - self, user_id: int - ) -> List[UserJoinedGameServer]: + def get_user_joined_game_servers_by_user_id(self, user_id: int) -> List[UserJoinedGameServer]: joins = List(UserJoinedGameServer) self._logger.trace( __name__, f"Send SQL command: {UserJoinedGameServer.get_select_by_user_id_string(user_id)}", ) - results = self._context.select( - UserJoinedGameServer.get_select_by_user_id_string(user_id) - ) + results = self._context.select(UserJoinedGameServer.get_select_by_user_id_string(user_id)) for result in results: joins.append(self._from_result(result)) return joins - def get_active_user_joined_game_server_by_user_id( - self, user_id: int - ) -> UserJoinedGameServer: + def get_active_user_joined_game_server_by_user_id(self, user_id: int) -> UserJoinedGameServer: self._logger.trace( __name__, f"Send SQL command: {UserJoinedGameServer.get_select_by_user_id_string(user_id)}", ) - result = self._context.select( - UserJoinedGameServer.get_select_active_by_user_id_string(user_id) - )[0] + result = self._context.select(UserJoinedGameServer.get_select_active_by_user_id_string(user_id))[0] return self._from_result(result) - def find_active_user_joined_game_server_by_user_id( - self, user_id: int - ) -> Optional[UserJoinedGameServer]: + def find_active_user_joined_game_server_by_user_id(self, user_id: int) -> Optional[UserJoinedGameServer]: self._logger.trace( __name__, f"Send SQL command: {UserJoinedGameServer.get_select_by_user_id_string(user_id)}", ) - result = self._context.select( - UserJoinedGameServer.get_select_active_by_user_id_string(user_id) - ) + result = self._context.select(UserJoinedGameServer.get_select_active_by_user_id_string(user_id)) if result is None or len(result) == 0: return None @@ -108,45 +92,29 @@ class UserJoinedGameServerRepositoryService(UserJoinedGameServerRepositoryABC): return self._from_result(result) - def find_active_user_joined_game_servers_by_user_id( - self, user_id: int - ) -> List[Optional[UserJoinedGameServer]]: + def find_active_user_joined_game_servers_by_user_id(self, user_id: int) -> List[Optional[UserJoinedGameServer]]: self._logger.trace( __name__, f"Send SQL command: {UserJoinedGameServer.get_select_active_by_user_id_string(user_id)}", ) result = List(UserJoinedGameServer) - db_results = self._context.select( - UserJoinedGameServer.get_select_active_by_user_id_string(user_id) - ) + db_results = self._context.select(UserJoinedGameServer.get_select_active_by_user_id_string(user_id)) for db_result in db_results: result.append(self._from_result(db_result)) return result - def add_user_joined_game_server( - self, user_joined_game_server: UserJoinedGameServer - ): - self._logger.trace( - __name__, f"Send SQL command: {user_joined_game_server.insert_string}" - ) + def add_user_joined_game_server(self, user_joined_game_server: UserJoinedGameServer): + self._logger.trace(__name__, f"Send SQL command: {user_joined_game_server.insert_string}") self._context.cursor.execute(user_joined_game_server.insert_string) - def update_user_joined_game_server( - self, user_joined_game_server: UserJoinedGameServer - ): - self._logger.trace( - __name__, f"Send SQL command: {user_joined_game_server.udpate_string}" - ) + def update_user_joined_game_server(self, user_joined_game_server: UserJoinedGameServer): + self._logger.trace(__name__, f"Send SQL command: {user_joined_game_server.udpate_string}") self._context.cursor.execute(user_joined_game_server.udpate_string) - def delete_user_joined_game_server( - self, user_joined_game_server: UserJoinedGameServer - ): - self._logger.trace( - __name__, f"Send SQL command: {user_joined_game_server.delete_string}" - ) + def delete_user_joined_game_server(self, user_joined_game_server: UserJoinedGameServer): + self._logger.trace(__name__, f"Send SQL command: {user_joined_game_server.delete_string}") self._context.cursor.execute(user_joined_game_server.delete_string) def delete_user_joined_game_server_by_user_id(self, user_id: int): @@ -154,6 +122,4 @@ class UserJoinedGameServerRepositoryService(UserJoinedGameServerRepositoryABC): __name__, f"Send SQL command: {UserJoinedGameServer.delete_by_user_id_string}", ) - self._context.cursor.execute( - UserJoinedGameServer.delete_by_user_id_string(user_id) - ) + self._context.cursor.execute(UserJoinedGameServer.delete_by_user_id_string(user_id)) diff --git a/bot/src/bot_data/service/user_joined_server_repository_service.py b/bot/src/bot_data/service/user_joined_server_repository_service.py index 02d8f948..abd0a17b 100644 --- a/bot/src/bot_data/service/user_joined_server_repository_service.py +++ b/bot/src/bot_data/service/user_joined_server_repository_service.py @@ -25,9 +25,7 @@ class UserJoinedServerRepositoryService(UserJoinedServerRepositoryABC): def get_user_joined_servers(self) -> List[UserJoinedServer]: joins = List(UserJoinedServer) - self._logger.trace( - __name__, f"Send SQL command: {UserJoinedServer.get_select_all_string()}" - ) + self._logger.trace(__name__, f"Send SQL command: {UserJoinedServer.get_select_all_string()}") results = self._context.select(UserJoinedServer.get_select_all_string()) for result in results: self._logger.trace(__name__, f"Get user-joined-server with id {result[0]}") @@ -74,17 +72,13 @@ class UserJoinedServerRepositoryService(UserJoinedServerRepositoryABC): id=result[0], ) - def get_user_joined_servers_by_user_id( - self, user_id: int - ) -> List[UserJoinedServer]: + def get_user_joined_servers_by_user_id(self, user_id: int) -> List[UserJoinedServer]: joins = List(UserJoinedServer) self._logger.trace( __name__, f"Send SQL command: {UserJoinedServer.get_select_by_user_id_string(user_id)}", ) - results = self._context.select( - UserJoinedServer.get_select_by_user_id_string(user_id) - ) + results = self._context.select(UserJoinedServer.get_select_by_user_id_string(user_id)) for result in results: joins.append( UserJoinedServer( @@ -99,16 +93,12 @@ class UserJoinedServerRepositoryService(UserJoinedServerRepositoryABC): return joins - def get_active_user_joined_server_by_user_id( - self, user_id: int - ) -> UserJoinedServer: + def get_active_user_joined_server_by_user_id(self, user_id: int) -> UserJoinedServer: self._logger.trace( __name__, f"Send SQL command: {UserJoinedServer.get_select_by_user_id_string(user_id)}", ) - result = self._context.select( - UserJoinedServer.get_select_active_by_user_id_string(user_id) - )[0] + result = self._context.select(UserJoinedServer.get_select_active_by_user_id_string(user_id))[0] return UserJoinedServer( self._users.get_user_by_id(result[1]), result[2], @@ -118,16 +108,12 @@ class UserJoinedServerRepositoryService(UserJoinedServerRepositoryABC): id=result[0], ) - def find_active_user_joined_server_by_user_id( - self, user_id: int - ) -> Optional[UserJoinedServer]: + def find_active_user_joined_server_by_user_id(self, user_id: int) -> Optional[UserJoinedServer]: self._logger.trace( __name__, f"Send SQL command: {UserJoinedServer.get_select_by_user_id_string(user_id)}", ) - result = self._context.select( - UserJoinedServer.get_select_active_by_user_id_string(user_id) - ) + result = self._context.select(UserJoinedServer.get_select_active_by_user_id_string(user_id)) if result is None or len(result) == 0: return None @@ -143,19 +129,13 @@ class UserJoinedServerRepositoryService(UserJoinedServerRepositoryABC): ) def add_user_joined_server(self, user_joined_server: UserJoinedServer): - self._logger.trace( - __name__, f"Send SQL command: {user_joined_server.insert_string}" - ) + self._logger.trace(__name__, f"Send SQL command: {user_joined_server.insert_string}") self._context.cursor.execute(user_joined_server.insert_string) def update_user_joined_server(self, user_joined_server: UserJoinedServer): - self._logger.trace( - __name__, f"Send SQL command: {user_joined_server.udpate_string}" - ) + self._logger.trace(__name__, f"Send SQL command: {user_joined_server.udpate_string}") self._context.cursor.execute(user_joined_server.udpate_string) def delete_user_joined_server(self, user_joined_server: UserJoinedServer): - self._logger.trace( - __name__, f"Send SQL command: {user_joined_server.delete_string}" - ) + self._logger.trace(__name__, f"Send SQL command: {user_joined_server.delete_string}") self._context.cursor.execute(user_joined_server.delete_string) diff --git a/bot/src/bot_data/service/user_joined_voice_channel_repository_service.py b/bot/src/bot_data/service/user_joined_voice_channel_repository_service.py index f01216ac..c441d26a 100644 --- a/bot/src/bot_data/service/user_joined_voice_channel_repository_service.py +++ b/bot/src/bot_data/service/user_joined_voice_channel_repository_service.py @@ -33,9 +33,7 @@ class UserJoinedVoiceChannelRepositoryService(UserJoinedVoiceChannelRepositoryAB ) results = self._context.select(UserJoinedVoiceChannel.get_select_all_string()) for result in results: - self._logger.trace( - __name__, f"Get user-joined-voice-channel with id {result[0]}" - ) + self._logger.trace(__name__, f"Get user-joined-voice-channel with id {result[0]}") joins.append( UserJoinedVoiceChannel( self._users.get_user_by_id(result[1]), @@ -54,9 +52,7 @@ class UserJoinedVoiceChannelRepositoryService(UserJoinedVoiceChannelRepositoryAB __name__, f"Send SQL command: {UserJoinedVoiceChannel.get_select_by_id_string(id)}", ) - result = self._context.select( - UserJoinedVoiceChannel.get_select_by_id_string(id) - )[0] + result = self._context.select(UserJoinedVoiceChannel.get_select_by_id_string(id))[0] return UserJoinedVoiceChannel( self._users.get_user_by_id(result[1]), result[2], @@ -66,17 +62,13 @@ class UserJoinedVoiceChannelRepositoryService(UserJoinedVoiceChannelRepositoryAB id=result[0], ) - def get_user_joined_voice_channels_by_user_id( - self, user_id: int - ) -> List[UserJoinedVoiceChannel]: + def get_user_joined_voice_channels_by_user_id(self, user_id: int) -> List[UserJoinedVoiceChannel]: joins = List(UserJoinedVoiceChannel) self._logger.trace( __name__, f"Send SQL command: {UserJoinedVoiceChannel.get_select_by_user_id_string(user_id)}", ) - results = self._context.select( - UserJoinedVoiceChannel.get_select_by_user_id_string(user_id) - ) + results = self._context.select(UserJoinedVoiceChannel.get_select_by_user_id_string(user_id)) for result in results: joins.append( UserJoinedVoiceChannel( @@ -91,16 +83,12 @@ class UserJoinedVoiceChannelRepositoryService(UserJoinedVoiceChannelRepositoryAB return joins - def get_active_user_joined_voice_channel_by_user_id( - self, user_id: int - ) -> UserJoinedVoiceChannel: + def get_active_user_joined_voice_channel_by_user_id(self, user_id: int) -> UserJoinedVoiceChannel: self._logger.trace( __name__, f"Send SQL command: {UserJoinedVoiceChannel.get_select_by_user_id_string(user_id)}", ) - result = self._context.select( - UserJoinedVoiceChannel.get_select_active_by_user_id_string(user_id) - )[0] + result = self._context.select(UserJoinedVoiceChannel.get_select_active_by_user_id_string(user_id))[0] return UserJoinedVoiceChannel( self._users.get_user_by_id(result[1]), result[2], @@ -110,16 +98,12 @@ class UserJoinedVoiceChannelRepositoryService(UserJoinedVoiceChannelRepositoryAB id=result[0], ) - def find_active_user_joined_voice_channel_by_user_id( - self, user_id: int - ) -> Optional[UserJoinedVoiceChannel]: + def find_active_user_joined_voice_channel_by_user_id(self, user_id: int) -> Optional[UserJoinedVoiceChannel]: self._logger.trace( __name__, f"Send SQL command: {UserJoinedVoiceChannel.get_select_by_user_id_string(user_id)}", ) - result = self._context.select( - UserJoinedVoiceChannel.get_select_active_by_user_id_string(user_id) - ) + result = self._context.select(UserJoinedVoiceChannel.get_select_active_by_user_id_string(user_id)) if result is None or len(result) == 0: return None @@ -134,17 +118,13 @@ class UserJoinedVoiceChannelRepositoryService(UserJoinedVoiceChannelRepositoryAB id=result[0], ) - def find_active_user_joined_voice_channels_by_user_id( - self, user_id: int - ) -> List[Optional[UserJoinedVoiceChannel]]: + def find_active_user_joined_voice_channels_by_user_id(self, user_id: int) -> List[Optional[UserJoinedVoiceChannel]]: self._logger.trace( __name__, f"Send SQL command: {UserJoinedVoiceChannel.get_select_active_by_user_id_string(user_id)}", ) result = List(UserJoinedVoiceChannel) - db_results = self._context.select( - UserJoinedVoiceChannel.get_select_active_by_user_id_string(user_id) - ) + db_results = self._context.select(UserJoinedVoiceChannel.get_select_active_by_user_id_string(user_id)) for db_result in db_results: result.append( @@ -160,28 +140,16 @@ class UserJoinedVoiceChannelRepositoryService(UserJoinedVoiceChannelRepositoryAB return result - def add_user_joined_voice_channel( - self, user_joined_voice_channel: UserJoinedVoiceChannel - ): - self._logger.trace( - __name__, f"Send SQL command: {user_joined_voice_channel.insert_string}" - ) + def add_user_joined_voice_channel(self, user_joined_voice_channel: UserJoinedVoiceChannel): + self._logger.trace(__name__, f"Send SQL command: {user_joined_voice_channel.insert_string}") self._context.cursor.execute(user_joined_voice_channel.insert_string) - def update_user_joined_voice_channel( - self, user_joined_voice_channel: UserJoinedVoiceChannel - ): - self._logger.trace( - __name__, f"Send SQL command: {user_joined_voice_channel.udpate_string}" - ) + def update_user_joined_voice_channel(self, user_joined_voice_channel: UserJoinedVoiceChannel): + self._logger.trace(__name__, f"Send SQL command: {user_joined_voice_channel.udpate_string}") self._context.cursor.execute(user_joined_voice_channel.udpate_string) - def delete_user_joined_voice_channel( - self, user_joined_voice_channel: UserJoinedVoiceChannel - ): - self._logger.trace( - __name__, f"Send SQL command: {user_joined_voice_channel.delete_string}" - ) + def delete_user_joined_voice_channel(self, user_joined_voice_channel: UserJoinedVoiceChannel): + self._logger.trace(__name__, f"Send SQL command: {user_joined_voice_channel.delete_string}") self._context.cursor.execute(user_joined_voice_channel.delete_string) def delete_user_joined_voice_channel_by_user_id(self, user_id: int): @@ -189,6 +157,4 @@ class UserJoinedVoiceChannelRepositoryService(UserJoinedVoiceChannelRepositoryAB __name__, f"Send SQL command: {UserJoinedVoiceChannel.delete_by_user_id_string}", ) - self._context.cursor.execute( - UserJoinedVoiceChannel.delete_by_user_id_string(user_id) - ) + self._context.cursor.execute(UserJoinedVoiceChannel.delete_by_user_id_string(user_id)) diff --git a/bot/src/bot_data/service/user_message_count_per_hour_repository_service.py b/bot/src/bot_data/service/user_message_count_per_hour_repository_service.py index 2ccb57e6..e63db818 100644 --- a/bot/src/bot_data/service/user_message_count_per_hour_repository_service.py +++ b/bot/src/bot_data/service/user_message_count_per_hour_repository_service.py @@ -51,16 +51,12 @@ class UserMessageCountPerHourRepositoryService(UserMessageCountPerHourRepository ) results = self._context.select(UserMessageCountPerHour.get_select_all_string()) for result in results: - self._logger.trace( - __name__, f"Get user message count per hour with id {result[0]}" - ) + self._logger.trace(__name__, f"Get user message count per hour with id {result[0]}") umcphs.append(self._from_result(result)) return umcphs - def find_user_message_count_per_hour_by_user_id( - self, user_id: int - ) -> List[Optional[UserMessageCountPerHour]]: + def find_user_message_count_per_hour_by_user_id(self, user_id: int) -> List[Optional[UserMessageCountPerHour]]: umcphs = List(UserMessageCountPerHour) sql = UserMessageCountPerHour.get_select_by_user_id_string(user_id) self._logger.trace(__name__, f"Send SQL command: {sql}") @@ -69,9 +65,7 @@ class UserMessageCountPerHourRepositoryService(UserMessageCountPerHourRepository return umcphs for result in results: - self._logger.trace( - __name__, f"Get user message count per hour with id {result[0]}" - ) + self._logger.trace(__name__, f"Get user message count per hour with id {result[0]}") umcphs.append(self._from_result(result)) return umcphs @@ -79,9 +73,7 @@ class UserMessageCountPerHourRepositoryService(UserMessageCountPerHourRepository def get_user_message_count_per_hour_by_user_id_and_date( self, user_id: int, date: datetime ) -> UserMessageCountPerHour: - sql = UserMessageCountPerHour.get_select_by_user_id_and_date_string( - user_id, date - ) + sql = UserMessageCountPerHour.get_select_by_user_id_and_date_string(user_id, date) self._logger.trace(__name__, f"Send SQL command: {sql}") result = self._context.select(sql)[0] return self._from_result(result) @@ -89,9 +81,7 @@ class UserMessageCountPerHourRepositoryService(UserMessageCountPerHourRepository def find_user_message_count_per_hour_by_user_id_and_date( self, user_id: int, date: datetime ) -> Optional[UserMessageCountPerHour]: - sql = UserMessageCountPerHour.get_select_by_user_id_and_date_string( - user_id, date - ) + sql = UserMessageCountPerHour.get_select_by_user_id_and_date_string(user_id, date) self._logger.trace(__name__, f"Send SQL command: {sql}") result = self._context.select(sql) if result is None or len(result) == 0: diff --git a/bot/src/bot_data/service/user_repository_service.py b/bot/src/bot_data/service/user_repository_service.py index b39cd560..940156a8 100644 --- a/bot/src/bot_data/service/user_repository_service.py +++ b/bot/src/bot_data/service/user_repository_service.py @@ -39,9 +39,7 @@ class UserRepositoryService(UserRepositoryABC): def get_users(self) -> List[User]: users = List(User) - self._logger.trace( - __name__, f"Send SQL command: {User.get_select_all_string()}" - ) + self._logger.trace(__name__, f"Send SQL command: {User.get_select_all_string()}") results = self._context.select(User.get_select_all_string()) for result in results: self._logger.trace(__name__, f"Get user with id {result[0]}") @@ -50,17 +48,13 @@ class UserRepositoryService(UserRepositoryABC): return users def get_user_by_id(self, id: int) -> User: - self._logger.trace( - __name__, f"Send SQL command: {User.get_select_by_id_string(id)}" - ) + self._logger.trace(__name__, f"Send SQL command: {User.get_select_by_id_string(id)}") result = self._context.select(User.get_select_by_id_string(id))[0] return self._from_result(result) def find_user_by_id(self, id: int) -> Optional[User]: - self._logger.trace( - __name__, f"Send SQL command: {User.get_select_by_id_string(id)}" - ) + self._logger.trace(__name__, f"Send SQL command: {User.get_select_by_id_string(id)}") result = self._context.select(User.get_select_by_id_string(id)) if result is None or len(result) == 0: return None @@ -93,29 +87,21 @@ class UserRepositoryService(UserRepositoryABC): return users - def get_user_by_discord_id_and_server_id( - self, discord_id: int, server_id: int - ) -> User: + def get_user_by_discord_id_and_server_id(self, discord_id: int, server_id: int) -> User: self._logger.trace( __name__, f"Send SQL command: {User.get_select_by_discord_id_and_server_id_string(discord_id, server_id)}", ) - result = self._context.select( - User.get_select_by_discord_id_and_server_id_string(discord_id, server_id) - )[0] + result = self._context.select(User.get_select_by_discord_id_and_server_id_string(discord_id, server_id))[0] return self._from_result(result) - def find_user_by_discord_id_and_server_id( - self, discord_id: int, server_id: int - ) -> Optional[User]: + def find_user_by_discord_id_and_server_id(self, discord_id: int, server_id: int) -> Optional[User]: self._logger.trace( __name__, f"Send SQL command: {User.get_select_by_discord_id_and_server_id_string(discord_id, server_id)}", ) - result = self._context.select( - User.get_select_by_discord_id_and_server_id_string(discord_id, server_id) - ) + result = self._context.select(User.get_select_by_discord_id_and_server_id_string(discord_id, server_id)) if result is None or len(result) == 0: return None diff --git a/bot/src/bot_data/service/user_warnings_repository_service.py b/bot/src/bot_data/service/user_warnings_repository_service.py index fade2db6..fbf7c4ee 100644 --- a/bot/src/bot_data/service/user_warnings_repository_service.py +++ b/bot/src/bot_data/service/user_warnings_repository_service.py @@ -47,9 +47,7 @@ class UserWarningsRepositoryService(UserWarningsRepositoryABC): def get_user_warnings(self) -> List[UserWarnings]: warnings = List(UserWarnings) - self._logger.trace( - __name__, f"Send SQL command: {UserWarnings.get_select_all_string()}" - ) + self._logger.trace(__name__, f"Send SQL command: {UserWarnings.get_select_all_string()}") results = self._context.select(UserWarnings.get_select_all_string()) for result in results: warnings.append(self._from_result(result)) @@ -57,9 +55,7 @@ class UserWarningsRepositoryService(UserWarningsRepositoryABC): return warnings def get_user_warnings_by_id(self, id: int) -> UserWarnings: - self._logger.trace( - __name__, f"Send SQL command: {UserWarnings.get_select_by_id_string(id)}" - ) + self._logger.trace(__name__, f"Send SQL command: {UserWarnings.get_select_by_id_string(id)}") result = self._context.select(UserWarnings.get_select_by_id_string(id))[0] return self._from_result(result) @@ -69,9 +65,7 @@ class UserWarningsRepositoryService(UserWarningsRepositoryABC): __name__, f"Send SQL command: {UserWarnings.get_select_by_user_id_string(user_id)}", ) - results = self._context.select( - UserWarnings.get_select_by_user_id_string(user_id) - ) + results = self._context.select(UserWarnings.get_select_by_user_id_string(user_id)) for result in results: warnings.append(self._from_result(result)) diff --git a/bot/src/bot_graphql/abc/filter_abc.py b/bot/src/bot_graphql/abc/filter_abc.py index aec7b1a9..e0d5ff8d 100644 --- a/bot/src/bot_graphql/abc/filter_abc.py +++ b/bot/src/bot_graphql/abc/filter_abc.py @@ -24,11 +24,7 @@ class FilterABC(ABC): sig = signature(f) for param in sig.parameters.items(): parameter = param[1] - if ( - parameter.name == "self" - or parameter.name == "cls" - or parameter.annotation == Parameter.empty - ): + if parameter.name == "self" or parameter.name == "cls" or parameter.annotation == Parameter.empty: continue if issubclass(parameter.annotation, FilterABC): @@ -38,9 +34,7 @@ class FilterABC(ABC): @staticmethod @ServiceProviderABC.inject - def get_collection_filter( - filter_type: type, values: dict, services: ServiceProviderABC - ): + def get_collection_filter(filter_type: type, values: dict, services: ServiceProviderABC): filter: FilterABC = services.get_service(filter_type) filter.from_dict(values) return filter diff --git a/bot/src/bot_graphql/abc/query_abc.py b/bot/src/bot_graphql/abc/query_abc.py index 535bbc59..850fb22b 100644 --- a/bot/src/bot_graphql/abc/query_abc.py +++ b/bot/src/bot_graphql/abc/query_abc.py @@ -38,14 +38,10 @@ class QueryABC(ObjectType): def __init__(self, name: str): ObjectType.__init__(self, name) - def add_collection( - self, name: str, get_collection: Callable, filter_type: type = None - ): + def add_collection(self, name: str, get_collection: Callable, filter_type: type = None): def wrapper(*args, **kwargs): if filter_type is not None and "filter" in kwargs: - kwargs["filter"] = FilterABC.get_collection_filter( - filter_type, kwargs["filter"] - ) + kwargs["filter"] = FilterABC.get_collection_filter(filter_type, kwargs["filter"]) else: kwargs["filter"] = None @@ -98,10 +94,7 @@ class QueryABC(ObjectType): 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 - ): + if permissions.is_member_moderator(member) and u.server.id == element.server.id: access = True break @@ -111,10 +104,7 @@ class QueryABC(ObjectType): 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 - ): + if permissions.is_member_moderator(member) and u.server.id == element.server.id: access = True break @@ -124,10 +114,7 @@ class QueryABC(ObjectType): 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.auto_role.server.id: access = True break @@ -212,18 +199,11 @@ class QueryABC(ObjectType): 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 - ): + if permissions.is_member_moderator(member) and u.server.id == element.server.id: access = True break - elif ( - type(element) == dict - and "key" in element - and element["key"] in [e.value for e in FeatureFlagsEnum] - ): + 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) @@ -235,9 +215,7 @@ class QueryABC(ObjectType): return access @ServiceProviderABC.inject - def _can_user_mutate_data( - self, server: Server, permission: UserRoleEnum, services: ServiceProviderABC - ): + def _can_user_mutate_data(self, server: Server, permission: UserRoleEnum, services: ServiceProviderABC): permissions: PermissionService = services.get_service(PermissionService) bot: DiscordBotServiceABC = services.get_service(DiscordBotServiceABC) @@ -246,9 +224,7 @@ class QueryABC(ObjectType): return member = bot.get_guild(server.discord_id).get_member( - auth_user.users.where(lambda x: x.server.id == server.id) - .single() - .discord_id + auth_user.users.where(lambda x: x.server.id == server.id).single().discord_id ) check_perm = lambda x: True @@ -261,9 +237,7 @@ class QueryABC(ObjectType): check_perm = lambda x: permissions.is_member_technician(x) if not check_perm(member): - ex = ServiceException( - ServiceErrorCode.Forbidden, f"User not allowed to mutate data" - ) + ex = ServiceException(ServiceErrorCode.Forbidden, f"User not allowed to mutate data") raise ex # @FilterABC.resolve_filter_annotation diff --git a/bot/src/bot_graphql/filter/achievement_filter.py b/bot/src/bot_graphql/filter/achievement_filter.py index 1e1afd11..b95e00c0 100644 --- a/bot/src/bot_graphql/filter/achievement_filter.py +++ b/bot/src/bot_graphql/filter/achievement_filter.py @@ -55,16 +55,10 @@ class AchievementFilter(FilterABC): query = query.where(lambda x: x.name == self._name or self._name in x.name) if self._description is not None: - query = query.where( - lambda x: x.description == self._description - or self._description in x.description - ) + query = query.where(lambda x: x.description == self._description or self._description in x.description) if self._attribute is not None: - query = query.where( - lambda x: x.attribute == self._attribute - or self._attribute in x.attribute - ) + query = query.where(lambda x: x.attribute == self._attribute or self._attribute in x.attribute) if self._operator is not None: query = query.where(lambda x: x.operator == self._operator) @@ -73,9 +67,7 @@ class AchievementFilter(FilterABC): query = query.where(lambda x: x.value == self._value) if self._server is not None: - servers = self._server.filter(query.select(lambda x: x.server)).select( - lambda x: x.id - ) + servers = self._server.filter(query.select(lambda x: x.server)).select(lambda x: x.id) query = query.where(lambda x: x.server.id in servers) return query diff --git a/bot/src/bot_graphql/filter/auto_role_filter.py b/bot/src/bot_graphql/filter/auto_role_filter.py index caa976d5..6f17dd59 100644 --- a/bot/src/bot_graphql/filter/auto_role_filter.py +++ b/bot/src/bot_graphql/filter/auto_role_filter.py @@ -46,26 +46,21 @@ class AutoRoleFilter(FilterABC): if self._channel_id is not None: query = query.where( - lambda x: x.discord_channel_id == self._channel_id - or str(self._channel_id) in str(x.discord_channel_id) + lambda x: x.discord_channel_id == self._channel_id or str(self._channel_id) in str(x.discord_channel_id) ) if self._channel_name is not None: query = query.where( - lambda x: x.discord_channel_name == self._channel_name - or self._channel_name in x.discord_channel_name + lambda x: x.discord_channel_name == self._channel_name or self._channel_name in x.discord_channel_name ) if self._message_id is not None: query = query.where( - lambda x: x.discord_message_id == self._message_id - or str(self._message_id) in str(x.discord_message_id) + lambda x: x.discord_message_id == self._message_id or str(self._message_id) in str(x.discord_message_id) ) if self._server is not None: - servers = self._server.filter(query.select(lambda x: x.server)).select( - lambda x: x.id - ) + servers = self._server.filter(query.select(lambda x: x.server)).select(lambda x: x.id) query = query.where(lambda x: x.server.id in servers) return query diff --git a/bot/src/bot_graphql/filter/auto_role_rule_filter.py b/bot/src/bot_graphql/filter/auto_role_rule_filter.py index 6d661147..b9571d8f 100644 --- a/bot/src/bot_graphql/filter/auto_role_rule_filter.py +++ b/bot/src/bot_graphql/filter/auto_role_rule_filter.py @@ -57,9 +57,7 @@ class AutoRoleRuleFilter(FilterABC): query = query.where(get_role_name) if self._auto_role is not None: - auto_roles = self._auto_role.filter( - query.select(lambda x: x.game_server) - ).select(lambda x: x.id) + auto_roles = self._auto_role.filter(query.select(lambda x: x.game_server)).select(lambda x: x.id) query = query.where(lambda x: x.game_server.id in auto_roles) return query diff --git a/bot/src/bot_graphql/filter/client_filter.py b/bot/src/bot_graphql/filter/client_filter.py index 8f46fca2..29563600 100644 --- a/bot/src/bot_graphql/filter/client_filter.py +++ b/bot/src/bot_graphql/filter/client_filter.py @@ -38,15 +38,10 @@ class ClientFilter(FilterABC): query = query.where(lambda x: x.id == self._discord_id) if self._name is not None: - query = query.where( - lambda x: self._name.lower() == x.name.lower() - or self._name.lower() in x.name.lower() - ) + query = query.where(lambda x: self._name.lower() == x.name.lower() or self._name.lower() in x.name.lower()) if self._server is not None: - servers = self._server.filter(query.select(lambda x: x.server)).select( - lambda x: x.id - ) + servers = self._server.filter(query.select(lambda x: x.server)).select(lambda x: x.id) query = query.where(lambda x: x.server.id in servers) return query diff --git a/bot/src/bot_graphql/filter/level_filter.py b/bot/src/bot_graphql/filter/level_filter.py index ebd8de39..2ded4ad8 100644 --- a/bot/src/bot_graphql/filter/level_filter.py +++ b/bot/src/bot_graphql/filter/level_filter.py @@ -33,15 +33,10 @@ class LevelFilter(FilterABC): query = query.where(lambda x: x.id == self._id) if self._name is not None: - query = query.where( - lambda x: self._name.lower() == x.name.lower() - or self._name.lower() in x.name.lower() - ) + query = query.where(lambda x: self._name.lower() == x.name.lower() or self._name.lower() in x.name.lower()) if self._server is not None: - servers = self._server.filter(query.select(lambda x: x.server)).select( - lambda x: x.id - ) + servers = self._server.filter(query.select(lambda x: x.server)).select(lambda x: x.id) query = query.where(lambda x: x.server.id in servers) return query diff --git a/bot/src/bot_graphql/filter/server_filter.py b/bot/src/bot_graphql/filter/server_filter.py index f6384146..e090323e 100644 --- a/bot/src/bot_graphql/filter/server_filter.py +++ b/bot/src/bot_graphql/filter/server_filter.py @@ -32,8 +32,7 @@ class ServerFilter(FilterABC): if self._discord_id is not None: query = query.where( - lambda x: x.discord_id == self._discord_id - or str(self._discord_id) in str(x.discord_id) + lambda x: x.discord_id == self._discord_id or str(self._discord_id) in str(x.discord_id) ) if self._name is not None: @@ -41,8 +40,7 @@ class ServerFilter(FilterABC): def where_guild(x: Guild): guild = bot.get_guild(x.discord_id) return guild is not None and ( - self._name.lower() == guild.name.lower() - or self._name.lower() in guild.name.lower() + self._name.lower() == guild.name.lower() or self._name.lower() in guild.name.lower() ) query = query.where(where_guild) diff --git a/bot/src/bot_graphql/filter/short_role_name_filter.py b/bot/src/bot_graphql/filter/short_role_name_filter.py index 2fb3b2be..426e3630 100644 --- a/bot/src/bot_graphql/filter/short_role_name_filter.py +++ b/bot/src/bot_graphql/filter/short_role_name_filter.py @@ -46,10 +46,7 @@ class ShortRoleNameFilter(FilterABC): query = query.where(lambda x: x.id == self._id) if self._short_name is not None: - query = query.where( - lambda x: x.short_name == self._short_name - or self._short_name in x.short_name - ) + query = query.where(lambda x: x.short_name == self._short_name or self._short_name in x.short_name) if self._role_id is not None: query = query.where(lambda x: x.role_id == self._role_id) @@ -67,9 +64,7 @@ class ShortRoleNameFilter(FilterABC): query = query.where(lambda x: x.position.value == self._position.value) if self._server is not None: - servers = self._server.filter(query.select(lambda x: x.server)).select( - lambda x: x.id - ) + servers = self._server.filter(query.select(lambda x: x.server)).select(lambda x: x.id) query = query.where(lambda x: x.server.id in servers) return query diff --git a/bot/src/bot_graphql/filter/user_filter.py b/bot/src/bot_graphql/filter/user_filter.py index 7a50f6d2..53c130d5 100644 --- a/bot/src/bot_graphql/filter/user_filter.py +++ b/bot/src/bot_graphql/filter/user_filter.py @@ -73,8 +73,7 @@ class UserFilter(FilterABC): if self._discord_id is not None: query = query.where( - lambda x: x.discord_id == self._discord_id - or str(self._discord_id) in str(x.discord_id) + lambda x: x.discord_id == self._discord_id or str(self._discord_id) in str(x.discord_id) ) if self._name is not None: @@ -82,9 +81,7 @@ class UserFilter(FilterABC): def _get_member(user: User): guild = self._bot.get_guild(user.server.discord_id) member = guild.get_member(user.discord_id) - return member is not None and ( - member.name == self._name or self._name in member.name - ) + return member is not None and (member.name == self._name or self._name in member.name) query = query.where(_get_member) @@ -92,30 +89,20 @@ class UserFilter(FilterABC): query = query.where(lambda x: x.xp == self._xp) if self._ontime is not None: - query = query.where( - lambda x: self._client_utils.get_ontime_for_user(x) == self._ontime - ) + query = query.where(lambda x: self._client_utils.get_ontime_for_user(x) == self._ontime) if self._level is not None: - levels = self._level.filter( - query.select(lambda x: self._levels.get_level(x)) - ).select(lambda x: x.id) + levels = self._level.filter(query.select(lambda x: self._levels.get_level(x))).select(lambda x: x.id) query = query.where(lambda x: self._levels.get_level(x).id in levels) if self._server is not None: - servers = self._server.filter(query.select(lambda x: x.server)).select( - lambda x: x.id - ) + servers = self._server.filter(query.select(lambda x: x.server)).select(lambda x: x.id) query = query.where(lambda x: x.server.id in servers) if self._left_server is not None: def _has_user_left_server(user: User): - active_join = ( - self._user_joined_servers.find_active_user_joined_server_by_user_id( - user.id - ) - ) + active_join = self._user_joined_servers.find_active_user_joined_server_by_user_id(user.id) return (active_join is None) == self._left_server query = query.where(_has_user_left_server) diff --git a/bot/src/bot_graphql/filter/user_joined_game_server_filter.py b/bot/src/bot_graphql/filter/user_joined_game_server_filter.py index 84297e50..1d266a70 100644 --- a/bot/src/bot_graphql/filter/user_joined_game_server_filter.py +++ b/bot/src/bot_graphql/filter/user_joined_game_server_filter.py @@ -42,9 +42,7 @@ class UserJoinedGameServerFilter(FilterABC): query = query.where(lambda x: x.game_server == self._game_server) if self._user is not None: - users = self._user.filter(query.select(lambda x: x.user)).select( - lambda x: x.id - ) + users = self._user.filter(query.select(lambda x: x.user)).select(lambda x: x.id) query = query.where(lambda x: x.user.id in users) return query diff --git a/bot/src/bot_graphql/filter/user_joined_server_filter.py b/bot/src/bot_graphql/filter/user_joined_server_filter.py index dd760752..3aac7e25 100644 --- a/bot/src/bot_graphql/filter/user_joined_server_filter.py +++ b/bot/src/bot_graphql/filter/user_joined_server_filter.py @@ -43,21 +43,13 @@ class UserJoinedServerFilter(FilterABC): query = query.where(lambda x: x.id == self._id) if self._user is not None: - users = self._user.filter(query.select(lambda x: x.user)).select( - lambda x: x.id - ) + users = self._user.filter(query.select(lambda x: x.user)).select(lambda x: x.id) query = query.where(lambda x: x.user.id in users) if self._joined_on is not None: - query = query.where( - lambda x: x.joined_on == self._joined_on - or self._joined_on in x.joined_on - ) + query = query.where(lambda x: x.joined_on == self._joined_on or self._joined_on in x.joined_on) if self._leaved_on is not None: - query = query.where( - lambda x: x.leaved_on == self._leaved_on - or self._leaved_on in x.leaved_on - ) + query = query.where(lambda x: x.leaved_on == self._leaved_on or self._leaved_on in x.leaved_on) return query diff --git a/bot/src/bot_graphql/filter/user_joined_voice_channel_filter.py b/bot/src/bot_graphql/filter/user_joined_voice_channel_filter.py index 681cf038..51ba446a 100644 --- a/bot/src/bot_graphql/filter/user_joined_voice_channel_filter.py +++ b/bot/src/bot_graphql/filter/user_joined_voice_channel_filter.py @@ -46,9 +46,7 @@ class UserJoinedVoiceChannelFilter(FilterABC): if "leavedOn" in values: self._leaved_on = values["leavedOn"] - def filter( - self, query: List[UserJoinedVoiceChannel] - ) -> List[UserJoinedVoiceChannel]: + def filter(self, query: List[UserJoinedVoiceChannel]) -> List[UserJoinedVoiceChannel]: if self._id is not None: query = query.where(lambda x: x.id == self._id) @@ -64,21 +62,13 @@ class UserJoinedVoiceChannelFilter(FilterABC): query = query.where(get_channel_name) if self._user is not None: - users = self._user.filter(query.select(lambda x: x.user)).select( - lambda x: x.id - ) + users = self._user.filter(query.select(lambda x: x.user)).select(lambda x: x.id) query = query.where(lambda x: x.user.id in users) if self._joined_on is not None: - query = query.where( - lambda x: x.joined_on == self._joined_on - or self._joined_on in x.joined_on - ) + query = query.where(lambda x: x.joined_on == self._joined_on or self._joined_on in x.joined_on) if self._leaved_on is not None: - query = query.where( - lambda x: x.leaved_on == self._leaved_on - or self._leaved_on in x.leaved_on - ) + query = query.where(lambda x: x.leaved_on == self._leaved_on or self._leaved_on in x.leaved_on) return query diff --git a/bot/src/bot_graphql/filter/user_warning_filter.py b/bot/src/bot_graphql/filter/user_warning_filter.py index c2d70df1..2c716c9e 100644 --- a/bot/src/bot_graphql/filter/user_warning_filter.py +++ b/bot/src/bot_graphql/filter/user_warning_filter.py @@ -43,21 +43,14 @@ class UserWarningFilter(FilterABC): query = query.where(lambda x: x.id == self._id) if self._user is not None: - users = self._user.filter(query.select(lambda x: x.user)).select( - lambda x: x.id - ) + users = self._user.filter(query.select(lambda x: x.user)).select(lambda x: x.id) query = query.where(lambda x: x.id in users) if self._description is not None: - query = query.where( - lambda x: x.description == self._description - or self._description in x.description - ) + query = query.where(lambda x: x.description == self._description or self._description in x.description) if self._author is not None: - users = self._author.filter(query.select(lambda x: x.author)).select( - lambda x: x.id - ) + users = self._author.filter(query.select(lambda x: x.author)).select(lambda x: x.id) query = query.where(lambda x: x.id in users) return query diff --git a/bot/src/bot_graphql/graphql_module.py b/bot/src/bot_graphql/graphql_module.py index 822556a4..e15e0c35 100644 --- a/bot/src/bot_graphql/graphql_module.py +++ b/bot/src/bot_graphql/graphql_module.py @@ -95,14 +95,10 @@ class GraphQLModule(ModuleABC): def __init__(self, dc: DiscordCollectionABC): ModuleABC.__init__(self, dc, FeatureFlagsEnum.data_module) - def configure_configuration( - self, config: ConfigurationABC, env: ApplicationEnvironmentABC - ): + def configure_configuration(self, config: ConfigurationABC, env: ApplicationEnvironmentABC): pass - def configure_services( - self, services: ServiceCollectionABC, env: ApplicationEnvironmentABC - ): + def configure_services(self, services: ServiceCollectionABC, env: ApplicationEnvironmentABC): services.add_singleton(Schema) services.add_singleton(GraphQLService) services.add_singleton(Query) diff --git a/bot/src/bot_graphql/mutations/achievement_mutation.py b/bot/src/bot_graphql/mutations/achievement_mutation.py index 2731df20..40975a38 100644 --- a/bot/src/bot_graphql/mutations/achievement_mutation.py +++ b/bot/src/bot_graphql/mutations/achievement_mutation.py @@ -55,26 +55,16 @@ class AchievementMutation(QueryABC): and a.server.id == server.id ) - return ( - self._achievements.get_achievements_by_server_id(achievement.server.id) - .where(get_new_achievement) - .last() - ) + return self._achievements.get_achievements_by_server_id(achievement.server.id).where(get_new_achievement).last() def resolve_update_achievement(self, *_, input: dict): achievement = self._achievements.get_achievement_by_id(input["id"]) self._can_user_mutate_data(achievement.server, UserRoleEnum.moderator) achievement.name = input["name"] if "name" in input else achievement.name - achievement.description = ( - input["description"] if "description" in input else achievement.description - ) - achievement.attribute = ( - input["attribute"] if "attribute" in input else achievement.attribute - ) - achievement.operator = ( - input["operator"] if "operator" in input else achievement.operator - ) + achievement.description = input["description"] if "description" in input else achievement.description + achievement.attribute = input["attribute"] if "attribute" in input else achievement.attribute + achievement.operator = input["operator"] if "operator" in input else achievement.operator achievement.value = input["value"] if "value" in input else achievement.value self._achievements.update_achievement(achievement) diff --git a/bot/src/bot_graphql/mutations/auto_role_mutation.py b/bot/src/bot_graphql/mutations/auto_role_mutation.py index e4dec683..72ac1cf9 100644 --- a/bot/src/bot_graphql/mutations/auto_role_mutation.py +++ b/bot/src/bot_graphql/mutations/auto_role_mutation.py @@ -42,22 +42,14 @@ class AutoRoleMutation(QueryABC): and x.discord_message_id == int(input["messageId"]) ) - return ( - self._auto_roles.get_auto_roles_by_server_id(auto_role.server.id) - .where(get_new) - .last() - ) + return self._auto_roles.get_auto_roles_by_server_id(auto_role.server.id).where(get_new).last() def resolve_update_auto_role(self, *_, input: dict): auto_role = self._auto_roles.get_auto_role_by_id(input["id"]) self._can_user_mutate_data(auto_role.server, UserRoleEnum.moderator) - auto_role.discord_channel_id = ( - input["channelId"] if "channelId" in input else auto_role.discord_channel_id - ) - auto_role.discord_message_id = ( - input["messageId"] if "messageId" in input else auto_role.discord_message_id - ) + auto_role.discord_channel_id = input["channelId"] if "channelId" in input else auto_role.discord_channel_id + auto_role.discord_message_id = input["messageId"] if "messageId" in input else auto_role.discord_message_id self._auto_roles.update_auto_role(auto_role) self._db.save_changes() diff --git a/bot/src/bot_graphql/mutations/auto_role_rule_mutation.py b/bot/src/bot_graphql/mutations/auto_role_rule_mutation.py index 0b880c0b..ceafdd2d 100644 --- a/bot/src/bot_graphql/mutations/auto_role_rule_mutation.py +++ b/bot/src/bot_graphql/mutations/auto_role_rule_mutation.py @@ -36,9 +36,7 @@ class AutoRoleRuleMutation(QueryABC): input["emojiName"], input["roleId"], ) - self._can_user_mutate_data( - auto_role_rule.auto_role.server, UserRoleEnum.moderator - ) + self._can_user_mutate_data(auto_role_rule.auto_role.server, UserRoleEnum.moderator) self._auto_roles.add_auto_role_rule(auto_role_rule) self._db.save_changes() @@ -58,26 +56,14 @@ class AutoRoleRuleMutation(QueryABC): self._bot.get_guild(auto_role_rule.auto_role.server.discord_id), ) ) - return ( - self._auto_roles.get_auto_role_rules_by_auto_role_id( - auto_role_rule.auto_role.id - ) - .where(get_new) - .last() - ) + return self._auto_roles.get_auto_role_rules_by_auto_role_id(auto_role_rule.auto_role.id).where(get_new).last() def resolve_update_auto_role_rule(self, *_, input: dict): auto_role_rule = self._auto_roles.get_auto_role_rule_by_id(input["id"]) - self._can_user_mutate_data( - auto_role_rule.auto_role.server, UserRoleEnum.moderator - ) + self._can_user_mutate_data(auto_role_rule.auto_role.server, UserRoleEnum.moderator) - auto_role_rule.emoji_name = ( - input["emojiName"] if "emojiName" in input else auto_role_rule.emoji_name - ) - auto_role_rule.role_id = ( - input["roleId"] if "roleId" in input else auto_role_rule.role_id - ) + auto_role_rule.emoji_name = input["emojiName"] if "emojiName" in input else auto_role_rule.emoji_name + auto_role_rule.role_id = input["roleId"] if "roleId" in input else auto_role_rule.role_id self._auto_roles.update_auto_role_rule(auto_role_rule) self._db.save_changes() @@ -95,9 +81,7 @@ class AutoRoleRuleMutation(QueryABC): def resolve_delete_auto_role_rule(self, *_, id: int): auto_role_rule = self._auto_roles.get_auto_role_rule_by_id(id) - self._can_user_mutate_data( - auto_role_rule.auto_role.server, UserRoleEnum.moderator - ) + self._can_user_mutate_data(auto_role_rule.auto_role.server, UserRoleEnum.moderator) self._auto_roles.delete_auto_role_rule(auto_role_rule) self._db.save_changes() diff --git a/bot/src/bot_graphql/mutations/level_mutation.py b/bot/src/bot_graphql/mutations/level_mutation.py index 179cc786..215538b7 100644 --- a/bot/src/bot_graphql/mutations/level_mutation.py +++ b/bot/src/bot_graphql/mutations/level_mutation.py @@ -54,11 +54,7 @@ class LevelMutation(QueryABC): ) self._bot.loop.create_task(self._level_seeder.seed()) - return ( - self._levels.get_levels_by_server_id(level.server.id) - .where(get_new_level) - .last() - ) + return self._levels.get_levels_by_server_id(level.server.id).where(get_new_level).last() def resolve_update_level(self, *_, input: dict): level = self._levels.get_level_by_id(input["id"]) @@ -67,9 +63,7 @@ class LevelMutation(QueryABC): level.name = input["name"] if "name" in input else level.name level.color = input["color"] if "color" in input else level.color level.min_xp = input["minXp"] if "minXp" in input else level.min_xp - level.permissions = ( - input["permissions"] if "permissions" in input else level.permissions - ) + level.permissions = input["permissions"] if "permissions" in input else level.permissions self._levels.update_level(level) self._db.save_changes() diff --git a/bot/src/bot_graphql/mutations/server_config_mutation.py b/bot/src/bot_graphql/mutations/server_config_mutation.py index 0f7df29b..6b2ff5eb 100644 --- a/bot/src/bot_graphql/mutations/server_config_mutation.py +++ b/bot/src/bot_graphql/mutations/server_config_mutation.py @@ -41,44 +41,28 @@ class ServerConfigMutation(QueryABC): 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 - ) + 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 + input["messageDeleteTimer"] if "messageDeleteTimer" in input else server_config.message_delete_timer ) server_config.notification_chat_id = ( - input["notificationChatId"] - if "notificationChatId" in input - else server_config.notification_chat_id + input["notificationChatId"] if "notificationChatId" in input else server_config.notification_chat_id ) server_config.max_voice_state_hours = ( - input["maxVoiceStateHours"] - if "maxVoiceStateHours" in input - else server_config.max_voice_state_hours + input["maxVoiceStateHours"] if "maxVoiceStateHours" in input else server_config.max_voice_state_hours ) server_config.xp_per_message = ( - input["xpPerMessage"] - if "xpPerMessage" in input - else server_config.xp_per_message + input["xpPerMessage"] if "xpPerMessage" in input else server_config.xp_per_message ) server_config.xp_per_reaction = ( - input["xpPerReaction"] - if "xpPerReaction" in input - else server_config.xp_per_reaction + input["xpPerReaction"] if "xpPerReaction" in input else server_config.xp_per_reaction ) server_config.max_message_xp_per_hour = ( - input["maxMessageXpPerHour"] - if "maxMessageXpPerHour" in input - else server_config.max_message_xp_per_hour + input["maxMessageXpPerHour"] if "maxMessageXpPerHour" in input else server_config.max_message_xp_per_hour ) server_config.xp_per_ontime_hour = ( - input["xpPerOntimeHour"] - if "xpPerOntimeHour" in input - else server_config.xp_per_ontime_hour + input["xpPerOntimeHour"] if "xpPerOntimeHour" in input else server_config.xp_per_ontime_hour ) server_config.xp_per_event_participation = ( input["xpPerEventParticipation"] @@ -86,29 +70,19 @@ class ServerConfigMutation(QueryABC): else server_config.xp_per_event_participation ) server_config.xp_per_achievement = ( - input["xpPerAchievement"] - if "xpPerAchievement" in input - else server_config.xp_per_achievement + input["xpPerAchievement"] if "xpPerAchievement" in input else server_config.xp_per_achievement ) server_config.xp_for_birthday = ( - input["xpForBirthday"] - if "xpForBirthday" in input - else server_config.xp_for_birthday + input["xpForBirthday"] if "xpForBirthday" in input else server_config.xp_for_birthday ) server_config.afk_command_channel_id = ( - input["afkCommandChannelId"] - if "afkCommandChannelId" in input - else server_config.afk_command_channel_id + input["afkCommandChannelId"] if "afkCommandChannelId" in input else server_config.afk_command_channel_id ) server_config.help_voice_channel_id = ( - input["helpVoiceChannelId"] - if "helpVoiceChannelId" in input - else server_config.help_voice_channel_id + input["helpVoiceChannelId"] if "helpVoiceChannelId" in input else server_config.help_voice_channel_id ) server_config.team_channel_id = ( - input["teamChannelId"] - if "teamChannelId" in input - else server_config.team_channel_id + input["teamChannelId"] if "teamChannelId" in input else server_config.team_channel_id ) server_config.login_message_channel_id = ( input["loginMessageChannelId"] @@ -116,9 +90,7 @@ class ServerConfigMutation(QueryABC): else server_config.login_message_channel_id ) server_config.default_role_id = ( - input["defaultRoleId"] - if "defaultRoleId" in input - else server_config.default_role_id + input["defaultRoleId"] if "defaultRoleId" in input else server_config.default_role_id ) server_config.short_role_name_only_set_highest_role = ( input["shortRoleNameOnlySetHighestRole"] @@ -150,33 +122,25 @@ class ServerConfigMutation(QueryABC): if "moderatorRoleIds" in input: team_role_ids.extend( [ - ServerTeamRoleIdsConfig( - x, TeamMemberTypeEnum.moderator, server_config.server.id - ) + ServerTeamRoleIdsConfig(x, TeamMemberTypeEnum.moderator, server_config.server.id) for x in input["moderatorRoleIds"] ] ) else: team_role_ids.extend( - server_config.team_role_ids.where( - lambda x: x.team_member_type == TeamMemberTypeEnum.moderator - ) + server_config.team_role_ids.where(lambda x: x.team_member_type == TeamMemberTypeEnum.moderator) ) if "adminRoleIds" in input: team_role_ids.extend( [ - ServerTeamRoleIdsConfig( - x, TeamMemberTypeEnum.admin, server_config.server.id - ) + ServerTeamRoleIdsConfig(x, TeamMemberTypeEnum.admin, server_config.server.id) for x in input["adminRoleIds"] ] ) else: team_role_ids.extend( - server_config.team_role_ids.where( - lambda x: x.team_member_type == TeamMemberTypeEnum.admin - ) + server_config.team_role_ids.where(lambda x: x.team_member_type == TeamMemberTypeEnum.admin) ) self._server_configs.update_server_config(server_config) @@ -188,15 +152,11 @@ class ServerConfigMutation(QueryABC): self._update_team_role_ids(server_config) self._db.save_changes() - self._bot.loop.create_task( - self._config_service.reload_server_config(server_config.server) - ) + self._bot.loop.create_task(self._config_service.reload_server_config(server_config.server)) 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_server(new_config.server.id) for channel_id in old_config.afk_channel_ids: if channel_id in new_config.afk_channel_ids: continue @@ -214,13 +174,9 @@ 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_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) - ): + if role_id.role_id in new_config.team_role_ids.select(lambda x: int(x.role_id)): continue self._server_configs.delete_server_team_role_id_config(role_id) @@ -232,9 +188,7 @@ class ServerConfigMutation(QueryABC): raise ValueError(f"Invalid roleId") for role_id in new_config.team_role_ids: - if role_id.role_id in old_config.team_role_ids.select( - lambda x: str(x.role_id) - ): + if role_id.role_id in old_config.team_role_ids.select(lambda x: str(x.role_id)): continue self._server_configs.add_server_team_role_id_config(role_id) diff --git a/bot/src/bot_graphql/mutations/short_role_name_mutation.py b/bot/src/bot_graphql/mutations/short_role_name_mutation.py index d3b8c910..3044af99 100644 --- a/bot/src/bot_graphql/mutations/short_role_name_mutation.py +++ b/bot/src/bot_graphql/mutations/short_role_name_mutation.py @@ -41,9 +41,7 @@ class ShortRoleNameMutation(QueryABC): server, ) - result = self._short_role_names.find_short_role_names_by_role_id( - short_role_name.role_id - ) + result = self._short_role_names.find_short_role_names_by_role_id(short_role_name.role_id) if result.count() > 0: raise ValueError("Short name for role already exists") @@ -58,9 +56,7 @@ class ShortRoleNameMutation(QueryABC): ) return ( - self._short_role_names.get_short_role_names_by_server_id( - short_role_name.server.id - ) + self._short_role_names.get_short_role_names_by_server_id(short_role_name.server.id) .where(get_new_short_role_name) .last() ) @@ -69,15 +65,9 @@ class ShortRoleNameMutation(QueryABC): short_role_name = self._short_role_names.get_short_role_name_by_id(input["id"]) self._can_user_mutate_data(short_role_name.server, UserRoleEnum.moderator) - short_role_name.short_name = ( - input["shortName"] if "shortName" in input else short_role_name.short_name - ) - short_role_name.role_id = ( - input["roleId"] if "roleId" in input else short_role_name.role_id - ) - short_role_name.position = ( - input["position"] if "position" in input else short_role_name.position - ) + short_role_name.short_name = input["shortName"] if "shortName" in input else short_role_name.short_name + short_role_name.role_id = input["roleId"] if "roleId" in input else short_role_name.role_id + short_role_name.position = input["position"] if "position" in input else short_role_name.position self._short_role_names.update_short_role_name(short_role_name) self._db.save_changes() diff --git a/bot/src/bot_graphql/mutations/technician_config_mutation.py b/bot/src/bot_graphql/mutations/technician_config_mutation.py index 09ba300b..f5dbbaa2 100644 --- a/bot/src/bot_graphql/mutations/technician_config_mutation.py +++ b/bot/src/bot_graphql/mutations/technician_config_mutation.py @@ -43,9 +43,7 @@ class TechnicianConfigMutation(QueryABC): self._bot.loop.create_task(self._tech_seeder.seed()) 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(Route.get_user().users[0].server, UserRoleEnum.technician) technician_config.help_command_reference_url = ( input["helpCommandReferenceUrl"] @@ -53,19 +51,13 @@ class TechnicianConfigMutation(QueryABC): else technician_config.help_command_reference_url ) technician_config.wait_for_restart = ( - input["waitForRestart"] - if "waitForRestart" in input - else technician_config.wait_for_restart + input["waitForRestart"] if "waitForRestart" in input else technician_config.wait_for_restart ) technician_config.wait_for_shutdown = ( - input["waitForShutdown"] - if "waitForShutdown" in input - else technician_config.wait_for_shutdown + input["waitForShutdown"] if "waitForShutdown" in input else technician_config.wait_for_shutdown ) technician_config.cache_max_messages = ( - input["cacheMaxMessages"] - if "cacheMaxMessages" in input - else technician_config.cache_max_messages + input["cacheMaxMessages"] if "cacheMaxMessages" in input else technician_config.cache_max_messages ) old_feature_flags = technician_config.feature_flags technician_config.feature_flags = ( @@ -83,9 +75,7 @@ class TechnicianConfigMutation(QueryABC): technician_config.feature_flags[old_flag] = False technician_config.ping_urls = ( - List(str, input["pingURLs"]) - if "pingURLs" in input - else technician_config.ping_urls + List(str, input["pingURLs"]) if "pingURLs" in input else technician_config.ping_urls ) technician_config.technician_ids = ( List(int).extend([int(x) for x in input["technicianIds"]]) @@ -110,17 +100,13 @@ class TechnicianConfigMutation(QueryABC): if url in new_config.ping_urls: continue - self._technician_configs.delete_technician_ping_url_config( - TechnicianPingUrlConfig(url) - ) + self._technician_configs.delete_technician_ping_url_config(TechnicianPingUrlConfig(url)) for url in new_config.ping_urls: if url in old_config.ping_urls: continue - self._technician_configs.add_technician_ping_url_config( - TechnicianPingUrlConfig(url) - ) + self._technician_configs.add_technician_ping_url_config(TechnicianPingUrlConfig(url)) def _update_technician_ids(self, new_config: TechnicianConfig): old_config = self._technician_configs.get_technician_config() @@ -128,9 +114,7 @@ class TechnicianConfigMutation(QueryABC): if technician_id in new_config.technician_ids: continue - self._technician_configs.delete_technician_id_config( - TechnicianIdConfig(technician_id) - ) + self._technician_configs.delete_technician_id_config(TechnicianIdConfig(technician_id)) for technician_id in new_config.technician_ids: user = self._bot.get_user(technician_id) @@ -141,6 +125,4 @@ class TechnicianConfigMutation(QueryABC): if technician_id in old_config.technician_ids: continue - self._technician_configs.add_technician_id_config( - TechnicianIdConfig(technician_id) - ) + self._technician_configs.add_technician_id_config(TechnicianIdConfig(technician_id)) diff --git a/bot/src/bot_graphql/mutations/user_joined_game_server_mutation.py b/bot/src/bot_graphql/mutations/user_joined_game_server_mutation.py index d5885fd6..4f53a741 100644 --- a/bot/src/bot_graphql/mutations/user_joined_game_server_mutation.py +++ b/bot/src/bot_graphql/mutations/user_joined_game_server_mutation.py @@ -63,9 +63,7 @@ class UserJoinedGameServerMutation(QueryABC): def _get_api_key_str(self, api_key: ApiKey) -> str: return hashlib.sha256( - f"{api_key.identifier}:{api_key.key}+{self._auth_settings.secret_key}".encode( - "utf-8" - ) + f"{api_key.identifier}:{api_key.key}+{self._auth_settings.secret_key}".encode("utf-8") ).hexdigest() def _get_api_key(self) -> Optional[ApiKey]: @@ -84,19 +82,13 @@ class UserJoinedGameServerMutation(QueryABC): game_ident = self._user_game_idents.get_user_game_ident_by_ident(input["ident"]) user = game_ident.user - settings: ServerConfig = self._config.get_configuration( - f"ServerConfig_{user.server.discord_id}" - ) - if not FeatureFlagsSettings.get_flag_from_dict( - settings.feature_flags, FeatureFlagsEnum.game_server - ): + settings: ServerConfig = self._config.get_configuration(f"ServerConfig_{user.server.discord_id}") + if not FeatureFlagsSettings.get_flag_from_dict(settings.feature_flags, FeatureFlagsEnum.game_server): raise Exception("Feature not activated") self._can_user_mutate_data(user.server, UserRoleEnum.admin) - active = self._user_joined_game_servers.find_active_user_joined_game_server_by_user_id( - user.id - ) + active = self._user_joined_game_servers.find_active_user_joined_game_server_by_user_id(user.id) if active is not None: self._logger.debug( __name__, @@ -108,38 +100,26 @@ class UserJoinedGameServerMutation(QueryABC): self._user_joined_game_servers.add_user_joined_game_server(new) self._db.save_changes() - return self._user_joined_game_servers.get_active_user_joined_game_server_by_user_id( - user.id - ) + return self._user_joined_game_servers.get_active_user_joined_game_server_by_user_id(user.id) def resolve_user_left(self, *_, input: dict): - game_ident = self._user_game_idents.find_user_game_ident_by_ident( - input["ident"] - ) + game_ident = self._user_game_idents.find_user_game_ident_by_ident(input["ident"]) if game_ident is None: return user = game_ident.user - settings: ServerConfig = self._config.get_configuration( - f"ServerConfig_{user.server.discord_id}" - ) - if not FeatureFlagsSettings.get_flag_from_dict( - settings.feature_flags, FeatureFlagsEnum.game_server - ): + settings: ServerConfig = self._config.get_configuration(f"ServerConfig_{user.server.discord_id}") + if not FeatureFlagsSettings.get_flag_from_dict(settings.feature_flags, FeatureFlagsEnum.game_server): raise Exception("Feature not activated") self._can_user_mutate_data(user.server, UserRoleEnum.admin) - active = self._user_joined_game_servers.find_active_user_joined_game_server_by_user_id( - user.id - ) + active = self._user_joined_game_servers.find_active_user_joined_game_server_by_user_id(user.id) if active is None: return active.leaved_on = datetime.now() - settings: ServerConfig = self._config.get_configuration( - f"ServerConfig_{user.server.discord_id}" - ) + settings: ServerConfig = self._config.get_configuration(f"ServerConfig_{user.server.discord_id}") ontime = round((active.leaved_on - active.joined_on).total_seconds() / 3600, 2) old_xp = user.xp diff --git a/bot/src/bot_graphql/mutations/user_mutation.py b/bot/src/bot_graphql/mutations/user_mutation.py index 778db4f4..9ec5f4cc 100644 --- a/bot/src/bot_graphql/mutations/user_mutation.py +++ b/bot/src/bot_graphql/mutations/user_mutation.py @@ -48,9 +48,7 @@ class UserMutation(QueryABC): auth_user = Route.get_user() member = self._bot.get_guild(user.server.discord_id).get_member( - auth_user.users.where(lambda x: x.server.id == user.server.id) - .single() - .discord_id + auth_user.users.where(lambda x: x.server.id == user.server.id).single().discord_id ) if member.id != user.discord_id: self._can_user_mutate_data(user.server, UserRoleEnum.moderator) @@ -64,19 +62,9 @@ class UserMutation(QueryABC): if "userWarnings" in input: self._update_user_warning(user, input["userWarnings"]) - user.xp = ( - new_xp - if new_xp is not None - else input["xp"] - if "xp" in input - else user.xp - ) + user.xp = new_xp if new_xp is not None else input["xp"] if "xp" in input else user.xp - user.birthday = ( - datetime.strptime(input["birthday"], "%d.%m.%Y") - if "birthday" in input - else user.birthday - ) + user.birthday = datetime.strptime(input["birthday"], "%d.%m.%Y") if "birthday" in input else user.birthday self._users.update_user(user) self._db.save_changes() @@ -88,23 +76,15 @@ class UserMutation(QueryABC): def _update_user_warning(self, user: User, new_warnings: dict): old_warnings = self._user_warnings.get_user_warnings_by_user_id(user.id) for warning in old_warnings: - if warning.id in [ - int(x["id"]) if "id" in x else None for x in new_warnings - ]: + if warning.id in [int(x["id"]) if "id" in x else None for x in new_warnings]: continue self._user_warning_service.remove_warnings(warning.id) for warning in new_warnings: - if "id" in warning and int(warning["id"]) in old_warnings.select( - lambda x: x.id - ): + if "id" in warning and int(warning["id"]) in old_warnings.select(lambda x: x.id): continue - member = self._bot.get_guild(user.server.discord_id).get_member( - user.discord_id - ) + member = self._bot.get_guild(user.server.discord_id).get_member(user.discord_id) author = self._users.get_user_by_id(int(warning["author"])) - self._user_warning_service.add_warnings( - member, warning["description"], author.discord_id - ) + self._user_warning_service.add_warnings(member, warning["description"], author.discord_id) diff --git a/bot/src/bot_graphql/queries/achievement_query.py b/bot/src/bot_graphql/queries/achievement_query.py index f12e8657..ab72fde0 100644 --- a/bot/src/bot_graphql/queries/achievement_query.py +++ b/bot/src/bot_graphql/queries/achievement_query.py @@ -9,9 +9,7 @@ class AchievementQuery(DataQueryWithHistoryABC): self, db: DatabaseContextABC, ): - DataQueryWithHistoryABC.__init__( - self, "Achievement", "AchievementsHistory", AchievementHistory, db - ) + DataQueryWithHistoryABC.__init__(self, "Achievement", "AchievementsHistory", AchievementHistory, db) self.set_field("id", lambda x, *_: x.id) self.set_field("name", lambda x, *_: x.name) diff --git a/bot/src/bot_graphql/queries/auto_role_query.py b/bot/src/bot_graphql/queries/auto_role_query.py index ea6b9d7c..aaf694b7 100644 --- a/bot/src/bot_graphql/queries/auto_role_query.py +++ b/bot/src/bot_graphql/queries/auto_role_query.py @@ -18,9 +18,7 @@ class AutoRoleQuery(DataQueryWithHistoryABC): servers: ServerRepositoryABC, db: DatabaseContextABC, ): - DataQueryWithHistoryABC.__init__( - self, "AutoRole", "AutoRolesHistory", AutoRoleHistory, db - ) + DataQueryWithHistoryABC.__init__(self, "AutoRole", "AutoRolesHistory", AutoRoleHistory, db) self._bot = bot self._auto_role_rules = auto_role_rules @@ -33,9 +31,7 @@ class AutoRoleQuery(DataQueryWithHistoryABC): self.set_field("server", self.resolve_server) self.add_collection( "autoRoleRule", - lambda x, *_: self._auto_role_rules.get_auto_role_rules_by_auto_role_id( - x.id - ), + lambda x, *_: self._auto_role_rules.get_auto_role_rules_by_auto_role_id(x.id), AutoRoleFilter, ) diff --git a/bot/src/bot_graphql/queries/auto_role_rule_query.py b/bot/src/bot_graphql/queries/auto_role_rule_query.py index e08dc4f1..0b6373dd 100644 --- a/bot/src/bot_graphql/queries/auto_role_rule_query.py +++ b/bot/src/bot_graphql/queries/auto_role_rule_query.py @@ -14,9 +14,7 @@ class AutoRoleRuleQuery(DataQueryWithHistoryABC): auto_roles: AutoRoleRepositoryABC, db: DatabaseContextABC, ): - DataQueryWithHistoryABC.__init__( - self, "AutoRoleRule", "AutoRoleRulesHistory", AutoRoleRuleHistory, db - ) + DataQueryWithHistoryABC.__init__(self, "AutoRoleRule", "AutoRoleRulesHistory", AutoRoleRuleHistory, db) self._bot = bot self._auto_roles = auto_roles diff --git a/bot/src/bot_graphql/queries/client_query.py b/bot/src/bot_graphql/queries/client_query.py index af462202..6e69a369 100644 --- a/bot/src/bot_graphql/queries/client_query.py +++ b/bot/src/bot_graphql/queries/client_query.py @@ -8,9 +8,7 @@ from bot_graphql.abc.data_query_with_history_abc import DataQueryWithHistoryABC class ClientQuery(DataQueryWithHistoryABC): def __init__(self, bot: DiscordBotServiceABC, db: DatabaseContextABC): - DataQueryWithHistoryABC.__init__( - self, "Client", "ClientsHistory", ClientHistory, db - ) + DataQueryWithHistoryABC.__init__(self, "Client", "ClientsHistory", ClientHistory, db) self._bot = bot diff --git a/bot/src/bot_graphql/queries/discord/guild_query.py b/bot/src/bot_graphql/queries/discord/guild_query.py index 5393c530..cf32e8d7 100644 --- a/bot/src/bot_graphql/queries/discord/guild_query.py +++ b/bot/src/bot_graphql/queries/discord/guild_query.py @@ -21,9 +21,7 @@ class GuildQuery(QueryABC): self.set_field("roles", lambda g, *_: g.roles.order_by(lambda x: x.position)) self.set_field( "emojis", - lambda g, *_: List(discord.Emoji, g.emojis).order_by_descending( - lambda x: x.created_at - ), + lambda g, *_: List(discord.Emoji, g.emojis).order_by_descending(lambda x: x.created_at), ) def _resolve_channels(self, g: Guild, *_, filter=None): diff --git a/bot/src/bot_graphql/queries/known_user_query.py b/bot/src/bot_graphql/queries/known_user_query.py index c6079b56..d3435735 100644 --- a/bot/src/bot_graphql/queries/known_user_query.py +++ b/bot/src/bot_graphql/queries/known_user_query.py @@ -7,9 +7,7 @@ from bot_graphql.abc.data_query_with_history_abc import DataQueryWithHistoryABC class KnownUserQuery(DataQueryWithHistoryABC): def __init__(self, db: DatabaseContextABC): - DataQueryWithHistoryABC.__init__( - self, "KnownUser", "KnownUsersHistory", KnownUserHistory, db - ) + DataQueryWithHistoryABC.__init__(self, "KnownUser", "KnownUsersHistory", KnownUserHistory, db) self.set_field("id", self.resolve_id) self.set_field("discordId", self.resolve_discord_id) diff --git a/bot/src/bot_graphql/queries/level_query.py b/bot/src/bot_graphql/queries/level_query.py index 7eef1b3f..5f726c5b 100644 --- a/bot/src/bot_graphql/queries/level_query.py +++ b/bot/src/bot_graphql/queries/level_query.py @@ -7,9 +7,7 @@ from bot_graphql.abc.data_query_with_history_abc import DataQueryWithHistoryABC class LevelQuery(DataQueryWithHistoryABC): def __init__(self, db: DatabaseContextABC): - DataQueryWithHistoryABC.__init__( - self, "Level", "LevelsHistory", LevelHistory, db - ) + DataQueryWithHistoryABC.__init__(self, "Level", "LevelsHistory", LevelHistory, db) self.set_field("id", self.resolve_id) self.set_field("name", self.resolve_name) diff --git a/bot/src/bot_graphql/queries/server_config_query.py b/bot/src/bot_graphql/queries/server_config_query.py index 9c28b560..3f45fdbf 100644 --- a/bot/src/bot_graphql/queries/server_config_query.py +++ b/bot/src/bot_graphql/queries/server_config_query.py @@ -8,25 +8,15 @@ from bot_graphql.abc.data_query_with_history_abc import DataQueryWithHistoryABC class ServerConfigQuery(DataQueryWithHistoryABC): def __init__(self, db: DatabaseContextABC): - DataQueryWithHistoryABC.__init__( - self, "ServerConfig", "CFG_ServerHistory", ServerConfigHistory, db - ) + DataQueryWithHistoryABC.__init__(self, "ServerConfig", "CFG_ServerHistory", ServerConfigHistory, db) self.set_field("id", lambda config, *_: config.id) - self.set_field( - "messageDeleteTimer", lambda config, *_: config.message_delete_timer - ) - self.set_field( - "notificationChatId", lambda config, *_: config.notification_chat_id - ) - self.set_field( - "maxVoiceStateHours", lambda config, *_: config.max_voice_state_hours - ) + self.set_field("messageDeleteTimer", lambda config, *_: config.message_delete_timer) + self.set_field("notificationChatId", lambda config, *_: config.notification_chat_id) + self.set_field("maxVoiceStateHours", lambda config, *_: config.max_voice_state_hours) self.set_field("xpPerMessage", lambda config, *_: config.xp_per_message) self.set_field("xpPerReaction", lambda config, *_: config.xp_per_reaction) - self.set_field( - "maxMessageXpPerHour", lambda config, *_: config.max_message_xp_per_hour - ) + self.set_field("maxMessageXpPerHour", lambda config, *_: config.max_message_xp_per_hour) self.set_field("xpPerOntimeHour", lambda config, *_: config.xp_per_ontime_hour) self.set_field( "xpPerEventParticipation", @@ -34,16 +24,10 @@ class ServerConfigQuery(DataQueryWithHistoryABC): ) self.set_field("xpPerAchievement", lambda config, *_: config.xp_per_achievement) self.set_field("xpForBirthday", lambda config, *_: config.xp_for_birthday) - self.set_field( - "afkCommandChannelId", lambda config, *_: config.afk_command_channel_id - ) - self.set_field( - "helpVoiceChannelId", lambda config, *_: config.help_voice_channel_id - ) + self.set_field("afkCommandChannelId", lambda config, *_: config.afk_command_channel_id) + self.set_field("helpVoiceChannelId", lambda config, *_: config.help_voice_channel_id) self.set_field("teamChannelId", lambda config, *_: config.team_channel_id) - self.set_field( - "loginMessageChannelId", lambda config, *_: config.login_message_channel_id - ) + self.set_field("loginMessageChannelId", lambda config, *_: config.login_message_channel_id) self.set_field("defaultRoleId", lambda config, *_: config.default_role_id) self.set_field( "shortRoleNameOnlySetHighestRole", @@ -57,10 +41,7 @@ class ServerConfigQuery(DataQueryWithHistoryABC): "featureFlag", lambda config, *_: List( any, - [ - {"key": x, "value": config.feature_flags[x]} - for x in config.feature_flags - ], + [{"key": x, "value": config.feature_flags[x]} for x in config.feature_flags], ), ) self.set_field("afkChannelIds", lambda config, *_: config.afk_channel_ids) diff --git a/bot/src/bot_graphql/queries/server_query.py b/bot/src/bot_graphql/queries/server_query.py index 67879229..edd647cd 100644 --- a/bot/src/bot_graphql/queries/server_query.py +++ b/bot/src/bot_graphql/queries/server_query.py @@ -45,9 +45,7 @@ class ServerQuery(DataQueryWithHistoryABC): short_role_names: ShortRoleNameRepositoryABC, server_configs: ServerConfigRepositoryABC, ): - DataQueryWithHistoryABC.__init__( - self, "Server", "ServersHistory", ServerHistory, db - ) + DataQueryWithHistoryABC.__init__(self, "Server", "ServersHistory", ServerHistory, db) self._config = config self._bot = bot @@ -94,9 +92,7 @@ class ServerQuery(DataQueryWithHistoryABC): ) self.add_collection( "shortRoleName", - lambda server, *_: short_role_names.get_short_role_names_by_server_id( - server.id - ), + lambda server, *_: short_role_names.get_short_role_names_by_server_id(server.id), ShortRoleNameFilter, ) self.set_field( @@ -105,9 +101,7 @@ class ServerQuery(DataQueryWithHistoryABC): ) self.set_field( "hasFeatureFlag", - lambda server, *_, **kwargs: self._resolve_has_feature_flag( - server, *_, **kwargs - ), + lambda server, *_, **kwargs: self._resolve_has_feature_flag(server, *_, **kwargs), ) @staticmethod @@ -127,14 +121,10 @@ class ServerQuery(DataQueryWithHistoryABC): return server.icon_url def _resolve_has_feature_flag(self, server: Server, *_, **kwargs): - settings: ServerConfig = self._config.get_configuration( - f"ServerConfig_{server.discord_id}" - ) + settings: ServerConfig = self._config.get_configuration(f"ServerConfig_{server.discord_id}") if "flag" not in kwargs: return False return { "key": kwargs["flag"], - "value": FeatureFlagsSettings.get_flag_from_dict( - settings.feature_flags, FeatureFlagsEnum(kwargs["flag"]) - ), + "value": FeatureFlagsSettings.get_flag_from_dict(settings.feature_flags, FeatureFlagsEnum(kwargs["flag"])), } diff --git a/bot/src/bot_graphql/queries/short_role_name_query.py b/bot/src/bot_graphql/queries/short_role_name_query.py index 6191aadd..75d07ac6 100644 --- a/bot/src/bot_graphql/queries/short_role_name_query.py +++ b/bot/src/bot_graphql/queries/short_role_name_query.py @@ -9,9 +9,7 @@ class ShortRoleNameQuery(DataQueryWithHistoryABC): self, db: DatabaseContextABC, ): - DataQueryWithHistoryABC.__init__( - self, "ShortRoleName", "ShortRoleNamesHistory", ShortRoleNameHistory, db - ) + DataQueryWithHistoryABC.__init__(self, "ShortRoleName", "ShortRoleNamesHistory", ShortRoleNameHistory, db) self.set_field("id", lambda x, *_: x.id) self.set_field("shortName", lambda x, *_: x.short_name) diff --git a/bot/src/bot_graphql/queries/technician_config_history_query.py b/bot/src/bot_graphql/queries/technician_config_history_query.py index 41ebbb54..fb35ff2f 100644 --- a/bot/src/bot_graphql/queries/technician_config_history_query.py +++ b/bot/src/bot_graphql/queries/technician_config_history_query.py @@ -18,9 +18,6 @@ class TechnicianConfigHistoryQuery(HistoryQueryABC): "featureFlag", lambda config, *_: List( any, - [ - {"key": x, "value": config.feature_flags[x]} - for x in config.feature_flags - ], + [{"key": x, "value": config.feature_flags[x]} for x in config.feature_flags], ), ) diff --git a/bot/src/bot_graphql/queries/technician_config_query.py b/bot/src/bot_graphql/queries/technician_config_query.py index a6363d9b..d44d66ad 100644 --- a/bot/src/bot_graphql/queries/technician_config_query.py +++ b/bot/src/bot_graphql/queries/technician_config_query.py @@ -31,10 +31,7 @@ class TechnicianConfigQuery(DataQueryWithHistoryABC): "featureFlag", lambda config, *_: List( any, - [ - {"key": x, "value": config.feature_flags[x]} - for x in config.feature_flags - ], + [{"key": x, "value": config.feature_flags[x]} for x in config.feature_flags], ), ) self.set_field("pingURLs", lambda config, *_: config.ping_urls) diff --git a/bot/src/bot_graphql/queries/user_query.py b/bot/src/bot_graphql/queries/user_query.py index d91d5043..ceeab6d4 100644 --- a/bot/src/bot_graphql/queries/user_query.py +++ b/bot/src/bot_graphql/queries/user_query.py @@ -66,16 +66,12 @@ class UserQuery(DataQueryWithHistoryABC): ) self.add_collection( "joinedVoiceChannel", - lambda user, *_: self._ujvs.get_user_joined_voice_channels_by_user_id( - user.id - ), + lambda user, *_: self._ujvs.get_user_joined_voice_channels_by_user_id(user.id), UserJoinedVoiceChannelFilter, ) self.add_collection( "userJoinedGameServer", - lambda user, *_: self._user_joined_game_server.get_user_joined_game_servers_by_user_id( - user.id - ), + lambda user, *_: self._user_joined_game_server.get_user_joined_game_servers_by_user_id(user.id), UserJoinedGameServerFilter, ) self.add_collection( diff --git a/bot/src/bot_graphql/queries/user_warning_query.py b/bot/src/bot_graphql/queries/user_warning_query.py index c738e0d7..f6243d5e 100644 --- a/bot/src/bot_graphql/queries/user_warning_query.py +++ b/bot/src/bot_graphql/queries/user_warning_query.py @@ -9,9 +9,7 @@ class UserWarningQuery(DataQueryWithHistoryABC): self, db: DatabaseContextABC, ): - DataQueryWithHistoryABC.__init__( - self, "UserWarning", "UserWarningsHistory", UserWarningsHistory, db - ) + DataQueryWithHistoryABC.__init__(self, "UserWarning", "UserWarningsHistory", UserWarningsHistory, db) self.set_field("id", lambda x, *_: x.id) self.set_field("user", lambda x, *_: x.user) diff --git a/bot/src/bot_graphql/query.py b/bot/src/bot_graphql/query.py index 602fe555..41dafdf0 100644 --- a/bot/src/bot_graphql/query.py +++ b/bot/src/bot_graphql/query.py @@ -62,9 +62,7 @@ class Query(QueryABC): ): QueryABC.__init__(self, "Query") - self.add_collection( - "autoRole", lambda *_: auto_roles.get_auto_roles(), AutoRoleFilter - ) + self.add_collection("autoRole", lambda *_: auto_roles.get_auto_roles(), AutoRoleFilter) self.add_collection( "autoRoleRule", lambda *_: auto_roles.get_auto_role_rules(), @@ -91,9 +89,7 @@ class Query(QueryABC): UserJoinedGameServerFilter, ) self.add_collection("user", lambda *_: users.get_users(), UserFilter) - self.add_collection( - "achievement", lambda *_: achievements.get_achievements(), AchievementFilter - ) + self.add_collection("achievement", lambda *_: achievements.get_achievements(), AchievementFilter) self.add_collection( "shortRoleName", lambda *_: short_role_names.get_short_role_names(), @@ -105,24 +101,14 @@ class Query(QueryABC): UserWarningFilter, ) - self.set_field( - "technicianConfig", lambda *_: technician_config.get_technician_config() - ) + self.set_field("technicianConfig", lambda *_: technician_config.get_technician_config()) - self.set_field( - "achievementAttributes", lambda *_: achievement_service.get_attributes() - ) - self.set_field( - "achievementOperators", lambda *_: achievement_service.get_operators() - ) + self.set_field("achievementAttributes", lambda *_: achievement_service.get_attributes()) + self.set_field("achievementOperators", lambda *_: achievement_service.get_operators()) self.set_field( "shortRoleNamePositions", lambda *_: [x.value for x in ShortRoleNamePositionEnum], ) - self.set_field( - "possibleFeatureFlags", lambda *_: [e.value for e in FeatureFlagsEnum] - ) - self.set_field( - "discord", lambda *_: Discord(bot.guilds, List(any).extend(bot.users)) - ) + self.set_field("possibleFeatureFlags", lambda *_: [e.value for e in FeatureFlagsEnum]) + self.set_field("discord", lambda *_: Discord(bot.guilds, List(any).extend(bot.users))) diff --git a/bot/src/bot_graphql/schema.py b/bot/src/bot_graphql/schema.py index 5e09a19c..020efbc8 100644 --- a/bot/src/bot_graphql/schema.py +++ b/bot/src/bot_graphql/schema.py @@ -10,9 +10,7 @@ from bot_graphql.query import Query class Schema: def __init__(self, query: Query, mutation: Mutation, queries: list[QueryABC]): - type_defs = load_schema_from_path( - os.path.join(os.path.dirname(os.path.realpath(__file__)), "graphql/") - ) + type_defs = load_schema_from_path(os.path.join(os.path.dirname(os.path.realpath(__file__)), "graphql/")) self._schema = make_executable_schema(type_defs, query, mutation, *queries) @property diff --git a/bot/src/modules/achievements/achievement_attribute_resolver.py b/bot/src/modules/achievements/achievement_attribute_resolver.py index 7de2ee0b..66f478f8 100644 --- a/bot/src/modules/achievements/achievement_attribute_resolver.py +++ b/bot/src/modules/achievements/achievement_attribute_resolver.py @@ -46,22 +46,9 @@ class AchievementAttributeResolver: self._achievements = achievements def get_played_on_game_server(self, user: User) -> List[str]: - joins = self._user_joined_game_server.get_user_joined_game_servers_by_user_id( - user.id - ) + joins = self._user_joined_game_server.get_user_joined_game_servers_by_user_id(user.id) return joins.select(lambda x: x.game_server.name) def get_last_ontime_hours(self, user: User) -> int: - ujvs = ( - self._user_joined_voice_channels.get_user_joined_voice_channels_by_user_id( - user.id - ) - ) - return int( - str( - ujvs.max( - lambda join: (join.leaved_on - join.joined_on).total_seconds() - / 3600 - ) - ) - ) + ujvs = self._user_joined_voice_channels.get_user_joined_voice_channels_by_user_id(user.id) + return int(str(ujvs.max(lambda join: (join.leaved_on - join.joined_on).total_seconds() / 3600))) diff --git a/bot/src/modules/achievements/achievement_service.py b/bot/src/modules/achievements/achievement_service.py index 9d3bbac5..39b6cd47 100644 --- a/bot/src/modules/achievements/achievement_service.py +++ b/bot/src/modules/achievements/achievement_service.py @@ -45,12 +45,8 @@ class AchievementService: self._attributes.extend( [ AchievementAttribute("xp", lambda user: user.xp, "number"), - AchievementAttribute( - "message_count", lambda user: user.message_count, "number" - ), - AchievementAttribute( - "reaction_count", lambda user: user.reaction_count, "number" - ), + AchievementAttribute("message_count", lambda user: user.message_count, "number"), + AchievementAttribute("reaction_count", lambda user: user.reaction_count, "number"), AchievementAttribute("ontime", lambda user: user.ontime, "number"), AchievementAttribute("level", lambda user: user.level, "Level"), # special cases @@ -70,14 +66,10 @@ class AchievementService: self._operators = { "==": lambda value, expected_value: value == expected_value, "!=": lambda value, expected_value: value != expected_value, - "<=": lambda value, expected_value: self._num(value) - <= self._num(expected_value), - ">=": lambda value, expected_value: self._num(value) - >= self._num(expected_value), - "<": lambda value, expected_value: self._num(value) - < self._num(expected_value), - ">": lambda value, expected_value: self._num(value) - > self._num(expected_value), + "<=": lambda value, expected_value: self._num(value) <= self._num(expected_value), + ">=": lambda value, expected_value: self._num(value) >= self._num(expected_value), + "<": lambda value, expected_value: self._num(value) < self._num(expected_value), + ">": lambda value, expected_value: self._num(value) > self._num(expected_value), "contains": lambda value, expected_value: expected_value in value, } @@ -100,57 +92,37 @@ class AchievementService: def _match(self, value: any, operator: str, expected_value: str) -> bool: return self._operators[operator](str(value), expected_value) - def has_user_achievement_already( - self, user: User, achievement: Achievement - ) -> bool: + def has_user_achievement_already(self, user: User, achievement: Achievement) -> bool: user_achievements = self._achievements.get_achievements_by_user_id(user.id) return user_achievements.where(lambda x: x.name == achievement.name).count() > 0 def has_user_achievement(self, user: User, achievement: Achievement) -> bool: - attribute: AchievementAttribute = self._attributes.where( - lambda x: x.name == achievement.attribute - ).single() - return self._match( - attribute.resolve(user), achievement.operator, achievement.value - ) + attribute: AchievementAttribute = self._attributes.where(lambda x: x.name == achievement.attribute).single() + return self._match(attribute.resolve(user), achievement.operator, achievement.value) async def validate_achievements_for_user(self, user: User): achievements = self._achievements.get_achievements_by_server_id(user.server.id) for achievement in achievements: - if self.has_user_achievement_already( - user, achievement - ) or not self.has_user_achievement(user, achievement): + if self.has_user_achievement_already(user, achievement) or not self.has_user_achievement(user, achievement): continue - self._achievements.add_user_got_achievement( - UserGotAchievement(user, achievement, user.server) - ) + self._achievements.add_user_got_achievement(UserGotAchievement(user, achievement, user.server)) self._db.save_changes() self._give_user_xp(user) - await self._send_achievement_notification( - user.server.discord_id, user.discord_id, achievement.name - ) + await self._send_achievement_notification(user.server.discord_id, user.discord_id, achievement.name) def _give_user_xp(self, user: User): - settings: ServerConfig = self._config.get_configuration( - f"ServerConfig_{user.server.discord_id}" - ) + settings: ServerConfig = self._config.get_configuration(f"ServerConfig_{user.server.discord_id}") user.xp += settings.xp_per_achievement self._users.update_user(user) self._db.save_changes() - async def _send_achievement_notification( - self, guild_id: int, member_id: int, achievement_name: str - ): + async def _send_achievement_notification(self, guild_id: int, member_id: int, achievement_name: str): member = self._bot.get_guild(guild_id).get_member(member_id) - settings: ServerConfig = self._config.get_configuration( - f"ServerConfig_{guild_id}" - ) + settings: ServerConfig = self._config.get_configuration(f"ServerConfig_{guild_id}") await self._message_service.send_channel_message( self._bot.get_channel(settings.notification_chat_id), - self._t.transform("modules.achievements.got_new_achievement").format( - member.mention, achievement_name - ), + self._t.transform("modules.achievements.got_new_achievement").format(member.mention, achievement_name), is_persistent=True, ) diff --git a/bot/src/modules/achievements/achievements_module.py b/bot/src/modules/achievements/achievements_module.py index cc7c5ec6..4e1a53f4 100644 --- a/bot/src/modules/achievements/achievements_module.py +++ b/bot/src/modules/achievements/achievements_module.py @@ -29,25 +29,17 @@ class AchievementsModule(ModuleABC): def __init__(self, dc: DiscordCollectionABC): ModuleABC.__init__(self, dc, FeatureFlagsEnum.achievements_module) - def configure_configuration( - self, config: ConfigurationABC, env: ApplicationEnvironmentABC - ): + def configure_configuration(self, config: ConfigurationABC, env: ApplicationEnvironmentABC): pass - def configure_services( - self, services: ServiceCollectionABC, env: ApplicationEnvironmentABC - ): + def configure_services(self, services: ServiceCollectionABC, env: ApplicationEnvironmentABC): services.add_transient(AchievementAttributeResolver) services.add_transient(AchievementService) services.add_transient(AchievementGroup) - services.add_transient( - DiscordEventTypesEnum.on_message.value, AchievementOnMessageEvent - ) - services.add_transient( - DiscordEventTypesEnum.on_reaction_add.value, AchievementOnReactionAddEvent - ) + services.add_transient(DiscordEventTypesEnum.on_message.value, AchievementOnMessageEvent) + services.add_transient(DiscordEventTypesEnum.on_reaction_add.value, AchievementOnReactionAddEvent) services.add_transient( DiscordEventTypesEnum.on_reaction_remove.value, AchievementOnReactionRemoveEvent, diff --git a/bot/src/modules/achievements/commands/achievements_group.py b/bot/src/modules/achievements/commands/achievements_group.py index 497dfe4c..a0c73ccb 100644 --- a/bot/src/modules/achievements/commands/achievements_group.py +++ b/bot/src/modules/achievements/commands/achievements_group.py @@ -54,9 +54,7 @@ class AchievementGroup(DiscordCommandABC): if ctx.guild is None: return - server_config: ServerConfig = self._config.get_configuration( - f"ServerConfig_{ctx.guild.id}" - ) + server_config: ServerConfig = self._config.get_configuration(f"ServerConfig_{ctx.guild.id}") if not FeatureFlagsSettings.get_flag_from_dict( server_config.feature_flags, FeatureFlagsEnum.achievements_module ): diff --git a/bot/src/modules/achievements/events/achievement_on_message_event.py b/bot/src/modules/achievements/events/achievement_on_message_event.py index 1cb6a9ee..b3564ccf 100644 --- a/bot/src/modules/achievements/events/achievement_on_message_event.py +++ b/bot/src/modules/achievements/events/achievement_on_message_event.py @@ -43,18 +43,14 @@ class AchievementOnMessageEvent(OnMessageABC): if message.author.bot: return - server_config: ServerConfig = self._config.get_configuration( - f"ServerConfig_{message.guild.id}" - ) + server_config: ServerConfig = self._config.get_configuration(f"ServerConfig_{message.guild.id}") if not FeatureFlagsSettings.get_flag_from_dict( server_config.feature_flags, FeatureFlagsEnum.achievements_module ): return server = self._servers.get_server_by_discord_id(message.guild.id) - user = self._users.get_user_by_discord_id_and_server_id( - message.author.id, server.id - ) + user = self._users.get_user_by_discord_id_and_server_id(message.author.id, server.id) user.message_count += 1 self._users.update_user(user) diff --git a/bot/src/modules/achievements/events/achievement_on_reaction_add_event.py b/bot/src/modules/achievements/events/achievement_on_reaction_add_event.py index cb4fcec9..37959385 100644 --- a/bot/src/modules/achievements/events/achievement_on_reaction_add_event.py +++ b/bot/src/modules/achievements/events/achievement_on_reaction_add_event.py @@ -50,9 +50,7 @@ class AchievementOnReactionAddEvent(OnReactionAddABC): if user.bot: return - server_config: ServerConfig = self._config.get_configuration( - f"ServerConfig_{user.guild.id}" - ) + server_config: ServerConfig = self._config.get_configuration(f"ServerConfig_{user.guild.id}") if not FeatureFlagsSettings.get_flag_from_dict( server_config.feature_flags, FeatureFlagsEnum.achievements_module ): diff --git a/bot/src/modules/achievements/events/achievement_on_reaction_remove_event.py b/bot/src/modules/achievements/events/achievement_on_reaction_remove_event.py index 63aacffc..a25e1868 100644 --- a/bot/src/modules/achievements/events/achievement_on_reaction_remove_event.py +++ b/bot/src/modules/achievements/events/achievement_on_reaction_remove_event.py @@ -50,9 +50,7 @@ class AchievementOnReactionRemoveEvent(OnReactionRemoveABC): if user.bot: return - server_config: ServerConfig = self._config.get_configuration( - f"ServerConfig_{user.guild.id}" - ) + server_config: ServerConfig = self._config.get_configuration(f"ServerConfig_{user.guild.id}") if not FeatureFlagsSettings.get_flag_from_dict( server_config.feature_flags, FeatureFlagsEnum.achievements_module ): diff --git a/bot/src/modules/achievements/events/achievement_on_voice_state_update_event.py b/bot/src/modules/achievements/events/achievement_on_voice_state_update_event.py index d7c5aeb7..b28d5f64 100644 --- a/bot/src/modules/achievements/events/achievement_on_voice_state_update_event.py +++ b/bot/src/modules/achievements/events/achievement_on_voice_state_update_event.py @@ -46,9 +46,7 @@ class AchievementOnVoiceStateUpdateEvent(OnVoiceStateUpdateABC): if member.bot: return - server_config: ServerConfig = self._config.get_configuration( - f"ServerConfig_{member.guild.id}" - ) + server_config: ServerConfig = self._config.get_configuration(f"ServerConfig_{member.guild.id}") if not FeatureFlagsSettings.get_flag_from_dict( server_config.feature_flags, FeatureFlagsEnum.achievements_module ): diff --git a/bot/src/modules/auto_role/auto_role_module.py b/bot/src/modules/auto_role/auto_role_module.py index 4fee55e8..07eba97e 100644 --- a/bot/src/modules/auto_role/auto_role_module.py +++ b/bot/src/modules/auto_role/auto_role_module.py @@ -20,14 +20,10 @@ class AutoRoleModule(ModuleABC): def __init__(self, dc: DiscordCollectionABC): ModuleABC.__init__(self, dc, FeatureFlagsEnum.auto_role_module) - def configure_configuration( - self, config: ConfigurationABC, env: ApplicationEnvironmentABC - ): + def configure_configuration(self, config: ConfigurationABC, env: ApplicationEnvironmentABC): pass - def configure_services( - self, services: ServiceCollectionABC, env: ApplicationEnvironmentABC - ): + def configure_services(self, services: ServiceCollectionABC, env: ApplicationEnvironmentABC): services.add_transient(AutoRoleReactionHandler) # commands services.add_transient(AutoRoleGroup) diff --git a/bot/src/modules/auto_role/command/auto_role_group.py b/bot/src/modules/auto_role/command/auto_role_group.py index 6e5ae53c..f8d48d4e 100644 --- a/bot/src/modules/auto_role/command/auto_role_group.py +++ b/bot/src/modules/auto_role/command/auto_role_group.py @@ -58,14 +58,10 @@ class AutoRoleGroup(DiscordCommandABC): self, interaction: discord.Interaction, current: str ) -> TList[app_commands.Choice[str]]: server = self._servers.get_server_by_discord_id(interaction.guild.id) - auto_roles = self._auto_roles.get_auto_roles_by_server_id(server.id).select( - lambda x: x.id - ) + auto_roles = self._auto_roles.get_auto_roles_by_server_id(server.id).select(lambda x: x.id) return [ app_commands.Choice(name=auto_role, value=auto_role) - for auto_role in self._client_utils.get_auto_complete_list( - auto_roles, current, lambda x: x.name - ) + for auto_role in self._client_utils.get_auto_complete_list(auto_roles, current, lambda x: x.name) ] @commands.hybrid_group(name="auto-role") @@ -82,12 +78,8 @@ class AutoRoleGroup(DiscordCommandABC): if ctx.guild is None: return - server_config: ServerConfig = self._config.get_configuration( - f"ServerConfig_{ctx.guild.id}" - ) - if not FeatureFlagsSettings.get_flag_from_dict( - server_config.feature_flags, FeatureFlagsEnum.auto_role_module - ): + server_config: ServerConfig = self._config.get_configuration(f"ServerConfig_{ctx.guild.id}") + if not FeatureFlagsSettings.get_flag_from_dict(server_config.feature_flags, FeatureFlagsEnum.auto_role_module): return embed = discord.Embed( @@ -98,9 +90,7 @@ class AutoRoleGroup(DiscordCommandABC): server = self._servers.get_server_by_discord_id(ctx.guild.id) auto_roles = self._auto_roles.get_auto_roles_by_server_id(server.id) if auto_roles.count() < 1: - await self._message_service.send_ctx_msg( - ctx, self._t.transform("modules.auto_role.error.nothing_found") - ) + await self._message_service.send_ctx_msg(ctx, self._t.transform("modules.auto_role.error.nothing_found")) self._logger.trace(__name__, f"Finished command auto-role list") return @@ -128,18 +118,12 @@ class AutoRoleGroup(DiscordCommandABC): @CommandChecks.check_is_ready() @CommandChecks.check_is_member_moderator() async def add(self, ctx: Context, channel: discord.TextChannel, message_id: str): - self._logger.debug( - __name__, f"Received command auto-role add {ctx} {message_id}" - ) + self._logger.debug(__name__, f"Received command auto-role add {ctx} {message_id}") if ctx.guild is None: return - server_config: ServerConfig = self._config.get_configuration( - f"ServerConfig_{ctx.guild.id}" - ) - if not FeatureFlagsSettings.get_flag_from_dict( - server_config.feature_flags, FeatureFlagsEnum.auto_role_module - ): + server_config: ServerConfig = self._config.get_configuration(f"ServerConfig_{ctx.guild.id}") + if not FeatureFlagsSettings.get_flag_from_dict(server_config.feature_flags, FeatureFlagsEnum.auto_role_module): return message = ( @@ -151,56 +135,38 @@ class AutoRoleGroup(DiscordCommandABC): .single_or_default() ) if message is None: - self._logger.debug( - __name__, f"Message with id {message_id} not found in {channel.name}" - ) + self._logger.debug(__name__, f"Message with id {message_id} not found in {channel.name}") await self._message_service.send_ctx_msg( ctx, - self._t.transform("modules.auto_role.add.error.not_found").format( - message_id, channel.mention - ), + self._t.transform("modules.auto_role.add.error.not_found").format(message_id, channel.mention), ) self._logger.trace(__name__, f"Finished command auto-role add") return if self._auto_roles.find_auto_role_by_message_id(int(message_id)) is not None: - self._logger.debug( - __name__, f"auto-role for message {message_id} already exists" - ) + self._logger.debug(__name__, f"auto-role for message {message_id} already exists") await self._message_service.send_ctx_msg( ctx, - self._t.transform("modules.auto_role.add.error.already_exists").format( - message_id - ), + self._t.transform("modules.auto_role.add.error.already_exists").format(message_id), ) self._logger.trace(__name__, f"Finished command auto-role add") return server = self._servers.get_server_by_discord_id(ctx.guild.id) - self._auto_roles.add_auto_role( - AutoRole(server, int(channel.id), int(message_id)) - ) + self._auto_roles.add_auto_role(AutoRole(server, int(channel.id), int(message_id))) self._db_context.save_changes() - self._logger.info( - __name__, f"Saved auto-role for message {message_id} at server {server}" - ) + self._logger.info(__name__, f"Saved auto-role for message {message_id} at server {server}") await self._message_service.send_ctx_msg( ctx, self._t.transform("modules.auto_role.add.success").format(message_id) ) self._logger.trace(__name__, f"Finished command auto-role add") @add.autocomplete("message_id") - async def add_autocomplete( - self, interaction: discord.Interaction, current: str - ) -> TList[app_commands.Choice[str]]: - channel = discord.utils.get( - interaction.guild.text_channels, id=interaction.channel_id - ) + async def add_autocomplete(self, interaction: discord.Interaction, current: str) -> TList[app_commands.Choice[str]]: + channel = discord.utils.get(interaction.guild.text_channels, id=interaction.channel_id) try: channel_from_data = interaction.data["options"][0]["options"][0]["value"] - found_channel = discord.utils.get( - interaction.guild.text_channels, id=int(channel_from_data) - ) + found_channel = discord.utils.get(interaction.guild.text_channels, id=int(channel_from_data)) if found_channel is not None: channel = found_channel finally: @@ -208,9 +174,7 @@ class AutoRoleGroup(DiscordCommandABC): messages = [message async for message in channel.history(limit=10)] return [ - app_commands.Choice( - name=f"{message.author}@{message.created_at}", value=str(message.id) - ) + app_commands.Choice(name=f"{message.author}@{message.created_at}", value=str(message.id)) for message in messages if current in str(message.id) ] @@ -220,18 +184,12 @@ class AutoRoleGroup(DiscordCommandABC): @CommandChecks.check_is_ready() @CommandChecks.check_is_member_moderator() async def remove(self, ctx: Context, auto_role: int): - self._logger.debug( - __name__, f"Received command auto-role remove {ctx} {auto_role}" - ) + self._logger.debug(__name__, f"Received command auto-role remove {ctx} {auto_role}") if ctx.guild is None: return - server_config: ServerConfig = self._config.get_configuration( - f"ServerConfig_{ctx.guild.id}" - ) - if not FeatureFlagsSettings.get_flag_from_dict( - server_config.feature_flags, FeatureFlagsEnum.auto_role_module - ): + server_config: ServerConfig = self._config.get_configuration(f"ServerConfig_{ctx.guild.id}") + if not FeatureFlagsSettings.get_flag_from_dict(server_config.feature_flags, FeatureFlagsEnum.auto_role_module): return auto_role_from_db = self._auto_roles.find_auto_role_by_id(auto_role) @@ -239,16 +197,12 @@ class AutoRoleGroup(DiscordCommandABC): self._logger.debug(__name__, f"auto-role {auto_role} not found") await self._message_service.send_ctx_msg( ctx, - self._t.transform("modules.auto_role.remove.error.not_found").format( - auto_role - ), + self._t.transform("modules.auto_role.remove.error.not_found").format(auto_role), ) self._logger.trace(__name__, f"Finished command auto-role remove") return - for rule in self._auto_roles.get_auto_role_rules_by_auto_role_id( - auto_role_from_db.id - ): + for rule in self._auto_roles.get_auto_role_rules_by_auto_role_id(auto_role_from_db.id): self._auto_roles.delete_auto_role_rule(rule) self._logger.info(__name__, f"Removed auto-role rule {rule.role_id}") @@ -271,18 +225,12 @@ class AutoRoleGroup(DiscordCommandABC): @CommandChecks.check_is_ready() @CommandChecks.check_is_member_moderator() async def react(self, ctx: Context, auto_role: int): - self._logger.debug( - __name__, f"Received command auto-role react {ctx} {auto_role}" - ) + self._logger.debug(__name__, f"Received command auto-role react {ctx} {auto_role}") if ctx.guild is None: return - server_config: ServerConfig = self._config.get_configuration( - f"ServerConfig_{ctx.guild.id}" - ) - if not FeatureFlagsSettings.get_flag_from_dict( - server_config.feature_flags, FeatureFlagsEnum.auto_role_module - ): + server_config: ServerConfig = self._config.get_configuration(f"ServerConfig_{ctx.guild.id}") + if not FeatureFlagsSettings.get_flag_from_dict(server_config.feature_flags, FeatureFlagsEnum.auto_role_module): return auto_role_from_db = self._auto_roles.find_auto_role_by_id(auto_role) @@ -290,16 +238,12 @@ class AutoRoleGroup(DiscordCommandABC): self._logger.debug(__name__, f"auto-role {auto_role} not found") await self._message_service.send_ctx_msg( ctx, - self._t.transform("modules.auto_role.remove.error.not_found").format( - auto_role - ), + self._t.transform("modules.auto_role.remove.error.not_found").format(auto_role), ) self._logger.trace(__name__, f"Finished command auto-role react") return - for rule in self._auto_roles.get_auto_role_rules_by_auto_role_id( - auto_role_from_db.id - ): + for rule in self._auto_roles.get_auto_role_rules_by_auto_role_id(auto_role_from_db.id): await self._client_utils.react_to_message_by_auto_role_rule( auto_role_from_db.discord_channel_id, auto_role_from_db.discord_message_id, @@ -333,12 +277,8 @@ class AutoRoleGroup(DiscordCommandABC): if ctx.guild is None: return - server_config: ServerConfig = self._config.get_configuration( - f"ServerConfig_{ctx.guild.id}" - ) - if not FeatureFlagsSettings.get_flag_from_dict( - server_config.feature_flags, FeatureFlagsEnum.auto_role_module - ): + server_config: ServerConfig = self._config.get_configuration(f"ServerConfig_{ctx.guild.id}") + if not FeatureFlagsSettings.get_flag_from_dict(server_config.feature_flags, FeatureFlagsEnum.auto_role_module): return embed = discord.Embed( @@ -391,30 +331,20 @@ class AutoRoleGroup(DiscordCommandABC): @CommandChecks.check_is_ready() @CommandChecks.check_is_member_moderator() async def add(self, ctx: Context, auto_role: int, emoji_name: str, role_id: str): - self._logger.debug( - __name__, f"Received command auto-role add {ctx} {auto_role}" - ) + self._logger.debug(__name__, f"Received command auto-role add {ctx} {auto_role}") if ctx.guild is None: return - server_config: ServerConfig = self._config.get_configuration( - f"ServerConfig_{ctx.guild.id}" - ) - if not FeatureFlagsSettings.get_flag_from_dict( - server_config.feature_flags, FeatureFlagsEnum.auto_role_module - ): + server_config: ServerConfig = self._config.get_configuration(f"ServerConfig_{ctx.guild.id}") + if not FeatureFlagsSettings.get_flag_from_dict(server_config.feature_flags, FeatureFlagsEnum.auto_role_module): return emoji = discord.utils.get(self._bot.emojis, name=emoji_name) if emoji is None: - self._logger.debug( - __name__, f"auto-role rule add emoji {emoji_name} not found" - ) + self._logger.debug(__name__, f"auto-role rule add emoji {emoji_name} not found") await self._message_service.send_ctx_msg( ctx, - self._t.transform( - "modules.auto_role.rule.add.error.emoji_not_found" - ).format(emoji_name, auto_role), + self._t.transform("modules.auto_role.rule.add.error.emoji_not_found").format(emoji_name, auto_role), ) self._logger.trace(__name__, f"Finished command auto-role add") return @@ -424,9 +354,7 @@ class AutoRoleGroup(DiscordCommandABC): self._logger.debug(__name__, f"auto-role rule add role {role_id} not found") await self._message_service.send_ctx_msg( ctx, - self._t.transform( - "modules.auto_role.rule.add.error.role_not_found" - ).format(role_id, auto_role), + self._t.transform("modules.auto_role.rule.add.error.role_not_found").format(role_id, auto_role), ) self._logger.trace(__name__, f"Finished command auto-role add") return @@ -435,9 +363,7 @@ class AutoRoleGroup(DiscordCommandABC): if auto_role_from_db is None: await self._message_service.send_ctx_msg( ctx, - self._t.transform("modules.auto_role.remove.error.not_found").format( - auto_role - ), + self._t.transform("modules.auto_role.remove.error.not_found").format(auto_role), ) self._logger.trace(__name__, f"Finished command auto-role rule add") return @@ -450,16 +376,12 @@ class AutoRoleGroup(DiscordCommandABC): ): await self._message_service.send_ctx_msg( ctx, - self._t.transform("modules.auto_role.add.error.already_exists").format( - auto_role - ), + self._t.transform("modules.auto_role.add.error.already_exists").format(auto_role), ) self._logger.trace(__name__, f"Finished command auto-role rule add") return - self._auto_roles.add_auto_role_rule( - AutoRoleRule(auto_role_from_db, emoji_name, int(role_id)) - ) + self._auto_roles.add_auto_role_rule(AutoRoleRule(auto_role_from_db, emoji_name, int(role_id))) self._db_context.save_changes() rule = ( self._auto_roles.get_auto_role_rules_by_auto_role_id(auto_role) @@ -479,28 +401,20 @@ class AutoRoleGroup(DiscordCommandABC): await self._message_service.send_ctx_msg( ctx, - self._t.transform("modules.auto_role.rule.add.success").format( - emoji, role.mention, auto_role - ), + self._t.transform("modules.auto_role.rule.add.success").format(emoji, role.mention, auto_role), ) self._logger.trace(__name__, f"Finished command auto-role rule add") @add.autocomplete("auto_role") - async def add_autocomplete( - self, interaction: discord.Interaction, current: str - ) -> TList[app_commands.Choice[str]]: + async def add_autocomplete(self, interaction: discord.Interaction, current: str) -> TList[app_commands.Choice[str]]: return await self._auto_role_auto_complete(interaction, current) @add.autocomplete("emoji_name") - async def add_autocomplete( - self, interaction: discord.Interaction, current: str - ) -> TList[app_commands.Choice[str]]: + async def add_autocomplete(self, interaction: discord.Interaction, current: str) -> TList[app_commands.Choice[str]]: emojis = List(discord.Emoji, interaction.guild.emojis) return [ app_commands.Choice(name=emoji.name, value=emoji.name) - for emoji in self._client_utils.get_auto_complete_list( - emojis, current, lambda e: e.name - ) + for emoji in self._client_utils.get_auto_complete_list(emojis, current, lambda e: e.name) ] @add.autocomplete("role_id") @@ -510,9 +424,7 @@ class AutoRoleGroup(DiscordCommandABC): roles = List(discord.Role, interaction.guild.roles) return [ app_commands.Choice(name=role.name, value=str(role.id)) - for role in self._client_utils.get_auto_complete_list( - roles, current, lambda r: r.name - ) + for role in self._client_utils.get_auto_complete_list(roles, current, lambda r: r.name) ] @rule.command() @@ -520,18 +432,12 @@ class AutoRoleGroup(DiscordCommandABC): @CommandChecks.check_is_ready() @CommandChecks.check_is_member_moderator() async def remove(self, ctx: Context, auto_role_rule: int): - self._logger.debug( - __name__, f"Received command auto-role remove {ctx} {auto_role_rule}" - ) + self._logger.debug(__name__, f"Received command auto-role remove {ctx} {auto_role_rule}") if ctx.guild is None: return - server_config: ServerConfig = self._config.get_configuration( - f"ServerConfig_{ctx.guild.id}" - ) - if not FeatureFlagsSettings.get_flag_from_dict( - server_config.feature_flags, FeatureFlagsEnum.auto_role_module - ): + server_config: ServerConfig = self._config.get_configuration(f"ServerConfig_{ctx.guild.id}") + if not FeatureFlagsSettings.get_flag_from_dict(server_config.feature_flags, FeatureFlagsEnum.auto_role_module): return auto_role_from_db = self._auto_roles.get_auto_role_rule_by_id(auto_role_rule) @@ -539,9 +445,7 @@ class AutoRoleGroup(DiscordCommandABC): self._logger.debug(__name__, f"auto-role rule {auto_role_rule} not found") await self._message_service.send_ctx_msg( ctx, - self._t.transform("modules.auto_role.remove.error.not_found").format( - auto_role_rule - ), + self._t.transform("modules.auto_role.remove.error.not_found").format(auto_role_rule), ) self._logger.trace(__name__, f"Finished command auto-role rule remove") return @@ -551,9 +455,7 @@ class AutoRoleGroup(DiscordCommandABC): self._logger.info(__name__, f"Removed auto-role rule {auto_role_rule}") await self._message_service.send_ctx_msg( ctx, - self._t.transform("modules.auto_role.rule.remove.success").format( - auto_role_rule - ), + self._t.transform("modules.auto_role.rule.remove.success").format(auto_role_rule), ) self._logger.trace(__name__, f"Finished command auto-role remove") @@ -562,18 +464,12 @@ class AutoRoleGroup(DiscordCommandABC): self, interaction: discord.Interaction, current: str ) -> TList[app_commands.Choice[str]]: server = self._servers.get_server_by_discord_id(interaction.guild.id) - auto_roles = self._auto_roles.get_auto_roles_by_server_id(server.id).select( - lambda x: x.id - ) - rules = auto_roles.select_many( - lambda ar: self._auto_roles.get_auto_role_rules_by_auto_role_id(ar) - ) + auto_roles = self._auto_roles.get_auto_roles_by_server_id(server.id).select(lambda x: x.id) + rules = auto_roles.select_many(lambda ar: self._auto_roles.get_auto_role_rules_by_auto_role_id(ar)) return [ app_commands.Choice( name=f"{rule.id} {rule.emoji_name} {interaction.guild.get_role(int(rule.role_id))}", value=rule.id, ) - for rule in self._client_utils.get_auto_complete_list( - rules, current, lambda r: r.id - ) + for rule in self._client_utils.get_auto_complete_list(rules, current, lambda r: r.id) ] diff --git a/bot/src/modules/auto_role/events/auto_role_on_raw_reaction_add.py b/bot/src/modules/auto_role/events/auto_role_on_raw_reaction_add.py index a85fadd2..f5d14804 100644 --- a/bot/src/modules/auto_role/events/auto_role_on_raw_reaction_add.py +++ b/bot/src/modules/auto_role/events/auto_role_on_raw_reaction_add.py @@ -35,12 +35,8 @@ class AutoRoleOnRawReactionAddEvent(OnRawReactionAddABC): @EventChecks.check_is_ready() async def on_raw_reaction_add(self, payload: RawReactionActionEvent): self._logger.debug(__name__, f"Module {type(self)} started") - server_config: ServerConfig = self._config.get_configuration( - f"ServerConfig_{payload.guild_id}" - ) - if not FeatureFlagsSettings.get_flag_from_dict( - server_config.feature_flags, FeatureFlagsEnum.auto_role_module - ): + server_config: ServerConfig = self._config.get_configuration(f"ServerConfig_{payload.guild_id}") + if not FeatureFlagsSettings.get_flag_from_dict(server_config.feature_flags, FeatureFlagsEnum.auto_role_module): return await self._reaction_handler.handle(payload, "add") diff --git a/bot/src/modules/auto_role/events/auto_role_on_raw_reaction_remove.py b/bot/src/modules/auto_role/events/auto_role_on_raw_reaction_remove.py index 0defd312..a174c8f5 100644 --- a/bot/src/modules/auto_role/events/auto_role_on_raw_reaction_remove.py +++ b/bot/src/modules/auto_role/events/auto_role_on_raw_reaction_remove.py @@ -35,12 +35,8 @@ class AutoRoleOnRawReactionRemoveEvent(OnRawReactionRemoveABC): @EventChecks.check_is_ready() async def on_raw_reaction_remove(self, payload: RawReactionActionEvent): self._logger.debug(__name__, f"Module {type(self)} started") - server_config: ServerConfig = self._config.get_configuration( - f"ServerConfig_{payload.guild_id}" - ) - if not FeatureFlagsSettings.get_flag_from_dict( - server_config.feature_flags, FeatureFlagsEnum.auto_role_module - ): + server_config: ServerConfig = self._config.get_configuration(f"ServerConfig_{payload.guild_id}") + if not FeatureFlagsSettings.get_flag_from_dict(server_config.feature_flags, FeatureFlagsEnum.auto_role_module): return await self._reaction_handler.handle(payload, "remove") diff --git a/bot/src/modules/auto_role/helper/auto_role_reaction_handler.py b/bot/src/modules/auto_role/helper/auto_role_reaction_handler.py index b0b59aee..47ab3778 100644 --- a/bot/src/modules/auto_role/helper/auto_role_reaction_handler.py +++ b/bot/src/modules/auto_role/helper/auto_role_reaction_handler.py @@ -22,9 +22,7 @@ class AutoRoleReactionHandler: self._servers = servers self._auto_roles = auto_roles - self._message_ids = self._auto_roles.get_auto_roles().select( - lambda x: x.discord_message_id - ) + self._message_ids = self._auto_roles.get_auto_roles().select(lambda x: x.discord_message_id) self._roles = self._auto_roles.get_auto_roles() async def handle(self, payload: RawReactionActionEvent, r_type=None) -> None: @@ -36,9 +34,7 @@ class AutoRoleReactionHandler: guild = self._bot.get_guild(payload.guild_id) user = guild.get_member(payload.user_id) if user is None: - self._logger.warn( - __name__, f"User {payload.user_id} in {guild.name} not found - skipping" - ) + self._logger.warn(__name__, f"User {payload.user_id} in {guild.name} not found - skipping") return if user.bot: @@ -53,9 +49,7 @@ class AutoRoleReactionHandler: self._logger.debug(__name__, f"auto-role for message not found - skipping") return - rules: List[ - AutoRoleRule - ] = self._auto_roles.get_auto_role_rules_by_auto_role_id(auto_role.id) + rules: List[AutoRoleRule] = self._auto_roles.get_auto_role_rules_by_auto_role_id(auto_role.id) if rules.count() == 0: self._logger.debug(__name__, f"auto-role rules not found - skipping") return diff --git a/bot/src/modules/base/base_module.py b/bot/src/modules/base/base_module.py index 60f17173..fc04e55e 100644 --- a/bot/src/modules/base/base_module.py +++ b/bot/src/modules/base/base_module.py @@ -53,14 +53,10 @@ class BaseModule(ModuleABC): def __init__(self, dc: DiscordCollectionABC): ModuleABC.__init__(self, dc, FeatureFlagsEnum.base_module) - def configure_configuration( - self, config: ConfigurationABC, env: ApplicationEnvironmentABC - ): + def configure_configuration(self, config: ConfigurationABC, env: ApplicationEnvironmentABC): pass - def configure_services( - self, services: ServiceCollectionABC, env: ApplicationEnvironmentABC - ): + def configure_services(self, services: ServiceCollectionABC, env: ApplicationEnvironmentABC): services.add_transient(BaseReactionHandler) services.add_singleton(EventService) services.add_transient(UserWarningsService) @@ -86,27 +82,13 @@ class BaseModule(ModuleABC): services.add_transient(UnregisterGroup) services.add_transient(GameServerGroup) # events - services.add_transient( - DiscordEventTypesEnum.on_command.value, BaseOnCommandEvent - ) - services.add_transient( - DiscordEventTypesEnum.on_command_error.value, BaseOnCommandErrorEvent - ) - services.add_transient( - DiscordEventTypesEnum.on_member_join.value, BaseOnMemberJoinEvent - ) - services.add_transient( - DiscordEventTypesEnum.on_member_remove.value, BaseOnMemberRemoveEvent - ) - services.add_transient( - DiscordEventTypesEnum.on_message.value, BaseOnMessageEvent - ) - services.add_transient( - DiscordEventTypesEnum.on_message_delete.value, BaseOnMessageDeleteEvent - ) - services.add_transient( - DiscordEventTypesEnum.on_raw_reaction_add.value, BaseOnRawReactionAddEvent - ) + services.add_transient(DiscordEventTypesEnum.on_command.value, BaseOnCommandEvent) + services.add_transient(DiscordEventTypesEnum.on_command_error.value, BaseOnCommandErrorEvent) + services.add_transient(DiscordEventTypesEnum.on_member_join.value, BaseOnMemberJoinEvent) + services.add_transient(DiscordEventTypesEnum.on_member_remove.value, BaseOnMemberRemoveEvent) + services.add_transient(DiscordEventTypesEnum.on_message.value, BaseOnMessageEvent) + services.add_transient(DiscordEventTypesEnum.on_message_delete.value, BaseOnMessageDeleteEvent) + services.add_transient(DiscordEventTypesEnum.on_raw_reaction_add.value, BaseOnRawReactionAddEvent) services.add_transient( DiscordEventTypesEnum.on_raw_reaction_remove.value, BaseOnRawReactionRemoveEvent, diff --git a/bot/src/modules/base/birthday_watcher.py b/bot/src/modules/base/birthday_watcher.py index 2b01095f..7b19638a 100644 --- a/bot/src/modules/base/birthday_watcher.py +++ b/bot/src/modules/base/birthday_watcher.py @@ -46,9 +46,7 @@ class BirthdayWatcher(TaskABC): if user.birthday.day != today.day or user.birthday.month != today.month: continue - settings: ServerConfig = self._config.get_configuration( - f"ServerConfig_{user.server.discord_id}" - ) + settings: ServerConfig = self._config.get_configuration(f"ServerConfig_{user.server.discord_id}") user.xp += settings.xp_for_birthday self._users.update_user(user) @@ -58,9 +56,7 @@ class BirthdayWatcher(TaskABC): member = guild.get_member(user.discord_id) await self._message_service.send_channel_message( self._bot.get_channel(settings.notification_chat_id), - self._t.transform("modules.base.user.birthday.has_birthday").format( - member.mention - ), + self._t.transform("modules.base.user.birthday.has_birthday").format(member.mention), is_persistent=True, ) except Exception as e: diff --git a/bot/src/modules/base/command/afk_command.py b/bot/src/modules/base/command/afk_command.py index 924c012d..092c9788 100644 --- a/bot/src/modules/base/command/afk_command.py +++ b/bot/src/modules/base/command/afk_command.py @@ -39,9 +39,7 @@ class AFKCommand(DiscordCommandABC): @CommandChecks.check_is_ready() async def afk(self, ctx: Context): self._logger.debug(__name__, f"Received command afk {ctx}") - settings: ServerConfig = self._config.get_configuration( - f"ServerConfig_{ctx.guild.id}" - ) + settings: ServerConfig = self._config.get_configuration(f"ServerConfig_{ctx.guild.id}") if ctx.author.voice is None or ctx.author.voice.channel is None: await self._message_service.send_ctx_msg( @@ -52,9 +50,7 @@ class AFKCommand(DiscordCommandABC): return self._bot.loop.create_task( - self._message_service.send_ctx_msg( - ctx, self._t.transform("modules.base.afk_command_move_message") - ) + self._message_service.send_ctx_msg(ctx, self._t.transform("modules.base.afk_command_move_message")) ) channel: VoiceChannel = ctx.guild.get_channel(settings.afk_command_channel_id) try: @@ -66,8 +62,6 @@ class AFKCommand(DiscordCommandABC): f"Cannot move user {ctx.author.id} to channel {ctx.channel.id}", e, ) - await self._message_service.send_ctx_msg( - ctx, self._t.transform("common.no_permission_message") - ) + await self._message_service.send_ctx_msg(ctx, self._t.transform("common.no_permission_message")) self._logger.trace(__name__, f"Finished afk command") diff --git a/bot/src/modules/base/command/game_server_group.py b/bot/src/modules/base/command/game_server_group.py index 051db38e..55d235e3 100644 --- a/bot/src/modules/base/command/game_server_group.py +++ b/bot/src/modules/base/command/game_server_group.py @@ -76,15 +76,9 @@ class GameServerGroup(DiscordCommandABC): if ctx.guild is None: return - settings: ServerConfig = self._config.get_configuration( - f"ServerConfig_{ctx.guild.id}" - ) - if not FeatureFlagsSettings.get_flag_from_dict( - settings.feature_flags, FeatureFlagsEnum.game_server - ): - await self._message_service.send_ctx_msg( - ctx, self._t.transform("common.feature_not_activated") - ) + settings: ServerConfig = self._config.get_configuration(f"ServerConfig_{ctx.guild.id}") + if not FeatureFlagsSettings.get_flag_from_dict(settings.feature_flags, FeatureFlagsEnum.game_server): + await self._message_service.send_ctx_msg(ctx, self._t.transform("common.feature_not_activated")) return server = self._servers.get_server_by_discord_id(ctx.guild.id) @@ -127,22 +121,14 @@ class GameServerGroup(DiscordCommandABC): @CommandChecks.check_is_ready() @CommandChecks.check_is_member_admin() async def add(self, ctx: Context, name: str, api_key_id: int): - self._logger.debug( - __name__, f"Received command game-server add {ctx}: {name} {api_key_id}" - ) + self._logger.debug(__name__, f"Received command game-server add {ctx}: {name} {api_key_id}") if ctx.guild is None: return - settings: ServerConfig = self._config.get_configuration( - f"ServerConfig_{ctx.guild.id}" - ) - if not FeatureFlagsSettings.get_flag_from_dict( - settings.feature_flags, FeatureFlagsEnum.game_server - ): - await self._message_service.send_ctx_msg( - ctx, self._t.transform("common.feature_not_activated") - ) + settings: ServerConfig = self._config.get_configuration(f"ServerConfig_{ctx.guild.id}") + if not FeatureFlagsSettings.get_flag_from_dict(settings.feature_flags, FeatureFlagsEnum.game_server): + await self._message_service.send_ctx_msg(ctx, self._t.transform("common.feature_not_activated")) return server = self._servers.get_server_by_discord_id(ctx.guild.id) @@ -166,9 +152,7 @@ class GameServerGroup(DiscordCommandABC): return [ app_commands.Choice(name=f"{key.identifier}: {key.key}", value=key.id) - for key in self._client_utils.get_auto_complete_list( - keys, current, lambda x: x.key - ) + for key in self._client_utils.get_auto_complete_list(keys, current, lambda x: x.key) ] @game_server.command() @@ -181,38 +165,26 @@ class GameServerGroup(DiscordCommandABC): if ctx.guild is None: return - settings: ServerConfig = self._config.get_configuration( - f"ServerConfig_{ctx.guild.id}" - ) - if not FeatureFlagsSettings.get_flag_from_dict( - settings.feature_flags, FeatureFlagsEnum.game_server - ): - await self._message_service.send_ctx_msg( - ctx, self._t.transform("common.feature_not_activated") - ) + settings: ServerConfig = self._config.get_configuration(f"ServerConfig_{ctx.guild.id}") + if not FeatureFlagsSettings.get_flag_from_dict(settings.feature_flags, FeatureFlagsEnum.game_server): + await self._message_service.send_ctx_msg(ctx, self._t.transform("common.feature_not_activated")) return game_server = self._game_servers.get_game_server_by_id(id) self._game_servers.delete_game_server(game_server) self._db.save_changes() - await self._message_service.send_ctx_msg( - ctx, self._t.transform("modules.base.game_server.remove.success") - ) + await self._message_service.send_ctx_msg(ctx, self._t.transform("modules.base.game_server.remove.success")) self._logger.trace(__name__, f"Finished command game-server remove") @remove.autocomplete("id") - async def id_autocomplete( - self, interaction: discord.Interaction, current: str - ) -> TList[app_commands.Choice[str]]: + async def id_autocomplete(self, interaction: discord.Interaction, current: str) -> TList[app_commands.Choice[str]]: server = self._servers.get_server_by_discord_id(interaction.guild.id) game_servers = self._game_servers.get_game_servers_by_server_id(server.id) return [ app_commands.Choice(name=gs.name, value=gs.id) - for gs in self._client_utils.get_auto_complete_list( - game_servers, current, lambda x: x.name - ) + for gs in self._client_utils.get_auto_complete_list(game_servers, current, lambda x: x.name) ] @game_server.command(name="list-members") @@ -225,30 +197,20 @@ class GameServerGroup(DiscordCommandABC): if ctx.guild is None: return - settings: ServerConfig = self._config.get_configuration( - f"ServerConfig_{ctx.guild.id}" - ) - if not FeatureFlagsSettings.get_flag_from_dict( - settings.feature_flags, FeatureFlagsEnum.game_server - ): - await self._message_service.send_ctx_msg( - ctx, self._t.transform("common.feature_not_activated") - ) + settings: ServerConfig = self._config.get_configuration(f"ServerConfig_{ctx.guild.id}") + if not FeatureFlagsSettings.get_flag_from_dict(settings.feature_flags, FeatureFlagsEnum.game_server): + await self._message_service.send_ctx_msg(ctx, self._t.transform("common.feature_not_activated")) return game_server = self._game_servers.get_game_server_by_id(id) - game_idents = self._user_game_idents.get_user_game_idents_by_game_server_id( - game_server.id - ) + game_idents = self._user_game_idents.get_user_game_idents_by_game_server_id(game_server.id) users = "" for game_ident in game_idents: users += f"\n{game_ident.user.name}" embed = discord.Embed( title=self._t.transform("modules.base.game_server.list_members.title"), - description=self._t.transform( - "modules.base.game_server.list_members.description" - ), + description=self._t.transform("modules.base.game_server.list_members.description"), color=int("ef9d0d", 16), ) embed.add_field( @@ -261,15 +223,11 @@ class GameServerGroup(DiscordCommandABC): self._logger.trace(__name__, f"Finished command game-server remove") @list_members.autocomplete("id") - async def id_autocomplete( - self, interaction: discord.Interaction, current: str - ) -> TList[app_commands.Choice[str]]: + async def id_autocomplete(self, interaction: discord.Interaction, current: str) -> TList[app_commands.Choice[str]]: server = self._servers.get_server_by_discord_id(interaction.guild.id) game_servers = self._game_servers.get_game_servers_by_server_id(server.id) return [ app_commands.Choice(name=gs.name, value=gs.id) - for gs in self._client_utils.get_auto_complete_list( - game_servers, current, lambda x: x.name - ) + for gs in self._client_utils.get_auto_complete_list(game_servers, current, lambda x: x.name) ] diff --git a/bot/src/modules/base/command/help_command.py b/bot/src/modules/base/command/help_command.py index e97dc198..beb63e77 100644 --- a/bot/src/modules/base/command/help_command.py +++ b/bot/src/modules/base/command/help_command.py @@ -50,8 +50,6 @@ class HelpCommand(DiscordCommandABC): self._logger.trace(__name__, f"Finished help command") @help.autocomplete("persistent_flag") - async def help_autocomplete( - self, interaction: discord.Interaction, current: str - ) -> List[app_commands.Choice[str]]: + async def help_autocomplete(self, interaction: discord.Interaction, current: str) -> List[app_commands.Choice[str]]: flags = ["--stay"] return [app_commands.Choice(name=key, value=key) for key in flags] diff --git a/bot/src/modules/base/command/info_command.py b/bot/src/modules/base/command/info_command.py index 11290c05..e228be84 100644 --- a/bot/src/modules/base/command/info_command.py +++ b/bot/src/modules/base/command/info_command.py @@ -55,10 +55,7 @@ class InfoCommand(DiscordCommandABC): ) start_time = self._config.get_configuration("Bot_StartTime") ontime = round( - ( - datetime.now() - datetime.strptime(start_time, "%Y-%m-%d %H:%M:%S.%f") - ).total_seconds() - / 3600, + (datetime.now() - datetime.strptime(start_time, "%Y-%m-%d %H:%M:%S.%f")).total_seconds() / 3600, 2, ) embed.add_field( diff --git a/bot/src/modules/base/command/mass_move_command.py b/bot/src/modules/base/command/mass_move_command.py index cedbaa03..4dd835d2 100644 --- a/bot/src/modules/base/command/mass_move_command.py +++ b/bot/src/modules/base/command/mass_move_command.py @@ -58,9 +58,7 @@ class MassMoveCommand(DiscordCommandABC): await self._message_service.send_ctx_msg( ctx, - self._t.transform("modules.base.mass_move.moved").format( - channel_from.mention, channel_to.mention - ), + self._t.transform("modules.base.mass_move.moved").format(channel_from.mention, channel_to.mention), ) self._logger.trace(__name__, f"Finished mass-move command") diff --git a/bot/src/modules/base/command/ping_command.py b/bot/src/modules/base/command/ping_command.py index 69aff5cf..ca0a14ac 100644 --- a/bot/src/modules/base/command/ping_command.py +++ b/bot/src/modules/base/command/ping_command.py @@ -58,12 +58,8 @@ class PingCommand(DiscordCommandABC): color=int("ef9d0d", 16), ) for server in self._settings.ping_urls: - embed.add_field( - name=server, value=f"{self._get_ping(server)} ms", inline=False - ) + embed.add_field(name=server, value=f"{self._get_ping(server)} ms", inline=False) await self._message_service.send_ctx_msg(ctx, embed) else: - await self._message_service.send_ctx_msg( - ctx, self._t.transform("modules.base.pong") - ) + await self._message_service.send_ctx_msg(ctx, self._t.transform("modules.base.pong")) self._logger.trace(__name__, f"Finished ping command") diff --git a/bot/src/modules/base/command/presence_command.py b/bot/src/modules/base/command/presence_command.py index 688e3d20..a314b4aa 100644 --- a/bot/src/modules/base/command/presence_command.py +++ b/bot/src/modules/base/command/presence_command.py @@ -34,9 +34,7 @@ class PresenceCommand(DiscordCommandABC): if text == "": await self._bot.change_presence(activity=None) - await self._message_service.send_ctx_msg( - ctx, self._t.transform("modules.base.presence.removed") - ) + await self._message_service.send_ctx_msg(ctx, self._t.transform("modules.base.presence.removed")) return if len(text) > 128: @@ -46,8 +44,6 @@ class PresenceCommand(DiscordCommandABC): return await self._bot.change_presence(activity=discord.Game(name=text)) - await self._message_service.send_ctx_msg( - ctx, self._t.transform("modules.base.presence.changed") - ) + await self._message_service.send_ctx_msg(ctx, self._t.transform("modules.base.presence.changed")) self._logger.trace(__name__, f"Finished presence command") diff --git a/bot/src/modules/base/command/purge_command.py b/bot/src/modules/base/command/purge_command.py index ff40f718..9816e29f 100644 --- a/bot/src/modules/base/command/purge_command.py +++ b/bot/src/modules/base/command/purge_command.py @@ -41,20 +41,14 @@ class PurgeCommand(DiscordCommandABC): @CommandChecks.check_is_member_moderator() async def purge(self, ctx: Context): self._logger.debug(__name__, f"Received command purge {ctx}") - server_settings: ServerConfig = self._config.get_configuration( - f"ServerConfig_{ctx.guild.id}" - ) + server_settings: ServerConfig = self._config.get_configuration(f"ServerConfig_{ctx.guild.id}") - await self._message_service.send_ctx_msg( - ctx, self._t.transform("modules.moderator.purge_message") - ) + await self._message_service.send_ctx_msg(ctx, self._t.transform("modules.moderator.purge_message")) await asyncio.sleep(server_settings.message_delete_timer) try: await ctx.channel.purge() except Exception as e: self._logger.error(__name__, f"Cannot purge channel {ctx.channel.id}", e) - await self._message_service.send_ctx_msg( - ctx, self._t.transform("common.bot_has_no_permission_message") - ) + await self._message_service.send_ctx_msg(ctx, self._t.transform("common.bot_has_no_permission_message")) self._logger.trace(__name__, f"Finished purge command") diff --git a/bot/src/modules/base/command/register_group.py b/bot/src/modules/base/command/register_group.py index 4fc94ac3..a598b31e 100644 --- a/bot/src/modules/base/command/register_group.py +++ b/bot/src/modules/base/command/register_group.py @@ -59,17 +59,13 @@ class RegisterGroup(DiscordCommandABC): @commands.guild_only() @CommandChecks.check_is_ready() @CommandChecks.check_is_member_moderator() - async def minecraft( - self, ctx: Context, member: discord.Member, game_server: int, name: str - ): + async def minecraft(self, ctx: Context, member: discord.Member, game_server: int, name: str): self._logger.debug(__name__, f"Received command register minecraft {ctx}") minecraft_id = None try: self._logger.debug(__name__, f"Try to get minecraft id for {name}") - response = requests.get( - url=f"https://api.mojang.com/users/profiles/minecraft/{name}" - ) + response = requests.get(url=f"https://api.mojang.com/users/profiles/minecraft/{name}") if len(response.content) == 0: await self._message_service.send_interaction_msg( ctx.interaction, @@ -110,7 +106,5 @@ class RegisterGroup(DiscordCommandABC): return [ app_commands.Choice(name=gs.name, value=gs.id) - for gs in self._client_utils.get_auto_complete_list( - game_servers, current, lambda x: x.name - ) + for gs in self._client_utils.get_auto_complete_list(game_servers, current, lambda x: x.name) ] diff --git a/bot/src/modules/base/command/submit_group.py b/bot/src/modules/base/command/submit_group.py index b832b7c2..ad1570e3 100644 --- a/bot/src/modules/base/command/submit_group.py +++ b/bot/src/modules/base/command/submit_group.py @@ -11,9 +11,7 @@ from modules.base.forms.complaint_form import ComplaintForm class SubmitGroup(DiscordCommandABC): - def __init__( - self, services: ServiceProviderABC, logger: LoggerABC, bot: DiscordBotServiceABC - ): + def __init__(self, services: ServiceProviderABC, logger: LoggerABC, bot: DiscordBotServiceABC): DiscordCommandABC.__init__(self) self._services = services diff --git a/bot/src/modules/base/command/unregister_group.py b/bot/src/modules/base/command/unregister_group.py index 3f4e2c1d..4d5f796a 100644 --- a/bot/src/modules/base/command/unregister_group.py +++ b/bot/src/modules/base/command/unregister_group.py @@ -62,9 +62,7 @@ class UnregisterGroup(DiscordCommandABC): server = self._servers.get_server_by_discord_id(ctx.guild.id) user = self._users.get_user_by_discord_id_and_server_id(member.id, server.id) - ident = user.game_idents.where( - lambda x: x.game_server.id == game_server - ).single() + ident = user.game_idents.where(lambda x: x.game_server.id == game_server).single() self._user_game_idents.delete_user_game_ident(ident) self._users.update_user(user) self._db.save_changes() @@ -84,7 +82,5 @@ class UnregisterGroup(DiscordCommandABC): return [ app_commands.Choice(name=gs.name, value=gs.id) - for gs in self._client_utils.get_auto_complete_list( - game_servers, current, lambda x: x.name - ) + for gs in self._client_utils.get_auto_complete_list(game_servers, current, lambda x: x.name) ] diff --git a/bot/src/modules/base/command/user_group.py b/bot/src/modules/base/command/user_group.py index 5ed217e7..4f1df692 100644 --- a/bot/src/modules/base/command/user_group.py +++ b/bot/src/modules/base/command/user_group.py @@ -111,9 +111,7 @@ class UserGroup(DiscordCommandABC): type = "add" if not is_remove else "remove" await self._message_service.send_interaction_msg( ctx.interaction, - self._t.transform(f"modules.base.user.{type}.{atr.lower()}").format( - atr, value, member.mention - ), + self._t.transform(f"modules.base.user.{type}.{atr.lower()}").format(atr, value, member.mention), ) @commands.hybrid_group() @@ -131,9 +129,7 @@ class UserGroup(DiscordCommandABC): ) date = datetime.date(year, month, day) server = self._servers.get_server_by_discord_id(ctx.guild.id) - user = self._users.get_user_by_discord_id_and_server_id( - ctx.author.id, server.id - ) + user = self._users.get_user_by_discord_id_and_server_id(ctx.author.id, server.id) user.birthday = date self._users.update_user(user) self._db.save_changes() @@ -141,15 +137,11 @@ class UserGroup(DiscordCommandABC): ctx.interaction, self._t.transform("modules.base.user.birthday.success") ) # notify team to prevent multiple entries every day - settings: ServerConfig = self._config.get_configuration( - f"ServerConfig_{ctx.guild.id}" - ) + settings: ServerConfig = self._config.get_configuration(f"ServerConfig_{ctx.guild.id}") channel = ctx.guild.get_channel(settings.team_channel_id) await self._message_service.send_channel_message( channel, - self._t.transform("modules.base.user.birthday.success_team").format( - ctx.author.mention, date - ), + self._t.transform("modules.base.user.birthday.success_team").format(ctx.author.mention, date), is_persistent=True, ) self._logger.trace(__name__, f"Finished user-info command") @@ -188,18 +180,12 @@ class UserGroup(DiscordCommandABC): @user.command() @commands.guild_only() @CommandChecks.check_is_ready() - async def info( - self, ctx: Context, member: Optional[discord.Member] = None, *, wait: int = None - ): - self._logger.debug( - __name__, f"Received command user-info {ctx}:{member},{wait}" - ) + async def info(self, ctx: Context, member: Optional[discord.Member] = None, *, wait: int = None): + self._logger.debug(__name__, f"Received command user-info {ctx}:{member},{wait}") is_mod = self._permissions.is_member_moderator(ctx.author) if member is not None and not is_mod: - await self._message_service.send_ctx_msg( - ctx, self._t.transform("common.no_permission_message") - ) + await self._message_service.send_ctx_msg(ctx, self._t.transform("common.no_permission_message")) return if member is None or not isinstance(member, discord.Member): @@ -209,16 +195,10 @@ class UserGroup(DiscordCommandABC): user = self._users.find_user_by_discord_id_and_server_id(member.id, server.id) joins = self._user_joined_servers.get_user_joined_servers_by_user_id(user.id) - embed = discord.Embed( - title=member.name, description=member.name, color=int("ef9d0d", 16) - ) + embed = discord.Embed(title=member.name, description=member.name, color=int("ef9d0d", 16)) - embed.add_field( - name=self._t.transform("modules.base.user.atr.id"), value=member.id - ) - embed.add_field( - name=self._t.transform("modules.base.user.atr.name"), value=member.name - ) + embed.add_field(name=self._t.transform("modules.base.user.atr.id"), value=member.id) + embed.add_field(name=self._t.transform("modules.base.user.atr.name"), value=member.name) embed.add_field( name=self._t.transform("modules.base.user.atr.discord_join"), value=self._date.transform(member.created_at), @@ -229,9 +209,7 @@ class UserGroup(DiscordCommandABC): value=self._date.transform(member.joined_at), inline=False, ) - embed.add_field( - name=self._t.transform("modules.base.user.atr.xp"), value=str(user.xp) - ) + embed.add_field(name=self._t.transform("modules.base.user.atr.xp"), value=str(user.xp)) embed.add_field( name=self._t.transform("modules.base.user.atr.ontime"), value=str(self._client_utils.get_ontime_for_user(user)), @@ -281,9 +259,7 @@ class UserGroup(DiscordCommandABC): ) # send to interaction because of sensitive data - await self._message_service.send_interaction_msg( - ctx.interaction, embed, wait_before_delete=wait - ) + await self._message_service.send_interaction_msg(ctx.interaction, embed, wait_before_delete=wait) self._logger.trace(__name__, f"Finished user-info command") @user.command() @@ -294,9 +270,7 @@ class UserGroup(DiscordCommandABC): is_mod = self._permissions.is_member_moderator(ctx.author) if member is not None and not is_mod: - await self._message_service.send_ctx_msg( - ctx, self._t.transform("common.no_permission_message") - ) + await self._message_service.send_ctx_msg(ctx, self._t.transform("common.no_permission_message")) return if member is None or not isinstance(member, discord.Member): @@ -320,26 +294,18 @@ class UserGroup(DiscordCommandABC): await self._message_service.send_interaction_msg( ctx.interaction, - self._t.transform(f"modules.base.user.get.{atr.lower()}").format( - member.mention, value - ), + self._t.transform(f"modules.base.user.get.{atr.lower()}").format(member.mention, value), ) @get.autocomplete("atr") - async def get_autocomplete( - self, interaction: discord.Interaction, current: str - ) -> TList[app_commands.Choice[str]]: - return [ - app_commands.Choice(name=value, value=key) for key, value in self._atr_TList - ] + async def get_autocomplete(self, interaction: discord.Interaction, current: str) -> TList[app_commands.Choice[str]]: + return [app_commands.Choice(name=value, value=key) for key, value in self._atr_TList] @user.command() @commands.guild_only() @CommandChecks.check_is_ready() @CommandChecks.check_is_member_moderator() - async def set( - self, ctx: Context, atr: str, value: int, member: discord.Member = None - ): + async def set(self, ctx: Context, atr: str, value: int, member: discord.Member = None): self._logger.debug(__name__, f"Received command user-set {atr} {ctx}:{member}") if member is None or not isinstance(member, discord.Member): @@ -352,9 +318,7 @@ class UserGroup(DiscordCommandABC): try: user.xp = value except TypeError as te: - self._logger.error( - __name__, f"String value couldn't be converted to int", te - ) + self._logger.error(__name__, f"String value couldn't be converted to int", te) await self._message_service.send_interaction_msg( ctx.interaction, self._t.transform("modules.base.user.set.error.type_error"), @@ -374,15 +338,11 @@ class UserGroup(DiscordCommandABC): await self._message_service.send_interaction_msg( ctx.interaction, - self._t.transform(f"modules.base.user.set.{atr.lower()}").format( - member.mention, value - ), + self._t.transform(f"modules.base.user.set.{atr.lower()}").format(member.mention, value), ) @set.autocomplete("atr") - async def set_autocomplete( - self, interaction: discord.Interaction, current: str - ) -> TList[app_commands.Choice[str]]: + async def set_autocomplete(self, interaction: discord.Interaction, current: str) -> TList[app_commands.Choice[str]]: atr_TList = [("xp", self._atr_dict["xp"])] return [app_commands.Choice(name=value, value=key) for key, value in atr_TList] @@ -390,18 +350,12 @@ class UserGroup(DiscordCommandABC): @commands.guild_only() @CommandChecks.check_is_ready() @CommandChecks.check_is_member_moderator() - async def add( - self, ctx: Context, atr: str, value: int, member: discord.Member = None - ): - self._logger.debug( - __name__, f"Received command user-add {atr}-={value} {ctx}:{member}" - ) + async def add(self, ctx: Context, atr: str, value: int, member: discord.Member = None): + self._logger.debug(__name__, f"Received command user-add {atr}-={value} {ctx}:{member}") await self._handle_atr_calc(ctx, atr, value, member) @add.autocomplete("atr") - async def set_autocomplete( - self, interaction: discord.Interaction, current: str - ) -> TList[app_commands.Choice[str]]: + async def set_autocomplete(self, interaction: discord.Interaction, current: str) -> TList[app_commands.Choice[str]]: atr_TList = [("xp", self._atr_dict["xp"])] return [app_commands.Choice(name=value, value=key) for key, value in atr_TList] @@ -409,18 +363,12 @@ class UserGroup(DiscordCommandABC): @commands.guild_only() @CommandChecks.check_is_ready() @CommandChecks.check_is_member_moderator() - async def remove( - self, ctx: Context, atr: str, value: int, member: discord.Member = None - ): - self._logger.debug( - __name__, f"Received command user-remove {atr}-={value} {ctx}:{member}" - ) + async def remove(self, ctx: Context, atr: str, value: int, member: discord.Member = None): + self._logger.debug(__name__, f"Received command user-remove {atr}-={value} {ctx}:{member}") await self._handle_atr_calc(ctx, atr, value, member, is_remove=True) @remove.autocomplete("atr") - async def set_autocomplete( - self, interaction: discord.Interaction, current: str - ) -> TList[app_commands.Choice[str]]: + async def set_autocomplete(self, interaction: discord.Interaction, current: str) -> TList[app_commands.Choice[str]]: atr_TList = [("xp", self._atr_dict["xp"])] return [app_commands.Choice(name=value, value=key) for key, value in atr_TList] @@ -429,9 +377,7 @@ class UserGroup(DiscordCommandABC): @CommandChecks.check_is_ready() @CommandChecks.check_is_member_moderator() async def reset(self, ctx: Context, atr: str, member: discord.Member = None): - self._logger.debug( - __name__, f"Received command user-reset {atr} {ctx}:{member}" - ) + self._logger.debug(__name__, f"Received command user-reset {atr} {ctx}:{member}") if member is None or not isinstance(member, discord.Member): member = ctx.author @@ -446,9 +392,7 @@ class UserGroup(DiscordCommandABC): await self._level.check_level(member) elif atr == "ontime": - self._user_joined_voice_channel.delete_user_joined_voice_channel_by_user_id( - user.id - ) + self._user_joined_voice_channel.delete_user_joined_voice_channel_by_user_id(user.id) self._db.save_changes() else: @@ -460,18 +404,14 @@ class UserGroup(DiscordCommandABC): await self._message_service.send_interaction_msg( ctx.interaction, - self._t.transform(f"modules.base.user.reset.{atr.lower()}").format( - atr, member.mention - ), + self._t.transform(f"modules.base.user.reset.{atr.lower()}").format(atr, member.mention), ) @reset.autocomplete("atr") async def reset_autocomplete( self, interaction: discord.Interaction, current: str ) -> TList[app_commands.Choice[str]]: - return [ - app_commands.Choice(name=value, value=key) for key, value in self._atr_TList - ] + return [app_commands.Choice(name=value, value=key) for key, value in self._atr_TList] @user.group() @commands.guild_only() @@ -483,9 +423,7 @@ class UserGroup(DiscordCommandABC): @CommandChecks.check_is_ready() @CommandChecks.check_is_member_moderator() async def show(self, ctx: Context, member: discord.Member, wait: int = None): - self._logger.debug( - __name__, f"Received command user warning show {ctx}:{member}" - ) + self._logger.debug(__name__, f"Received command user warning show {ctx}:{member}") server = self._servers.find_server_by_discord_id(ctx.guild.id) user = self._users.find_user_by_discord_id_and_server_id(member.id, server.id) @@ -515,9 +453,7 @@ class UserGroup(DiscordCommandABC): value=warnings_description_string, inline=True, ) - await self._message_service.send_interaction_msg( - ctx.interaction, embed, wait_before_delete=wait - ) + await self._message_service.send_interaction_msg(ctx.interaction, embed, wait_before_delete=wait) self._logger.trace(__name__, f"Finished user warning show command") @warning.command() @@ -525,21 +461,13 @@ class UserGroup(DiscordCommandABC): @CommandChecks.check_is_ready() @CommandChecks.check_is_member_moderator() async def add(self, ctx: Context, member: discord.Member, description: str): - self._logger.debug( - __name__, f"Received command user warning add {ctx}:{member},{description}" - ) + self._logger.debug(__name__, f"Received command user warning add {ctx}:{member},{description}") try: - await self._user_warnings_service.add_warnings_async( - member, description, ctx.author.id - ) - await self._message_service.send_ctx_msg( - ctx, self._t.transform("modules.base.warnings.add.success") - ) + await self._user_warnings_service.add_warnings_async(member, description, ctx.author.id) + await self._message_service.send_ctx_msg(ctx, self._t.transform("modules.base.warnings.add.success")) except Exception as e: self._logger.error(__name__, f"Adding user warning failed", e) - await self._message_service.send_ctx_msg( - ctx, self._t.transform("modules.base.warnings.add.failed") - ) + await self._message_service.send_ctx_msg(ctx, self._t.transform("modules.base.warnings.add.failed")) self._logger.trace(__name__, f"Finished user warning add command") @warning.command() @@ -547,17 +475,11 @@ class UserGroup(DiscordCommandABC): @CommandChecks.check_is_ready() @CommandChecks.check_is_member_moderator() async def remove(self, ctx: Context, warning_id: int): - self._logger.debug( - __name__, f"Received command user warning remove {ctx}:{warning_id}" - ) + self._logger.debug(__name__, f"Received command user warning remove {ctx}:{warning_id}") try: await self._user_warnings_service.remove_warnings_async(warning_id) - await self._message_service.send_ctx_msg( - ctx, self._t.transform("modules.base.warnings.remove.success") - ) + await self._message_service.send_ctx_msg(ctx, self._t.transform("modules.base.warnings.remove.success")) except Exception as e: self._logger.error(__name__, f"Removing user warning failed", e) - await self._message_service.send_ctx_msg( - ctx, self._t.transform("modules.base.warnings.remove.failed") - ) + await self._message_service.send_ctx_msg(ctx, self._t.transform("modules.base.warnings.remove.failed")) self._logger.trace(__name__, f"Finished user warning remove command") diff --git a/bot/src/modules/base/events/base_on_command_error_event.py b/bot/src/modules/base/events/base_on_command_error_event.py index 5a4628f6..d5aab492 100644 --- a/bot/src/modules/base/events/base_on_command_error_event.py +++ b/bot/src/modules/base/events/base_on_command_error_event.py @@ -167,9 +167,7 @@ class BaseOnCommandErrorEvent(OnCommandErrorABC): ) elif isinstance(error, commands.NotOwner): - await self._messenger.send_ctx_msg( - ctx, self._t.transform("common.errors.not_owner"), without_tracking=True - ) + await self._messenger.send_ctx_msg(ctx, self._t.transform("common.errors.not_owner"), without_tracking=True) elif isinstance(error, commands.MissingPermissions): await self._messenger.send_ctx_msg( @@ -261,19 +259,13 @@ class BaseOnCommandErrorEvent(OnCommandErrorABC): self._t.transform("common.errors.command_error"), without_tracking=True, ) - message = self._t.transform( - "modules.base.technician_command_error_message" - ).format( + message = self._t.transform("modules.base.technician_command_error_message").format( ctx.command, ctx.author, error, - datetime.datetime.now().strftime( - self._time_format_settings.date_time_format - ), + datetime.datetime.now().strftime(self._time_format_settings.date_time_format), uid, ) for t in self._tech_settings.technician_ids: member = self._bot.get_user(t) - await self._messenger.send_dm_message( - message, member, without_tracking=True - ) + await self._messenger.send_dm_message(message, member, without_tracking=True) diff --git a/bot/src/modules/base/events/base_on_command_event.py b/bot/src/modules/base/events/base_on_command_event.py index 149426d5..407a875f 100644 --- a/bot/src/modules/base/events/base_on_command_event.py +++ b/bot/src/modules/base/events/base_on_command_event.py @@ -49,9 +49,7 @@ class BaseOnCommandEvent(OnCommandABC): self._clients.append_received_command_count(self._bot.user.id, g_id, 1) self._db.save_changes() except Exception as e: - self._logger.error( - __name__, f"Cannot edit client {self._bot.user.id}@{g_id}", e - ) + self._logger.error(__name__, f"Cannot edit client {self._bot.user.id}@{g_id}", e) def _handle_message_for_xp(self, message: discord.Message): dc_user_id = message.author.id @@ -63,9 +61,7 @@ class BaseOnCommandEvent(OnCommandABC): user: Optional[User] = None try: - user = self._users.get_user_by_discord_id_and_server_id( - dc_user_id, server.id - ) + user = self._users.get_user_by_discord_id_and_server_id(dc_user_id, server.id) except Exception as e: self._logger.error(__name__, f"Cannot get user {dc_user_id}", e) return @@ -74,23 +70,17 @@ class BaseOnCommandEvent(OnCommandABC): self._logger.error(__name__, f"User not found {dc_user_id}") return - settings: ServerConfig = self._config.get_configuration( - f"ServerConfig_{message.guild.id}" - ) + settings: ServerConfig = self._config.get_configuration(f"ServerConfig_{message.guild.id}") old_xp = user.xp user.xp += settings.xp_per_message self._users.update_user(user) self._db.save_changes() - self._logger.debug( - __name__, f"User {user} sent message. xp: from {old_xp} to {user.xp}" - ) + self._logger.debug(__name__, f"User {user} sent message. xp: from {old_xp} to {user.xp}") async def on_command(self, ctx: Context): self._logger.debug(__name__, f"Module {type(self)} started") - self._logger.info( - __name__, f"Received command: {ctx.command} from {ctx.channel}" - ) + self._logger.info(__name__, f"Received command: {ctx.command} from {ctx.channel}") if ctx is None or ctx.guild is None: return self._append_received_command_count(ctx.guild.id) diff --git a/bot/src/modules/base/events/base_on_member_join_event.py b/bot/src/modules/base/events/base_on_member_join_event.py index 99939a27..a09772d6 100644 --- a/bot/src/modules/base/events/base_on_member_join_event.py +++ b/bot/src/modules/base/events/base_on_member_join_event.py @@ -66,9 +66,7 @@ class BaseOnMemberJoinEvent(OnMemberJoinABC): except Exception as e: self._logger.error(__name__, f"Cannot get user {member.id}", e) - async def _add_if_not_exists_user_async( - self, member: Union[discord.User, discord.Member] - ): + async def _add_if_not_exists_user_async(self, member: Union[discord.User, discord.Member]): self._logger.debug(__name__, f"Check if user exists {member}") await self._messenger.send_dm_message( self._t.transform("modules.base.welcome_message").format(member.guild.name), @@ -77,40 +75,28 @@ class BaseOnMemberJoinEvent(OnMemberJoinABC): try: server = self._servers.get_server_by_discord_id(member.guild.id) - user = self._users.find_user_by_discord_id_and_server_id( - member.id, server.id - ) + user = self._users.find_user_by_discord_id_and_server_id(member.id, server.id) if user is not None: - self._user_joins.add_user_joined_server( - UserJoinedServer(user, datetime.now()) - ) + self._user_joins.add_user_joined_server(UserJoinedServer(user, datetime.now())) self._db.save_changes() return self._logger.debug(__name__, f"Add user: {member.id}") self._users.add_user(User(member.id, 0, 0, 0, server)) self._db.save_changes() - user = self._users.get_user_by_discord_id_and_server_id( - member.id, server.id - ) - self._user_joins.add_user_joined_server( - UserJoinedServer(user, datetime.now()) - ) + user = self._users.get_user_by_discord_id_and_server_id(member.id, server.id) + self._user_joins.add_user_joined_server(UserJoinedServer(user, datetime.now())) self._db.save_changes() except Exception as e: self._logger.error(__name__, f"Cannot get user {member.id}", e) async def _notify_team(self, member: discord.Member): self._logger.debug(__name__, f"Notify team that a member left") - settings: ServerConfig = self._config.get_configuration( - f"ServerConfig_{member.guild.id}" - ) + settings: ServerConfig = self._config.get_configuration(f"ServerConfig_{member.guild.id}") channel = member.guild.get_channel(settings.team_channel_id) await self._messenger.send_channel_message( channel, - self._t.transform("modules.base.welcome_message_for_team").format( - member.mention - ), + self._t.transform("modules.base.welcome_message_for_team").format(member.mention), is_persistent=True, ) self._logger.trace(__name__, f"Notified team that a member left") diff --git a/bot/src/modules/base/events/base_on_member_remove_event.py b/bot/src/modules/base/events/base_on_member_remove_event.py index ed6a02df..adfe7e87 100644 --- a/bot/src/modules/base/events/base_on_member_remove_event.py +++ b/bot/src/modules/base/events/base_on_member_remove_event.py @@ -41,16 +41,12 @@ class BaseOnMemberRemoveEvent(OnMemberRemoveABC): async def _remove_user(self, member: Union[discord.User, discord.Member]): self._logger.debug(__name__, f"Remove user {member}") - await self._message_service.send_dm_message( - self._t.transform("modules.base.goodbye_message"), member - ) + await self._message_service.send_dm_message(self._t.transform("modules.base.goodbye_message"), member) try: server = self._servers.get_server_by_discord_id(member.guild.id) - user = self._users.find_user_by_discord_id_and_server_id( - member.id, server.id - ) + user = self._users.find_user_by_discord_id_and_server_id(member.id, server.id) if user is None: self._logger.error(__name__, f"Cannot find user {member}") return @@ -64,15 +60,11 @@ class BaseOnMemberRemoveEvent(OnMemberRemoveABC): async def _notify_team(self, member: discord.Member): self._logger.debug(__name__, f"Notify team that a member left") - settings: ServerConfig = self._config.get_configuration( - f"ServerConfig_{member.guild.id}" - ) + settings: ServerConfig = self._config.get_configuration(f"ServerConfig_{member.guild.id}") channel = member.guild.get_channel(settings.team_channel_id) await self._message_service.send_channel_message( channel, - self._t.transform("modules.base.member_left_message").format( - member.mention - ), + self._t.transform("modules.base.member_left_message").format(member.mention), is_persistent=True, ) self._logger.trace(__name__, f"Notified team that a member left") diff --git a/bot/src/modules/base/events/base_on_message_delete_event.py b/bot/src/modules/base/events/base_on_message_delete_event.py index c3bcd022..3d3aad1c 100644 --- a/bot/src/modules/base/events/base_on_message_delete_event.py +++ b/bot/src/modules/base/events/base_on_message_delete_event.py @@ -40,9 +40,7 @@ class BaseOnMessageDeleteEvent(OnMessageDeleteABC): self._clients.append_deleted_message_count(self._bot.user.id, g_id, 1) self._db.save_changes() except Exception as e: - self._logger.error( - __name__, f"Cannot edit client {self._bot.user.id}@{g_id}", e - ) + self._logger.error(__name__, f"Cannot edit client {self._bot.user.id}@{g_id}", e) def _handle_message_delete(self, message: discord.Message): dc_user_id = message.author.id @@ -54,9 +52,7 @@ class BaseOnMessageDeleteEvent(OnMessageDeleteABC): user: Optional[User] = None try: - user = self._users.find_user_by_discord_id_and_server_id( - dc_user_id, server.id - ) + user = self._users.find_user_by_discord_id_and_server_id(dc_user_id, server.id) except Exception as e: self._logger.error(__name__, f"Cannot get user {dc_user_id}", e) return @@ -65,9 +61,7 @@ class BaseOnMessageDeleteEvent(OnMessageDeleteABC): self._logger.error(__name__, f"User not found {dc_user_id}") return - settings: ServerConfig = self._config.get_configuration( - f"ServerConfig_{message.guild.id}" - ) + settings: ServerConfig = self._config.get_configuration(f"ServerConfig_{message.guild.id}") old_xp = user.xp user.xp -= settings.xp_per_message self._users.update_user(user) @@ -83,9 +77,7 @@ class BaseOnMessageDeleteEvent(OnMessageDeleteABC): if message is None or message.guild is None: return - self._logger.info( - __name__, f"Received message: {LogMessageHelper.get_log_string(message)}" - ) + self._logger.info(__name__, f"Received message: {LogMessageHelper.get_log_string(message)}") self._append_deleted_message_count(message.guild.id) if not message.author.bot: diff --git a/bot/src/modules/base/events/base_on_message_event.py b/bot/src/modules/base/events/base_on_message_event.py index 438b10b8..e6531385 100644 --- a/bot/src/modules/base/events/base_on_message_event.py +++ b/bot/src/modules/base/events/base_on_message_event.py @@ -45,9 +45,7 @@ class BaseOnMessageEvent(OnMessageABC): self._clients.append_received_message_count(self._bot.user.id, g_id, 1) self._db.save_changes() except Exception as e: - self._logger.error( - __name__, f"Cannot edit client {self._bot.user.id}@{g_id}", e - ) + self._logger.error(__name__, f"Cannot edit client {self._bot.user.id}@{g_id}", e) def _handle_message_for_xp(self, message: discord.Message): dc_user_id = message.author.id @@ -59,9 +57,7 @@ class BaseOnMessageEvent(OnMessageABC): user: Optional[User] = None try: - user = self._users.find_user_by_discord_id_and_server_id( - dc_user_id, server.id - ) + user = self._users.find_user_by_discord_id_and_server_id(dc_user_id, server.id) except Exception as e: self._logger.error(__name__, f"Cannot get user {dc_user_id}", e) return @@ -70,9 +66,7 @@ class BaseOnMessageEvent(OnMessageABC): self._logger.error(__name__, f"User not found {dc_user_id}") return - settings: ServerConfig = self._config.get_configuration( - f"ServerConfig_{server.discord_id}" - ) + settings: ServerConfig = self._config.get_configuration(f"ServerConfig_{server.discord_id}") if self._client_utils.is_message_xp_count_by_hour_higher_that_max_message_count_per_hour( message.created_at, user, settings ): @@ -83,9 +77,7 @@ class BaseOnMessageEvent(OnMessageABC): self._users.update_user(user) self._db.save_changes() - self._logger.debug( - __name__, f"User {user} sent message. xp: from {old_xp} to {user.xp}" - ) + self._logger.debug(__name__, f"User {user} sent message. xp: from {old_xp} to {user.xp}") @EventChecks.check_is_ready() async def on_message(self, message: discord.Message): @@ -93,9 +85,7 @@ class BaseOnMessageEvent(OnMessageABC): if message is None or message.guild is None: return - self._logger.info( - __name__, f"Received message: {LogMessageHelper.get_log_string(message)}" - ) + self._logger.info(__name__, f"Received message: {LogMessageHelper.get_log_string(message)}") self._append_received_message_count(message.guild.id) if not message.author.bot: diff --git a/bot/src/modules/base/events/base_on_scheduled_event_update_event.py b/bot/src/modules/base/events/base_on_scheduled_event_update_event.py index f3dfda00..640a9a80 100644 --- a/bot/src/modules/base/events/base_on_scheduled_event_update_event.py +++ b/bot/src/modules/base/events/base_on_scheduled_event_update_event.py @@ -21,9 +21,7 @@ class BaseOnScheduledEventUpdateEvent(OnScheduledEventUpdateABC): self._bot = bot self._events = events - async def on_scheduled_event_update( - self, before: discord.ScheduledEvent, after: discord.ScheduledEvent - ): + async def on_scheduled_event_update(self, before: discord.ScheduledEvent, after: discord.ScheduledEvent): self._logger.debug(__name__, f"Module {type(self)} started") # save started event @@ -35,8 +33,7 @@ class BaseOnScheduledEventUpdateEvent(OnScheduledEventUpdateABC): self._events.give_xp_for_event_participation(member, active_event) # delete stopped event if before.status != after.status and ( - after.status.value == EventStatus.cancelled.value - or after.status.value == EventStatus.completed.value + after.status.value == EventStatus.cancelled.value or after.status.value == EventStatus.completed.value ): event = self._events.get_active_event(after) if event is None: diff --git a/bot/src/modules/base/events/base_on_voice_state_update_event.py b/bot/src/modules/base/events/base_on_voice_state_update_event.py index 5a5e25ab..6fb0c113 100644 --- a/bot/src/modules/base/events/base_on_voice_state_update_event.py +++ b/bot/src/modules/base/events/base_on_voice_state_update_event.py @@ -45,14 +45,10 @@ class BaseOnVoiceStateUpdateEvent(OnVoiceStateUpdateABC): self._logger.info(__name__, f"Module {type(self)} loaded") - def _update_voice_state( - self, joined: bool, dc_user_id: int, channel_id: int, server: Server - ): + def _update_voice_state(self, joined: bool, dc_user_id: int, channel_id: int, server: Server): user: Optional[User] = None try: - user = self._users.get_user_by_discord_id_and_server_id( - dc_user_id, server.id - ) + user = self._users.get_user_by_discord_id_and_server_id(dc_user_id, server.id) except Exception as e: self._logger.error(__name__, f"Cannot get user {dc_user_id}", e) return @@ -68,13 +64,9 @@ class BaseOnVoiceStateUpdateEvent(OnVoiceStateUpdateABC): self._db.save_changes() return - settings: ServerConfig = self._config.get_configuration( - f"ServerConfig_{server.discord_id}" - ) + settings: ServerConfig = self._config.get_configuration(f"ServerConfig_{server.discord_id}") - join = self._user_joins_vc.get_active_user_joined_voice_channel_by_user_id( - user.id - ) + join = self._user_joins_vc.get_active_user_joined_voice_channel_by_user_id(user.id) join.leaved_on = datetime.now() old_xp = user.xp @@ -103,9 +95,7 @@ class BaseOnVoiceStateUpdateEvent(OnVoiceStateUpdateABC): __name__, f"Detected on_voice_state_update {member.id} from {before} to {after}", ) - settings: ServerConfig = self._config.get_configuration( - f"ServerConfig_{member.guild.id}" - ) + settings: ServerConfig = self._config.get_configuration(f"ServerConfig_{member.guild.id}") server = self._servers.get_server_by_discord_id(member.guild.id) try: @@ -133,36 +123,18 @@ class BaseOnVoiceStateUpdateEvent(OnVoiceStateUpdateABC): # channel to channel elif before.channel is not None and after.channel is not None: # joined - if ( - before.channel.id in settings.afk_channel_ids - and after.channel.id not in settings.afk_channel_ids - ): - self._logger.trace( - __name__, f"User {member.id} joined {after.channel}" - ) + if before.channel.id in settings.afk_channel_ids and after.channel.id not in settings.afk_channel_ids: + self._logger.trace(__name__, f"User {member.id} joined {after.channel}") self._update_voice_state(True, member.id, after.channel.id, server) # left - elif ( - after.channel.id in settings.afk_channel_ids - and before.channel.id not in settings.afk_channel_ids - ): - self._logger.trace( - __name__, f"User {member.id} left {before.channel}" - ) - self._update_voice_state( - False, member.id, before.channel.id, server - ) + elif after.channel.id in settings.afk_channel_ids and before.channel.id not in settings.afk_channel_ids: + self._logger.trace(__name__, f"User {member.id} left {before.channel}") + self._update_voice_state(False, member.id, before.channel.id, server) else: - self._logger.trace( - __name__, f"User {member.id} switched to {after.channel}" - ) - self._update_voice_state( - False, member.id, before.channel.id, server - ) + self._logger.trace(__name__, f"User {member.id} switched to {after.channel}") + self._update_voice_state(False, member.id, before.channel.id, server) self._update_voice_state(True, member.id, after.channel.id, server) except Exception as e: - self._logger.error( - __name__, f"Cannot handle voice state for user {member.id}", e - ) + self._logger.error(__name__, f"Cannot handle voice state for user {member.id}", e) diff --git a/bot/src/modules/base/events/base_on_voice_state_update_event_help_channel.py b/bot/src/modules/base/events/base_on_voice_state_update_event_help_channel.py index d1d24e07..3e1b3da0 100644 --- a/bot/src/modules/base/events/base_on_voice_state_update_event_help_channel.py +++ b/bot/src/modules/base/events/base_on_voice_state_update_event_help_channel.py @@ -33,15 +33,11 @@ class BaseOnVoiceStateUpdateEventHelpChannel(OnVoiceStateUpdateABC): async def _notify_team(self, member: discord.Member): self._logger.debug(__name__, f"Notify team that a member needs help") - settings: ServerConfig = self._config.get_configuration( - f"ServerConfig_{member.guild.id}" - ) + settings: ServerConfig = self._config.get_configuration(f"ServerConfig_{member.guild.id}") channel = member.guild.get_channel(settings.team_channel_id) await self._message_service.send_channel_message( channel, - self._t.transform("modules.base.member_joined_help_voice_channel").format( - member.mention - ), + self._t.transform("modules.base.member_joined_help_voice_channel").format(member.mention), is_persistent=True, ) self._logger.trace(__name__, f"Notified team that a member need help") @@ -55,9 +51,7 @@ class BaseOnVoiceStateUpdateEventHelpChannel(OnVoiceStateUpdateABC): ): self._logger.debug(__name__, f"Module {type(self)} started") server = self._servers.get_server_by_discord_id(member.guild.id) - settings: ServerConfig = self._config.get_configuration( - f"ServerConfig_{server.discord_id}" - ) + settings: ServerConfig = self._config.get_configuration(f"ServerConfig_{server.discord_id}") if after.channel is None or after.channel.id != settings.help_voice_channel_id: return diff --git a/bot/src/modules/base/forms/bug_report_form.py b/bot/src/modules/base/forms/bug_report_form.py index 88fc6cab..185fd51f 100644 --- a/bot/src/modules/base/forms/bug_report_form.py +++ b/bot/src/modules/base/forms/bug_report_form.py @@ -10,9 +10,7 @@ from bot_data.model.technician_config import TechnicianConfig class BugReportForm(ui.Modal): - description = ui.TextInput( - label="Report a bug", required=True, style=TextStyle.long - ) + description = ui.TextInput(label="Report a bug", required=True, style=TextStyle.long) def __init__( self, @@ -40,14 +38,10 @@ class BugReportForm(ui.Modal): for t in self._technician_config.technician_ids: member = self._bot.get_user(t) await self._message_service.send_dm_message( - self._t.transform("modules.base.bug.message").format( - interaction.user.mention, self.description.value - ), + self._t.transform("modules.base.bug.message").format(interaction.user.mention, self.description.value), member, without_tracking=True, ) - await self._message_service.send_interaction_msg( - interaction, self._t.transform("modules.base.bug.response") - ) + await self._message_service.send_interaction_msg(interaction, self._t.transform("modules.base.bug.response")) self._logger.trace(__name__, f"Finished bug report form") diff --git a/bot/src/modules/base/forms/complaint_form.py b/bot/src/modules/base/forms/complaint_form.py index cb39e23c..b0d77813 100644 --- a/bot/src/modules/base/forms/complaint_form.py +++ b/bot/src/modules/base/forms/complaint_form.py @@ -10,9 +10,7 @@ from bot_data.model.server_config import ServerConfig class ComplaintForm(ui.Modal): - description = ui.TextInput( - label="Complain about something", required=True, style=TextStyle.long - ) + description = ui.TextInput(label="Complain about something", required=True, style=TextStyle.long) def __init__( self, @@ -34,9 +32,7 @@ class ComplaintForm(ui.Modal): async def on_submit(self, interaction: discord.Interaction): self._logger.debug(__name__, f"Started complaint command form") - settings: ServerConfig = self._config.get_configuration( - f"ServerConfig_{interaction.guild.id}" - ) + settings: ServerConfig = self._config.get_configuration(f"ServerConfig_{interaction.guild.id}") channel = interaction.guild.get_channel(settings.team_channel_id) await self._message_service.send_channel_message( channel, diff --git a/bot/src/modules/base/helper/base_reaction_handler.py b/bot/src/modules/base/helper/base_reaction_handler.py index e63f4412..d2cb1581 100644 --- a/bot/src/modules/base/helper/base_reaction_handler.py +++ b/bot/src/modules/base/helper/base_reaction_handler.py @@ -38,9 +38,7 @@ class BaseReactionHandler: guild = self._bot.get_guild(payload.guild_id) member = guild.get_member(payload.user_id) if member is None: - self._logger.warn( - __name__, f"User {payload.user_id} in {guild.name} not found - skipping" - ) + self._logger.warn(__name__, f"User {payload.user_id} in {guild.name} not found - skipping") return try: @@ -62,12 +60,8 @@ class BaseReactionHandler: self._logger.debug(__name__, f"Skipping reaction handling") return except Exception as e: - self._logger.error( - __name__, f"Getting message for reaction logging failed", e - ) - self._logger.info( - __name__, f"{log_msg} to message {payload.message_id}" - ) + self._logger.error(__name__, f"Getting message for reaction logging failed", e) + self._logger.info(__name__, f"{log_msg} to message {payload.message_id}") except Exception as e: self._logger.error(__name__, f"Reaction logging failed", e) @@ -76,9 +70,7 @@ class BaseReactionHandler: server = self._servers.get_server_by_discord_id(guild.id) user = self._users.get_user_by_discord_id_and_server_id(member.id, server.id) - settings: ServerConfig = self._config.get_configuration( - f"ServerConfig_{guild.id}" - ) + settings: ServerConfig = self._config.get_configuration(f"ServerConfig_{guild.id}") if r_type == "add": if self._client_utils.is_message_xp_count_by_hour_higher_that_max_message_count_per_hour( diff --git a/bot/src/modules/base/helper/voice_channel_transformer.py b/bot/src/modules/base/helper/voice_channel_transformer.py index f7fa205f..a6056e58 100644 --- a/bot/src/modules/base/helper/voice_channel_transformer.py +++ b/bot/src/modules/base/helper/voice_channel_transformer.py @@ -8,9 +8,7 @@ from bot_core.abc.client_utils_abc import ClientUtilsABC class VoiceChannelTransformer(Transformer): - async def transform( - self, interaction: Interaction, value: str, / - ) -> discord.VoiceChannel: + async def transform(self, interaction: Interaction, value: str, /) -> discord.VoiceChannel: voice_channel = ( List(discord.VoiceChannel, interaction.guild.voice_channels) .where(lambda x: str(x.id) == value) @@ -18,24 +16,16 @@ class VoiceChannelTransformer(Transformer): ) return voice_channel - async def autocomplete( - self, interaction: Interaction, current: str, / - ) -> list[Choice[str]]: + async def autocomplete(self, interaction: Interaction, current: str, /) -> list[Choice[str]]: @ServiceProviderABC.inject def get_client_utils(client_utils: ClientUtilsABC) -> ClientUtilsABC: return client_utils - voice_channels = List(discord.Role, interaction.guild.voice_channels).where( - lambda x: len(x.members) > 0 - ) + voice_channels = List(discord.Role, interaction.guild.voice_channels).where(lambda x: len(x.members) > 0) return [ app_commands.Choice( - name=f"{vc.name}" - if vc.category is None - else f"{vc.name}: {vc.category.name}", + name=f"{vc.name}" if vc.category is None else f"{vc.name}: {vc.category.name}", value=vc.name, ) - for vc in get_client_utils().get_auto_complete_list( - voice_channels, current, lambda x: x.name - ) + for vc in get_client_utils().get_auto_complete_list(voice_channels, current, lambda x: x.name) ] diff --git a/bot/src/modules/base/service/event_service.py b/bot/src/modules/base/service/event_service.py index 51cf211c..30b19d96 100644 --- a/bot/src/modules/base/service/event_service.py +++ b/bot/src/modules/base/service/event_service.py @@ -36,9 +36,7 @@ class EventService: self._active_events.add(event) def get_active_event(self, event: discord.ScheduledEvent) -> Optional[ActiveEvent]: - return self._active_events.where( - lambda x: x.event.id == event.id - ).single_or_default() + return self._active_events.where(lambda x: x.event.id == event.id).single_or_default() def get_active_event_by_channel_id(self, channel_id: int) -> Optional[ActiveEvent]: return self._active_events.where( @@ -51,18 +49,14 @@ class EventService: self._active_events.remove(event) - def give_xp_for_event_participation( - self, member: discord.Member, active_event: ActiveEvent - ): + def give_xp_for_event_participation(self, member: discord.Member, active_event: ActiveEvent): server = self._servers.get_server_by_discord_id(member.guild.id) user = self._users.get_user_by_discord_id_and_server_id(member.id, server.id) if active_event.participants.any(lambda x: x.id == user.id): self._logger.debug(__name__, f"Module {type(self)} stopped") return - settings: ServerConfig = self._config.get_configuration( - f"ServerConfig_{server.discord_id}" - ) + settings: ServerConfig = self._config.get_configuration(f"ServerConfig_{server.discord_id}") user.xp += settings.xp_per_event_participation self._users.update_user(user) self._db.save_changes() diff --git a/bot/src/modules/base/service/user_warnings_service.py b/bot/src/modules/base/service/user_warnings_service.py index 54c394c7..eea9129a 100644 --- a/bot/src/modules/base/service/user_warnings_service.py +++ b/bot/src/modules/base/service/user_warnings_service.py @@ -46,92 +46,60 @@ class UserWarningsService: self._t = t self._permissions = permissions - async def notify_team( - self, member: discord.Member, description: str, removed=False - ): + async def notify_team(self, member: discord.Member, description: str, removed=False): try: - settings: ServerConfig = self._config.get_configuration( - f"ServerConfig_{member.guild.id}" - ) + settings: ServerConfig = self._config.get_configuration(f"ServerConfig_{member.guild.id}") channel = member.guild.get_channel(settings.team_channel_id) if removed: - translation = self._t.transform( - "modules.base.warnings.team_removed" - ).format(description, member.mention) + translation = self._t.transform("modules.base.warnings.team_removed").format( + description, member.mention + ) else: - translation = self._t.transform( - "modules.base.warnings.team_warned" - ).format(member.mention, description) + translation = self._t.transform("modules.base.warnings.team_warned").format(member.mention, description) self._bot.loop.create_task( - self._message_service.send_channel_message( - channel, translation, is_persistent=True - ) + self._message_service.send_channel_message(channel, translation, is_persistent=True) ) except Exception as e: - self._logger.error( - __name__, f"Team notification for user warning failed!", e - ) + self._logger.error(__name__, f"Team notification for user warning failed!", e) async def notify_user(self, member: discord.Member, message: str): try: # run as task to keep the interaction alive - self._bot.loop.create_task( - self._message_service.send_dm_message(message, member) - ) + self._bot.loop.create_task(self._message_service.send_dm_message(message, member)) except Exception as e: - self._logger.error( - __name__, f"User notification for user warning failed!", e - ) + self._logger.error(__name__, f"User notification for user warning failed!", e) async def check_for_warnings(self, member: discord.Member, user: User): existing_warnings = self._warnings.get_user_warnings_by_user_id(user.id) if existing_warnings.count() == 1: - await self.notify_user( - member, self._t.transform("modules.base.warnings.first") - ) + await self.notify_user(member, self._t.transform("modules.base.warnings.first")) elif existing_warnings.count() == 2: server = self._servers.get_server_by_discord_id(member.guild.id) - user = self._users.get_user_by_discord_id_and_server_id( - member.id, server.id - ) + user = self._users.get_user_by_discord_id_and_server_id(member.id, server.id) level = self._level_service.get_level(user) - levels = self._levels.get_levels_by_server_id(server.id).order_by( - lambda l: l.min_xp - ) + levels = self._levels.get_levels_by_server_id(server.id).order_by(lambda l: l.min_xp) - new_level = levels.where( - lambda l: l.min_xp < level.min_xp - ).last_or_default() + new_level = levels.where(lambda l: l.min_xp < level.min_xp).last_or_default() if new_level is not None: user.xp = new_level.min_xp self._users.update_user(user) self._db.save_changes() - await self.notify_user( - member, self._t.transform("modules.base.warnings.second") - ) + await self.notify_user(member, self._t.transform("modules.base.warnings.second")) elif existing_warnings.count() == 3: server = self._servers.get_server_by_discord_id(member.guild.id) - user = self._users.get_user_by_discord_id_and_server_id( - member.id, server.id - ) + user = self._users.get_user_by_discord_id_and_server_id(member.id, server.id) levels = self._levels.get_levels_by_server_id(server.id) - new_level = ( - levels.where(lambda l: l.min_xp > 0) - .order_by(lambda l: l.min_xp) - .last_or_default() - ) + new_level = levels.where(lambda l: l.min_xp > 0).order_by(lambda l: l.min_xp).last_or_default() if new_level is not None: user.xp = new_level.min_xp self._users.update_user(user) self._db.save_changes() - await self.notify_user( - member, self._t.transform("modules.base.warnings.third") - ) + await self.notify_user(member, self._t.transform("modules.base.warnings.third")) elif existing_warnings.count() >= 4: user.xp = 0 @@ -149,39 +117,29 @@ class UserWarningsService: await self.notify_user( member, - self._t.transform("modules.base.warnings.warned").format( - warning.description - ), + self._t.transform("modules.base.warnings.warned").format(warning.description), ) await self.notify_team(member, warning.description) await self.check_for_warnings(member, user) - def _add_warnings( - self, member: discord.Member, description: str, author_id: int = None - ): + def _add_warnings(self, member: discord.Member, description: str, author_id: int = None): server = self._servers.get_server_by_discord_id(member.guild.id) user = self._users.get_user_by_discord_id_and_server_id(member.id, server.id) author = None if author_id is not None: - author = self._users.get_user_by_discord_id_and_server_id( - author_id, server.id - ) + author = self._users.get_user_by_discord_id_and_server_id(author_id, server.id) warning = UserWarnings(description, user, author) self._warnings.add_user_warnings(warning) self._db.save_changes() return warning - def add_warnings( - self, member: discord.Member, description: str, author_id: int = None - ): + def add_warnings(self, member: discord.Member, description: str, author_id: int = None): warning = self._add_warnings(member, description, author_id) self._bot.loop.create_task(self._notify_after_add(member, warning)) - async def add_warnings_async( - self, member: discord.Member, description: str, author_id: int = None - ): + async def add_warnings_async(self, member: discord.Member, description: str, author_id: int = None): warning = self._add_warnings(member, description, author_id) await self._notify_after_add(member, warning) @@ -190,9 +148,7 @@ class UserWarningsService: member = guild.get_member(warning.user.discord_id) await self.notify_user( member, - self._t.transform("modules.base.warnings.removed").format( - warning.description - ), + self._t.transform("modules.base.warnings.removed").format(warning.description), ) await self.notify_team(member, warning.description, removed=True) diff --git a/bot/src/modules/boot_log/boot_log_extension.py b/bot/src/modules/boot_log/boot_log_extension.py index e0f59082..62b7c6c7 100644 --- a/bot/src/modules/boot_log/boot_log_extension.py +++ b/bot/src/modules/boot_log/boot_log_extension.py @@ -14,9 +14,7 @@ class BootLogExtension(ApplicationExtensionABC): pass async def run(self, config: ConfigurationABC, services: ServiceProviderABC): - feature_flags: FeatureFlagsSettings = config.get_configuration( - FeatureFlagsSettings - ) + feature_flags: FeatureFlagsSettings = config.get_configuration(FeatureFlagsSettings) if not feature_flags.get_flag(FeatureFlagsEnum.boot_log_module): return logger: LoggerABC = services.get_service(LoggerABC) diff --git a/bot/src/modules/boot_log/boot_log_module.py b/bot/src/modules/boot_log/boot_log_module.py index 0701876f..dde842f0 100644 --- a/bot/src/modules/boot_log/boot_log_module.py +++ b/bot/src/modules/boot_log/boot_log_module.py @@ -13,16 +13,10 @@ class BootLogModule(ModuleABC): def __init__(self, dc: DiscordCollectionABC): ModuleABC.__init__(self, dc, FeatureFlagsEnum.boot_log_module) - def configure_configuration( - self, config: ConfigurationABC, env: ApplicationEnvironmentABC - ): + def configure_configuration(self, config: ConfigurationABC, env: ApplicationEnvironmentABC): pass - def configure_services( - self, services: ServiceCollectionABC, env: ApplicationEnvironmentABC - ): + def configure_services(self, services: ServiceCollectionABC, env: ApplicationEnvironmentABC): # commands # events - services.add_transient( - DiscordEventTypesEnum.on_ready.value, BootLogOnReadyEvent - ) + services.add_transient(DiscordEventTypesEnum.on_ready.value, BootLogOnReadyEvent) diff --git a/bot/src/modules/boot_log/boot_log_on_ready_event.py b/bot/src/modules/boot_log/boot_log_on_ready_event.py index f0962bae..4c8aeec7 100644 --- a/bot/src/modules/boot_log/boot_log_on_ready_event.py +++ b/bot/src/modules/boot_log/boot_log_on_ready_event.py @@ -45,10 +45,7 @@ class BootLogOnReadyEvent(OnReadyABC): try: start_time = self._config.get_configuration("Bot_StartTime") init_time = round( - ( - datetime.now() - - datetime.strptime(start_time, "%Y-%m-%d %H:%M:%S.%f") - ).total_seconds(), + (datetime.now() - datetime.strptime(start_time, "%Y-%m-%d %H:%M:%S.%f")).total_seconds(), 2, ) self._config.add_configuration("InitTime", str(init_time)) @@ -59,9 +56,7 @@ class BootLogOnReadyEvent(OnReadyABC): # print error if initialisation took way too long elif init_time >= 90: - self._logger.error( - __name__, "It takes far too long to start the bot!!!" - ) + self._logger.error(__name__, "It takes far too long to start the bot!!!") except Exception as e: self._logger.error(__name__, "Init time calculation failed", e) return @@ -70,9 +65,7 @@ class BootLogOnReadyEvent(OnReadyABC): g: guild = g self._logger.debug(__name__, f"Server detected: {g.id}") - server_config: ServerConfig = self._config.get_configuration( - f"ServerConfig_{g.id}" - ) + server_config: ServerConfig = self._config.get_configuration(f"ServerConfig_{g.id}") if server_config is None: self._logger.error(__name__, f"Config ServerConfig_{g.id} not found!") return @@ -85,9 +78,7 @@ class BootLogOnReadyEvent(OnReadyABC): self._bot.loop.create_task( self._message_service.send_channel_message( self._bot.get_channel(server_config.login_message_channel_id), - self._t.transform("modules.boot_log.login_message").format( - init_time - ), + self._t.transform("modules.boot_log.login_message").format(init_time), ) ) diff --git a/bot/src/modules/config/config_extension.py b/bot/src/modules/config/config_extension.py index f11ba6ad..ce164180 100644 --- a/bot/src/modules/config/config_extension.py +++ b/bot/src/modules/config/config_extension.py @@ -13,9 +13,7 @@ class ConfigExtension(ApplicationExtensionABC): pass async def run(self, config: ConfigurationABC, services: ServiceProviderABC): - feature_flags: FeatureFlagsSettings = config.get_configuration( - FeatureFlagsSettings - ) + feature_flags: FeatureFlagsSettings = config.get_configuration(FeatureFlagsSettings) if not feature_flags.get_flag(FeatureFlagsEnum.config_module): return logger: LoggerABC = services.get_service(LoggerABC) diff --git a/bot/src/modules/config/config_module.py b/bot/src/modules/config/config_module.py index a8180637..14c16263 100644 --- a/bot/src/modules/config/config_module.py +++ b/bot/src/modules/config/config_module.py @@ -13,12 +13,8 @@ class ConfigModule(ModuleABC): def __init__(self, dc: DiscordCollectionABC): ModuleABC.__init__(self, dc, FeatureFlagsEnum.config_module) - def configure_configuration( - self, config: ConfigurationABC, env: ApplicationEnvironmentABC - ): + def configure_configuration(self, config: ConfigurationABC, env: ApplicationEnvironmentABC): pass - def configure_services( - self, services: ServiceCollectionABC, env: ApplicationEnvironmentABC - ): + def configure_services(self, services: ServiceCollectionABC, env: ApplicationEnvironmentABC): services.add_transient(DiscordEventTypesEnum.on_ready.value, ConfigOnReadyEvent) diff --git a/bot/src/modules/config/events/config_on_ready_event.py b/bot/src/modules/config/events/config_on_ready_event.py index ddec8ccf..14ad229a 100644 --- a/bot/src/modules/config/events/config_on_ready_event.py +++ b/bot/src/modules/config/events/config_on_ready_event.py @@ -26,6 +26,4 @@ class ConfigOnReadyEvent(OnReadyABC): async def on_ready(self): for guild in self._bot.guilds: - await self._config_service.reload_server_config( - self._servers.get_server_by_discord_id(guild.id) - ) + await self._config_service.reload_server_config(self._servers.get_server_by_discord_id(guild.id)) diff --git a/bot/src/modules/database/database_extension.py b/bot/src/modules/database/database_extension.py index de874826..1c26e70b 100644 --- a/bot/src/modules/database/database_extension.py +++ b/bot/src/modules/database/database_extension.py @@ -17,9 +17,7 @@ class DatabaseExtension(ApplicationExtensionABC): pass async def run(self, config: ConfigurationABC, services: ServiceProviderABC): - feature_flags: FeatureFlagsSettings = config.get_configuration( - FeatureFlagsSettings - ) + feature_flags: FeatureFlagsSettings = config.get_configuration(FeatureFlagsSettings) if not feature_flags.get_flag(FeatureFlagsEnum.data_module): return logger: LoggerABC = services.get_service(DatabaseLogger) diff --git a/bot/src/modules/database/database_module.py b/bot/src/modules/database/database_module.py index 65b98988..bd7c6c6f 100644 --- a/bot/src/modules/database/database_module.py +++ b/bot/src/modules/database/database_module.py @@ -13,16 +13,10 @@ class DatabaseModule(ModuleABC): def __init__(self, dc: DiscordCollectionABC): ModuleABC.__init__(self, dc, FeatureFlagsEnum.database_module) - def configure_configuration( - self, config: ConfigurationABC, env: ApplicationEnvironmentABC - ): + def configure_configuration(self, config: ConfigurationABC, env: ApplicationEnvironmentABC): pass - def configure_services( - self, services: ServiceCollectionABC, env: ApplicationEnvironmentABC - ): + def configure_services(self, services: ServiceCollectionABC, env: ApplicationEnvironmentABC): # commands # events - services.add_transient( - DiscordEventTypesEnum.on_ready.value, DatabaseOnReadyEvent - ) + services.add_transient(DiscordEventTypesEnum.on_ready.value, DatabaseOnReadyEvent) diff --git a/bot/src/modules/database/database_on_ready_event.py b/bot/src/modules/database/database_on_ready_event.py index 9b76de38..5c3bd775 100644 --- a/bot/src/modules/database/database_on_ready_event.py +++ b/bot/src/modules/database/database_on_ready_event.py @@ -29,25 +29,18 @@ class DatabaseOnReadyEvent(OnReadyABC): try: start_time = self._config.get_configuration("Database_StartTime") init_time = round( - ( - datetime.now() - - datetime.strptime(start_time, "%Y-%m-%d %H:%M:%S.%f") - ).total_seconds(), + (datetime.now() - datetime.strptime(start_time, "%Y-%m-%d %H:%M:%S.%f")).total_seconds(), 2, ) self._config.add_configuration("Database_InitTime", str(init_time)) self._logger.debug(__name__, f"Database Init time: {init_time}s") # print warning if initialisation took too long if init_time >= 30: - self._logger.warn( - __name__, "It takes too long to prepare the database!" - ) + self._logger.warn(__name__, "It takes too long to prepare the database!") # print error if initialisation took way too long elif init_time >= 90: - self._logger.error( - __name__, "It takes far too long to prepare the database!!!" - ) + self._logger.error(__name__, "It takes far too long to prepare the database!!!") except Exception as e: # self._logger.error(__name__, "Database init time calculation failed", e) return diff --git a/bot/src/modules/level/command/level_group.py b/bot/src/modules/level/command/level_group.py index e5dca679..50e03692 100644 --- a/bot/src/modules/level/command/level_group.py +++ b/bot/src/modules/level/command/level_group.py @@ -108,17 +108,13 @@ class LevelGroup(DiscordCommandABC): except Exception as e: self._logger.error(__name__, f"Level seeding failed", e) - await self._message_service.send_ctx_msg( - ctx, self._t.transform("modules.level.seeding_failed") - ) + await self._message_service.send_ctx_msg(ctx, self._t.transform("modules.level.seeding_failed")) async def _level_auto_complete( self, interaction: discord.Interaction, current: str ) -> TList[app_commands.Choice[str]]: server = self._servers.get_server_by_discord_id(interaction.guild.id) - levels = self._levels.get_levels_by_server_id(server.id).select( - lambda l: l.name - ) + levels = self._levels.get_levels_by_server_id(server.id).select(lambda l: l.name) return [ app_commands.Choice(name=level, value=level) for level in self._client_utils.get_auto_complete_list(levels, current) @@ -138,20 +134,14 @@ class LevelGroup(DiscordCommandABC): if ctx.guild is None: return - server_config: ServerConfig = self._config.get_configuration( - f"ServerConfig_{ctx.guild.id}" - ) - if not FeatureFlagsSettings.get_flag_from_dict( - server_config.feature_flags, FeatureFlagsEnum.level_module - ): + server_config: ServerConfig = self._config.get_configuration(f"ServerConfig_{ctx.guild.id}") + if not FeatureFlagsSettings.get_flag_from_dict(server_config.feature_flags, FeatureFlagsEnum.level_module): return server = self._servers.get_server_by_discord_id(ctx.guild.id) levels = self._levels.get_levels_by_server_id(server.id) if levels.count() < 1: - await self._message_service.send_ctx_msg( - ctx, self._t.transform("modules.level.error.nothing_found") - ) + await self._message_service.send_ctx_msg(ctx, self._t.transform("modules.level.error.nothing_found")) self._logger.trace(__name__, f"Finished command level list") return @@ -173,9 +163,7 @@ class LevelGroup(DiscordCommandABC): value=level_name, inline=True, ) - embed.add_field( - name=self._t.transform("modules.level.list.min_xp"), value=xp, inline=True - ) + embed.add_field(name=self._t.transform("modules.level.list.min_xp"), value=xp, inline=True) embed.add_field( name=self._t.transform("modules.level.list.permission_int"), value=permissions, @@ -188,19 +176,13 @@ class LevelGroup(DiscordCommandABC): @commands.guild_only() @CommandChecks.check_is_ready() @CommandChecks.check_is_member_admin() - async def create( - self, ctx: Context, name: str, color: str, min_xp: int, permissions: int - ): + async def create(self, ctx: Context, name: str, color: str, min_xp: int, permissions: int): self._logger.debug(__name__, f"Received command level create {ctx}") if ctx.guild is None: return - server_config: ServerConfig = self._config.get_configuration( - f"ServerConfig_{ctx.guild.id}" - ) - if not FeatureFlagsSettings.get_flag_from_dict( - server_config.feature_flags, FeatureFlagsEnum.level_module - ): + server_config: ServerConfig = self._config.get_configuration(f"ServerConfig_{ctx.guild.id}") + if not FeatureFlagsSettings.get_flag_from_dict(server_config.feature_flags, FeatureFlagsEnum.level_module): return try: @@ -226,26 +208,19 @@ class LevelGroup(DiscordCommandABC): self._logger.debug(__name__, f"Level with name {level.name} already exists") await self._message_service.send_ctx_msg( ctx, - self._t.transform( - "modules.level.error.level_with_name_already_exists" - ).format(level.name), + self._t.transform("modules.level.error.level_with_name_already_exists").format(level.name), ) - elif ( - levels.where(lambda l: l.min_xp == level.min_xp).first_or_default() - is not None - ): + elif levels.where(lambda l: l.min_xp == level.min_xp).first_or_default() is not None: self._logger.debug( __name__, f"Level with min_xp {level.min_xp} already exists {level.name}", ) - found_level = levels.where( - lambda l: l.min_xp == level.min_xp - ).first_or_default() + found_level = levels.where(lambda l: l.min_xp == level.min_xp).first_or_default() await self._message_service.send_ctx_msg( ctx, - self._t.transform( - "modules.level.error.level_with_xp_already_exists" - ).format(found_level.name, found_level.min_xp), + self._t.transform("modules.level.error.level_with_xp_already_exists").format( + found_level.name, found_level.min_xp + ), ) else: try: @@ -264,9 +239,7 @@ class LevelGroup(DiscordCommandABC): else: await self._message_service.send_ctx_msg( ctx, - self._t.transform("modules.level.create.created").format( - name, permissions - ), + self._t.transform("modules.level.create.created").format(name, permissions), ) await self._seed_levels(ctx) @@ -303,19 +276,13 @@ class LevelGroup(DiscordCommandABC): if ctx.guild is None: return - server_config: ServerConfig = self._config.get_configuration( - f"ServerConfig_{ctx.guild.id}" - ) - if not FeatureFlagsSettings.get_flag_from_dict( - server_config.feature_flags, FeatureFlagsEnum.level_module - ): + server_config: ServerConfig = self._config.get_configuration(f"ServerConfig_{ctx.guild.id}") + if not FeatureFlagsSettings.get_flag_from_dict(server_config.feature_flags, FeatureFlagsEnum.level_module): return server = self._servers.get_server_by_discord_id(ctx.guild.id) level_from_db = ( - self._levels.get_levels_by_server_id(server.id) - .where(lambda l: l.name == level) - .single_or_default() + self._levels.get_levels_by_server_id(server.id).where(lambda l: l.name == level).single_or_default() ) if level_from_db is None: await self._message_service.send_ctx_msg( @@ -349,13 +316,9 @@ class LevelGroup(DiscordCommandABC): except Exception as e: await self._message_service.send_ctx_msg( ctx, - self._t.transform("modules.level.edit.permission_invalid").format( - permissions - ), - ) - self._logger.error( - __name__, f"Error parsing permissions {permissions}", e + self._t.transform("modules.level.edit.permission_invalid").format(permissions), ) + self._logger.error(__name__, f"Error parsing permissions {permissions}", e) return try: @@ -377,9 +340,7 @@ class LevelGroup(DiscordCommandABC): e, ) else: - await self._message_service.send_ctx_msg( - ctx, self._t.transform("modules.level.edit.edited").format(level) - ) + await self._message_service.send_ctx_msg(ctx, self._t.transform("modules.level.edit.edited").format(level)) await self._seed_levels(ctx) self._logger.trace(__name__, f"Finished command level edit") @@ -413,19 +374,13 @@ class LevelGroup(DiscordCommandABC): if ctx.guild is None: return - server_config: ServerConfig = self._config.get_configuration( - f"ServerConfig_{ctx.guild.id}" - ) - if not FeatureFlagsSettings.get_flag_from_dict( - server_config.feature_flags, FeatureFlagsEnum.level_module - ): + server_config: ServerConfig = self._config.get_configuration(f"ServerConfig_{ctx.guild.id}") + if not FeatureFlagsSettings.get_flag_from_dict(server_config.feature_flags, FeatureFlagsEnum.level_module): return server = self._servers.get_server_by_discord_id(ctx.guild.id) level_from_db = ( - self._levels.get_levels_by_server_id(server.id) - .where(lambda l: l.name == level) - .first_or_default() + self._levels.get_levels_by_server_id(server.id).where(lambda l: l.name == level).first_or_default() ) if level_from_db is None: self._logger.debug(__name__, f"level {level} not found") @@ -440,9 +395,7 @@ class LevelGroup(DiscordCommandABC): self._levels.delete_level(level_from_db) self._db.save_changes() guild: Guild = self._bot.guilds.where(lambda g: g == ctx.guild).single() - role: Role = guild.roles.where( - lambda r: r.name == level - ).single_or_default() + role: Role = guild.roles.where(lambda r: r.name == level).single_or_default() if role is not None: await role.delete() self._logger.info(__name__, f"Removed level {level}") @@ -471,12 +424,8 @@ class LevelGroup(DiscordCommandABC): if ctx.guild is None: return - server_config: ServerConfig = self._config.get_configuration( - f"ServerConfig_{ctx.guild.id}" - ) - if not FeatureFlagsSettings.get_flag_from_dict( - server_config.feature_flags, FeatureFlagsEnum.level_module - ): + server_config: ServerConfig = self._config.get_configuration(f"ServerConfig_{ctx.guild.id}") + if not FeatureFlagsSettings.get_flag_from_dict(server_config.feature_flags, FeatureFlagsEnum.level_module): return if member.bot: @@ -485,16 +434,12 @@ class LevelGroup(DiscordCommandABC): server = self._servers.get_server_by_discord_id(ctx.guild.id) user = self._users.get_user_by_discord_id_and_server_id(member.id, server.id) level = self._level_service.get_level(user) - levels = self._levels.get_levels_by_server_id(server.id).order_by( - lambda l: l.min_xp - ) + levels = self._levels.get_levels_by_server_id(server.id).order_by(lambda l: l.min_xp) if level == levels.first(): await self._message_service.send_ctx_msg( ctx, - self._t.transform("modules.level.down.already_first").format( - member.mention - ), + self._t.transform("modules.level.down.already_first").format(member.mention), ) self._logger.trace(__name__, f"Finished command level down") return @@ -506,15 +451,11 @@ class LevelGroup(DiscordCommandABC): self._db.save_changes() await self._message_service.send_ctx_msg( ctx, - self._t.transform("modules.level.down.success").format( - member.mention, new_level.name - ), + self._t.transform("modules.level.down.success").format(member.mention, new_level.name), ) await self._level_service.set_level(user) except Exception as e: - self._logger.error( - __name__, f"Cannot level down {member.name} with level {level.name}", e - ) + self._logger.error(__name__, f"Cannot level down {member.name} with level {level.name}", e) await self._message_service.send_ctx_msg( ctx, self._t.transform("modules.level.down.failed").format(member.mention), @@ -531,12 +472,8 @@ class LevelGroup(DiscordCommandABC): if ctx.guild is None: return - server_config: ServerConfig = self._config.get_configuration( - f"ServerConfig_{ctx.guild.id}" - ) - if not FeatureFlagsSettings.get_flag_from_dict( - server_config.feature_flags, FeatureFlagsEnum.level_module - ): + server_config: ServerConfig = self._config.get_configuration(f"ServerConfig_{ctx.guild.id}") + if not FeatureFlagsSettings.get_flag_from_dict(server_config.feature_flags, FeatureFlagsEnum.level_module): return if member.bot: @@ -545,16 +482,12 @@ class LevelGroup(DiscordCommandABC): server = self._servers.get_server_by_discord_id(ctx.guild.id) user = self._users.get_user_by_discord_id_and_server_id(member.id, server.id) level = self._level_service.get_level(user) - levels = self._levels.get_levels_by_server_id(server.id).order_by( - lambda l: l.min_xp - ) + levels = self._levels.get_levels_by_server_id(server.id).order_by(lambda l: l.min_xp) if level.name == levels.last().name: await self._message_service.send_ctx_msg( ctx, - self._t.transform("modules.level.up.already_last").format( - member.mention - ), + self._t.transform("modules.level.up.already_last").format(member.mention), ) self._logger.trace(__name__, f"Finished command level up") return @@ -566,15 +499,11 @@ class LevelGroup(DiscordCommandABC): self._db.save_changes() await self._message_service.send_ctx_msg( ctx, - self._t.transform("modules.level.up.success").format( - member.mention, new_level.name - ), + self._t.transform("modules.level.up.success").format(member.mention, new_level.name), ) await self._level_service.set_level(user) except Exception as e: - self._logger.error( - __name__, f"Cannot level up {member.name} with level {level.name}", e - ) + self._logger.error(__name__, f"Cannot level up {member.name} with level {level.name}", e) await self._message_service.send_ctx_msg( ctx, self._t.transform("modules.level.up.failed").format(member.mention) ) @@ -590,12 +519,8 @@ class LevelGroup(DiscordCommandABC): if ctx.guild is None: return - server_config: ServerConfig = self._config.get_configuration( - f"ServerConfig_{ctx.guild.id}" - ) - if not FeatureFlagsSettings.get_flag_from_dict( - server_config.feature_flags, FeatureFlagsEnum.level_module - ): + server_config: ServerConfig = self._config.get_configuration(f"ServerConfig_{ctx.guild.id}") + if not FeatureFlagsSettings.get_flag_from_dict(server_config.feature_flags, FeatureFlagsEnum.level_module): return if member.bot: @@ -604,11 +529,7 @@ class LevelGroup(DiscordCommandABC): server = self._servers.get_server_by_discord_id(ctx.guild.id) user = self._users.get_user_by_discord_id_and_server_id(member.id, server.id) current_level = self._level_service.get_level(user) - new_level = ( - self._levels.get_levels_by_server_id(server.id) - .where(lambda l: l.name == level) - .single_or_default() - ) + new_level = self._levels.get_levels_by_server_id(server.id).where(lambda l: l.name == level).single_or_default() if new_level is None: await self._message_service.send_ctx_msg( @@ -620,9 +541,7 @@ class LevelGroup(DiscordCommandABC): if current_level.name == level: await self._message_service.send_ctx_msg( ctx, - self._t.transform("modules.level.set.already_level").format( - member.mention, level - ), + self._t.transform("modules.level.set.already_level").format(member.mention, level), ) self._logger.trace(__name__, f"Finished command level set") return @@ -633,15 +552,11 @@ class LevelGroup(DiscordCommandABC): self._db.save_changes() await self._message_service.send_ctx_msg( ctx, - self._t.transform("modules.level.set.success").format( - member.mention, new_level.name - ), + self._t.transform("modules.level.set.success").format(member.mention, new_level.name), ) await self._level_service.set_level(user) except Exception as e: - self._logger.error( - __name__, f"Cannot set level {level} for {member.name}", e - ) + self._logger.error(__name__, f"Cannot set level {level} for {member.name}", e) await self._message_service.send_ctx_msg( ctx, self._t.transform("modules.level.set.failed").format(member.mention), @@ -650,9 +565,7 @@ class LevelGroup(DiscordCommandABC): self._logger.trace(__name__, f"Finished command level set") @set.autocomplete("level") - async def set_autocomplete( - self, interaction: discord.Interaction, current: str - ) -> TList[app_commands.Choice[str]]: + async def set_autocomplete(self, interaction: discord.Interaction, current: str) -> TList[app_commands.Choice[str]]: return await self._level_auto_complete(interaction, current) @level.command() @@ -664,12 +577,8 @@ class LevelGroup(DiscordCommandABC): if ctx.guild is None: return - server_config: ServerConfig = self._config.get_configuration( - f"ServerConfig_{ctx.guild.id}" - ) - if not FeatureFlagsSettings.get_flag_from_dict( - server_config.feature_flags, FeatureFlagsEnum.level_module - ): + server_config: ServerConfig = self._config.get_configuration(f"ServerConfig_{ctx.guild.id}") + if not FeatureFlagsSettings.get_flag_from_dict(server_config.feature_flags, FeatureFlagsEnum.level_module): return await self._seed_levels(ctx) diff --git a/bot/src/modules/level/events/level_on_member_join_event.py b/bot/src/modules/level/events/level_on_member_join_event.py index 94f74841..7113f761 100644 --- a/bot/src/modules/level/events/level_on_member_join_event.py +++ b/bot/src/modules/level/events/level_on_member_join_event.py @@ -11,9 +11,7 @@ from modules.level.service.level_service import LevelService class LevelOnMemberJoinEvent(OnMemberJoinABC): - def __init__( - self, config: ConfigurationABC, logger: MessageLogger, level: LevelService - ): + def __init__(self, config: ConfigurationABC, logger: MessageLogger, level: LevelService): OnMemberJoinABC.__init__(self) self._config = config self._logger = logger @@ -22,12 +20,8 @@ class LevelOnMemberJoinEvent(OnMemberJoinABC): @EventChecks.check_is_ready() async def on_member_join(self, member: discord.Member): self._logger.debug(__name__, f"Module {type(self)} started") - server_config: ServerConfig = self._config.get_configuration( - f"ServerConfig_{member.guild.id}" - ) - if not FeatureFlagsSettings.get_flag_from_dict( - server_config.feature_flags, FeatureFlagsEnum.level_module - ): + server_config: ServerConfig = self._config.get_configuration(f"ServerConfig_{member.guild.id}") + if not FeatureFlagsSettings.get_flag_from_dict(server_config.feature_flags, FeatureFlagsEnum.level_module): return await self._level.check_level(member) diff --git a/bot/src/modules/level/events/level_on_message_event.py b/bot/src/modules/level/events/level_on_message_event.py index 94141f78..4c98706f 100644 --- a/bot/src/modules/level/events/level_on_message_event.py +++ b/bot/src/modules/level/events/level_on_message_event.py @@ -11,9 +11,7 @@ from modules.level.service.level_service import LevelService class LevelOnMessageEvent(OnMessageABC): - def __init__( - self, config: ConfigurationABC, logger: MessageLogger, level: LevelService - ): + def __init__(self, config: ConfigurationABC, logger: MessageLogger, level: LevelService): OnMessageABC.__init__(self) self._config = config self._logger = logger @@ -28,12 +26,8 @@ class LevelOnMessageEvent(OnMessageABC): if message.author.bot: return - server_config: ServerConfig = self._config.get_configuration( - f"ServerConfig_{message.guild.id}" - ) - if not FeatureFlagsSettings.get_flag_from_dict( - server_config.feature_flags, FeatureFlagsEnum.level_module - ): + server_config: ServerConfig = self._config.get_configuration(f"ServerConfig_{message.guild.id}") + if not FeatureFlagsSettings.get_flag_from_dict(server_config.feature_flags, FeatureFlagsEnum.level_module): return try: diff --git a/bot/src/modules/level/events/level_on_raw_reaction_add_event.py b/bot/src/modules/level/events/level_on_raw_reaction_add_event.py index b59ce939..bffc56ef 100644 --- a/bot/src/modules/level/events/level_on_raw_reaction_add_event.py +++ b/bot/src/modules/level/events/level_on_raw_reaction_add_event.py @@ -29,12 +29,8 @@ class LevelOnRawReactionAddEvent(OnRawReactionAddABC): @EventChecks.check_is_ready() async def on_raw_reaction_add(self, payload: RawReactionActionEvent): self._logger.debug(__name__, f"Module {type(self)} started") - server_config: ServerConfig = self._config.get_configuration( - f"ServerConfig_{payload.guild_id}" - ) - if not FeatureFlagsSettings.get_flag_from_dict( - server_config.feature_flags, FeatureFlagsEnum.level_module - ): + server_config: ServerConfig = self._config.get_configuration(f"ServerConfig_{payload.guild_id}") + if not FeatureFlagsSettings.get_flag_from_dict(server_config.feature_flags, FeatureFlagsEnum.level_module): return try: diff --git a/bot/src/modules/level/events/level_on_raw_reaction_remove_event.py b/bot/src/modules/level/events/level_on_raw_reaction_remove_event.py index fceccd0b..fa94e334 100644 --- a/bot/src/modules/level/events/level_on_raw_reaction_remove_event.py +++ b/bot/src/modules/level/events/level_on_raw_reaction_remove_event.py @@ -29,12 +29,8 @@ class LevelOnRawReactionRemoveEvent(OnRawReactionRemoveABC): @EventChecks.check_is_ready() async def on_raw_reaction_remove(self, payload: RawReactionActionEvent): self._logger.debug(__name__, f"Module {type(self)} started") - server_config: ServerConfig = self._config.get_configuration( - f"ServerConfig_{payload.guild_id}" - ) - if not FeatureFlagsSettings.get_flag_from_dict( - server_config.feature_flags, FeatureFlagsEnum.level_module - ): + server_config: ServerConfig = self._config.get_configuration(f"ServerConfig_{payload.guild_id}") + if not FeatureFlagsSettings.get_flag_from_dict(server_config.feature_flags, FeatureFlagsEnum.level_module): return try: diff --git a/bot/src/modules/level/events/level_on_voice_state_update_event.py b/bot/src/modules/level/events/level_on_voice_state_update_event.py index c529311c..9a0b5978 100644 --- a/bot/src/modules/level/events/level_on_voice_state_update_event.py +++ b/bot/src/modules/level/events/level_on_voice_state_update_event.py @@ -11,9 +11,7 @@ from modules.level.service.level_service import LevelService class LevelOnVoiceStateUpdateEvent(OnVoiceStateUpdateABC): - def __init__( - self, config: ConfigurationABC, logger: LoggerABC, level: LevelService - ): + def __init__(self, config: ConfigurationABC, logger: LoggerABC, level: LevelService): OnVoiceStateUpdateABC.__init__(self) self._config = config self._logger = logger @@ -29,12 +27,8 @@ class LevelOnVoiceStateUpdateEvent(OnVoiceStateUpdateABC): after: discord.VoiceState, ): self._logger.debug(__name__, f"Module {type(self)} started") - server_config: ServerConfig = self._config.get_configuration( - f"ServerConfig_{member.guild.id}" - ) - if not FeatureFlagsSettings.get_flag_from_dict( - server_config.feature_flags, FeatureFlagsEnum.level_module - ): + server_config: ServerConfig = self._config.get_configuration(f"ServerConfig_{member.guild.id}") + if not FeatureFlagsSettings.get_flag_from_dict(server_config.feature_flags, FeatureFlagsEnum.level_module): return await self._level.check_level(member) diff --git a/bot/src/modules/level/level_module.py b/bot/src/modules/level/level_module.py index 19e04459..500e4a01 100644 --- a/bot/src/modules/level/level_module.py +++ b/bot/src/modules/level/level_module.py @@ -29,17 +29,13 @@ class LevelModule(ModuleABC): def __init__(self, dc: DiscordCollectionABC): ModuleABC.__init__(self, dc, FeatureFlagsEnum.level_module) - def configure_configuration( - self, config: ConfigurationABC, env: ApplicationEnvironmentABC - ): + def configure_configuration(self, config: ConfigurationABC, env: ApplicationEnvironmentABC): cwd = env.working_directory env.set_working_directory(os.path.dirname(os.path.realpath(__file__))) config.add_json_file(f"default-level.json", optional=False) env.set_working_directory(cwd) - def configure_services( - self, services: ServiceCollectionABC, env: ApplicationEnvironmentABC - ): + def configure_services(self, services: ServiceCollectionABC, env: ApplicationEnvironmentABC): services.add_transient(DataSeederABC, LevelSeeder) services.add_transient(LevelService) @@ -47,19 +43,13 @@ class LevelModule(ModuleABC): services.add_transient(LevelGroup) # events - services.add_transient( - DiscordEventTypesEnum.on_message.value, LevelOnMessageEvent - ) + services.add_transient(DiscordEventTypesEnum.on_message.value, LevelOnMessageEvent) services.add_transient( DiscordEventTypesEnum.on_voice_state_update.value, LevelOnVoiceStateUpdateEvent, ) - services.add_transient( - DiscordEventTypesEnum.on_member_join.value, LevelOnMemberJoinEvent - ) - services.add_transient( - DiscordEventTypesEnum.on_raw_reaction_add.value, LevelOnRawReactionAddEvent - ) + services.add_transient(DiscordEventTypesEnum.on_member_join.value, LevelOnMemberJoinEvent) + services.add_transient(DiscordEventTypesEnum.on_raw_reaction_add.value, LevelOnRawReactionAddEvent) services.add_transient( DiscordEventTypesEnum.on_raw_reaction_remove.value, LevelOnRawReactionRemoveEvent, diff --git a/bot/src/modules/level/level_seeder.py b/bot/src/modules/level/level_seeder.py index e0f81148..19c7b773 100644 --- a/bot/src/modules/level/level_seeder.py +++ b/bot/src/modules/level/level_seeder.py @@ -46,10 +46,7 @@ class LevelSeeder(DataSeederABC): async def _create_level(self, level: Level, guild: Guild, server: Server): level.server = server try: - if ( - guild.roles.where(lambda r: r.name == level.name).first_or_default() - is None - ): + if guild.roles.where(lambda r: r.name == level.name).first_or_default() is None: await guild.create_role( name=level.name, colour=Colour(int(level.color, 16)), @@ -60,11 +57,7 @@ class LevelSeeder(DataSeederABC): self._logger.debug(__name__, f"Created role {level.name}") levels = self._levels.find_levels_by_server_id(server.id) - if ( - levels is None - or levels.where(lambda l: l.name == level.name).first_or_default() - is None - ): + if levels is None or levels.where(lambda l: l.name == level.name).first_or_default() is None: self._levels.add_level(level) self._logger.debug(__name__, f"Saved level {level.name}") self._db.save_changes() @@ -78,21 +71,12 @@ class LevelSeeder(DataSeederABC): async def seed(self): # create levels for guild in self._bot.guilds: - server_config: ServerConfig = self._config.get_configuration( - f"ServerConfig_{guild.id}" - ) - if not FeatureFlagsSettings.get_flag_from_dict( - server_config.feature_flags, FeatureFlagsEnum.level_module - ): + server_config: ServerConfig = self._config.get_configuration(f"ServerConfig_{guild.id}") + if not FeatureFlagsSettings.get_flag_from_dict(server_config.feature_flags, FeatureFlagsEnum.level_module): continue created_default = False - if ( - guild.roles.where( - lambda r: r.name == self._level_header - ).first_or_default() - is None - ): + if guild.roles.where(lambda r: r.name == self._level_header).first_or_default() is None: await guild.create_role(name=self._level_header) server = self._servers.find_server_by_discord_id(guild.id) @@ -118,20 +102,13 @@ class LevelSeeder(DataSeederABC): continue levels = levels.order_by_descending(lambda l: l.min_xp) - position_above_levels = ( - guild.roles.where(lambda r: r.name == self._level_header) - .single() - .position - ) + position_above_levels = guild.roles.where(lambda r: r.name == self._level_header).single().position for role in guild.roles.order_by_descending(lambda r: r.position): if levels.where(lambda l: l.name == role.name).count() == 0: continue new_position = position_above_levels - ( - levels.index_of( - levels.where(lambda l: l.name == role.name).single() - ) - + 1 + levels.index_of(levels.where(lambda l: l.name == role.name).single()) + 1 ) if new_position <= 0: new_position = 1 @@ -142,9 +119,7 @@ class LevelSeeder(DataSeederABC): ) await role.edit(position=new_position) except Exception as e: - self._logger.error( - __name__, f"Cannot change position of {role.name}", e - ) + self._logger.error(__name__, f"Cannot change position of {role.name}", e) for m in guild.members: await self._level.check_level(m) diff --git a/bot/src/modules/level/service/level_service.py b/bot/src/modules/level/service/level_service.py index 258bec27..e85c1719 100644 --- a/bot/src/modules/level/service/level_service.py +++ b/bot/src/modules/level/service/level_service.py @@ -43,9 +43,7 @@ class LevelService: if user.xp < 0: return levels_by_server.order_by(lambda l: l.min_xp).first() - levels = levels_by_server.order_by(lambda l: l.min_xp).where( - lambda l: user.xp >= l.min_xp - ) + levels = levels_by_server.order_by(lambda l: l.min_xp).where(lambda l: user.xp >= l.min_xp) if levels.count() == 0: return levels_by_server.order_by(lambda l: l.min_xp).last() @@ -53,12 +51,8 @@ class LevelService: return levels.last() async def set_level(self, user: User): - level_names = self._levels.get_levels_by_server_id(user.server.id).select( - lambda l: l.name - ) - guild: Guild = self._bot.guilds.where( - lambda g: g.id == user.server.discord_id - ).single() + level_names = self._levels.get_levels_by_server_id(user.server.id).select(lambda l: l.name) + guild: Guild = self._bot.guilds.where(lambda g: g.id == user.server.discord_id).single() member: Member = guild.members.where(lambda m: m.id == user.discord_id).single() level = self.get_level(user) @@ -69,39 +63,25 @@ class LevelService: notification_needed = False for role in member.roles.where(lambda r: r.name in level_names.to_list()): try: - self._logger.debug( - __name__, f"Try to remove role {role.name} from {member.name}" - ) + self._logger.debug(__name__, f"Try to remove role {role.name} from {member.name}") await member.remove_roles(role) notification_needed = True - self._logger.info( - __name__, f"Removed role {role.name} from {member.name}" - ) + self._logger.info(__name__, f"Removed role {role.name} from {member.name}") except Exception as e: - self._logger.error( - __name__, f"Removing role {role.name} from {member.name} failed!", e - ) + self._logger.error(__name__, f"Removing role {role.name} from {member.name} failed!", e) try: - self._logger.debug( - __name__, f"Try to add role {level_role.name} to {member.name}" - ) + self._logger.debug(__name__, f"Try to add role {level_role.name} to {member.name}") await member.add_roles(level_role) self._logger.info(__name__, f"Add role {level_role.name} to {member.name}") except Exception as e: - self._logger.error( - __name__, f"Adding role {level_role.name} to {member.name} failed!", e - ) + self._logger.error(__name__, f"Adding role {level_role.name} to {member.name} failed!", e) if notification_needed: - settings: ServerConfig = self._config.get_configuration( - f"ServerConfig_{guild.id}" - ) + settings: ServerConfig = self._config.get_configuration(f"ServerConfig_{guild.id}") await self._message_service.send_channel_message( self._bot.get_channel(settings.notification_chat_id), - self._t.transform("modules.level.new_level_message").format( - member.mention, level.name - ), + self._t.transform("modules.level.new_level_message").format(member.mention, level.name), is_persistent=True, ) @@ -112,9 +92,7 @@ class LevelService: server = self._servers.get_server_by_discord_id(member.guild.id) user = self._users.find_user_by_discord_id_and_server_id(member.id, server.id) if user is None: - self._logger.warn( - __name__, f"User not found {member.guild.name}@{member.name}" - ) + self._logger.warn(__name__, f"User not found {member.guild.name}@{member.name}") return await self.set_level(user) diff --git a/bot/src/modules/permission/permission_module.py b/bot/src/modules/permission/permission_module.py index fb6c509d..75da783e 100644 --- a/bot/src/modules/permission/permission_module.py +++ b/bot/src/modules/permission/permission_module.py @@ -13,14 +13,10 @@ class PermissionModule(ModuleABC): def __init__(self, dc: DiscordCollectionABC): ModuleABC.__init__(self, dc, FeatureFlagsEnum.permission_module) - def configure_configuration( - self, config: ConfigurationABC, env: ApplicationEnvironmentABC - ): + def configure_configuration(self, config: ConfigurationABC, env: ApplicationEnvironmentABC): pass - def configure_services( - self, services: ServiceCollectionABC, env: ApplicationEnvironmentABC - ): + def configure_services(self, services: ServiceCollectionABC, env: ApplicationEnvironmentABC): services.add_transient(PermissionServiceABC, PermissionService) # commands # events diff --git a/bot/src/modules/permission/service/permission_service.py b/bot/src/modules/permission/service/permission_service.py index c75175e7..9ac28c55 100644 --- a/bot/src/modules/permission/service/permission_service.py +++ b/bot/src/modules/permission/service/permission_service.py @@ -28,22 +28,18 @@ class PermissionService(PermissionServiceABC): self._server_configs = server_configs self._technician_configs = technician_configs - def _has_member_role( - self, member: discord.Member, team_member_type: TeamMemberTypeEnum - ) -> bool: + def _has_member_role(self, member: discord.Member, team_member_type: TeamMemberTypeEnum) -> bool: if member is None or member.guild is None: return False - self._logger.debug( - __name__, f"Checking is member {member.name} {team_member_type.value}" - ) + self._logger.debug(__name__, f"Checking is member {member.name} {team_member_type.value}") try: server = self._servers.get_server_by_discord_id(member.guild.id) config = self._server_configs.get_server_config_by_server(server.id) - roles = config.team_role_ids.where( - lambda x: x.team_member_type == team_member_type - ).select(lambda x: member.guild.get_role(x.role_id)) + roles = config.team_role_ids.where(lambda x: x.team_member_type == team_member_type).select( + lambda x: member.guild.get_role(x.role_id) + ) for role in roles: if role not in member.roles: continue @@ -58,9 +54,9 @@ class PermissionService(PermissionServiceABC): return self._has_member_role(member, TeamMemberTypeEnum.admin) def is_member_moderator(self, member: discord.Member) -> bool: - return self._has_member_role( - member, TeamMemberTypeEnum.moderator - ) or self._has_member_role(member, TeamMemberTypeEnum.admin) + return self._has_member_role(member, TeamMemberTypeEnum.moderator) or self._has_member_role( + member, TeamMemberTypeEnum.admin + ) def is_member_technician(self, member: discord.Member) -> bool: if member is None or member.guild is None: diff --git a/bot/src/modules/short_role_name/events/short_role_name_on_member_update_event.py b/bot/src/modules/short_role_name/events/short_role_name_on_member_update_event.py index 574b3379..6b942ed1 100644 --- a/bot/src/modules/short_role_name/events/short_role_name_on_member_update_event.py +++ b/bot/src/modules/short_role_name/events/short_role_name_on_member_update_event.py @@ -9,8 +9,6 @@ class ShortRoleNameOnMemberUpdateEvent(OnMemberUpdateABC): OnMemberUpdateABC.__init__(self) self._service = service - async def on_member_update( - self, before: discord.member.Member, after: discord.member.Member - ): + async def on_member_update(self, before: discord.member.Member, after: discord.member.Member): if before.roles != after.roles or before.name != after.name: await self._service.check_short_role_names(after) diff --git a/bot/src/modules/short_role_name/service/short_role_name_service.py b/bot/src/modules/short_role_name/service/short_role_name_service.py index f85f2d01..5a2e8af8 100644 --- a/bot/src/modules/short_role_name/service/short_role_name_service.py +++ b/bot/src/modules/short_role_name/service/short_role_name_service.py @@ -32,12 +32,8 @@ class ShortRoleNameService: async def check_short_role_names(self, member: discord.Member): self._logger.debug(__name__, f"Started short role name check for {member.id}") - settings: ServerConfig = self._config.get_configuration( - f"ServerConfig_{member.guild.id}" - ) - if not FeatureFlagsSettings.get_flag_from_dict( - settings.feature_flags, FeatureFlagsEnum.short_role_name - ): + settings: ServerConfig = self._config.get_configuration(f"ServerConfig_{member.guild.id}") + if not FeatureFlagsSettings.get_flag_from_dict(settings.feature_flags, FeatureFlagsEnum.short_role_name): self._logger.debug(__name__, f"Feature not active") return @@ -49,16 +45,12 @@ class ShortRoleNameService: new_nick = member.nick if member.nick is not None else member.name member_roles = List(discord.Role, member.roles) highest_role: Optional[discord.Role] = ( - member_roles.last_or_default() - if settings.short_role_name_only_set_highest_role - else None + member_roles.last_or_default() if settings.short_role_name_only_set_highest_role else None ) member_role_ids = member_roles.select(lambda x: x.id) server = self._server.get_server_by_discord_id(member.guild.id) - for short_role_name in self._short_role_names.get_short_role_names_by_server_id( - server.id - ): + for short_role_name in self._short_role_names.get_short_role_names_by_server_id(server.id): short_role_name: ShortRoleName = short_role_name new_nick = new_nick.replace(f" [{short_role_name.short_name}]", "") diff --git a/bot/src/modules/short_role_name/short_role_name_check_command.py b/bot/src/modules/short_role_name/short_role_name_check_command.py index feb35a99..663be0f1 100644 --- a/bot/src/modules/short_role_name/short_role_name_check_command.py +++ b/bot/src/modules/short_role_name/short_role_name_check_command.py @@ -47,22 +47,14 @@ class ShortRoleNameCheckCommand(DiscordCommandABC): if ctx.guild is None: return - settings: ServerConfig = self._config.get_configuration( - f"ServerConfig_{ctx.guild.id}" - ) - if not FeatureFlagsSettings.get_flag_from_dict( - settings.feature_flags, FeatureFlagsEnum.short_role_name - ): - await self._message_service.send_ctx_msg( - ctx, self._t.transform("common.feature_not_activated") - ) + settings: ServerConfig = self._config.get_configuration(f"ServerConfig_{ctx.guild.id}") + if not FeatureFlagsSettings.get_flag_from_dict(settings.feature_flags, FeatureFlagsEnum.short_role_name): + await self._message_service.send_ctx_msg(ctx, self._t.transform("common.feature_not_activated")) return for member in ctx.guild.members: await self._service.check_short_role_names(member) - await self._message_service.send_ctx_msg( - ctx, self._t.transform("modules.short_role_name.checked_message") - ) + await self._message_service.send_ctx_msg(ctx, self._t.transform("modules.short_role_name.checked_message")) self._logger.trace(__name__, f"Finished purge command") diff --git a/bot/src/modules/short_role_name/short_role_name_module.py b/bot/src/modules/short_role_name/short_role_name_module.py index 224e52d9..19b732fe 100644 --- a/bot/src/modules/short_role_name/short_role_name_module.py +++ b/bot/src/modules/short_role_name/short_role_name_module.py @@ -21,14 +21,10 @@ class ShortRoleNameModule(ModuleABC): def __init__(self, dc: DiscordCollectionABC): ModuleABC.__init__(self, dc, FeatureFlagsEnum.short_role_name_module) - def configure_configuration( - self, config: ConfigurationABC, env: ApplicationEnvironmentABC - ): + def configure_configuration(self, config: ConfigurationABC, env: ApplicationEnvironmentABC): pass - def configure_services( - self, services: ServiceCollectionABC, env: ApplicationEnvironmentABC - ): + def configure_services(self, services: ServiceCollectionABC, env: ApplicationEnvironmentABC): services.add_transient(DataSeederABC, ShortRoleNameSeeder) services.add_transient(ShortRoleNameService) diff --git a/bot/src/modules/special_offers/special_offers_module.py b/bot/src/modules/special_offers/special_offers_module.py index 4a35120d..e64108b5 100644 --- a/bot/src/modules/special_offers/special_offers_module.py +++ b/bot/src/modules/special_offers/special_offers_module.py @@ -13,14 +13,10 @@ class SteamSpecialOffersModule(ModuleABC): def __init__(self, dc: DiscordCollectionABC): ModuleABC.__init__(self, dc, FeatureFlagsEnum.steam_special_offers_module) - def configure_configuration( - self, config: ConfigurationABC, env: ApplicationEnvironmentABC - ): + def configure_configuration(self, config: ConfigurationABC, env: ApplicationEnvironmentABC): pass - def configure_services( - self, services: ServiceCollectionABC, env: ApplicationEnvironmentABC - ): + def configure_services(self, services: ServiceCollectionABC, env: ApplicationEnvironmentABC): services.add_singleton(TaskABC, SteamOfferWatcher) # commands # events diff --git a/bot/src/modules/special_offers/steam_offer_watcher.py b/bot/src/modules/special_offers/steam_offer_watcher.py index b31e6a6a..d2cd2317 100644 --- a/bot/src/modules/special_offers/steam_offer_watcher.py +++ b/bot/src/modules/special_offers/steam_offer_watcher.py @@ -53,9 +53,7 @@ class SteamOfferWatcher(TaskABC): @staticmethod def _get_max_count() -> int: count = 0 - result = requests.get( - f"https://store.steampowered.com/search/results?specials=1" - ) + result = requests.get(f"https://store.steampowered.com/search/results?specials=1") soup = bs4.BeautifulSoup(result.text, "lxml") element = soup.find_all("div", {"class": "search_results_count"}) if len(element) < 1: @@ -77,13 +75,9 @@ class SteamOfferWatcher(TaskABC): for element in elements: name_element = element.find("span", {"class": "title"}) - original_price_element = element.find( - "div", {"class": "discount_original_price"} - ) + original_price_element = element.find("div", {"class": "discount_original_price"}) discount_element = element.find("div", {"class": "discount_pct"}) - discount_price_element = element.find( - "div", {"class": "discount_final_price"} - ) + discount_price_element = element.find("div", {"class": "discount_final_price"}) if ( name_element is None @@ -99,25 +93,15 @@ class SteamOfferWatcher(TaskABC): name = name_element.contents[0].replace("'", "`").replace('"', "`") original_price = float( - original_price_element.contents[0] - .replace(" ", "") - .replace("€", "") - .replace(",", ".") + original_price_element.contents[0].replace(" ", "").replace("€", "").replace(",", ".") ) discount = int(discount_element.contents[0].replace("%", "")) discount_price = float( - discount_price_element.contents[0] - .replace(" ", "") - .replace("€", "") - .replace(",", ".") + discount_price_element.contents[0].replace(" ", "").replace("€", "").replace(",", ".") ) games.add(SteamSpecialOffer(name, original_price, discount_price, discount)) self._urls[name] = element.attrs["href"] - self._image_urls[name] = ( - element.find("div", {"class": "search_capsule"}) - .find("img") - .attrs["src"] - ) + self._image_urls[name] = element.find("div", {"class": "search_capsule"}).find("img").attrs["src"] return games @@ -134,9 +118,7 @@ class SteamOfferWatcher(TaskABC): return new_offers - async def _send_embed_for_offer( - self, offer: SteamSpecialOffer, channel_id: int - ) -> discord.Embed: + async def _send_embed_for_offer(self, offer: SteamSpecialOffer, channel_id: int) -> discord.Embed: embed = discord.Embed( title=offer.name, url=self._urls[offer.name], @@ -211,9 +193,7 @@ class SteamOfferWatcher(TaskABC): if self._is_new: return for guild in self._bot.guilds: - settings: ServerConfig = self._config.get_configuration( - f"ServerConfig_{guild.id}" - ) + settings: ServerConfig = self._config.get_configuration(f"ServerConfig_{guild.id}") if ( not FeatureFlagsSettings.get_flag_from_dict( settings.feature_flags, FeatureFlagsEnum.steam_special_offers @@ -224,9 +204,7 @@ class SteamOfferWatcher(TaskABC): for offer in offers_for_notifications: self._bot.loop.create_task( - self._send_embed_for_offer( - offer, settings.game_offer_notification_chat_id - ) + self._send_embed_for_offer(offer, settings.game_offer_notification_chat_id) ) except Exception as e: self._logger.error(__name__, f"Steam offer watcher failed", e) diff --git a/bot/src/modules/technician/api_key_seeder.py b/bot/src/modules/technician/api_key_seeder.py index 70792942..f8f1305c 100644 --- a/bot/src/modules/technician/api_key_seeder.py +++ b/bot/src/modules/technician/api_key_seeder.py @@ -36,9 +36,7 @@ class ApiKeySeeder(DataSeederABC): return try: - frontend_key = ApiKey( - "frontend", "87f529fd-a32e-40b3-a1d1-7a1583cf3ff5", None - ) + frontend_key = ApiKey("frontend", "87f529fd-a32e-40b3-a1d1-7a1583cf3ff5", None) self._api_keys.add_api_key(frontend_key) self._db.save_changes() self._logger.info(__name__, f"Created frontend API-Key") diff --git a/bot/src/modules/technician/command/api_key_group.py b/bot/src/modules/technician/command/api_key_group.py index f0171553..11912385 100644 --- a/bot/src/modules/technician/command/api_key_group.py +++ b/bot/src/modules/technician/command/api_key_group.py @@ -54,9 +54,7 @@ class ApiKeyGroup(DiscordCommandABC): def _get_api_key_str(self, api_key: ApiKey) -> str: return hashlib.sha256( - f"{api_key.identifier}:{api_key.key}+{self._auth_settings.secret_key}".encode( - "utf-8" - ) + f"{api_key.identifier}:{api_key.key}+{self._auth_settings.secret_key}".encode("utf-8") ).hexdigest() @commands.hybrid_group(name="api-key") @@ -69,9 +67,7 @@ class ApiKeyGroup(DiscordCommandABC): @CommandChecks.check_is_ready() @CommandChecks.check_is_member_technician() async def get(self, ctx: Context, key: str, wait: int = None): - self._logger.debug( - __name__, f"Received command api-key get {ctx}: {key},{wait}" - ) + self._logger.debug(__name__, f"Received command api-key get {ctx}: {key},{wait}") api_key = self._api_keys.get_api_key_by_key(key) await self._message_service.send_ctx_msg( @@ -83,16 +79,12 @@ class ApiKeyGroup(DiscordCommandABC): self._logger.trace(__name__, f"Finished command api-key get") @get.autocomplete("key") - async def get_autocomplete( - self, interaction: discord.Interaction, current: str - ) -> TList[app_commands.Choice[str]]: + async def get_autocomplete(self, interaction: discord.Interaction, current: str) -> TList[app_commands.Choice[str]]: keys = self._api_keys.get_api_keys() return [ app_commands.Choice(name=f"{key.identifier}: {key.key}", value=key.key) - for key in self._client_utils.get_auto_complete_list( - keys, current, lambda x: x.key - ) + for key in self._client_utils.get_auto_complete_list(keys, current, lambda x: x.key) ] @api_key.command() @@ -100,14 +92,10 @@ class ApiKeyGroup(DiscordCommandABC): @CommandChecks.check_is_ready() @CommandChecks.check_is_member_moderator() async def add(self, ctx: Context, identifier: str): - self._logger.debug( - __name__, f"Received command api-key add {ctx}: {identifier}" - ) + self._logger.debug(__name__, f"Received command api-key add {ctx}: {identifier}") server = self._servers.get_server_by_discord_id(ctx.guild.id) - user = self._users.get_user_by_discord_id_and_server_id( - ctx.author.id, server.id - ) + user = self._users.get_user_by_discord_id_and_server_id(ctx.author.id, server.id) api_key = ApiKey(identifier, str(uuid.uuid4()), user) self._api_keys.add_api_key(api_key) self._db.save_changes() @@ -137,21 +125,15 @@ class ApiKeyGroup(DiscordCommandABC): api_key = keys.single() self._api_keys.delete_api_key(api_key) self._db.save_changes() - await self._message_service.send_ctx_msg( - ctx, self._t.transform("modules.technician.api_key.remove.success") - ) + await self._message_service.send_ctx_msg(ctx, self._t.transform("modules.technician.api_key.remove.success")) self._logger.trace(__name__, f"Finished command api-key remove") @remove.autocomplete("key") - async def set_autocomplete( - self, interaction: discord.Interaction, current: str - ) -> TList[app_commands.Choice[str]]: + async def set_autocomplete(self, interaction: discord.Interaction, current: str) -> TList[app_commands.Choice[str]]: keys = self._api_keys.get_api_keys() return [ app_commands.Choice(name=f"{key.identifier}: {key.key}", value=key.key) - for key in self._client_utils.get_auto_complete_list( - keys, current, lambda x: x.key - ) + for key in self._client_utils.get_auto_complete_list(keys, current, lambda x: x.key) ] diff --git a/bot/src/modules/technician/command/log_command.py b/bot/src/modules/technician/command/log_command.py index 27e8c557..2f799d61 100644 --- a/bot/src/modules/technician/command/log_command.py +++ b/bot/src/modules/technician/command/log_command.py @@ -98,10 +98,7 @@ class LogCommand(DiscordCommandABC): continue split_filename = file.split(".") - if ( - f".{split_filename[len(split_filename) - 1]}" - not in file_extensions - ): + if f".{split_filename[len(split_filename) - 1]}" not in file_extensions: continue files.append(os.path.join(r, file)) diff --git a/bot/src/modules/technician/command/restart_command.py b/bot/src/modules/technician/command/restart_command.py index 102519fd..76fda82c 100644 --- a/bot/src/modules/technician/command/restart_command.py +++ b/bot/src/modules/technician/command/restart_command.py @@ -52,9 +52,7 @@ class RestartCommand(DiscordCommandABC): self._config.add_configuration("IS_RESTART", "true") await self._client_utils.presence_game("common.presence.restart") - await self._message_service.send_ctx_msg( - ctx, self._t.transform("modules.technician.restart_message") - ) + await self._message_service.send_ctx_msg(ctx, self._t.transform("modules.technician.restart_message")) await asyncio.sleep(self._settings.wait_for_restart) await self._data_integrity.check_data_integrity(is_for_shutdown=True) await self._bot.stop_async() diff --git a/bot/src/modules/technician/command/shutdown_command.py b/bot/src/modules/technician/command/shutdown_command.py index 5ddf9603..db2f807a 100644 --- a/bot/src/modules/technician/command/shutdown_command.py +++ b/bot/src/modules/technician/command/shutdown_command.py @@ -51,9 +51,7 @@ class ShutdownCommand(DiscordCommandABC): self._logger.debug(__name__, f"Received command shutdown {ctx}") await self._client_utils.presence_game("common.presence.shutdown") - await self._message_service.send_ctx_msg( - ctx, self._t.transform("modules.technician.shutdown_message") - ) + await self._message_service.send_ctx_msg(ctx, self._t.transform("modules.technician.shutdown_message")) await asyncio.sleep(self._settings.wait_for_shutdown) await self._data_integrity.check_data_integrity(is_for_shutdown=True) await self._bot.stop_async() diff --git a/bot/src/modules/technician/command/sync_xp_command.py b/bot/src/modules/technician/command/sync_xp_command.py index 90e97554..e54a770f 100644 --- a/bot/src/modules/technician/command/sync_xp_command.py +++ b/bot/src/modules/technician/command/sync_xp_command.py @@ -71,28 +71,18 @@ class SyncXpGroup(DiscordCommandABC): if ctx.guild is None: return - settings: ServerConfig = self._config.get_configuration( - f"ServerConfig_{ctx.guild.id}" - ) - if not FeatureFlagsSettings.get_flag_from_dict( - settings.feature_flags, FeatureFlagsEnum.sync_xp - ): - await self._message_service.send_ctx_msg( - ctx, self._t.transform("common.feature_not_activated") - ) + settings: ServerConfig = self._config.get_configuration(f"ServerConfig_{ctx.guild.id}") + if not FeatureFlagsSettings.get_flag_from_dict(settings.feature_flags, FeatureFlagsEnum.sync_xp): + await self._message_service.send_ctx_msg(ctx, self._t.transform("common.feature_not_activated")) return other_server = self._servers.get_server_by_id(server_id) - users_on_other_server = self._users.get_users_by_server_id( - other_server.id - ).where(lambda x: not x.left_server) - discord_ids_on_other_server = users_on_other_server.select( - lambda x: x.discord_id - ) + users_on_other_server = self._users.get_users_by_server_id(other_server.id).where(lambda x: not x.left_server) + discord_ids_on_other_server = users_on_other_server.select(lambda x: x.discord_id) - for user in self._users.get_users_by_server_id( - self._servers.get_server_by_discord_id(ctx.guild.id).id - ).where(lambda x: not x.left_server): + for user in self._users.get_users_by_server_id(self._servers.get_server_by_discord_id(ctx.guild.id).id).where( + lambda x: not x.left_server + ): try: if user.discord_id not in discord_ids_on_other_server: continue @@ -106,21 +96,15 @@ class SyncXpGroup(DiscordCommandABC): user.xp = user_on_other_server.xp self._users.update_user(user) self._db.save_changes() - await self._level_service.check_level( - ctx.guild.get_member(user.discord_id) - ) + await self._level_service.check_level(ctx.guild.get_member(user.discord_id)) except Exception as e: self._logger.error(__name__, f"Cannot sync user {user.name}", e) - await self._message_service.send_ctx_msg( - ctx, self._t.transform("modules.technician.synced_message") - ) + await self._message_service.send_ctx_msg(ctx, self._t.transform("modules.technician.synced_message")) self._logger.trace(__name__, f"Finished sync xp command") @all_members.autocomplete("server_id") - async def list_autocomplete( - self, interaction: discord.Interaction, current: str - ) -> list[app_commands.Choice]: + async def list_autocomplete(self, interaction: discord.Interaction, current: str) -> list[app_commands.Choice]: return [ app_commands.Choice(name=server.name, value=server.id) for server in self._client_utils.get_auto_complete_list( @@ -138,15 +122,9 @@ class SyncXpGroup(DiscordCommandABC): if ctx.guild is None: return - settings: ServerConfig = self._config.get_configuration( - f"ServerConfig_{ctx.guild.id}" - ) - if not FeatureFlagsSettings.get_flag_from_dict( - settings.feature_flags, FeatureFlagsEnum.sync_xp - ): - await self._message_service.send_ctx_msg( - ctx, self._t.transform("common.feature_not_activated") - ) + settings: ServerConfig = self._config.get_configuration(f"ServerConfig_{ctx.guild.id}") + if not FeatureFlagsSettings.get_flag_from_dict(settings.feature_flags, FeatureFlagsEnum.sync_xp): + await self._message_service.send_ctx_msg(ctx, self._t.transform("common.feature_not_activated")) return other_server = self._servers.get_server_by_id(server_id) @@ -169,16 +147,12 @@ class SyncXpGroup(DiscordCommandABC): except Exception as e: self._logger.error(__name__, f"Cannot sync user {user.name}", e) - await self._message_service.send_ctx_msg( - ctx, self._t.transform("modules.technician.synced_message") - ) + await self._message_service.send_ctx_msg(ctx, self._t.transform("modules.technician.synced_message")) await self._level_service.check_level(member) self._logger.trace(__name__, f"Finished sync xp command") @by_member.autocomplete("server_id") - async def list_autocomplete( - self, interaction: discord.Interaction, current: str - ) -> list[app_commands.Choice]: + async def list_autocomplete(self, interaction: discord.Interaction, current: str) -> list[app_commands.Choice]: return [ app_commands.Choice(name=server.name, value=server.id) for server in self._client_utils.get_auto_complete_list( diff --git a/bot/src/modules/technician/technician_module.py b/bot/src/modules/technician/technician_module.py index 77677cc9..8550b7d6 100644 --- a/bot/src/modules/technician/technician_module.py +++ b/bot/src/modules/technician/technician_module.py @@ -18,14 +18,10 @@ class TechnicianModule(ModuleABC): def __init__(self, dc: DiscordCollectionABC): ModuleABC.__init__(self, dc, FeatureFlagsEnum.base_module) - def configure_configuration( - self, config: ConfigurationABC, env: ApplicationEnvironmentABC - ): + def configure_configuration(self, config: ConfigurationABC, env: ApplicationEnvironmentABC): pass - def configure_services( - self, services: ServiceCollectionABC, env: ApplicationEnvironmentABC - ): + def configure_services(self, services: ServiceCollectionABC, env: ApplicationEnvironmentABC): services.add_transient(DataSeederABC, ApiKeySeeder) # commands services.add_transient(RestartCommand) diff --git a/bot/tools/get_version/startup.py b/bot/tools/get_version/startup.py index eaa731d7..8cb6680f 100644 --- a/bot/tools/get_version/startup.py +++ b/bot/tools/get_version/startup.py @@ -14,14 +14,10 @@ class Startup(StartupABC): def configure_configuration( self, configuration: ConfigurationABC, environment: ApplicationEnvironment ) -> ConfigurationABC: - environment.set_working_directory( - os.path.abspath(os.path.join(environment.working_directory, "../../")) - ) + environment.set_working_directory(os.path.abspath(os.path.join(environment.working_directory, "../../"))) configuration.add_json_file(f"cpl-workspace.json", optional=False, output=False) ws: WorkspaceSettings = configuration.get_configuration(WorkspaceSettings) - configuration.add_json_file( - ws.projects[ws.default_project], optional=False, output=False - ) + configuration.add_json_file(ws.projects[ws.default_project], optional=False, output=False) return configuration diff --git a/bot/tools/post_build/post_build_settings.py b/bot/tools/post_build/post_build_settings.py index b1d815da..3c8a789e 100644 --- a/bot/tools/post_build/post_build_settings.py +++ b/bot/tools/post_build/post_build_settings.py @@ -24,9 +24,5 @@ class PostBuildSettings(ConfigurationModelABC): self._keep_config = settings["KeepConfigs"] self._config_paths = settings["ConfigPaths"] except Exception as e: - Console.error( - f"[ ERROR ] [ {__name__} ]: Reading error in {type(self).__name__} settings" - ) - Console.error( - f"[ EXCEPTION ] [ {__name__} ]: {e} -> {traceback.format_exc()}" - ) + Console.error(f"[ ERROR ] [ {__name__} ]: Reading error in {type(self).__name__} settings") + Console.error(f"[ EXCEPTION ] [ {__name__} ]: {e} -> {traceback.format_exc()}") diff --git a/bot/tools/post_build/service/dependencies.py b/bot/tools/post_build/service/dependencies.py index b0362257..060adae4 100644 --- a/bot/tools/post_build/service/dependencies.py +++ b/bot/tools/post_build/service/dependencies.py @@ -54,9 +54,7 @@ class Dependencies: ) for project in self._workspace.projects: - project_file = os.path.join( - self._env.working_directory, self._workspace.projects[project] - ) + project_file = os.path.join(self._env.working_directory, self._workspace.projects[project]) self._config.add_json_file(project_file, output=False, optional=False) project: ProjectSettings = self._config.get_configuration(ProjectSettings) self._add_dependencies(project.dependencies) diff --git a/bot/tools/post_build/startup.py b/bot/tools/post_build/startup.py index 6d5e484d..537f3f2a 100644 --- a/bot/tools/post_build/startup.py +++ b/bot/tools/post_build/startup.py @@ -18,14 +18,10 @@ class Startup(StartupABC): self, configuration: ConfigurationABC, environment: ApplicationEnvironment ) -> ConfigurationABC: configuration.add_json_file(f"appsettings.json", optional=False, output=False) - environment.set_working_directory( - os.path.abspath(os.path.join(environment.working_directory, "../../")) - ) + environment.set_working_directory(os.path.abspath(os.path.join(environment.working_directory, "../../"))) configuration.add_json_file(f"cpl-workspace.json", optional=False, output=False) ws: WorkspaceSettings = configuration.get_configuration(WorkspaceSettings) - configuration.add_json_file( - ws.projects[ws.default_project], optional=False, output=False - ) + configuration.add_json_file(ws.projects[ws.default_project], optional=False, output=False) return configuration diff --git a/bot/tools/set_version/application.py b/bot/tools/set_version/application.py index f773982c..882d819a 100644 --- a/bot/tools/set_version/application.py +++ b/bot/tools/set_version/application.py @@ -22,9 +22,7 @@ class Application(ApplicationABC): self._workspace: WorkspaceSettings = config.get_configuration(WorkspaceSettings) self._git_service: GitService = self._services.get_service(GitService) - self._version_setter: VersionSetterService = self._services.get_service( - VersionSetterService - ) + self._version_setter: VersionSetterService = self._services.get_service(VersionSetterService) self._version_pipe: VersionPipe = self._services.get_service(VersionPipe) def configure(self): @@ -63,15 +61,11 @@ class Application(ApplicationABC): optional=False, output=False, ) - ps: ProjectSettings = self._configuration.get_configuration( - ProjectSettings - ) + ps: ProjectSettings = self._configuration.get_configuration(ProjectSettings) version[VersionSettingsNameEnum.major.value] = ps.version.major version[VersionSettingsNameEnum.minor.value] = ps.version.minor - version[ - VersionSettingsNameEnum.micro.value - ] = f'dev{branch.split("#")[1]}' + version[VersionSettingsNameEnum.micro.value] = f'dev{branch.split("#")[1]}' else: if "." not in branch and "." in suffix: branch = suffix @@ -86,9 +80,7 @@ class Application(ApplicationABC): else: if not suffix.startswith(".") and suffix != "": suffix = f".{suffix}" - version[ - VersionSettingsNameEnum.micro.value - ] = f'{branch.split(".")[2]}{suffix}' + version[VersionSettingsNameEnum.micro.value] = f'{branch.split(".")[2]}{suffix}' except Exception as e: Console.error(f"Branch {branch} does not contain valid version") return @@ -114,18 +106,12 @@ class Application(ApplicationABC): try: skipped = [] for project in self._workspace.projects: - if ( - project not in diff_paths - and String.convert_to_snake_case(project) not in diff_paths - and not force - ): + if project not in diff_paths and String.convert_to_snake_case(project) not in diff_paths and not force: # Console.write_line(f'Skipping {project} due to missing changes') skipped.append(project) continue - Console.write_line( - f"Set dependencies {self._version_pipe.transform(version)} for {project}" - ) + Console.write_line(f"Set dependencies {self._version_pipe.transform(version)} for {project}") self._version_setter.set_dependencies( self._workspace.projects[project], version, @@ -139,12 +125,8 @@ class Application(ApplicationABC): skipped=skipped, ) - Console.write_line( - f"Set version {self._version_pipe.transform(version)} for {project}" - ) - self._version_setter.set_version( - self._workspace.projects[project], version - ) + Console.write_line(f"Set version {self._version_pipe.transform(version)} for {project}") + self._version_setter.set_version(self._workspace.projects[project], version) except Exception as e: Console.error("Version could not be set", traceback.format_exc()) return diff --git a/bot/tools/set_version/startup.py b/bot/tools/set_version/startup.py index 47898325..ce7fb47f 100644 --- a/bot/tools/set_version/startup.py +++ b/bot/tools/set_version/startup.py @@ -19,12 +19,8 @@ class Startup(StartupABC): ) -> ConfigurationABC: configuration.add_json_file("cpl-workspace.json", optional=True, output=False) if configuration.get_configuration(WorkspaceSettings) is None: - environment.set_working_directory( - os.path.join(environment.working_directory, "../../") - ) - configuration.add_json_file( - "cpl-workspace.json", optional=False, output=False - ) + environment.set_working_directory(os.path.join(environment.working_directory, "../../")) + configuration.add_json_file("cpl-workspace.json", optional=False, output=False) return configuration diff --git a/bot/tools/set_version/version_setter_service.py b/bot/tools/set_version/version_setter_service.py index e4b0545d..af019658 100644 --- a/bot/tools/set_version/version_setter_service.py +++ b/bot/tools/set_version/version_setter_service.py @@ -12,9 +12,7 @@ class VersionSetterService: def _read_file(self, file: str) -> dict: project_json = {} - with open( - os.path.join(self._env.working_directory, file), "r", encoding="utf-8" - ) as f: + with open(os.path.join(self._env.working_directory, file), "r", encoding="utf-8") as f: # load json project_json = json.load(f) f.close() @@ -22,9 +20,7 @@ class VersionSetterService: return project_json def _write_file(self, file: str, project_json: dict): - with open( - os.path.join(self._env.working_directory, file), "w", encoding="utf-8" - ) as f: + with open(os.path.join(self._env.working_directory, file), "w", encoding="utf-8") as f: f.write(json.dumps(project_json, indent=2)) f.close() @@ -52,10 +48,7 @@ class VersionSetterService: if ( skipped is not None - and ( - dep_name in skipped - or String.convert_to_snake_case(dep_name) in skipped - ) + and (dep_name in skipped or String.convert_to_snake_case(dep_name) in skipped) or dep_version == "" ): new_deps.append(dependency) -- 2.45.2 From 410049be6ee38bd2c3a12f2f6efb70bbb86793d5 Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Sun, 15 Oct 2023 11:31:28 +0200 Subject: [PATCH 18/58] Updated web build #405 --- web/dockerfile | 2 +- web/package.json | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/web/dockerfile b/web/dockerfile index 106595b5..ff84e5af 100644 --- a/web/dockerfile +++ b/web/dockerfile @@ -1,7 +1,7 @@ FROM nginx:alpine COPY nginx.conf.template /etc/nginx/conf.d/nginx.conf.template RUN rm -rf /usr/share/nginx/html/* -COPY ./dist/kdb-web/ /usr/share/nginx/html +COPY ./dist/web/ /usr/share/nginx/html RUN apk update RUN apk add bash CMD /bin/bash -c "envsubst '\$BOT_CONTAINER_NAME' < /etc/nginx/conf.d/nginx.conf.template > /etc/nginx/nginx.conf; nginx -g 'daemon off;'" diff --git a/web/package.json b/web/package.json index 8312e902..cdce16e1 100644 --- a/web/package.json +++ b/web/package.json @@ -1,5 +1,5 @@ { - "name": "kdb-web", + "name": "web", "version": "1.2.0", "scripts": { "ng": "ng", @@ -52,4 +52,4 @@ "tslib": "^2.4.1", "typescript": "~4.9.5" } -} \ No newline at end of file +} -- 2.45.2 From c9b967b9d0c5a6a64f0781f729602c46603711ea Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Sun, 15 Oct 2023 11:44:06 +0200 Subject: [PATCH 19/58] Changed env var prefix #405 --- bot/src/bot/startup_settings_extension.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bot/src/bot/startup_settings_extension.py b/bot/src/bot/startup_settings_extension.py index caf34f19..ea5cfbca 100644 --- a/bot/src/bot/startup_settings_extension.py +++ b/bot/src/bot/startup_settings_extension.py @@ -17,7 +17,7 @@ class StartupSettingsExtension(StartupExtensionABC): def configure_configuration(self, configuration: ConfigurationABC, environment: ApplicationEnvironmentABC): # this shit has to be done here because we need settings in subsequent startup extensions environment.set_working_directory(os.path.dirname(os.path.realpath(__file__))) - configuration.add_environment_variables("KDB_") + configuration.add_environment_variables("SDB_") configuration.add_environment_variables("DISCORD_") configuration.add_json_file(f"config/appsettings.json", optional=False) -- 2.45.2 From b8d27cc682e84232e528676e7520290d261c366f Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Sun, 15 Oct 2023 16:18:09 +0200 Subject: [PATCH 20/58] Fixed sorting --- bot/src/bot/bot.json | 3 ++- web/package-lock.json | 4 ++-- web/package.json | 2 +- web/src/app/modules/shared/base/hideable-component.ts | 4 +++- .../components/hideable-header/hideable-header.component.html | 2 +- .../app/modules/view/server/members/members.component.html | 4 ++-- 6 files changed, 11 insertions(+), 8 deletions(-) diff --git a/bot/src/bot/bot.json b/bot/src/bot/bot.json index f732df34..96b50f38 100644 --- a/bot/src/bot/bot.json +++ b/bot/src/bot/bot.json @@ -31,7 +31,8 @@ "icmplib==3.0.4", "ariadne==0.20.1", "cryptography==41.0.4", - "discord==2.3.2" + "discord==2.3.2", + "bs4==0.0.1" ], "DevDependencies": [ "cpl-cli==2023.4.0.post3", diff --git a/web/package-lock.json b/web/package-lock.json index aa28d9bb..b19c0429 100644 --- a/web/package-lock.json +++ b/web/package-lock.json @@ -1,11 +1,11 @@ { - "name": "kdb-web", + "name": "web", "version": "1.2.0", "lockfileVersion": 3, "requires": true, "packages": { "": { - "name": "kdb-web", + "name": "web", "version": "1.2.0", "dependencies": { "@angular/animations": "^15.1.4", diff --git a/web/package.json b/web/package.json index cdce16e1..dce1efde 100644 --- a/web/package.json +++ b/web/package.json @@ -52,4 +52,4 @@ "tslib": "^2.4.1", "typescript": "~4.9.5" } -} +} \ No newline at end of file diff --git a/web/src/app/modules/shared/base/hideable-component.ts b/web/src/app/modules/shared/base/hideable-component.ts index 4421ff91..3626eb48 100644 --- a/web/src/app/modules/shared/base/hideable-component.ts +++ b/web/src/app/modules/shared/base/hideable-component.ts @@ -5,9 +5,11 @@ import { ComponentWithTable } from "../../../base/component-with-table"; export class HideableComponent { @HostBinding("class.hidden-column") get hidden() { - return !(this.parent?.isColumnVisible(this.column) ?? true); + const column = this.subColumn ?? this.column; + return !(this.parent?.isColumnVisible(column) ?? true); }; @Input() column!: string; + @Input() subColumn!: string; @Input() parent!: ComponentWithTable; } diff --git a/web/src/app/modules/shared/components/hideable-header/hideable-header.component.html b/web/src/app/modules/shared/components/hideable-header/hideable-header.component.html index f35a2a42..dd36bef3 100644 --- a/web/src/app/modules/shared/components/hideable-header/hideable-header.component.html +++ b/web/src/app/modules/shared/components/hideable-header/hideable-header.component.html @@ -2,7 +2,7 @@ -
+
diff --git a/web/src/app/modules/view/server/members/members.component.html b/web/src/app/modules/view/server/members/members.component.html index cb4271ed..ba4baabd 100644 --- a/web/src/app/modules/view/server/members/members.component.html +++ b/web/src/app/modules/view/server/members/members.component.html @@ -72,10 +72,10 @@
- +
{{'common.level' | translate}}
- +
-- 2.45.2 From 71c091c22603ec522eac8f6893e7760edbabdcce Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Sun, 22 Oct 2023 11:57:10 +0200 Subject: [PATCH 21/58] Added todo comment --- bot/src/modules/special_offers/steam_offer_watcher.py | 1 + 1 file changed, 1 insertion(+) diff --git a/bot/src/modules/special_offers/steam_offer_watcher.py b/bot/src/modules/special_offers/steam_offer_watcher.py index d2cd2317..debce24b 100644 --- a/bot/src/modules/special_offers/steam_offer_watcher.py +++ b/bot/src/modules/special_offers/steam_offer_watcher.py @@ -110,6 +110,7 @@ class SteamOfferWatcher(TaskABC): # sale_count = self._get_max_count() + 100 sale_count = 500 # only look at first 500 + # todo: let admins change the value self._logger.debug(__name__, f"Get special offers from 0 to {sale_count}") for i in range(0, sale_count, 100): new_offers.extend(self._get_games_from_page(i, 100)) -- 2.45.2 From a113e21e19e990553a8c8514625df0eff279a3a4 Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Sun, 22 Oct 2023 12:04:14 +0200 Subject: [PATCH 22/58] Fixed angular.json --- web/angular.json | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/web/angular.json b/web/angular.json index 95493524..6c5de2a0 100644 --- a/web/angular.json +++ b/web/angular.json @@ -3,7 +3,7 @@ "version": 1, "newProjectRoot": "projects", "projects": { - "kdb-web": { + "web": { "projectType": "application", "schematics": { "@schematics/angular:component": { @@ -20,7 +20,7 @@ "build": { "builder": "@angular-devkit/build-angular:browser", "options": { - "outputPath": "dist/kdb-web", + "outputPath": "dist/web", "index": "src/index.html", "main": "src/main.ts", "polyfills": "src/polyfills.ts", @@ -86,10 +86,10 @@ "builder": "@angular-devkit/build-angular:dev-server", "configurations": { "production": { - "browserTarget": "kdb-web:build:production" + "browserTarget": "web:build:production" }, "development": { - "browserTarget": "kdb-web:build:development" + "browserTarget": "web:build:development" } }, "defaultConfiguration": "development" @@ -97,7 +97,7 @@ "extract-i18n": { "builder": "@angular-devkit/build-angular:extract-i18n", "options": { - "browserTarget": "kdb-web:build" + "browserTarget": "web:build" } }, "test": { -- 2.45.2 From 403c169b7198908b00b6533caf86043f0189b266 Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Sun, 22 Oct 2023 12:29:13 +0200 Subject: [PATCH 23/58] Fixed action --- .gitea/workflows/deploy_dev.yaml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.gitea/workflows/deploy_dev.yaml b/.gitea/workflows/deploy_dev.yaml index 5b7485a1..bba07baf 100644 --- a/.gitea/workflows/deploy_dev.yaml +++ b/.gitea/workflows/deploy_dev.yaml @@ -22,6 +22,8 @@ jobs: - name: Clone Repository uses: https://github.com/actions/checkout@v3 + with: + submodules: true - name: Shutdown stack run: docker stack rm sdb_staging @@ -61,5 +63,5 @@ jobs: portainer-password: "${{ secrets.docker_job }}" portainer-endpoint: 2 name: sdb_staging - file: ./docker-compose.staging.yml + file: ./bot/docker/docker-compose.staging.yml variables: '{}' -- 2.45.2 From 0e679eda321d03907b4ec08233f7babbba77089c Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Sun, 22 Oct 2023 12:38:56 +0200 Subject: [PATCH 24/58] Fixed action --- .gitea/workflows/deploy_dev.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitea/workflows/deploy_dev.yaml b/.gitea/workflows/deploy_dev.yaml index bba07baf..5b1df9c9 100644 --- a/.gitea/workflows/deploy_dev.yaml +++ b/.gitea/workflows/deploy_dev.yaml @@ -63,5 +63,5 @@ jobs: portainer-password: "${{ secrets.docker_job }}" portainer-endpoint: 2 name: sdb_staging - file: ./bot/docker/docker-compose.staging.yml + file: bot/docker/docker-compose.staging.yml variables: '{}' -- 2.45.2 From 74c71abea59cbcd07fa10b04b162c1366b26ef33 Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Sun, 22 Oct 2023 13:39:26 +0200 Subject: [PATCH 25/58] Readded docker --- bot/docker | 1 + 1 file changed, 1 insertion(+) create mode 160000 bot/docker diff --git a/bot/docker b/bot/docker new file mode 160000 index 00000000..f2bd6c12 --- /dev/null +++ b/bot/docker @@ -0,0 +1 @@ +Subproject commit f2bd6c12c0e21e4955821e91f0f851de0ef7583c -- 2.45.2 From 798162fb621e4f36dfe00443277e5de297d427e4 Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Sun, 22 Oct 2023 13:40:40 +0200 Subject: [PATCH 26/58] Readded configs --- bot/src/bot/config | 1 + bot/src/bot_api/config | 1 + 2 files changed, 2 insertions(+) create mode 160000 bot/src/bot/config create mode 160000 bot/src/bot_api/config diff --git a/bot/src/bot/config b/bot/src/bot/config new file mode 160000 index 00000000..aa124934 --- /dev/null +++ b/bot/src/bot/config @@ -0,0 +1 @@ +Subproject commit aa1249341910f2877522a2002df7feea95256749 diff --git a/bot/src/bot_api/config b/bot/src/bot_api/config new file mode 160000 index 00000000..b6ffed4d --- /dev/null +++ b/bot/src/bot_api/config @@ -0,0 +1 @@ +Subproject commit b6ffed4da1f75f5fbad1ce7f312b67f32de010b5 -- 2.45.2 From 6a6d19686c026b934c43bb9ae274bbd374757a96 Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Sun, 22 Oct 2023 14:03:53 +0200 Subject: [PATCH 27/58] Fixed workflow --- .gitea/workflows/deploy_dev.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitea/workflows/deploy_dev.yaml b/.gitea/workflows/deploy_dev.yaml index 5b1df9c9..73f98948 100644 --- a/.gitea/workflows/deploy_dev.yaml +++ b/.gitea/workflows/deploy_dev.yaml @@ -23,6 +23,7 @@ jobs: - name: Clone Repository uses: https://github.com/actions/checkout@v3 with: + token: ${{ secrets.CI_ACCESS_TOKEN }} submodules: true - name: Shutdown stack -- 2.45.2 From 4b5299514347e6ae80a428db13f5a0a6b6aa3208 Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Sun, 22 Oct 2023 14:11:11 +0200 Subject: [PATCH 28/58] Updated image name in stack --- bot/docker | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bot/docker b/bot/docker index f2bd6c12..d4d1a5c1 160000 --- a/bot/docker +++ b/bot/docker @@ -1 +1 @@ -Subproject commit f2bd6c12c0e21e4955821e91f0f851de0ef7583c +Subproject commit d4d1a5c172480874d115ada396885d741da614c2 -- 2.45.2 From 1f1b1f7b65ef2169586bbc1b222b0fa3045046b4 Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Sun, 22 Oct 2023 14:21:33 +0200 Subject: [PATCH 29/58] Fixed docker config --- bot/docker | 2 +- bot/src/bot/config | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/bot/docker b/bot/docker index d4d1a5c1..91461d3c 160000 --- a/bot/docker +++ b/bot/docker @@ -1 +1 @@ -Subproject commit d4d1a5c172480874d115ada396885d741da614c2 +Subproject commit 91461d3ce30d3c61c24a143fadd975a2dddb593a diff --git a/bot/src/bot/config b/bot/src/bot/config index aa124934..aaf03f6b 160000 --- a/bot/src/bot/config +++ b/bot/src/bot/config @@ -1 +1 @@ -Subproject commit aa1249341910f2877522a2002df7feea95256749 +Subproject commit aaf03f6b8e27e7205a344e2dc892d1e501822d46 -- 2.45.2 From c2fa1a1c0041b9e56eed08ce5af1bce5bc47531e Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Sun, 22 Oct 2023 14:26:50 +0200 Subject: [PATCH 30/58] Fixed docker config --- bot/src/bot/config | 2 +- web/package.json | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/bot/src/bot/config b/bot/src/bot/config index aaf03f6b..6f4414ce 160000 --- a/bot/src/bot/config +++ b/bot/src/bot/config @@ -1 +1 @@ -Subproject commit aaf03f6b8e27e7205a344e2dc892d1e501822d46 +Subproject commit 6f4414ce9d0c5999a85144a00623fbd70170ecf7 diff --git a/web/package.json b/web/package.json index dce1efde..86bb83f4 100644 --- a/web/package.json +++ b/web/package.json @@ -11,9 +11,9 @@ "watch": "ng build --watch --configuration development", "test": "ng test", "predocker-build": "npm run update-version", - "docker-build": "export VERSION=$npm_package_version; ng build; docker build -t sh-edraft.de/kdb-web:$VERSION .", - "docker-build-dev": "export VERSION=$npm_package_version; ng build --configuration development; docker build -t sh-edraft.de/kdb-web:$VERSION .", - "docker-build-stage": "export VERSION=$npm_package_version; ng build --configuration staging; docker build -t sh-edraft.de/kdb-web:$VERSION ." + "docker-build": "export VERSION=$npm_package_version; ng build; docker build -t sh-edraft.de/sdb-web:$VERSION .", + "docker-build-dev": "export VERSION=$npm_package_version; ng build --configuration development; docker build -t sh-edraft.de/sdb-web:$VERSION .", + "docker-build-stage": "export VERSION=$npm_package_version; ng build --configuration staging; docker build -t sh-edraft.de/sdb-web:$VERSION ." }, "private": true, "dependencies": { @@ -52,4 +52,4 @@ "tslib": "^2.4.1", "typescript": "~4.9.5" } -} \ No newline at end of file +} -- 2.45.2 From 940a2ed065f453076cbe9edfabac6344ae4c463e Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Sun, 22 Oct 2023 16:29:24 +0200 Subject: [PATCH 31/58] Fixed add user --- bot/src/bot_core/service/data_integrity_service.py | 2 +- bot/src/bot_data/model/user.py | 4 ++-- bot/src/bot_data/service/migration_service.py | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/bot/src/bot_core/service/data_integrity_service.py b/bot/src/bot_core/service/data_integrity_service.py index fc044a9d..eba805e1 100644 --- a/bot/src/bot_core/service/data_integrity_service.py +++ b/bot/src/bot_core/service/data_integrity_service.py @@ -176,7 +176,7 @@ class DataIntegrityService: self._logger.warn(__name__, f"User not found in database: {u.id}") self._logger.debug(__name__, f"Add user: {u.id}") - self._users.add_user(User(u.id, 0, 0, 0, server)) + self._users.add_user(User(u.id, 0, 0, 0, None, server)) self._db_context.save_changes() self._logger.debug(__name__, f"Added User: {u.id}") diff --git a/bot/src/bot_data/model/user.py b/bot/src/bot_data/model/user.py index ed44c58a..c5766eb6 100644 --- a/bot/src/bot_data/model/user.py +++ b/bot/src/bot_data/model/user.py @@ -191,7 +191,7 @@ class User(TableABC): {self._xp}, {self._message_count}, {self._reaction_count}, - '{self._birthday}', + {"NULL" if self._birthday is None else f"'{self._birthday}'"}, {self._server.id} ); """ @@ -205,7 +205,7 @@ class User(TableABC): SET `XP` = {self._xp}, `MessageCount` = {self._message_count}, `ReactionCount` = {self._reaction_count}, - `Birthday` = '{self._birthday}' + `Birthday` = {"NULL" if self._birthday is None else f"'{self._birthday}'"} WHERE `UserId` = {self._user_id}; """ ) diff --git a/bot/src/bot_data/service/migration_service.py b/bot/src/bot_data/service/migration_service.py index dc6436a7..ab347283 100644 --- a/bot/src/bot_data/service/migration_service.py +++ b/bot/src/bot_data/service/migration_service.py @@ -21,7 +21,7 @@ class MigrationService: self._cursor = db.cursor self._migrations: List[MigrationABC] = ( - List(type, MigrationABC.__subclasses__()).order_by(lambda x: x.name).order_by(lambda x: x.prio) + List(type, MigrationABC.__subclasses__()).order_by(lambda x: x.name.split("_")[0]).then_by(lambda x: x.prio) ) def migrate(self): -- 2.45.2 From 09cccd1b89444231e20acd4939ccb4b3c01019d1 Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Mon, 23 Oct 2023 17:09:38 +0200 Subject: [PATCH 32/58] Fixed deps --- bot/src/bot/bot.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bot/src/bot/bot.json b/bot/src/bot/bot.json index 96b50f38..2db04199 100644 --- a/bot/src/bot/bot.json +++ b/bot/src/bot/bot.json @@ -32,7 +32,8 @@ "ariadne==0.20.1", "cryptography==41.0.4", "discord==2.3.2", - "bs4==0.0.1" + "bs4==0.0.1", + "lxml==4.9.3" ], "DevDependencies": [ "cpl-cli==2023.4.0.post3", -- 2.45.2 From 626d0891f91781c4f7437105a14667100b9c9d52 Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Mon, 23 Oct 2023 17:24:31 +0200 Subject: [PATCH 33/58] Fixed config loading query --- web/package.json | 2 +- web/src/app/models/graphql/queries.model.ts | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/web/package.json b/web/package.json index 86bb83f4..c01deb92 100644 --- a/web/package.json +++ b/web/package.json @@ -52,4 +52,4 @@ "tslib": "^2.4.1", "typescript": "~4.9.5" } -} +} \ No newline at end of file diff --git a/web/src/app/models/graphql/queries.model.ts b/web/src/app/models/graphql/queries.model.ts index bbc6a408..69cc22e6 100644 --- a/web/src/app/models/graphql/queries.model.ts +++ b/web/src/app/models/graphql/queries.model.ts @@ -532,6 +532,7 @@ export class Queries { loginMessageChannelId defaultRoleId shortRoleNameOnlySetHighestRole + gameOfferNotificationChatId featureFlags { key value -- 2.45.2 From 90ae55c0d4f8d52ef5b653305925dc2bab895442 Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Mon, 23 Oct 2023 17:36:24 +0200 Subject: [PATCH 34/58] Fixed birthday gql output --- bot/src/bot_graphql/queries/user_query.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bot/src/bot_graphql/queries/user_query.py b/bot/src/bot_graphql/queries/user_query.py index ceeab6d4..a6cffa64 100644 --- a/bot/src/bot_graphql/queries/user_query.py +++ b/bot/src/bot_graphql/queries/user_query.py @@ -56,7 +56,7 @@ class UserQuery(DataQueryWithHistoryABC): self.set_field("xp", self.resolve_xp) self.set_field("messageCount", lambda x, *_: x.message_count) self.set_field("reactionCount", lambda x, *_: x.reaction_count) - self.set_field("birthday", lambda x, *_: x.birthday) + self.set_field("birthday", lambda x, *_: None if x.birthday is None else x.birthday.strftime("%d.%m.%Y")) self.set_field("ontime", self.resolve_ontime) self.set_field("level", self.resolve_level) self.add_collection( -- 2.45.2 From 33006e3d01f33f87de269ab34b839056401577b0 Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Tue, 24 Oct 2023 19:13:47 +0200 Subject: [PATCH 35/58] Added data import & export #407 --- web/package.json | 2 +- web/src/app/base/component-with-table.ts | 86 ++-- .../auth-user/auth-user.component.html | 2 +- .../auth-user/auth-user.component.ts | 4 +- .../data-import-and-export.component.html | 10 + .../data-import-and-export.component.scss | 5 + .../data-import-and-export.component.spec.ts | 23 + .../data-import-and-export.component.ts | 66 +++ web/src/app/modules/shared/shared.module.ts | 5 + .../achievement/achievement.component.html | 4 +- .../achievement/achievement.component.ts | 2 +- .../auto-roles-rules.component.html | 4 +- .../auto-roles-rules.component.ts | 2 +- .../auto-roles/auto-roles.component.html | 4 +- .../auto-roles/auto-roles.component.ts | 2 +- .../components/levels/levels.component.html | 412 ++++++++-------- .../components/levels/levels.component.ts | 444 +++++++++--------- .../server/members/members.component.html | 2 +- .../view/server/members/members.component.ts | 10 +- .../short-role-names.component.html | 4 +- .../short-role-names.component.ts | 2 +- web/src/assets/i18n/de.json | 3 + web/src/assets/i18n/en.json | 3 + web/src/assets/version.json | 2 +- 24 files changed, 617 insertions(+), 486 deletions(-) create mode 100644 web/src/app/modules/shared/components/data-import-and-export/data-import-and-export.component.html create mode 100644 web/src/app/modules/shared/components/data-import-and-export/data-import-and-export.component.scss create mode 100644 web/src/app/modules/shared/components/data-import-and-export/data-import-and-export.component.spec.ts create mode 100644 web/src/app/modules/shared/components/data-import-and-export/data-import-and-export.component.ts diff --git a/web/package.json b/web/package.json index c01deb92..a37690f6 100644 --- a/web/package.json +++ b/web/package.json @@ -1,6 +1,6 @@ { "name": "web", - "version": "1.2.0", + "version": "1.2.dev407", "scripts": { "ng": "ng", "update-version": "ts-node update-version.ts", diff --git a/web/src/app/base/component-with-table.ts b/web/src/app/base/component-with-table.ts index 9386a28f..d38e09c9 100644 --- a/web/src/app/base/component-with-table.ts +++ b/web/src/app/base/component-with-table.ts @@ -1,44 +1,58 @@ +import { Level } from "../models/data/level.model"; + export interface Column { - key: string; - name: string; + key: string; + name: string; } export class ComponentWithTable { - - private _hiddenColumns: Column[] = []; - set hiddenColumns(value: Column[]) { - this._hiddenColumns = value; - localStorage.setItem("hiddenColumns", JSON.stringify(value)); - } - - get hiddenColumns(): Column[] { - return this._hiddenColumns; - } - - public name: string = ""; - public columns: Column[] = []; - - constructor( - name: string, - columns: string[] - ) { - this.name = name; - this.columns = columns.map(column => { - return { key: this.getKey(column), name: column }; - }); - let hiddenColumns = localStorage.getItem("hiddenColumns"); - if (!hiddenColumns) { - localStorage.setItem("hiddenColumns", JSON.stringify([{}])); - hiddenColumns = localStorage.getItem("hiddenColumns") ?? JSON.stringify([{}]); + private _hiddenColumns: Column[] = []; + set hiddenColumns(value: Column[]) { + this._hiddenColumns = value; + localStorage.setItem("hiddenColumns", JSON.stringify(value)); } - this._hiddenColumns = JSON.parse(hiddenColumns); - } - private getKey(column: string): string { - return `${this.name}_${column}`; - } + get hiddenColumns(): Column[] { + return this._hiddenColumns; + } - public isColumnVisible(column: string): boolean { - return !this._hiddenColumns.map(column => column.key).includes(this.getKey(column)); - } + public name: string = ""; + public columns: Column[] = []; + + constructor( + name: string, + columns: string[] + ) { + this.name = name; + this.columns = columns.map(column => { + return { key: this.getKey(column), name: column }; + }); + let hiddenColumns = localStorage.getItem("hiddenColumns"); + if (!hiddenColumns) { + localStorage.setItem("hiddenColumns", JSON.stringify([{}])); + hiddenColumns = localStorage.getItem("hiddenColumns") ?? JSON.stringify([{}]); + } + this._hiddenColumns = JSON.parse(hiddenColumns); + } + + private getKey(column: string): string { + return `${this.name}_${column}`; + } + + public isColumnVisible(column: string): boolean { + return !this._hiddenColumns.map(column => column.key).includes(this.getKey(column)); + } + + public callback = (data: any[]) => { + this.save(data); + }; + + public onRowEditSave(newLevel: any, index: number) { + } + + public save(data: any[]) { + for (let i = 0; i < data.length; i++) { + this.onRowEditSave(data[i], i); + } + } } diff --git a/web/src/app/modules/admin/auth-users/components/auth-user/auth-user.component.html b/web/src/app/modules/admin/auth-users/components/auth-user/auth-user.component.html index a61ff338..a8d34658 100644 --- a/web/src/app/modules/admin/auth-users/components/auth-user/auth-user.component.html +++ b/web/src/app/modules/admin/auth-users/components/auth-user/auth-user.component.html @@ -225,7 +225,7 @@ (click)="deleteUser(user)"> + icon="pi pi-check-circle" (click)="onRowEditSave(user, ri)">
diff --git a/web/src/app/modules/admin/auth-users/components/auth-user/auth-user.component.ts b/web/src/app/modules/admin/auth-users/components/auth-user/auth-user.component.ts index e0df3efb..cb69d8c2 100644 --- a/web/src/app/modules/admin/auth-users/components/auth-user/auth-user.component.ts +++ b/web/src/app/modules/admin/auth-users/components/auth-user/auth-user.component.ts @@ -193,7 +193,7 @@ export class AuthUserComponent extends ComponentWithTable implements OnInit, OnD this.clonedUsers[index] = { ...user }; } - onRowEditSave(table: Table, newUser: AuthUserDTO, index: number) { + public override onRowEditSave(newUser: AuthUserDTO, index: number) { const oldUser = this.clonedUsers[index]; delete this.clonedUsers[index]; @@ -219,7 +219,6 @@ export class AuthUserComponent extends ComponentWithTable implements OnInit, OnD newUser.email == "" ) ) { - table.initRowEdit(newUser); return; } @@ -239,7 +238,6 @@ export class AuthUserComponent extends ComponentWithTable implements OnInit, OnD this.toastService.error(this.translate.instant("admin.auth_users.message.user_already_exists"), this.translate.instant("admin.auth_users.message.user_already_exists_d", { email: newUser.email })); } error.error = null; - table.initRowEdit(newUser); } this.spinnerService.hideSpinner(); diff --git a/web/src/app/modules/shared/components/data-import-and-export/data-import-and-export.component.html b/web/src/app/modules/shared/components/data-import-and-export/data-import-and-export.component.html new file mode 100644 index 00000000..4dc66234 --- /dev/null +++ b/web/src/app/modules/shared/components/data-import-and-export/data-import-and-export.component.html @@ -0,0 +1,10 @@ + + + + diff --git a/web/src/app/modules/shared/components/data-import-and-export/data-import-and-export.component.scss b/web/src/app/modules/shared/components/data-import-and-export/data-import-and-export.component.scss new file mode 100644 index 00000000..f22d5334 --- /dev/null +++ b/web/src/app/modules/shared/components/data-import-and-export/data-import-and-export.component.scss @@ -0,0 +1,5 @@ +:host { + display: flex; + flex-direction: row; +} + diff --git a/web/src/app/modules/shared/components/data-import-and-export/data-import-and-export.component.spec.ts b/web/src/app/modules/shared/components/data-import-and-export/data-import-and-export.component.spec.ts new file mode 100644 index 00000000..6c059443 --- /dev/null +++ b/web/src/app/modules/shared/components/data-import-and-export/data-import-and-export.component.spec.ts @@ -0,0 +1,23 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; + +import { DataImportAndExportComponent } from './data-import-and-export.component'; + +describe('DataImportAndExportComponent', () => { + let component: DataImportAndExportComponent; + let fixture: ComponentFixture; + + beforeEach(async () => { + await TestBed.configureTestingModule({ + declarations: [ DataImportAndExportComponent ] + }) + .compileComponents(); + + fixture = TestBed.createComponent(DataImportAndExportComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/web/src/app/modules/shared/components/data-import-and-export/data-import-and-export.component.ts b/web/src/app/modules/shared/components/data-import-and-export/data-import-and-export.component.ts new file mode 100644 index 00000000..1a4ef75c --- /dev/null +++ b/web/src/app/modules/shared/components/data-import-and-export/data-import-and-export.component.ts @@ -0,0 +1,66 @@ +import { Component, EventEmitter, Input, Output, ViewChild } from "@angular/core"; +import { ToastService } from "../../../../services/toast/toast.service"; +import { TranslateService } from "@ngx-translate/core"; + +interface UploadEvent { + originalEvent: Event; + files: File[]; +} + +@Component({ + selector: "app-data-import-and-export", + templateUrl: "./data-import-and-export.component.html", + styleUrls: ["./data-import-and-export.component.scss"] +}) +export class DataImportAndExportComponent { + + @ViewChild("upload") upload: any; + + private _data: any[] = []; + + @Input() name: string = ""; + + @Input() + set data(data: any[]) { + this._data = data; + this.dataChange.emit(data); + } + + get data(): any[] { + return this._data; + } + + @Output() dataChange: EventEmitter = new EventEmitter(); + @Input() callback!: (data: any[]) => void; + + public constructor( + private toastService: ToastService, + private translate: TranslateService + ) { + + } + + public export() { + const json = JSON.stringify(this.data); + const element = document.createElement("a"); + element.setAttribute("href", "data:application/json;charset=UTF-8," + encodeURIComponent(json)); + element.setAttribute("download", `${this.name}.json`); + element.style.display = "none"; + document.body.appendChild(element); + element.click(); // simulate click + document.body.removeChild(element); + } + + public import(event: { files: File[] }) { + const file = event.files[0]; + const fileReader = new FileReader(); + fileReader.onload = () => { + if (!fileReader.result) return; + this.data = JSON.parse(fileReader.result.toString()); + this.upload.clear(); + this.callback(this.data); + this.toastService.success(this.translate.instant("common.file.uploaded"), this.translate.instant("common.file.uploaded")); + }; + fileReader.readAsText(file, "UTF-8"); + } +} diff --git a/web/src/app/modules/shared/shared.module.ts b/web/src/app/modules/shared/shared.module.ts index f05452c0..d4ce44bf 100644 --- a/web/src/app/modules/shared/shared.module.ts +++ b/web/src/app/modules/shared/shared.module.ts @@ -33,6 +33,8 @@ import { MultiSelectColumnsComponent } from './base/multi-select-columns/multi-s import { FeatureFlagListComponent } from './components/feature-flag-list/feature-flag-list.component'; import { InputSwitchModule } from "primeng/inputswitch"; import { CalendarModule } from "primeng/calendar"; +import { DataImportAndExportComponent } from './components/data-import-and-export/data-import-and-export.component'; +import { FileUploadModule } from "primeng/fileupload"; const PrimeNGModules = [ @@ -61,6 +63,7 @@ const PrimeNGModules = [ MultiSelectModule, InputSwitchModule, CalendarModule, + FileUploadModule, ] @NgModule({ @@ -74,6 +77,7 @@ const PrimeNGModules = [ HideableHeaderComponent, MultiSelectColumnsComponent, FeatureFlagListComponent, + DataImportAndExportComponent, ], imports: [ CommonModule, @@ -91,6 +95,7 @@ const PrimeNGModules = [ HideableHeaderComponent, MultiSelectColumnsComponent, FeatureFlagListComponent, + DataImportAndExportComponent ] }) export class SharedModule { diff --git a/web/src/app/modules/view/server/achievements/components/achievement/achievement.component.html b/web/src/app/modules/view/server/achievements/components/achievement/achievement.component.html index a84d3fbc..823db3e1 100644 --- a/web/src/app/modules/view/server/achievements/components/achievement/achievement.component.html +++ b/web/src/app/modules/view/server/achievements/components/achievement/achievement.component.html @@ -27,6 +27,8 @@ +
@@ -246,7 +248,7 @@ (click)="deleteAchievement(achievement)" [disabled]="!user || !user.isModerator && !user.isAdmin"> + icon="pi pi-check-circle" (click)="onRowEditSave(achievement, ri)" [disabled]="!user || !user.isModerator && !user.isAdmin"> diff --git a/web/src/app/modules/view/server/achievements/components/achievement/achievement.component.ts b/web/src/app/modules/view/server/achievements/components/achievement/achievement.component.ts index 96625572..18f03c2b 100644 --- a/web/src/app/modules/view/server/achievements/components/achievement/achievement.component.ts +++ b/web/src/app/modules/view/server/achievements/components/achievement/achievement.component.ts @@ -215,7 +215,7 @@ export class AchievementComponent extends ComponentWithTable implements OnInit, this.clonedAchievements[index] = { ...user }; } - public onRowEditSave(table: Table, newAchievement: Achievement, index: number): void { + public override onRowEditSave(newAchievement: Achievement, index: number): void { if (this.isEditingNew && JSON.stringify(newAchievement) === JSON.stringify(this.newAchievementTemplate)) { this.isEditingNew = false; this.achievements.splice(index, 1); diff --git a/web/src/app/modules/view/server/auto-role/components/auto-roles-rules/auto-roles-rules.component.html b/web/src/app/modules/view/server/auto-role/components/auto-roles-rules/auto-roles-rules.component.html index 432bdfae..638c8ad3 100644 --- a/web/src/app/modules/view/server/auto-role/components/auto-roles-rules/auto-roles-rules.component.html +++ b/web/src/app/modules/view/server/auto-role/components/auto-roles-rules/auto-roles-rules.component.html @@ -26,6 +26,8 @@ + @@ -174,7 +176,7 @@ (click)="deleteAutoRoleRule(autoRoleRule)"> + icon="pi pi-check-circle" (click)="onRowEditSave(autoRoleRule, ri)"> diff --git a/web/src/app/modules/view/server/auto-role/components/auto-roles-rules/auto-roles-rules.component.ts b/web/src/app/modules/view/server/auto-role/components/auto-roles-rules/auto-roles-rules.component.ts index f19a8c2f..a8fda8d6 100644 --- a/web/src/app/modules/view/server/auto-role/components/auto-roles-rules/auto-roles-rules.component.ts +++ b/web/src/app/modules/view/server/auto-role/components/auto-roles-rules/auto-roles-rules.component.ts @@ -203,7 +203,7 @@ export class AutoRolesRulesComponent extends ComponentWithTable implements OnIni this.clonedUsers[index] = { ...autoRoleRule }; } - public onRowEditSave(table: Table, newAutoRoleRule: AutoRoleRule, index: number): void { + public override onRowEditSave(newAutoRoleRule: AutoRoleRule, index: number): void { if (this.isEditingNew && JSON.stringify(newAutoRoleRule) === JSON.stringify(this.newAutoRoleTemplate)) { this.isEditingNew = false; this.rules.splice(index, 1); diff --git a/web/src/app/modules/view/server/auto-role/components/auto-roles/auto-roles.component.html b/web/src/app/modules/view/server/auto-role/components/auto-roles/auto-roles.component.html index 12f1448c..7784981d 100644 --- a/web/src/app/modules/view/server/auto-role/components/auto-roles/auto-roles.component.html +++ b/web/src/app/modules/view/server/auto-role/components/auto-roles/auto-roles.component.html @@ -27,6 +27,8 @@ + @@ -209,7 +211,7 @@ (click)="deleteAutoRole(autoRole)"> + icon="pi pi-check-circle" (click)="onRowEditSave(autoRole, ri)"> diff --git a/web/src/app/modules/view/server/auto-role/components/auto-roles/auto-roles.component.ts b/web/src/app/modules/view/server/auto-role/components/auto-roles/auto-roles.component.ts index 2c77fede..c5b26460 100644 --- a/web/src/app/modules/view/server/auto-role/components/auto-roles/auto-roles.component.ts +++ b/web/src/app/modules/view/server/auto-role/components/auto-roles/auto-roles.component.ts @@ -192,7 +192,7 @@ export class AutoRolesComponent extends ComponentWithTable implements OnInit, On this.clonedUsers[index] = { ...autoRole }; } - public onRowEditSave(table: Table, newAutoRole: AutoRole, index: number): void { + public override onRowEditSave(newAutoRole: AutoRole, index: number): void { if (this.isEditingNew && JSON.stringify(newAutoRole) === JSON.stringify(this.newAutoRoleTemplate)) { this.isEditingNew = false; this.auto_roles.splice(index, 1); diff --git a/web/src/app/modules/view/server/levels/components/levels/levels.component.html b/web/src/app/modules/view/server/levels/components/levels/levels.component.html index 5d9f5912..329fcd3b 100644 --- a/web/src/app/modules/view/server/levels/components/levels/levels.component.html +++ b/web/src/app/modules/view/server/levels/components/levels/levels.component.html @@ -1,226 +1,238 @@

- {{'view.server.levels.header' | translate}} + {{'view.server.levels.header' | translate}}

-
- +
+ - -
-
-
- {{levels.length}} {{'common.of' | translate}} - {{dt.totalRecords}} - - {{'view.server.levels.levels' | translate}} -
+ +
+
+
+ {{levels.length}} {{'common.of' | translate}} + {{dt.totalRecords}} + + {{'view.server.levels.levels' | translate}} +
- -
+ +
-
- - -
-
- +
+ + + +
+
+
- - - -
-
{{'common.id' | translate}}
- -
- + + + +
+
{{'common.id' | translate}}
+ +
+ - -
-
{{'common.name' | translate}}
- -
- + +
+
{{'common.name' | translate}}
+ +
+ - -
-
{{'common.color' | translate}}
- -
- + +
+
{{'common.color' | translate}}
+ +
+ - -
-
{{'common.min_xp' | translate}}
- -
- + +
+
{{'common.min_xp' | translate}}
+ +
+ - -
-
{{'common.permissions' | translate}}
- -
- + +
+
{{'common.permissions' | translate}}
+ +
+ - -
-
{{'common.created_at' | translate}}
-
- + +
+
{{'common.created_at' | translate}}
+
+ - -
-
{{'common.modified_at' | translate}}
-
- + +
+
{{'common.modified_at' | translate}}
+
+ - -
-
{{'common.actions' | translate}}
-
- - + +
+
{{'common.actions' | translate}}
+
+ + - - -
- -
- - -
- -
- - - - - - - - -
+ + +
+ +
+ + +
+ +
+ + + + + + + + +
- - - - {{'common.id' | translate}}: - - - {{level.id}} - - - {{level.id}} - - - + + + + {{'common.id' | translate}}: + + + {{level.id}} + + + {{level.id}} + + + - - {{'common.name' | translate}}: - - - - - - {{level.name}} - - - + + {{'common.name' | translate}}: + + + + + + {{level.name}} + + + - - {{'common.color' | translate}}: - - - - - - {{level.color}} - - - + + {{'common.color' | translate}}: + + + + + + {{level.color}} + + + - - {{'common.min_xp' | translate}}: - - - - - - {{level.minXp}} - - - + + {{'common.min_xp' | translate}}: + + + + + + {{level.minXp}} + + + - - {{'common.permissions' | translate}}: - - - - - - {{level.permissions}} - - - + + {{'common.permissions' | translate}}: + + + + + + {{level.permissions}} + + + - - {{'common.created_at' | translate}}: - - - {{level.createdAt | date:'dd.MM.yy HH:mm'}} - - - {{level.createdAt | date:'dd.MM.yy HH:mm'}} - - - - - {{'common.modified_at' | translate}}: - - - {{level.modifiedAt | date:'dd.MM.yy HH:mm'}} - - - {{level.modifiedAt | date:'dd.MM.yy HH:mm'}} - - - - -
- - - + + {{'common.created_at' | translate}}: + + + {{level.createdAt | date:'dd.MM.yy HH:mm'}} + + + {{level.createdAt | date:'dd.MM.yy HH:mm'}} + + + + + {{'common.modified_at' | translate}}: + + + {{level.modifiedAt | date:'dd.MM.yy HH:mm'}} + + + {{level.modifiedAt | date:'dd.MM.yy HH:mm'}} + + + + +
+ + + - - -
- - - + + +
+ + +
- - - - {{'common.no_entries_found' | translate}} - - - + + + + {{'common.no_entries_found' | translate}} + + + - - -
-
+ + +
+
diff --git a/web/src/app/modules/view/server/levels/components/levels/levels.component.ts b/web/src/app/modules/view/server/levels/components/levels/levels.component.ts index c1b808b2..80f3660a 100644 --- a/web/src/app/modules/view/server/levels/components/levels/levels.component.ts +++ b/web/src/app/modules/view/server/levels/components/levels/levels.component.ts @@ -25,249 +25,241 @@ import { UserDTO } from "../../../../../../models/auth/auth-user.dto"; import { ComponentWithTable } from "../../../../../../base/component-with-table"; @Component({ - selector: "app-levels", - templateUrl: "./levels.component.html", - styleUrls: ["./levels.component.scss"] + selector: "app-levels", + templateUrl: "./levels.component.html", + styleUrls: ["./levels.component.scss"] }) export class LevelsComponent extends ComponentWithTable implements OnInit, OnDestroy { - public levels: Level[] = []; - public loading = true; + public levels: Level[] = []; + public loading = true; - public isEditingNew: boolean = false; + public isEditingNew: boolean = false; - public filterForm!: FormGroup<{ - id: FormControl, - name: FormControl, - color: FormControl, - min_xp: FormControl, - permissions: FormControl, - }>; + public filterForm!: FormGroup<{ + id: FormControl, + name: FormControl, + color: FormControl, + min_xp: FormControl, + permissions: FormControl, + }>; - public filter: LevelFilter = {}; - public page: Page = { - pageSize: undefined, - pageIndex: undefined - }; - public sort: Sort = { - sortColumn: undefined, - sortDirection: undefined - }; + public filter: LevelFilter = {}; + public page: Page = { + pageSize: undefined, + pageIndex: undefined + }; + public sort: Sort = { + sortColumn: undefined, + sortDirection: undefined + }; - public totalRecords: number = 0; + public totalRecords: number = 0; - public clonedLevels: { [s: string]: Level; } = {}; + public clonedLevels: { [s: string]: Level; } = {}; - private unsubscriber = new Subject(); - private server: Server = {}; - public user: UserDTO | null = null; + private unsubscriber = new Subject(); + private server: Server = {}; + public user: UserDTO | null = null; - query: string = Queries.levelWithHistoryQuery; + query: string = Queries.levelWithHistoryQuery; - public constructor( - private authService: AuthService, - private spinner: SpinnerService, - private toastService: ToastService, - private confirmDialog: ConfirmationDialogService, - private fb: FormBuilder, - private translate: TranslateService, - private data: DataService, - private sidebar: SidebarService, - private route: ActivatedRoute - ) { - super("level", ["id", "name", "color", "min_xp", "permissions"]); - } - - public ngOnInit(): void { - this.setFilterForm(); - this.data.getServerFromRoute(this.route).then(async server => { - this.server = server; - this.loadNextPage(); - let authUser = await this.authService.getLoggedInUser(); - this.user = authUser?.users?.find(u => u.server == this.server.id) ?? null; - }); - } - - public ngOnDestroy(): void { - this.unsubscriber.next(); - this.unsubscriber.complete(); - } - - public loadNextPage(): void { - this.loading = true; - this.data.query(Queries.levelQuery, { - serverId: this.server.id, filter: this.filter, page: this.page, sort: this.sort - }, - (data: Query) => { - return data.servers[0]; - } - ).subscribe(data => { - this.totalRecords = data.levelCount; - this.levels = data.levels; - this.spinner.hideSpinner(); - this.loading = false; - }); - } - - public setFilterForm(): void { - this.filterForm = this.fb.group({ - id: new FormControl(null), - name: new FormControl(null), - color: new FormControl(null), - min_xp: new FormControl(null), - permissions: new FormControl(null) - }); - - this.filterForm.valueChanges.pipe( - takeUntil(this.unsubscriber), - debounceTime(600) - ).subscribe(changes => { - if (changes.id) { - this.filter.id = changes.id; - } else { - this.filter.id = undefined; - } - - if (changes.name) { - this.filter.name = changes.name; - } else { - this.filter.name = undefined; - } - - if (this.page.pageSize) - this.page.pageSize = 10; - - if (this.page.pageIndex) - this.page.pageIndex = 0; - - this.loadNextPage(); - }); - } - - public newLevelTemplate: Level = { - createdAt: "", - modifiedAt: "" - }; - - public nextPage(event: LazyLoadEvent): void { - this.page.pageSize = event.rows ?? 0; - if (event.first != null && event.rows != null) - this.page.pageIndex = event.first / event.rows; - this.sort.sortColumn = event.sortField ?? undefined; - this.sort.sortDirection = event.sortOrder === 1 ? SortDirection.ASC : event.sortOrder === -1 ? SortDirection.DESC : SortDirection.ASC; - - this.loadNextPage(); - } - - public resetFilters(): void { - this.filterForm.reset(); - } - - public onRowEditInit(table: Table, user: User, index: number): void { - this.clonedLevels[index] = { ...user }; - } - - public onRowEditSave(table: Table, newLevel: Level, index: number): void { - // const oldUser = this.clonedUsers[index]; - // delete this.clonedUsers[index]; - - // if (JSON.stringify(oldUser) === JSON.stringify(newUser) && !this.isEditingNew) { - // console.log(1, oldUser, newUser, JSON.stringify(oldUser) === JSON.stringify(newUser), !this.isEditingNew); - // return; - // } - - if (this.isEditingNew && JSON.stringify(newLevel) === JSON.stringify(this.newLevelTemplate)) { - this.isEditingNew = false; - this.levels.splice(index, 1); - return; + public constructor( + private authService: AuthService, + private spinner: SpinnerService, + private toastService: ToastService, + private confirmDialog: ConfirmationDialogService, + private fb: FormBuilder, + private translate: TranslateService, + private data: DataService, + private sidebar: SidebarService, + private route: ActivatedRoute + ) { + super("level", ["id", "name", "color", "min_xp", "permissions"]); } - if (!newLevel.id && !this.isEditingNew || !newLevel.minXp && !newLevel?.name && !newLevel?.permissions) { - return; - } - - if (this.isEditingNew) { - this.spinner.showSpinner(); - this.data.mutation(Mutations.createLevel, { - name: newLevel.name, - color: newLevel.color, - minXp: newLevel.minXp, - permissions: newLevel.permissions, - serverId: this.server.id - } - ).pipe(catchError(err => { - this.isEditingNew = false; - this.spinner.hideSpinner(); - return throwError(err); - })).subscribe(result => { - this.isEditingNew = false; - this.spinner.hideSpinner(); - this.toastService.success(this.translate.instant("view.server.levels.message.level_create"), this.translate.instant("view.server.levels.message.level_create_d", { name: result.level.createLevel?.name })); - this.loadNextPage(); - }); - return; - } - - this.spinner.showSpinner(); - this.data.mutation(Mutations.updateLevel, { - id: newLevel.id, - name: newLevel.name, - color: newLevel.color, - minXp: newLevel.minXp, - permissions: newLevel.permissions - } - ).pipe(catchError(err => { - this.spinner.hideSpinner(); - return throwError(err); - })).subscribe(_ => { - this.spinner.hideSpinner(); - this.toastService.success(this.translate.instant("view.server.levels.message.level_update"), this.translate.instant("view.server.levels.message.level_update_d", { name: newLevel.name })); - this.loadNextPage(); - }); - - } - - public onRowEditCancel(index: number): void { - if (this.isEditingNew) { - this.levels.splice(index, 1); - delete this.clonedLevels[index]; - this.isEditingNew = false; - return; - } - - this.levels[index] = this.clonedLevels[index]; - delete this.clonedLevels[index]; - } - - public deleteLevel(level: Level): void { - this.confirmDialog.confirmDialog( - this.translate.instant("view.server.levels.message.level_delete"), this.translate.instant("view.server.levels.message.level_delete_q", { name: level.name }), - () => { - this.spinner.showSpinner(); - this.data.mutation(Mutations.deleteLevel, { - id: level.id - } - ).pipe(catchError(err => { - this.spinner.hideSpinner(); - return throwError(err); - })).subscribe(l => { - this.spinner.hideSpinner(); - this.toastService.success(this.translate.instant("view.server.levels.message.level_deleted"), this.translate.instant("view.server.levels.message.level_deleted_d", { name: level.name })); - this.loadNextPage(); + public ngOnInit(): void { + this.setFilterForm(); + this.data.getServerFromRoute(this.route).then(async server => { + this.server = server; + this.loadNextPage(); + let authUser = await this.authService.getLoggedInUser(); + this.user = authUser?.users?.find(u => u.server == this.server.id) ?? null; }); - }); - } + } - public addLevel(table: Table): void { - const newLevel = JSON.parse(JSON.stringify(this.newLevelTemplate)); + public ngOnDestroy(): void { + this.unsubscriber.next(); + this.unsubscriber.complete(); + } - this.levels = [newLevel, ...this.levels]; + public loadNextPage(): void { + this.loading = true; + this.data.query(Queries.levelQuery, { + serverId: this.server.id, filter: this.filter, page: this.page, sort: this.sort + }, + (data: Query) => { + return data.servers[0]; + } + ).subscribe(data => { + this.totalRecords = data.levelCount; + this.levels = data.levels; + this.spinner.hideSpinner(); + this.loading = false; + }); + } - table.initRowEdit(newLevel); + public setFilterForm(): void { + this.filterForm = this.fb.group({ + id: new FormControl(null), + name: new FormControl(null), + color: new FormControl(null), + min_xp: new FormControl(null), + permissions: new FormControl(null) + }); - const index = this.levels.findIndex(l => l.id == newLevel.id); - this.onRowEditInit(table, newLevel, index); + this.filterForm.valueChanges.pipe( + takeUntil(this.unsubscriber), + debounceTime(600) + ).subscribe(changes => { + if (changes.id) { + this.filter.id = changes.id; + } else { + this.filter.id = undefined; + } - this.isEditingNew = true; - } + if (changes.name) { + this.filter.name = changes.name; + } else { + this.filter.name = undefined; + } + + if (this.page.pageSize) + this.page.pageSize = 10; + + if (this.page.pageIndex) + this.page.pageIndex = 0; + + this.loadNextPage(); + }); + } + + public newLevelTemplate: Level = { + createdAt: "", + modifiedAt: "" + }; + + public nextPage(event: LazyLoadEvent): void { + this.page.pageSize = event.rows ?? 0; + if (event.first != null && event.rows != null) + this.page.pageIndex = event.first / event.rows; + this.sort.sortColumn = event.sortField ?? undefined; + this.sort.sortDirection = event.sortOrder === 1 ? SortDirection.ASC : event.sortOrder === -1 ? SortDirection.DESC : SortDirection.ASC; + + this.loadNextPage(); + } + + public resetFilters(): void { + this.filterForm.reset(); + } + + public onRowEditInit(table: Table, user: User, index: number): void { + this.clonedLevels[index] = { ...user }; + } + + public override onRowEditSave(newLevel: Level, index: number): void { + if (this.isEditingNew && JSON.stringify(newLevel) === JSON.stringify(this.newLevelTemplate)) { + this.isEditingNew = false; + this.levels.splice(index, 1); + return; + } + + if (!newLevel.id && !this.isEditingNew || !newLevel.minXp && !newLevel?.name && !newLevel?.permissions) { + return; + } + + if (this.isEditingNew) { + this.spinner.showSpinner(); + this.data.mutation(Mutations.createLevel, { + name: newLevel.name, + color: newLevel.color, + minXp: newLevel.minXp, + permissions: newLevel.permissions, + serverId: this.server.id + } + ).pipe(catchError(err => { + this.isEditingNew = false; + this.spinner.hideSpinner(); + return throwError(err); + })).subscribe(result => { + this.isEditingNew = false; + this.spinner.hideSpinner(); + this.toastService.success(this.translate.instant("view.server.levels.message.level_create"), this.translate.instant("view.server.levels.message.level_create_d", { name: result.level.createLevel?.name })); + this.loadNextPage(); + }); + return; + } + + this.spinner.showSpinner(); + this.data.mutation(Mutations.updateLevel, { + id: newLevel.id, + name: newLevel.name, + color: newLevel.color, + minXp: newLevel.minXp, + permissions: newLevel.permissions + } + ).pipe(catchError(err => { + this.spinner.hideSpinner(); + return throwError(err); + })).subscribe(_ => { + this.spinner.hideSpinner(); + this.toastService.success(this.translate.instant("view.server.levels.message.level_update"), this.translate.instant("view.server.levels.message.level_update_d", { name: newLevel.name })); + this.loadNextPage(); + }); + + } + + public onRowEditCancel(index: number): void { + if (this.isEditingNew) { + this.levels.splice(index, 1); + delete this.clonedLevels[index]; + this.isEditingNew = false; + return; + } + + this.levels[index] = this.clonedLevels[index]; + delete this.clonedLevels[index]; + } + + public deleteLevel(level: Level): void { + this.confirmDialog.confirmDialog( + this.translate.instant("view.server.levels.message.level_delete"), this.translate.instant("view.server.levels.message.level_delete_q", { name: level.name }), + () => { + this.spinner.showSpinner(); + this.data.mutation(Mutations.deleteLevel, { + id: level.id + } + ).pipe(catchError(err => { + this.spinner.hideSpinner(); + return throwError(err); + })).subscribe(l => { + this.spinner.hideSpinner(); + this.toastService.success(this.translate.instant("view.server.levels.message.level_deleted"), this.translate.instant("view.server.levels.message.level_deleted_d", { name: level.name })); + this.loadNextPage(); + }); + }); + } + + public addLevel(table: Table): void { + const newLevel = JSON.parse(JSON.stringify(this.newLevelTemplate)); + + this.levels = [newLevel, ...this.levels]; + + table.initRowEdit(newLevel); + + const index = this.levels.findIndex(l => l.id == newLevel.id); + this.onRowEditInit(table, newLevel, index); + + this.isEditingNew = true; + } } diff --git a/web/src/app/modules/view/server/members/members.component.html b/web/src/app/modules/view/server/members/members.component.html index ba4baabd..a5b465b2 100644 --- a/web/src/app/modules/view/server/members/members.component.html +++ b/web/src/app/modules/view/server/members/members.component.html @@ -242,7 +242,7 @@ [routerLink]="member.id"> + icon="pi pi-check-circle" (click)="onRowEditSave(member, ri)"> diff --git a/web/src/app/modules/view/server/members/members.component.ts b/web/src/app/modules/view/server/members/members.component.ts index bfb65b75..980de0ca 100644 --- a/web/src/app/modules/view/server/members/members.component.ts +++ b/web/src/app/modules/view/server/members/members.component.ts @@ -213,15 +213,7 @@ export class MembersComponent extends ComponentWithTable implements OnInit, OnDe this.clonedUsers[index] = { ...user }; } - onRowEditSave(table: Table, newUser: User, index: number) { - // const oldUser = this.clonedUsers[index]; - // delete this.clonedUsers[index]; - - // if (JSON.stringify(oldUser) === JSON.stringify(newUser) && !this.isEditingNew) { - // console.log(1, oldUser, newUser, JSON.stringify(oldUser) === JSON.stringify(newUser), !this.isEditingNew); - // return; - // } - + public override onRowEditSave(newUser: User, index: number) { if (this.isEditingNew && JSON.stringify(newUser) === JSON.stringify(this.newUserTemplate)) { this.isEditingNew = false; this.members.splice(index, 1); diff --git a/web/src/app/modules/view/server/short-role-name/components/short-role-names/short-role-names.component.html b/web/src/app/modules/view/server/short-role-name/components/short-role-names/short-role-names.component.html index 0cbc7ead..bb312ecf 100644 --- a/web/src/app/modules/view/server/short-role-name/components/short-role-names/short-role-names.component.html +++ b/web/src/app/modules/view/server/short-role-name/components/short-role-names/short-role-names.component.html @@ -27,6 +27,8 @@ + @@ -192,7 +194,7 @@ (click)="deleteShortRoleName(shortRoleName)"> + icon="pi pi-check-circle" (click)="onRowEditSave(shortRoleName, ri)"> diff --git a/web/src/app/modules/view/server/short-role-name/components/short-role-names/short-role-names.component.ts b/web/src/app/modules/view/server/short-role-name/components/short-role-names/short-role-names.component.ts index cd254446..49665c6a 100644 --- a/web/src/app/modules/view/server/short-role-name/components/short-role-names/short-role-names.component.ts +++ b/web/src/app/modules/view/server/short-role-name/components/short-role-names/short-role-names.component.ts @@ -199,7 +199,7 @@ export class ShortRoleNamesComponent extends ComponentWithTable implements OnIni this.clonedShortRoleNames[index] = { ...user }; } - public onRowEditSave(table: Table, newShortRoleName: ShortRoleName, index: number): void { + public override onRowEditSave(newShortRoleName: ShortRoleName, index: number): void { if (this.isEditingNew && JSON.stringify(newShortRoleName) === JSON.stringify(this.newShortRoleNameTemplate)) { this.isEditingNew = false; this.shortRoleNames.splice(index, 1); diff --git a/web/src/assets/i18n/de.json b/web/src/assets/i18n/de.json index ade9226c..3cb071ed 100644 --- a/web/src/assets/i18n/de.json +++ b/web/src/assets/i18n/de.json @@ -144,6 +144,9 @@ "emoji": "Emoji", "error": "Fehler", "feature_flags": "Funktionen", + "file": { + "uploaded": "Daten wurden erfolgreich importiert." + }, "first_name": "Vorname", "hidden_columns": "Ausgeblendete Spalten", "history": { diff --git a/web/src/assets/i18n/en.json b/web/src/assets/i18n/en.json index 36d7f324..b1a37671 100644 --- a/web/src/assets/i18n/en.json +++ b/web/src/assets/i18n/en.json @@ -144,6 +144,9 @@ "emoji": "Emoji", "error": "Error", "feature_flags": "Features", + "file": { + "uploaded": "Data was imported successfully." + }, "first_name": "First name", "hidden_columns": "Hidden columns", "history": { diff --git a/web/src/assets/version.json b/web/src/assets/version.json index 3ae731e3..c2737cb6 100644 --- a/web/src/assets/version.json +++ b/web/src/assets/version.json @@ -2,6 +2,6 @@ "WebVersion": { "Major": "1", "Minor": "2", - "Micro": "0" + "Micro": "dev407" } } \ No newline at end of file -- 2.45.2 From 1c20bbed66d9ee8d17db77c4e3be91a6c70b41c3 Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Tue, 24 Oct 2023 19:15:59 +0200 Subject: [PATCH 36/58] Added tooltip translation #407 --- web/src/assets/i18n/de.json | 2 ++ web/src/assets/i18n/en.json | 2 ++ 2 files changed, 4 insertions(+) diff --git a/web/src/assets/i18n/de.json b/web/src/assets/i18n/de.json index 3cb071ed..79ed799b 100644 --- a/web/src/assets/i18n/de.json +++ b/web/src/assets/i18n/de.json @@ -143,6 +143,7 @@ "email": "E-Mail", "emoji": "Emoji", "error": "Fehler", + "export": "Exportieren", "feature_flags": "Funktionen", "file": { "uploaded": "Daten wurden erfolgreich importiert." @@ -173,6 +174,7 @@ "xp": "XP" }, "id": "Id", + "import": "Importieren", "joined_at": "Beigetreten am", "last_name": "Nachname", "leaved_at": "Verlassen am", diff --git a/web/src/assets/i18n/en.json b/web/src/assets/i18n/en.json index b1a37671..aed94311 100644 --- a/web/src/assets/i18n/en.json +++ b/web/src/assets/i18n/en.json @@ -143,6 +143,7 @@ "email": "E-Mail", "emoji": "Emoji", "error": "Error", + "export": "Export", "feature_flags": "Features", "file": { "uploaded": "Data was imported successfully." @@ -173,6 +174,7 @@ "xp": "XP" }, "id": "Id", + "import": "Import", "joined_at": "Joined at", "last_name": "Last name", "leaved_at": "Leaved at", -- 2.45.2 From b943b9a7eda34173e3fbb142daa5e0802ce58513 Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Tue, 24 Oct 2023 19:21:16 +0200 Subject: [PATCH 37/58] Fixed version #407 --- web/package.json | 4 ++-- web/src/assets/version.json | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/web/package.json b/web/package.json index a37690f6..86bb83f4 100644 --- a/web/package.json +++ b/web/package.json @@ -1,6 +1,6 @@ { "name": "web", - "version": "1.2.dev407", + "version": "1.2.0", "scripts": { "ng": "ng", "update-version": "ts-node update-version.ts", @@ -52,4 +52,4 @@ "tslib": "^2.4.1", "typescript": "~4.9.5" } -} \ No newline at end of file +} diff --git a/web/src/assets/version.json b/web/src/assets/version.json index c2737cb6..c6ada89c 100644 --- a/web/src/assets/version.json +++ b/web/src/assets/version.json @@ -2,6 +2,6 @@ "WebVersion": { "Major": "1", "Minor": "2", - "Micro": "dev407" + "Micro": "0" } -} \ No newline at end of file +} -- 2.45.2 From 79278d8f4b9c9b029817270065c6f0f2a60482e1 Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Tue, 24 Oct 2023 19:38:30 +0200 Subject: [PATCH 38/58] Fixed sync by member command --- bot/src/modules/technician/command/sync_xp_command.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bot/src/modules/technician/command/sync_xp_command.py b/bot/src/modules/technician/command/sync_xp_command.py index e54a770f..f2d3e06a 100644 --- a/bot/src/modules/technician/command/sync_xp_command.py +++ b/bot/src/modules/technician/command/sync_xp_command.py @@ -129,7 +129,8 @@ class SyncXpGroup(DiscordCommandABC): other_server = self._servers.get_server_by_id(server_id) user = self._users.get_user_by_discord_id_and_server_id( - self._servers.get_server_by_discord_id(ctx.guild.id).id, member.id + member.id, + self._servers.get_server_by_discord_id(ctx.guild.id).id ) try: -- 2.45.2 From 2d358188af598831b8fe5b5196d76a3e93eb177a Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Wed, 1 Nov 2023 16:29:08 +0100 Subject: [PATCH 39/58] Fixed formatting --- bot/src/modules/technician/command/sync_xp_command.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/bot/src/modules/technician/command/sync_xp_command.py b/bot/src/modules/technician/command/sync_xp_command.py index f2d3e06a..a14bd8ac 100644 --- a/bot/src/modules/technician/command/sync_xp_command.py +++ b/bot/src/modules/technician/command/sync_xp_command.py @@ -129,8 +129,7 @@ class SyncXpGroup(DiscordCommandABC): other_server = self._servers.get_server_by_id(server_id) user = self._users.get_user_by_discord_id_and_server_id( - member.id, - self._servers.get_server_by_discord_id(ctx.guild.id).id + member.id, self._servers.get_server_by_discord_id(ctx.guild.id).id ) try: -- 2.45.2 From 84fedfaa0ba097dee881af62d597ebc622a75ee0 Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Wed, 1 Nov 2023 22:37:33 +0100 Subject: [PATCH 40/58] Improved data validation for import --- .../bot_graphql/mutations/level_mutation.py | 3 + web/src/app/base/component-with-table.ts | 103 +++-- .../auth-user/auth-user.component.ts | 1 - .../data-import-and-export.component.ts | 110 +++-- .../achievement/achievement.component.html | 2 +- .../achievement/achievement.component.ts | 15 +- .../auto-roles-rules.component.html | 2 +- .../auto-roles-rules.component.ts | 8 +- .../auto-roles/auto-roles.component.html | 2 +- .../auto-roles/auto-roles.component.ts | 6 +- .../components/levels/levels.component.html | 2 +- .../components/levels/levels.component.ts | 418 +++++++++--------- .../view/server/members/members.component.ts | 1 - .../short-role-names.component.html | 2 +- .../short-role-names.component.ts | 7 +- 15 files changed, 361 insertions(+), 321 deletions(-) diff --git a/bot/src/bot_graphql/mutations/level_mutation.py b/bot/src/bot_graphql/mutations/level_mutation.py index 215538b7..e0959c55 100644 --- a/bot/src/bot_graphql/mutations/level_mutation.py +++ b/bot/src/bot_graphql/mutations/level_mutation.py @@ -41,6 +41,9 @@ class LevelMutation(QueryABC): int(input["permissions"]), server, ) + levels = self._levels.get_levels_by_server_id(server.id) + if levels.where(lambda x: x.name == level.name).count() > 0: + raise ValueError(f"Level with name {level.name} already exists") self._levels.add_level(level) self._db.save_changes() diff --git a/web/src/app/base/component-with-table.ts b/web/src/app/base/component-with-table.ts index d38e09c9..acafbaa4 100644 --- a/web/src/app/base/component-with-table.ts +++ b/web/src/app/base/component-with-table.ts @@ -1,58 +1,65 @@ -import { Level } from "../models/data/level.model"; - export interface Column { - key: string; - name: string; + key: string; + name: string; } export class ComponentWithTable { - private _hiddenColumns: Column[] = []; - set hiddenColumns(value: Column[]) { - this._hiddenColumns = value; - localStorage.setItem("hiddenColumns", JSON.stringify(value)); + private _hiddenColumns: Column[] = []; + set hiddenColumns(value: Column[]) { + this._hiddenColumns = value; + localStorage.setItem("hiddenColumns", JSON.stringify(value)); + } + + get hiddenColumns(): Column[] { + return this._hiddenColumns; + } + + public name: string = ""; + public columns: Column[] = []; + public isEditingNew: boolean = false; + + public callback = (data: any[], isNew: boolean) => { + this.save(data, isNew); + }; + public validator: (oldElement: any, newElement: any) => boolean = (oldElement: any, newElement: any) => { + return true; + }; + + constructor( + name: string, + columns: string[], + validator?: (oldElement: any, newElement: any) => boolean + ) { + this.name = name; + this.columns = columns.map(column => { + return { key: this.getKey(column), name: column }; + }); + let hiddenColumns = localStorage.getItem("hiddenColumns"); + if (!hiddenColumns) { + localStorage.setItem("hiddenColumns", JSON.stringify([{}])); + hiddenColumns = localStorage.getItem("hiddenColumns") ?? JSON.stringify([{}]); } - - get hiddenColumns(): Column[] { - return this._hiddenColumns; + this._hiddenColumns = JSON.parse(hiddenColumns); + if (validator) { + this.validator = validator; } + } - public name: string = ""; - public columns: Column[] = []; + private getKey(column: string): string { + return `${this.name}_${column}`; + } - constructor( - name: string, - columns: string[] - ) { - this.name = name; - this.columns = columns.map(column => { - return { key: this.getKey(column), name: column }; - }); - let hiddenColumns = localStorage.getItem("hiddenColumns"); - if (!hiddenColumns) { - localStorage.setItem("hiddenColumns", JSON.stringify([{}])); - hiddenColumns = localStorage.getItem("hiddenColumns") ?? JSON.stringify([{}]); - } - this._hiddenColumns = JSON.parse(hiddenColumns); - } - - private getKey(column: string): string { - return `${this.name}_${column}`; - } - - public isColumnVisible(column: string): boolean { - return !this._hiddenColumns.map(column => column.key).includes(this.getKey(column)); - } - - public callback = (data: any[]) => { - this.save(data); - }; - - public onRowEditSave(newLevel: any, index: number) { - } - - public save(data: any[]) { - for (let i = 0; i < data.length; i++) { - this.onRowEditSave(data[i], i); - } + public isColumnVisible(column: string): boolean { + return !this._hiddenColumns.map(column => column.key).includes(this.getKey(column)); + } + + public onRowEditSave(newLevel: any, index: number) { + } + + public save(data: any[], isNew: boolean) { + for (let i = 0; i < data.length; i++) { + this.isEditingNew = isNew; + this.onRowEditSave(data[i], i); } + } } diff --git a/web/src/app/modules/admin/auth-users/components/auth-user/auth-user.component.ts b/web/src/app/modules/admin/auth-users/components/auth-user/auth-user.component.ts index cb69d8c2..faec3c9a 100644 --- a/web/src/app/modules/admin/auth-users/components/auth-user/auth-user.component.ts +++ b/web/src/app/modules/admin/auth-users/components/auth-user/auth-user.component.ts @@ -31,7 +31,6 @@ export class AuthUserComponent extends ComponentWithTable implements OnInit, OnD activityValues: number[] = [0, 100]; clonedUsers: { [s: string]: AuthUserDTO; } = {}; - isEditingNew: boolean = false; authRoles = [ { label: AuthRoles[AuthRoles.Normal].toString(), value: AuthRoles.Normal }, diff --git a/web/src/app/modules/shared/components/data-import-and-export/data-import-and-export.component.ts b/web/src/app/modules/shared/components/data-import-and-export/data-import-and-export.component.ts index 1a4ef75c..8bab8927 100644 --- a/web/src/app/modules/shared/components/data-import-and-export/data-import-and-export.component.ts +++ b/web/src/app/modules/shared/components/data-import-and-export/data-import-and-export.component.ts @@ -1,66 +1,86 @@ import { Component, EventEmitter, Input, Output, ViewChild } from "@angular/core"; import { ToastService } from "../../../../services/toast/toast.service"; import { TranslateService } from "@ngx-translate/core"; +import { elementAt } from "rxjs"; interface UploadEvent { - originalEvent: Event; - files: File[]; + originalEvent: Event; + files: File[]; } @Component({ - selector: "app-data-import-and-export", - templateUrl: "./data-import-and-export.component.html", - styleUrls: ["./data-import-and-export.component.scss"] + selector: "app-data-import-and-export", + templateUrl: "./data-import-and-export.component.html", + styleUrls: ["./data-import-and-export.component.scss"] }) export class DataImportAndExportComponent { - @ViewChild("upload") upload: any; + @ViewChild("upload") upload: any; - private _data: any[] = []; + private _data: any[] = []; - @Input() name: string = ""; + @Input() name: string = ""; - @Input() - set data(data: any[]) { - this._data = data; - this.dataChange.emit(data); - } + @Input() + set data(data: any[]) { + this._data = data; + this.dataChange.emit(data); + } - get data(): any[] { - return this._data; - } + get data(): any[] { + return this._data; + } - @Output() dataChange: EventEmitter = new EventEmitter(); - @Input() callback!: (data: any[]) => void; + @Output() dataChange: EventEmitter = new EventEmitter(); + @Input() callback!: (data: any[], isNew: boolean) => void; + @Input() validator: (oldElement: any, newElement: any) => boolean = (oldElement: any, newElement: any) => { + return true; + }; - public constructor( - private toastService: ToastService, - private translate: TranslateService - ) { + public constructor( + private toastService: ToastService, + private translate: TranslateService + ) { - } + } - public export() { - const json = JSON.stringify(this.data); - const element = document.createElement("a"); - element.setAttribute("href", "data:application/json;charset=UTF-8," + encodeURIComponent(json)); - element.setAttribute("download", `${this.name}.json`); - element.style.display = "none"; - document.body.appendChild(element); - element.click(); // simulate click - document.body.removeChild(element); - } + public export() { + const json = JSON.stringify(this.data); + const element = document.createElement("a"); + element.setAttribute("href", "data:application/json;charset=UTF-8," + encodeURIComponent(json)); + element.setAttribute("download", `${this.name}.json`); + element.style.display = "none"; + document.body.appendChild(element); + element.click(); // simulate click + document.body.removeChild(element); + } - public import(event: { files: File[] }) { - const file = event.files[0]; - const fileReader = new FileReader(); - fileReader.onload = () => { - if (!fileReader.result) return; - this.data = JSON.parse(fileReader.result.toString()); - this.upload.clear(); - this.callback(this.data); - this.toastService.success(this.translate.instant("common.file.uploaded"), this.translate.instant("common.file.uploaded")); - }; - fileReader.readAsText(file, "UTF-8"); - } + public import(event: { files: File[] }) { + const file = event.files[0]; + const fileReader = new FileReader(); + fileReader.onload = () => { + if (!fileReader.result) return; + const newData: any[] = JSON.parse(fileReader.result.toString()); + this.upload.clear(); + newData.forEach(element => { + element.id = 0; + }); + this.data.forEach(element => { + const existingElement = newData.find(x => this.validator(x, element)); + if (existingElement) { + const index = this.data.indexOf(element); + const oldId = element.id; + element = existingElement; + element.id = oldId; + this.data[index] = element; + newData.splice(newData.indexOf(existingElement), 1); + } + }); + this.callback(this.data, false); + this.callback(newData, true); + this.data.push(...newData); + this.toastService.success(this.translate.instant("common.file.uploaded"), this.translate.instant("common.file.uploaded")); + }; + fileReader.readAsText(file, "UTF-8"); + } } diff --git a/web/src/app/modules/view/server/achievements/components/achievement/achievement.component.html b/web/src/app/modules/view/server/achievements/components/achievement/achievement.component.html index 823db3e1..45e43f36 100644 --- a/web/src/app/modules/view/server/achievements/components/achievement/achievement.component.html +++ b/web/src/app/modules/view/server/achievements/components/achievement/achievement.component.html @@ -28,7 +28,7 @@ class="icon-btn btn" (click)="resetFilters()"> + [callback]="callback" [validator]="validator"> diff --git a/web/src/app/modules/view/server/achievements/components/achievement/achievement.component.ts b/web/src/app/modules/view/server/achievements/components/achievement/achievement.component.ts index 18f03c2b..e2b6e508 100644 --- a/web/src/app/modules/view/server/achievements/components/achievement/achievement.component.ts +++ b/web/src/app/modules/view/server/achievements/components/achievement/achievement.component.ts @@ -15,7 +15,13 @@ import { TranslateService } from "@ngx-translate/core"; import { DataService } from "../../../../../../services/data/data.service"; import { SidebarService } from "../../../../../../services/sidebar/sidebar.service"; import { ActivatedRoute } from "@angular/router"; -import { AchievementListQuery, AchievementTypeQuery, GameServerListQuery, LevelListQuery, Query } from "../../../../../../models/graphql/query.model"; +import { + AchievementListQuery, + AchievementTypeQuery, + GameServerListQuery, + LevelListQuery, + Query +} from "../../../../../../models/graphql/query.model"; import { catchError, debounceTime, takeUntil } from "rxjs/operators"; import { LazyLoadEvent, MenuItem } from "primeng/api"; import { Table } from "primeng/table"; @@ -33,8 +39,6 @@ export class AchievementComponent extends ComponentWithTable implements OnInit, public achievements: Achievement[] = []; public loading = true; - public isEditingNew: boolean = false; - public filterForm!: FormGroup<{ id: FormControl, name: FormControl, @@ -81,7 +85,10 @@ export class AchievementComponent extends ComponentWithTable implements OnInit, private data: DataService, private sidebar: SidebarService, private route: ActivatedRoute) { - super("achievement", ["id", "name", "description", "attribute", "operator", "value"]); + super("achievement", ["id", "name", "description", "attribute", "operator", "value"], + (oldElement: Achievement, newElement: Achievement) => { + return oldElement.name === newElement.name; + }); } public ngOnInit(): void { diff --git a/web/src/app/modules/view/server/auto-role/components/auto-roles-rules/auto-roles-rules.component.html b/web/src/app/modules/view/server/auto-role/components/auto-roles-rules/auto-roles-rules.component.html index 638c8ad3..c9abacbc 100644 --- a/web/src/app/modules/view/server/auto-role/components/auto-roles-rules/auto-roles-rules.component.html +++ b/web/src/app/modules/view/server/auto-role/components/auto-roles-rules/auto-roles-rules.component.html @@ -27,7 +27,7 @@ class="icon-btn btn" (click)="resetFilters()"> + [callback]="callback" [validator]="validator"> diff --git a/web/src/app/modules/view/server/auto-role/components/auto-roles-rules/auto-roles-rules.component.ts b/web/src/app/modules/view/server/auto-role/components/auto-roles-rules/auto-roles-rules.component.ts index a8fda8d6..d9bc9061 100644 --- a/web/src/app/modules/view/server/auto-role/components/auto-roles-rules/auto-roles-rules.component.ts +++ b/web/src/app/modules/view/server/auto-role/components/auto-roles-rules/auto-roles-rules.component.ts @@ -1,7 +1,7 @@ import { Component, OnDestroy, OnInit } from "@angular/core"; import { DataService } from "../../../../../../services/data/data.service"; import { ActivatedRoute, Router } from "@angular/router"; -import { AutoRoleRule, AutoRoleRuleFilter } from "../../../../../../models/data/auto_role.model"; +import { AutoRole, AutoRoleRule, AutoRoleRuleFilter } from "../../../../../../models/data/auto_role.model"; import { Guild } from "../../../../../../models/data/discord.model"; import { LazyLoadEvent, MenuItem } from "primeng/api"; import { User } from "../../../../../../models/data/user.model"; @@ -40,7 +40,6 @@ export class AutoRolesRulesComponent extends ComponentWithTable implements OnIni autoRoleId!: number; clonedUsers: { [s: string]: User; } = {}; - isEditingNew: boolean = false; newAutoRoleTemplate: AutoRoleRule = { createdAt: "", @@ -81,7 +80,10 @@ export class AutoRolesRulesComponent extends ComponentWithTable implements OnIni private route: ActivatedRoute, private router: Router ) { - super("auto-role-rules", ["id", "role", "emoji"]); + super("auto-role-rules", ["id", "role", "emoji"], (oldElement: AutoRoleRule, newElement: AutoRoleRule) => { + return oldElement.autoRole?.id === newElement.autoRole?.id && + oldElement.roleId === newElement.roleId; + }); } public getEmojiUrl(name: string): string { diff --git a/web/src/app/modules/view/server/auto-role/components/auto-roles/auto-roles.component.html b/web/src/app/modules/view/server/auto-role/components/auto-roles/auto-roles.component.html index 7784981d..66915c46 100644 --- a/web/src/app/modules/view/server/auto-role/components/auto-roles/auto-roles.component.html +++ b/web/src/app/modules/view/server/auto-role/components/auto-roles/auto-roles.component.html @@ -28,7 +28,7 @@ class="icon-btn btn" (click)="resetFilters()"> + [callback]="callback" [validator]="validator"> diff --git a/web/src/app/modules/view/server/auto-role/components/auto-roles/auto-roles.component.ts b/web/src/app/modules/view/server/auto-role/components/auto-roles/auto-roles.component.ts index c5b26460..2a5fd6b0 100644 --- a/web/src/app/modules/view/server/auto-role/components/auto-roles/auto-roles.component.ts +++ b/web/src/app/modules/view/server/auto-role/components/auto-roles/auto-roles.component.ts @@ -36,7 +36,6 @@ export class AutoRolesComponent extends ComponentWithTable implements OnInit, On loading = true; clonedUsers: { [s: string]: User; } = {}; - isEditingNew: boolean = false; newAutoRoleTemplate: AutoRole = { createdAt: "", @@ -77,7 +76,10 @@ export class AutoRolesComponent extends ComponentWithTable implements OnInit, On private sidebar: SidebarService, private route: ActivatedRoute ) { - super("auto-role", ["id", "channel_id", "channel_name", "message_id", "rule_count"]); + super("auto-role", ["id", "channel_id", "channel_name", "message_id", "rule_count"], (oldElement: AutoRole, newElement: AutoRole) => { + return oldElement.channelId === newElement.channelId && + oldElement.messageId === newElement.messageId; + }); } public ngOnInit(): void { diff --git a/web/src/app/modules/view/server/levels/components/levels/levels.component.html b/web/src/app/modules/view/server/levels/components/levels/levels.component.html index 329fcd3b..0af4809d 100644 --- a/web/src/app/modules/view/server/levels/components/levels/levels.component.html +++ b/web/src/app/modules/view/server/levels/components/levels/levels.component.html @@ -31,7 +31,7 @@ class="icon-btn btn" (click)="resetFilters()"> + [callback]="callback" [validator]="validator"> diff --git a/web/src/app/modules/view/server/levels/components/levels/levels.component.ts b/web/src/app/modules/view/server/levels/components/levels/levels.component.ts index 80f3660a..85558bc0 100644 --- a/web/src/app/modules/view/server/levels/components/levels/levels.component.ts +++ b/web/src/app/modules/view/server/levels/components/levels/levels.component.ts @@ -19,247 +19,247 @@ import { Table } from "primeng/table"; import { User } from "../../../../../../models/data/user.model"; import { LevelMutationResult, UpdateUserMutationResult } from "../../../../../../models/graphql/result.model"; import { Mutations } from "../../../../../../models/graphql/mutations.model"; -import { Subject, throwError } from "rxjs"; +import { forkJoin, Subject, throwError } from "rxjs"; import { Server } from "../../../../../../models/data/server.model"; import { UserDTO } from "../../../../../../models/auth/auth-user.dto"; import { ComponentWithTable } from "../../../../../../base/component-with-table"; @Component({ - selector: "app-levels", - templateUrl: "./levels.component.html", - styleUrls: ["./levels.component.scss"] + selector: "app-levels", + templateUrl: "./levels.component.html", + styleUrls: ["./levels.component.scss"] }) export class LevelsComponent extends ComponentWithTable implements OnInit, OnDestroy { - public levels: Level[] = []; - public loading = true; + public levels: Level[] = []; + public loading = true; - public isEditingNew: boolean = false; + public filterForm!: FormGroup<{ + id: FormControl, + name: FormControl, + color: FormControl, + min_xp: FormControl, + permissions: FormControl, + }>; - public filterForm!: FormGroup<{ - id: FormControl, - name: FormControl, - color: FormControl, - min_xp: FormControl, - permissions: FormControl, - }>; + public filter: LevelFilter = {}; + public page: Page = { + pageSize: undefined, + pageIndex: undefined + }; + public sort: Sort = { + sortColumn: undefined, + sortDirection: undefined + }; - public filter: LevelFilter = {}; - public page: Page = { - pageSize: undefined, - pageIndex: undefined - }; - public sort: Sort = { - sortColumn: undefined, - sortDirection: undefined - }; + public totalRecords: number = 0; - public totalRecords: number = 0; + public clonedLevels: { [s: string]: Level; } = {}; - public clonedLevels: { [s: string]: Level; } = {}; + private unsubscriber = new Subject(); + private server: Server = {}; + public user: UserDTO | null = null; - private unsubscriber = new Subject(); - private server: Server = {}; - public user: UserDTO | null = null; + query: string = Queries.levelWithHistoryQuery; - query: string = Queries.levelWithHistoryQuery; + public constructor( + private authService: AuthService, + private spinner: SpinnerService, + private toastService: ToastService, + private confirmDialog: ConfirmationDialogService, + private fb: FormBuilder, + private translate: TranslateService, + private data: DataService, + private sidebar: SidebarService, + private route: ActivatedRoute + ) { + super("level", ["id", "name", "color", "min_xp", "permissions"], (oldElement: Level, newElement: Level) => { + return oldElement.name === newElement.name; + }); + } - public constructor( - private authService: AuthService, - private spinner: SpinnerService, - private toastService: ToastService, - private confirmDialog: ConfirmationDialogService, - private fb: FormBuilder, - private translate: TranslateService, - private data: DataService, - private sidebar: SidebarService, - private route: ActivatedRoute - ) { - super("level", ["id", "name", "color", "min_xp", "permissions"]); + public ngOnInit(): void { + this.setFilterForm(); + this.data.getServerFromRoute(this.route).then(async server => { + this.server = server; + this.loadNextPage(); + let authUser = await this.authService.getLoggedInUser(); + this.user = authUser?.users?.find(u => u.server == this.server.id) ?? null; + }); + } + + public ngOnDestroy(): void { + this.unsubscriber.next(); + this.unsubscriber.complete(); + } + + public loadNextPage(): void { + this.loading = true; + this.data.query(Queries.levelQuery, { + serverId: this.server.id, filter: this.filter, page: this.page, sort: this.sort + }, + (data: Query) => { + return data.servers[0]; + } + ).subscribe(data => { + this.totalRecords = data.levelCount; + this.levels = data.levels; + this.spinner.hideSpinner(); + this.loading = false; + }); + } + + public setFilterForm(): void { + this.filterForm = this.fb.group({ + id: new FormControl(null), + name: new FormControl(null), + color: new FormControl(null), + min_xp: new FormControl(null), + permissions: new FormControl(null) + }); + + this.filterForm.valueChanges.pipe( + takeUntil(this.unsubscriber), + debounceTime(600) + ).subscribe(changes => { + if (changes.id) { + this.filter.id = changes.id; + } else { + this.filter.id = undefined; + } + + if (changes.name) { + this.filter.name = changes.name; + } else { + this.filter.name = undefined; + } + + if (this.page.pageSize) + this.page.pageSize = 10; + + if (this.page.pageIndex) + this.page.pageIndex = 0; + + this.loadNextPage(); + }); + } + + public newLevelTemplate: Level = { + createdAt: "", + modifiedAt: "" + }; + + public nextPage(event: LazyLoadEvent): void { + this.page.pageSize = event.rows ?? 0; + if (event.first != null && event.rows != null) + this.page.pageIndex = event.first / event.rows; + this.sort.sortColumn = event.sortField ?? undefined; + this.sort.sortDirection = event.sortOrder === 1 ? SortDirection.ASC : event.sortOrder === -1 ? SortDirection.DESC : SortDirection.ASC; + + this.loadNextPage(); + } + + public resetFilters(): void { + this.filterForm.reset(); + } + + public onRowEditInit(table: Table, user: User, index: number): void { + this.clonedLevels[index] = { ...user }; + } + + public override onRowEditSave(newLevel: Level, index: number): void { + if (this.isEditingNew && JSON.stringify(newLevel) === JSON.stringify(this.newLevelTemplate)) { + this.isEditingNew = false; + this.levels.splice(index, 1); + return; } - public ngOnInit(): void { - this.setFilterForm(); - this.data.getServerFromRoute(this.route).then(async server => { - this.server = server; - this.loadNextPage(); - let authUser = await this.authService.getLoggedInUser(); - this.user = authUser?.users?.find(u => u.server == this.server.id) ?? null; - }); + if (!newLevel.id && !this.isEditingNew || !newLevel.minXp && !newLevel?.name && !newLevel?.permissions) { + return; } - public ngOnDestroy(): void { - this.unsubscriber.next(); - this.unsubscriber.complete(); - } - - public loadNextPage(): void { - this.loading = true; - this.data.query(Queries.levelQuery, { - serverId: this.server.id, filter: this.filter, page: this.page, sort: this.sort - }, - (data: Query) => { - return data.servers[0]; - } - ).subscribe(data => { - this.totalRecords = data.levelCount; - this.levels = data.levels; - this.spinner.hideSpinner(); - this.loading = false; - }); - } - - public setFilterForm(): void { - this.filterForm = this.fb.group({ - id: new FormControl(null), - name: new FormControl(null), - color: new FormControl(null), - min_xp: new FormControl(null), - permissions: new FormControl(null) - }); - - this.filterForm.valueChanges.pipe( - takeUntil(this.unsubscriber), - debounceTime(600) - ).subscribe(changes => { - if (changes.id) { - this.filter.id = changes.id; - } else { - this.filter.id = undefined; - } - - if (changes.name) { - this.filter.name = changes.name; - } else { - this.filter.name = undefined; - } - - if (this.page.pageSize) - this.page.pageSize = 10; - - if (this.page.pageIndex) - this.page.pageIndex = 0; - - this.loadNextPage(); - }); - } - - public newLevelTemplate: Level = { - createdAt: "", - modifiedAt: "" - }; - - public nextPage(event: LazyLoadEvent): void { - this.page.pageSize = event.rows ?? 0; - if (event.first != null && event.rows != null) - this.page.pageIndex = event.first / event.rows; - this.sort.sortColumn = event.sortField ?? undefined; - this.sort.sortDirection = event.sortOrder === 1 ? SortDirection.ASC : event.sortOrder === -1 ? SortDirection.DESC : SortDirection.ASC; - + if (this.isEditingNew) { + this.spinner.showSpinner(); + this.data.mutation(Mutations.createLevel, { + name: newLevel.name, + color: newLevel.color, + minXp: newLevel.minXp, + permissions: newLevel.permissions, + serverId: this.server.id + } + ).pipe(catchError(err => { + this.isEditingNew = false; + this.spinner.hideSpinner(); + return throwError(err); + })).subscribe(result => { + this.isEditingNew = false; + this.spinner.hideSpinner(); + this.toastService.success(this.translate.instant("view.server.levels.message.level_create"), this.translate.instant("view.server.levels.message.level_create_d", { name: result.level.createLevel?.name })); this.loadNextPage(); + }); + return; } - public resetFilters(): void { - this.filterForm.reset(); + this.spinner.showSpinner(); + this.data.mutation(Mutations.updateLevel, { + id: newLevel.id, + name: newLevel.name, + color: newLevel.color, + minXp: newLevel.minXp, + permissions: newLevel.permissions + } + ).pipe(catchError(err => { + this.spinner.hideSpinner(); + return throwError(err); + })).subscribe(_ => { + this.spinner.hideSpinner(); + this.toastService.success(this.translate.instant("view.server.levels.message.level_update"), this.translate.instant("view.server.levels.message.level_update_d", { name: newLevel.name })); + this.loadNextPage(); + }); + + } + + public onRowEditCancel(index: number): void { + if (this.isEditingNew) { + this.levels.splice(index, 1); + delete this.clonedLevels[index]; + this.isEditingNew = false; + return; } - public onRowEditInit(table: Table, user: User, index: number): void { - this.clonedLevels[index] = { ...user }; - } - - public override onRowEditSave(newLevel: Level, index: number): void { - if (this.isEditingNew && JSON.stringify(newLevel) === JSON.stringify(this.newLevelTemplate)) { - this.isEditingNew = false; - this.levels.splice(index, 1); - return; - } - - if (!newLevel.id && !this.isEditingNew || !newLevel.minXp && !newLevel?.name && !newLevel?.permissions) { - return; - } - - if (this.isEditingNew) { - this.spinner.showSpinner(); - this.data.mutation(Mutations.createLevel, { - name: newLevel.name, - color: newLevel.color, - minXp: newLevel.minXp, - permissions: newLevel.permissions, - serverId: this.server.id - } - ).pipe(catchError(err => { - this.isEditingNew = false; - this.spinner.hideSpinner(); - return throwError(err); - })).subscribe(result => { - this.isEditingNew = false; - this.spinner.hideSpinner(); - this.toastService.success(this.translate.instant("view.server.levels.message.level_create"), this.translate.instant("view.server.levels.message.level_create_d", { name: result.level.createLevel?.name })); - this.loadNextPage(); - }); - return; - } + this.levels[index] = this.clonedLevels[index]; + delete this.clonedLevels[index]; + } + public deleteLevel(level: Level): void { + this.confirmDialog.confirmDialog( + this.translate.instant("view.server.levels.message.level_delete"), this.translate.instant("view.server.levels.message.level_delete_q", { name: level.name }), + () => { this.spinner.showSpinner(); - this.data.mutation(Mutations.updateLevel, { - id: newLevel.id, - name: newLevel.name, - color: newLevel.color, - minXp: newLevel.minXp, - permissions: newLevel.permissions - } + this.data.mutation(Mutations.deleteLevel, { + id: level.id + } ).pipe(catchError(err => { - this.spinner.hideSpinner(); - return throwError(err); - })).subscribe(_ => { - this.spinner.hideSpinner(); - this.toastService.success(this.translate.instant("view.server.levels.message.level_update"), this.translate.instant("view.server.levels.message.level_update_d", { name: newLevel.name })); - this.loadNextPage(); + this.spinner.hideSpinner(); + return throwError(err); + })).subscribe(l => { + this.spinner.hideSpinner(); + this.toastService.success(this.translate.instant("view.server.levels.message.level_deleted"), this.translate.instant("view.server.levels.message.level_deleted_d", { name: level.name })); + this.loadNextPage(); }); + }); + } - } + public addLevel(table: Table): void { + const newLevel = JSON.parse(JSON.stringify(this.newLevelTemplate)); - public onRowEditCancel(index: number): void { - if (this.isEditingNew) { - this.levels.splice(index, 1); - delete this.clonedLevels[index]; - this.isEditingNew = false; - return; - } + this.levels = [newLevel, ...this.levels]; - this.levels[index] = this.clonedLevels[index]; - delete this.clonedLevels[index]; - } + table.initRowEdit(newLevel); - public deleteLevel(level: Level): void { - this.confirmDialog.confirmDialog( - this.translate.instant("view.server.levels.message.level_delete"), this.translate.instant("view.server.levels.message.level_delete_q", { name: level.name }), - () => { - this.spinner.showSpinner(); - this.data.mutation(Mutations.deleteLevel, { - id: level.id - } - ).pipe(catchError(err => { - this.spinner.hideSpinner(); - return throwError(err); - })).subscribe(l => { - this.spinner.hideSpinner(); - this.toastService.success(this.translate.instant("view.server.levels.message.level_deleted"), this.translate.instant("view.server.levels.message.level_deleted_d", { name: level.name })); - this.loadNextPage(); - }); - }); - } + const index = this.levels.findIndex(l => l.id == newLevel.id); + this.onRowEditInit(table, newLevel, index); - public addLevel(table: Table): void { - const newLevel = JSON.parse(JSON.stringify(this.newLevelTemplate)); - - this.levels = [newLevel, ...this.levels]; - - table.initRowEdit(newLevel); - - const index = this.levels.findIndex(l => l.id == newLevel.id); - this.onRowEditInit(table, newLevel, index); - - this.isEditingNew = true; - } + this.isEditingNew = true; + } } diff --git a/web/src/app/modules/view/server/members/members.component.ts b/web/src/app/modules/view/server/members/members.component.ts index 980de0ca..32855b6e 100644 --- a/web/src/app/modules/view/server/members/members.component.ts +++ b/web/src/app/modules/view/server/members/members.component.ts @@ -34,7 +34,6 @@ export class MembersComponent extends ComponentWithTable implements OnInit, OnDe loading = true; clonedUsers: { [s: string]: User; } = {}; - isEditingNew: boolean = false; newUserTemplate: User = { discordId: 0, diff --git a/web/src/app/modules/view/server/short-role-name/components/short-role-names/short-role-names.component.html b/web/src/app/modules/view/server/short-role-name/components/short-role-names/short-role-names.component.html index bb312ecf..684e2e0e 100644 --- a/web/src/app/modules/view/server/short-role-name/components/short-role-names/short-role-names.component.html +++ b/web/src/app/modules/view/server/short-role-name/components/short-role-names/short-role-names.component.html @@ -28,7 +28,7 @@ class="icon-btn btn" (click)="resetFilters()"> + [callback]="callback" [validator]="validator"> diff --git a/web/src/app/modules/view/server/short-role-name/components/short-role-names/short-role-names.component.ts b/web/src/app/modules/view/server/short-role-name/components/short-role-names/short-role-names.component.ts index 49665c6a..8202fd5f 100644 --- a/web/src/app/modules/view/server/short-role-name/components/short-role-names/short-role-names.component.ts +++ b/web/src/app/modules/view/server/short-role-name/components/short-role-names/short-role-names.component.ts @@ -33,8 +33,6 @@ export class ShortRoleNamesComponent extends ComponentWithTable implements OnIni public shortRoleNames: ShortRoleName[] = []; public loading = true; - public isEditingNew: boolean = false; - public filterForm!: FormGroup<{ id: FormControl, shortName: FormControl, @@ -75,7 +73,10 @@ export class ShortRoleNamesComponent extends ComponentWithTable implements OnIni private sidebar: SidebarService, private route: ActivatedRoute ) { - super("short-role-names", ["id", "name", "role", "position"]); + super("short-role-names", ["id", "name", "role", "position"], (oldElement: ShortRoleName, newElement: ShortRoleName) => { + return oldElement.shortName === newElement.shortName && + oldElement.roleId === newElement.roleId; + }); } public ngOnInit(): void { -- 2.45.2 From b8356917b328632a6247a0677b406266eef97159 Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Wed, 1 Nov 2023 23:02:47 +0100 Subject: [PATCH 41/58] Prevent logging bots --- bot/src/bot_core/service/data_integrity_service.py | 14 ++++++++++++++ .../base/events/base_on_member_join_event.py | 2 ++ .../events/base_on_voice_state_update_event.py | 2 ++ 3 files changed, 18 insertions(+) diff --git a/bot/src/bot_core/service/data_integrity_service.py b/bot/src/bot_core/service/data_integrity_service.py index eba805e1..cb3c0f6f 100644 --- a/bot/src/bot_core/service/data_integrity_service.py +++ b/bot/src/bot_core/service/data_integrity_service.py @@ -389,6 +389,19 @@ class DataIntegrityService: for member in guild.members: await self._client_utils.check_default_role(member) + def _check_for_bots(self): + for guild in self._bot.guilds: + server = self._servers.get_server_by_discord_id(guild.id) + + for member in guild.members.where(lambda x: x.bot): + user = self._users.find_user_by_discord_id_and_server_id(member.id, server.id) + if user is None: + continue + + self._user_joins_vc.delete_user_joined_voice_channel_by_user_id(user.id) + self._users.delete_user(user) + self._db_context.save_changes() + 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 @@ -402,3 +415,4 @@ class DataIntegrityService: self._check_user_joins_vc() self._check_user_joined_gs() await self._check_for_user_achievements() + self._check_for_bots() diff --git a/bot/src/modules/base/events/base_on_member_join_event.py b/bot/src/modules/base/events/base_on_member_join_event.py index a09772d6..b3cd2625 100644 --- a/bot/src/modules/base/events/base_on_member_join_event.py +++ b/bot/src/modules/base/events/base_on_member_join_event.py @@ -104,6 +104,8 @@ class BaseOnMemberJoinEvent(OnMemberJoinABC): @EventChecks.check_is_ready() async def on_member_join(self, member: discord.Member): self._logger.debug(__name__, f"Module {type(self)} started") + if member.bot: + return await self._client_utils.check_default_role(member) self._check_for_known_user(member) await self._add_if_not_exists_user_async(member) diff --git a/bot/src/modules/base/events/base_on_voice_state_update_event.py b/bot/src/modules/base/events/base_on_voice_state_update_event.py index 6fb0c113..8815530b 100644 --- a/bot/src/modules/base/events/base_on_voice_state_update_event.py +++ b/bot/src/modules/base/events/base_on_voice_state_update_event.py @@ -97,6 +97,8 @@ class BaseOnVoiceStateUpdateEvent(OnVoiceStateUpdateABC): ) settings: ServerConfig = self._config.get_configuration(f"ServerConfig_{member.guild.id}") server = self._servers.get_server_by_discord_id(member.guild.id) + if member.bot: + return try: if before.channel == after.channel: -- 2.45.2 From ed72620d33d24c91f37497ffb3d2291eb8ffda40 Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Wed, 1 Nov 2023 23:50:11 +0100 Subject: [PATCH 42/58] Changed steam sale offer checker --- bot/src/modules/special_offers/steam_offer_watcher.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bot/src/modules/special_offers/steam_offer_watcher.py b/bot/src/modules/special_offers/steam_offer_watcher.py index debce24b..66e183ed 100644 --- a/bot/src/modules/special_offers/steam_offer_watcher.py +++ b/bot/src/modules/special_offers/steam_offer_watcher.py @@ -66,7 +66,7 @@ class SteamOfferWatcher(TaskABC): def _get_games_from_page(self, start: int, count: int) -> List[SteamSpecialOffer]: games = List(SteamSpecialOffer) result = requests.get( - f"https://store.steampowered.com/search/results?query&start={start}&count={count}&force_infinite=1&specials=1" + f"https://store.steampowered.com/search/results?query&start={start}&count={count}&force_infinite=1&specials=1&filter=topsellers" ) soup = bs4.BeautifulSoup(result.text, "lxml") elements = soup.find_all("a", {"class": "search_result_row"}) @@ -109,7 +109,7 @@ class SteamOfferWatcher(TaskABC): new_offers = List(SteamSpecialOffer) # sale_count = self._get_max_count() + 100 - sale_count = 500 # only look at first 500 + sale_count = 250 # only look at first 500 # todo: let admins change the value self._logger.debug(__name__, f"Get special offers from 0 to {sale_count}") for i in range(0, sale_count, 100): -- 2.45.2 From 7a0f29f557d9e2bf10f57b3f01435fdf96128544 Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Fri, 3 Nov 2023 14:15:51 +0100 Subject: [PATCH 43/58] Improved workflows --- .gitea/workflows/deploy_dev.yaml | 18 +++++++++--------- .gitea/workflows/deploy_prod.yaml | 27 +++++++++++++++------------ 2 files changed, 24 insertions(+), 21 deletions(-) diff --git a/.gitea/workflows/deploy_dev.yaml b/.gitea/workflows/deploy_dev.yaml index 73f98948..be8e0e2a 100644 --- a/.gitea/workflows/deploy_dev.yaml +++ b/.gitea/workflows/deploy_dev.yaml @@ -26,21 +26,12 @@ jobs: token: ${{ secrets.CI_ACCESS_TOKEN }} submodules: true - - name: Shutdown stack - run: docker stack rm sdb_staging - - name: Prepare bot build run: | cd bot pip install --extra-index-url https://pip.sh-edraft.de cpl-cli cpl i - - name: Build docker bot - run: | - cd bot - docker image prune -f - cpl docker-build - - name: Setup node uses: https://github.com/actions/setup-node@v3 @@ -50,6 +41,15 @@ jobs: npm install -g ts-node npm i + - name: Shutdown stack + run: docker stack rm sdb_staging + + - name: Build docker bot + run: | + cd bot + docker image prune -f + cpl docker-build + - name: Build docker web run: | cd web diff --git a/.gitea/workflows/deploy_prod.yaml b/.gitea/workflows/deploy_prod.yaml index bf530ed8..906eda1b 100644 --- a/.gitea/workflows/deploy_prod.yaml +++ b/.gitea/workflows/deploy_prod.yaml @@ -1,5 +1,5 @@ -name: Deploy dev on push -run-name: Deploy dev on push +name: Deploy prod on push +run-name: Deploy prod on push on: push: branches: @@ -22,9 +22,9 @@ jobs: - name: Clone Repository uses: https://github.com/actions/checkout@v3 - - - name: Shutdown stack - run: docker stack rm sdb_prod + with: + token: ${{ secrets.CI_ACCESS_TOKEN }} + submodules: true - name: Prepare bot build run: | @@ -32,12 +32,6 @@ jobs: pip install --extra-index-url https://pip.sh-edraft.de cpl-cli cpl i - - name: Build docker bot - run: | - cd bot - docker image prune -f - cpl docker-build - - name: Setup node uses: https://github.com/actions/setup-node@v3 @@ -47,6 +41,15 @@ jobs: npm install -g ts-node npm i + - name: Shutdown stack + run: docker stack rm sdb_prod + + - name: Build docker bot + run: | + cd bot + docker image prune -f + cpl docker-build + - name: Build docker web run: | cd web @@ -61,5 +64,5 @@ jobs: portainer-password: "${{ secrets.docker_job }}" portainer-endpoint: 2 name: sdb_prod - file: ./docker-compose.yml + file: bot/docker/docker-compose.yml variables: '{}' -- 2.45.2 From b21c9f894fe4ac27f1c04216f669fccb1f2c7946 Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Fri, 3 Nov 2023 14:54:25 +0100 Subject: [PATCH 44/58] Fixed sale count for steam offers --- bot/src/modules/special_offers/steam_offer_watcher.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/bot/src/modules/special_offers/steam_offer_watcher.py b/bot/src/modules/special_offers/steam_offer_watcher.py index 66e183ed..65d6f1e9 100644 --- a/bot/src/modules/special_offers/steam_offer_watcher.py +++ b/bot/src/modules/special_offers/steam_offer_watcher.py @@ -113,6 +113,8 @@ class SteamOfferWatcher(TaskABC): # todo: let admins change the value self._logger.debug(__name__, f"Get special offers from 0 to {sale_count}") for i in range(0, sale_count, 100): + if i > sale_count: + break new_offers.extend(self._get_games_from_page(i, 100)) self._logger.debug(__name__, f"Got {new_offers.count()} offers") -- 2.45.2 From 9bbfe498cc8f29873b8ad9203bb93005df65c6b5 Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Fri, 3 Nov 2023 15:02:27 +0100 Subject: [PATCH 45/58] Fixed channel sort --- bot/src/bot_graphql/queries/discord/guild_query.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bot/src/bot_graphql/queries/discord/guild_query.py b/bot/src/bot_graphql/queries/discord/guild_query.py index cf32e8d7..7b64eeab 100644 --- a/bot/src/bot_graphql/queries/discord/guild_query.py +++ b/bot/src/bot_graphql/queries/discord/guild_query.py @@ -25,7 +25,7 @@ class GuildQuery(QueryABC): ) def _resolve_channels(self, g: Guild, *_, filter=None): - channels = List(any).extend(g.channels) + channels = List(any).extend(g.channels).order_by(lambda x: x.position) if filter is None: return channels @@ -39,4 +39,4 @@ class GuildQuery(QueryABC): if "type" in filter: channels = channels.where(lambda c: type(c).__name__ == filter["type"]) - return channels.order_by(lambda x: x.position) + return channels -- 2.45.2 From f972055ebfc05da0d43fe5394a997bb4c0b7507d Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Fri, 3 Nov 2023 15:07:23 +0100 Subject: [PATCH 46/58] Added translation for short role name position --- web/package.json | 2 +- .../short-role-names.component.html | 17 +++++++++++------ .../short-role-names.component.ts | 2 +- web/src/assets/version.json | 2 +- 4 files changed, 14 insertions(+), 9 deletions(-) diff --git a/web/package.json b/web/package.json index 86bb83f4..c01deb92 100644 --- a/web/package.json +++ b/web/package.json @@ -52,4 +52,4 @@ "tslib": "^2.4.1", "typescript": "~4.9.5" } -} +} \ No newline at end of file diff --git a/web/src/app/modules/view/server/short-role-name/components/short-role-names/short-role-names.component.html b/web/src/app/modules/view/server/short-role-name/components/short-role-names/short-role-names.component.html index 684e2e0e..bfceb38e 100644 --- a/web/src/app/modules/view/server/short-role-name/components/short-role-names/short-role-names.component.html +++ b/web/src/app/modules/view/server/short-role-name/components/short-role-names/short-role-names.component.html @@ -3,7 +3,8 @@
- @@ -17,12 +18,14 @@ {{'view.server.short_role_names.short_role_names' | translate}}
- +