Compare commits

...

7 Commits

Author SHA1 Message Date
af9c55e4b1 Updated dev action
Some checks failed
Deploy dev on push / pre-build (push) Successful in 2s
Deploy dev on push / build-bot (push) Failing after 2m3s
Deploy dev on push / build-web (push) Failing after 2m5s
Deploy dev on push / deploy (push) Has been skipped
2023-12-09 21:00:20 +01:00
e3172d6f24 Fixed event logger
All checks were successful
Deploy staging on push / on-push-deploy_sh-edraft (push) Successful in 4m22s
2023-12-09 14:11:34 +01:00
0706579f62 Fixed set timestamp for scheduled events #456
All checks were successful
Deploy staging on push / on-push-deploy_sh-edraft (push) Successful in 4m9s
2023-12-09 14:05:35 +01:00
ad3fc94923 Improved logging for event_service
All checks were successful
Deploy staging on push / on-push-deploy_sh-edraft (push) Successful in 4m13s
2023-12-09 13:58:38 +01:00
69882af0bd Added event logger
Some checks reported warnings
Deploy staging on push / on-push-deploy_sh-edraft (push) Has been cancelled
2023-12-09 13:55:40 +01:00
b0fb12f841 Removed native password & disable ssl
All checks were successful
Deploy staging on push / on-push-deploy_sh-edraft (push) Successful in 5m13s
2023-12-06 17:59:23 +01:00
4d980331e2 Merge pull request 'Added user activity score #451' (#452) from dev into staging
All checks were successful
Deploy staging on push / on-push-deploy_sh-edraft (push) Successful in 3m18s
Reviewed-on: #452
2023-12-04 22:55:03 +01:00
25 changed files with 132 additions and 52 deletions

View File

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

View File

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

View File

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

View File

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

View File

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

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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