Compare commits
108 Commits
1.1.4
...
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 | |||
9be4e344f6 | |||
ebc782e266 | |||
887a46fa7f | |||
0cc8d6f2c7 | |||
3546d38f75 | |||
376cb76036 | |||
8e8da46a54 | |||
94e003312d | |||
fe42d46a38 | |||
4c0a4bc1ae | |||
4161d3a38a | |||
4a763e4e03 | |||
9783424066 | |||
290b5f38a7 | |||
5bfd04722c | |||
12f956f4c3 | |||
0b767fcb68 | |||
a303108da2 | |||
5e9cca5b1d | |||
d1c79c95b2 | |||
378d2c3dc9 | |||
a8ea9f5e49 | |||
957a54ccf3 | |||
0037a30c11 | |||
77e079d91c | |||
25137c6923 | |||
0a0401dd87 | |||
74f3ee2f08 | |||
69fc75fc97 | |||
5a85232374 | |||
5892b209d3 | |||
6715ecacd6 | |||
d72715d51b | |||
a7f9fa5818 | |||
c45916aaee | |||
8bbd57e82f | |||
987a1a664b | |||
99bfa9874a | |||
82058bab0e | |||
a566fca01f | |||
e52f5e4186 | |||
c90ede69dd | |||
85ba012b6f | |||
4cc094576d | |||
74ddc238be | |||
b53ddb1351 | |||
ca5a6c81b8 | |||
7b7bbaea50 | |||
d4b40eb52e | |||
ed524c2f64 | |||
8e3c8459f8 | |||
e661ee1489 | |||
9eaeb2df42 | |||
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
|
65
.gitea/workflows/deploy_dev.yaml
Normal file
65
.gitea/workflows/deploy_dev.yaml
Normal file
@@ -0,0 +1,65 @@
|
||||
name: Deploy dev on push
|
||||
run-name: Deploy dev on push
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- dev
|
||||
|
||||
jobs:
|
||||
on-push-deploy_sh-edraft:
|
||||
runs-on: [ dobby.sh-edraft.de, ubuntu-latest ]
|
||||
container: catthehacker/ubuntu:act-latest
|
||||
steps:
|
||||
- name: Setup Python 3.10
|
||||
uses: actions/setup-python@v3
|
||||
with:
|
||||
python-version: "3.10.12"
|
||||
- run: python -v
|
||||
|
||||
- name: Setup docker
|
||||
uses: https://github.com/papodaca/install-docker-action@main
|
||||
- run: docker -v
|
||||
|
||||
- name: Clone Repository
|
||||
uses: https://github.com/actions/checkout@v3
|
||||
|
||||
- name: Shutdown stack
|
||||
run: docker stack rm kdb_staging
|
||||
|
||||
- name: Prepare bot build
|
||||
run: |
|
||||
cd kdb-bot
|
||||
pip install --extra-index-url https://pip.sh-edraft.de cpl-cli
|
||||
cpl i
|
||||
|
||||
- name: Build docker bot
|
||||
run: |
|
||||
cd kdb-bot
|
||||
docker image prune -f
|
||||
cpl docker-build
|
||||
|
||||
- name: Setup node
|
||||
uses: https://github.com/actions/setup-node@v3
|
||||
|
||||
- name: Prepare web build
|
||||
run: |
|
||||
cd kdb-web
|
||||
npm install -g ts-node
|
||||
npm i
|
||||
|
||||
- name: Build docker web
|
||||
run: |
|
||||
cd kdb-web
|
||||
docker image prune -f
|
||||
npm run docker-build
|
||||
|
||||
- name: Deploy Stack to sh-edraft.de
|
||||
uses: https://github.com/kgierke/portainer-stack-deployment@v1
|
||||
with:
|
||||
portainer-url: "https://docker.sh-edraft.de"
|
||||
portainer-username: "gitea_job"
|
||||
portainer-password: "${{ secrets.docker_job }}"
|
||||
portainer-endpoint: 2
|
||||
name: kdb_staging
|
||||
file: ./docker-compose.staging.yml
|
||||
variables: '{}'
|
65
.gitea/workflows/deploy_prod.yaml
Normal file
65
.gitea/workflows/deploy_prod.yaml
Normal file
@@ -0,0 +1,65 @@
|
||||
name: Deploy dev on push
|
||||
run-name: Deploy dev on push
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
|
||||
jobs:
|
||||
on-push-deploy_sh-edraft:
|
||||
runs-on: [ dobby.sh-edraft.de, ubuntu-latest ]
|
||||
container: catthehacker/ubuntu:act-latest
|
||||
steps:
|
||||
- name: Setup Python 3.10
|
||||
uses: actions/setup-python@v3
|
||||
with:
|
||||
python-version: "3.10.12"
|
||||
- run: python -v
|
||||
|
||||
- name: Setup docker
|
||||
uses: https://github.com/papodaca/install-docker-action@main
|
||||
- run: docker -v
|
||||
|
||||
- name: Clone Repository
|
||||
uses: https://github.com/actions/checkout@v3
|
||||
|
||||
- name: Shutdown stack
|
||||
run: docker stack rm kdb_prod
|
||||
|
||||
- name: Prepare bot build
|
||||
run: |
|
||||
cd kdb-bot
|
||||
pip install --extra-index-url https://pip.sh-edraft.de cpl-cli
|
||||
cpl i
|
||||
|
||||
- name: Build docker bot
|
||||
run: |
|
||||
cd kdb-bot
|
||||
docker image prune -f
|
||||
cpl docker-build
|
||||
|
||||
- name: Setup node
|
||||
uses: https://github.com/actions/setup-node@v3
|
||||
|
||||
- name: Prepare web build
|
||||
run: |
|
||||
cd kdb-web
|
||||
npm install -g ts-node
|
||||
npm i
|
||||
|
||||
- name: Build docker web
|
||||
run: |
|
||||
cd kdb-web
|
||||
docker image prune -f
|
||||
npm run docker-build
|
||||
|
||||
- name: Deploy Stack to sh-edraft.de
|
||||
uses: https://github.com/kgierke/portainer-stack-deployment@v1
|
||||
with:
|
||||
portainer-url: "https://docker.sh-edraft.de"
|
||||
portainer-username: "gitea_job"
|
||||
portainer-password: "${{ secrets.docker_job }}"
|
||||
portainer-endpoint: 2
|
||||
name: kdb_prod
|
||||
file: ./docker-compose.yml
|
||||
variables: '{}'
|
87
docker-compose.staging.yml
Normal file
87
docker-compose.staging.yml
Normal file
@@ -0,0 +1,87 @@
|
||||
version: "3.9"
|
||||
|
||||
volumes:
|
||||
kdb_db_staging_1:
|
||||
|
||||
services:
|
||||
kdb_bot_staging_1:
|
||||
image: sh-edraft.de/kdb-bot:1.1.10
|
||||
restart: unless-stopped
|
||||
depends_on:
|
||||
- kdb_db_staging_1
|
||||
networks:
|
||||
- kdb_test
|
||||
- reverse_proxy
|
||||
volumes:
|
||||
- /opt/kdb/staging/bot/config:/app/bot/config
|
||||
- /opt/kdb/staging/bot/api_config:/app/bot_api/config
|
||||
- /opt/kdb/staging/bot/logs:/app/bot/logs
|
||||
environment:
|
||||
KDB_ENVIRONMENT: "staging"
|
||||
KDB_TOKEN: "OTk4MTU5ODAyMzkzOTY0NTk0.G-csct.b2Y-HxvLz0SfFLl5HpukROv2GaiWhcMABbMzYE"
|
||||
KDB_PREFIX: "!kt "
|
||||
command: bash /app/bot/bot -stage
|
||||
deploy:
|
||||
mode: replicated
|
||||
replicas: 1
|
||||
placement:
|
||||
constraints: [node.role == manager]
|
||||
resources:
|
||||
reservations:
|
||||
cpus: "0.5"
|
||||
memory: 1024M
|
||||
|
||||
kdb_web_staging_1:
|
||||
image: sh-edraft.de/kdb-web:1.1.10
|
||||
depends_on:
|
||||
- kdb_bot_staging_1
|
||||
networks:
|
||||
- kdb_test
|
||||
- reverse_proxy
|
||||
volumes:
|
||||
- /opt/kdb/staging/web/config.json:/usr/share/nginx/html/assets/config.json
|
||||
environment:
|
||||
BOT_CONTAINER_NAME: "kdb_bot_staging_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_staging_1:
|
||||
image: mysql:latest
|
||||
command: mysqld --default-authentication-plugin=mysql_native_password --log_bin_trust_function_creators=1
|
||||
networks:
|
||||
- kdb_test
|
||||
environment:
|
||||
MYSQL_ROOT_PASSWORD: "kd_kdb"
|
||||
MYSQL_USER: "kd_kdb"
|
||||
MYSQL_PASSWORD: "~qELxjvtjJ3r7yg4PZr5!,V}d.{TC4rg"
|
||||
MYSQL_DATABASE: "kd_kdb"
|
||||
ports:
|
||||
- "3308:3306"
|
||||
volumes:
|
||||
- kdb_db_staging_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_test:
|
||||
driver: overlay
|
||||
attachable: true
|
87
docker-compose.yml
Normal file
87
docker-compose.yml
Normal file
@@ -0,0 +1,87 @@
|
||||
version: "3.9"
|
||||
|
||||
volumes:
|
||||
kdb_db_prod_1:
|
||||
|
||||
services:
|
||||
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.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
|
||||
|
||||
networks:
|
||||
reverse_proxy:
|
||||
external: true
|
||||
kdb_prod:
|
||||
driver: overlay
|
||||
attachable: true
|
@@ -16,6 +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/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",
|
||||
@@ -35,7 +37,7 @@
|
||||
"stage": "export KDB_ENVIRONMENT=staging; export KDB_NAME=KDB-Stage; cpl start;",
|
||||
"pre-dev": "cpl build",
|
||||
"dev": "export KDB_ENVIRONMENT=development; export KDB_NAME=KDB-Dev; cpl start;",
|
||||
"docker-build": "cpl build $ARGS; docker build -t kdb-bot/kdb-bot:$(cpl gv) .;",
|
||||
"docker-build": "cpl build $ARGS; docker build -t sh-edraft.de/kdb-bot:$(cpl gv) .;",
|
||||
"dc-up": "docker-compose up -d",
|
||||
"dc-down": "docker-compose down",
|
||||
"docker": "cpl dc-down; cpl docker-build; cpl dc-up;"
|
||||
|
@@ -1,10 +1,10 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""
|
||||
bot Keksdose bot
|
||||
bot sh-edraft.de Discord bot
|
||||
~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Discord bot for the Keksdose discord Server
|
||||
Discord bot for customers of sh-edraft.de
|
||||
|
||||
:copyright: (c) 2022 - 2023 sh-edraft.de
|
||||
:license: MIT, see LICENSE for more details.
|
||||
@@ -15,7 +15,7 @@ __title__ = "bot"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.1.4"
|
||||
__version__ = "1.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="4")
|
||||
version_info = VersionInfo(major="1", minor="1", micro="10")
|
||||
|
@@ -4,12 +4,12 @@
|
||||
"Version": {
|
||||
"Major": "1",
|
||||
"Minor": "1",
|
||||
"Micro": "4"
|
||||
"Micro": "10"
|
||||
},
|
||||
"Author": "Sven Heidemann",
|
||||
"AuthorEmail": "sven.heidemann@sh-edraft.de",
|
||||
"Description": "Keksdose bot",
|
||||
"LongDescription": "Discord bot for the Keksdose discord Server",
|
||||
"Description": "sh-edraft.de Discord bot",
|
||||
"LongDescription": "Discord bot for customers of sh-edraft.de",
|
||||
"URL": "https://www.sh-edraft.de",
|
||||
"CopyrightDate": "2022 - 2023",
|
||||
"CopyrightName": "sh-edraft.de",
|
||||
@@ -68,6 +68,8 @@
|
||||
"../modules/database/database.json",
|
||||
"../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
@@ -1,10 +1,10 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""
|
||||
bot Keksdose bot
|
||||
bot sh-edraft.de Discord bot
|
||||
~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Discord bot for the Keksdose discord Server
|
||||
Discord bot for customers of sh-edraft.de
|
||||
|
||||
:copyright: (c) 2022 - 2023 sh-edraft.de
|
||||
:license: MIT, see LICENSE for more details.
|
||||
@@ -15,7 +15,7 @@ __title__ = "bot.extension"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.1.4"
|
||||
__version__ = "1.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="4")
|
||||
version_info = VersionInfo(major="1", minor="1", micro="10")
|
||||
|
@@ -13,6 +13,8 @@ from modules.config.config_module import ConfigModule
|
||||
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
|
||||
|
||||
|
||||
@@ -35,6 +37,8 @@ class ModuleList:
|
||||
ApiModule,
|
||||
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,14 +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,
|
||||
@@ -50,3 +56,9 @@ class StartupMigrationExtension(StartupExtensionABC):
|
||||
services.add_transient(MigrationABC, ConfigMigration) # 19.07.2023 #127 - 1.1.0
|
||||
services.add_transient(MigrationABC, ConfigFeatureFlagsMigration) # 15.08.2023 #334 - 1.1.0
|
||||
services.add_transient(MigrationABC, DefaultRoleMigration) # 24.09.2023 #360 - 1.1.3
|
||||
services.add_transient(MigrationABC, ShortRoleNameMigration) # 28.09.2023 #378 - 1.1.7
|
||||
services.add_transient(MigrationABC, FixUpdatesMigration) # 28.09.2023 #378 - 1.1.7
|
||||
services.add_transient(MigrationABC, ShortRoleNameOnlyHighestMigration) # 02.10.2023 #391 - 1.1.9
|
||||
services.add_transient(MigrationABC, FixUserHistoryMigration) # 10.10.2023 #401 - 1.2.0
|
||||
services.add_transient(MigrationABC, BirthdayMigration) # 10.10.2023 #401 - 1.2.0
|
||||
services.add_transient(MigrationABC, SteamSpecialOfferMigration) # 10.10.2023 #188 - 1.2.0
|
||||
|
@@ -82,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...",
|
||||
@@ -93,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": {
|
||||
@@ -122,6 +128,9 @@
|
||||
},
|
||||
"success": "auto-role {} wurde entfernt :D"
|
||||
},
|
||||
"react": {
|
||||
"success": "Alle Reaktionen wurden hinzugefügt"
|
||||
},
|
||||
"rule": {
|
||||
"add": {
|
||||
"error": {
|
||||
@@ -151,33 +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": {
|
||||
"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"
|
||||
@@ -204,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.",
|
||||
@@ -220,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"
|
||||
},
|
||||
@@ -340,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": {
|
||||
@@ -353,7 +374,8 @@
|
||||
},
|
||||
"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."
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,10 +1,10 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""
|
||||
bot Keksdose bot
|
||||
bot sh-edraft.de Discord bot
|
||||
~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Discord bot for the Keksdose discord Server
|
||||
Discord bot for customers of sh-edraft.de
|
||||
|
||||
:copyright: (c) 2022 - 2023 sh-edraft.de
|
||||
:license: MIT, see LICENSE for more details.
|
||||
@@ -15,7 +15,7 @@ __title__ = "bot_api"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.1.4"
|
||||
__version__ = "1.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="4")
|
||||
version_info = VersionInfo(major="1", minor="1", micro="10")
|
||||
|
@@ -1,10 +1,10 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""
|
||||
bot Keksdose bot
|
||||
bot sh-edraft.de Discord bot
|
||||
~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Discord bot for the Keksdose discord Server
|
||||
Discord bot for customers of sh-edraft.de
|
||||
|
||||
:copyright: (c) 2022 - 2023 sh-edraft.de
|
||||
:license: MIT, see LICENSE for more details.
|
||||
@@ -15,7 +15,7 @@ __title__ = "bot_api.abc"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.1.4"
|
||||
__version__ = "1.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="4")
|
||||
version_info = VersionInfo(major="1", minor="1", micro="10")
|
||||
|
@@ -4,7 +4,7 @@
|
||||
"Version": {
|
||||
"Major": "1",
|
||||
"Minor": "1",
|
||||
"Micro": "4"
|
||||
"Micro": "10"
|
||||
},
|
||||
"Author": "",
|
||||
"AuthorEmail": "",
|
||||
|
@@ -1,10 +1,10 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""
|
||||
bot Keksdose bot
|
||||
bot sh-edraft.de Discord bot
|
||||
~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Discord bot for the Keksdose discord Server
|
||||
Discord bot for customers of sh-edraft.de
|
||||
|
||||
:copyright: (c) 2022 - 2023 sh-edraft.de
|
||||
:license: MIT, see LICENSE for more details.
|
||||
@@ -15,7 +15,7 @@ __title__ = "bot_api.configuration"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.1.4"
|
||||
__version__ = "1.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="4")
|
||||
version_info = VersionInfo(major="1", minor="1", micro="10")
|
||||
|
@@ -1,10 +1,10 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""
|
||||
bot Keksdose bot
|
||||
bot sh-edraft.de Discord bot
|
||||
~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Discord bot for the Keksdose discord Server
|
||||
Discord bot for customers of sh-edraft.de
|
||||
|
||||
:copyright: (c) 2022 - 2023 sh-edraft.de
|
||||
:license: MIT, see LICENSE for more details.
|
||||
@@ -15,7 +15,7 @@ __title__ = "bot_api.controller"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.1.4"
|
||||
__version__ = "1.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="4")
|
||||
version_info = VersionInfo(major="1", minor="1", micro="10")
|
||||
|
@@ -1,10 +1,10 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""
|
||||
bot Keksdose bot
|
||||
bot sh-edraft.de Discord bot
|
||||
~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Discord bot for the Keksdose discord Server
|
||||
Discord bot for customers of sh-edraft.de
|
||||
|
||||
:copyright: (c) 2022 - 2023 sh-edraft.de
|
||||
:license: MIT, see LICENSE for more details.
|
||||
@@ -15,7 +15,7 @@ __title__ = "bot_api.event"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.1.4"
|
||||
__version__ = "1.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="4")
|
||||
version_info = VersionInfo(major="1", minor="1", micro="10")
|
||||
|
@@ -1,10 +1,10 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""
|
||||
bot Keksdose bot
|
||||
bot sh-edraft.de Discord bot
|
||||
~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Discord bot for the Keksdose discord Server
|
||||
Discord bot for customers of sh-edraft.de
|
||||
|
||||
:copyright: (c) 2022 - 2023 sh-edraft.de
|
||||
:license: MIT, see LICENSE for more details.
|
||||
@@ -15,7 +15,7 @@ __title__ = "bot_api.exception"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.1.4"
|
||||
__version__ = "1.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="4")
|
||||
version_info = VersionInfo(major="1", minor="1", micro="10")
|
||||
|
@@ -1,10 +1,10 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""
|
||||
bot Keksdose bot
|
||||
bot sh-edraft.de Discord bot
|
||||
~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Discord bot for the Keksdose discord Server
|
||||
Discord bot for customers of sh-edraft.de
|
||||
|
||||
:copyright: (c) 2022 - 2023 sh-edraft.de
|
||||
:license: MIT, see LICENSE for more details.
|
||||
@@ -15,7 +15,7 @@ __title__ = "bot_api.filter"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.1.4"
|
||||
__version__ = "1.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="4")
|
||||
version_info = VersionInfo(major="1", minor="1", micro="10")
|
||||
|
@@ -1,10 +1,10 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""
|
||||
bot Keksdose bot
|
||||
bot sh-edraft.de Discord bot
|
||||
~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Discord bot for the Keksdose discord Server
|
||||
Discord bot for customers of sh-edraft.de
|
||||
|
||||
:copyright: (c) 2022 - 2023 sh-edraft.de
|
||||
:license: MIT, see LICENSE for more details.
|
||||
@@ -15,7 +15,7 @@ __title__ = "bot_api.filter.discord"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.1.4"
|
||||
__version__ = "1.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="4")
|
||||
version_info = VersionInfo(major="1", minor="1", micro="10")
|
||||
|
@@ -1,10 +1,10 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""
|
||||
bot Keksdose bot
|
||||
bot sh-edraft.de Discord bot
|
||||
~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Discord bot for the Keksdose discord Server
|
||||
Discord bot for customers of sh-edraft.de
|
||||
|
||||
:copyright: (c) 2022 - 2023 sh-edraft.de
|
||||
:license: MIT, see LICENSE for more details.
|
||||
@@ -15,7 +15,7 @@ __title__ = "bot_api.logging"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.1.4"
|
||||
__version__ = "1.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="4")
|
||||
version_info = VersionInfo(major="1", minor="1", micro="10")
|
||||
|
@@ -1,10 +1,10 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""
|
||||
bot Keksdose bot
|
||||
bot sh-edraft.de Discord bot
|
||||
~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Discord bot for the Keksdose discord Server
|
||||
Discord bot for customers of sh-edraft.de
|
||||
|
||||
:copyright: (c) 2022 - 2023 sh-edraft.de
|
||||
:license: MIT, see LICENSE for more details.
|
||||
@@ -15,7 +15,7 @@ __title__ = "bot_api.model"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.1.4"
|
||||
__version__ = "1.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="4")
|
||||
version_info = VersionInfo(major="1", minor="1", micro="10")
|
||||
|
@@ -1,10 +1,10 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""
|
||||
bot Keksdose bot
|
||||
bot sh-edraft.de Discord bot
|
||||
~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Discord bot for the Keksdose discord Server
|
||||
Discord bot for customers of sh-edraft.de
|
||||
|
||||
:copyright: (c) 2022 - 2023 sh-edraft.de
|
||||
:license: MIT, see LICENSE for more details.
|
||||
@@ -15,7 +15,7 @@ __title__ = "bot_api.model.discord"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.1.4"
|
||||
__version__ = "1.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="4")
|
||||
version_info = VersionInfo(major="1", minor="1", micro="10")
|
||||
|
@@ -1,10 +1,10 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""
|
||||
bot Keksdose bot
|
||||
bot sh-edraft.de Discord bot
|
||||
~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Discord bot for the Keksdose discord Server
|
||||
Discord bot for customers of sh-edraft.de
|
||||
|
||||
:copyright: (c) 2022 - 2023 sh-edraft.de
|
||||
:license: MIT, see LICENSE for more details.
|
||||
@@ -15,7 +15,7 @@ __title__ = "bot_api.route"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.1.4"
|
||||
__version__ = "1.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="4")
|
||||
version_info = VersionInfo(major="1", minor="1", micro="10")
|
||||
|
@@ -1,10 +1,10 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""
|
||||
bot Keksdose bot
|
||||
bot sh-edraft.de Discord bot
|
||||
~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Discord bot for the Keksdose discord Server
|
||||
Discord bot for customers of sh-edraft.de
|
||||
|
||||
:copyright: (c) 2022 - 2023 sh-edraft.de
|
||||
:license: MIT, see LICENSE for more details.
|
||||
@@ -15,7 +15,7 @@ __title__ = "bot_api.service"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.1.4"
|
||||
__version__ = "1.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="4")
|
||||
version_info = VersionInfo(major="1", minor="1", micro="10")
|
||||
|
@@ -1,10 +1,10 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""
|
||||
bot Keksdose bot
|
||||
bot sh-edraft.de Discord bot
|
||||
~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Discord bot for the Keksdose discord Server
|
||||
Discord bot for customers of sh-edraft.de
|
||||
|
||||
:copyright: (c) 2022 - 2023 sh-edraft.de
|
||||
:license: MIT, see LICENSE for more details.
|
||||
@@ -15,7 +15,7 @@ __title__ = "bot_api.transformer"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.1.4"
|
||||
__version__ = "1.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="4")
|
||||
version_info = VersionInfo(major="1", minor="1", micro="10")
|
||||
|
@@ -1,10 +1,10 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""
|
||||
bot Keksdose bot
|
||||
bot sh-edraft.de Discord bot
|
||||
~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Discord bot for the Keksdose discord Server
|
||||
Discord bot for customers of sh-edraft.de
|
||||
|
||||
:copyright: (c) 2022 - 2023 sh-edraft.de
|
||||
:license: MIT, see LICENSE for more details.
|
||||
@@ -15,7 +15,7 @@ __title__ = "bot_core"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.1.4"
|
||||
__version__ = "1.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="4")
|
||||
version_info = VersionInfo(major="1", minor="1", micro="10")
|
||||
|
@@ -1,10 +1,10 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""
|
||||
bot Keksdose bot
|
||||
bot sh-edraft.de Discord bot
|
||||
~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Discord bot for the Keksdose discord Server
|
||||
Discord bot for customers of sh-edraft.de
|
||||
|
||||
:copyright: (c) 2022 - 2023 sh-edraft.de
|
||||
:license: MIT, see LICENSE for more details.
|
||||
@@ -15,7 +15,7 @@ __title__ = "bot_core.abc"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.1.4"
|
||||
__version__ = "1.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="4")
|
||||
version_info = VersionInfo(major="1", minor="1", micro="10")
|
||||
|
@@ -4,7 +4,7 @@
|
||||
"Version": {
|
||||
"Major": "1",
|
||||
"Minor": "1",
|
||||
"Micro": "4"
|
||||
"Micro": "10"
|
||||
},
|
||||
"Author": "Sven Heidemann",
|
||||
"AuthorEmail": "sven.heidemann@sh-edraft.de",
|
||||
|
@@ -1,10 +1,10 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""
|
||||
bot Keksdose bot
|
||||
bot sh-edraft.de Discord bot
|
||||
~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Discord bot for the Keksdose discord Server
|
||||
Discord bot for customers of sh-edraft.de
|
||||
|
||||
:copyright: (c) 2022 - 2023 sh-edraft.de
|
||||
:license: MIT, see LICENSE for more details.
|
||||
@@ -15,7 +15,7 @@ __title__ = "bot_core.configuration"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.1.4"
|
||||
__version__ = "1.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="4")
|
||||
version_info = VersionInfo(major="1", minor="1", micro="10")
|
||||
|
@@ -16,7 +16,14 @@ class FeatureFlagsEnum(Enum):
|
||||
level_module = "LevelModule"
|
||||
moderator_module = "ModeratorModule"
|
||||
permission_module = "PermissionModule"
|
||||
short_role_name_module = "ShortRoleNameModule"
|
||||
steam_special_offers_module = "SteamSpecialOffersModule"
|
||||
# features
|
||||
api_only = "ApiOnly"
|
||||
presence = "Presence"
|
||||
version_in_presence = "VersionInPresence"
|
||||
game_server = "GameServer"
|
||||
sync_xp = "SyncXp"
|
||||
short_role_name = "ShortRoleName"
|
||||
technician_full_access = "TechnicianFullAccess"
|
||||
steam_special_offers = "SteamSpecialOffers"
|
||||
|
@@ -18,10 +18,17 @@ class FeatureFlagsSettings(ConfigurationModelABC):
|
||||
FeatureFlagsEnum.moderator_module.value: False, # 02.10.2022 #48
|
||||
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
|
||||
FeatureFlagsEnum.version_in_presence.value: False, # 21.03.2023 #253
|
||||
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):
|
||||
|
@@ -1,10 +1,10 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""
|
||||
bot Keksdose bot
|
||||
bot sh-edraft.de Discord bot
|
||||
~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Discord bot for the Keksdose discord Server
|
||||
Discord bot for customers of sh-edraft.de
|
||||
|
||||
:copyright: (c) 2022 - 2023 sh-edraft.de
|
||||
:license: MIT, see LICENSE for more details.
|
||||
@@ -15,7 +15,7 @@ __title__ = "bot_core.core_extension"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.1.4"
|
||||
__version__ = "1.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="4")
|
||||
version_info = VersionInfo(major="1", minor="1", micro="10")
|
||||
|
@@ -1,10 +1,10 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""
|
||||
bot Keksdose bot
|
||||
bot sh-edraft.de Discord bot
|
||||
~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Discord bot for the Keksdose discord Server
|
||||
Discord bot for customers of sh-edraft.de
|
||||
|
||||
:copyright: (c) 2022 - 2023 sh-edraft.de
|
||||
:license: MIT, see LICENSE for more details.
|
||||
@@ -15,7 +15,7 @@ __title__ = "bot_core.events"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.1.4"
|
||||
__version__ = "1.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="4")
|
||||
version_info = VersionInfo(major="1", minor="1", micro="10")
|
||||
|
@@ -1,10 +1,10 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""
|
||||
bot Keksdose bot
|
||||
bot sh-edraft.de Discord bot
|
||||
~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Discord bot for the Keksdose discord Server
|
||||
Discord bot for customers of sh-edraft.de
|
||||
|
||||
:copyright: (c) 2022 - 2023 sh-edraft.de
|
||||
:license: MIT, see LICENSE for more details.
|
||||
@@ -15,7 +15,7 @@ __title__ = "bot_core.exception"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.1.4"
|
||||
__version__ = "1.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="4")
|
||||
version_info = VersionInfo(major="1", minor="1", micro="10")
|
||||
|
@@ -1,10 +1,10 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""
|
||||
bot Keksdose bot
|
||||
bot sh-edraft.de Discord bot
|
||||
~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Discord bot for the Keksdose discord Server
|
||||
Discord bot for customers of sh-edraft.de
|
||||
|
||||
:copyright: (c) 2022 - 2023 sh-edraft.de
|
||||
:license: MIT, see LICENSE for more details.
|
||||
@@ -15,7 +15,7 @@ __title__ = "bot_core.helper"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.1.4"
|
||||
__version__ = "1.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="4")
|
||||
version_info = VersionInfo(major="1", minor="1", micro="10")
|
||||
|
@@ -1,10 +1,10 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""
|
||||
bot Keksdose bot
|
||||
bot sh-edraft.de Discord bot
|
||||
~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Discord bot for the Keksdose discord Server
|
||||
Discord bot for customers of sh-edraft.de
|
||||
|
||||
:copyright: (c) 2022 - 2023 sh-edraft.de
|
||||
:license: MIT, see LICENSE for more details.
|
||||
@@ -15,7 +15,7 @@ __title__ = "bot_core.logging"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.1.4"
|
||||
__version__ = "1.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="4")
|
||||
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)
|
@@ -1,10 +1,10 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""
|
||||
bot Keksdose bot
|
||||
bot sh-edraft.de Discord bot
|
||||
~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Discord bot for the Keksdose discord Server
|
||||
Discord bot for customers of sh-edraft.de
|
||||
|
||||
:copyright: (c) 2022 - 2023 sh-edraft.de
|
||||
:license: MIT, see LICENSE for more details.
|
||||
@@ -15,7 +15,7 @@ __title__ = "bot_core.pipes"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.1.4"
|
||||
__version__ = "1.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="4")
|
||||
version_info = VersionInfo(major="1", minor="1", micro="10")
|
||||
|
@@ -1,10 +1,10 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""
|
||||
bot Keksdose bot
|
||||
bot sh-edraft.de Discord bot
|
||||
~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Discord bot for the Keksdose discord Server
|
||||
Discord bot for customers of sh-edraft.de
|
||||
|
||||
:copyright: (c) 2022 - 2023 sh-edraft.de
|
||||
:license: MIT, see LICENSE for more details.
|
||||
@@ -15,7 +15,7 @@ __title__ = "bot_core.service"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.1.4"
|
||||
__version__ = "1.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="4")
|
||||
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()
|
||||
|
@@ -24,7 +24,6 @@ from bot_data.model.server_config import ServerConfig
|
||||
from bot_data.model.user import User
|
||||
from bot_data.model.user_joined_server import UserJoinedServer
|
||||
from bot_data.model.user_joined_voice_channel import UserJoinedVoiceChannel
|
||||
from bot_data.service.seeder_service import SeederService
|
||||
from bot_data.service.user_repository_service import ServerRepositoryABC
|
||||
from modules.achievements.achievement_service import AchievementService
|
||||
|
||||
@@ -34,7 +33,6 @@ class DataIntegrityService:
|
||||
self,
|
||||
config: ConfigurationABC,
|
||||
logger: DatabaseLogger,
|
||||
seeder: SeederService,
|
||||
bot: DiscordBotServiceABC,
|
||||
db_context: DatabaseContextABC,
|
||||
server_repo: ServerRepositoryABC,
|
||||
@@ -51,7 +49,6 @@ class DataIntegrityService:
|
||||
self._config = config
|
||||
|
||||
self._logger = logger
|
||||
self._seeder = seeder
|
||||
self._bot = bot
|
||||
self._db_context = db_context
|
||||
self._servers = server_repo
|
||||
|
@@ -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:
|
||||
|
@@ -1,10 +1,10 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""
|
||||
bot Keksdose bot
|
||||
bot sh-edraft.de Discord bot
|
||||
~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Discord bot for the Keksdose discord Server
|
||||
Discord bot for customers of sh-edraft.de
|
||||
|
||||
:copyright: (c) 2022 - 2023 sh-edraft.de
|
||||
:license: MIT, see LICENSE for more details.
|
||||
@@ -15,7 +15,7 @@ __title__ = "bot_data"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.1.4"
|
||||
__version__ = "1.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="4")
|
||||
version_info = VersionInfo(major="1", minor="1", micro="10")
|
||||
|
@@ -1,10 +1,10 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""
|
||||
bot Keksdose bot
|
||||
bot sh-edraft.de Discord bot
|
||||
~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Discord bot for the Keksdose discord Server
|
||||
Discord bot for customers of sh-edraft.de
|
||||
|
||||
:copyright: (c) 2022 - 2023 sh-edraft.de
|
||||
:license: MIT, see LICENSE for more details.
|
||||
@@ -15,7 +15,7 @@ __title__ = "bot_data.abc"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.1.4"
|
||||
__version__ = "1.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="4")
|
||||
version_info = VersionInfo(major="1", minor="1", micro="10")
|
||||
|
@@ -23,7 +23,7 @@ class GameServerRepositoryABC(ABC):
|
||||
pass
|
||||
|
||||
@abstractmethod
|
||||
def get_game_server_by_api_key_id(self, id: int) -> GameServer:
|
||||
def get_game_servers_by_api_key_id(self, id: int) -> List[GameServer]:
|
||||
pass
|
||||
|
||||
@abstractmethod
|
||||
|
@@ -1,13 +1,20 @@
|
||||
import os
|
||||
from abc import ABC, abstractmethod
|
||||
|
||||
from cpl_core.dependency_injection import ServiceProviderABC
|
||||
from mysql.connector.cursor import MySQLCursorBuffered
|
||||
|
||||
from bot_data.db_context import DBContext
|
||||
|
||||
|
||||
class MigrationABC(ABC):
|
||||
name = None
|
||||
prio = 0
|
||||
|
||||
@abstractmethod
|
||||
def __init__(self):
|
||||
pass
|
||||
@ServiceProviderABC.inject
|
||||
def __init__(self, db: DBContext):
|
||||
self._cursor: MySQLCursorBuffered = db.cursor
|
||||
|
||||
@abstractmethod
|
||||
def upgrade(self):
|
||||
@@ -16,3 +23,10 @@ class MigrationABC(ABC):
|
||||
@abstractmethod
|
||||
def downgrade(self):
|
||||
pass
|
||||
|
||||
def _exec(self, self_file: str, file: str):
|
||||
path = f"{os.path.dirname(os.path.realpath(self_file))}/db_history_scripts"
|
||||
sql = open(f"{path}/{file}").read()
|
||||
|
||||
for statement in sql.split("\n\n"):
|
||||
self._cursor.execute(statement + ";")
|
||||
|
39
kdb-bot/src/bot_data/abc/short_role_name_repository_abc.py
Normal file
39
kdb-bot/src/bot_data/abc/short_role_name_repository_abc.py
Normal file
@@ -0,0 +1,39 @@
|
||||
from abc import ABC, abstractmethod
|
||||
|
||||
from cpl_query.extension import List
|
||||
|
||||
from bot_data.model.short_role_name import ShortRoleName
|
||||
|
||||
|
||||
class ShortRoleNameRepositoryABC(ABC):
|
||||
@abstractmethod
|
||||
def __init__(self):
|
||||
pass
|
||||
|
||||
@abstractmethod
|
||||
def get_short_role_names(self) -> List[ShortRoleName]:
|
||||
pass
|
||||
|
||||
@abstractmethod
|
||||
def get_short_role_name_by_id(self, id: int) -> ShortRoleName:
|
||||
pass
|
||||
|
||||
@abstractmethod
|
||||
def find_short_role_names_by_role_id(self, role_id: int) -> List[ShortRoleName]:
|
||||
pass
|
||||
|
||||
@abstractmethod
|
||||
def get_short_role_names_by_server_id(self, id: int) -> List[ShortRoleName]:
|
||||
pass
|
||||
|
||||
@abstractmethod
|
||||
def add_short_role_name(self, short_role_name: ShortRoleName):
|
||||
pass
|
||||
|
||||
@abstractmethod
|
||||
def update_short_role_name(self, short_role_name: ShortRoleName):
|
||||
pass
|
||||
|
||||
@abstractmethod
|
||||
def delete_short_role_name(self, short_role_name: ShortRoleName):
|
||||
pass
|
@@ -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
|
@@ -14,6 +14,10 @@ class UserGameIdentRepositoryABC(ABC):
|
||||
def get_user_game_idents(self) -> List[UserGameIdent]:
|
||||
pass
|
||||
|
||||
@abstractmethod
|
||||
def get_user_game_idents_by_game_server_id(self, id: int) -> List[UserGameIdent]:
|
||||
pass
|
||||
|
||||
@abstractmethod
|
||||
def get_user_game_ident_by_id(self, id: int) -> UserGameIdent:
|
||||
pass
|
||||
|
@@ -4,7 +4,7 @@
|
||||
"Version": {
|
||||
"Major": "1",
|
||||
"Minor": "1",
|
||||
"Micro": "4"
|
||||
"Micro": "10"
|
||||
},
|
||||
"Author": "Sven Heidemann",
|
||||
"AuthorEmail": "sven.heidemann@sh-edraft.de",
|
||||
|
@@ -16,6 +16,8 @@ from bot_data.abc.known_user_repository_abc import KnownUserRepositoryABC
|
||||
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
|
||||
@@ -41,6 +43,8 @@ from bot_data.service.seeder_service import SeederService
|
||||
from bot_data.service.server_config_repository_service import ServerConfigRepositoryService
|
||||
from bot_data.service.server_config_seeder import ServerConfigSeeder
|
||||
from bot_data.service.server_repository_service import ServerRepositoryService
|
||||
from bot_data.service.short_role_name_repository_service import ShortRoleNameRepositoryService
|
||||
from bot_data.service.steam_special_offer_repository_service import SteamSpecialOfferRepositoryService
|
||||
from bot_data.service.technician_config_repository_service import TechnicianConfigRepositoryService
|
||||
from bot_data.service.technician_config_seeder import TechnicianConfigSeeder
|
||||
from bot_data.service.user_game_ident_repository_service import UserGameIdentRepositoryService
|
||||
@@ -89,6 +93,8 @@ class DataModule(ModuleABC):
|
||||
services.add_transient(AchievementRepositoryABC, AchievementRepositoryService)
|
||||
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)
|
||||
|
@@ -1,10 +1,10 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""
|
||||
bot Keksdose bot
|
||||
bot sh-edraft.de Discord bot
|
||||
~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Discord bot for the Keksdose discord Server
|
||||
Discord bot for customers of sh-edraft.de
|
||||
|
||||
:copyright: (c) 2022 - 2023 sh-edraft.de
|
||||
:license: MIT, see LICENSE for more details.
|
||||
@@ -15,7 +15,7 @@ __title__ = "bot_data.migration"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.1.4"
|
||||
__version__ = "1.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="4")
|
||||
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,5 +1,3 @@
|
||||
import os
|
||||
|
||||
from bot_core.logging.database_logger import DatabaseLogger
|
||||
from bot_data.abc.migration_abc import MigrationABC
|
||||
from bot_data.db_context import DBContext
|
||||
@@ -12,26 +10,18 @@ class ConfigMigration(MigrationABC):
|
||||
MigrationABC.__init__(self)
|
||||
self._logger = logger
|
||||
self._db = db
|
||||
self._cursor = db.cursor
|
||||
|
||||
def _exec(self, file: str):
|
||||
path = f"{os.path.dirname(os.path.realpath(__file__))}/db_history_scripts"
|
||||
sql = open(f"{path}/{file}").read()
|
||||
|
||||
for statement in sql.split("\n\n"):
|
||||
self._cursor.execute(statement + ";")
|
||||
|
||||
def upgrade(self):
|
||||
self._logger.debug(__name__, "Running upgrade")
|
||||
self._server_upgrade()
|
||||
self._technician_upgrade()
|
||||
|
||||
self._exec("config/server.sql")
|
||||
self._exec("config/server_afk_channels.sql")
|
||||
self._exec("config/server_team_roles.sql")
|
||||
self._exec("config/technician.sql")
|
||||
self._exec("config/technician_ids.sql")
|
||||
self._exec("config/technician_ping_urls.sql")
|
||||
self._exec(__file__, "config/server.sql")
|
||||
self._exec(__file__, "config/server_afk_channels.sql")
|
||||
self._exec(__file__, "config/server_team_roles.sql")
|
||||
self._exec(__file__, "config/technician.sql")
|
||||
self._exec(__file__, "config/technician_ids.sql")
|
||||
self._exec(__file__, "config/technician_ping_urls.sql")
|
||||
|
||||
def _server_upgrade(self):
|
||||
self._cursor.execute(
|
||||
|
@@ -1,5 +1,3 @@
|
||||
import os
|
||||
|
||||
from bot_core.logging.database_logger import DatabaseLogger
|
||||
from bot_data.abc.migration_abc import MigrationABC
|
||||
from bot_data.db_context import DBContext
|
||||
@@ -15,33 +13,26 @@ class DBHistoryMigration(MigrationABC):
|
||||
self._db = db
|
||||
self._cursor = db.cursor
|
||||
|
||||
def _exec(self, file: str):
|
||||
path = f"{os.path.dirname(os.path.realpath(__file__))}/db_history_scripts"
|
||||
sql = open(f"{path}/{file}").read()
|
||||
|
||||
for statement in sql.split("\n\n"):
|
||||
self._cursor.execute(statement + ";")
|
||||
|
||||
def upgrade(self):
|
||||
self._logger.debug(__name__, "Running upgrade")
|
||||
|
||||
self._exec("api_keys.sql")
|
||||
self._exec("auth_users.sql")
|
||||
self._exec("auth_user_users_relation.sql")
|
||||
self._exec("auto_role_rules.sql")
|
||||
self._exec("auto_roles.sql")
|
||||
self._exec("clients.sql")
|
||||
self._exec("game_servers.sql")
|
||||
self._exec("known_users.sql")
|
||||
self._exec("levels.sql")
|
||||
self._exec("servers.sql")
|
||||
self._exec("user_game_idents.sql")
|
||||
self._exec("user_joined_game_servers.sql")
|
||||
self._exec("user_joined_servers.sql")
|
||||
self._exec("user_joined_voice_channel.sql")
|
||||
self._exec("user_message_count_per_hour.sql")
|
||||
self._exec("users.sql")
|
||||
self._exec("user_warnings.sql")
|
||||
self._exec(__file__, "api_keys.sql")
|
||||
self._exec(__file__, "auth_users.sql")
|
||||
self._exec(__file__, "auth_user_users_relation.sql")
|
||||
self._exec(__file__, "auto_role_rules.sql")
|
||||
self._exec(__file__, "auto_roles.sql")
|
||||
self._exec(__file__, "clients.sql")
|
||||
self._exec(__file__, "game_servers.sql")
|
||||
self._exec(__file__, "known_users.sql")
|
||||
self._exec(__file__, "levels.sql")
|
||||
self._exec(__file__, "servers.sql")
|
||||
self._exec(__file__, "user_game_idents.sql")
|
||||
self._exec(__file__, "user_joined_game_servers.sql")
|
||||
self._exec(__file__, "user_joined_servers.sql")
|
||||
self._exec(__file__, "user_joined_voice_channel.sql")
|
||||
self._exec(__file__, "user_message_count_per_hour.sql")
|
||||
self._exec(__file__, "users.sql")
|
||||
self._exec(__file__, "user_warnings.sql")
|
||||
|
||||
self._logger.debug(__name__, "Finished history upgrade")
|
||||
|
||||
|
@@ -1,23 +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,
|
||||
`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`;
|
||||
@@ -27,44 +30,46 @@ CREATE TRIGGER `TR_CFG_ServerUpdate`
|
||||
ON `CFG_Server`
|
||||
FOR EACH ROW
|
||||
BEGIN
|
||||
INSERT INTO `CFG_ServerHistory` (
|
||||
`Id`,
|
||||
`MessageDeleteTimer`,
|
||||
`NotificationChatId`,
|
||||
`MaxVoiceStateHours`,
|
||||
`XpPerMessage`,
|
||||
`XpPerReaction`,
|
||||
`MaxMessageXpPerHour`,
|
||||
`XpPerOntimeHour`,
|
||||
`XpPerEventParticipation`,
|
||||
`XpPerAchievement`,
|
||||
`AFKCommandChannelId`,
|
||||
`HelpVoiceChannelId`,
|
||||
`TeamChannelId`,
|
||||
`LoginMessageChannelId`,
|
||||
`ServerId`,
|
||||
`DateFrom`,
|
||||
`DateTo`
|
||||
)
|
||||
VALUES (
|
||||
OLD.Id,
|
||||
OLD.MessageDeleteTimer,
|
||||
OLD.NotificationChatId,
|
||||
OLD.MaxVoiceStateHours,
|
||||
OLD.XpPerMessage,
|
||||
OLD.XpPerReaction,
|
||||
OLD.MaxMessageXpPerHour,
|
||||
OLD.XpPerOntimeHour,
|
||||
OLD.XpPerEventParticipation,
|
||||
OLD.XpPerAchievement,
|
||||
OLD.AFKCommandChannelId,
|
||||
OLD.HelpVoiceChannelId,
|
||||
OLD.TeamChannelId,
|
||||
OLD.LoginMessageChannelId,
|
||||
OLD.ServerId,
|
||||
OLD.LastModifiedAt,
|
||||
CURRENT_TIMESTAMP(6)
|
||||
);
|
||||
INSERT INTO `CFG_ServerHistory` (`Id`,
|
||||
`MessageDeleteTimer`,
|
||||
`NotificationChatId`,
|
||||
`MaxVoiceStateHours`,
|
||||
`XpPerMessage`,
|
||||
`XpPerReaction`,
|
||||
`MaxMessageXpPerHour`,
|
||||
`XpPerOntimeHour`,
|
||||
`XpPerEventParticipation`,
|
||||
`XpPerAchievement`,
|
||||
`AFKCommandChannelId`,
|
||||
`HelpVoiceChannelId`,
|
||||
`TeamChannelId`,
|
||||
`LoginMessageChannelId`,
|
||||
`DefaultRoleId`,
|
||||
`ShortRoleNameSetOnlyHighest`,
|
||||
`FeatureFlags`,
|
||||
`ServerId`,
|
||||
`DateFrom`,
|
||||
`DateTo`)
|
||||
VALUES (OLD.Id,
|
||||
OLD.MessageDeleteTimer,
|
||||
OLD.NotificationChatId,
|
||||
OLD.MaxVoiceStateHours,
|
||||
OLD.XpPerMessage,
|
||||
OLD.XpPerReaction,
|
||||
OLD.MaxMessageXpPerHour,
|
||||
OLD.XpPerOntimeHour,
|
||||
OLD.XpPerEventParticipation,
|
||||
OLD.XpPerAchievement,
|
||||
OLD.AFKCommandChannelId,
|
||||
OLD.HelpVoiceChannelId,
|
||||
OLD.TeamChannelId,
|
||||
OLD.LoginMessageChannelId,
|
||||
OLD.DefaultRoleId,
|
||||
OLD.ShortRoleNameSetOnlyHighest,
|
||||
OLD.FeatureFlags,
|
||||
OLD.ServerId,
|
||||
OLD.LastModifiedAt,
|
||||
CURRENT_TIMESTAMP(6));
|
||||
END;
|
||||
|
||||
DROP TRIGGER IF EXISTS `TR_CFG_ServerDelete`;
|
||||
@@ -74,44 +79,46 @@ CREATE TRIGGER `TR_CFG_ServerDelete`
|
||||
ON `CFG_Server`
|
||||
FOR EACH ROW
|
||||
BEGIN
|
||||
INSERT INTO `CFG_ServerHistory` (
|
||||
`Id`,
|
||||
`MessageDeleteTimer`,
|
||||
`NotificationChatId`,
|
||||
`MaxVoiceStateHours`,
|
||||
`XpPerMessage`,
|
||||
`XpPerReaction`,
|
||||
`MaxMessageXpPerHour`,
|
||||
`XpPerOntimeHour`,
|
||||
`XpPerEventParticipation`,
|
||||
`XpPerAchievement`,
|
||||
`AFKCommandChannelId`,
|
||||
`HelpVoiceChannelId`,
|
||||
`TeamChannelId`,
|
||||
`LoginMessageChannelId`,
|
||||
`ServerId`,
|
||||
`Deleted`,
|
||||
`DateFrom`,
|
||||
`DateTo`
|
||||
)
|
||||
VALUES (
|
||||
OLD.Id,
|
||||
OLD.MessageDeleteTimer,
|
||||
OLD.NotificationChatId,
|
||||
OLD.MaxVoiceStateHours,
|
||||
OLD.XpPerMessage,
|
||||
OLD.XpPerReaction,
|
||||
OLD.MaxMessageXpPerHour,
|
||||
OLD.XpPerOntimeHour,
|
||||
OLD.XpPerEventParticipation,
|
||||
OLD.XpPerAchievement,
|
||||
OLD.AFKCommandChannelId,
|
||||
OLD.HelpVoiceChannelId,
|
||||
OLD.TeamChannelId,
|
||||
OLD.LoginMessageChannelId,
|
||||
OLD.ServerId,
|
||||
TRUE,
|
||||
OLD.LastModifiedAt,
|
||||
CURRENT_TIMESTAMP(6)
|
||||
);
|
||||
INSERT INTO `CFG_ServerHistory` (`Id`,
|
||||
`MessageDeleteTimer`,
|
||||
`NotificationChatId`,
|
||||
`MaxVoiceStateHours`,
|
||||
`XpPerMessage`,
|
||||
`XpPerReaction`,
|
||||
`MaxMessageXpPerHour`,
|
||||
`XpPerOntimeHour`,
|
||||
`XpPerEventParticipation`,
|
||||
`XpPerAchievement`,
|
||||
`AFKCommandChannelId`,
|
||||
`HelpVoiceChannelId`,
|
||||
`TeamChannelId`,
|
||||
`LoginMessageChannelId`,
|
||||
`DefaultRoleId`,
|
||||
`ShortRoleNameSetOnlyHighest`,
|
||||
`ServerId`,
|
||||
`FeatureFlags`,
|
||||
`Deleted`,
|
||||
`DateFrom`,
|
||||
`DateTo`)
|
||||
VALUES (OLD.Id,
|
||||
OLD.MessageDeleteTimer,
|
||||
OLD.NotificationChatId,
|
||||
OLD.MaxVoiceStateHours,
|
||||
OLD.XpPerMessage,
|
||||
OLD.XpPerReaction,
|
||||
OLD.MaxMessageXpPerHour,
|
||||
OLD.XpPerOntimeHour,
|
||||
OLD.XpPerEventParticipation,
|
||||
OLD.XpPerAchievement,
|
||||
OLD.AFKCommandChannelId,
|
||||
OLD.HelpVoiceChannelId,
|
||||
OLD.TeamChannelId,
|
||||
OLD.LoginMessageChannelId,
|
||||
OLD.DefaultRoleId,
|
||||
OLD.ShortRoleNameSetOnlyHighest,
|
||||
OLD.FeatureFlags,
|
||||
OLD.ServerId,
|
||||
TRUE,
|
||||
OLD.LastModifiedAt,
|
||||
CURRENT_TIMESTAMP(6));
|
||||
END;
|
@@ -1,13 +1,14 @@
|
||||
CREATE TABLE IF NOT EXISTS `CFG_TechnicianHistory`
|
||||
(
|
||||
`Id` BIGINT(20) NOT NULL,
|
||||
`Id` BIGINT(20) NOT NULL,
|
||||
`HelpCommandReferenceUrl` VARCHAR(255) NOT NULL,
|
||||
`WaitForRestart` BIGINT NOT NULL DEFAULT 8,
|
||||
`WaitForShutdown` BIGINT NOT NULL DEFAULT 8,
|
||||
`CacheMaxMessages` BIGINT NOT NULL DEFAULT 1000000,
|
||||
`Deleted` BOOL DEFAULT FALSE,
|
||||
`DateFrom` DATETIME(6) NOT NULL,
|
||||
`DateTo` DATETIME(6) NOT NULL
|
||||
`WaitForRestart` BIGINT NOT NULL DEFAULT 8,
|
||||
`WaitForShutdown` BIGINT NOT NULL DEFAULT 8,
|
||||
`CacheMaxMessages` BIGINT NOT NULL DEFAULT 1000000,
|
||||
`FeatureFlags` JSON NULL DEFAULT ('{}'),
|
||||
`Deleted` BOOL DEFAULT FALSE,
|
||||
`DateFrom` DATETIME(6) NOT NULL,
|
||||
`DateTo` DATETIME(6) NOT NULL
|
||||
);
|
||||
|
||||
DROP TRIGGER IF EXISTS `TR_CFG_TechnicianUpdate`;
|
||||
@@ -17,24 +18,22 @@ CREATE TRIGGER `TR_CFG_TechnicianUpdate`
|
||||
ON `CFG_Technician`
|
||||
FOR EACH ROW
|
||||
BEGIN
|
||||
INSERT INTO `CFG_TechnicianHistory` (
|
||||
`Id`,
|
||||
`HelpCommandReferenceUrl`,
|
||||
`WaitForRestart`,
|
||||
`WaitForShutdown`,
|
||||
`CacheMaxMessages`,
|
||||
`DateFrom`,
|
||||
`DateTo`
|
||||
)
|
||||
VALUES (
|
||||
OLD.Id,
|
||||
OLD.HelpCommandReferenceUrl,
|
||||
OLD.WaitForRestart,
|
||||
OLD.WaitForShutdown,
|
||||
OLD.CacheMaxMessages,
|
||||
OLD.LastModifiedAt,
|
||||
CURRENT_TIMESTAMP(6)
|
||||
);
|
||||
INSERT INTO `CFG_TechnicianHistory` (`Id`,
|
||||
`HelpCommandReferenceUrl`,
|
||||
`WaitForRestart`,
|
||||
`WaitForShutdown`,
|
||||
`CacheMaxMessages`,
|
||||
`FeatureFlags`,
|
||||
`DateFrom`,
|
||||
`DateTo`)
|
||||
VALUES (OLD.Id,
|
||||
OLD.HelpCommandReferenceUrl,
|
||||
OLD.WaitForRestart,
|
||||
OLD.WaitForShutdown,
|
||||
OLD.CacheMaxMessages,
|
||||
OLD.FeatureFlags,
|
||||
OLD.LastModifiedAt,
|
||||
CURRENT_TIMESTAMP(6));
|
||||
END;
|
||||
|
||||
DROP TRIGGER IF EXISTS `TR_CFG_TechnicianDelete`;
|
||||
@@ -44,24 +43,22 @@ CREATE TRIGGER `TR_CFG_TechnicianDelete`
|
||||
ON `CFG_Technician`
|
||||
FOR EACH ROW
|
||||
BEGIN
|
||||
INSERT INTO `CFG_TechnicianHistory` (
|
||||
`Id`,
|
||||
`HelpCommandReferenceUrl`,
|
||||
`WaitForRestart`,
|
||||
`WaitForShutdown`,
|
||||
`CacheMaxMessages`,
|
||||
`Deleted`,
|
||||
`DateFrom`,
|
||||
`DateTo`
|
||||
)
|
||||
VALUES (
|
||||
OLD.Id,
|
||||
OLD.HelpCommandReferenceUrl,
|
||||
OLD.WaitForRestart,
|
||||
OLD.WaitForShutdown,
|
||||
OLD.CacheMaxMessages,
|
||||
TRUE,
|
||||
OLD.LastModifiedAt,
|
||||
CURRENT_TIMESTAMP(6)
|
||||
);
|
||||
INSERT INTO `CFG_TechnicianHistory` (`Id`,
|
||||
`HelpCommandReferenceUrl`,
|
||||
`WaitForRestart`,
|
||||
`WaitForShutdown`,
|
||||
`CacheMaxMessages`,
|
||||
`FeatureFlags`,
|
||||
`Deleted`,
|
||||
`DateFrom`,
|
||||
`DateTo`)
|
||||
VALUES (OLD.Id,
|
||||
OLD.HelpCommandReferenceUrl,
|
||||
OLD.WaitForRestart,
|
||||
OLD.WaitForShutdown,
|
||||
OLD.CacheMaxMessages,
|
||||
OLD.FeatureFlags,
|
||||
TRUE,
|
||||
OLD.LastModifiedAt,
|
||||
CURRENT_TIMESTAMP(6));
|
||||
END;
|
@@ -0,0 +1,38 @@
|
||||
CREATE TABLE IF NOT EXISTS `ShortRoleNamesHistory`
|
||||
(
|
||||
`Id` BIGINT(20) NOT NULL,
|
||||
`ShortName` VARCHAR(64) DEFAULT NULL,
|
||||
`DiscordRoleId` BIGINT(20) NOT NULL,
|
||||
`Position` ENUM ('Before', 'After') NOT 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_ShortRoleNamesUpdate`;
|
||||
|
||||
CREATE TRIGGER `TR_ShortRoleNamesUpdate`
|
||||
AFTER UPDATE
|
||||
ON `ShortRoleNames`
|
||||
FOR EACH ROW
|
||||
BEGIN
|
||||
INSERT INTO `ShortRoleNamesHistory` (`Id`, `ShortName`, `DiscordRoleId`, `Position`, `ServerId`, `DateFrom`,
|
||||
`DateTo`)
|
||||
VALUES (OLD.Id, OLD.ShortName, OLD.DiscordRoleId, OLD.Position, OLD.ServerId, OLD.LastModifiedAt,
|
||||
CURRENT_TIMESTAMP(6));
|
||||
END;
|
||||
|
||||
DROP TRIGGER IF EXISTS `TR_ShortRoleNamesDelete`;
|
||||
|
||||
CREATE TRIGGER `TR_ShortRoleNamesDelete`
|
||||
AFTER DELETE
|
||||
ON `ShortRoleNames`
|
||||
FOR EACH ROW
|
||||
BEGIN
|
||||
INSERT INTO `ShortRoleNamesHistory` (`Id`, `ShortName`, `DiscordRoleId`, `Position`, `ServerId`, `Deleted`,
|
||||
`DateFrom`,
|
||||
`DateTo`)
|
||||
VALUES (OLD.Id, OLD.ShortName, OLD.DiscordRoleId, OLD.Position, OLD.ServerId, TRUE, OLD.LastModifiedAt,
|
||||
CURRENT_TIMESTAMP(6));
|
||||
END;
|
@@ -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;
|
51
kdb-bot/src/bot_data/migration/fix_updates_migration.py
Normal file
51
kdb-bot/src/bot_data/migration/fix_updates_migration.py
Normal file
@@ -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 FixUpdatesMigration(MigrationABC):
|
||||
name = "1.1.7_FixUpdatesMigration"
|
||||
|
||||
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_ServerHistory
|
||||
ADD DefaultRoleId BIGINT NULL AFTER LoginMessageChannelId;
|
||||
"""
|
||||
)
|
||||
)
|
||||
|
||||
self._cursor.execute(
|
||||
str(
|
||||
"""ALTER TABLE CFG_TechnicianHistory ADD FeatureFlags JSON NULL DEFAULT ('{}') AFTER CacheMaxMessages;"""
|
||||
)
|
||||
)
|
||||
|
||||
self._cursor.execute(
|
||||
str(
|
||||
"""ALTER TABLE CFG_ServerHistory ADD FeatureFlags JSON NULL DEFAULT ('{}') AFTER LoginMessageChannelId;"""
|
||||
)
|
||||
)
|
||||
|
||||
self._exec(__file__, "config/server.sql")
|
||||
self._exec(__file__, "config/technician.sql")
|
||||
|
||||
def downgrade(self):
|
||||
self._cursor.execute(
|
||||
str(
|
||||
f"""
|
||||
ALTER TABLE CFG_ServerHistory DROP COLUMN DefaultRoleId;
|
||||
"""
|
||||
)
|
||||
)
|
||||
self._cursor.execute("ALTER TABLE CFG_TechnicianHistory DROP COLUMN FeatureFlags;")
|
||||
self._cursor.execute("ALTER TABLE CFG_ServerHistory DROP COLUMN FeatureFlags;")
|
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;
|
||||
"""
|
||||
)
|
||||
)
|
40
kdb-bot/src/bot_data/migration/short_role_name_migration.py
Normal file
40
kdb-bot/src/bot_data/migration/short_role_name_migration.py
Normal file
@@ -0,0 +1,40 @@
|
||||
from bot_core.logging.database_logger import DatabaseLogger
|
||||
from bot_data.abc.migration_abc import MigrationABC
|
||||
from bot_data.db_context import DBContext
|
||||
|
||||
|
||||
class ShortRoleNameMigration(MigrationABC):
|
||||
name = "1.1.7_ShortRoleNameMigration"
|
||||
|
||||
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 `ShortRoleNames` (
|
||||
`Id` BIGINT NOT NULL AUTO_INCREMENT,
|
||||
`ShortName` VARCHAR(255) NOT NULL,
|
||||
`DiscordRoleId` BIGINT NOT NULL,
|
||||
`Position` ENUM('before', 'after') NOT NULL,
|
||||
`ServerId` BIGINT,
|
||||
`CreatedAt` DATETIME(6) NULL DEFAULT CURRENT_TIMESTAMP(6),
|
||||
`LastModifiedAt` DATETIME(6) NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6),
|
||||
PRIMARY KEY(`Id`),
|
||||
FOREIGN KEY (`ServerId`) REFERENCES `Servers`(`ServerId`)
|
||||
);
|
||||
"""
|
||||
)
|
||||
)
|
||||
|
||||
self._exec(__file__, "short_rule_names.sql")
|
||||
|
||||
def downgrade(self):
|
||||
self._cursor.execute("DROP TABLE `ShortRoleNames`;")
|
||||
self._cursor.execute("DROP TABLE `ShortRoleNamesHistory`;")
|
@@ -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;
|
||||
"""
|
||||
)
|
||||
)
|
@@ -1,10 +1,10 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""
|
||||
bot Keksdose bot
|
||||
bot sh-edraft.de Discord bot
|
||||
~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Discord bot for the Keksdose discord Server
|
||||
Discord bot for customers of sh-edraft.de
|
||||
|
||||
:copyright: (c) 2022 - 2023 sh-edraft.de
|
||||
:license: MIT, see LICENSE for more details.
|
||||
@@ -15,7 +15,7 @@ __title__ = "bot_data.model"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.1.4"
|
||||
__version__ = "1.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="4")
|
||||
version_info = VersionInfo(major="1", minor="1", micro="10")
|
||||
|
@@ -1,9 +1,11 @@
|
||||
import json
|
||||
from datetime import datetime
|
||||
from typing import Optional
|
||||
|
||||
from cpl_core.configuration import ConfigurationModelABC
|
||||
from cpl_core.database import TableABC
|
||||
from cpl_query.extension import List
|
||||
from discord import Guild
|
||||
|
||||
from bot_core.configuration.feature_flags_enum import FeatureFlagsEnum
|
||||
from bot_data.model.server import Server
|
||||
@@ -22,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: 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],
|
||||
@@ -45,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
|
||||
@@ -59,6 +68,32 @@ class ServerConfig(TableABC, ConfigurationModelABC):
|
||||
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
|
||||
|
||||
@staticmethod
|
||||
def new(guild: Guild, server: Server) -> "ServerConfig":
|
||||
return ServerConfig(
|
||||
6,
|
||||
guild.system_channel.id,
|
||||
6,
|
||||
1,
|
||||
1,
|
||||
20,
|
||||
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),
|
||||
List(int),
|
||||
)
|
||||
|
||||
@property
|
||||
def id(self) -> int:
|
||||
return self._id
|
||||
@@ -135,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
|
||||
@@ -175,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
|
||||
@@ -243,11 +302,14 @@ class ServerConfig(TableABC, ConfigurationModelABC):
|
||||
`XpPerOntimeHour`,
|
||||
`XpPerEventParticipation`,
|
||||
`XpPerAchievement`,
|
||||
`XpForBirthday`,
|
||||
`AFKCommandChannelId`,
|
||||
`HelpVoiceChannelId`,
|
||||
`TeamChannelId`,
|
||||
`LoginMessageChannelId`,
|
||||
`DefaultRoleId`,
|
||||
`ShortRoleNameSetOnlyHighest`,
|
||||
`GameOfferNotificationChatId`,
|
||||
`FeatureFlags`,
|
||||
`ServerId`
|
||||
) VALUES (
|
||||
@@ -260,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},
|
||||
{self._default_role_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}
|
||||
);
|
||||
@@ -285,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` = {self._default_role_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
|
||||
|
140
kdb-bot/src/bot_data/model/short_role_name.py
Normal file
140
kdb-bot/src/bot_data/model/short_role_name.py
Normal file
@@ -0,0 +1,140 @@
|
||||
from datetime import datetime
|
||||
|
||||
from cpl_core.database import TableABC
|
||||
from cpl_core.dependency_injection import ServiceProviderABC
|
||||
from cpl_discord.service import DiscordBotServiceABC
|
||||
|
||||
from bot_data.model.server import Server
|
||||
from bot_data.model.short_role_name_position_enum import ShortRoleNamePositionEnum
|
||||
|
||||
|
||||
class ShortRoleName(TableABC):
|
||||
def __init__(
|
||||
self,
|
||||
short_name: str,
|
||||
discord_role_id: int,
|
||||
position: ShortRoleNamePositionEnum,
|
||||
server: Server,
|
||||
created_at: datetime = None,
|
||||
modified_at: datetime = None,
|
||||
id=0,
|
||||
):
|
||||
self._id = id
|
||||
self._short_name = short_name
|
||||
self._discord_role_id = discord_role_id
|
||||
self._position = position
|
||||
self._server = server
|
||||
|
||||
TableABC.__init__(self)
|
||||
self._created_at = created_at if created_at is not None else self._created_at
|
||||
self._modified_at = modified_at if modified_at is not None else self._modified_at
|
||||
|
||||
@property
|
||||
def id(self) -> int:
|
||||
return self._id
|
||||
|
||||
@property
|
||||
def short_name(self) -> str:
|
||||
return self._short_name
|
||||
|
||||
@short_name.setter
|
||||
def short_name(self, value: str):
|
||||
self._short_name = value
|
||||
|
||||
@property
|
||||
def role_id(self) -> int:
|
||||
return self._discord_role_id
|
||||
|
||||
@role_id.setter
|
||||
def role_id(self, value: int):
|
||||
self._discord_role_id = value
|
||||
|
||||
@property
|
||||
@ServiceProviderABC.inject
|
||||
def role_name(self, bot: DiscordBotServiceABC) -> str:
|
||||
guild = bot.get_guild(self._server.discord_id)
|
||||
return guild.get_role(self.role_id).name
|
||||
|
||||
@property
|
||||
def position(self) -> ShortRoleNamePositionEnum:
|
||||
return self._position
|
||||
|
||||
@position.setter
|
||||
def position(self, value: ShortRoleNamePositionEnum):
|
||||
self._position = value
|
||||
|
||||
@property
|
||||
def server(self) -> Server:
|
||||
return self._server
|
||||
|
||||
@staticmethod
|
||||
def get_select_all_string() -> str:
|
||||
return str(
|
||||
f"""
|
||||
SELECT * FROM `ShortRoleNames`;
|
||||
"""
|
||||
)
|
||||
|
||||
@staticmethod
|
||||
def get_select_by_id_string(id: int) -> str:
|
||||
return str(
|
||||
f"""
|
||||
SELECT * FROM `ShortRoleNames`
|
||||
WHERE `Id` = {id};
|
||||
"""
|
||||
)
|
||||
|
||||
@staticmethod
|
||||
def get_select_by_role_id_string(id: int) -> str:
|
||||
return str(
|
||||
f"""
|
||||
SELECT * FROM `ShortRoleNames`
|
||||
WHERE `DiscordRoleId` = {id};
|
||||
"""
|
||||
)
|
||||
|
||||
@staticmethod
|
||||
def get_select_by_server_id_string(id: int) -> str:
|
||||
return str(
|
||||
f"""
|
||||
SELECT * FROM `ShortRoleNames`
|
||||
WHERE `ServerId` = {id};
|
||||
"""
|
||||
)
|
||||
|
||||
@property
|
||||
def insert_string(self) -> str:
|
||||
return str(
|
||||
f"""
|
||||
INSERT INTO `ShortRoleNames` (
|
||||
`ShortName`, `DiscordRoleId`, `Position`, `ServerId`
|
||||
) VALUES (
|
||||
'{self._short_name}',
|
||||
{self._discord_role_id},
|
||||
'{self._position}',
|
||||
{self._server.id}
|
||||
);
|
||||
"""
|
||||
)
|
||||
|
||||
@property
|
||||
def udpate_string(self) -> str:
|
||||
return str(
|
||||
f"""
|
||||
UPDATE `ShortRoleNames`
|
||||
SET `ShortName` = '{self._short_name}',
|
||||
`DiscordRoleId` = {self._discord_role_id},
|
||||
`Position` = '{self._position}',
|
||||
`ServerId` = {self._server.id}
|
||||
WHERE `Id` = {self._id};
|
||||
"""
|
||||
)
|
||||
|
||||
@property
|
||||
def delete_string(self) -> str:
|
||||
return str(
|
||||
f"""
|
||||
DELETE FROM `ShortRoleNames`
|
||||
WHERE `Id` = {self._id};
|
||||
"""
|
||||
)
|
56
kdb-bot/src/bot_data/model/short_role_name_history.py
Normal file
56
kdb-bot/src/bot_data/model/short_role_name_history.py
Normal file
@@ -0,0 +1,56 @@
|
||||
from cpl_core.dependency_injection import ServiceProviderABC
|
||||
from cpl_discord.service import DiscordBotServiceABC
|
||||
|
||||
from bot_data.abc.history_table_abc import HistoryTableABC
|
||||
|
||||
|
||||
class ShortRoleNameHistory(HistoryTableABC):
|
||||
def __init__(
|
||||
self,
|
||||
name: str,
|
||||
discord_role_id: int,
|
||||
server: int,
|
||||
deleted: bool,
|
||||
date_from: str,
|
||||
date_to: str,
|
||||
id=0,
|
||||
):
|
||||
HistoryTableABC.__init__(self)
|
||||
self._id = id
|
||||
self._name = name
|
||||
self._discord_role_id = discord_role_id
|
||||
self._server = server
|
||||
|
||||
self._deleted = deleted
|
||||
self._date_from = date_from
|
||||
self._date_to = date_to
|
||||
|
||||
@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 role_id(self) -> int:
|
||||
return self._discord_role_id
|
||||
|
||||
@role_id.setter
|
||||
def role_id(self, value: int):
|
||||
self._discord_role_id = value
|
||||
|
||||
@property
|
||||
@ServiceProviderABC.inject
|
||||
def role_name(self, bot: DiscordBotServiceABC) -> str:
|
||||
guild = bot.get_guild(self._server.discord_id)
|
||||
return guild.get_role(self.role_id).name
|
||||
|
||||
@property
|
||||
def server(self) -> int:
|
||||
return self._server
|
@@ -0,0 +1,6 @@
|
||||
from enum import Enum
|
||||
|
||||
|
||||
class ShortRoleNamePositionEnum(Enum):
|
||||
before = "before"
|
||||
after = "after"
|
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};
|
||||
"""
|
||||
)
|
||||
|
@@ -49,6 +49,15 @@ class UserGameIdent(TableABC):
|
||||
"""
|
||||
)
|
||||
|
||||
@staticmethod
|
||||
def get_select_by_game_server_id_string(id: int) -> str:
|
||||
return str(
|
||||
f"""
|
||||
SELECT * FROM `UserGameIdents`
|
||||
WHERE `GameServerId` = {id};
|
||||
"""
|
||||
)
|
||||
|
||||
@staticmethod
|
||||
def get_select_by_id_string(id: int) -> str:
|
||||
return str(
|
||||
|
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
|
@@ -1,10 +1,10 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""
|
||||
bot Keksdose bot
|
||||
bot sh-edraft.de Discord bot
|
||||
~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Discord bot for the Keksdose discord Server
|
||||
Discord bot for customers of sh-edraft.de
|
||||
|
||||
:copyright: (c) 2022 - 2023 sh-edraft.de
|
||||
:license: MIT, see LICENSE for more details.
|
||||
@@ -15,7 +15,7 @@ __title__ = "bot_data.service"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.1.4"
|
||||
__version__ = "1.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="4")
|
||||
version_info = VersionInfo(major="1", minor="1", micro="10")
|
||||
|
@@ -68,13 +68,16 @@ class GameServerRepositoryService(GameServerRepositoryABC):
|
||||
result = self._context.select(GameServer.get_select_by_id_string(id))[0]
|
||||
return self._from_result(result)
|
||||
|
||||
def get_game_server_by_api_key_id(self, id: int) -> GameServer:
|
||||
def get_game_servers_by_api_key_id(self, id: int) -> List[GameServer]:
|
||||
self._logger.trace(
|
||||
__name__,
|
||||
f"Send SQL command: {GameServer.get_select_by_api_key_id_string(id)}",
|
||||
)
|
||||
result = self._context.select(GameServer.get_select_by_api_key_id_string(id))[0]
|
||||
return self._from_result(result)
|
||||
game_servers = List(GameServer)
|
||||
results = self._context.select(GameServer.get_select_by_api_key_id_string(id))
|
||||
for result in results:
|
||||
game_servers.append(self._from_result(result))
|
||||
return game_servers
|
||||
|
||||
def add_game_server(self, game_server: GameServer):
|
||||
self._logger.trace(__name__, f"Send SQL command: {game_server.insert_string}")
|
||||
|
@@ -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],
|
||||
)
|
||||
|
||||
|
@@ -34,30 +34,12 @@ class ServerConfigSeeder(DataSeederABC):
|
||||
if self._server_config.does_server_config_exists(server.id):
|
||||
continue
|
||||
|
||||
config = ServerConfig(
|
||||
6,
|
||||
guild.system_channel.id,
|
||||
6,
|
||||
1,
|
||||
1,
|
||||
20,
|
||||
10,
|
||||
10,
|
||||
10,
|
||||
guild.system_channel.id,
|
||||
guild.system_channel.id,
|
||||
guild.system_channel.id,
|
||||
guild.system_channel.id,
|
||||
{},
|
||||
server,
|
||||
[],
|
||||
[],
|
||||
)
|
||||
config = ServerConfig.new(guild, server)
|
||||
|
||||
self._server_config.add_server_config(config)
|
||||
|
||||
self._db.save_changes()
|
||||
self._logger.debug(__name__, "Seeded technician config")
|
||||
self._logger.debug(__name__, "Seeded server config")
|
||||
|
||||
except Exception as e:
|
||||
self._logger.error(__name__, f"Seeding technician config failed", e)
|
||||
self._logger.error(__name__, f"Seeding server config failed", e)
|
||||
|
@@ -0,0 +1,95 @@
|
||||
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.short_role_name_repository_abc import ShortRoleNameRepositoryABC
|
||||
from bot_data.model.short_role_name import ShortRoleName
|
||||
from bot_data.model.short_role_name_position_enum import ShortRoleNamePositionEnum
|
||||
|
||||
|
||||
class ShortRoleNameRepositoryService(ShortRoleNameRepositoryABC):
|
||||
def __init__(
|
||||
self,
|
||||
logger: DatabaseLogger,
|
||||
db_context: DatabaseContextABC,
|
||||
servers: ServerRepositoryABC,
|
||||
):
|
||||
self._logger = logger
|
||||
self._context = db_context
|
||||
|
||||
self._servers = servers
|
||||
|
||||
ShortRoleNameRepositoryABC.__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 _short_role_name_from_result(self, sql_result: tuple) -> ShortRoleName:
|
||||
return ShortRoleName(
|
||||
self._get_value_from_result(sql_result[1]), # name
|
||||
int(self._get_value_from_result(sql_result[2])), # role_id
|
||||
ShortRoleNamePositionEnum(self._get_value_from_result(sql_result[3])), # position
|
||||
self._servers.get_server_by_id(sql_result[4]), # server
|
||||
self._get_value_from_result(sql_result[5]), # created_at
|
||||
self._get_value_from_result(sql_result[6]), # modified_at
|
||||
id=self._get_value_from_result(sql_result[0]), # id
|
||||
)
|
||||
|
||||
def get_short_role_names(self) -> List[ShortRoleName]:
|
||||
short_role_names = List(ShortRoleName)
|
||||
self._logger.trace(__name__, f"Send SQL command: {ShortRoleName.get_select_all_string()}")
|
||||
results = self._context.select(ShortRoleName.get_select_all_string())
|
||||
for result in results:
|
||||
self._logger.trace(__name__, f"Get short_role_name with id {result[0]}")
|
||||
short_role_names.append(self._short_role_name_from_result(result))
|
||||
|
||||
return short_role_names
|
||||
|
||||
def get_short_role_name_by_id(self, id: int) -> ShortRoleName:
|
||||
self._logger.trace(__name__, f"Send SQL command: {ShortRoleName.get_select_by_id_string(id)}")
|
||||
result = self._context.select(ShortRoleName.get_select_by_id_string(id))[0]
|
||||
|
||||
return self._short_role_name_from_result(result)
|
||||
|
||||
def find_short_role_names_by_role_id(self, role_id: int) -> List[ShortRoleName]:
|
||||
short_role_names = List(ShortRoleName)
|
||||
self._logger.trace(__name__, f"Send SQL command: {ShortRoleName.get_select_by_role_id_string(role_id)}")
|
||||
results = self._context.select(ShortRoleName.get_select_by_role_id_string(role_id))
|
||||
for result in results:
|
||||
self._logger.trace(__name__, f"Get short_role_name with id {result[0]}")
|
||||
short_role_names.append(self._short_role_name_from_result(result))
|
||||
|
||||
return short_role_names
|
||||
|
||||
def get_short_role_names_by_server_id(self, server_id: int) -> List[ShortRoleName]:
|
||||
short_role_names = List(ShortRoleName)
|
||||
self._logger.trace(
|
||||
__name__,
|
||||
f"Send SQL command: {ShortRoleName.get_select_by_server_id_string(server_id)}",
|
||||
)
|
||||
results = self._context.select(ShortRoleName.get_select_by_server_id_string(server_id))
|
||||
|
||||
for result in results:
|
||||
self._logger.trace(__name__, f"Get short_role_name with id {result[0]}")
|
||||
short_role_names.append(self._short_role_name_from_result(result))
|
||||
|
||||
return short_role_names
|
||||
|
||||
def add_short_role_name(self, short_role_name: ShortRoleName):
|
||||
self._logger.trace(__name__, f"Send SQL command: {short_role_name.insert_string}")
|
||||
self._context.cursor.execute(short_role_name.insert_string)
|
||||
|
||||
def update_short_role_name(self, short_role_name: ShortRoleName):
|
||||
self._logger.trace(__name__, f"Send SQL command: {short_role_name.udpate_string}")
|
||||
self._context.cursor.execute(short_role_name.udpate_string)
|
||||
|
||||
def delete_short_role_name(self, short_role_name: ShortRoleName):
|
||||
self._logger.trace(__name__, f"Send SQL command: {short_role_name.delete_string}")
|
||||
self._context.cursor.execute(short_role_name.delete_string)
|
@@ -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)
|
@@ -51,6 +51,19 @@ class UserGameIdentRepositoryService(UserGameIdentRepositoryABC):
|
||||
|
||||
return joins
|
||||
|
||||
def get_user_game_idents_by_game_server_id(self, game_server_id: int) -> List[UserGameIdent]:
|
||||
joins = List(UserGameIdent)
|
||||
self._logger.trace(
|
||||
__name__,
|
||||
f"Send SQL command: {UserGameIdent.get_select_by_game_server_id_string(game_server_id)}",
|
||||
)
|
||||
results = self._context.select(UserGameIdent.get_select_by_game_server_id_string(game_server_id))
|
||||
for result in results:
|
||||
self._logger.trace(__name__, f"Get UserGameIdent with id {result[0]}")
|
||||
joins.append(self._from_result(result))
|
||||
|
||||
return joins
|
||||
|
||||
def get_user_game_ident_by_id(self, id: int) -> UserGameIdent:
|
||||
self._logger.trace(
|
||||
__name__,
|
||||
|
@@ -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)
|
||||
|
||||
|
@@ -1,10 +1,10 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""
|
||||
bot Keksdose bot
|
||||
bot sh-edraft.de Discord bot
|
||||
~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Discord bot for the Keksdose discord Server
|
||||
Discord bot for customers of sh-edraft.de
|
||||
|
||||
:copyright: (c) 2022 - 2023 sh-edraft.de
|
||||
:license: MIT, see LICENSE for more details.
|
||||
@@ -15,7 +15,7 @@ __title__ = "bot_graphql"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.1.4"
|
||||
__version__ = "1.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="4")
|
||||
version_info = VersionInfo(major="1", minor="1", micro="10")
|
||||
|
@@ -1,10 +1,10 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""
|
||||
bot Keksdose bot
|
||||
bot sh-edraft.de Discord bot
|
||||
~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Discord bot for the Keksdose discord Server
|
||||
Discord bot for customers of sh-edraft.de
|
||||
|
||||
:copyright: (c) 2022 - 2023 sh-edraft.de
|
||||
:license: MIT, see LICENSE for more details.
|
||||
@@ -15,7 +15,7 @@ __title__ = "bot_graphql.abc"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.1.4"
|
||||
__version__ = "1.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="4")
|
||||
version_info = VersionInfo(major="1", minor="1", micro="10")
|
||||
|
@@ -20,6 +20,7 @@ from bot_data.model.known_user import KnownUser
|
||||
from bot_data.model.level import Level
|
||||
from bot_data.model.server import Server
|
||||
from bot_data.model.server_config import ServerConfig
|
||||
from bot_data.model.short_role_name import ShortRoleName
|
||||
from bot_data.model.user import User
|
||||
from bot_data.model.user_joined_game_server import UserJoinedGameServer
|
||||
from bot_data.model.user_joined_server import UserJoinedServer
|
||||
@@ -78,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
|
||||
@@ -184,6 +193,16 @@ class QueryABC(ObjectType):
|
||||
access = True
|
||||
break
|
||||
|
||||
elif type(element) == ShortRoleName:
|
||||
element: ShortRoleName = element
|
||||
for u in user.users:
|
||||
u: User = u
|
||||
guild = bot.get_guild(u.server.discord_id)
|
||||
member = guild.get_member(u.discord_id)
|
||||
if permissions.is_member_moderator(member) and u.server.id == element.server.id:
|
||||
access = True
|
||||
break
|
||||
|
||||
elif type(element) == dict and "key" in element and element["key"] in [e.value for e in FeatureFlagsEnum]:
|
||||
for u in user.users:
|
||||
u: User = u
|
||||
|
@@ -4,7 +4,7 @@
|
||||
"Version": {
|
||||
"Major": "1",
|
||||
"Minor": "1",
|
||||
"Micro": "4"
|
||||
"Micro": "10"
|
||||
},
|
||||
"Author": "Sven Heidemann",
|
||||
"AuthorEmail": "sven.heidemann@sh-edraft.de",
|
||||
|
@@ -1,10 +1,10 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""
|
||||
bot Keksdose bot
|
||||
bot sh-edraft.de Discord bot
|
||||
~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Discord bot for the Keksdose discord Server
|
||||
Discord bot for customers of sh-edraft.de
|
||||
|
||||
:copyright: (c) 2022 - 2023 sh-edraft.de
|
||||
:license: MIT, see LICENSE for more details.
|
||||
@@ -15,7 +15,7 @@ __title__ = "bot_graphql.filter"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.1.4"
|
||||
__version__ = "1.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="4")
|
||||
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
|
||||
|
70
kdb-bot/src/bot_graphql/filter/short_role_name_filter.py
Normal file
70
kdb-bot/src/bot_graphql/filter/short_role_name_filter.py
Normal file
@@ -0,0 +1,70 @@
|
||||
from cpl_discord.service import DiscordBotServiceABC
|
||||
from cpl_query.extension import List
|
||||
|
||||
from bot_data.model.short_role_name import ShortRoleName
|
||||
from bot_data.model.short_role_name_position_enum import ShortRoleNamePositionEnum
|
||||
from bot_data.model.user import User
|
||||
from bot_graphql.abc.filter_abc import FilterABC
|
||||
|
||||
|
||||
class ShortRoleNameFilter(FilterABC):
|
||||
def __init__(self, bot: DiscordBotServiceABC):
|
||||
FilterABC.__init__(self)
|
||||
self._bot = bot
|
||||
|
||||
self._id = None
|
||||
self._short_name = None
|
||||
self._role_id = None
|
||||
self._role_name = None
|
||||
self._position = None
|
||||
self._server = None
|
||||
|
||||
def from_dict(self, values: dict):
|
||||
if "id" in values:
|
||||
self._id = int(values["id"])
|
||||
|
||||
if "shortName" in values:
|
||||
self._short_name = values["shortName"]
|
||||
|
||||
if "roleId" in values:
|
||||
self._role_id = int(values["roleId"])
|
||||
|
||||
if "roleName" in values:
|
||||
self._role_name = values["roleName"]
|
||||
|
||||
if "position" in values:
|
||||
self._position = ShortRoleNamePositionEnum(values["position"])
|
||||
|
||||
if "server" in values:
|
||||
from bot_graphql.filter.server_filter import ServerFilter
|
||||
|
||||
self._server: ServerFilter = self._services.get_service(ServerFilter)
|
||||
self._server.from_dict(values["server"])
|
||||
|
||||
def filter(self, query: List[User]) -> List[User]:
|
||||
if self._id is not None:
|
||||
query = query.where(lambda x: x.id == self._id)
|
||||
|
||||
if self._short_name is not None:
|
||||
query = query.where(lambda x: x.short_name == self._short_name or self._short_name in x.short_name)
|
||||
|
||||
if self._role_id is not None:
|
||||
query = query.where(lambda x: x.role_id == self._role_id)
|
||||
|
||||
if self._role_name is not None and self._role_id is not None:
|
||||
|
||||
def get_role_name(x: ShortRoleName):
|
||||
guild = self._bot.get_guild(x.server.discord_id)
|
||||
name = guild.get_role(x.role_id).name
|
||||
return name == self._role_name or self._role_name in name
|
||||
|
||||
query = query.where(get_role_name)
|
||||
|
||||
if self._position is not None:
|
||||
query = query.where(lambda x: x.position.value == self._position.value)
|
||||
|
||||
if self._server is not None:
|
||||
servers = self._server.filter(query.select(lambda x: x.server)).select(lambda x: x.id)
|
||||
query = query.where(lambda x: x.server.id in servers)
|
||||
|
||||
return query
|
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
|
@@ -5,6 +5,7 @@ type Mutation {
|
||||
user: UserMutation
|
||||
userJoinedGameServer: UserJoinedGameServerMutation
|
||||
achievement: AchievementMutation
|
||||
shortRoleName: ShortRoleNameMutation
|
||||
technicianConfig: TechnicianConfigMutation
|
||||
serverConfig: ServerConfigMutation
|
||||
}
|
@@ -37,6 +37,13 @@ type Query {
|
||||
achievementAttributes: [AchievementAttribute]
|
||||
achievementOperators: [String]
|
||||
|
||||
shortRoleNameCount: Int
|
||||
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
|
||||
|
@@ -31,7 +31,11 @@ type Server implements TableWithHistoryQuery {
|
||||
achievementCount: Int
|
||||
achievements(filter: AchievementFilter, page: Page, sort: Sort): [Achievement]
|
||||
|
||||
shortRoleNameCount: Int
|
||||
shortRoleNames(filter: ShortRoleNameFilter, page: Page, sort: Sort): [ShortRoleName]
|
||||
|
||||
config: ServerConfig
|
||||
hasFeatureFlag(flag: String): FeatureFlag
|
||||
|
||||
createdAt: String
|
||||
modifiedAt: String
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user