Compare commits
57 Commits
1.1.7
...
d448ad7707
Author | SHA1 | Date | |
---|---|---|---|
d448ad7707 | |||
19791ff9d8 | |||
3cba8de675 | |||
b7ff070676 | |||
c88e07d743 | |||
f5b978b231 | |||
0e2b7d03fc | |||
c7f5ab0161 | |||
01e8e4256d | |||
75adc2285e | |||
9e12d84ba0 | |||
d3b503d3ef | |||
dd86c3a657 | |||
aba6e48e2b | |||
73848c3141 | |||
33d6015088 | |||
7e962e05f6 | |||
c73c6876b2 | |||
8e949c3e1a | |||
472a76d563 | |||
f5d88ec94c | |||
2182c021b9 | |||
a9c9880fd4 | |||
d91c76467d | |||
2f10ace27f | |||
3b79a61bb6 | |||
ef0fab1178 | |||
189b6370a9 | |||
0ed93c56d0 | |||
4d18dd3845 | |||
7b7cbb20db | |||
84c2f5c2c4 | |||
c85c6df784 | |||
d5d898fa07 | |||
ef5ebabf81 | |||
f89b4c4ef5 | |||
8b277a2d19 | |||
a84e77e055 | |||
892c983e1e | |||
1d3809c986 | |||
3117f617d9 | |||
7e6053768f | |||
3d9cd0a2fc | |||
8d90768594 | |||
7e8a9482d4 | |||
bf7d29e6ab | |||
608001e0e1 | |||
0dd9558f33 | |||
7acd850e68 | |||
ecd3ea96b1 | |||
d869bcfd3a | |||
818e021761 | |||
b286322247 | |||
661b057e85 | |||
25137c6923 | |||
74f3ee2f08 | |||
2e0c1babe4 |
17
.gitea/issue_template.md
Normal file
17
.gitea/issue_template.md
Normal file
@@ -0,0 +1,17 @@
|
||||
#### Beschreibung
|
||||
|
||||
Als Produktmanager muss ich nun dieses Ticket ausfüllen.
|
||||
|
||||
#### Aktuelles Verhalten
|
||||
|
||||
* Was macht die Software aktuell?
|
||||
|
||||
#### Gewünschtes Verhalten
|
||||
|
||||
* Was soll die Software anders machen?
|
||||
|
||||
#### Akzeptanzkriterien
|
||||
|
||||
* Was muss erfüllt sein, damit das Ticket als abgeschlossen angesehen werden kann?
|
||||
|
||||
#### Anmerkungen
|
7
.gitea/pull_request_template.md
Normal file
7
.gitea/pull_request_template.md
Normal file
@@ -0,0 +1,7 @@
|
||||
#### Ticket Referenz:
|
||||
|
||||
#1
|
||||
|
||||
#### Gibt es etwas beim Review zu beachten?
|
||||
|
||||
Nein
|
@@ -3,7 +3,7 @@ run-name: Deploy dev on push
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- support
|
||||
- dev
|
||||
|
||||
jobs:
|
||||
on-push-deploy_sh-edraft:
|
@@ -5,8 +5,8 @@ volumes:
|
||||
|
||||
services:
|
||||
kdb_bot_staging_1:
|
||||
image: sh-edraft.de/kdb-bot:1.1.6
|
||||
container_name: kdb_bot_staging_1
|
||||
image: sh-edraft.de/kdb-bot:1.1.10
|
||||
restart: unless-stopped
|
||||
depends_on:
|
||||
- kdb_db_staging_1
|
||||
networks:
|
||||
@@ -25,15 +25,14 @@ services:
|
||||
mode: replicated
|
||||
replicas: 1
|
||||
placement:
|
||||
constraints: [ node.role == manager ]
|
||||
constraints: [node.role == manager]
|
||||
resources:
|
||||
reservations:
|
||||
cpus: "0.5"
|
||||
memory: 1024M
|
||||
|
||||
kdb_web_staging_1:
|
||||
image: sh-edraft.de/kdb-web:1.1.6
|
||||
container_name: kdb_web_staging_1
|
||||
image: sh-edraft.de/kdb-web:1.1.10
|
||||
depends_on:
|
||||
- kdb_bot_staging_1
|
||||
networks:
|
||||
@@ -42,12 +41,12 @@ services:
|
||||
volumes:
|
||||
- /opt/kdb/staging/web/config.json:/usr/share/nginx/html/assets/config.json
|
||||
environment:
|
||||
BOT_CONTAINER_NAME: "kdb_bot_staging_1"
|
||||
BOT_CONTAINER_NAME: "kdb_bot_staging_1"
|
||||
deploy:
|
||||
mode: replicated
|
||||
replicas: 1
|
||||
placement:
|
||||
constraints: [ node.role == manager ]
|
||||
constraints: [node.role == manager]
|
||||
resources:
|
||||
limits:
|
||||
cpus: "0.4"
|
||||
@@ -58,7 +57,6 @@ services:
|
||||
|
||||
kdb_db_staging_1:
|
||||
image: mysql:latest
|
||||
container_name: kdb_db_staging_1
|
||||
command: mysqld --default-authentication-plugin=mysql_native_password --log_bin_trust_function_creators=1
|
||||
networks:
|
||||
- kdb_test
|
||||
@@ -75,7 +73,7 @@ services:
|
||||
mode: replicated
|
||||
replicas: 1
|
||||
placement:
|
||||
constraints: [ node.role == manager ]
|
||||
constraints: [node.role == manager]
|
||||
resources:
|
||||
reservations:
|
||||
cpus: "0.1"
|
||||
@@ -86,4 +84,4 @@ networks:
|
||||
external: true
|
||||
kdb_test:
|
||||
driver: overlay
|
||||
attachable: true
|
||||
attachable: true
|
||||
|
@@ -1,86 +1,87 @@
|
||||
version: "3.9"
|
||||
|
||||
volumes:
|
||||
kdb_db_prod_1:
|
||||
kdb_db_prod_1:
|
||||
|
||||
services:
|
||||
kdb_bot_prod_1:
|
||||
image: sh-edraft.de/kdb-bot:1.1.6
|
||||
depends_on:
|
||||
- kdb_db_prod_1
|
||||
networks:
|
||||
- kdb_prod
|
||||
- reverse_proxy
|
||||
volumes:
|
||||
- /opt/kdb/production/bot/config:/app/bot/config
|
||||
- /opt/kdb/production/bot/api_config:/app/bot_api/config
|
||||
- /opt/kdb/production/bot/logs:/app/bot/logs
|
||||
environment:
|
||||
KDB_ENVIRONMENT: "production"
|
||||
KDB_TOKEN: "OTk4MTU5NTEyNDYyNzA4Nzg2.Gx0hSB.Ouq2dfRKxLBJvHfEq8OrFBHVUF24AQrVf55coM"
|
||||
KDB_PREFIX: "!k "
|
||||
deploy:
|
||||
mode: replicated
|
||||
replicas: 1
|
||||
placement:
|
||||
constraints: [ node.role == manager ]
|
||||
resources:
|
||||
reservations:
|
||||
cpus: "0.5"
|
||||
memory: 1024M
|
||||
kdb_bot_prod_1:
|
||||
image: sh-edraft.de/kdb-bot:1.1.10
|
||||
restart: unless-stopped
|
||||
depends_on:
|
||||
- kdb_db_prod_1
|
||||
networks:
|
||||
- kdb_prod
|
||||
- reverse_proxy
|
||||
volumes:
|
||||
- /opt/kdb/production/bot/config:/app/bot/config
|
||||
- /opt/kdb/production/bot/api_config:/app/bot_api/config
|
||||
- /opt/kdb/production/bot/logs:/app/bot/logs
|
||||
environment:
|
||||
KDB_ENVIRONMENT: "production"
|
||||
KDB_TOKEN: "OTk4MTU5NTEyNDYyNzA4Nzg2.Gx0hSB.Ouq2dfRKxLBJvHfEq8OrFBHVUF24AQrVf55coM"
|
||||
KDB_PREFIX: "!k "
|
||||
deploy:
|
||||
mode: replicated
|
||||
replicas: 1
|
||||
placement:
|
||||
constraints: [node.role == manager]
|
||||
resources:
|
||||
reservations:
|
||||
cpus: "0.5"
|
||||
memory: 1024M
|
||||
|
||||
kdb_web_prod_1:
|
||||
image: sh-edraft.de/kdb-web:1.1.6
|
||||
depends_on:
|
||||
- kdb_bot_prod_1
|
||||
networks:
|
||||
- kdb_prod
|
||||
- reverse_proxy
|
||||
volumes:
|
||||
- /opt/kdb/production/web/config.json:/usr/share/nginx/html/assets/config.json
|
||||
environment:
|
||||
BOT_CONTAINER_NAME: "kdb_bot_prod_1"
|
||||
deploy:
|
||||
mode: replicated
|
||||
replicas: 1
|
||||
placement:
|
||||
constraints: [ node.role == manager ]
|
||||
resources:
|
||||
limits:
|
||||
cpus: "0.4"
|
||||
memory: 400M
|
||||
reservations:
|
||||
cpus: "0.1"
|
||||
memory: 20M
|
||||
kdb_web_prod_1:
|
||||
image: sh-edraft.de/kdb-web:1.1.10
|
||||
depends_on:
|
||||
- kdb_bot_prod_1
|
||||
networks:
|
||||
- kdb_prod
|
||||
- reverse_proxy
|
||||
volumes:
|
||||
- /opt/kdb/production/web/config.json:/usr/share/nginx/html/assets/config.json
|
||||
environment:
|
||||
BOT_CONTAINER_NAME: "kdb_bot_prod_1"
|
||||
deploy:
|
||||
mode: replicated
|
||||
replicas: 1
|
||||
placement:
|
||||
constraints: [node.role == manager]
|
||||
resources:
|
||||
limits:
|
||||
cpus: "0.4"
|
||||
memory: 400M
|
||||
reservations:
|
||||
cpus: "0.1"
|
||||
memory: 20M
|
||||
|
||||
kdb_db_prod_1:
|
||||
image: mysql:latest
|
||||
command: mysqld --default-authentication-plugin=mysql_native_password --log_bin_trust_function_creators=1
|
||||
networks:
|
||||
- kdb_prod
|
||||
restart: unless-stopped
|
||||
environment:
|
||||
MYSQL_ROOT_PASSWORD: "kd_kdb"
|
||||
MYSQL_USER: "kd_kdb"
|
||||
MYSQL_PASSWORD: ",2#MzfN4J=7r(q,Tz3npDkCR§>VE&}7T"
|
||||
MYSQL_DATABASE: "kd_kdb"
|
||||
ports:
|
||||
- "3307:3306"
|
||||
volumes:
|
||||
- kdb_db_prod_1:/var/lib/mysql
|
||||
deploy:
|
||||
mode: replicated
|
||||
replicas: 1
|
||||
placement:
|
||||
constraints: [ node.role == manager ]
|
||||
resources:
|
||||
reservations:
|
||||
cpus: "0.1"
|
||||
memory: 150M
|
||||
kdb_db_prod_1:
|
||||
image: mysql:latest
|
||||
command: mysqld --default-authentication-plugin=mysql_native_password --log_bin_trust_function_creators=1
|
||||
networks:
|
||||
- kdb_prod
|
||||
restart: unless-stopped
|
||||
environment:
|
||||
MYSQL_ROOT_PASSWORD: "kd_kdb"
|
||||
MYSQL_USER: "kd_kdb"
|
||||
MYSQL_PASSWORD: ",2#MzfN4J=7r(q,Tz3npDkCR§>VE&}7T"
|
||||
MYSQL_DATABASE: "kd_kdb"
|
||||
ports:
|
||||
- "3307:3306"
|
||||
volumes:
|
||||
- kdb_db_prod_1:/var/lib/mysql
|
||||
deploy:
|
||||
mode: replicated
|
||||
replicas: 1
|
||||
placement:
|
||||
constraints: [node.role == manager]
|
||||
resources:
|
||||
reservations:
|
||||
cpus: "0.1"
|
||||
memory: 150M
|
||||
|
||||
networks:
|
||||
reverse_proxy:
|
||||
external: true
|
||||
kdb_prod:
|
||||
driver: overlay
|
||||
attachable: true
|
||||
attachable: true
|
||||
|
@@ -16,7 +16,8 @@
|
||||
"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/modules/short-role-name.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",
|
||||
|
@@ -15,7 +15,7 @@ __title__ = "bot"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.1.7"
|
||||
__version__ = "1.1.10"
|
||||
|
||||
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="7")
|
||||
version_info = VersionInfo(major="1", minor="1", micro="10")
|
||||
|
@@ -4,7 +4,7 @@
|
||||
"Version": {
|
||||
"Major": "1",
|
||||
"Minor": "1",
|
||||
"Micro": "7"
|
||||
"Micro": "10"
|
||||
},
|
||||
"Author": "Sven Heidemann",
|
||||
"AuthorEmail": "sven.heidemann@sh-edraft.de",
|
||||
@@ -69,6 +69,7 @@
|
||||
"../modules/level/level.json",
|
||||
"../modules/permission/permission.json",
|
||||
"../modules/short_role_name/short-role-name.json",
|
||||
"../modules/special_offers/special-offers.json",
|
||||
"../modules/technician/technician.json"
|
||||
]
|
||||
}
|
||||
|
Submodule kdb-bot/src/bot/config updated: 23eafb2e21...839bbb823a
@@ -15,7 +15,7 @@ __title__ = "bot.extension"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.1.7"
|
||||
__version__ = "1.1.10"
|
||||
|
||||
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="7")
|
||||
version_info = VersionInfo(major="1", minor="1", micro="10")
|
||||
|
@@ -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.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,
|
||||
|
@@ -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)
|
||||
|
@@ -9,16 +9,20 @@ 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
|
||||
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,
|
||||
@@ -54,3 +58,7 @@ class StartupMigrationExtension(StartupExtensionABC):
|
||||
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
|
||||
|
@@ -21,7 +21,6 @@
|
||||
}
|
||||
},
|
||||
"common": {
|
||||
"feature_not_activated": "Diese Funktion ist deaktiviert",
|
||||
"bot_has_no_permission_message": "Ey!!!\nWas soll das?\nIch habe keine Berechtigungen :(\nScheiß System...",
|
||||
"colors": {
|
||||
"blue": "Blau",
|
||||
@@ -83,6 +82,7 @@
|
||||
"unexpected_quote_error": "Fehler: Unerwarteter Fehler beim Anführungszeichen!",
|
||||
"user_input_error": "Fehler: Eingabefehler!"
|
||||
},
|
||||
"feature_not_activated": "Diese Funktion ist deaktiviert",
|
||||
"hello_world": "Hallo Welt",
|
||||
"no_permission_message": "Nein!\nIch höre nicht auf dich ¯\\_(ツ)_/¯",
|
||||
"not_implemented_yet": "Ey Alter, das kann ich noch nicht...",
|
||||
@@ -94,11 +94,16 @@
|
||||
}
|
||||
},
|
||||
"modules": {
|
||||
"special_offers": {
|
||||
"price": "Preis",
|
||||
"discount": "Rabatt",
|
||||
"discount_price": "Neuer Preis"
|
||||
},
|
||||
"achievements": {
|
||||
"got_new_achievement": "{} hat die Errungenschaft {} freigeschaltet :D",
|
||||
"commands": {
|
||||
"check": "Alles klar, ich schaue eben nach... nom nom"
|
||||
}
|
||||
},
|
||||
"got_new_achievement": "{} hat die Errungenschaft {} freigeschaltet :D"
|
||||
},
|
||||
"auto_role": {
|
||||
"add": {
|
||||
@@ -123,6 +128,9 @@
|
||||
},
|
||||
"success": "auto-role {} wurde entfernt :D"
|
||||
},
|
||||
"react": {
|
||||
"success": "Alle Reaktionen wurden hinzugefügt"
|
||||
},
|
||||
"rule": {
|
||||
"add": {
|
||||
"error": {
|
||||
@@ -152,38 +160,37 @@
|
||||
}
|
||||
},
|
||||
"base": {
|
||||
"member_left_message": "{} hat uns leider verlassen :(",
|
||||
"complaints": {
|
||||
"title": "Beschwerde einreichen",
|
||||
"label": "Beschwerde",
|
||||
"message": "{} hat eine Beschwerde eingereicht:\n{}",
|
||||
"response": "Danke für deine Beschwerde"
|
||||
},
|
||||
"bug": {
|
||||
"title": "Bug melden",
|
||||
"label": "Bug",
|
||||
"message": "{} meldet einen Bug:\n{}",
|
||||
"response": "Danke für dein Feedback :D"
|
||||
},
|
||||
"afk_command_channel_missing_message": "Zu unfähig einem Sprachkanal beizutreten?",
|
||||
"afk_command_move_message": "Ich verschiebe dich ja schon... (◔_◔)",
|
||||
"bug": {
|
||||
"label": "Bug",
|
||||
"message": "{} meldet einen Bug:\n{}",
|
||||
"response": "Danke für dein Feedback :D",
|
||||
"title": "Bug melden"
|
||||
},
|
||||
"complaints": {
|
||||
"label": "Beschwerde",
|
||||
"message": "{} hat eine Beschwerde eingereicht:\n{}",
|
||||
"response": "Danke für deine Beschwerde",
|
||||
"title": "Beschwerde einreichen"
|
||||
},
|
||||
"game_server": {
|
||||
"add": {
|
||||
"success": "Gameserver {} wurde hinzugefügt :)"
|
||||
},
|
||||
"error": {
|
||||
"nothing_found": "Keine Gameserver gefunden."
|
||||
},
|
||||
"list_members": {
|
||||
"title": "Mitglieder",
|
||||
"description": "Konfigurierte Mitglieder:",
|
||||
"users": "Mitglieder"
|
||||
},
|
||||
"list": {
|
||||
"title": "Gameserver",
|
||||
"api_key": "API Key",
|
||||
"description": "Konfigurierte Gameserver:",
|
||||
"name": "Name",
|
||||
"api_key": "API Key"
|
||||
"title": "Gameserver"
|
||||
},
|
||||
"add": {
|
||||
"success": "Gameserver {} wurde hinzugefügt :)"
|
||||
"list_members": {
|
||||
"description": "Konfigurierte Mitglieder:",
|
||||
"title": "Mitglieder",
|
||||
"users": "Mitglieder"
|
||||
},
|
||||
"remove": {
|
||||
"success": "Gameserver wurde entfernt :D"
|
||||
@@ -210,6 +217,7 @@
|
||||
"moved": "Alle Personen aus {} wurden nach {} verschoben."
|
||||
},
|
||||
"member_joined_help_voice_channel": "{} braucht Hilfe, bitte kümmere dich drum :D",
|
||||
"member_left_message": "{} hat uns leider verlassen :(",
|
||||
"pong": "Pong",
|
||||
"presence": {
|
||||
"changed": "Presence wurde geändert.",
|
||||
@@ -226,6 +234,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"
|
||||
},
|
||||
@@ -346,6 +358,9 @@
|
||||
"moderator": {
|
||||
"purge_message": "Na gut..., ich lösche alle Nachrichten wenns sein muss."
|
||||
},
|
||||
"short_role_name": {
|
||||
"checked_message": "Die Rollen Kürzel wurden überprüft"
|
||||
},
|
||||
"technician": {
|
||||
"api_key": {
|
||||
"add": {
|
||||
@@ -357,10 +372,10 @@
|
||||
"success": "API-Schlüssel wurde entfernt :D"
|
||||
}
|
||||
},
|
||||
"synced_message": "Der Sync wurde abgeschlossen.",
|
||||
"log_message": "Hier sind deine Logdateien! :)",
|
||||
"restart_message": "Bin gleich wieder da :D",
|
||||
"shutdown_message": "Trauert nicht um mich, es war eine logische Entscheidung. Das Wohl von Vielen, es wiegt schwerer als das Wohl von Wenigen oder eines Einzelnen. Ich war es und ich werde es immer sein, euer Freund. Lebt lange und in Frieden :)"
|
||||
"shutdown_message": "Trauert nicht um mich, es war eine logische Entscheidung. Das Wohl von Vielen, es wiegt schwerer als das Wohl von Wenigen oder eines Einzelnen. Ich war es und ich werde es immer sein, euer Freund. Lebt lange und in Frieden :)",
|
||||
"synced_message": "Der Sync wurde abgeschlossen."
|
||||
}
|
||||
}
|
||||
}
|
@@ -15,7 +15,7 @@ __title__ = "bot_api"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.1.7"
|
||||
__version__ = "1.1.10"
|
||||
|
||||
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="7")
|
||||
version_info = VersionInfo(major="1", minor="1", micro="10")
|
||||
|
@@ -15,7 +15,7 @@ __title__ = "bot_api.abc"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.1.7"
|
||||
__version__ = "1.1.10"
|
||||
|
||||
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="7")
|
||||
version_info = VersionInfo(major="1", minor="1", micro="10")
|
||||
|
@@ -4,7 +4,7 @@
|
||||
"Version": {
|
||||
"Major": "1",
|
||||
"Minor": "1",
|
||||
"Micro": "7"
|
||||
"Micro": "10"
|
||||
},
|
||||
"Author": "",
|
||||
"AuthorEmail": "",
|
||||
|
@@ -15,7 +15,7 @@ __title__ = "bot_api.configuration"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.1.7"
|
||||
__version__ = "1.1.10"
|
||||
|
||||
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="7")
|
||||
version_info = VersionInfo(major="1", minor="1", micro="10")
|
||||
|
@@ -15,7 +15,7 @@ __title__ = "bot_api.controller"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.1.7"
|
||||
__version__ = "1.1.10"
|
||||
|
||||
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="7")
|
||||
version_info = VersionInfo(major="1", minor="1", micro="10")
|
||||
|
@@ -15,7 +15,7 @@ __title__ = "bot_api.event"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.1.7"
|
||||
__version__ = "1.1.10"
|
||||
|
||||
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="7")
|
||||
version_info = VersionInfo(major="1", minor="1", micro="10")
|
||||
|
@@ -15,7 +15,7 @@ __title__ = "bot_api.exception"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.1.7"
|
||||
__version__ = "1.1.10"
|
||||
|
||||
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="7")
|
||||
version_info = VersionInfo(major="1", minor="1", micro="10")
|
||||
|
@@ -15,7 +15,7 @@ __title__ = "bot_api.filter"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.1.7"
|
||||
__version__ = "1.1.10"
|
||||
|
||||
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="7")
|
||||
version_info = VersionInfo(major="1", minor="1", micro="10")
|
||||
|
@@ -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.7"
|
||||
__version__ = "1.1.10"
|
||||
|
||||
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="7")
|
||||
version_info = VersionInfo(major="1", minor="1", micro="10")
|
||||
|
@@ -15,7 +15,7 @@ __title__ = "bot_api.logging"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.1.7"
|
||||
__version__ = "1.1.10"
|
||||
|
||||
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="7")
|
||||
version_info = VersionInfo(major="1", minor="1", micro="10")
|
||||
|
@@ -15,7 +15,7 @@ __title__ = "bot_api.model"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.1.7"
|
||||
__version__ = "1.1.10"
|
||||
|
||||
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="7")
|
||||
version_info = VersionInfo(major="1", minor="1", micro="10")
|
||||
|
@@ -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.7"
|
||||
__version__ = "1.1.10"
|
||||
|
||||
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="7")
|
||||
version_info = VersionInfo(major="1", minor="1", micro="10")
|
||||
|
@@ -15,7 +15,7 @@ __title__ = "bot_api.route"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.1.7"
|
||||
__version__ = "1.1.10"
|
||||
|
||||
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="7")
|
||||
version_info = VersionInfo(major="1", minor="1", micro="10")
|
||||
|
@@ -15,7 +15,7 @@ __title__ = "bot_api.service"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.1.7"
|
||||
__version__ = "1.1.10"
|
||||
|
||||
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="7")
|
||||
version_info = VersionInfo(major="1", minor="1", micro="10")
|
||||
|
@@ -15,7 +15,7 @@ __title__ = "bot_api.transformer"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.1.7"
|
||||
__version__ = "1.1.10"
|
||||
|
||||
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="7")
|
||||
version_info = VersionInfo(major="1", minor="1", micro="10")
|
||||
|
@@ -15,7 +15,7 @@ __title__ = "bot_core"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.1.7"
|
||||
__version__ = "1.1.10"
|
||||
|
||||
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="7")
|
||||
version_info = VersionInfo(major="1", minor="1", micro="10")
|
||||
|
@@ -15,7 +15,7 @@ __title__ = "bot_core.abc"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.1.7"
|
||||
__version__ = "1.1.10"
|
||||
|
||||
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="7")
|
||||
version_info = VersionInfo(major="1", minor="1", micro="10")
|
||||
|
@@ -4,7 +4,7 @@
|
||||
"Version": {
|
||||
"Major": "1",
|
||||
"Minor": "1",
|
||||
"Micro": "7"
|
||||
"Micro": "10"
|
||||
},
|
||||
"Author": "Sven Heidemann",
|
||||
"AuthorEmail": "sven.heidemann@sh-edraft.de",
|
||||
|
@@ -15,7 +15,7 @@ __title__ = "bot_core.configuration"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.1.7"
|
||||
__version__ = "1.1.10"
|
||||
|
||||
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="7")
|
||||
version_info = VersionInfo(major="1", minor="1", micro="10")
|
||||
|
@@ -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"
|
||||
@@ -24,3 +25,5 @@ class FeatureFlagsEnum(Enum):
|
||||
game_server = "GameServer"
|
||||
sync_xp = "SyncXp"
|
||||
short_role_name = "ShortRoleName"
|
||||
technician_full_access = "TechnicianFullAccess"
|
||||
steam_special_offers = "SteamSpecialOffers"
|
||||
|
@@ -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
|
||||
@@ -26,6 +27,8 @@ class FeatureFlagsSettings(ConfigurationModelABC):
|
||||
FeatureFlagsEnum.game_server.value: False, # 25.09.2023 #366
|
||||
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):
|
||||
|
@@ -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.7"
|
||||
__version__ = "1.1.10"
|
||||
|
||||
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="7")
|
||||
version_info = VersionInfo(major="1", minor="1", micro="10")
|
||||
|
@@ -15,7 +15,7 @@ __title__ = "bot_core.events"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.1.7"
|
||||
__version__ = "1.1.10"
|
||||
|
||||
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="7")
|
||||
version_info = VersionInfo(major="1", minor="1", micro="10")
|
||||
|
@@ -15,7 +15,7 @@ __title__ = "bot_core.exception"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.1.7"
|
||||
__version__ = "1.1.10"
|
||||
|
||||
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="7")
|
||||
version_info = VersionInfo(major="1", minor="1", micro="10")
|
||||
|
@@ -15,7 +15,7 @@ __title__ = "bot_core.helper"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.1.7"
|
||||
__version__ = "1.1.10"
|
||||
|
||||
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="7")
|
||||
version_info = VersionInfo(major="1", minor="1", micro="10")
|
||||
|
@@ -15,7 +15,7 @@ __title__ = "bot_core.logging"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.1.7"
|
||||
__version__ = "1.1.10"
|
||||
|
||||
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="7")
|
||||
version_info = VersionInfo(major="1", minor="1", micro="10")
|
||||
|
15
kdb-bot/src/bot_core/logging/task_logger.py
Normal file
15
kdb-bot/src/bot_core/logging/task_logger.py
Normal file
@@ -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)
|
@@ -15,7 +15,7 @@ __title__ = "bot_core.pipes"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.1.7"
|
||||
__version__ = "1.1.10"
|
||||
|
||||
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="7")
|
||||
version_info = VersionInfo(major="1", minor="1", micro="10")
|
||||
|
@@ -15,7 +15,7 @@ __title__ = "bot_core.service"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.1.7"
|
||||
__version__ = "1.1.10"
|
||||
|
||||
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="7")
|
||||
version_info = VersionInfo(major="1", minor="1", micro="10")
|
||||
|
@@ -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)
|
||||
|
||||
@@ -228,7 +228,7 @@ class ClientUtilsService(ClientUtilsABC):
|
||||
return
|
||||
|
||||
default_role = member.guild.get_role(settings.default_role_id)
|
||||
if default_role in member.roles:
|
||||
if default_role is None or default_role in member.roles:
|
||||
return
|
||||
|
||||
await member.add_roles(default_role)
|
||||
|
@@ -7,8 +7,6 @@ from bot_data.abc.technician_config_repository_abc import TechnicianConfigReposi
|
||||
from bot_data.model.server import Server
|
||||
from bot_data.model.technician_config import TechnicianConfig
|
||||
from bot_data.service.server_config_seeder import ServerConfigSeeder
|
||||
from bot_data.service.technician_config_seeder import TechnicianConfigSeeder
|
||||
from modules.permission.abc.permission_service_abc import PermissionServiceABC
|
||||
|
||||
|
||||
class ConfigService:
|
||||
@@ -18,7 +16,6 @@ class ConfigService:
|
||||
services: ServiceProviderABC,
|
||||
technician_config_repo: TechnicianConfigRepositoryABC,
|
||||
server_config_repo: ServerConfigRepositoryABC,
|
||||
tech_seeder: TechnicianConfigSeeder,
|
||||
server_seeder: ServerConfigSeeder,
|
||||
):
|
||||
self._config = config
|
||||
@@ -26,13 +23,9 @@ class ConfigService:
|
||||
self._technician_config_repo = technician_config_repo
|
||||
self._server_config_repo = server_config_repo
|
||||
|
||||
self._tech_seeder = tech_seeder
|
||||
self._server_seeder = server_seeder
|
||||
|
||||
async def reload_technician_config(self):
|
||||
if not self._technician_config_repo.does_technician_config_exists():
|
||||
await self._tech_seeder.seed()
|
||||
|
||||
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))
|
||||
@@ -45,6 +38,3 @@ class ConfigService:
|
||||
self._config.add_configuration(
|
||||
f"{type(server_config).__name__}_{server_config.server.discord_id}", server_config
|
||||
)
|
||||
|
||||
permissions: PermissionServiceABC = self._services.get_service(PermissionServiceABC)
|
||||
permissions.on_ready()
|
||||
|
@@ -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:
|
||||
|
@@ -15,7 +15,7 @@ __title__ = "bot_data"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.1.7"
|
||||
__version__ = "1.1.10"
|
||||
|
||||
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="7")
|
||||
version_info = VersionInfo(major="1", minor="1", micro="10")
|
||||
|
@@ -15,7 +15,7 @@ __title__ = "bot_data.abc"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.1.7"
|
||||
__version__ = "1.1.10"
|
||||
|
||||
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="7")
|
||||
version_info = VersionInfo(major="1", minor="1", micro="10")
|
||||
|
@@ -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
|
@@ -4,7 +4,7 @@
|
||||
"Version": {
|
||||
"Major": "1",
|
||||
"Minor": "1",
|
||||
"Micro": "7"
|
||||
"Micro": "10"
|
||||
},
|
||||
"Author": "Sven Heidemann",
|
||||
"AuthorEmail": "sven.heidemann@sh-edraft.de",
|
||||
|
@@ -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)
|
||||
|
@@ -15,7 +15,7 @@ __title__ = "bot_data.migration"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.1.7"
|
||||
__version__ = "1.1.10"
|
||||
|
||||
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="7")
|
||||
version_info = VersionInfo(major="1", minor="1", micro="10")
|
||||
|
84
kdb-bot/src/bot_data/migration/birthday_migration.py
Normal file
84
kdb-bot/src/bot_data/migration/birthday_migration.py
Normal file
@@ -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;
|
||||
"""
|
||||
)
|
||||
)
|
@@ -1,25 +1,26 @@
|
||||
CREATE TABLE IF NOT EXISTS `CFG_ServerHistory`
|
||||
(
|
||||
`Id` BIGINT(20) NOT NULL,
|
||||
`MessageDeleteTimer` BIGINT NOT NULL DEFAULT 6,
|
||||
`NotificationChatId` BIGINT NOT NULL,
|
||||
`MaxVoiceStateHours` BIGINT NOT NULL DEFAULT 6,
|
||||
`XpPerMessage` BIGINT NOT NULL DEFAULT 1,
|
||||
`XpPerReaction` BIGINT NOT NULL DEFAULT 1,
|
||||
`MaxMessageXpPerHour` BIGINT NOT NULL DEFAULT 20,
|
||||
`XpPerOntimeHour` BIGINT NOT NULL DEFAULT 10,
|
||||
`XpPerEventParticipation` BIGINT NOT NULL DEFAULT 10,
|
||||
`XpPerAchievement` BIGINT NOT NULL DEFAULT 10,
|
||||
`AFKCommandChannelId` BIGINT NOT NULL,
|
||||
`HelpVoiceChannelId` BIGINT NOT NULL,
|
||||
`TeamChannelId` BIGINT NOT NULL,
|
||||
`LoginMessageChannelId` BIGINT NOT NULL,
|
||||
`DefaultRoleId` BIGINT NULL,
|
||||
`FeatureFlags` JSON NULL DEFAULT ('{}'),
|
||||
`ServerId` BIGINT NOT NULL,
|
||||
`Deleted` BOOL DEFAULT FALSE,
|
||||
`DateFrom` DATETIME(6) NOT NULL,
|
||||
`DateTo` DATETIME(6) NOT NULL
|
||||
`Id` BIGINT(20) NOT NULL,
|
||||
`MessageDeleteTimer` BIGINT NOT NULL DEFAULT 6,
|
||||
`NotificationChatId` BIGINT NOT NULL,
|
||||
`MaxVoiceStateHours` BIGINT NOT NULL DEFAULT 6,
|
||||
`XpPerMessage` BIGINT NOT NULL DEFAULT 1,
|
||||
`XpPerReaction` BIGINT NOT NULL DEFAULT 1,
|
||||
`MaxMessageXpPerHour` BIGINT NOT NULL DEFAULT 20,
|
||||
`XpPerOntimeHour` BIGINT NOT NULL DEFAULT 10,
|
||||
`XpPerEventParticipation` BIGINT NOT NULL DEFAULT 10,
|
||||
`XpPerAchievement` BIGINT NOT NULL DEFAULT 10,
|
||||
`AFKCommandChannelId` BIGINT NOT NULL,
|
||||
`HelpVoiceChannelId` BIGINT NOT NULL,
|
||||
`TeamChannelId` BIGINT NOT NULL,
|
||||
`LoginMessageChannelId` BIGINT NOT NULL,
|
||||
`DefaultRoleId` BIGINT NULL,
|
||||
`ShortRoleNameSetOnlyHighest` BOOLEAN NOT NULL DEFAULT FALSE,
|
||||
`FeatureFlags` JSON NULL DEFAULT ('{}'),
|
||||
`ServerId` BIGINT NOT NULL,
|
||||
`Deleted` BOOL DEFAULT FALSE,
|
||||
`DateFrom` DATETIME(6) NOT NULL,
|
||||
`DateTo` DATETIME(6) NOT NULL
|
||||
);
|
||||
|
||||
DROP TRIGGER IF EXISTS `TR_CFG_ServerUpdate`;
|
||||
@@ -44,6 +45,7 @@ BEGIN
|
||||
`TeamChannelId`,
|
||||
`LoginMessageChannelId`,
|
||||
`DefaultRoleId`,
|
||||
`ShortRoleNameSetOnlyHighest`,
|
||||
`FeatureFlags`,
|
||||
`ServerId`,
|
||||
`DateFrom`,
|
||||
@@ -63,6 +65,7 @@ BEGIN
|
||||
OLD.TeamChannelId,
|
||||
OLD.LoginMessageChannelId,
|
||||
OLD.DefaultRoleId,
|
||||
OLD.ShortRoleNameSetOnlyHighest,
|
||||
OLD.FeatureFlags,
|
||||
OLD.ServerId,
|
||||
OLD.LastModifiedAt,
|
||||
@@ -91,6 +94,7 @@ BEGIN
|
||||
`TeamChannelId`,
|
||||
`LoginMessageChannelId`,
|
||||
`DefaultRoleId`,
|
||||
`ShortRoleNameSetOnlyHighest`,
|
||||
`ServerId`,
|
||||
`FeatureFlags`,
|
||||
`Deleted`,
|
||||
@@ -111,6 +115,7 @@ BEGIN
|
||||
OLD.TeamChannelId,
|
||||
OLD.LoginMessageChannelId,
|
||||
OLD.DefaultRoleId,
|
||||
OLD.ShortRoleNameSetOnlyHighest,
|
||||
OLD.FeatureFlags,
|
||||
OLD.ServerId,
|
||||
TRUE,
|
||||
|
@@ -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;
|
45
kdb-bot/src/bot_data/migration/fix_user_history_migration.py
Normal file
45
kdb-bot/src/bot_data/migration/fix_user_history_migration.py
Normal file
@@ -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;
|
||||
"""
|
||||
)
|
||||
)
|
@@ -0,0 +1,51 @@
|
||||
from bot_core.logging.database_logger import DatabaseLogger
|
||||
from bot_data.abc.migration_abc import MigrationABC
|
||||
from bot_data.db_context import DBContext
|
||||
|
||||
|
||||
class ShortRoleNameOnlyHighestMigration(MigrationABC):
|
||||
name = "1.1.9_ShortRoleNameOnlyHighestMigration"
|
||||
|
||||
def __init__(self, logger: DatabaseLogger, db: DBContext):
|
||||
MigrationABC.__init__(self)
|
||||
self._logger = logger
|
||||
self._db = db
|
||||
self._cursor = db.cursor
|
||||
|
||||
def upgrade(self):
|
||||
self._logger.debug(__name__, "Running upgrade")
|
||||
|
||||
self._cursor.execute(
|
||||
str(
|
||||
f"""
|
||||
ALTER TABLE CFG_Server
|
||||
ADD ShortRoleNameSetOnlyHighest BOOLEAN NOT NULL DEFAULT FALSE AFTER DefaultRoleId;
|
||||
"""
|
||||
)
|
||||
)
|
||||
|
||||
self._cursor.execute(
|
||||
str(
|
||||
f"""
|
||||
ALTER TABLE CFG_ServerHistory
|
||||
ADD ShortRoleNameSetOnlyHighest BOOLEAN NOT NULL DEFAULT FALSE AFTER DefaultRoleId;
|
||||
"""
|
||||
)
|
||||
)
|
||||
self._exec(__file__, "config/server.sql")
|
||||
|
||||
def downgrade(self):
|
||||
self._cursor.execute(
|
||||
str(
|
||||
f"""
|
||||
ALTER TABLE CFG_Server DROP COLUMN ShortRoleNameSetOnlyHighest;
|
||||
"""
|
||||
)
|
||||
)
|
||||
self._cursor.execute(
|
||||
str(
|
||||
f"""
|
||||
ALTER TABLE CFG_ServerHistory DROP COLUMN ShortRoleNameSetOnlyHighest;
|
||||
"""
|
||||
)
|
||||
)
|
@@ -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;
|
||||
"""
|
||||
)
|
||||
)
|
@@ -15,7 +15,7 @@ __title__ = "bot_data.model"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.1.7"
|
||||
__version__ = "1.1.10"
|
||||
|
||||
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="7")
|
||||
version_info = VersionInfo(major="1", minor="1", micro="10")
|
||||
|
@@ -24,11 +24,14 @@ 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,
|
||||
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],
|
||||
@@ -47,11 +50,15 @@ 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
|
||||
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
|
||||
self._afk_channel_ids = afk_channel_ids
|
||||
@@ -73,11 +80,14 @@ class ServerConfig(TableABC, ConfigurationModelABC):
|
||||
10,
|
||||
10,
|
||||
10,
|
||||
10,
|
||||
guild.system_channel.id,
|
||||
guild.system_channel.id,
|
||||
guild.system_channel.id,
|
||||
guild.system_channel.id,
|
||||
None,
|
||||
False,
|
||||
guild.system_channel.id,
|
||||
{},
|
||||
server,
|
||||
List(int),
|
||||
@@ -160,6 +170,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
|
||||
@@ -200,6 +218,22 @@ class ServerConfig(TableABC, ConfigurationModelABC):
|
||||
def default_role_id(self, value: int):
|
||||
self._default_role_id = value
|
||||
|
||||
@property
|
||||
def short_role_name_only_set_highest_role(self) -> bool:
|
||||
return self._short_role_name_only_set_highest_role
|
||||
|
||||
@short_role_name_only_set_highest_role.setter
|
||||
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
|
||||
@@ -268,11 +302,14 @@ class ServerConfig(TableABC, ConfigurationModelABC):
|
||||
`XpPerOntimeHour`,
|
||||
`XpPerEventParticipation`,
|
||||
`XpPerAchievement`,
|
||||
`XpForBirthday`,
|
||||
`AFKCommandChannelId`,
|
||||
`HelpVoiceChannelId`,
|
||||
`TeamChannelId`,
|
||||
`LoginMessageChannelId`,
|
||||
`DefaultRoleId`,
|
||||
`ShortRoleNameSetOnlyHighest`,
|
||||
`GameOfferNotificationChatId`,
|
||||
`FeatureFlags`,
|
||||
`ServerId`
|
||||
) VALUES (
|
||||
@@ -285,11 +322,14 @@ 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},
|
||||
{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}
|
||||
);
|
||||
@@ -310,11 +350,14 @@ 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},
|
||||
`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};
|
||||
|
@@ -18,6 +18,7 @@ class ServerConfigHistory(HistoryTableABC):
|
||||
team_channel_id: int,
|
||||
login_message_channel_id: int,
|
||||
default_role_id: int,
|
||||
short_role_name_only_set_highest_role: bool,
|
||||
feature_flags: dict[str],
|
||||
server_id: int,
|
||||
deleted: bool,
|
||||
@@ -42,6 +43,8 @@ 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._feature_flags = feature_flags
|
||||
self._server_id = server_id
|
||||
|
||||
@@ -105,6 +108,10 @@ class ServerConfigHistory(HistoryTableABC):
|
||||
def default_role_id(self) -> int:
|
||||
return self._default_role_id
|
||||
|
||||
@property
|
||||
def short_role_name_only_set_highest_role(self) -> bool:
|
||||
return self._short_role_name_only_set_highest_role
|
||||
|
||||
@property
|
||||
def feature_flags(self) -> dict[str]:
|
||||
return self._feature_flags
|
||||
|
115
kdb-bot/src/bot_data/model/steam_special_offer.py
Normal file
115
kdb-bot/src/bot_data/model/steam_special_offer.py
Normal file
@@ -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};
|
||||
"""
|
||||
)
|
@@ -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};
|
||||
"""
|
||||
)
|
||||
|
43
kdb-bot/src/bot_data/model/user_warnings_history.py
Normal file
43
kdb-bot/src/bot_data/model/user_warnings_history.py
Normal file
@@ -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
|
@@ -15,7 +15,7 @@ __title__ = "bot_data.service"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.1.7"
|
||||
__version__ = "1.1.10"
|
||||
|
||||
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="7")
|
||||
version_info = VersionInfo(major="1", minor="1", micro="10")
|
||||
|
@@ -65,12 +65,15 @@ class ServerConfigRepositoryService(ServerConfigRepositoryABC):
|
||||
result[12],
|
||||
result[13],
|
||||
result[14],
|
||||
json.loads(result[15]),
|
||||
self._servers.get_server_by_id(result[16]),
|
||||
self._get_afk_channel_ids(result[16]),
|
||||
self._get_team_role_ids(result[16]),
|
||||
result[15],
|
||||
result[16],
|
||||
result[17],
|
||||
result[18],
|
||||
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],
|
||||
)
|
||||
|
||||
|
@@ -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)
|
@@ -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],
|
||||
)
|
||||
|
||||
|
@@ -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)
|
||||
|
||||
|
@@ -15,7 +15,7 @@ __title__ = "bot_graphql"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.1.7"
|
||||
__version__ = "1.1.10"
|
||||
|
||||
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="7")
|
||||
version_info = VersionInfo(major="1", minor="1", micro="10")
|
||||
|
@@ -15,7 +15,7 @@ __title__ = "bot_graphql.abc"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.1.7"
|
||||
__version__ = "1.1.10"
|
||||
|
||||
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="7")
|
||||
version_info = VersionInfo(major="1", minor="1", micro="10")
|
||||
|
@@ -79,6 +79,14 @@ class QueryABC(ObjectType):
|
||||
permissions: PermissionService = services.get_service(PermissionService)
|
||||
bot: DiscordBotServiceABC = services.get_service(DiscordBotServiceABC)
|
||||
|
||||
if user.auth_role == AuthRoleEnum.admin:
|
||||
return True
|
||||
|
||||
for u in user.users:
|
||||
guild = bot.get_guild(u.server.discord_id)
|
||||
if permissions.is_member_technician(guild.get_member(u.discord_id)):
|
||||
return True
|
||||
|
||||
access = False
|
||||
if type(element) == Achievement:
|
||||
element: Achievement = element
|
||||
|
@@ -4,7 +4,7 @@
|
||||
"Version": {
|
||||
"Major": "1",
|
||||
"Minor": "1",
|
||||
"Micro": "7"
|
||||
"Micro": "10"
|
||||
},
|
||||
"Author": "Sven Heidemann",
|
||||
"AuthorEmail": "sven.heidemann@sh-edraft.de",
|
||||
|
@@ -15,7 +15,7 @@ __title__ = "bot_graphql.filter"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.1.7"
|
||||
__version__ = "1.1.10"
|
||||
|
||||
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="7")
|
||||
version_info = VersionInfo(major="1", minor="1", micro="10")
|
||||
|
@@ -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
|
||||
|
56
kdb-bot/src/bot_graphql/filter/user_warning_filter.py
Normal file
56
kdb-bot/src/bot_graphql/filter/user_warning_filter.py
Normal file
@@ -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
|
@@ -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
|
||||
|
@@ -9,11 +9,14 @@ type ServerConfig implements TableWithHistoryQuery {
|
||||
xpPerOntimeHour: Int
|
||||
xpPerEventParticipation: Int
|
||||
xpPerAchievement: Int
|
||||
xpForBirthday: Int
|
||||
afkCommandChannelId: String
|
||||
helpVoiceChannelId: String
|
||||
teamChannelId: String
|
||||
loginMessageChannelId: String
|
||||
defaultRoleId: String
|
||||
shortRoleNameOnlySetHighestRole: Boolean
|
||||
gameOfferNotificationChatId: String
|
||||
featureFlagCount: Int
|
||||
featureFlags: [FeatureFlag]
|
||||
|
||||
@@ -40,11 +43,14 @@ type ServerConfigHistory implements HistoryTableQuery {
|
||||
xpPerOntimeHour: Int
|
||||
xpPerEventParticipation: Int
|
||||
xpPerAchievement: Int
|
||||
xpForBirthday: Int
|
||||
afkCommandChannelId: String
|
||||
helpVoiceChannelId: String
|
||||
teamChannelId: String
|
||||
loginMessageChannelId: String
|
||||
defaultRoleId: String
|
||||
shortRoleNameOnlySetHighestRole: Boolean
|
||||
gameOfferNotificationChatId: String
|
||||
featureFlagCount: Int
|
||||
featureFlags: [FeatureFlag]
|
||||
|
||||
@@ -89,11 +95,14 @@ input ServerConfigInput {
|
||||
xpPerOntimeHour: Int
|
||||
xpPerEventParticipation: Int
|
||||
xpPerAchievement: Int
|
||||
xpForBirthday: Int
|
||||
afkCommandChannelId: String
|
||||
helpVoiceChannelId: String
|
||||
teamChannelId: String
|
||||
loginMessageChannelId: String
|
||||
defaultRoleId: String
|
||||
shortRoleNameOnlySetHighestRole: Boolean
|
||||
gameOfferNotificationChatId: String
|
||||
featureFlags: [FeatureFlagInput]
|
||||
|
||||
afkChannelIds: [String]
|
||||
|
@@ -5,6 +5,7 @@ type User implements TableWithHistoryQuery {
|
||||
xp: Int
|
||||
messageCount: Int
|
||||
reactionCount: Int
|
||||
birthday: String
|
||||
ontime: Float
|
||||
level: Level
|
||||
|
||||
@@ -20,6 +21,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
|
||||
|
||||
@@ -59,5 +63,7 @@ type UserMutation {
|
||||
input UserInput {
|
||||
id: ID
|
||||
xp: Int
|
||||
birthday: String
|
||||
levelId: ID
|
||||
userWarnings: [UserWarningInput]
|
||||
}
|
34
kdb-bot/src/bot_graphql/graphql/userWarning.gql
Normal file
34
kdb-bot/src/bot_graphql/graphql/userWarning.gql
Normal file
@@ -0,0 +1,34 @@
|
||||
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
|
||||
}
|
||||
|
||||
input UserWarningInput {
|
||||
id: ID
|
||||
user: ID
|
||||
description: String
|
||||
author: ID
|
||||
}
|
@@ -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)
|
||||
|
@@ -15,7 +15,7 @@ __title__ = "bot_graphql.model"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.1.7"
|
||||
__version__ = "1.1.10"
|
||||
|
||||
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="7")
|
||||
version_info = VersionInfo(major="1", minor="1", micro="10")
|
||||
|
@@ -15,7 +15,7 @@ __title__ = "bot_graphql.mutations"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.1.7"
|
||||
__version__ = "1.1.10"
|
||||
|
||||
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="7")
|
||||
version_info = VersionInfo(major="1", minor="1", micro="10")
|
||||
|
@@ -13,7 +13,6 @@ from bot_data.model.server_team_role_ids_config import ServerTeamRoleIdsConfig
|
||||
from bot_data.model.team_member_type_enum import TeamMemberTypeEnum
|
||||
from bot_data.model.user_role_enum import UserRoleEnum
|
||||
from bot_graphql.abc.query_abc import QueryABC
|
||||
from modules.permission.abc.permission_service_abc import PermissionServiceABC
|
||||
|
||||
|
||||
class ServerConfigMutation(QueryABC):
|
||||
@@ -25,7 +24,6 @@ class ServerConfigMutation(QueryABC):
|
||||
server_configs: ServerConfigRepositoryABC,
|
||||
db: DatabaseContextABC,
|
||||
config_service: ConfigService,
|
||||
permissions: PermissionServiceABC,
|
||||
):
|
||||
QueryABC.__init__(self, "ServerConfigMutation")
|
||||
|
||||
@@ -35,7 +33,6 @@ class ServerConfigMutation(QueryABC):
|
||||
self._server_configs = server_configs
|
||||
self._db = db
|
||||
self._config_service = config_service
|
||||
self._permissions = permissions
|
||||
|
||||
self.set_field("updateServerConfig", self.resolve_update_server_config)
|
||||
|
||||
@@ -92,6 +89,16 @@ class ServerConfigMutation(QueryABC):
|
||||
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"]
|
||||
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
|
||||
@@ -137,6 +144,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):
|
||||
@@ -176,6 +184,3 @@ class ServerConfigMutation(QueryABC):
|
||||
continue
|
||||
|
||||
self._server_configs.add_server_team_role_id_config(role_id)
|
||||
|
||||
self._bot.loop.create_task(self._config_service.reload_server_config(new_config.server))
|
||||
self._permissions.on_ready()
|
||||
|
@@ -42,7 +42,7 @@ class ShortRoleNameMutation(QueryABC):
|
||||
)
|
||||
|
||||
result = self._short_role_names.find_short_role_names_by_role_id(short_role_name.role_id)
|
||||
if result is not None:
|
||||
if result.count() > 0:
|
||||
raise ValueError("Short name for role already exists")
|
||||
|
||||
self._short_role_names.add_short_role_name(short_role_name)
|
||||
|
@@ -11,8 +11,8 @@ from bot_data.model.technician_config import TechnicianConfig
|
||||
from bot_data.model.technician_id_config import TechnicianIdConfig
|
||||
from bot_data.model.technician_ping_url_config import TechnicianPingUrlConfig
|
||||
from bot_data.model.user_role_enum import UserRoleEnum
|
||||
from bot_data.service.technician_config_seeder import TechnicianConfigSeeder
|
||||
from bot_graphql.abc.query_abc import QueryABC
|
||||
from modules.permission.abc.permission_service_abc import PermissionServiceABC
|
||||
|
||||
|
||||
class TechnicianConfigMutation(QueryABC):
|
||||
@@ -23,8 +23,8 @@ class TechnicianConfigMutation(QueryABC):
|
||||
servers: ServerRepositoryABC,
|
||||
technician_configs: TechnicianConfigRepositoryABC,
|
||||
db: DatabaseContextABC,
|
||||
permissions: PermissionServiceABC,
|
||||
config_service: ConfigService,
|
||||
tech_seeder: TechnicianConfigSeeder,
|
||||
):
|
||||
QueryABC.__init__(self, "TechnicianConfigMutation")
|
||||
|
||||
@@ -33,12 +33,15 @@ class TechnicianConfigMutation(QueryABC):
|
||||
self._servers = servers
|
||||
self._technician_configs = technician_configs
|
||||
self._db = db
|
||||
self._permissions = permissions
|
||||
self._config_service = config_service
|
||||
self._tech_seeder = tech_seeder
|
||||
|
||||
self.set_field("updateTechnicianConfig", self.resolve_update_technician_config)
|
||||
|
||||
def resolve_update_technician_config(self, *_, input: dict):
|
||||
if not self._technician_configs.does_technician_config_exists():
|
||||
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)
|
||||
|
||||
@@ -56,11 +59,16 @@ class TechnicianConfigMutation(QueryABC):
|
||||
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"]]))
|
||||
if "featureFlags" in input
|
||||
else technician_config.feature_flags
|
||||
)
|
||||
for old_flag in old_feature_flags:
|
||||
if old_flag not in technician_config.feature_flags:
|
||||
technician_config.feature_flags[old_flag] = False
|
||||
|
||||
technician_config.ping_urls = (
|
||||
List(str, input["pingURLs"]) if "pingURLs" in input else technician_config.ping_urls
|
||||
)
|
||||
@@ -78,6 +86,7 @@ class TechnicianConfigMutation(QueryABC):
|
||||
self._update_technician_ids(technician_config)
|
||||
|
||||
self._db.save_changes()
|
||||
self._config_service.reload_technician_config()
|
||||
return technician_config
|
||||
|
||||
def _update_ping_urls(self, new_config: TechnicianConfig):
|
||||
@@ -112,6 +121,3 @@ class TechnicianConfigMutation(QueryABC):
|
||||
continue
|
||||
|
||||
self._technician_configs.add_technician_id_config(TechnicianIdConfig(technician_id))
|
||||
|
||||
self._bot.loop.create_task(self._config_service.reload_technician_config())
|
||||
self._permissions.on_ready()
|
||||
|
@@ -1,11 +1,17 @@
|
||||
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
|
||||
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 +26,8 @@ class UserMutation(QueryABC):
|
||||
permissions: PermissionService,
|
||||
levels: LevelRepositoryABC,
|
||||
level_service: LevelService,
|
||||
user_warnings: UserWarningsRepositoryABC,
|
||||
user_warning_service: UserWarningsService,
|
||||
):
|
||||
QueryABC.__init__(self, "UserMutation")
|
||||
|
||||
@@ -30,20 +38,33 @@ 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)
|
||||
|
||||
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"])
|
||||
|
||||
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()
|
||||
@@ -51,3 +72,19 @@ class UserMutation(QueryABC):
|
||||
|
||||
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)
|
||||
|
@@ -15,7 +15,7 @@ __title__ = "bot_graphql.queries"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.1.7"
|
||||
__version__ = "1.1.10"
|
||||
|
||||
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="7")
|
||||
version_info = VersionInfo(major="1", minor="1", micro="10")
|
||||
|
@@ -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.7"
|
||||
__version__ = "1.1.10"
|
||||
|
||||
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="7")
|
||||
version_info = VersionInfo(major="1", minor="1", micro="10")
|
||||
|
@@ -20,11 +20,16 @@ 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)
|
||||
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
|
||||
)
|
||||
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]),
|
||||
|
@@ -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)
|
||||
|
||||
@@ -47,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(
|
||||
@@ -67,6 +71,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)
|
||||
|
@@ -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)
|
17
kdb-bot/src/bot_graphql/queries/user_warning_query.py
Normal file
17
kdb-bot/src/bot_graphql/queries/user_warning_query.py
Normal file
@@ -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)
|
@@ -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)))
|
||||
|
@@ -15,7 +15,7 @@ __title__ = "modules.achievements"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.1.7"
|
||||
__version__ = "1.1.10"
|
||||
|
||||
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="7")
|
||||
version_info = VersionInfo(major="1", minor="1", micro="10")
|
||||
|
@@ -4,7 +4,7 @@
|
||||
"Version": {
|
||||
"Major": "1",
|
||||
"Minor": "1",
|
||||
"Micro": "7"
|
||||
"Micro": "10"
|
||||
},
|
||||
"Author": "Sven Heidemann",
|
||||
"AuthorEmail": "sven.heidemann@sh-edraft.de",
|
||||
|
@@ -15,7 +15,7 @@ __title__ = "modules.achievements.commands"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.1.7"
|
||||
__version__ = "1.1.10"
|
||||
|
||||
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="7")
|
||||
version_info = VersionInfo(major="1", minor="1", micro="10")
|
||||
|
@@ -15,7 +15,7 @@ __title__ = "modules.achievements.events"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.1.7"
|
||||
__version__ = "1.1.10"
|
||||
|
||||
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="7")
|
||||
version_info = VersionInfo(major="1", minor="1", micro="10")
|
||||
|
@@ -15,7 +15,7 @@ __title__ = "modules.achievements.model"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.1.7"
|
||||
__version__ = "1.1.10"
|
||||
|
||||
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="7")
|
||||
version_info = VersionInfo(major="1", minor="1", micro="10")
|
||||
|
@@ -15,7 +15,7 @@ __title__ = "modules.auto_role"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.1.7"
|
||||
__version__ = "1.1.10"
|
||||
|
||||
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="7")
|
||||
version_info = VersionInfo(major="1", minor="1", micro="10")
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user