Compare commits
42 Commits
0a47393510
...
dev
Author | SHA1 | Date | |
---|---|---|---|
266dacb301 | |||
280cd9827d | |||
36998470e8 | |||
53c6bf4208 | |||
4e80e3ccb7 | |||
ba173a6743 | |||
84ff2a8a9b | |||
13bc38fea8 | |||
dfdf0555d7 | |||
39299eb11b | |||
dfb6751bf9 | |||
4a75635a55 | |||
f6b2739394 | |||
36d2605655 | |||
af891fa588 | |||
af348b85a4 | |||
7ed621a25b | |||
013f953a7f | |||
4163532696 | |||
b6a1172cc1 | |||
20bdb6bd98 | |||
3f13f65932 | |||
711e184895 | |||
7e3975f4be | |||
d4f4f39522 | |||
af9c55e4b1 | |||
e3172d6f24 | |||
0706579f62 | |||
ad3fc94923 | |||
69882af0bd | |||
b0fb12f841 | |||
4d980331e2 | |||
e6667c78c8 | |||
9976c59302 | |||
293c8cd81c | |||
8f4ea56184 | |||
898e005978 | |||
db3e6183ba | |||
6c5b514b41 | |||
84f994fd58 | |||
919eef79f6 | |||
5de6710261 |
@@ -6,9 +6,17 @@ on:
|
||||
- dev
|
||||
|
||||
jobs:
|
||||
on-push-deploy_sh-edraft:
|
||||
pre-build:
|
||||
runs-on: [ dobby.sh-edraft.de, ubuntu-latest ]
|
||||
container: sh-edraft.de/act-runner:latest
|
||||
container: git.sh-edraft.de/sh-edraft.de/act-runner:latest
|
||||
steps:
|
||||
- name: Shutdown stack
|
||||
run: docker stack rm sdb_dev
|
||||
|
||||
build-bot:
|
||||
needs: pre-build
|
||||
runs-on: [ dobby.sh-edraft.de, ubuntu-latest ]
|
||||
container: git.sh-edraft.de/sh-edraft.de/act-runner:latest
|
||||
steps:
|
||||
- name: Setup docker
|
||||
uses: https://github.com/papodaca/install-docker-action@main
|
||||
@@ -22,10 +30,44 @@ jobs:
|
||||
|
||||
- name: Prepare bot build
|
||||
run: |
|
||||
cd bot
|
||||
python3.10 -m pip install --extra-index-url https://pip.sh-edraft.de cpl-cli
|
||||
cd bot
|
||||
cpl i
|
||||
|
||||
- name: Build docker bot
|
||||
run: |
|
||||
cd bot
|
||||
docker image prune -f
|
||||
cpl build
|
||||
docker build -t git.sh-edraft.de/sh-edraft.de/sdb-bot:$(cpl gv)-dev .
|
||||
|
||||
- name: Login to registry git.sh-edraft.de
|
||||
uses: https://github.com/docker/login-action@v1
|
||||
with:
|
||||
registry: git.sh-edraft.de
|
||||
username: ${{ secrets.CI_USERNAME }}
|
||||
password: ${{ secrets.CI_ACCESS_TOKEN }}
|
||||
|
||||
- name: Push image
|
||||
run: |
|
||||
cd bot
|
||||
docker push git.sh-edraft.de/sh-edraft.de/sdb-bot:$(cpl gv)-dev
|
||||
|
||||
build-web:
|
||||
needs: pre-build
|
||||
runs-on: [ dobby.sh-edraft.de, ubuntu-latest ]
|
||||
container: git.sh-edraft.de/sh-edraft.de/act-runner:latest
|
||||
steps:
|
||||
- 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
|
||||
with:
|
||||
token: ${{ secrets.CI_ACCESS_TOKEN }}
|
||||
submodules: true
|
||||
|
||||
- name: Setup node
|
||||
uses: https://github.com/actions/setup-node@v3
|
||||
|
||||
@@ -35,29 +77,45 @@ jobs:
|
||||
npm install -g ts-node
|
||||
npm ci
|
||||
|
||||
- name: Shutdown stack
|
||||
run: docker stack rm sdb_dev
|
||||
|
||||
- name: Build docker bot
|
||||
run: |
|
||||
cd bot
|
||||
docker image prune -f
|
||||
cpl build
|
||||
docker build -t sh-edraft.de/sdb-bot:$(cpl gv)-dev .
|
||||
|
||||
- name: Build docker web
|
||||
run: |
|
||||
cd web
|
||||
docker image prune -f
|
||||
cp src/favicon.dev.ico src/favicon.ico
|
||||
npm run build
|
||||
docker build -t sh-edraft.de/sdb-web:$(npm run -s gv)-dev .
|
||||
docker build -t git.sh-edraft.de/sh-edraft.de/sdb-web:$(npm run -s gv)-dev .
|
||||
|
||||
- name: Login to registry git.sh-edraft.de
|
||||
uses: https://github.com/docker/login-action@v1
|
||||
with:
|
||||
registry: git.sh-edraft.de
|
||||
username: ${{ secrets.CI_USERNAME }}
|
||||
password: ${{ secrets.CI_ACCESS_TOKEN }}
|
||||
|
||||
- name: Push image
|
||||
run: |
|
||||
cd web
|
||||
docker push git.sh-edraft.de/sh-edraft.de/sdb-web:$(npm run -s gv)-dev
|
||||
|
||||
deploy:
|
||||
needs: [ build-bot, build-web ]
|
||||
runs-on: [ dobby.sh-edraft.de, ubuntu-latest ]
|
||||
container: git.sh-edraft.de/sh-edraft.de/act-runner:latest
|
||||
steps:
|
||||
- name: Clone Repository
|
||||
uses: https://github.com/actions/checkout@v3
|
||||
with:
|
||||
token: ${{ secrets.CI_ACCESS_TOKEN }}
|
||||
submodules: true
|
||||
|
||||
- name: Install cpl
|
||||
run: python3.10 -m pip install --extra-index-url https://pip.sh-edraft.de cpl-cli
|
||||
|
||||
- name: Set version
|
||||
run: |
|
||||
cd bot/docker
|
||||
chmod +x ./set-docker-compose-image-version.sh
|
||||
./set-docker-compose-image-version.sh sh-edraft.de/sdb-bot:$(cd ../; cpl gv)-dev sh-edraft.de/sdb-web:$(cd ../../web; npm run -s gv;)-dev
|
||||
./set-docker-compose-image-version.sh git.sh-edraft.de/sh-edraft.de/sdb-bot:$(cd ../; cpl gv)-dev git.sh-edraft.de/sh-edraft.de/sdb-web:$(cd ../../web; npm run -s gv;)-dev
|
||||
|
||||
- name: Deploy Stack to sh-edraft.de
|
||||
uses: https://github.com/kgierke/portainer-stack-deployment@v1
|
||||
|
@@ -6,9 +6,17 @@ on:
|
||||
- master
|
||||
|
||||
jobs:
|
||||
on-push-deploy_sh-edraft:
|
||||
pre-build:
|
||||
runs-on: [ dobby.sh-edraft.de, ubuntu-latest ]
|
||||
container: sh-edraft.de/act-runner:latest
|
||||
container: git.sh-edraft.de/sh-edraft.de/act-runner:latest
|
||||
steps:
|
||||
- name: Shutdown stack
|
||||
run: docker stack rm sdb_prod
|
||||
|
||||
build-bot:
|
||||
needs: pre-build
|
||||
runs-on: [ dobby.sh-edraft.de, ubuntu-latest ]
|
||||
container: git.sh-edraft.de/sh-edraft.de/act-runner:latest
|
||||
steps:
|
||||
- name: Setup docker
|
||||
uses: https://github.com/papodaca/install-docker-action@main
|
||||
@@ -22,10 +30,44 @@ jobs:
|
||||
|
||||
- name: Prepare bot build
|
||||
run: |
|
||||
cd bot
|
||||
python3.10 -m pip install --extra-index-url https://pip.sh-edraft.de cpl-cli
|
||||
cd bot
|
||||
cpl i
|
||||
|
||||
- name: Build docker bot
|
||||
run: |
|
||||
cd bot
|
||||
docker image prune -f
|
||||
cpl build
|
||||
docker build -t git.sh-edraft.de/sh-edraft.de/sdb-bot:$(cpl gv) .
|
||||
|
||||
- name: Login to registry git.sh-edraft.de
|
||||
uses: https://github.com/docker/login-action@v1
|
||||
with:
|
||||
registry: git.sh-edraft.de
|
||||
username: ${{ secrets.CI_USERNAME }}
|
||||
password: ${{ secrets.CI_ACCESS_TOKEN }}
|
||||
|
||||
- name: Push image
|
||||
run: |
|
||||
cd bot
|
||||
docker push git.sh-edraft.de/sh-edraft.de/sdb-bot:$(cpl gv)
|
||||
|
||||
build-web:
|
||||
needs: pre-build
|
||||
runs-on: [ dobby.sh-edraft.de, ubuntu-latest ]
|
||||
container: git.sh-edraft.de/sh-edraft.de/act-runner:latest
|
||||
steps:
|
||||
- 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
|
||||
with:
|
||||
token: ${{ secrets.CI_ACCESS_TOKEN }}
|
||||
submodules: true
|
||||
|
||||
- name: Setup node
|
||||
uses: https://github.com/actions/setup-node@v3
|
||||
|
||||
@@ -35,28 +77,45 @@ jobs:
|
||||
npm install -g ts-node
|
||||
npm ci
|
||||
|
||||
- name: Shutdown stack
|
||||
run: docker stack rm sdb_prod
|
||||
|
||||
- name: Build docker bot
|
||||
run: |
|
||||
cd bot
|
||||
docker image prune -f
|
||||
cpl build
|
||||
docker build -t sh-edraft.de/sdb-bot:$(cpl gv) .
|
||||
|
||||
- name: Build docker web
|
||||
run: |
|
||||
cd web
|
||||
docker image prune -f
|
||||
cp src/favicon.ico src/favicon.ico
|
||||
npm run build
|
||||
docker build -t sh-edraft.de/sdb-web:$(npm run -s gv) .
|
||||
docker build -t git.sh-edraft.de/sh-edraft.de/sdb-web:$(npm run -s gv) .
|
||||
|
||||
- name: Login to registry git.sh-edraft.de
|
||||
uses: https://github.com/docker/login-action@v1
|
||||
with:
|
||||
registry: git.sh-edraft.de
|
||||
username: ${{ secrets.CI_USERNAME }}
|
||||
password: ${{ secrets.CI_ACCESS_TOKEN }}
|
||||
|
||||
- name: Push image
|
||||
run: |
|
||||
cd web
|
||||
docker push git.sh-edraft.de/sh-edraft.de/sdb-web:$(npm run -s gv)
|
||||
|
||||
deploy:
|
||||
needs: [ build-bot, build-web ]
|
||||
runs-on: [ dobby.sh-edraft.de, ubuntu-latest ]
|
||||
container: git.sh-edraft.de/sh-edraft.de/act-runner:latest
|
||||
steps:
|
||||
- name: Clone Repository
|
||||
uses: https://github.com/actions/checkout@v3
|
||||
with:
|
||||
token: ${{ secrets.CI_ACCESS_TOKEN }}
|
||||
submodules: true
|
||||
|
||||
- name: Install cpl
|
||||
run: python3.10 -m pip install --extra-index-url https://pip.sh-edraft.de cpl-cli
|
||||
|
||||
- name: Set version
|
||||
run: |
|
||||
cd bot/docker
|
||||
chmod +x ./set-docker-compose-image-version.sh
|
||||
./set-docker-compose-image-version.sh sh-edraft.de/sdb-bot:$(cd ../; cpl gv) sh-edraft.de/sdb-web:$(cd ../../web; npm run -s gv;)
|
||||
./set-docker-compose-image-version.sh git.sh-edraft.de/sh-edraft.de/sdb-bot:$(cd ../; cpl gv) git.sh-edraft.de/sh-edraft.de/sdb-web:$(cd ../../web; npm run -s gv;)
|
||||
|
||||
- name: Deploy Stack to sh-edraft.de
|
||||
uses: https://github.com/kgierke/portainer-stack-deployment@v1
|
||||
|
@@ -6,9 +6,17 @@ on:
|
||||
- staging
|
||||
|
||||
jobs:
|
||||
on-push-deploy_sh-edraft:
|
||||
pre-build:
|
||||
runs-on: [ dobby.sh-edraft.de, ubuntu-latest ]
|
||||
container: sh-edraft.de/act-runner:latest
|
||||
container: git.sh-edraft.de/sh-edraft.de/act-runner:latest
|
||||
steps:
|
||||
- name: Shutdown stack
|
||||
run: docker stack rm sdb_staging
|
||||
|
||||
build-bot:
|
||||
needs: pre-build
|
||||
runs-on: [ dobby.sh-edraft.de, ubuntu-latest ]
|
||||
container: git.sh-edraft.de/sh-edraft.de/act-runner:latest
|
||||
steps:
|
||||
- name: Setup docker
|
||||
uses: https://github.com/papodaca/install-docker-action@main
|
||||
@@ -22,10 +30,44 @@ jobs:
|
||||
|
||||
- name: Prepare bot build
|
||||
run: |
|
||||
cd bot
|
||||
python3.10 -m pip install --extra-index-url https://pip.sh-edraft.de cpl-cli
|
||||
cd bot
|
||||
cpl i
|
||||
|
||||
- name: Build docker bot
|
||||
run: |
|
||||
cd bot
|
||||
docker image prune -f
|
||||
cpl build
|
||||
docker build -t git.sh-edraft.de/sh-edraft.de/sdb-bot:$(cpl gv)-staging .
|
||||
|
||||
- name: Login to registry git.sh-edraft.de
|
||||
uses: https://github.com/docker/login-action@v1
|
||||
with:
|
||||
registry: git.sh-edraft.de
|
||||
username: ${{ secrets.CI_USERNAME }}
|
||||
password: ${{ secrets.CI_ACCESS_TOKEN }}
|
||||
|
||||
- name: Push image
|
||||
run: |
|
||||
cd bot
|
||||
docker push git.sh-edraft.de/sh-edraft.de/sdb-bot:$(cpl gv)-staging
|
||||
|
||||
build-web:
|
||||
needs: pre-build
|
||||
runs-on: [ dobby.sh-edraft.de, ubuntu-latest ]
|
||||
container: git.sh-edraft.de/sh-edraft.de/act-runner:latest
|
||||
steps:
|
||||
- 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
|
||||
with:
|
||||
token: ${{ secrets.CI_ACCESS_TOKEN }}
|
||||
submodules: true
|
||||
|
||||
- name: Setup node
|
||||
uses: https://github.com/actions/setup-node@v3
|
||||
|
||||
@@ -35,29 +77,45 @@ jobs:
|
||||
npm install -g ts-node
|
||||
npm ci
|
||||
|
||||
- name: Shutdown stack
|
||||
run: docker stack rm sdb_staging
|
||||
|
||||
- name: Build docker bot
|
||||
run: |
|
||||
cd bot
|
||||
docker image prune -f
|
||||
cpl build
|
||||
docker build -t sh-edraft.de/sdb-bot:$(cpl gv)-staging .
|
||||
|
||||
- name: Build docker web
|
||||
run: |
|
||||
cd web
|
||||
docker image prune -f
|
||||
cp src/favicon.staging.ico src/favicon.ico
|
||||
npm run build
|
||||
docker build -t sh-edraft.de/sdb-web:$(npm run -s gv)-staging .
|
||||
docker build -t git.sh-edraft.de/sh-edraft.de/sdb-web:$(npm run -s gv)-staging .
|
||||
|
||||
- name: Login to registry git.sh-edraft.de
|
||||
uses: https://github.com/docker/login-action@v1
|
||||
with:
|
||||
registry: git.sh-edraft.de
|
||||
username: ${{ secrets.CI_USERNAME }}
|
||||
password: ${{ secrets.CI_ACCESS_TOKEN }}
|
||||
|
||||
- name: Push image
|
||||
run: |
|
||||
cd web
|
||||
docker push git.sh-edraft.de/sh-edraft.de/sdb-web:$(npm run -s gv)-staging
|
||||
|
||||
deploy:
|
||||
needs: [ build-bot, build-web ]
|
||||
runs-on: [ dobby.sh-edraft.de, ubuntu-latest ]
|
||||
container: git.sh-edraft.de/sh-edraft.de/act-runner:latest
|
||||
steps:
|
||||
- name: Clone Repository
|
||||
uses: https://github.com/actions/checkout@v3
|
||||
with:
|
||||
token: ${{ secrets.CI_ACCESS_TOKEN }}
|
||||
submodules: true
|
||||
|
||||
- name: Install cpl
|
||||
run: python3.10 -m pip install --extra-index-url https://pip.sh-edraft.de cpl-cli
|
||||
|
||||
- name: Set version
|
||||
run: |
|
||||
cd bot/docker
|
||||
chmod +x ./set-docker-compose-image-version.sh
|
||||
./set-docker-compose-image-version.sh sh-edraft.de/sdb-bot:$(cd ../; cpl gv)-staging sh-edraft.de/sdb-web:$(cd ../../web; npm run -s gv;)-staging
|
||||
./set-docker-compose-image-version.sh git.sh-edraft.de/sh-edraft.de/sdb-bot:$(cd ../; cpl gv)-staging git.sh-edraft.de/sh-edraft.de/sdb-web:$(cd ../../web; npm run -s gv;)-staging
|
||||
|
||||
- name: Deploy Stack to sh-edraft.de
|
||||
uses: https://github.com/kgierke/portainer-stack-deployment@v1
|
||||
|
Submodule bot/docker updated: b0bacce9f6...36ed43055d
@@ -15,7 +15,7 @@ __title__ = "bot"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.2.2"
|
||||
__version__ = "1.2.3"
|
||||
|
||||
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="2", micro="2")
|
||||
version_info = VersionInfo(major="1", minor="2", micro="3")
|
||||
|
@@ -4,7 +4,7 @@
|
||||
"Version": {
|
||||
"Major": "1",
|
||||
"Minor": "2",
|
||||
"Micro": "2"
|
||||
"Micro": "3"
|
||||
},
|
||||
"Author": "Sven Heidemann",
|
||||
"AuthorEmail": "sven.heidemann@sh-edraft.de",
|
||||
@@ -16,7 +16,7 @@
|
||||
"LicenseName": "MIT",
|
||||
"LicenseDescription": "MIT, see LICENSE for more details.",
|
||||
"Dependencies": [
|
||||
"cpl-core==2023.10.0",
|
||||
"cpl-core==2023.10.1",
|
||||
"cpl-translation==2023.4.0.post1",
|
||||
"cpl-query==2023.10.0",
|
||||
"cpl-discord==2023.10.0.post1",
|
||||
@@ -33,7 +33,8 @@
|
||||
"cryptography==41.0.4",
|
||||
"discord==2.3.2",
|
||||
"bs4==0.0.1",
|
||||
"lxml==4.9.3"
|
||||
"lxml==4.9.3",
|
||||
"python-valve==0.2.1"
|
||||
],
|
||||
"DevDependencies": [
|
||||
"cpl-cli==2023.4.0.post3",
|
||||
|
Submodule bot/src/bot/config updated: c11ca6f2e8...be5b15f227
@@ -15,7 +15,7 @@ __title__ = "bot.extension"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.2.2"
|
||||
__version__ = "1.2.3"
|
||||
|
||||
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="2", micro="2")
|
||||
version_info = VersionInfo(major="1", minor="2", micro="3")
|
||||
|
@@ -15,6 +15,7 @@ from bot_core.configuration.feature_flags_enum import FeatureFlagsEnum
|
||||
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.event_logger import EventLogger
|
||||
from bot_core.logging.message_logger import MessageLogger
|
||||
from bot_core.logging.task_logger import TaskLogger
|
||||
from bot_data.db_context import DBContext
|
||||
@@ -45,6 +46,7 @@ class Startup(StartupABC):
|
||||
services.add_singleton(CustomFileLoggerABC, DatabaseLogger)
|
||||
services.add_singleton(CustomFileLoggerABC, MessageLogger)
|
||||
services.add_singleton(CustomFileLoggerABC, TaskLogger)
|
||||
services.add_singleton(CustomFileLoggerABC, EventLogger)
|
||||
|
||||
if self._feature_flags.get_flag(FeatureFlagsEnum.api_module):
|
||||
services.add_singleton(CustomFileLoggerABC, ApiLogger)
|
||||
|
@@ -15,7 +15,7 @@ __title__ = "bot_api"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.2.2"
|
||||
__version__ = "1.2.3"
|
||||
|
||||
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="2", micro="2")
|
||||
version_info = VersionInfo(major="1", minor="2", micro="3")
|
||||
|
@@ -15,7 +15,7 @@ __title__ = "bot_api.abc"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.2.2"
|
||||
__version__ = "1.2.3"
|
||||
|
||||
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="2", micro="2")
|
||||
version_info = VersionInfo(major="1", minor="2", micro="3")
|
||||
|
@@ -4,7 +4,7 @@
|
||||
"Version": {
|
||||
"Major": "1",
|
||||
"Minor": "2",
|
||||
"Micro": "2"
|
||||
"Micro": "3"
|
||||
},
|
||||
"Author": "",
|
||||
"AuthorEmail": "",
|
||||
|
@@ -15,7 +15,7 @@ __title__ = "bot_api.configuration"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.2.2"
|
||||
__version__ = "1.2.3"
|
||||
|
||||
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="2", micro="2")
|
||||
version_info = VersionInfo(major="1", minor="2", micro="3")
|
||||
|
@@ -15,7 +15,7 @@ __title__ = "bot_api.controller"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.2.2"
|
||||
__version__ = "1.2.3"
|
||||
|
||||
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="2", micro="2")
|
||||
version_info = VersionInfo(major="1", minor="2", micro="3")
|
||||
|
@@ -15,7 +15,7 @@ __title__ = "bot_api.event"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.2.2"
|
||||
__version__ = "1.2.3"
|
||||
|
||||
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="2", micro="2")
|
||||
version_info = VersionInfo(major="1", minor="2", micro="3")
|
||||
|
@@ -15,7 +15,7 @@ __title__ = "bot_api.exception"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.2.2"
|
||||
__version__ = "1.2.3"
|
||||
|
||||
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="2", micro="2")
|
||||
version_info = VersionInfo(major="1", minor="2", micro="3")
|
||||
|
@@ -15,7 +15,7 @@ __title__ = "bot_api.filter"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.2.2"
|
||||
__version__ = "1.2.3"
|
||||
|
||||
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="2", micro="2")
|
||||
version_info = VersionInfo(major="1", minor="2", micro="3")
|
||||
|
@@ -15,7 +15,7 @@ __title__ = "bot_api.filter.discord"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.2.2"
|
||||
__version__ = "1.2.3"
|
||||
|
||||
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="2", micro="2")
|
||||
version_info = VersionInfo(major="1", minor="2", micro="3")
|
||||
|
@@ -15,7 +15,7 @@ __title__ = "bot_api.logging"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.2.2"
|
||||
__version__ = "1.2.3"
|
||||
|
||||
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="2", micro="2")
|
||||
version_info = VersionInfo(major="1", minor="2", micro="3")
|
||||
|
@@ -15,7 +15,7 @@ __title__ = "bot_api.model"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.2.2"
|
||||
__version__ = "1.2.3"
|
||||
|
||||
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="2", micro="2")
|
||||
version_info = VersionInfo(major="1", minor="2", micro="3")
|
||||
|
@@ -15,7 +15,7 @@ __title__ = "bot_api.model.discord"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.2.2"
|
||||
__version__ = "1.2.3"
|
||||
|
||||
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="2", micro="2")
|
||||
version_info = VersionInfo(major="1", minor="2", micro="3")
|
||||
|
@@ -15,7 +15,7 @@ __title__ = "bot_api.route"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.2.2"
|
||||
__version__ = "1.2.3"
|
||||
|
||||
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="2", micro="2")
|
||||
version_info = VersionInfo(major="1", minor="2", micro="3")
|
||||
|
@@ -15,7 +15,7 @@ __title__ = "bot_api.service"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.2.2"
|
||||
__version__ = "1.2.3"
|
||||
|
||||
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="2", micro="2")
|
||||
version_info = VersionInfo(major="1", minor="2", micro="3")
|
||||
|
@@ -15,7 +15,7 @@ __title__ = "bot_api.transformer"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.2.2"
|
||||
__version__ = "1.2.3"
|
||||
|
||||
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="2", micro="2")
|
||||
version_info = VersionInfo(major="1", minor="2", micro="3")
|
||||
|
@@ -15,7 +15,7 @@ __title__ = "bot_core"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.2.2"
|
||||
__version__ = "1.2.3"
|
||||
|
||||
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="2", micro="2")
|
||||
version_info = VersionInfo(major="1", minor="2", micro="3")
|
||||
|
@@ -15,7 +15,7 @@ __title__ = "bot_core.abc"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.2.2"
|
||||
__version__ = "1.2.3"
|
||||
|
||||
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="2", micro="2")
|
||||
version_info = VersionInfo(major="1", minor="2", micro="3")
|
||||
|
@@ -4,7 +4,7 @@
|
||||
"Version": {
|
||||
"Major": "1",
|
||||
"Minor": "2",
|
||||
"Micro": "2"
|
||||
"Micro": "3"
|
||||
},
|
||||
"Author": "Sven Heidemann",
|
||||
"AuthorEmail": "sven.heidemann@sh-edraft.de",
|
||||
|
@@ -15,7 +15,7 @@ __title__ = "bot_core.configuration"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.2.2"
|
||||
__version__ = "1.2.3"
|
||||
|
||||
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="2", micro="2")
|
||||
version_info = VersionInfo(major="1", minor="2", micro="3")
|
||||
|
@@ -15,7 +15,7 @@ __title__ = "bot_core.core_extension"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.2.2"
|
||||
__version__ = "1.2.3"
|
||||
|
||||
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="2", micro="2")
|
||||
version_info = VersionInfo(major="1", minor="2", micro="3")
|
||||
|
@@ -1,20 +1,18 @@
|
||||
import asyncio
|
||||
|
||||
from cpl_core.configuration import ConfigurationABC
|
||||
from cpl_core.logging import LoggerABC
|
||||
from cpl_discord.events import OnReadyABC
|
||||
from cpl_discord.service import DiscordBotServiceABC
|
||||
from cpl_translation import TranslatePipe
|
||||
|
||||
from bot_core.abc.client_utils_abc import ClientUtilsABC
|
||||
from bot_core.environment_variables import MAINTENANCE
|
||||
from bot_core.logging.event_logger import EventLogger
|
||||
|
||||
|
||||
class CoreExtensionOnReadyEvent(OnReadyABC):
|
||||
def __init__(
|
||||
self,
|
||||
config: ConfigurationABC,
|
||||
logger: LoggerABC,
|
||||
logger: EventLogger,
|
||||
bot: DiscordBotServiceABC,
|
||||
client_utils: ClientUtilsABC,
|
||||
t: TranslatePipe,
|
||||
|
@@ -15,7 +15,7 @@ __title__ = "bot_core.events"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.2.2"
|
||||
__version__ = "1.2.3"
|
||||
|
||||
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="2", micro="2")
|
||||
version_info = VersionInfo(major="1", minor="2", micro="3")
|
||||
|
@@ -1,15 +1,15 @@
|
||||
from cpl_core.logging import LoggerABC
|
||||
from cpl_discord.events import OnReadyABC
|
||||
from cpl_discord.service import DiscordBotServiceABC
|
||||
from cpl_translation import TranslatePipe
|
||||
|
||||
from bot_core.abc.client_utils_abc import ClientUtilsABC
|
||||
from bot_core.logging.event_logger import EventLogger
|
||||
|
||||
|
||||
class CoreOnReadyEvent(OnReadyABC):
|
||||
def __init__(
|
||||
self,
|
||||
logger: LoggerABC,
|
||||
logger: EventLogger,
|
||||
bot: DiscordBotServiceABC,
|
||||
client_utils: ClientUtilsABC,
|
||||
t: TranslatePipe,
|
||||
|
@@ -15,7 +15,7 @@ __title__ = "bot_core.exception"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.2.2"
|
||||
__version__ = "1.2.3"
|
||||
|
||||
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="2", micro="2")
|
||||
version_info = VersionInfo(major="1", minor="2", micro="3")
|
||||
|
@@ -15,7 +15,7 @@ __title__ = "bot_core.helper"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.2.2"
|
||||
__version__ = "1.2.3"
|
||||
|
||||
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="2", micro="2")
|
||||
version_info = VersionInfo(major="1", minor="2", micro="3")
|
||||
|
@@ -15,7 +15,7 @@ __title__ = "bot_core.logging"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.2.2"
|
||||
__version__ = "1.2.3"
|
||||
|
||||
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="2", micro="2")
|
||||
version_info = VersionInfo(major="1", minor="2", micro="3")
|
||||
|
15
bot/src/bot_core/logging/event_logger.py
Normal file
15
bot/src/bot_core/logging/event_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 EventLogger(CustomFileLoggerABC):
|
||||
def __init__(
|
||||
self,
|
||||
config: ConfigurationABC,
|
||||
time_format: TimeFormatSettings,
|
||||
env: ApplicationEnvironmentABC,
|
||||
):
|
||||
CustomFileLoggerABC.__init__(self, "Event", config, time_format, env)
|
@@ -15,7 +15,7 @@ __title__ = "bot_core.pipes"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.2.2"
|
||||
__version__ = "1.2.3"
|
||||
|
||||
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="2", micro="2")
|
||||
version_info = VersionInfo(major="1", minor="2", micro="3")
|
||||
|
@@ -15,7 +15,7 @@ __title__ = "bot_core.service"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.2.2"
|
||||
__version__ = "1.2.3"
|
||||
|
||||
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="2", micro="2")
|
||||
version_info = VersionInfo(major="1", minor="2", micro="3")
|
||||
|
@@ -74,7 +74,7 @@ class PermissionService(PermissionServiceABC):
|
||||
self._logger.debug(__name__, f"Checking is member {member.name} {team_member_type.value}")
|
||||
|
||||
has_permission = True in [
|
||||
member.guild.get_role(x.role_id) not in member.roles
|
||||
member.guild.get_role(x.role_id) in member.roles
|
||||
for x in self._server_configs.get_server_config_by_server(
|
||||
self._servers.get_server_by_discord_id(member.guild.id).id
|
||||
).team_role_ids
|
||||
|
@@ -15,7 +15,7 @@ __title__ = "bot_data"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.2.2"
|
||||
__version__ = "1.2.3"
|
||||
|
||||
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="2", micro="2")
|
||||
version_info = VersionInfo(major="1", minor="2", micro="3")
|
||||
|
@@ -15,7 +15,7 @@ __title__ = "bot_data.abc"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.2.2"
|
||||
__version__ = "1.2.3"
|
||||
|
||||
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="2", micro="2")
|
||||
version_info = VersionInfo(major="1", minor="2", micro="3")
|
||||
|
@@ -31,6 +31,10 @@ class UserRepositoryABC(ABC):
|
||||
def get_users_by_server_id(self, server_id: int) -> List[User]:
|
||||
pass
|
||||
|
||||
@abstractmethod
|
||||
def get_users_with_activity_by_server_id(self, server_id: int) -> List[User]:
|
||||
pass
|
||||
|
||||
@abstractmethod
|
||||
def get_user_by_discord_id_and_server_id(self, discord_id: int, server_id: int) -> User:
|
||||
pass
|
||||
|
@@ -4,7 +4,7 @@
|
||||
"Version": {
|
||||
"Major": "1",
|
||||
"Minor": "2",
|
||||
"Micro": "2"
|
||||
"Micro": "3"
|
||||
},
|
||||
"Author": "Sven Heidemann",
|
||||
"AuthorEmail": "sven.heidemann@sh-edraft.de",
|
||||
|
@@ -15,7 +15,7 @@ __title__ = "bot_data.model"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.2.2"
|
||||
__version__ = "1.2.3"
|
||||
|
||||
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="2", micro="2")
|
||||
version_info = VersionInfo(major="1", minor="2", micro="3")
|
||||
|
@@ -32,6 +32,8 @@ class User(TableABC):
|
||||
self._birthday = birthday
|
||||
self._server = server
|
||||
|
||||
self._activity = 0
|
||||
|
||||
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
|
||||
@@ -120,6 +122,14 @@ class User(TableABC):
|
||||
return 0
|
||||
return float(result)
|
||||
|
||||
@property
|
||||
def activity(self) -> int:
|
||||
return self._activity
|
||||
|
||||
@activity.setter
|
||||
def activity(self, value: int):
|
||||
self._activity = value
|
||||
|
||||
@property
|
||||
@ServiceProviderABC.inject
|
||||
def level(self, services: ServiceProviderABC) -> Level:
|
||||
@@ -158,6 +168,13 @@ class User(TableABC):
|
||||
game_idents_repo: UserGameIdentRepositoryABC = services.get_service(UserGameIdentRepositoryABC)
|
||||
return game_idents_repo.get_user_game_idents_by_user_id(self.id)
|
||||
|
||||
@property
|
||||
@ServiceProviderABC.inject
|
||||
def profile_picture_url(self, bot: DiscordBotServiceABC) -> str:
|
||||
guild = bot.get_guild(self.server.discord_id)
|
||||
user = guild.get_member(self._discord_id)
|
||||
return None if user is None else user.avatar.url
|
||||
|
||||
@staticmethod
|
||||
def get_select_all_string() -> str:
|
||||
return str(
|
||||
|
@@ -15,7 +15,7 @@ __title__ = "bot_data.service"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.2.2"
|
||||
__version__ = "1.2.3"
|
||||
|
||||
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="2", micro="2")
|
||||
version_info = VersionInfo(major="1", minor="2", micro="3")
|
||||
|
@@ -1,6 +1,8 @@
|
||||
import datetime
|
||||
from typing import Optional
|
||||
|
||||
from cpl_core.database.context import DatabaseContextABC
|
||||
from cpl_core.type import T, R
|
||||
from cpl_query.extension import List
|
||||
|
||||
from bot_core.logging.database_logger import DatabaseLogger
|
||||
@@ -38,7 +40,9 @@ class UserRepositoryService(UserRepositoryABC):
|
||||
|
||||
def get_users(self) -> List[User]:
|
||||
self._logger.trace(__name__, f"Send SQL command: {User.get_select_all_string()}")
|
||||
return List(User, [self._from_result(user) for user in self._context.select(User.get_select_all_string())])
|
||||
return List(
|
||||
User, [self._from_result(user) for user in self._context.select(User.get_select_all_string())]
|
||||
).for_each(lambda x: self._set_user_activity(x))
|
||||
|
||||
def get_user_by_id(self, id: int) -> User:
|
||||
self._logger.trace(__name__, f"Send SQL command: {User.get_select_by_id_string(id)}")
|
||||
@@ -77,6 +81,16 @@ class UserRepositoryService(UserRepositoryABC):
|
||||
[self._from_result(user) for user in self._context.select(User.get_select_by_server_id_string(server_id))],
|
||||
)
|
||||
|
||||
def get_users_with_activity_by_server_id(self, server_id: int) -> List[User]:
|
||||
self._logger.trace(
|
||||
__name__,
|
||||
f"Send SQL command: {User.get_select_by_server_id_string(server_id)}",
|
||||
)
|
||||
return List(
|
||||
User,
|
||||
[self._from_result(user) for user in self._context.select(User.get_select_by_server_id_string(server_id))],
|
||||
).for_each(lambda x: self._set_user_activity(x))
|
||||
|
||||
def get_user_by_discord_id_and_server_id(self, discord_id: int, server_id: int) -> User:
|
||||
self._logger.trace(
|
||||
__name__,
|
||||
@@ -109,3 +123,91 @@ class UserRepositoryService(UserRepositoryABC):
|
||||
def delete_user(self, user: User):
|
||||
self._logger.trace(__name__, f"Send SQL command: {user.delete_string}")
|
||||
self._context.cursor.execute(user.delete_string)
|
||||
|
||||
def _set_user_activity(self, user):
|
||||
days = (datetime.date.today() - (datetime.date.today() - datetime.timedelta(days=7))).days
|
||||
query = f"""
|
||||
SELECT (
|
||||
(
|
||||
SELECT Count(UserGotAchievements.CreatedAt)
|
||||
FROM UserGotAchievements
|
||||
INNER JOIN Achievements ON UserGotAchievements.AchievementId = Achievements.Id
|
||||
INNER JOIN Users ON UserGotAchievements.UserId = Users.UserId
|
||||
WHERE Users.ServerId = {user.server.id}
|
||||
AND Users.UserId = {user.id}
|
||||
AND UserGotAchievements.CreatedAt >= "{datetime.date.today() - datetime.timedelta(days=7)}"
|
||||
) +
|
||||
(
|
||||
SELECT SUM(
|
||||
UserMessageCountPerHour.XPCount / (
|
||||
SELECT XpPerMessage
|
||||
FROM CFG_Server
|
||||
WHERE ServerId = {user.server.id}
|
||||
)
|
||||
)
|
||||
FROM UserMessageCountPerHour
|
||||
INNER JOIN Users ON UserMessageCountPerHour.UserId = Users.UserId
|
||||
WHERE Users.ServerId = {user.server.id}
|
||||
AND Users.UserId = {user.id}
|
||||
AND UserMessageCountPerHour.CreatedAt >= "{datetime.date.today() - datetime.timedelta(days=7)}"
|
||||
) +
|
||||
(
|
||||
SELECT Count(UserJoinedVoiceChannel.CreatedAt)
|
||||
FROM UserJoinedVoiceChannel
|
||||
INNER JOIN Users ON UserJoinedVoiceChannel.UserId = Users.UserId
|
||||
WHERE Users.ServerId = {user.server.id}
|
||||
AND Users.UserId = {user.id}
|
||||
AND UserJoinedVoiceChannel.CreatedAt >= "{datetime.date.today() - datetime.timedelta(days=7)}"
|
||||
) +
|
||||
(
|
||||
SELECT IFNULL(ROUND(SUM(TIME_TO_SEC(
|
||||
TIMEDIFF(UserJoinedVoiceChannel.LeavedOn, UserJoinedVoiceChannel.JoinedOn)
|
||||
) / 3600), 2), 0)
|
||||
FROM UserJoinedVoiceChannel
|
||||
INNER JOIN Users ON UserJoinedVoiceChannel.UserId = Users.UserId
|
||||
WHERE Users.ServerId = {user.server.id}
|
||||
AND Users.UserId = {user.id}
|
||||
AND UserJoinedVoiceChannel.CreatedAt >= "{datetime.date.today() - datetime.timedelta(days=7)}"
|
||||
) +
|
||||
(
|
||||
SELECT Count(UserJoinedGameServer.CreatedAt)
|
||||
FROM UserJoinedGameServer
|
||||
INNER JOIN Users ON UserJoinedGameServer.UserId = Users.UserId
|
||||
WHERE Users.ServerId = {user.server.id}
|
||||
AND Users.UserId = {user.id}
|
||||
AND UserJoinedGameServer.CreatedAt >= "{datetime.date.today() - datetime.timedelta(days=7)}"
|
||||
) +
|
||||
(
|
||||
SELECT IFNULL(ROUND(SUM(TIME_TO_SEC(
|
||||
TIMEDIFF(UserJoinedGameServer.LeavedOn, UserJoinedGameServer.JoinedOn)
|
||||
) / 3600), 2), 0)
|
||||
FROM UserJoinedGameServer
|
||||
INNER JOIN Users ON UserJoinedGameServer.UserId = Users.UserId
|
||||
WHERE Users.ServerId = {user.server.id}
|
||||
AND Users.UserId = {user.id}
|
||||
AND UserJoinedGameServer.CreatedAt >= "{datetime.date.today() - datetime.timedelta(days=7)}"
|
||||
) -
|
||||
(
|
||||
SELECT COUNT(UserWarnings.CreatedAt)
|
||||
FROM UserWarnings
|
||||
INNER JOIN Users ON UserWarnings.UserId = Users.UserId
|
||||
WHERE Users.ServerId = {user.server.id}
|
||||
AND Users.UserId = {user.id}
|
||||
AND UserWarnings.CreatedAt >= "{datetime.date.today() - datetime.timedelta(days=7)}"
|
||||
)
|
||||
) / {days} * 1000 as count;
|
||||
"""
|
||||
user.activity = self._cast_query_result(query, int)
|
||||
|
||||
def _cast_query_result(self, query: str, r_type: T) -> Optional[R]:
|
||||
results = self._context.select(query)
|
||||
if len(results) == 0 or len(results[0]) == 0:
|
||||
return None
|
||||
result = results[0][0]
|
||||
default = None
|
||||
if r_type is int or r_type is float:
|
||||
default = 0
|
||||
elif r_type is str:
|
||||
default = ""
|
||||
|
||||
return r_type(result) if result is not None else default
|
||||
|
@@ -15,7 +15,7 @@ __title__ = "bot_graphql"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.2.2"
|
||||
__version__ = "1.2.3"
|
||||
|
||||
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="2", micro="2")
|
||||
version_info = VersionInfo(major="1", minor="2", micro="3")
|
||||
|
@@ -15,7 +15,7 @@ __title__ = "bot_graphql.abc"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.2.2"
|
||||
__version__ = "1.2.3"
|
||||
|
||||
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="2", micro="2")
|
||||
version_info = VersionInfo(major="1", minor="2", micro="3")
|
||||
|
@@ -64,11 +64,9 @@ class QueryABC(ObjectType):
|
||||
if user == "system" or user.auth_role == AuthRoleEnum.admin:
|
||||
return self._resolve_collection(collection, *args, **kwargs)
|
||||
|
||||
for x in collection.to_list():
|
||||
if not self._can_user_see_element(user, x):
|
||||
collection.remove(x)
|
||||
|
||||
return self._resolve_collection(collection, *args, **kwargs)
|
||||
return self._resolve_collection(
|
||||
collection.where(lambda x: self._can_user_see_element(user, x)), *args, **kwargs
|
||||
)
|
||||
|
||||
self.set_field(f"{name}s", wrapper)
|
||||
self.set_field(f"{name}Count", lambda *args: wrapper(*args).count())
|
||||
|
@@ -4,7 +4,7 @@
|
||||
"Version": {
|
||||
"Major": "1",
|
||||
"Minor": "2",
|
||||
"Micro": "2"
|
||||
"Micro": "3"
|
||||
},
|
||||
"Author": "Sven Heidemann",
|
||||
"AuthorEmail": "sven.heidemann@sh-edraft.de",
|
||||
|
@@ -15,7 +15,7 @@ __title__ = "bot_graphql.filter"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.2.2"
|
||||
__version__ = "1.2.3"
|
||||
|
||||
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="2", micro="2")
|
||||
version_info = VersionInfo(major="1", minor="2", micro="3")
|
||||
|
@@ -9,6 +9,9 @@ type User implements TableWithHistoryQuery {
|
||||
ontime: Float
|
||||
gameOntime: Float
|
||||
level: Level
|
||||
activityScore: Int
|
||||
|
||||
profilePictureURL: String
|
||||
|
||||
joinedServers(filter: UserJoinedServerFilter, page: Page, sort: Sort): [UserJoinedServer]
|
||||
joinedServerCount: Int
|
||||
|
@@ -15,7 +15,7 @@ __title__ = "bot_graphql.model"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.2.2"
|
||||
__version__ = "1.2.3"
|
||||
|
||||
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="2", micro="2")
|
||||
version_info = VersionInfo(major="1", minor="2", micro="3")
|
||||
|
@@ -15,7 +15,7 @@ __title__ = "bot_graphql.mutations"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.2.2"
|
||||
__version__ = "1.2.3"
|
||||
|
||||
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="2", micro="2")
|
||||
version_info = VersionInfo(major="1", minor="2", micro="3")
|
||||
|
@@ -11,6 +11,7 @@ from flask import request
|
||||
from bot_api.configuration.authentication_settings import AuthenticationSettings
|
||||
from bot_core.configuration.feature_flags_enum import FeatureFlagsEnum
|
||||
from bot_core.configuration.feature_flags_settings import FeatureFlagsSettings
|
||||
from bot_core.service.permission_service import PermissionService
|
||||
from bot_data.abc.api_key_repository_abc import ApiKeyRepositoryABC
|
||||
from bot_data.abc.game_server_repository_abc import GameServerRepositoryABC
|
||||
from bot_data.abc.server_repository_abc import ServerRepositoryABC
|
||||
@@ -24,7 +25,6 @@ from bot_data.model.server_config import ServerConfig
|
||||
from bot_data.model.user_joined_game_server import UserJoinedGameServer
|
||||
from bot_data.model.user_role_enum import UserRoleEnum
|
||||
from bot_graphql.abc.query_abc import QueryABC
|
||||
from bot_core.service.permission_service import PermissionService
|
||||
|
||||
|
||||
class UserJoinedGameServerMutation(QueryABC):
|
||||
@@ -79,7 +79,10 @@ class UserJoinedGameServerMutation(QueryABC):
|
||||
)
|
||||
|
||||
def resolve_user_joined(self, *_, input: dict):
|
||||
game_ident = self._user_game_idents.get_user_game_ident_by_ident(input["ident"])
|
||||
game_ident = self._user_game_idents.find_user_game_ident_by_ident(input["ident"])
|
||||
if game_ident is None:
|
||||
return
|
||||
|
||||
user = game_ident.user
|
||||
|
||||
settings: ServerConfig = self._config.get_configuration(f"ServerConfig_{user.server.discord_id}")
|
||||
|
@@ -4,6 +4,7 @@ from cpl_core.database.context import DatabaseContextABC
|
||||
from cpl_discord.service import DiscordBotServiceABC
|
||||
|
||||
from bot_api.route.route import Route
|
||||
from bot_core.service.permission_service import PermissionService
|
||||
from bot_data.abc.level_repository_abc import LevelRepositoryABC
|
||||
from bot_data.abc.server_repository_abc import ServerRepositoryABC
|
||||
from bot_data.abc.user_repository_abc import UserRepositoryABC
|
||||
@@ -13,7 +14,6 @@ from bot_data.model.user_role_enum import UserRoleEnum
|
||||
from bot_graphql.abc.query_abc import QueryABC
|
||||
from modules.base.service.user_warnings_service import UserWarningsService
|
||||
from modules.level.service.level_service import LevelService
|
||||
from bot_core.service.permission_service import PermissionService
|
||||
|
||||
|
||||
class UserMutation(QueryABC):
|
||||
@@ -50,7 +50,7 @@ class UserMutation(QueryABC):
|
||||
member = self._bot.get_guild(user.server.discord_id).get_member(
|
||||
auth_user.users.where(lambda x: x.server.id == user.server.id).single().discord_id
|
||||
)
|
||||
if member.id != user.discord_id:
|
||||
if self._permissions.is_member_moderator(member) or member.id != user.discord_id:
|
||||
self._can_user_mutate_data(user.server, UserRoleEnum.moderator)
|
||||
|
||||
new_xp = None
|
||||
|
@@ -15,7 +15,7 @@ __title__ = "bot_graphql.queries"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.2.2"
|
||||
__version__ = "1.2.3"
|
||||
|
||||
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="2", micro="2")
|
||||
version_info = VersionInfo(major="1", minor="2", micro="3")
|
||||
|
@@ -15,7 +15,7 @@ __title__ = "bot_graphql.queries.discord"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.2.2"
|
||||
__version__ = "1.2.3"
|
||||
|
||||
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="2", micro="2")
|
||||
version_info = VersionInfo(major="1", minor="2", micro="3")
|
||||
|
@@ -86,7 +86,7 @@ class ServerQuery(DataQueryWithHistoryABC):
|
||||
)
|
||||
self.add_collection(
|
||||
"user",
|
||||
lambda server, *_: self._users.get_users_by_server_id(server.id),
|
||||
lambda server, *_: self._users.get_users_with_activity_by_server_id(server.id),
|
||||
UserFilter,
|
||||
)
|
||||
self.add_collection(
|
||||
|
@@ -114,7 +114,9 @@ class ServerStatisticQuery(QueryABC):
|
||||
|
||||
def _resolve_voice_channel_ontime(self, server, *_):
|
||||
query = f"""
|
||||
SELECT ROUND(SUM(TIME_TO_SEC(TIMEDIFF(UserJoinedVoiceChannel.LeavedOn, UserJoinedVoiceChannel.JoinedOn)) / 3600),{server.server.id}) FROM UserJoinedVoiceChannel
|
||||
SELECT IFNULL(ROUND(SUM(
|
||||
TIME_TO_SEC(TIMEDIFF(UserJoinedVoiceChannel.LeavedOn, UserJoinedVoiceChannel.JoinedOn)) / 3600
|
||||
), 2), 0) FROM UserJoinedVoiceChannel
|
||||
INNER JOIN Users ON UserJoinedVoiceChannel.UserId = Users.UserId
|
||||
WHERE Users.ServerId = {server.server.id}
|
||||
AND UserJoinedVoiceChannel.CreatedAt >= "{self._get_date(**server.kwargs)}";
|
||||
@@ -132,7 +134,10 @@ class ServerStatisticQuery(QueryABC):
|
||||
|
||||
def _resolve_game_server_ontime(self, server, *_):
|
||||
query = f"""
|
||||
SELECT ROUND(SUM(TIME_TO_SEC(TIMEDIFF(UserJoinedGameServer.LeavedOn, UserJoinedGameServer.JoinedOn)) / 3600),2) FROM UserJoinedGameServer
|
||||
SELECT IFNULL(ROUND(SUM(
|
||||
TIME_TO_SEC(TIMEDIFF(UserJoinedGameServer.LeavedOn, UserJoinedGameServer.JoinedOn)) / 3600
|
||||
), 2), 0)
|
||||
FROM UserJoinedGameServer
|
||||
INNER JOIN Users ON UserJoinedGameServer.UserId = Users.UserId
|
||||
WHERE Users.ServerId = {server.server.id}
|
||||
AND UserJoinedGameServer.CreatedAt >= "{self._get_date(**server.kwargs)}";
|
||||
|
@@ -59,6 +59,7 @@ class UserQuery(DataQueryWithHistoryABC):
|
||||
self.set_field("ontime", lambda user, *_: user.ontime)
|
||||
self.set_field("gameOntime", lambda user, *_: user.game_ontime)
|
||||
self.set_field("level", lambda user, *_: user.level)
|
||||
self.set_field("activityScore", lambda user, *_: user.activity)
|
||||
self.add_collection(
|
||||
"joinedServer",
|
||||
lambda user, *_: self._ujs.get_user_joined_servers_by_user_id(user.id),
|
||||
@@ -87,3 +88,4 @@ class UserQuery(DataQueryWithHistoryABC):
|
||||
|
||||
self.set_field("server", lambda user, *_: user.server)
|
||||
self.set_field("leftServer", lambda user, *_: user.left_server)
|
||||
self.set_field("profilePictureURL", lambda user, *_: user.profile_picture_url)
|
||||
|
@@ -15,7 +15,7 @@ __title__ = "modules.achievements"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.2.2"
|
||||
__version__ = "1.2.3"
|
||||
|
||||
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="2", micro="2")
|
||||
version_info = VersionInfo(major="1", minor="2", micro="3")
|
||||
|
@@ -4,7 +4,7 @@
|
||||
"Version": {
|
||||
"Major": "1",
|
||||
"Minor": "2",
|
||||
"Micro": "2"
|
||||
"Micro": "3"
|
||||
},
|
||||
"Author": "Sven Heidemann",
|
||||
"AuthorEmail": "sven.heidemann@sh-edraft.de",
|
||||
|
@@ -15,7 +15,7 @@ __title__ = "modules.achievements.commands"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.2.2"
|
||||
__version__ = "1.2.3"
|
||||
|
||||
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="2", micro="2")
|
||||
version_info = VersionInfo(major="1", minor="2", micro="3")
|
||||
|
@@ -15,7 +15,7 @@ __title__ = "modules.achievements.events"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.2.2"
|
||||
__version__ = "1.2.3"
|
||||
|
||||
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="2", micro="2")
|
||||
version_info = VersionInfo(major="1", minor="2", micro="3")
|
||||
|
@@ -15,7 +15,7 @@ __title__ = "modules.achievements.model"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.2.2"
|
||||
__version__ = "1.2.3"
|
||||
|
||||
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="2", micro="2")
|
||||
version_info = VersionInfo(major="1", minor="2", micro="3")
|
||||
|
@@ -15,7 +15,7 @@ __title__ = "modules.auto_role"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.2.2"
|
||||
__version__ = "1.2.3"
|
||||
|
||||
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="2", micro="2")
|
||||
version_info = VersionInfo(major="1", minor="2", micro="3")
|
||||
|
@@ -4,7 +4,7 @@
|
||||
"Version": {
|
||||
"Major": "1",
|
||||
"Minor": "2",
|
||||
"Micro": "2"
|
||||
"Micro": "3"
|
||||
},
|
||||
"Author": "",
|
||||
"AuthorEmail": "",
|
||||
|
@@ -15,7 +15,7 @@ __title__ = "modules.auto_role.command"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.2.2"
|
||||
__version__ = "1.2.3"
|
||||
|
||||
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="2", micro="2")
|
||||
version_info = VersionInfo(major="1", minor="2", micro="3")
|
||||
|
@@ -15,7 +15,7 @@ __title__ = "modules.auto_role.events"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.2.2"
|
||||
__version__ = "1.2.3"
|
||||
|
||||
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="2", micro="2")
|
||||
version_info = VersionInfo(major="1", minor="2", micro="3")
|
||||
|
@@ -15,7 +15,7 @@ __title__ = "modules.auto_role.helper"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.2.2"
|
||||
__version__ = "1.2.3"
|
||||
|
||||
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="2", micro="2")
|
||||
version_info = VersionInfo(major="1", minor="2", micro="3")
|
||||
|
@@ -15,7 +15,7 @@ __title__ = "modules.base"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.2.2"
|
||||
__version__ = "1.2.3"
|
||||
|
||||
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="2", micro="2")
|
||||
version_info = VersionInfo(major="1", minor="2", micro="3")
|
||||
|
@@ -4,7 +4,7 @@
|
||||
"Version": {
|
||||
"Major": "1",
|
||||
"Minor": "2",
|
||||
"Micro": "2"
|
||||
"Micro": "3"
|
||||
},
|
||||
"Author": "",
|
||||
"AuthorEmail": "",
|
||||
|
@@ -62,8 +62,8 @@ class BaseModule(ModuleABC):
|
||||
services.add_transient(BaseReactionHandler)
|
||||
services.add_singleton(EventService)
|
||||
services.add_transient(UserWarningsService)
|
||||
services.add_singleton(TaskABC, BirthdayWatcher)
|
||||
services.add_singleton(TaskABC, ScheduledEventsWatcher)
|
||||
services.add_transient(TaskABC, BirthdayWatcher)
|
||||
services.add_transient(TaskABC, ScheduledEventsWatcher)
|
||||
|
||||
# forms
|
||||
services.add_transient(BugReportForm)
|
||||
|
@@ -15,7 +15,7 @@ __title__ = "modules.base.command"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.2.2"
|
||||
__version__ = "1.2.3"
|
||||
|
||||
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="2", micro="2")
|
||||
version_info = VersionInfo(major="1", minor="2", micro="3")
|
||||
|
@@ -9,6 +9,7 @@ from cpl_translation import TranslatePipe
|
||||
from discord import app_commands
|
||||
from discord.ext import commands
|
||||
from discord.ext.commands import Context
|
||||
from valve.steam.id import SteamID
|
||||
|
||||
from bot_core.abc.client_utils_abc import ClientUtilsABC
|
||||
from bot_core.abc.message_service_abc import MessageServiceABC
|
||||
@@ -50,6 +51,17 @@ class RegisterGroup(DiscordCommandABC):
|
||||
|
||||
self._logger.trace(__name__, f"Loaded command service: {type(self).__name__}")
|
||||
|
||||
async def _game_server_autocomplete(
|
||||
self, interaction: discord.Interaction, current: str
|
||||
) -> TList[app_commands.Choice[str]]:
|
||||
server = self._servers.get_server_by_discord_id(interaction.guild.id)
|
||||
game_servers = self._game_server.get_game_servers_by_server_id(server.id)
|
||||
|
||||
return [
|
||||
app_commands.Choice(name=gs.name, value=gs.id)
|
||||
for gs in self._client_utils.get_auto_complete_list(game_servers, current, lambda x: x.name)
|
||||
]
|
||||
|
||||
@commands.hybrid_group()
|
||||
@commands.guild_only()
|
||||
async def register(self, ctx: Context):
|
||||
@@ -101,10 +113,44 @@ class RegisterGroup(DiscordCommandABC):
|
||||
async def game_server_autocomplete(
|
||||
self, interaction: discord.Interaction, current: str
|
||||
) -> TList[app_commands.Choice[str]]:
|
||||
server = self._servers.get_server_by_discord_id(interaction.guild.id)
|
||||
game_servers = self._game_server.get_game_servers_by_server_id(server.id)
|
||||
return await self._game_server_autocomplete(interaction, current)
|
||||
|
||||
return [
|
||||
app_commands.Choice(name=gs.name, value=gs.id)
|
||||
for gs in self._client_utils.get_auto_complete_list(game_servers, current, lambda x: x.name)
|
||||
]
|
||||
@register.command()
|
||||
@commands.guild_only()
|
||||
@CommandChecks.check_is_ready()
|
||||
@CommandChecks.check_is_member_moderator()
|
||||
async def gmod(self, ctx: Context, member: discord.Member, game_server: int, steam_url: str):
|
||||
self._logger.debug(__name__, f"Received command register gmod {ctx}")
|
||||
|
||||
steam_id = None
|
||||
try:
|
||||
self._logger.debug(__name__, f"Try to get steam id for {id}")
|
||||
steam_id = SteamID.from_community_url(steam_url)
|
||||
except Exception as e:
|
||||
self._logger.error(__name__, f"Get steam id for {steam_id} failed", e)
|
||||
await self._message_service.send_interaction_msg(
|
||||
ctx.interaction, self._t.transform("modules.base.register.not_found")
|
||||
)
|
||||
|
||||
if steam_id is None:
|
||||
return
|
||||
|
||||
server = self._servers.get_server_by_discord_id(ctx.guild.id)
|
||||
user = self._users.get_user_by_discord_id_and_server_id(member.id, server.id)
|
||||
gs = self._game_server.get_game_server_by_id(game_server)
|
||||
|
||||
game_ident = UserGameIdent(user, gs, steam_id)
|
||||
self._user_game_ident.add_user_game_ident(game_ident)
|
||||
self._db.save_changes()
|
||||
|
||||
await self._message_service.send_interaction_msg(
|
||||
ctx.interaction, self._t.transform("modules.base.register.success")
|
||||
)
|
||||
|
||||
self._logger.trace(__name__, f"Finished register gmod command")
|
||||
|
||||
@gmod.autocomplete("game_server")
|
||||
async def game_server_autocomplete(
|
||||
self, interaction: discord.Interaction, current: str
|
||||
) -> TList[app_commands.Choice[str]]:
|
||||
return await self._game_server_autocomplete(interaction, current)
|
||||
|
@@ -1,22 +1,34 @@
|
||||
from cpl_core.configuration import ConfigurationABC
|
||||
from cpl_discord.command import DiscordCommandABC
|
||||
from cpl_translation import TranslatePipe
|
||||
from discord.ext import commands
|
||||
from discord.ext.commands import Context
|
||||
|
||||
from bot_core.configuration.feature_flags_enum import FeatureFlagsEnum
|
||||
from bot_core.configuration.feature_flags_settings import FeatureFlagsSettings
|
||||
from bot_core.helper.command_checks import CommandChecks
|
||||
from bot_core.logging.command_logger import CommandLogger
|
||||
from bot_core.service.message_service import MessageService
|
||||
from bot_data.model.server_config import ServerConfig
|
||||
from modules.base.service.event_service import EventService
|
||||
|
||||
|
||||
class ScheduledEventsCommand(DiscordCommandABC):
|
||||
def __init__(
|
||||
self,
|
||||
config: ConfigurationABC,
|
||||
logger: CommandLogger,
|
||||
events: EventService,
|
||||
message_service: MessageService,
|
||||
t: TranslatePipe,
|
||||
):
|
||||
DiscordCommandABC.__init__(self)
|
||||
|
||||
self._config = config
|
||||
self._logger = logger
|
||||
self._events = events
|
||||
self._message_service = message_service
|
||||
self._t = t
|
||||
|
||||
self._logger.trace(__name__, f"Loaded command service: {type(self).__name__}")
|
||||
|
||||
@@ -30,6 +42,12 @@ class ScheduledEventsCommand(DiscordCommandABC):
|
||||
@CommandChecks.check_is_ready()
|
||||
@CommandChecks.check_is_member_moderator()
|
||||
async def reload(self, ctx: Context):
|
||||
settings: ServerConfig = self._config.get_configuration(f"ServerConfig_{ctx.guild.id}")
|
||||
if not FeatureFlagsSettings.get_flag_from_dict(settings.feature_flags, FeatureFlagsEnum.scheduled_events):
|
||||
self._logger.debug(__name__, f"Skipping scheduled event check for {ctx.guild.id}. Feature is disabled.")
|
||||
await self._message_service.send_ctx_msg(ctx, self._t.transform("common.feature_not_activated"))
|
||||
return
|
||||
|
||||
self._logger.debug(__name__, "Running scheduled-events reload")
|
||||
try:
|
||||
await self._events.check_and_create_scheduled_events(ctx.guild)
|
||||
|
@@ -15,7 +15,7 @@ __title__ = "modules.base.events"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.2.2"
|
||||
__version__ = "1.2.3"
|
||||
|
||||
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="2", micro="2")
|
||||
version_info = VersionInfo(major="1", minor="2", micro="3")
|
||||
|
@@ -1,7 +1,6 @@
|
||||
import datetime
|
||||
import uuid
|
||||
|
||||
from cpl_core.logging import LoggerABC
|
||||
from cpl_core.time import TimeFormatSettings
|
||||
from cpl_discord.events.on_command_error_abc import OnCommandErrorABC
|
||||
from cpl_discord.service import DiscordBotServiceABC
|
||||
@@ -12,13 +11,14 @@ from discord.ext.commands import Context, CommandError
|
||||
from bot_core.abc.message_service_abc import MessageServiceABC
|
||||
from bot_core.exception.check_error import CheckError
|
||||
from bot_core.helper.event_checks import EventChecks
|
||||
from bot_core.logging.event_logger import EventLogger
|
||||
from bot_data.model.technician_config import TechnicianConfig
|
||||
|
||||
|
||||
class BaseOnCommandErrorEvent(OnCommandErrorABC):
|
||||
def __init__(
|
||||
self,
|
||||
logger: LoggerABC,
|
||||
logger: EventLogger,
|
||||
bot: DiscordBotServiceABC,
|
||||
messenger: MessageServiceABC,
|
||||
tech_settings: TechnicianConfig,
|
||||
|
@@ -1,10 +1,10 @@
|
||||
from cpl_core.database.context import DatabaseContextABC
|
||||
from cpl_core.logging import LoggerABC
|
||||
from cpl_discord.events import OnGuildJoinABC
|
||||
from cpl_discord.service import DiscordBotServiceABC
|
||||
from discord import Guild
|
||||
|
||||
from bot_core.helper.event_checks import EventChecks
|
||||
from bot_core.logging.event_logger import EventLogger
|
||||
from bot_data.abc.server_config_repository_abc import ServerConfigRepositoryABC
|
||||
from bot_data.abc.server_repository_abc import ServerRepositoryABC
|
||||
from bot_data.model.server import Server
|
||||
@@ -14,7 +14,7 @@ from bot_data.service.seeder_service import SeederService
|
||||
class BaseOnGuildJoinEvent(OnGuildJoinABC):
|
||||
def __init__(
|
||||
self,
|
||||
logger: LoggerABC,
|
||||
logger: EventLogger,
|
||||
bot: DiscordBotServiceABC,
|
||||
servers: ServerRepositoryABC,
|
||||
server_config: ServerConfigRepositoryABC,
|
||||
|
@@ -4,14 +4,15 @@ from typing import Union
|
||||
import discord
|
||||
from cpl_core.configuration import ConfigurationABC
|
||||
from cpl_core.database.context import DatabaseContextABC
|
||||
from cpl_core.logging import LoggerABC
|
||||
from cpl_discord.events import OnMemberJoinABC
|
||||
from cpl_discord.service import DiscordBotServiceABC
|
||||
from cpl_translation import TranslatePipe
|
||||
|
||||
from bot_core.abc.client_utils_abc import ClientUtilsABC
|
||||
from bot_core.abc.message_service_abc import MessageServiceABC
|
||||
from bot_core.abc.permission_service_abc import PermissionServiceABC
|
||||
from bot_core.helper.event_checks import EventChecks
|
||||
from bot_core.logging.event_logger import EventLogger
|
||||
from bot_data.abc.known_user_repository_abc import KnownUserRepositoryABC
|
||||
from bot_data.abc.server_repository_abc import ServerRepositoryABC
|
||||
from bot_data.abc.user_joined_server_repository_abc import UserJoinedServerRepositoryABC
|
||||
@@ -20,14 +21,13 @@ from bot_data.model.known_user import KnownUser
|
||||
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_core.abc.permission_service_abc import PermissionServiceABC
|
||||
|
||||
|
||||
class BaseOnMemberJoinEvent(OnMemberJoinABC):
|
||||
def __init__(
|
||||
self,
|
||||
config: ConfigurationABC,
|
||||
logger: LoggerABC,
|
||||
logger: EventLogger,
|
||||
messenger: MessageServiceABC,
|
||||
permissions: PermissionServiceABC,
|
||||
db: DatabaseContextABC,
|
||||
|
@@ -4,12 +4,12 @@ from typing import Union
|
||||
import discord
|
||||
from cpl_core.configuration import ConfigurationABC
|
||||
from cpl_core.database.context import DatabaseContextABC
|
||||
from cpl_core.logging import LoggerABC
|
||||
from cpl_discord.events import OnMemberRemoveABC
|
||||
from cpl_translation import TranslatePipe
|
||||
|
||||
from bot_core.abc.message_service_abc import MessageServiceABC
|
||||
from bot_core.helper.event_checks import EventChecks
|
||||
from bot_core.logging.event_logger import EventLogger
|
||||
from bot_data.abc.server_repository_abc import ServerRepositoryABC
|
||||
from bot_data.abc.user_joined_server_repository_abc import UserJoinedServerRepositoryABC
|
||||
from bot_data.abc.user_repository_abc import UserRepositoryABC
|
||||
@@ -20,7 +20,7 @@ class BaseOnMemberRemoveEvent(OnMemberRemoveABC):
|
||||
def __init__(
|
||||
self,
|
||||
config: ConfigurationABC,
|
||||
logger: LoggerABC,
|
||||
logger: EventLogger,
|
||||
db: DatabaseContextABC,
|
||||
message_service: MessageServiceABC,
|
||||
users: UserRepositoryABC,
|
||||
|
@@ -4,6 +4,7 @@ from cpl_discord.service import DiscordBotServiceABC
|
||||
from discord import RawReactionActionEvent
|
||||
|
||||
from bot_core.helper.event_checks import EventChecks
|
||||
from bot_core.logging.event_logger import EventLogger
|
||||
from bot_data.abc.auto_role_repository_abc import AutoRoleRepositoryABC
|
||||
from bot_data.abc.server_repository_abc import ServerRepositoryABC
|
||||
from modules.base.helper.base_reaction_handler import BaseReactionHandler
|
||||
@@ -12,7 +13,7 @@ from modules.base.helper.base_reaction_handler import BaseReactionHandler
|
||||
class BaseOnRawReactionAddEvent(OnRawReactionAddABC):
|
||||
def __init__(
|
||||
self,
|
||||
logger: LoggerABC,
|
||||
logger: EventLogger,
|
||||
bot: DiscordBotServiceABC,
|
||||
servers: ServerRepositoryABC,
|
||||
auto_roles: AutoRoleRepositoryABC,
|
||||
|
@@ -4,6 +4,7 @@ from cpl_discord.service import DiscordBotServiceABC
|
||||
from discord import RawReactionActionEvent
|
||||
|
||||
from bot_core.helper.event_checks import EventChecks
|
||||
from bot_core.logging.event_logger import EventLogger
|
||||
from bot_data.abc.auto_role_repository_abc import AutoRoleRepositoryABC
|
||||
from bot_data.abc.server_repository_abc import ServerRepositoryABC
|
||||
from modules.base.helper.base_reaction_handler import BaseReactionHandler
|
||||
@@ -12,7 +13,7 @@ from modules.base.helper.base_reaction_handler import BaseReactionHandler
|
||||
class BaseOnRawReactionRemoveEvent(OnRawReactionRemoveABC):
|
||||
def __init__(
|
||||
self,
|
||||
logger: LoggerABC,
|
||||
logger: EventLogger,
|
||||
bot: DiscordBotServiceABC,
|
||||
servers: ServerRepositoryABC,
|
||||
auto_roles: AutoRoleRepositoryABC,
|
||||
|
@@ -5,6 +5,7 @@ from cpl_discord.service import DiscordBotServiceABC
|
||||
from discord import EventStatus
|
||||
|
||||
from bot_core.helper.event_checks import EventChecks
|
||||
from bot_core.logging.event_logger import EventLogger
|
||||
from modules.base.model.active_event import ActiveEvent
|
||||
from modules.base.service.event_service import EventService
|
||||
|
||||
@@ -12,7 +13,7 @@ from modules.base.service.event_service import EventService
|
||||
class BaseOnScheduledEventUpdateEvent(OnScheduledEventUpdateABC):
|
||||
def __init__(
|
||||
self,
|
||||
logger: LoggerABC,
|
||||
logger: EventLogger,
|
||||
bot: DiscordBotServiceABC,
|
||||
events: EventService,
|
||||
):
|
||||
|
@@ -8,6 +8,7 @@ from cpl_core.logging import LoggerABC
|
||||
from cpl_discord.events import OnVoiceStateUpdateABC
|
||||
|
||||
from bot_core.helper.event_checks import EventChecks
|
||||
from bot_core.logging.event_logger import EventLogger
|
||||
from bot_data.abc.known_user_repository_abc import KnownUserRepositoryABC
|
||||
from bot_data.abc.server_repository_abc import ServerRepositoryABC
|
||||
from bot_data.abc.user_joined_server_repository_abc import UserJoinedServerRepositoryABC
|
||||
@@ -25,7 +26,7 @@ class BaseOnVoiceStateUpdateEvent(OnVoiceStateUpdateABC):
|
||||
def __init__(
|
||||
self,
|
||||
config: ConfigurationABC,
|
||||
logger: LoggerABC,
|
||||
logger: EventLogger,
|
||||
servers: ServerRepositoryABC,
|
||||
known_users: KnownUserRepositoryABC,
|
||||
users: UserRepositoryABC,
|
||||
|
@@ -6,6 +6,7 @@ from cpl_translation import TranslatePipe
|
||||
|
||||
from bot_core.abc.message_service_abc import MessageServiceABC
|
||||
from bot_core.helper.event_checks import EventChecks
|
||||
from bot_core.logging.event_logger import EventLogger
|
||||
from bot_data.abc.server_repository_abc import ServerRepositoryABC
|
||||
from bot_data.model.server_config import ServerConfig
|
||||
from bot_core.abc.permission_service_abc import PermissionServiceABC
|
||||
@@ -15,7 +16,7 @@ class BaseOnVoiceStateUpdateEventHelpChannel(OnVoiceStateUpdateABC):
|
||||
def __init__(
|
||||
self,
|
||||
config: ConfigurationABC,
|
||||
logger: LoggerABC,
|
||||
logger: EventLogger,
|
||||
servers: ServerRepositoryABC,
|
||||
permissions: PermissionServiceABC,
|
||||
message_service: MessageServiceABC,
|
||||
|
@@ -5,6 +5,7 @@ from cpl_core.logging import LoggerABC
|
||||
from cpl_discord.events import OnVoiceStateUpdateABC
|
||||
|
||||
from bot_core.helper.event_checks import EventChecks
|
||||
from bot_core.logging.event_logger import EventLogger
|
||||
from bot_data.abc.server_repository_abc import ServerRepositoryABC
|
||||
from bot_data.abc.user_repository_abc import UserRepositoryABC
|
||||
from modules.base.service.event_service import EventService
|
||||
@@ -14,7 +15,7 @@ class BaseOnVoiceStateUpdateEventScheduledEventBonus(OnVoiceStateUpdateABC):
|
||||
def __init__(
|
||||
self,
|
||||
config: ConfigurationABC,
|
||||
logger: LoggerABC,
|
||||
logger: EventLogger,
|
||||
servers: ServerRepositoryABC,
|
||||
users: UserRepositoryABC,
|
||||
events: EventService,
|
||||
|
@@ -15,7 +15,7 @@ __title__ = "modules.base.forms"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.2.2"
|
||||
__version__ = "1.2.3"
|
||||
|
||||
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="2", micro="2")
|
||||
version_info = VersionInfo(major="1", minor="2", micro="3")
|
||||
|
@@ -15,7 +15,7 @@ __title__ = "modules.base.helper"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.2.2"
|
||||
__version__ = "1.2.3"
|
||||
|
||||
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="2", micro="2")
|
||||
version_info = VersionInfo(major="1", minor="2", micro="3")
|
||||
|
@@ -15,7 +15,7 @@ __title__ = "modules.base.model"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.2.2"
|
||||
__version__ = "1.2.3"
|
||||
|
||||
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="2", micro="2")
|
||||
version_info = VersionInfo(major="1", minor="2", micro="3")
|
||||
|
@@ -15,7 +15,7 @@ __title__ = "modules.base.service"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.2.2"
|
||||
__version__ = "1.2.3"
|
||||
|
||||
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="2", micro="2")
|
||||
version_info = VersionInfo(major="1", minor="2", micro="3")
|
||||
|
@@ -9,7 +9,7 @@ from cpl_core.database.context import DatabaseContextABC
|
||||
from cpl_core.logging import LoggerABC
|
||||
from cpl_discord.container import Guild
|
||||
from cpl_query.extension import List
|
||||
from discord import PrivacyLevel
|
||||
from discord import PrivacyLevel, EventStatus
|
||||
from discord.scheduled_event import ScheduledEvent as DiscordEvent
|
||||
|
||||
from bot_data.abc.scheduled_event_repository_abc import ScheduledEventRepositoryABC
|
||||
@@ -99,14 +99,17 @@ class EventService:
|
||||
async def check_and_create_scheduled_events(self, guild: Guild):
|
||||
server = self._servers.get_server_by_discord_id(guild.id)
|
||||
scheduled_events_from_db = self._events.get_scheduled_events_by_server_id(server.id)
|
||||
self._logger.debug(__name__, f"Checking {scheduled_events_from_db.count()} events for server {guild.id}")
|
||||
for scheduled_event in scheduled_events_from_db:
|
||||
scheduled_event: ScheduledEvent = scheduled_event
|
||||
from_guild = List(DiscordEvent, guild.scheduled_events).where(
|
||||
lambda x: x.name == scheduled_event.name
|
||||
and x.description == scheduled_event.description
|
||||
and x.entity_type == scheduled_event.entity_type
|
||||
and x.status == EventStatus.scheduled
|
||||
)
|
||||
if from_guild.count() != 0:
|
||||
self._logger.debug(__name__, f"Event {scheduled_event.name} already exists on discord server")
|
||||
continue
|
||||
|
||||
kwargs = {"name": scheduled_event.name, "description": scheduled_event.description}
|
||||
@@ -119,14 +122,14 @@ class EventService:
|
||||
scheduled_event.interval, scheduled_event.start_time.replace(tzinfo=ZoneInfo("Europe/Berlin"))
|
||||
)
|
||||
kwargs["start_time"] = start_time
|
||||
scheduled_event.start_time = scheduled_event.start_time.replace(tzinfo=None)
|
||||
scheduled_event.start_time = start_time.replace(tzinfo=None)
|
||||
|
||||
if scheduled_event.end_time is not None:
|
||||
end_time = self._append_interval(
|
||||
scheduled_event.interval, scheduled_event.end_time.replace(tzinfo=ZoneInfo("Europe/Berlin"))
|
||||
)
|
||||
kwargs["end_time"] = end_time
|
||||
scheduled_event.end_time = scheduled_event.end_time.replace(tzinfo=None)
|
||||
scheduled_event.end_time = end_time.replace(tzinfo=None)
|
||||
|
||||
kwargs["entity_type"] = scheduled_event.entity_type
|
||||
if scheduled_event.location is not None:
|
||||
@@ -135,9 +138,10 @@ class EventService:
|
||||
kwargs["privacy_level"] = PrivacyLevel.guild_only
|
||||
|
||||
try:
|
||||
self._logger.debug(__name__, f"Try to create scheduled event for guild {guild.name}")
|
||||
self._logger.trace(__name__, f"Try to create scheduled event for guild {guild.name}")
|
||||
await guild.create_scheduled_event(**kwargs)
|
||||
self._events.update_scheduled_event(scheduled_event)
|
||||
self._db.save_changes()
|
||||
self._logger.debug(__name__, f"Created scheduled event for guild {guild.name}")
|
||||
except Exception as e:
|
||||
self._logger.error(__name__, f"Watching scheduled events failed", e)
|
||||
|
@@ -15,7 +15,7 @@ __title__ = "modules.base.tasks"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.2.2"
|
||||
__version__ = "1.2.3"
|
||||
|
||||
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="2", micro="2")
|
||||
version_info = VersionInfo(major="1", minor="2", micro="3")
|
||||
|
@@ -37,7 +37,7 @@ class BirthdayWatcher(TaskABC):
|
||||
if not self._is_maintenance():
|
||||
self.watch.start()
|
||||
|
||||
@tasks.loop(time=datetime.time(hour=8, minute=0))
|
||||
@tasks.loop(time=datetime.time(hour=8, minute=0), reconnect=True)
|
||||
async def watch(self):
|
||||
self._logger.info(__name__, "Watching birthdays")
|
||||
try:
|
||||
|
@@ -5,9 +5,12 @@ from cpl_translation import TranslatePipe
|
||||
from discord.ext import tasks
|
||||
|
||||
from bot_core.abc.task_abc import TaskABC
|
||||
from bot_core.configuration.feature_flags_enum import FeatureFlagsEnum
|
||||
from bot_core.configuration.feature_flags_settings import FeatureFlagsSettings
|
||||
from bot_core.logging.task_logger import TaskLogger
|
||||
from bot_core.service.message_service import MessageService
|
||||
from bot_data.abc.server_repository_abc import ServerRepositoryABC
|
||||
from bot_data.model.server_config import ServerConfig
|
||||
from modules.base.service.event_service import EventService
|
||||
|
||||
|
||||
@@ -37,11 +40,18 @@ class ScheduledEventsWatcher(TaskABC):
|
||||
if not self._is_maintenance():
|
||||
self.watch.start()
|
||||
|
||||
@tasks.loop(hours=12)
|
||||
@tasks.loop(hours=3, reconnect=True)
|
||||
async def watch(self):
|
||||
self._logger.info(__name__, "Watching scheduled events")
|
||||
try:
|
||||
for guild in self._bot.guilds:
|
||||
settings: ServerConfig = self._config.get_configuration(f"ServerConfig_{guild.id}")
|
||||
if not FeatureFlagsSettings.get_flag_from_dict(
|
||||
settings.feature_flags, FeatureFlagsEnum.scheduled_events
|
||||
):
|
||||
self._logger.debug(__name__, f"Skipping scheduled event check for {guild.id}. Feature is disabled.")
|
||||
continue
|
||||
|
||||
await self._events.check_and_create_scheduled_events(guild)
|
||||
except Exception as e:
|
||||
self._logger.error(__name__, f"Watching scheduled events failed", e)
|
||||
|
@@ -15,7 +15,7 @@ __title__ = "modules.boot_log"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.2.2"
|
||||
__version__ = "1.2.3"
|
||||
|
||||
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="2", micro="2")
|
||||
version_info = VersionInfo(major="1", minor="2", micro="3")
|
||||
|
@@ -4,7 +4,7 @@
|
||||
"Version": {
|
||||
"Major": "1",
|
||||
"Minor": "2",
|
||||
"Micro": "2"
|
||||
"Micro": "3"
|
||||
},
|
||||
"Author": "",
|
||||
"AuthorEmail": "",
|
||||
|
@@ -10,6 +10,7 @@ from discord import guild
|
||||
from bot_core.abc.message_service_abc import MessageServiceABC
|
||||
from bot_core.configuration.feature_flags_enum import FeatureFlagsEnum
|
||||
from bot_core.configuration.feature_flags_settings import FeatureFlagsSettings
|
||||
from bot_core.logging.event_logger import EventLogger
|
||||
from bot_data.model.server_config import ServerConfig
|
||||
from bot_data.model.technician_config import TechnicianConfig
|
||||
|
||||
@@ -18,7 +19,7 @@ class BootLogOnReadyEvent(OnReadyABC):
|
||||
def __init__(
|
||||
self,
|
||||
config: ConfigurationABC,
|
||||
logger: LoggerABC,
|
||||
logger: EventLogger,
|
||||
bot: DiscordBotServiceABC,
|
||||
message_service: MessageServiceABC,
|
||||
translate: TranslatePipe,
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user