Merge pull request 'staging into master' (#426) from staging into master
All checks were successful
Deploy prod on push / on-push-deploy_sh-edraft (push) Successful in 3m30s

Reviewed-on: #426
Reviewed-by: edraft-dev <dev.sven.heidemann@sh-edraft.de>
This commit is contained in:
Sven Heidemann 2023-11-06 20:06:33 +01:00
commit 5b43b72838
840 changed files with 4651 additions and 1356 deletions

View File

@ -14,6 +14,7 @@ jobs:
uses: actions/setup-python@v3
with:
python-version: "3.10.12"
token: ${{ secrets.CI_GITHUB_ACCESS_TOKEN }}
- run: python -v
- name: Setup docker
@ -22,36 +23,48 @@ jobs:
- name: Clone Repository
uses: https://github.com/actions/checkout@v3
- name: Shutdown stack
run: docker stack rm kdb_staging
with:
token: ${{ secrets.CI_ACCESS_TOKEN }}
submodules: true
- name: Prepare bot build
run: |
cd kdb-bot
cd bot
pip install --extra-index-url https://pip.sh-edraft.de cpl-cli
cpl i
- name: Build docker bot
run: |
cd kdb-bot
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
cd web
npm install -g ts-node
npm i
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 kdb-web
cd web
docker image prune -f
npm run docker-build
cp src/favicon.dev.ico src/favicon.ico
npm run build
docker build -t sh-edraft.de/sdb-web:$(npm run -s gv)-dev .
- 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
- name: Deploy Stack to sh-edraft.de
uses: https://github.com/kgierke/portainer-stack-deployment@v1
@ -60,6 +73,6 @@ jobs:
portainer-username: "gitea_job"
portainer-password: "${{ secrets.docker_job }}"
portainer-endpoint: 2
name: kdb_staging
file: ./docker-compose.staging.yml
name: sdb_dev
file: bot/docker/docker-compose.dev.yml
variables: '{}'

View File

@ -1,5 +1,5 @@
name: Deploy dev on push
run-name: Deploy dev on push
name: Deploy prod on push
run-name: Deploy prod on push
on:
push:
branches:
@ -14,6 +14,7 @@ jobs:
uses: actions/setup-python@v3
with:
python-version: "3.10.12"
token: ${{ secrets.CI_GITHUB_ACCESS_TOKEN }}
- run: python -v
- name: Setup docker
@ -22,36 +23,47 @@ jobs:
- name: Clone Repository
uses: https://github.com/actions/checkout@v3
- name: Shutdown stack
run: docker stack rm kdb_prod
with:
token: ${{ secrets.CI_ACCESS_TOKEN }}
submodules: true
- name: Prepare bot build
run: |
cd kdb-bot
cd bot
pip install --extra-index-url https://pip.sh-edraft.de cpl-cli
cpl i
- name: Build docker bot
run: |
cd kdb-bot
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
cd web
npm install -g ts-node
npm i
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 kdb-web
cd web
docker image prune -f
npm run docker-build
npm run build
docker build -t sh-edraft.de/sdb-web:$(npm run -s gv) .
- 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;)
- name: Deploy Stack to sh-edraft.de
uses: https://github.com/kgierke/portainer-stack-deployment@v1
@ -60,6 +72,6 @@ jobs:
portainer-username: "gitea_job"
portainer-password: "${{ secrets.docker_job }}"
portainer-endpoint: 2
name: kdb_prod
file: ./docker-compose.yml
name: sdb_prod
file: bot/docker/docker-compose.yml
variables: '{}'

View File

@ -0,0 +1,78 @@
name: Deploy staging on push
run-name: Deploy staging on push
on:
push:
branches:
- staging
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"
token: ${{ secrets.CI_GITHUB_ACCESS_TOKEN }}
- 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
with:
token: ${{ secrets.CI_ACCESS_TOKEN }}
submodules: true
- name: Prepare bot build
run: |
cd bot
pip install --extra-index-url https://pip.sh-edraft.de cpl-cli
cpl i
- name: Setup node
uses: https://github.com/actions/setup-node@v3
- name: Prepare web build
run: |
cd web
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 .
- 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
- 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: sdb_staging
file: bot/docker/docker-compose.staging.yml
variables: '{}'

18
.gitmodules vendored
View File

@ -1,9 +1,9 @@
[submodule "kdb-bot/src/bot/config"]
path = kdb-bot/src/bot/config
url = https://git.sh-edraft.de/sh-edraft.de/kd_discord_bot.config.git
[submodule "kdb-bot/src/bot_api/config"]
path = kdb-bot/src/bot_api/config
url = https://git.sh-edraft.de/sh-edraft.de/kd_discord_bot.api.config.git
[submodule "kdb-bot/docker"]
path = kdb-bot/docker
url = https://git.sh-edraft.de/sh-edraft.de/kd_discord_bot.docker.git
[submodule "bot/src/bot/config"]
path = bot/src/bot/config
url = https://git.sh-edraft.de/sh-edraft.de/sh_discord_bot.config.git
[submodule "bot/src/bot_api/config"]
path = bot/src/bot_api/config
url = https://git.sh-edraft.de/sh-edraft.de/sh_discord_bot.api.config.git
[submodule "bot/docker"]
path = bot/docker
url = https://git.sh-edraft.de/sh-edraft.de/sh_discord_bot.docker.git

View File

@ -17,6 +17,7 @@
"permission": "src/modules/permission/permission.json",
"technician": "src/modules/technician/technician.json",
"short-role-name": "src/modules/short_role_name/short-role-name.json",
"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",
@ -31,12 +32,12 @@
"pre-build": "cpl set-version $ARGS; black ./;",
"post-build": "cpl run post-build --dev; black ./;",
"pre-prod": "cpl build",
"prod": "export KDB_ENVIRONMENT=production; export KDB_NAME=KDB-Prod; cpl start;",
"prod": "export SDB_ENVIRONMENT=production; export SDB_NAME=SDB-Prod; cpl start;",
"pre-stage": "cpl build",
"stage": "export KDB_ENVIRONMENT=staging; export KDB_NAME=KDB-Stage; cpl start;",
"stage": "export SDB_ENVIRONMENT=staging; export SDB_NAME=SDB-Stage; cpl start;",
"pre-dev": "cpl build",
"dev": "export KDB_ENVIRONMENT=development; export KDB_NAME=KDB-Dev; cpl start;",
"docker-build": "cpl build $ARGS; docker build -t sh-edraft.de/kdb-bot:$(cpl gv) .;",
"dev": "export SDB_ENVIRONMENT=development; export SDB_NAME=SDB-Dev; cpl start;",
"docker-build": "cpl build $ARGS; docker build -t sh-edraft.de/sdb-bot:$(cpl gv) .;",
"dc-up": "docker-compose up -d",
"dc-down": "docker-compose down",
"docker": "cpl dc-down; cpl docker-build; cpl dc-up;"

1
bot/docker Submodule

@ -0,0 +1 @@
Subproject commit 8063944d871d88a1400e45d3fdac29ee69485eb5

View File

@ -2,7 +2,7 @@
FROM python:3.10.4-alpine
WORKDIR /app
COPY ./dist/bot/build/kdb-bot/ .
COPY ./dist/bot/build/bot/ .
COPY ./dist/bot/build/requirements.txt .
RUN python -m pip install --upgrade pip

View File

@ -15,7 +15,7 @@ __title__ = "bot"
__author__ = "Sven Heidemann"
__license__ = "MIT"
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
__version__ = "1.1.10"
__version__ = "1.2.0"
from collections import namedtuple
@ -23,4 +23,4 @@ from collections import namedtuple
# imports:
VersionInfo = namedtuple("VersionInfo", "major minor micro")
version_info = VersionInfo(major="1", minor="1", micro="10")
version_info = VersionInfo(major="1", minor="2", micro="0")

View File

@ -8,8 +8,10 @@ from cpl_discord.service import DiscordBotServiceABC, DiscordBotService
from cpl_translation import TranslatePipe, TranslationServiceABC, TranslationSettings
from bot_api.api_thread import ApiThread
from bot_core.abc.task_abc import TaskABC
from bot_core.configuration.feature_flags_enum import FeatureFlagsEnum
from bot_core.configuration.feature_flags_settings import FeatureFlagsSettings
from bot_core.environment_variables import MAINTENANCE
from bot_core.service.data_integrity_service import DataIntegrityService
@ -29,6 +31,8 @@ class Application(DiscordBotApplicationABC):
# cpl-translation
self._translation: TranslationServiceABC = services.get_service(TranslationServiceABC)
self._t: TranslatePipe = services.get_service(TranslatePipe)
# internal stuff
self._tasks = services.get_services(TaskABC)
self._feature_flags: FeatureFlagsSettings = config.get_configuration(FeatureFlagsSettings)
@ -55,6 +59,10 @@ class Application(DiscordBotApplicationABC):
return
self._logger.info(__name__, f"Try to start {DiscordBotService.__name__}")
if not self._config.get_configuration(MAINTENANCE):
for task in self._tasks:
await self._bot.add_cog(task)
await self._bot.start_async()
await self._bot.stop_async()
except Exception as e:

View File

@ -3,8 +3,8 @@
"Name": "bot",
"Version": {
"Major": "1",
"Minor": "1",
"Micro": "10"
"Minor": "2",
"Micro": "0"
},
"Author": "Sven Heidemann",
"AuthorEmail": "sven.heidemann@sh-edraft.de",
@ -16,22 +16,24 @@
"LicenseName": "MIT",
"LicenseDescription": "MIT, see LICENSE for more details.",
"Dependencies": [
"cpl-core==2023.4.0.post5",
"cpl-core==2023.10.0",
"cpl-translation==2023.4.0.post1",
"cpl-query==2023.4.0.post1",
"cpl-discord==2023.4.0.post3",
"Flask==2.3.2",
"Flask-Classful==0.14.2",
"cpl-query==2023.10.0",
"cpl-discord==2023.10.0.post1",
"Flask==3.0.0",
"Flask-Classful==0.16.0",
"Flask-Cors==4.0.0",
"PyJWT==2.8.0",
"waitress==2.1.2",
"Flask-SocketIO==5.3.4",
"Flask-SocketIO==5.3.6",
"eventlet==0.33.3",
"requests-oauthlib==1.3.1",
"icmplib==3.0.3",
"icmplib==3.0.4",
"ariadne==0.20.1",
"cryptography==41.0.2",
"discord>=2.3.2"
"cryptography==41.0.4",
"discord==2.3.2",
"bs4==0.0.1",
"lxml==4.9.3"
],
"DevDependencies": [
"cpl-cli==2023.4.0.post3",
@ -69,6 +71,7 @@
"../modules/level/level.json",
"../modules/permission/permission.json",
"../modules/short_role_name/short-role-name.json",
"../modules/special_offers/special-offers.json",
"../modules/technician/technician.json"
]
}

1
bot/src/bot/config Submodule

@ -0,0 +1 @@
Subproject commit c11ca6f2e8e54bacdf16da677fbcf03705ff9780

View File

@ -15,7 +15,7 @@ __title__ = "bot.extension"
__author__ = "Sven Heidemann"
__license__ = "MIT"
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
__version__ = "1.1.10"
__version__ = "1.2.0"
from collections import namedtuple
@ -23,4 +23,4 @@ from collections import namedtuple
# imports:
VersionInfo = namedtuple("VersionInfo", "major minor micro")
version_info = VersionInfo(major="1", minor="1", micro="10")
version_info = VersionInfo(major="1", minor="2", micro="0")

View File

@ -9,7 +9,7 @@ from bot.application import Application
from bot.extension.init_bot_extension import InitBotExtension
from bot.startup import Startup
from bot.startup_discord_extension import StartupDiscordExtension
from bot.startup_migration_extension import StartupMigrationExtension
from bot_data.startup_migration_extension import StartupMigrationExtension
from bot.startup_module_extension import StartupModuleExtension
from bot.startup_settings_extension import StartupSettingsExtension
from bot_api.app_api_extension import AppApiExtension

View File

@ -14,6 +14,7 @@ from modules.database.database_module import DatabaseModule
from modules.level.level_module import LevelModule
from modules.permission.permission_module import PermissionModule
from modules.short_role_name.short_role_name_module import ShortRoleNameModule
from modules.special_offers.special_offers_module import SteamSpecialOffersModule
from modules.technician.technician_module import TechnicianModule
@ -37,6 +38,7 @@ class ModuleList:
TechnicianModule,
AchievementsModule,
ShortRoleNameModule,
SteamSpecialOffersModule,
# has to be last!
BootLogModule,
CoreExtensionModule,

View File

@ -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)

View File

@ -8,6 +8,7 @@ from cpl_core.dependency_injection import ServiceCollectionABC
from cpl_core.environment import ApplicationEnvironmentABC
from bot_core.configuration.bot_logging_settings import BotLoggingSettings
from bot_core.environment_variables import MAINTENANCE, MIGRATION_ONLY
class StartupSettingsExtension(StartupExtensionABC):
@ -17,8 +18,14 @@ class StartupSettingsExtension(StartupExtensionABC):
def configure_configuration(self, configuration: ConfigurationABC, environment: ApplicationEnvironmentABC):
# this shit has to be done here because we need settings in subsequent startup extensions
environment.set_working_directory(os.path.dirname(os.path.realpath(__file__)))
configuration.add_environment_variables("KDB_")
configuration.add_environment_variables("SDB_")
configuration.add_environment_variables("DISCORD_")
configuration.add_configuration(
MAINTENANCE, configuration.get_configuration(MAINTENANCE) in [True, "true", "True"]
)
configuration.add_configuration(
MIGRATION_ONLY, configuration.get_configuration(MIGRATION_ONLY) in [True, "true", "True"]
)
configuration.add_json_file(f"config/appsettings.json", optional=False)
configuration.add_json_file(f"config/appsettings.{environment.environment_name}.json", optional=True)

View File

@ -90,10 +90,16 @@
"booting": "Ich fahre gerade hoch...",
"restart": "Muss neue Kekse holen...",
"running": "Ich esse Kekse :D",
"shutdown": "Ich werde bestimmt wieder kommen..."
"shutdown": "Ich werde bestimmt wieder kommen...",
"maintenance": "In Wartung!"
}
},
"modules": {
"special_offers": {
"price": "Preis",
"discount": "Rabatt",
"discount_price": "Neuer Preis"
},
"achievements": {
"commands": {
"check": "Alles klar, ich schaue eben nach... nom nom"
@ -229,6 +235,11 @@
"success": "Verlinkung wurde entfernt :D"
},
"user": {
"birthday": {
"has_birthday": "Alles Gute zum Geburtag {} :D",
"success": "Dein Geburtstag wurde eingetragen.",
"success_team": "{} hat seinen Geburtstag eingetragen: {}"
},
"add": {
"xp": "Die {} von {} wurden um {} erhöht"
},

View File

@ -15,7 +15,7 @@ __title__ = "bot_api"
__author__ = "Sven Heidemann"
__license__ = "MIT"
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
__version__ = "1.1.10"
__version__ = "1.2.0"
from collections import namedtuple
@ -23,4 +23,4 @@ from collections import namedtuple
# imports:
VersionInfo = namedtuple("VersionInfo", "major minor micro")
version_info = VersionInfo(major="1", minor="1", micro="10")
version_info = VersionInfo(major="1", minor="2", micro="0")

View File

@ -15,7 +15,7 @@ __title__ = "bot_api.abc"
__author__ = "Sven Heidemann"
__license__ = "MIT"
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
__version__ = "1.1.10"
__version__ = "1.2.0"
from collections import namedtuple
@ -23,4 +23,4 @@ from collections import namedtuple
# imports:
VersionInfo = namedtuple("VersionInfo", "major minor micro")
version_info = VersionInfo(major="1", minor="1", micro="10")
version_info = VersionInfo(major="1", minor="2", micro="0")

View File

@ -149,7 +149,10 @@ class Api(Flask):
return response
def start(self):
self._logger.info(__name__, f"Starting API {self._api_settings.host}:{self._api_settings.port}")
self._logger.info(
__name__,
f"Starting API {self._api_settings.host}:{self._api_settings.port}",
)
self._register_routes()
self.secret_key = CredentialManager.decrypt(self._auth_settings.secret_key)
# from waitress import serve

View File

@ -48,4 +48,4 @@ class ApiModule(ModuleABC):
services.add_transient(GraphQLController)
# cpl-discord
self._dc.add_event(DiscordEventTypesEnum.on_ready.value, BotApiOnReadyEvent)
services.add_transient(DiscordEventTypesEnum.on_ready.value, BotApiOnReadyEvent)

View File

@ -3,8 +3,8 @@
"Name": "bot-api",
"Version": {
"Major": "1",
"Minor": "1",
"Micro": "10"
"Minor": "2",
"Micro": "0"
},
"Author": "",
"AuthorEmail": "",

@ -0,0 +1 @@
Subproject commit 521951b8abb0f784b59b6d3e0210606fa193e60a

View File

@ -15,7 +15,7 @@ __title__ = "bot_api.configuration"
__author__ = "Sven Heidemann"
__license__ = "MIT"
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
__version__ = "1.1.10"
__version__ = "1.2.0"
from collections import namedtuple
@ -23,4 +23,4 @@ from collections import namedtuple
# imports
VersionInfo = namedtuple("VersionInfo", "major minor micro")
version_info = VersionInfo(major="1", minor="1", micro="10")
version_info = VersionInfo(major="1", minor="2", micro="0")

View File

@ -15,7 +15,7 @@ __title__ = "bot_api.controller"
__author__ = "Sven Heidemann"
__license__ = "MIT"
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
__version__ = "1.1.10"
__version__ = "1.2.0"
from collections import namedtuple
@ -23,4 +23,4 @@ from collections import namedtuple
# imports:
VersionInfo = namedtuple("VersionInfo", "major minor micro")
version_info = VersionInfo(major="1", minor="1", micro="10")
version_info = VersionInfo(major="1", minor="2", micro="0")

View File

@ -15,7 +15,7 @@ __title__ = "bot_api.event"
__author__ = "Sven Heidemann"
__license__ = "MIT"
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
__version__ = "1.1.10"
__version__ = "1.2.0"
from collections import namedtuple
@ -23,4 +23,4 @@ from collections import namedtuple
# imports:
VersionInfo = namedtuple("VersionInfo", "major minor micro")
version_info = VersionInfo(major="1", minor="1", micro="10")
version_info = VersionInfo(major="1", minor="2", micro="0")

View File

@ -15,7 +15,7 @@ __title__ = "bot_api.exception"
__author__ = "Sven Heidemann"
__license__ = "MIT"
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
__version__ = "1.1.10"
__version__ = "1.2.0"
from collections import namedtuple
@ -23,4 +23,4 @@ from collections import namedtuple
# imports:
VersionInfo = namedtuple("VersionInfo", "major minor micro")
version_info = VersionInfo(major="1", minor="1", micro="10")
version_info = VersionInfo(major="1", minor="2", micro="0")

View File

@ -15,7 +15,7 @@ __title__ = "bot_api.filter"
__author__ = "Sven Heidemann"
__license__ = "MIT"
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
__version__ = "1.1.10"
__version__ = "1.2.0"
from collections import namedtuple
@ -23,4 +23,4 @@ from collections import namedtuple
# imports:
VersionInfo = namedtuple("VersionInfo", "major minor micro")
version_info = VersionInfo(major="1", minor="1", micro="10")
version_info = VersionInfo(major="1", minor="2", micro="0")

View File

@ -15,7 +15,7 @@ __title__ = "bot_api.filter.discord"
__author__ = "Sven Heidemann"
__license__ = "MIT"
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
__version__ = "1.1.10"
__version__ = "1.2.0"
from collections import namedtuple
@ -23,4 +23,4 @@ from collections import namedtuple
# imports:
VersionInfo = namedtuple("VersionInfo", "major minor micro")
version_info = VersionInfo(major="1", minor="1", micro="10")
version_info = VersionInfo(major="1", minor="2", micro="0")

View File

@ -15,7 +15,7 @@ __title__ = "bot_api.logging"
__author__ = "Sven Heidemann"
__license__ = "MIT"
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
__version__ = "1.1.10"
__version__ = "1.2.0"
from collections import namedtuple
@ -23,4 +23,4 @@ from collections import namedtuple
# imports:
VersionInfo = namedtuple("VersionInfo", "major minor micro")
version_info = VersionInfo(major="1", minor="1", micro="10")
version_info = VersionInfo(major="1", minor="2", micro="0")

View File

@ -15,7 +15,7 @@ __title__ = "bot_api.model"
__author__ = "Sven Heidemann"
__license__ = "MIT"
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
__version__ = "1.1.10"
__version__ = "1.2.0"
from collections import namedtuple
@ -23,4 +23,4 @@ from collections import namedtuple
# imports:
VersionInfo = namedtuple("VersionInfo", "major minor micro")
version_info = VersionInfo(major="1", minor="1", micro="10")
version_info = VersionInfo(major="1", minor="2", micro="0")

View File

@ -15,7 +15,7 @@ __title__ = "bot_api.model.discord"
__author__ = "Sven Heidemann"
__license__ = "MIT"
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
__version__ = "1.1.10"
__version__ = "1.2.0"
from collections import namedtuple
@ -23,4 +23,4 @@ from collections import namedtuple
# imports:
VersionInfo = namedtuple("VersionInfo", "major minor micro")
version_info = VersionInfo(major="1", minor="1", micro="10")
version_info = VersionInfo(major="1", minor="2", micro="0")

View File

@ -27,4 +27,8 @@ class TokenDTO(DtoABC):
self._first_login = values["firstLogin"]
def to_dict(self) -> dict:
return {"token": self._token, "refreshToken": self._refresh_token, "firstLogin": self._first_login}
return {
"token": self._token,
"refreshToken": self._refresh_token,
"firstLogin": self._first_login,
}

View File

@ -15,7 +15,7 @@ __title__ = "bot_api.route"
__author__ = "Sven Heidemann"
__license__ = "MIT"
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
__version__ = "1.1.10"
__version__ = "1.2.0"
from collections import namedtuple
@ -23,4 +23,4 @@ from collections import namedtuple
# imports:
VersionInfo = namedtuple("VersionInfo", "major minor micro")
version_info = VersionInfo(major="1", minor="1", micro="10")
version_info = VersionInfo(major="1", minor="2", micro="0")

View File

@ -25,7 +25,12 @@ class Route:
@classmethod
@ServiceProviderABC.inject
def init_authorize(cls, env: ApplicationEnvironmentABC, auth_users: AuthUserRepositoryABC, auth: AuthServiceABC):
def init_authorize(
cls,
env: ApplicationEnvironmentABC,
auth_users: AuthUserRepositoryABC,
auth: AuthServiceABC,
):
cls._auth_users = auth_users
cls._auth = auth
cls._env = env.environment_name
@ -52,7 +57,13 @@ class Route:
return user
@classmethod
def authorize(cls, f: Callable = None, role: AuthRoleEnum = None, skip_in_dev=False, by_api_key=False):
def authorize(
cls,
f: Callable = None,
role: AuthRoleEnum = None,
skip_in_dev=False,
by_api_key=False,
):
if f is None:
return functools.partial(cls.authorize, role=role, skip_in_dev=skip_in_dev, by_api_key=by_api_key)

View File

@ -15,7 +15,7 @@ __title__ = "bot_api.service"
__author__ = "Sven Heidemann"
__license__ = "MIT"
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
__version__ = "1.1.10"
__version__ = "1.2.0"
from collections import namedtuple
@ -23,4 +23,4 @@ from collections import namedtuple
# imports
VersionInfo = namedtuple("VersionInfo", "major minor micro")
version_info = VersionInfo(major="1", minor="1", micro="10")
version_info = VersionInfo(major="1", minor="2", micro="0")

View File

@ -15,7 +15,7 @@ __title__ = "bot_api.transformer"
__author__ = "Sven Heidemann"
__license__ = "MIT"
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
__version__ = "1.1.10"
__version__ = "1.2.0"
from collections import namedtuple
@ -23,4 +23,4 @@ from collections import namedtuple
# imports:
VersionInfo = namedtuple("VersionInfo", "major minor micro")
version_info = VersionInfo(major="1", minor="1", micro="10")
version_info = VersionInfo(major="1", minor="2", micro="0")

View File

@ -15,7 +15,7 @@ __title__ = "bot_core"
__author__ = "Sven Heidemann"
__license__ = "MIT"
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
__version__ = "1.1.10"
__version__ = "1.2.0"
from collections import namedtuple
@ -23,4 +23,4 @@ from collections import namedtuple
# imports
VersionInfo = namedtuple("VersionInfo", "major minor micro")
version_info = VersionInfo(major="1", minor="1", micro="10")
version_info = VersionInfo(major="1", minor="2", micro="0")

View File

@ -15,7 +15,7 @@ __title__ = "bot_core.abc"
__author__ = "Sven Heidemann"
__license__ = "MIT"
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
__version__ = "1.1.10"
__version__ = "1.2.0"
from collections import namedtuple
@ -23,4 +23,4 @@ from collections import namedtuple
# imports:
VersionInfo = namedtuple("VersionInfo", "major minor micro")
version_info = VersionInfo(major="1", minor="1", micro="10")
version_info = VersionInfo(major="1", minor="2", micro="0")

View File

@ -64,10 +64,18 @@ class ClientUtilsABC(ABC):
@abstractmethod
async def react_to_message_by_auto_role_rule(
self, discord_channel_id: int, discord_message_id: int, rule: AutoRoleRule, guild: discord.Guild
self,
discord_channel_id: int,
discord_message_id: int,
rule: AutoRoleRule,
guild: discord.Guild,
):
pass
@abstractmethod
async def check_default_role(self, member: Union[discord.User, discord.Member]):
pass
@abstractmethod
async def set_maintenance_mode(self, state: bool):
pass

View File

@ -0,0 +1,33 @@
import asyncio
from abc import abstractmethod
from cpl_core.configuration import ConfigurationABC
from cpl_core.dependency_injection import ServiceProviderABC
from cpl_discord.service import DiscordBotServiceABC
from discord.ext import commands
from bot_core.environment_variables import MAINTENANCE
from bot_core.logging.task_logger import TaskLogger
class TaskABC(commands.Cog):
@abstractmethod
def __init__(self):
commands.Cog.__init__(self)
@ServiceProviderABC.inject
def _is_maintenance(self, config: ConfigurationABC) -> bool:
return config.get_configuration(MAINTENANCE) is True
@ServiceProviderABC.inject
async def _wait_until_ready(self, config: ConfigurationABC, logger: TaskLogger, bot: DiscordBotServiceABC):
logger.debug(__name__, f"Waiting before {type(self).__name__}")
await bot.wait_until_ready()
async def wait():
is_ready = config.get_configuration("IS_READY") is True
if not is_ready:
await asyncio.sleep(1)
await wait()
await wait()

View File

@ -3,8 +3,8 @@
"Name": "bot-core",
"Version": {
"Major": "1",
"Minor": "1",
"Micro": "10"
"Minor": "2",
"Micro": "0"
},
"Author": "Sven Heidemann",
"AuthorEmail": "sven.heidemann@sh-edraft.de",

View File

@ -15,7 +15,7 @@ __title__ = "bot_core.configuration"
__author__ = "Sven Heidemann"
__license__ = "MIT"
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
__version__ = "1.1.10"
__version__ = "1.2.0"
from collections import namedtuple
@ -23,4 +23,4 @@ from collections import namedtuple
# imports:
VersionInfo = namedtuple("VersionInfo", "major minor micro")
version_info = VersionInfo(major="1", minor="1", micro="10")
version_info = VersionInfo(major="1", minor="2", micro="0")

View File

@ -17,6 +17,7 @@ class FeatureFlagsEnum(Enum):
moderator_module = "ModeratorModule"
permission_module = "PermissionModule"
short_role_name_module = "ShortRoleNameModule"
steam_special_offers_module = "SteamSpecialOffersModule"
# features
api_only = "ApiOnly"
presence = "Presence"
@ -25,3 +26,4 @@ class FeatureFlagsEnum(Enum):
sync_xp = "SyncXp"
short_role_name = "ShortRoleName"
technician_full_access = "TechnicianFullAccess"
steam_special_offers = "SteamSpecialOffers"

View File

@ -19,6 +19,7 @@ class FeatureFlagsSettings(ConfigurationModelABC):
FeatureFlagsEnum.permission_module.value: True, # 02.10.2022 #48
FeatureFlagsEnum.config_module.value: True, # 19.07.2023 #127
FeatureFlagsEnum.short_role_name_module.value: True, # 28.09.2023 #378
FeatureFlagsEnum.steam_special_offers_module.value: True, # 11.10.2023 #188
# features
FeatureFlagsEnum.api_only.value: False, # 13.10.2022 #70
FeatureFlagsEnum.presence.value: True, # 03.10.2022 #56
@ -27,6 +28,7 @@ class FeatureFlagsSettings(ConfigurationModelABC):
FeatureFlagsEnum.sync_xp.value: False, # 25.09.2023 #366
FeatureFlagsEnum.short_role_name.value: False, # 28.09.2023 #378
FeatureFlagsEnum.technician_full_access.value: False, # 03.10.2023 #393
FeatureFlagsEnum.steam_special_offers.value: False, # 11.10.2023 #188
}
def __init__(self, **kwargs: dict):

View File

@ -15,7 +15,7 @@ __title__ = "bot_core.core_extension"
__author__ = "Sven Heidemann"
__license__ = "MIT"
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
__version__ = "1.1.10"
__version__ = "1.2.0"
from collections import namedtuple
@ -23,4 +23,4 @@ from collections import namedtuple
# imports:
VersionInfo = namedtuple("VersionInfo", "major minor micro")
version_info = VersionInfo(major="1", minor="1", micro="10")
version_info = VersionInfo(major="1", minor="2", micro="0")

View File

@ -19,4 +19,4 @@ class CoreExtensionModule(ModuleABC):
pass
def configure_services(self, services: ServiceCollectionABC, env: ApplicationEnvironmentABC):
self._dc.add_event(DiscordEventTypesEnum.on_ready.value, CoreExtensionOnReadyEvent)
services.add_transient(DiscordEventTypesEnum.on_ready.value, CoreExtensionOnReadyEvent)

Some files were not shown because too many files have changed in this diff Show More