Compare commits
7 Commits
e6667c78c8
...
af9c55e4b1
Author | SHA1 | Date | |
---|---|---|---|
af9c55e4b1 | |||
e3172d6f24 | |||
0706579f62 | |||
ad3fc94923 | |||
69882af0bd | |||
b0fb12f841 | |||
4d980331e2 |
@ -6,9 +6,17 @@ on:
|
|||||||
- dev
|
- dev
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
on-push-deploy_sh-edraft:
|
pre-build:
|
||||||
runs-on: [ dobby.sh-edraft.de, ubuntu-latest ]
|
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:
|
steps:
|
||||||
- name: Setup docker
|
- name: Setup docker
|
||||||
uses: https://github.com/papodaca/install-docker-action@main
|
uses: https://github.com/papodaca/install-docker-action@main
|
||||||
@ -20,12 +28,56 @@ jobs:
|
|||||||
token: ${{ secrets.CI_ACCESS_TOKEN }}
|
token: ${{ secrets.CI_ACCESS_TOKEN }}
|
||||||
submodules: true
|
submodules: true
|
||||||
|
|
||||||
|
- 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: Prepare bot build
|
- name: Prepare bot build
|
||||||
run: |
|
run: |
|
||||||
cd bot
|
cd bot
|
||||||
python3.10 -m pip install --extra-index-url https://pip.sh-edraft.de cpl-cli
|
python3.10 -m pip install --extra-index-url https://pip.sh-edraft.de cpl-cli
|
||||||
cpl i
|
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: 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: 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: Setup node
|
- name: Setup node
|
||||||
uses: https://github.com/actions/setup-node@v3
|
uses: https://github.com/actions/setup-node@v3
|
||||||
|
|
||||||
@ -35,30 +87,29 @@ jobs:
|
|||||||
npm install -g ts-node
|
npm install -g ts-node
|
||||||
npm ci
|
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
|
- name: Build docker web
|
||||||
run: |
|
run: |
|
||||||
cd web
|
cd web
|
||||||
docker image prune -f
|
docker image prune -f
|
||||||
cp src/favicon.dev.ico src/favicon.ico
|
cp src/favicon.dev.ico src/favicon.ico
|
||||||
npm run build
|
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: Set version
|
- name: Login to registry git.sh-edraft.de
|
||||||
run: |
|
uses: https://github.com/docker/login-action@v1
|
||||||
cd bot/docker
|
with:
|
||||||
chmod +x ./set-docker-compose-image-version.sh
|
registry: git.sh-edraft.de
|
||||||
./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
|
username: ${{ secrets.CI_USERNAME }}
|
||||||
|
password: ${{ secrets.CI_ACCESS_TOKEN }}
|
||||||
|
|
||||||
|
- name: Push image
|
||||||
|
run: docker build -t 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: Deploy Stack to sh-edraft.de
|
- name: Deploy Stack to sh-edraft.de
|
||||||
uses: https://github.com/kgierke/portainer-stack-deployment@v1
|
uses: https://github.com/kgierke/portainer-stack-deployment@v1
|
||||||
with:
|
with:
|
||||||
|
@ -1 +1 @@
|
|||||||
Subproject commit b0bacce9f6cd20833560c4889289ac4320f643b6
|
Subproject commit abd17085309242a2aa0b415a9a14d5390163dfc2
|
@ -16,7 +16,7 @@
|
|||||||
"LicenseName": "MIT",
|
"LicenseName": "MIT",
|
||||||
"LicenseDescription": "MIT, see LICENSE for more details.",
|
"LicenseDescription": "MIT, see LICENSE for more details.",
|
||||||
"Dependencies": [
|
"Dependencies": [
|
||||||
"cpl-core==2023.10.0",
|
"cpl-core==2023.10.1",
|
||||||
"cpl-translation==2023.4.0.post1",
|
"cpl-translation==2023.4.0.post1",
|
||||||
"cpl-query==2023.10.0",
|
"cpl-query==2023.10.0",
|
||||||
"cpl-discord==2023.10.0.post1",
|
"cpl-discord==2023.10.0.post1",
|
||||||
|
@ -1 +1 @@
|
|||||||
Subproject commit c11ca6f2e8e54bacdf16da677fbcf03705ff9780
|
Subproject commit be5b15f227e7b2b12cc73c0edd7f6fa95dbdd52f
|
@ -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.configuration.feature_flags_settings import FeatureFlagsSettings
|
||||||
from bot_core.logging.command_logger import CommandLogger
|
from bot_core.logging.command_logger import CommandLogger
|
||||||
from bot_core.logging.database_logger import DatabaseLogger
|
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.message_logger import MessageLogger
|
||||||
from bot_core.logging.task_logger import TaskLogger
|
from bot_core.logging.task_logger import TaskLogger
|
||||||
from bot_data.db_context import DBContext
|
from bot_data.db_context import DBContext
|
||||||
@ -45,6 +46,7 @@ class Startup(StartupABC):
|
|||||||
services.add_singleton(CustomFileLoggerABC, DatabaseLogger)
|
services.add_singleton(CustomFileLoggerABC, DatabaseLogger)
|
||||||
services.add_singleton(CustomFileLoggerABC, MessageLogger)
|
services.add_singleton(CustomFileLoggerABC, MessageLogger)
|
||||||
services.add_singleton(CustomFileLoggerABC, TaskLogger)
|
services.add_singleton(CustomFileLoggerABC, TaskLogger)
|
||||||
|
services.add_singleton(CustomFileLoggerABC, EventLogger)
|
||||||
|
|
||||||
if self._feature_flags.get_flag(FeatureFlagsEnum.api_module):
|
if self._feature_flags.get_flag(FeatureFlagsEnum.api_module):
|
||||||
services.add_singleton(CustomFileLoggerABC, ApiLogger)
|
services.add_singleton(CustomFileLoggerABC, ApiLogger)
|
||||||
|
@ -1,20 +1,18 @@
|
|||||||
import asyncio
|
|
||||||
|
|
||||||
from cpl_core.configuration import ConfigurationABC
|
from cpl_core.configuration import ConfigurationABC
|
||||||
from cpl_core.logging import LoggerABC
|
|
||||||
from cpl_discord.events import OnReadyABC
|
from cpl_discord.events import OnReadyABC
|
||||||
from cpl_discord.service import DiscordBotServiceABC
|
from cpl_discord.service import DiscordBotServiceABC
|
||||||
from cpl_translation import TranslatePipe
|
from cpl_translation import TranslatePipe
|
||||||
|
|
||||||
from bot_core.abc.client_utils_abc import ClientUtilsABC
|
from bot_core.abc.client_utils_abc import ClientUtilsABC
|
||||||
from bot_core.environment_variables import MAINTENANCE
|
from bot_core.environment_variables import MAINTENANCE
|
||||||
|
from bot_core.logging.event_logger import EventLogger
|
||||||
|
|
||||||
|
|
||||||
class CoreExtensionOnReadyEvent(OnReadyABC):
|
class CoreExtensionOnReadyEvent(OnReadyABC):
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
config: ConfigurationABC,
|
config: ConfigurationABC,
|
||||||
logger: LoggerABC,
|
logger: EventLogger,
|
||||||
bot: DiscordBotServiceABC,
|
bot: DiscordBotServiceABC,
|
||||||
client_utils: ClientUtilsABC,
|
client_utils: ClientUtilsABC,
|
||||||
t: TranslatePipe,
|
t: TranslatePipe,
|
||||||
|
@ -1,15 +1,15 @@
|
|||||||
from cpl_core.logging import LoggerABC
|
|
||||||
from cpl_discord.events import OnReadyABC
|
from cpl_discord.events import OnReadyABC
|
||||||
from cpl_discord.service import DiscordBotServiceABC
|
from cpl_discord.service import DiscordBotServiceABC
|
||||||
from cpl_translation import TranslatePipe
|
from cpl_translation import TranslatePipe
|
||||||
|
|
||||||
from bot_core.abc.client_utils_abc import ClientUtilsABC
|
from bot_core.abc.client_utils_abc import ClientUtilsABC
|
||||||
|
from bot_core.logging.event_logger import EventLogger
|
||||||
|
|
||||||
|
|
||||||
class CoreOnReadyEvent(OnReadyABC):
|
class CoreOnReadyEvent(OnReadyABC):
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
logger: LoggerABC,
|
logger: EventLogger,
|
||||||
bot: DiscordBotServiceABC,
|
bot: DiscordBotServiceABC,
|
||||||
client_utils: ClientUtilsABC,
|
client_utils: ClientUtilsABC,
|
||||||
t: TranslatePipe,
|
t: TranslatePipe,
|
||||||
|
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)
|
@ -1,7 +1,6 @@
|
|||||||
import datetime
|
import datetime
|
||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
from cpl_core.logging import LoggerABC
|
|
||||||
from cpl_core.time import TimeFormatSettings
|
from cpl_core.time import TimeFormatSettings
|
||||||
from cpl_discord.events.on_command_error_abc import OnCommandErrorABC
|
from cpl_discord.events.on_command_error_abc import OnCommandErrorABC
|
||||||
from cpl_discord.service import DiscordBotServiceABC
|
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.abc.message_service_abc import MessageServiceABC
|
||||||
from bot_core.exception.check_error import CheckError
|
from bot_core.exception.check_error import CheckError
|
||||||
from bot_core.helper.event_checks import EventChecks
|
from bot_core.helper.event_checks import EventChecks
|
||||||
|
from bot_core.logging.event_logger import EventLogger
|
||||||
from bot_data.model.technician_config import TechnicianConfig
|
from bot_data.model.technician_config import TechnicianConfig
|
||||||
|
|
||||||
|
|
||||||
class BaseOnCommandErrorEvent(OnCommandErrorABC):
|
class BaseOnCommandErrorEvent(OnCommandErrorABC):
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
logger: LoggerABC,
|
logger: EventLogger,
|
||||||
bot: DiscordBotServiceABC,
|
bot: DiscordBotServiceABC,
|
||||||
messenger: MessageServiceABC,
|
messenger: MessageServiceABC,
|
||||||
tech_settings: TechnicianConfig,
|
tech_settings: TechnicianConfig,
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
from cpl_core.database.context import DatabaseContextABC
|
from cpl_core.database.context import DatabaseContextABC
|
||||||
from cpl_core.logging import LoggerABC
|
|
||||||
from cpl_discord.events import OnGuildJoinABC
|
from cpl_discord.events import OnGuildJoinABC
|
||||||
from cpl_discord.service import DiscordBotServiceABC
|
from cpl_discord.service import DiscordBotServiceABC
|
||||||
from discord import Guild
|
from discord import Guild
|
||||||
|
|
||||||
from bot_core.helper.event_checks import EventChecks
|
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_config_repository_abc import ServerConfigRepositoryABC
|
||||||
from bot_data.abc.server_repository_abc import ServerRepositoryABC
|
from bot_data.abc.server_repository_abc import ServerRepositoryABC
|
||||||
from bot_data.model.server import Server
|
from bot_data.model.server import Server
|
||||||
@ -14,7 +14,7 @@ from bot_data.service.seeder_service import SeederService
|
|||||||
class BaseOnGuildJoinEvent(OnGuildJoinABC):
|
class BaseOnGuildJoinEvent(OnGuildJoinABC):
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
logger: LoggerABC,
|
logger: EventLogger,
|
||||||
bot: DiscordBotServiceABC,
|
bot: DiscordBotServiceABC,
|
||||||
servers: ServerRepositoryABC,
|
servers: ServerRepositoryABC,
|
||||||
server_config: ServerConfigRepositoryABC,
|
server_config: ServerConfigRepositoryABC,
|
||||||
|
@ -4,14 +4,15 @@ from typing import Union
|
|||||||
import discord
|
import discord
|
||||||
from cpl_core.configuration import ConfigurationABC
|
from cpl_core.configuration import ConfigurationABC
|
||||||
from cpl_core.database.context import DatabaseContextABC
|
from cpl_core.database.context import DatabaseContextABC
|
||||||
from cpl_core.logging import LoggerABC
|
|
||||||
from cpl_discord.events import OnMemberJoinABC
|
from cpl_discord.events import OnMemberJoinABC
|
||||||
from cpl_discord.service import DiscordBotServiceABC
|
from cpl_discord.service import DiscordBotServiceABC
|
||||||
from cpl_translation import TranslatePipe
|
from cpl_translation import TranslatePipe
|
||||||
|
|
||||||
from bot_core.abc.client_utils_abc import ClientUtilsABC
|
from bot_core.abc.client_utils_abc import ClientUtilsABC
|
||||||
from bot_core.abc.message_service_abc import MessageServiceABC
|
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.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.known_user_repository_abc import KnownUserRepositoryABC
|
||||||
from bot_data.abc.server_repository_abc import ServerRepositoryABC
|
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_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.server_config import ServerConfig
|
||||||
from bot_data.model.user import User
|
from bot_data.model.user import User
|
||||||
from bot_data.model.user_joined_server import UserJoinedServer
|
from bot_data.model.user_joined_server import UserJoinedServer
|
||||||
from bot_core.abc.permission_service_abc import PermissionServiceABC
|
|
||||||
|
|
||||||
|
|
||||||
class BaseOnMemberJoinEvent(OnMemberJoinABC):
|
class BaseOnMemberJoinEvent(OnMemberJoinABC):
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
config: ConfigurationABC,
|
config: ConfigurationABC,
|
||||||
logger: LoggerABC,
|
logger: EventLogger,
|
||||||
messenger: MessageServiceABC,
|
messenger: MessageServiceABC,
|
||||||
permissions: PermissionServiceABC,
|
permissions: PermissionServiceABC,
|
||||||
db: DatabaseContextABC,
|
db: DatabaseContextABC,
|
||||||
|
@ -4,12 +4,12 @@ from typing import Union
|
|||||||
import discord
|
import discord
|
||||||
from cpl_core.configuration import ConfigurationABC
|
from cpl_core.configuration import ConfigurationABC
|
||||||
from cpl_core.database.context import DatabaseContextABC
|
from cpl_core.database.context import DatabaseContextABC
|
||||||
from cpl_core.logging import LoggerABC
|
|
||||||
from cpl_discord.events import OnMemberRemoveABC
|
from cpl_discord.events import OnMemberRemoveABC
|
||||||
from cpl_translation import TranslatePipe
|
from cpl_translation import TranslatePipe
|
||||||
|
|
||||||
from bot_core.abc.message_service_abc import MessageServiceABC
|
from bot_core.abc.message_service_abc import MessageServiceABC
|
||||||
from bot_core.helper.event_checks import EventChecks
|
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.server_repository_abc import ServerRepositoryABC
|
||||||
from bot_data.abc.user_joined_server_repository_abc import UserJoinedServerRepositoryABC
|
from bot_data.abc.user_joined_server_repository_abc import UserJoinedServerRepositoryABC
|
||||||
from bot_data.abc.user_repository_abc import UserRepositoryABC
|
from bot_data.abc.user_repository_abc import UserRepositoryABC
|
||||||
@ -20,7 +20,7 @@ class BaseOnMemberRemoveEvent(OnMemberRemoveABC):
|
|||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
config: ConfigurationABC,
|
config: ConfigurationABC,
|
||||||
logger: LoggerABC,
|
logger: EventLogger,
|
||||||
db: DatabaseContextABC,
|
db: DatabaseContextABC,
|
||||||
message_service: MessageServiceABC,
|
message_service: MessageServiceABC,
|
||||||
users: UserRepositoryABC,
|
users: UserRepositoryABC,
|
||||||
|
@ -4,6 +4,7 @@ from cpl_discord.service import DiscordBotServiceABC
|
|||||||
from discord import RawReactionActionEvent
|
from discord import RawReactionActionEvent
|
||||||
|
|
||||||
from bot_core.helper.event_checks import EventChecks
|
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.auto_role_repository_abc import AutoRoleRepositoryABC
|
||||||
from bot_data.abc.server_repository_abc import ServerRepositoryABC
|
from bot_data.abc.server_repository_abc import ServerRepositoryABC
|
||||||
from modules.base.helper.base_reaction_handler import BaseReactionHandler
|
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):
|
class BaseOnRawReactionAddEvent(OnRawReactionAddABC):
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
logger: LoggerABC,
|
logger: EventLogger,
|
||||||
bot: DiscordBotServiceABC,
|
bot: DiscordBotServiceABC,
|
||||||
servers: ServerRepositoryABC,
|
servers: ServerRepositoryABC,
|
||||||
auto_roles: AutoRoleRepositoryABC,
|
auto_roles: AutoRoleRepositoryABC,
|
||||||
|
@ -4,6 +4,7 @@ from cpl_discord.service import DiscordBotServiceABC
|
|||||||
from discord import RawReactionActionEvent
|
from discord import RawReactionActionEvent
|
||||||
|
|
||||||
from bot_core.helper.event_checks import EventChecks
|
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.auto_role_repository_abc import AutoRoleRepositoryABC
|
||||||
from bot_data.abc.server_repository_abc import ServerRepositoryABC
|
from bot_data.abc.server_repository_abc import ServerRepositoryABC
|
||||||
from modules.base.helper.base_reaction_handler import BaseReactionHandler
|
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):
|
class BaseOnRawReactionRemoveEvent(OnRawReactionRemoveABC):
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
logger: LoggerABC,
|
logger: EventLogger,
|
||||||
bot: DiscordBotServiceABC,
|
bot: DiscordBotServiceABC,
|
||||||
servers: ServerRepositoryABC,
|
servers: ServerRepositoryABC,
|
||||||
auto_roles: AutoRoleRepositoryABC,
|
auto_roles: AutoRoleRepositoryABC,
|
||||||
|
@ -5,6 +5,7 @@ from cpl_discord.service import DiscordBotServiceABC
|
|||||||
from discord import EventStatus
|
from discord import EventStatus
|
||||||
|
|
||||||
from bot_core.helper.event_checks import EventChecks
|
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.model.active_event import ActiveEvent
|
||||||
from modules.base.service.event_service import EventService
|
from modules.base.service.event_service import EventService
|
||||||
|
|
||||||
@ -12,7 +13,7 @@ from modules.base.service.event_service import EventService
|
|||||||
class BaseOnScheduledEventUpdateEvent(OnScheduledEventUpdateABC):
|
class BaseOnScheduledEventUpdateEvent(OnScheduledEventUpdateABC):
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
logger: LoggerABC,
|
logger: EventLogger,
|
||||||
bot: DiscordBotServiceABC,
|
bot: DiscordBotServiceABC,
|
||||||
events: EventService,
|
events: EventService,
|
||||||
):
|
):
|
||||||
|
@ -8,6 +8,7 @@ from cpl_core.logging import LoggerABC
|
|||||||
from cpl_discord.events import OnVoiceStateUpdateABC
|
from cpl_discord.events import OnVoiceStateUpdateABC
|
||||||
|
|
||||||
from bot_core.helper.event_checks import EventChecks
|
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.known_user_repository_abc import KnownUserRepositoryABC
|
||||||
from bot_data.abc.server_repository_abc import ServerRepositoryABC
|
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_joined_server_repository_abc import UserJoinedServerRepositoryABC
|
||||||
@ -25,7 +26,7 @@ class BaseOnVoiceStateUpdateEvent(OnVoiceStateUpdateABC):
|
|||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
config: ConfigurationABC,
|
config: ConfigurationABC,
|
||||||
logger: LoggerABC,
|
logger: EventLogger,
|
||||||
servers: ServerRepositoryABC,
|
servers: ServerRepositoryABC,
|
||||||
known_users: KnownUserRepositoryABC,
|
known_users: KnownUserRepositoryABC,
|
||||||
users: UserRepositoryABC,
|
users: UserRepositoryABC,
|
||||||
|
@ -6,6 +6,7 @@ from cpl_translation import TranslatePipe
|
|||||||
|
|
||||||
from bot_core.abc.message_service_abc import MessageServiceABC
|
from bot_core.abc.message_service_abc import MessageServiceABC
|
||||||
from bot_core.helper.event_checks import EventChecks
|
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.server_repository_abc import ServerRepositoryABC
|
||||||
from bot_data.model.server_config import ServerConfig
|
from bot_data.model.server_config import ServerConfig
|
||||||
from bot_core.abc.permission_service_abc import PermissionServiceABC
|
from bot_core.abc.permission_service_abc import PermissionServiceABC
|
||||||
@ -15,7 +16,7 @@ class BaseOnVoiceStateUpdateEventHelpChannel(OnVoiceStateUpdateABC):
|
|||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
config: ConfigurationABC,
|
config: ConfigurationABC,
|
||||||
logger: LoggerABC,
|
logger: EventLogger,
|
||||||
servers: ServerRepositoryABC,
|
servers: ServerRepositoryABC,
|
||||||
permissions: PermissionServiceABC,
|
permissions: PermissionServiceABC,
|
||||||
message_service: MessageServiceABC,
|
message_service: MessageServiceABC,
|
||||||
|
@ -5,6 +5,7 @@ from cpl_core.logging import LoggerABC
|
|||||||
from cpl_discord.events import OnVoiceStateUpdateABC
|
from cpl_discord.events import OnVoiceStateUpdateABC
|
||||||
|
|
||||||
from bot_core.helper.event_checks import EventChecks
|
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.server_repository_abc import ServerRepositoryABC
|
||||||
from bot_data.abc.user_repository_abc import UserRepositoryABC
|
from bot_data.abc.user_repository_abc import UserRepositoryABC
|
||||||
from modules.base.service.event_service import EventService
|
from modules.base.service.event_service import EventService
|
||||||
@ -14,7 +15,7 @@ class BaseOnVoiceStateUpdateEventScheduledEventBonus(OnVoiceStateUpdateABC):
|
|||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
config: ConfigurationABC,
|
config: ConfigurationABC,
|
||||||
logger: LoggerABC,
|
logger: EventLogger,
|
||||||
servers: ServerRepositoryABC,
|
servers: ServerRepositoryABC,
|
||||||
users: UserRepositoryABC,
|
users: UserRepositoryABC,
|
||||||
events: EventService,
|
events: EventService,
|
||||||
|
@ -99,6 +99,7 @@ class EventService:
|
|||||||
async def check_and_create_scheduled_events(self, guild: Guild):
|
async def check_and_create_scheduled_events(self, guild: Guild):
|
||||||
server = self._servers.get_server_by_discord_id(guild.id)
|
server = self._servers.get_server_by_discord_id(guild.id)
|
||||||
scheduled_events_from_db = self._events.get_scheduled_events_by_server_id(server.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:
|
for scheduled_event in scheduled_events_from_db:
|
||||||
scheduled_event: ScheduledEvent = scheduled_event
|
scheduled_event: ScheduledEvent = scheduled_event
|
||||||
from_guild = List(DiscordEvent, guild.scheduled_events).where(
|
from_guild = List(DiscordEvent, guild.scheduled_events).where(
|
||||||
@ -107,6 +108,7 @@ class EventService:
|
|||||||
and x.entity_type == scheduled_event.entity_type
|
and x.entity_type == scheduled_event.entity_type
|
||||||
)
|
)
|
||||||
if from_guild.count() != 0:
|
if from_guild.count() != 0:
|
||||||
|
self._logger.debug(__name__, f"Event {scheduled_event.name} already exists on discord server")
|
||||||
continue
|
continue
|
||||||
|
|
||||||
kwargs = {"name": scheduled_event.name, "description": scheduled_event.description}
|
kwargs = {"name": scheduled_event.name, "description": scheduled_event.description}
|
||||||
@ -119,14 +121,14 @@ class EventService:
|
|||||||
scheduled_event.interval, scheduled_event.start_time.replace(tzinfo=ZoneInfo("Europe/Berlin"))
|
scheduled_event.interval, scheduled_event.start_time.replace(tzinfo=ZoneInfo("Europe/Berlin"))
|
||||||
)
|
)
|
||||||
kwargs["start_time"] = start_time
|
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:
|
if scheduled_event.end_time is not None:
|
||||||
end_time = self._append_interval(
|
end_time = self._append_interval(
|
||||||
scheduled_event.interval, scheduled_event.end_time.replace(tzinfo=ZoneInfo("Europe/Berlin"))
|
scheduled_event.interval, scheduled_event.end_time.replace(tzinfo=ZoneInfo("Europe/Berlin"))
|
||||||
)
|
)
|
||||||
kwargs["end_time"] = end_time
|
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
|
kwargs["entity_type"] = scheduled_event.entity_type
|
||||||
if scheduled_event.location is not None:
|
if scheduled_event.location is not None:
|
||||||
@ -135,9 +137,10 @@ class EventService:
|
|||||||
kwargs["privacy_level"] = PrivacyLevel.guild_only
|
kwargs["privacy_level"] = PrivacyLevel.guild_only
|
||||||
|
|
||||||
try:
|
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)
|
await guild.create_scheduled_event(**kwargs)
|
||||||
self._events.update_scheduled_event(scheduled_event)
|
self._events.update_scheduled_event(scheduled_event)
|
||||||
self._db.save_changes()
|
self._db.save_changes()
|
||||||
|
self._logger.debug(__name__, f"Created scheduled event for guild {guild.name}")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
self._logger.error(__name__, f"Watching scheduled events failed", e)
|
self._logger.error(__name__, f"Watching scheduled events failed", e)
|
||||||
|
@ -10,6 +10,7 @@ from discord import guild
|
|||||||
from bot_core.abc.message_service_abc import MessageServiceABC
|
from bot_core.abc.message_service_abc import MessageServiceABC
|
||||||
from bot_core.configuration.feature_flags_enum import FeatureFlagsEnum
|
from bot_core.configuration.feature_flags_enum import FeatureFlagsEnum
|
||||||
from bot_core.configuration.feature_flags_settings import FeatureFlagsSettings
|
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.server_config import ServerConfig
|
||||||
from bot_data.model.technician_config import TechnicianConfig
|
from bot_data.model.technician_config import TechnicianConfig
|
||||||
|
|
||||||
@ -18,7 +19,7 @@ class BootLogOnReadyEvent(OnReadyABC):
|
|||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
config: ConfigurationABC,
|
config: ConfigurationABC,
|
||||||
logger: LoggerABC,
|
logger: EventLogger,
|
||||||
bot: DiscordBotServiceABC,
|
bot: DiscordBotServiceABC,
|
||||||
message_service: MessageServiceABC,
|
message_service: MessageServiceABC,
|
||||||
translate: TranslatePipe,
|
translate: TranslatePipe,
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
from cpl_core.configuration import ConfigurationABC
|
from cpl_core.configuration import ConfigurationABC
|
||||||
from cpl_core.logging import LoggerABC
|
|
||||||
from cpl_discord.events import OnReadyABC
|
from cpl_discord.events import OnReadyABC
|
||||||
from cpl_discord.service import DiscordBotServiceABC
|
from cpl_discord.service import DiscordBotServiceABC
|
||||||
|
|
||||||
|
from bot_core.logging.event_logger import EventLogger
|
||||||
from bot_core.service.config_service import ConfigService
|
from bot_core.service.config_service import ConfigService
|
||||||
from bot_core.service.data_integrity_service import DataIntegrityService
|
from bot_core.service.data_integrity_service import DataIntegrityService
|
||||||
from bot_data.abc.server_repository_abc import ServerRepositoryABC
|
from bot_data.abc.server_repository_abc import ServerRepositoryABC
|
||||||
@ -12,7 +12,7 @@ class ConfigOnReadyEvent(OnReadyABC):
|
|||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
config: ConfigurationABC,
|
config: ConfigurationABC,
|
||||||
logger: LoggerABC,
|
logger: EventLogger,
|
||||||
bot: DiscordBotServiceABC,
|
bot: DiscordBotServiceABC,
|
||||||
servers: ServerRepositoryABC,
|
servers: ServerRepositoryABC,
|
||||||
config_service: ConfigService,
|
config_service: ConfigService,
|
||||||
|
@ -5,13 +5,14 @@ from cpl_discord.events import OnMemberJoinABC
|
|||||||
from bot_core.configuration.feature_flags_enum import FeatureFlagsEnum
|
from bot_core.configuration.feature_flags_enum import FeatureFlagsEnum
|
||||||
from bot_core.configuration.feature_flags_settings import FeatureFlagsSettings
|
from bot_core.configuration.feature_flags_settings import FeatureFlagsSettings
|
||||||
from bot_core.helper.event_checks import EventChecks
|
from bot_core.helper.event_checks import EventChecks
|
||||||
|
from bot_core.logging.event_logger import EventLogger
|
||||||
from bot_core.logging.message_logger import MessageLogger
|
from bot_core.logging.message_logger import MessageLogger
|
||||||
from bot_data.model.server_config import ServerConfig
|
from bot_data.model.server_config import ServerConfig
|
||||||
from modules.level.service.level_service import LevelService
|
from modules.level.service.level_service import LevelService
|
||||||
|
|
||||||
|
|
||||||
class LevelOnMemberJoinEvent(OnMemberJoinABC):
|
class LevelOnMemberJoinEvent(OnMemberJoinABC):
|
||||||
def __init__(self, config: ConfigurationABC, logger: MessageLogger, level: LevelService):
|
def __init__(self, config: ConfigurationABC, logger: EventLogger, level: LevelService):
|
||||||
OnMemberJoinABC.__init__(self)
|
OnMemberJoinABC.__init__(self)
|
||||||
self._config = config
|
self._config = config
|
||||||
self._logger = logger
|
self._logger = logger
|
||||||
|
@ -7,6 +7,7 @@ from discord import RawReactionActionEvent
|
|||||||
from bot_core.configuration.feature_flags_enum import FeatureFlagsEnum
|
from bot_core.configuration.feature_flags_enum import FeatureFlagsEnum
|
||||||
from bot_core.configuration.feature_flags_settings import FeatureFlagsSettings
|
from bot_core.configuration.feature_flags_settings import FeatureFlagsSettings
|
||||||
from bot_core.helper.event_checks import EventChecks
|
from bot_core.helper.event_checks import EventChecks
|
||||||
|
from bot_core.logging.event_logger import EventLogger
|
||||||
from bot_data.model.server_config import ServerConfig
|
from bot_data.model.server_config import ServerConfig
|
||||||
from modules.level.service.level_service import LevelService
|
from modules.level.service.level_service import LevelService
|
||||||
|
|
||||||
@ -15,7 +16,7 @@ class LevelOnRawReactionAddEvent(OnRawReactionAddABC):
|
|||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
config: ConfigurationABC,
|
config: ConfigurationABC,
|
||||||
logger: LoggerABC,
|
logger: EventLogger,
|
||||||
bot: DiscordBotServiceABC,
|
bot: DiscordBotServiceABC,
|
||||||
level: LevelService,
|
level: LevelService,
|
||||||
):
|
):
|
||||||
|
@ -7,6 +7,7 @@ from discord import RawReactionActionEvent
|
|||||||
from bot_core.configuration.feature_flags_enum import FeatureFlagsEnum
|
from bot_core.configuration.feature_flags_enum import FeatureFlagsEnum
|
||||||
from bot_core.configuration.feature_flags_settings import FeatureFlagsSettings
|
from bot_core.configuration.feature_flags_settings import FeatureFlagsSettings
|
||||||
from bot_core.helper.event_checks import EventChecks
|
from bot_core.helper.event_checks import EventChecks
|
||||||
|
from bot_core.logging.event_logger import EventLogger
|
||||||
from bot_data.model.server_config import ServerConfig
|
from bot_data.model.server_config import ServerConfig
|
||||||
from modules.level.service.level_service import LevelService
|
from modules.level.service.level_service import LevelService
|
||||||
|
|
||||||
@ -15,7 +16,7 @@ class LevelOnRawReactionRemoveEvent(OnRawReactionRemoveABC):
|
|||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
config: ConfigurationABC,
|
config: ConfigurationABC,
|
||||||
logger: LoggerABC,
|
logger: EventLogger,
|
||||||
bot: DiscordBotServiceABC,
|
bot: DiscordBotServiceABC,
|
||||||
level: LevelService,
|
level: LevelService,
|
||||||
):
|
):
|
||||||
|
@ -6,12 +6,13 @@ from cpl_discord.events import OnVoiceStateUpdateABC
|
|||||||
from bot_core.configuration.feature_flags_enum import FeatureFlagsEnum
|
from bot_core.configuration.feature_flags_enum import FeatureFlagsEnum
|
||||||
from bot_core.configuration.feature_flags_settings import FeatureFlagsSettings
|
from bot_core.configuration.feature_flags_settings import FeatureFlagsSettings
|
||||||
from bot_core.helper.event_checks import EventChecks
|
from bot_core.helper.event_checks import EventChecks
|
||||||
|
from bot_core.logging.event_logger import EventLogger
|
||||||
from bot_data.model.server_config import ServerConfig
|
from bot_data.model.server_config import ServerConfig
|
||||||
from modules.level.service.level_service import LevelService
|
from modules.level.service.level_service import LevelService
|
||||||
|
|
||||||
|
|
||||||
class LevelOnVoiceStateUpdateEvent(OnVoiceStateUpdateABC):
|
class LevelOnVoiceStateUpdateEvent(OnVoiceStateUpdateABC):
|
||||||
def __init__(self, config: ConfigurationABC, logger: LoggerABC, level: LevelService):
|
def __init__(self, config: ConfigurationABC, logger: EventLogger, level: LevelService):
|
||||||
OnVoiceStateUpdateABC.__init__(self)
|
OnVoiceStateUpdateABC.__init__(self)
|
||||||
self._config = config
|
self._config = config
|
||||||
self._logger = logger
|
self._logger = logger
|
||||||
|
Loading…
Reference in New Issue
Block a user