Merge branch '0.2' into #42
This commit is contained in:
commit
5b1a98ad5c
@ -1,16 +1,28 @@
|
|||||||
version: "3.9"
|
version: "3.9"
|
||||||
|
|
||||||
services:
|
services:
|
||||||
kdb_1:
|
kdb_prod_1:
|
||||||
image: kdb
|
image: kdb
|
||||||
container_name: kdb_1
|
container_name: kdb_1
|
||||||
depends_on:
|
depends_on:
|
||||||
- kdb_db_1
|
- kdb_db_1
|
||||||
environment:
|
environment:
|
||||||
|
KDB_ENVIRONMENT: "production"
|
||||||
KDB_TOKEN: ""
|
KDB_TOKEN: ""
|
||||||
KDB_PREFIX: "!k "
|
KDB_PREFIX: "!k "
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
|
|
||||||
|
kdb_staging_1:
|
||||||
|
image: kdb
|
||||||
|
container_name: kdb_1
|
||||||
|
depends_on:
|
||||||
|
- kdb_db_1
|
||||||
|
environment:
|
||||||
|
KDB_ENVIRONMENT: "staging"
|
||||||
|
KDB_TOKEN: ""
|
||||||
|
KDB_PREFIX: "!kt "
|
||||||
|
restart: unless-stopped
|
||||||
|
|
||||||
kdb_db_1:
|
kdb_db_1:
|
||||||
image: mysql:latest
|
image: mysql:latest
|
||||||
container_name: kdb_db_1
|
container_name: kdb_db_1
|
||||||
@ -23,3 +35,16 @@ services:
|
|||||||
MYSQL_DATABASE: "kd_kdb"
|
MYSQL_DATABASE: "kd_kdb"
|
||||||
ports:
|
ports:
|
||||||
- "3307:3306"
|
- "3307:3306"
|
||||||
|
|
||||||
|
kdb_db_2:
|
||||||
|
image: mysql:latest
|
||||||
|
container_name: kdb_db_2
|
||||||
|
command: mysqld --default-authentication-plugin=mysql_native_password
|
||||||
|
restart: unless-stopped
|
||||||
|
environment:
|
||||||
|
MYSQL_ROOT_PASSWORD: "kd_kdb"
|
||||||
|
MYSQL_USER: "kd_kdb"
|
||||||
|
MYSQL_PASSWORD: "kd_kdb"
|
||||||
|
MYSQL_DATABASE: "kd_kdb"
|
||||||
|
ports:
|
||||||
|
- "3308:3306"
|
@ -1,6 +1,6 @@
|
|||||||
from typing import Optional, Type
|
from typing import Optional, Type, Callable
|
||||||
|
|
||||||
from cpl_core.configuration import ConfigurationABC, ConfigurationModelABC
|
from cpl_core.configuration import ConfigurationABC
|
||||||
from cpl_core.console import Console
|
from cpl_core.console import Console
|
||||||
from cpl_core.dependency_injection import ServiceProviderABC
|
from cpl_core.dependency_injection import ServiceProviderABC
|
||||||
from cpl_core.logging import LoggerABC
|
from cpl_core.logging import LoggerABC
|
||||||
@ -9,13 +9,12 @@ from cpl_discord.configuration import DiscordBotSettings
|
|||||||
from cpl_discord.service import DiscordBotServiceABC, DiscordBotService
|
from cpl_discord.service import DiscordBotServiceABC, DiscordBotService
|
||||||
from cpl_translation import TranslatePipe, TranslationServiceABC, TranslationSettings
|
from cpl_translation import TranslatePipe, TranslationServiceABC, TranslationSettings
|
||||||
|
|
||||||
|
from bot_core.configuration.bot_logging_settings import BotLoggingSettings
|
||||||
from bot_core.configuration.bot_settings import BotSettings
|
from bot_core.configuration.bot_settings import BotSettings
|
||||||
from bot_core.configuration.server_settings import ServerSettings
|
from bot_core.logging.command_logger import CommandLogger
|
||||||
from modules.base.configuration.base_server_settings import BaseServerSettings
|
from bot_core.logging.database_logger import DatabaseLogger
|
||||||
from modules.base.configuration.base_settings import BaseSettings
|
from modules.base.configuration.base_settings import BaseSettings
|
||||||
from modules.boot_log.configuration.boot_log_server_settings import BootLogServerSettings
|
|
||||||
from modules.boot_log.configuration.boot_log_settings import BootLogSettings
|
from modules.boot_log.configuration.boot_log_settings import BootLogSettings
|
||||||
from modules.permission.configuration.permission_server_settings import PermissionServerSettings
|
|
||||||
from modules.permission.configuration.permission_settings import PermissionSettings
|
from modules.permission.configuration.permission_settings import PermissionSettings
|
||||||
|
|
||||||
|
|
||||||
@ -24,6 +23,8 @@ class Application(DiscordBotApplicationABC):
|
|||||||
def __init__(self, config: ConfigurationABC, services: ServiceProviderABC):
|
def __init__(self, config: ConfigurationABC, services: ServiceProviderABC):
|
||||||
DiscordBotApplicationABC.__init__(self, config, services)
|
DiscordBotApplicationABC.__init__(self, config, services)
|
||||||
|
|
||||||
|
self._services = services
|
||||||
|
|
||||||
# cpl-core
|
# cpl-core
|
||||||
self._logger: LoggerABC = services.get_service(LoggerABC)
|
self._logger: LoggerABC = services.get_service(LoggerABC)
|
||||||
# cpl-discord
|
# cpl-discord
|
||||||
@ -33,31 +34,25 @@ class Application(DiscordBotApplicationABC):
|
|||||||
self._translation: TranslationServiceABC = services.get_service(TranslationServiceABC)
|
self._translation: TranslationServiceABC = services.get_service(TranslationServiceABC)
|
||||||
self._translate: TranslatePipe = services.get_service(TranslatePipe)
|
self._translate: TranslatePipe = services.get_service(TranslatePipe)
|
||||||
|
|
||||||
def _configure_settings_with_servers(self, settings: Type, server_settings: Type):
|
self._is_stopping = False
|
||||||
settings: Optional[settings] = self._configuration.get_configuration(settings)
|
|
||||||
if settings is None:
|
|
||||||
return
|
|
||||||
|
|
||||||
for server in settings.servers:
|
|
||||||
self._logger.trace(__name__, f'Saved config: {type(server).__name__}_{server.id}')
|
|
||||||
self._configuration.add_configuration(f'{type(server).__name__}_{server.id}', server)
|
|
||||||
|
|
||||||
async def configure(self):
|
async def configure(self):
|
||||||
self._translation.load_by_settings(self._configuration.get_configuration(TranslationSettings))
|
self._translation.load_by_settings(self._configuration.get_configuration(TranslationSettings))
|
||||||
self._configure_settings_with_servers(BotSettings, ServerSettings)
|
|
||||||
self._configure_settings_with_servers(BaseSettings, BaseServerSettings)
|
|
||||||
self._configure_settings_with_servers(BootLogSettings, BootLogServerSettings)
|
|
||||||
self._configure_settings_with_servers(PermissionSettings, PermissionServerSettings)
|
|
||||||
|
|
||||||
async def main(self):
|
async def main(self):
|
||||||
try:
|
try:
|
||||||
self._logger.debug(__name__, f'Starting...\n')
|
self._logger.debug(__name__, f'Starting...\n')
|
||||||
self._logger.trace(__name__, f'Try to start {DiscordBotService.__name__}')
|
self._logger.trace(__name__, f'Try to start {DiscordBotService.__name__}')
|
||||||
await self._bot.start_async()
|
await self._bot.start_async()
|
||||||
|
await self._bot.stop_async()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
self._logger.error(__name__, 'Start failed', e)
|
self._logger.error(__name__, 'Start failed', e)
|
||||||
|
|
||||||
async def stop_async(self):
|
async def stop_async(self):
|
||||||
|
if self._is_stopping:
|
||||||
|
return
|
||||||
|
|
||||||
|
self._is_stopping = True
|
||||||
try:
|
try:
|
||||||
self._logger.trace(__name__, f'Try to stop {DiscordBotService.__name__}')
|
self._logger.trace(__name__, f'Try to stop {DiscordBotService.__name__}')
|
||||||
await self._bot.close()
|
await self._bot.close()
|
||||||
|
@ -7,16 +7,44 @@
|
|||||||
},
|
},
|
||||||
"LoggingSettings": {
|
"LoggingSettings": {
|
||||||
"Path": "logs/",
|
"Path": "logs/",
|
||||||
"Filename": "log_dev.log",
|
"Filename": "bot.log",
|
||||||
"ConsoleLogLevel": "DEBUG",
|
"ConsoleLogLevel": "DEBUG",
|
||||||
"FileLogLevel": "DEBUG"
|
"FileLogLevel": "DEBUG"
|
||||||
},
|
},
|
||||||
|
"BotLoggingSettings": {
|
||||||
|
"Command": {
|
||||||
|
"Path": "logs/",
|
||||||
|
"Filename": "commands.log",
|
||||||
|
"ConsoleLogLevel": "DEBUG",
|
||||||
|
"FileLogLevel": "DEBUG"
|
||||||
|
},
|
||||||
|
"Database": {
|
||||||
|
"Path": "logs/",
|
||||||
|
"Filename": "database.log",
|
||||||
|
"ConsoleLogLevel": "DEBUG",
|
||||||
|
"FileLogLevel": "DEBUG"
|
||||||
|
},
|
||||||
|
"Message": {
|
||||||
|
"Path": "logs/",
|
||||||
|
"Filename": "message.log",
|
||||||
|
"ConsoleLogLevel": "DEBUG",
|
||||||
|
"FileLogLevel": "DEBUG"
|
||||||
|
}
|
||||||
|
},
|
||||||
"Translation": {
|
"Translation": {
|
||||||
"DefaultLanguage": "de",
|
"DefaultLanguage": "de",
|
||||||
"Languages": [
|
"Languages": [
|
||||||
"de"
|
"de"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
"FeatureFlags": {
|
||||||
|
"AdminModule": true,
|
||||||
|
"BaseModule": true,
|
||||||
|
"BootLogModule": true,
|
||||||
|
"DatabaseModule": true,
|
||||||
|
"ModeratorModule": true,
|
||||||
|
"PermissionModule": true
|
||||||
|
},
|
||||||
"DiscordBot": {
|
"DiscordBot": {
|
||||||
"Token": "OTk4MTU5NjczODkzMDYwNzM4.GN3QyA.yvWO6L7Eu36gXQ7ARDs0Jg2J1VqIDnHLou5lT4",
|
"Token": "OTk4MTU5NjczODkzMDYwNzM4.GN3QyA.yvWO6L7Eu36gXQ7ARDs0Jg2J1VqIDnHLou5lT4",
|
||||||
"Prefix": "!kd "
|
"Prefix": "!kd "
|
||||||
|
@ -1,10 +1,30 @@
|
|||||||
{
|
{
|
||||||
"LoggingSettings": {
|
"LoggingSettings": {
|
||||||
"Path": "logs/",
|
"Path": "logs/",
|
||||||
"Filename": "log_dev.log",
|
"Filename": "bot.log",
|
||||||
"ConsoleLogLevel": "DEBUG",
|
"ConsoleLogLevel": "DEBUG",
|
||||||
"FileLogLevel": "TRACE"
|
"FileLogLevel": "TRACE"
|
||||||
},
|
},
|
||||||
|
"BotLoggingSettings": {
|
||||||
|
"Command": {
|
||||||
|
"Path": "logs/",
|
||||||
|
"Filename": "commands.log",
|
||||||
|
"ConsoleLogLevel": "DEBUG",
|
||||||
|
"FileLogLevel": "TRACE"
|
||||||
|
},
|
||||||
|
"Database": {
|
||||||
|
"Path": "logs/",
|
||||||
|
"Filename": "database.log",
|
||||||
|
"ConsoleLogLevel": "DEBUG",
|
||||||
|
"FileLogLevel": "TRACE"
|
||||||
|
},
|
||||||
|
"Message": {
|
||||||
|
"Path": "logs/",
|
||||||
|
"Filename": "message.log",
|
||||||
|
"ConsoleLogLevel": "DEBUG",
|
||||||
|
"FileLogLevel": "TRACE"
|
||||||
|
}
|
||||||
|
},
|
||||||
"DatabaseSettings": {
|
"DatabaseSettings": {
|
||||||
"Host": "localhost",
|
"Host": "localhost",
|
||||||
"User": "kd_kdb",
|
"User": "kd_kdb",
|
||||||
@ -19,6 +39,14 @@
|
|||||||
"Token": "OTk4MTYwNDI3Njg5MTgxMjM3.GI7h67.BqD6Lu1Tz0MuG8iktYrcLnHi1pNozyMiWFGTKI",
|
"Token": "OTk4MTYwNDI3Njg5MTgxMjM3.GI7h67.BqD6Lu1Tz0MuG8iktYrcLnHi1pNozyMiWFGTKI",
|
||||||
"Prefix": "!ke "
|
"Prefix": "!ke "
|
||||||
},
|
},
|
||||||
|
"FeatureFlags": {
|
||||||
|
"AdminModule": true,
|
||||||
|
"BaseModule": true,
|
||||||
|
"BootLogModule": true,
|
||||||
|
"DatabaseModule": true,
|
||||||
|
"ModeratorModule": true,
|
||||||
|
"PermissionModule": true
|
||||||
|
},
|
||||||
"Bot": {
|
"Bot": {
|
||||||
"910199451145076828": {
|
"910199451145076828": {
|
||||||
"MessageDeleteTimer": 2
|
"MessageDeleteTimer": 2
|
||||||
|
@ -6,9 +6,29 @@
|
|||||||
"DateTimeLogFormat": "%Y-%m-%d_%H-%M-%S"
|
"DateTimeLogFormat": "%Y-%m-%d_%H-%M-%S"
|
||||||
},
|
},
|
||||||
"LoggingSettings": {
|
"LoggingSettings": {
|
||||||
"Path": "logs/",
|
"Path": "logs/$date_now/",
|
||||||
"Filename": "log_$start_time.log",
|
"Filename": "bot.log",
|
||||||
|
"ConsoleLogLevel": "ERROR",
|
||||||
|
"FileLogLevel": "WARN"
|
||||||
|
},
|
||||||
|
"BotLoggingSettings": {
|
||||||
|
"Command": {
|
||||||
|
"Path": "logs/$date_now/",
|
||||||
|
"Filename": "commands.log",
|
||||||
|
"ConsoleLogLevel": "ERROR",
|
||||||
|
"FileLogLevel": "WARN"
|
||||||
|
},
|
||||||
|
"Database": {
|
||||||
|
"Path": "logs/$date_now/",
|
||||||
|
"Filename": "database.log",
|
||||||
|
"ConsoleLogLevel": "ERROR",
|
||||||
|
"FileLogLevel": "WARN"
|
||||||
|
},
|
||||||
|
"Message": {
|
||||||
|
"Path": "logs/$date_now/",
|
||||||
|
"Filename": "message.log",
|
||||||
"ConsoleLogLevel": "ERROR",
|
"ConsoleLogLevel": "ERROR",
|
||||||
"FileLogLevel": "WARN"
|
"FileLogLevel": "WARN"
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
@ -6,11 +6,31 @@
|
|||||||
"DateTimeLogFormat": "%Y-%m-%d_%H-%M-%S"
|
"DateTimeLogFormat": "%Y-%m-%d_%H-%M-%S"
|
||||||
},
|
},
|
||||||
"LoggingSettings": {
|
"LoggingSettings": {
|
||||||
"Path": "logs/",
|
"Path": "logs/$date_now/",
|
||||||
"Filename": "log_$start_time.log",
|
"Filename": "bot.log",
|
||||||
"ConsoleLogLevel": "ERROR",
|
"ConsoleLogLevel": "ERROR",
|
||||||
"FileLogLevel": "INFO"
|
"FileLogLevel": "INFO"
|
||||||
},
|
},
|
||||||
|
"BotLoggingSettings": {
|
||||||
|
"Command": {
|
||||||
|
"Path": "logs/$date_now/",
|
||||||
|
"Filename": "commands.log",
|
||||||
|
"ConsoleLogLevel": "ERROR",
|
||||||
|
"FileLogLevel": "INFO"
|
||||||
|
},
|
||||||
|
"Database": {
|
||||||
|
"Path": "logs/$date_now/",
|
||||||
|
"Filename": "database.log",
|
||||||
|
"ConsoleLogLevel": "ERROR",
|
||||||
|
"FileLogLevel": "INFO"
|
||||||
|
},
|
||||||
|
"Message": {
|
||||||
|
"Path": "logs/$date_now/",
|
||||||
|
"Filename": "message.log",
|
||||||
|
"ConsoleLogLevel": "ERROR",
|
||||||
|
"FileLogLevel": "INFO"
|
||||||
|
}
|
||||||
|
},
|
||||||
"Translation": {
|
"Translation": {
|
||||||
"DefaultLanguage": "de",
|
"DefaultLanguage": "de",
|
||||||
"Languages": [
|
"Languages": [
|
||||||
@ -18,7 +38,7 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"DatabaseSettings": {
|
"DatabaseSettings": {
|
||||||
"Host": "192.168.0.40",
|
"Host": "localhost",
|
||||||
"User": "kd_kdb",
|
"User": "kd_kdb",
|
||||||
"Password": "a2Rfa2Ri",
|
"Password": "a2Rfa2Ri",
|
||||||
"Database": "kd_kdb",
|
"Database": "kd_kdb",
|
||||||
@ -28,6 +48,14 @@
|
|||||||
"Buffered": "true",
|
"Buffered": "true",
|
||||||
"AuthPlugin": "mysql_native_password"
|
"AuthPlugin": "mysql_native_password"
|
||||||
},
|
},
|
||||||
|
"FeatureFlags": {
|
||||||
|
"AdminModule": true,
|
||||||
|
"BaseModule": true,
|
||||||
|
"BootLogModule": true,
|
||||||
|
"DatabaseModule": true,
|
||||||
|
"ModeratorModule": true,
|
||||||
|
"PermissionModule": true
|
||||||
|
},
|
||||||
"Bot": {
|
"Bot": {
|
||||||
"650366049023295514": {
|
"650366049023295514": {
|
||||||
"MessageDeleteTimer": 2
|
"MessageDeleteTimer": 2
|
||||||
|
@ -6,17 +6,56 @@
|
|||||||
"DateTimeLogFormat": "%Y-%m-%d_%H-%M-%S"
|
"DateTimeLogFormat": "%Y-%m-%d_%H-%M-%S"
|
||||||
},
|
},
|
||||||
"LoggingSettings": {
|
"LoggingSettings": {
|
||||||
"Path": "logs/",
|
"Path": "logs/$date_now/",
|
||||||
"Filename": "log_staging_$start_time.log",
|
"Filename": "bot.log",
|
||||||
"ConsoleLogLevel": "INFO",
|
"ConsoleLogLevel": "INFO",
|
||||||
"FileLogLevel": "DEBUG"
|
"FileLogLevel": "DEBUG"
|
||||||
},
|
},
|
||||||
|
"BotLoggingSettings": {
|
||||||
|
"Command": {
|
||||||
|
"Path": "logs/$date_now/",
|
||||||
|
"Filename": "commands.log",
|
||||||
|
"ConsoleLogLevel": "INFO",
|
||||||
|
"FileLogLevel": "DEBUG"
|
||||||
|
},
|
||||||
|
"Database": {
|
||||||
|
"Path": "logs/$date_now/",
|
||||||
|
"Filename": "database.log",
|
||||||
|
"ConsoleLogLevel": "INFO",
|
||||||
|
"FileLogLevel": "DEBUG"
|
||||||
|
},
|
||||||
|
"Message": {
|
||||||
|
"Path": "logs/$date_now/",
|
||||||
|
"Filename": "message.log",
|
||||||
|
"ConsoleLogLevel": "INFO",
|
||||||
|
"FileLogLevel": "DEBUG"
|
||||||
|
}
|
||||||
|
},
|
||||||
"Translation": {
|
"Translation": {
|
||||||
"DefaultLanguage": "de",
|
"DefaultLanguage": "de",
|
||||||
"Languages": [
|
"Languages": [
|
||||||
"de"
|
"de"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
"DatabaseSettings": {
|
||||||
|
"Host": "localhost",
|
||||||
|
"User": "kd_kdb",
|
||||||
|
"Password": "a2Rfa2Ri",
|
||||||
|
"Database": "kd_kdb",
|
||||||
|
"Port": "3308",
|
||||||
|
"Charset": "utf8mb4",
|
||||||
|
"UseUnicode": "true",
|
||||||
|
"Buffered": "true",
|
||||||
|
"AuthPlugin": "mysql_native_password"
|
||||||
|
},
|
||||||
|
"FeatureFlags": {
|
||||||
|
"AdminModule": true,
|
||||||
|
"BaseModule": true,
|
||||||
|
"BootLogModule": true,
|
||||||
|
"DatabaseModule": true,
|
||||||
|
"ModeratorModule": true,
|
||||||
|
"PermissionModule": true
|
||||||
|
},
|
||||||
"Bot": {
|
"Bot": {
|
||||||
"910199451145076828": {
|
"910199451145076828": {
|
||||||
"MessageDeleteTimer": 4
|
"MessageDeleteTimer": 4
|
||||||
|
@ -8,6 +8,7 @@ from bot.application import Application
|
|||||||
from bot.startup import Startup
|
from bot.startup import Startup
|
||||||
from bot.startup_discord_extension import StartupDiscordExtension
|
from bot.startup_discord_extension import StartupDiscordExtension
|
||||||
from bot.startup_migration_extension import StartupMigrationExtension
|
from bot.startup_migration_extension import StartupMigrationExtension
|
||||||
|
from bot.startup_settings_extension import StartupSettingsExtension
|
||||||
from modules.boot_log.boot_log_extension import BootLogExtension
|
from modules.boot_log.boot_log_extension import BootLogExtension
|
||||||
from modules.database.database_extension import DatabaseExtension
|
from modules.database.database_extension import DatabaseExtension
|
||||||
|
|
||||||
@ -18,12 +19,13 @@ class Program:
|
|||||||
self.app: Optional[Application] = None
|
self.app: Optional[Application] = None
|
||||||
|
|
||||||
async def start(self):
|
async def start(self):
|
||||||
app_builder = ApplicationBuilder(Application)
|
app_builder = ApplicationBuilder(Application) \
|
||||||
app_builder.use_extension(StartupDiscordExtension)
|
.use_extension(StartupSettingsExtension) \
|
||||||
app_builder.use_extension(StartupMigrationExtension)
|
.use_extension(StartupDiscordExtension) \
|
||||||
app_builder.use_extension(BootLogExtension)
|
.use_extension(StartupMigrationExtension) \
|
||||||
app_builder.use_extension(DatabaseExtension)
|
.use_extension(BootLogExtension) \
|
||||||
app_builder.use_startup(Startup)
|
.use_extension(DatabaseExtension) \
|
||||||
|
.use_startup(Startup)
|
||||||
self.app: Application = await app_builder.build_async()
|
self.app: Application = await app_builder.build_async()
|
||||||
await self.app.run_async()
|
await self.app.run_async()
|
||||||
|
|
||||||
|
@ -7,9 +7,14 @@ from cpl_core.configuration import ConfigurationABC
|
|||||||
from cpl_core.database import DatabaseSettings
|
from cpl_core.database import DatabaseSettings
|
||||||
from cpl_core.dependency_injection import ServiceProviderABC, ServiceCollectionABC
|
from cpl_core.dependency_injection import ServiceProviderABC, ServiceCollectionABC
|
||||||
from cpl_core.environment import ApplicationEnvironment
|
from cpl_core.environment import ApplicationEnvironment
|
||||||
|
from cpl_core.logging import LoggerABC
|
||||||
|
|
||||||
from bot_core.abc.client_utils_service_abc import ClientUtilsServiceABC
|
from bot_core.abc.client_utils_service_abc import ClientUtilsServiceABC
|
||||||
|
from bot_core.abc.custom_file_logger_abc import CustomFileLoggerABC
|
||||||
from bot_core.abc.message_service_abc import MessageServiceABC
|
from bot_core.abc.message_service_abc import MessageServiceABC
|
||||||
|
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.pipes.date_time_offset_pipe import DateTimeOffsetPipe
|
from bot_core.pipes.date_time_offset_pipe import DateTimeOffsetPipe
|
||||||
from bot_core.service.client_utils_service import ClientUtilsService
|
from bot_core.service.client_utils_service import ClientUtilsService
|
||||||
from bot_core.service.message_service import MessageService
|
from bot_core.service.message_service import MessageService
|
||||||
@ -41,21 +46,16 @@ class Startup(StartupABC):
|
|||||||
self._config: Optional[ConfigurationABC] = None
|
self._config: Optional[ConfigurationABC] = None
|
||||||
|
|
||||||
def configure_configuration(self, configuration: ConfigurationABC, environment: ApplicationEnvironment) -> ConfigurationABC:
|
def configure_configuration(self, configuration: ConfigurationABC, environment: ApplicationEnvironment) -> ConfigurationABC:
|
||||||
environment.set_working_directory(os.path.dirname(os.path.realpath(__file__)))
|
|
||||||
configuration.add_environment_variables('KDB_')
|
|
||||||
configuration.add_environment_variables('DISCORD_')
|
|
||||||
|
|
||||||
configuration.add_json_file(f'config/appsettings.json', optional=False)
|
|
||||||
configuration.add_json_file(f'config/appsettings.{environment.environment_name}.json', optional=True)
|
|
||||||
configuration.add_json_file(f'config/appsettings.{environment.host_name}.json', optional=True)
|
|
||||||
|
|
||||||
configuration.add_configuration('Startup_StartTime', str(self._start_time))
|
|
||||||
|
|
||||||
self._config = configuration
|
self._config = configuration
|
||||||
return configuration
|
return configuration
|
||||||
|
|
||||||
def configure_services(self, services: ServiceCollectionABC, environment: ApplicationEnvironment) -> ServiceProviderABC:
|
def configure_services(self, services: ServiceCollectionABC, environment: ApplicationEnvironment) -> ServiceProviderABC:
|
||||||
services.add_logging()
|
services.add_logging()
|
||||||
|
# custom logging
|
||||||
|
services.add_singleton(LoggerABC, CommandLogger)
|
||||||
|
services.add_singleton(LoggerABC, DatabaseLogger)
|
||||||
|
services.add_singleton(LoggerABC, MessageLogger)
|
||||||
|
|
||||||
services.add_translation()
|
services.add_translation()
|
||||||
|
|
||||||
services.add_db_context(DBContext, self._config.get_configuration(DatabaseSettings))
|
services.add_db_context(DBContext, self._config.get_configuration(DatabaseSettings))
|
||||||
@ -79,4 +79,9 @@ class Startup(StartupABC):
|
|||||||
services.add_transient(UserJoinedServerRepositoryABC, UserJoinedServerRepositoryService)
|
services.add_transient(UserJoinedServerRepositoryABC, UserJoinedServerRepositoryService)
|
||||||
services.add_transient(UserJoinedVoiceChannelRepositoryABC, UserJoinedVoiceChannelRepositoryService)
|
services.add_transient(UserJoinedVoiceChannelRepositoryABC, UserJoinedVoiceChannelRepositoryService)
|
||||||
|
|
||||||
return services.build_service_provider()
|
provider = services.build_service_provider()
|
||||||
|
# instantiate custom logger
|
||||||
|
for c in CustomFileLoggerABC.__subclasses__():
|
||||||
|
i: LoggerABC = provider.get_service(c)
|
||||||
|
|
||||||
|
return provider
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
from typing import Optional
|
||||||
|
|
||||||
from cpl_core.application import StartupExtensionABC
|
from cpl_core.application import StartupExtensionABC
|
||||||
from cpl_core.configuration import ConfigurationABC
|
from cpl_core.configuration import ConfigurationABC
|
||||||
from cpl_core.dependency_injection import ServiceCollectionABC
|
from cpl_core.dependency_injection import ServiceCollectionABC
|
||||||
@ -5,6 +7,7 @@ from cpl_core.environment import ApplicationEnvironmentABC
|
|||||||
from cpl_discord import get_discord_collection
|
from cpl_discord import get_discord_collection
|
||||||
from cpl_discord.discord_event_types_enum import DiscordEventTypesEnum
|
from cpl_discord.discord_event_types_enum import DiscordEventTypesEnum
|
||||||
|
|
||||||
|
from bot_core.configuration.feature_flags_settings import FeatureFlagsSettings
|
||||||
from modules.admin.command.restart_command import RestartCommand
|
from modules.admin.command.restart_command import RestartCommand
|
||||||
from modules.admin.command.shutdown_command import ShutdownCommand
|
from modules.admin.command.shutdown_command import ShutdownCommand
|
||||||
from modules.base.command.afk_command import AFKCommand
|
from modules.base.command.afk_command import AFKCommand
|
||||||
@ -12,6 +15,7 @@ from modules.base.command.help_command import HelpCommand
|
|||||||
from modules.base.command.info_command import InfoCommand
|
from modules.base.command.info_command import InfoCommand
|
||||||
from modules.base.command.ping_command import PingCommand
|
from modules.base.command.ping_command import PingCommand
|
||||||
from modules.base.events.base_on_command_error_event import BaseOnCommandErrorEvent
|
from modules.base.events.base_on_command_error_event import BaseOnCommandErrorEvent
|
||||||
|
from modules.base.events.base_on_command_event import BaseOnCommandEvent
|
||||||
from modules.moderator.command.purge_command import PurgeCommand
|
from modules.moderator.command.purge_command import PurgeCommand
|
||||||
from modules.base.command.user_info_command import UserInfoCommand
|
from modules.base.command.user_info_command import UserInfoCommand
|
||||||
from modules.base.events.base_on_member_join_event import BaseOnMemberJoinEvent
|
from modules.base.events.base_on_member_join_event import BaseOnMemberJoinEvent
|
||||||
@ -27,40 +31,54 @@ from modules.permission.events.permission_on_ready_event import PermissionOnRead
|
|||||||
class StartupDiscordExtension(StartupExtensionABC):
|
class StartupDiscordExtension(StartupExtensionABC):
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
pass
|
self._feature_flags: Optional[FeatureFlagsSettings] = None
|
||||||
|
|
||||||
def configure_configuration(self, config: ConfigurationABC, env: ApplicationEnvironmentABC):
|
def configure_configuration(self, config: ConfigurationABC, env: ApplicationEnvironmentABC):
|
||||||
pass
|
self._feature_flags = config.get_configuration(FeatureFlagsSettings)
|
||||||
|
|
||||||
def configure_services(self, services: ServiceCollectionABC, env: ApplicationEnvironmentABC):
|
def configure_services(self, services: ServiceCollectionABC, env: ApplicationEnvironmentABC):
|
||||||
services.add_discord()
|
services.add_discord()
|
||||||
dc = get_discord_collection(services)
|
dc = get_discord_collection(services)
|
||||||
|
"""modules"""
|
||||||
|
if self._feature_flags.admin_module:
|
||||||
""" commands """
|
""" commands """
|
||||||
# admin
|
|
||||||
dc.add_command(RestartCommand)
|
dc.add_command(RestartCommand)
|
||||||
dc.add_command(ShutdownCommand)
|
dc.add_command(ShutdownCommand)
|
||||||
# moderator
|
""" events """
|
||||||
dc.add_command(PurgeCommand)
|
|
||||||
# simple
|
if self._feature_flags.base_module:
|
||||||
|
""" commands """
|
||||||
dc.add_command(AFKCommand)
|
dc.add_command(AFKCommand)
|
||||||
dc.add_command(HelpCommand)
|
dc.add_command(HelpCommand)
|
||||||
dc.add_command(InfoCommand)
|
dc.add_command(InfoCommand)
|
||||||
dc.add_command(PingCommand)
|
dc.add_command(PingCommand)
|
||||||
dc.add_command(UserInfoCommand)
|
dc.add_command(UserInfoCommand)
|
||||||
""" events """
|
""" events """
|
||||||
# on_command_error
|
dc.add_event(DiscordEventTypesEnum.on_command.value, BaseOnCommandEvent)
|
||||||
dc.add_event(DiscordEventTypesEnum.on_command_error.value, BaseOnCommandErrorEvent)
|
dc.add_event(DiscordEventTypesEnum.on_command_error.value, BaseOnCommandErrorEvent)
|
||||||
# on_member_join
|
|
||||||
dc.add_event(DiscordEventTypesEnum.on_member_join.value, BaseOnMemberJoinEvent)
|
dc.add_event(DiscordEventTypesEnum.on_member_join.value, BaseOnMemberJoinEvent)
|
||||||
# on_member_remove
|
|
||||||
dc.add_event(DiscordEventTypesEnum.on_member_join.value, BaseOnMemberRemoveEvent)
|
dc.add_event(DiscordEventTypesEnum.on_member_join.value, BaseOnMemberRemoveEvent)
|
||||||
# on_member_update
|
|
||||||
dc.add_event(DiscordEventTypesEnum.on_member_update.value, PermissionOnMemberUpdateEvent)
|
|
||||||
# on_message
|
|
||||||
dc.add_event(DiscordEventTypesEnum.on_message.value, BaseOnMessageEvent)
|
dc.add_event(DiscordEventTypesEnum.on_message.value, BaseOnMessageEvent)
|
||||||
# on_voice_state_update
|
|
||||||
dc.add_event(DiscordEventTypesEnum.on_voice_state_update.value, BaseOnVoiceStateUpdateEvent)
|
dc.add_event(DiscordEventTypesEnum.on_voice_state_update.value, BaseOnVoiceStateUpdateEvent)
|
||||||
# on_ready
|
|
||||||
|
if self._feature_flags.database_module:
|
||||||
|
""" commands """
|
||||||
|
""" events """
|
||||||
dc.add_event(DiscordEventTypesEnum.on_ready.value, DatabaseOnReadyEvent)
|
dc.add_event(DiscordEventTypesEnum.on_ready.value, DatabaseOnReadyEvent)
|
||||||
|
|
||||||
|
if self._feature_flags.moderator_module:
|
||||||
|
""" commands """
|
||||||
|
dc.add_command(PurgeCommand)
|
||||||
|
""" events """
|
||||||
|
|
||||||
|
if self._feature_flags.permission_module:
|
||||||
|
""" commands """
|
||||||
|
""" events """
|
||||||
dc.add_event(DiscordEventTypesEnum.on_ready.value, PermissionOnReadyEvent)
|
dc.add_event(DiscordEventTypesEnum.on_ready.value, PermissionOnReadyEvent)
|
||||||
dc.add_event(DiscordEventTypesEnum.on_ready.value, BootLogOnReadyEvent) # has to be last
|
dc.add_event(DiscordEventTypesEnum.on_member_update.value, PermissionOnMemberUpdateEvent)
|
||||||
|
|
||||||
|
# has to be last!
|
||||||
|
if self._feature_flags.boot_log_module:
|
||||||
|
""" commands """
|
||||||
|
""" events """
|
||||||
|
dc.add_event(DiscordEventTypesEnum.on_ready.value, BootLogOnReadyEvent)
|
||||||
|
52
src/bot/startup_settings_extension.py
Normal file
52
src/bot/startup_settings_extension.py
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
import os
|
||||||
|
from datetime import datetime
|
||||||
|
from typing import Callable, Type, Optional
|
||||||
|
|
||||||
|
from cpl_core.application import StartupExtensionABC
|
||||||
|
from cpl_core.configuration import ConfigurationABC
|
||||||
|
from cpl_core.dependency_injection import ServiceCollectionABC
|
||||||
|
from cpl_core.environment import ApplicationEnvironmentABC
|
||||||
|
from cpl_core.logging import LoggerABC
|
||||||
|
|
||||||
|
from bot_core.configuration.bot_logging_settings import BotLoggingSettings
|
||||||
|
from bot_core.configuration.bot_settings import BotSettings
|
||||||
|
from bot_core.logging.command_logger import CommandLogger
|
||||||
|
from bot_core.logging.database_logger import DatabaseLogger
|
||||||
|
from modules.base.configuration.base_settings import BaseSettings
|
||||||
|
from modules.boot_log.configuration.boot_log_settings import BootLogSettings
|
||||||
|
from modules.permission.configuration.permission_settings import PermissionSettings
|
||||||
|
|
||||||
|
|
||||||
|
class StartupSettingsExtension(StartupExtensionABC):
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
self._start_time = datetime.now()
|
||||||
|
|
||||||
|
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('DISCORD_')
|
||||||
|
|
||||||
|
configuration.add_json_file(f'config/appsettings.json', optional=False)
|
||||||
|
configuration.add_json_file(f'config/appsettings.{environment.environment_name}.json', optional=True)
|
||||||
|
configuration.add_json_file(f'config/appsettings.{environment.host_name}.json', optional=True)
|
||||||
|
|
||||||
|
configuration.add_configuration('Startup_StartTime', str(self._start_time))
|
||||||
|
self._configure_settings_with_sub_settings(configuration, BotSettings, lambda x: x.servers, lambda x: x.id)
|
||||||
|
self._configure_settings_with_sub_settings(configuration, BaseSettings, lambda x: x.servers, lambda x: x.id)
|
||||||
|
self._configure_settings_with_sub_settings(configuration, BootLogSettings, lambda x: x.servers, lambda x: x.id)
|
||||||
|
self._configure_settings_with_sub_settings(configuration, PermissionSettings, lambda x: x.servers, lambda x: x.id)
|
||||||
|
self._configure_settings_with_sub_settings(configuration, BotLoggingSettings, lambda x: x.files, lambda x: x.key)
|
||||||
|
|
||||||
|
def configure_services(self, services: ServiceCollectionABC, env: ApplicationEnvironmentABC):
|
||||||
|
pass
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def _configure_settings_with_sub_settings(config: ConfigurationABC, settings: Type, list_atr: Callable, atr: Callable):
|
||||||
|
settings: Optional[settings] = config.get_configuration(settings)
|
||||||
|
if settings is None:
|
||||||
|
return
|
||||||
|
|
||||||
|
for sub_settings in list_atr(settings):
|
||||||
|
config.add_configuration(f'{type(sub_settings).__name__}_{atr(sub_settings)}', sub_settings)
|
60
src/bot_core/abc/custom_file_logger_abc.py
Normal file
60
src/bot_core/abc/custom_file_logger_abc.py
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
from abc import ABC, abstractmethod
|
||||||
|
|
||||||
|
from cpl_core.configuration import ConfigurationABC
|
||||||
|
from cpl_core.environment import ApplicationEnvironmentABC
|
||||||
|
from cpl_core.logging import LoggingSettings, Logger, LoggingLevelEnum, LoggerABC
|
||||||
|
from cpl_core.time import TimeFormatSettings
|
||||||
|
|
||||||
|
from bot_core.configuration.file_logging_settings import FileLoggingSettings
|
||||||
|
|
||||||
|
|
||||||
|
class CustomFileLoggerABC(Logger, ABC):
|
||||||
|
|
||||||
|
@abstractmethod
|
||||||
|
def __init__(self, key: str, config: ConfigurationABC, time_format: TimeFormatSettings, env: ApplicationEnvironmentABC):
|
||||||
|
self._key = key
|
||||||
|
settings: LoggingSettings = config.get_configuration(f'{FileLoggingSettings.__name__}_{key}')
|
||||||
|
Logger.__init__(self, settings, time_format, env)
|
||||||
|
self._begin_log()
|
||||||
|
|
||||||
|
def _begin_log(self):
|
||||||
|
console_level = self._console.value
|
||||||
|
self._console = LoggingLevelEnum.OFF
|
||||||
|
self.info(__name__, f'Starting...')
|
||||||
|
self._console = LoggingLevelEnum(console_level)
|
||||||
|
|
||||||
|
def _get_string(self, name_list_as_str: str, level: LoggingLevelEnum, message: str) -> str:
|
||||||
|
names = name_list_as_str.split(' ')
|
||||||
|
log_level = level.name
|
||||||
|
string = f'<{self._get_datetime_now()}> [ {log_level} ]'
|
||||||
|
for name in names:
|
||||||
|
string += f' [ {name} ]'
|
||||||
|
string += f': {message}'
|
||||||
|
return string
|
||||||
|
|
||||||
|
def header(self, string: str):
|
||||||
|
super().header(string)
|
||||||
|
|
||||||
|
def trace(self, name: str, message: str):
|
||||||
|
name = f'{name} {self._key}'
|
||||||
|
super().trace(name, message)
|
||||||
|
|
||||||
|
def debug(self, name: str, message: str):
|
||||||
|
name = f'{name} {self._key}'
|
||||||
|
super().debug(name, message)
|
||||||
|
|
||||||
|
def info(self, name: str, message: str):
|
||||||
|
name = f'{name} {self._key}'
|
||||||
|
super().info(name, message)
|
||||||
|
|
||||||
|
def warn(self, name: str, message: str):
|
||||||
|
name = f'{name} {self._key}'
|
||||||
|
super().warn(name, message)
|
||||||
|
|
||||||
|
def error(self, name: str, message: str, ex: Exception = None):
|
||||||
|
name = f'{name} {self._key}'
|
||||||
|
super().error(name, message, ex)
|
||||||
|
|
||||||
|
def fatal(self, name: str, message: str, ex: Exception = None):
|
||||||
|
name = f'{name} {self._key}'
|
||||||
|
super().fatal(name, message, ex)
|
33
src/bot_core/configuration/bot_logging_settings.py
Normal file
33
src/bot_core/configuration/bot_logging_settings.py
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
import traceback
|
||||||
|
|
||||||
|
from cpl_core.configuration.configuration_model_abc import ConfigurationModelABC
|
||||||
|
from cpl_core.console import Console, ForegroundColorEnum
|
||||||
|
from cpl_query.extension import List
|
||||||
|
|
||||||
|
from bot_core.configuration.file_logging_settings import FileLoggingSettings
|
||||||
|
|
||||||
|
|
||||||
|
class BotLoggingSettings(ConfigurationModelABC):
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
ConfigurationModelABC.__init__(self)
|
||||||
|
self._files: List[FileLoggingSettings] = List(FileLoggingSettings)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def files(self) -> List[FileLoggingSettings]:
|
||||||
|
return self._files
|
||||||
|
|
||||||
|
def from_dict(self, settings: dict):
|
||||||
|
try:
|
||||||
|
files = List(FileLoggingSettings)
|
||||||
|
for s in settings:
|
||||||
|
st = FileLoggingSettings()
|
||||||
|
settings[s]['Key'] = s
|
||||||
|
st.from_dict(settings[s])
|
||||||
|
files.append(st)
|
||||||
|
self._files = files
|
||||||
|
except Exception as e:
|
||||||
|
Console.set_foreground_color(ForegroundColorEnum.red)
|
||||||
|
Console.write_line(f'[ ERROR ] [ {__name__} ]: Reading error in {type(self).__name__} settings')
|
||||||
|
Console.write_line(f'[ EXCEPTION ] [ {__name__} ]: {e} -> {traceback.format_exc()}')
|
||||||
|
Console.set_foreground_color(ForegroundColorEnum.default)
|
65
src/bot_core/configuration/feature_flags_settings.py
Normal file
65
src/bot_core/configuration/feature_flags_settings.py
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
import traceback
|
||||||
|
from typing import Optional
|
||||||
|
|
||||||
|
from cpl_core.configuration.configuration_model_abc import ConfigurationModelABC
|
||||||
|
from cpl_core.console import Console
|
||||||
|
|
||||||
|
|
||||||
|
class FeatureFlagsSettings(ConfigurationModelABC):
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
ConfigurationModelABC.__init__(self)
|
||||||
|
|
||||||
|
self._admin_module = False # 02.10.2022 #48
|
||||||
|
self._base_module = True # 02.10.2022 #48
|
||||||
|
self._boot_log_module = True # 02.10.2022 #48
|
||||||
|
self._database_module = True # 02.10.2022 #48
|
||||||
|
self._moderator_module = False # 02.10.2022 #48
|
||||||
|
self._permission_module = True # 02.10.2022 #48
|
||||||
|
|
||||||
|
@property
|
||||||
|
def admin_module(self) -> bool:
|
||||||
|
return self._admin_module
|
||||||
|
|
||||||
|
@property
|
||||||
|
def base_module(self) -> bool:
|
||||||
|
return self._base_module
|
||||||
|
|
||||||
|
@property
|
||||||
|
def boot_log_module(self) -> bool:
|
||||||
|
return self._boot_log_module
|
||||||
|
|
||||||
|
@property
|
||||||
|
def database_module(self) -> bool:
|
||||||
|
return self._database_module
|
||||||
|
|
||||||
|
@property
|
||||||
|
def moderator_module(self) -> bool:
|
||||||
|
return self._moderator_module
|
||||||
|
|
||||||
|
@property
|
||||||
|
def permission_module(self) -> bool:
|
||||||
|
return self._permission_module
|
||||||
|
|
||||||
|
def from_dict(self, settings: dict):
|
||||||
|
try:
|
||||||
|
if 'AdminModule' in settings:
|
||||||
|
self._admin_module = settings['AdminModule']
|
||||||
|
|
||||||
|
if 'BaseModule' in settings:
|
||||||
|
self._base_module = settings['BaseModule']
|
||||||
|
|
||||||
|
if 'BootLogModule' in settings:
|
||||||
|
self._boot_log_module = settings['BootLogModule']
|
||||||
|
|
||||||
|
if 'DatabaseModule' in settings:
|
||||||
|
self._database_module = settings['DatabaseModule']
|
||||||
|
|
||||||
|
if 'ModeratorModule' in settings:
|
||||||
|
self._moderator_module = settings['ModeratorModule']
|
||||||
|
|
||||||
|
if 'PermissionModule' in settings:
|
||||||
|
self._permission_module = settings['PermissionModule']
|
||||||
|
except Exception as e:
|
||||||
|
Console.error(f'[ ERROR ] [ {__name__} ]: Reading error in {type(self).__name__} settings')
|
||||||
|
Console.error(f'[ EXCEPTION ] [ {__name__} ]: {e} -> {traceback.format_exc()}')
|
24
src/bot_core/configuration/file_logging_settings.py
Normal file
24
src/bot_core/configuration/file_logging_settings.py
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
import traceback
|
||||||
|
|
||||||
|
from cpl_core.console import Console
|
||||||
|
from cpl_core.logging import LoggingSettings
|
||||||
|
|
||||||
|
|
||||||
|
class FileLoggingSettings(LoggingSettings):
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
LoggingSettings.__init__(self)
|
||||||
|
|
||||||
|
self._key = ''
|
||||||
|
|
||||||
|
@property
|
||||||
|
def key(self) -> str:
|
||||||
|
return self._key
|
||||||
|
|
||||||
|
def from_dict(self, settings: dict):
|
||||||
|
try:
|
||||||
|
self._key = settings['Key']
|
||||||
|
super().from_dict(settings)
|
||||||
|
except Exception as e:
|
||||||
|
Console.error(f'[ ERROR ] [ {__name__} ]: Reading error in {type(self).__name__} settings')
|
||||||
|
Console.error(f'[ EXCEPTION ] [ {__name__} ]: {e} -> {traceback.format_exc()}')
|
0
src/bot_core/helper/__init__.py
Normal file
0
src/bot_core/helper/__init__.py
Normal file
9
src/bot_core/helper/log_message_helper.py
Normal file
9
src/bot_core/helper/log_message_helper.py
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
import discord
|
||||||
|
|
||||||
|
|
||||||
|
class LogMessageHelper:
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def get_log_string(message: discord.Message):
|
||||||
|
content = message.content.replace("\n", "\n\t")
|
||||||
|
return f'{message.author} @ {message.channel} -> \n\t{content}'
|
1
src/bot_core/logging/__init__.py
Normal file
1
src/bot_core/logging/__init__.py
Normal file
@ -0,0 +1 @@
|
|||||||
|
# imports
|
11
src/bot_core/logging/command_logger.py
Normal file
11
src/bot_core/logging/command_logger.py
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
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 CommandLogger(CustomFileLoggerABC):
|
||||||
|
|
||||||
|
def __init__(self, config: ConfigurationABC, time_format: TimeFormatSettings, env: ApplicationEnvironmentABC):
|
||||||
|
CustomFileLoggerABC.__init__(self, 'Command', config, time_format, env)
|
11
src/bot_core/logging/database_logger.py
Normal file
11
src/bot_core/logging/database_logger.py
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
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 DatabaseLogger(CustomFileLoggerABC):
|
||||||
|
|
||||||
|
def __init__(self, config: ConfigurationABC, time_format: TimeFormatSettings, env: ApplicationEnvironmentABC):
|
||||||
|
CustomFileLoggerABC.__init__(self, 'Database', config, time_format, env)
|
11
src/bot_core/logging/message_logger.py
Normal file
11
src/bot_core/logging/message_logger.py
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
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 MessageLogger(CustomFileLoggerABC):
|
||||||
|
|
||||||
|
def __init__(self, config: ConfigurationABC, time_format: TimeFormatSettings, env: ApplicationEnvironmentABC):
|
||||||
|
CustomFileLoggerABC.__init__(self, 'Message', config, time_format, env)
|
@ -4,19 +4,20 @@ from typing import Union
|
|||||||
import discord
|
import discord
|
||||||
from cpl_core.configuration.configuration_abc import ConfigurationABC
|
from cpl_core.configuration.configuration_abc import ConfigurationABC
|
||||||
from cpl_core.database.context.database_context_abc import DatabaseContextABC
|
from cpl_core.database.context.database_context_abc import DatabaseContextABC
|
||||||
from cpl_core.logging import LoggerABC
|
|
||||||
from cpl_discord.service import DiscordBotServiceABC
|
from cpl_discord.service import DiscordBotServiceABC
|
||||||
from cpl_query.extension import List
|
from cpl_query.extension import List
|
||||||
from discord.ext.commands import Context
|
from discord.ext.commands import Context
|
||||||
|
|
||||||
from bot_core.abc.message_service_abc import MessageServiceABC
|
from bot_core.abc.message_service_abc import MessageServiceABC
|
||||||
from bot_core.configuration.server_settings import ServerSettings
|
from bot_core.configuration.server_settings import ServerSettings
|
||||||
|
from bot_core.helper.log_message_helper import LogMessageHelper
|
||||||
|
from bot_core.logging.message_logger import MessageLogger
|
||||||
from bot_data.abc.client_repository_abc import ClientRepositoryABC
|
from bot_data.abc.client_repository_abc import ClientRepositoryABC
|
||||||
|
|
||||||
|
|
||||||
class MessageService(MessageServiceABC):
|
class MessageService(MessageServiceABC):
|
||||||
|
|
||||||
def __init__(self, config: ConfigurationABC, logger: LoggerABC, bot: DiscordBotServiceABC, clients: ClientRepositoryABC, db: DatabaseContextABC):
|
def __init__(self, config: ConfigurationABC, logger: MessageLogger, bot: DiscordBotServiceABC, clients: ClientRepositoryABC, db: DatabaseContextABC):
|
||||||
self._config = config
|
self._config = config
|
||||||
self._logger = logger
|
self._logger = logger
|
||||||
self._bot = bot
|
self._bot = bot
|
||||||
@ -35,7 +36,7 @@ class MessageService(MessageServiceABC):
|
|||||||
server_st: ServerSettings = self._config.get_configuration(f'ServerSettings_{message.guild.id}')
|
server_st: ServerSettings = self._config.get_configuration(f'ServerSettings_{message.guild.id}')
|
||||||
if not mass_delete:
|
if not mass_delete:
|
||||||
await asyncio.sleep(server_st.message_delete_timer)
|
await asyncio.sleep(server_st.message_delete_timer)
|
||||||
self._logger.debug(__name__, f'Try to delete message:\n\t{message}\n\t{message.content}')
|
self._logger.debug(__name__, f'Try to delete message: {LogMessageHelper.get_log_string(message)}')
|
||||||
guild_id = message.guild.id
|
guild_id = message.guild.id
|
||||||
try:
|
try:
|
||||||
await message.delete()
|
await message.delete()
|
||||||
|
@ -1,11 +1,12 @@
|
|||||||
from cpl_core.database import DatabaseSettings
|
from cpl_core.database import DatabaseSettings
|
||||||
from cpl_core.database.context import DatabaseContext
|
from cpl_core.database.context import DatabaseContext
|
||||||
from cpl_core.logging import LoggerABC
|
|
||||||
|
from bot_core.logging.database_logger import DatabaseLogger
|
||||||
|
|
||||||
|
|
||||||
class DBContext(DatabaseContext):
|
class DBContext(DatabaseContext):
|
||||||
|
|
||||||
def __init__(self, logger: LoggerABC):
|
def __init__(self, logger: DatabaseLogger):
|
||||||
|
|
||||||
self._logger = logger
|
self._logger = logger
|
||||||
|
|
||||||
|
@ -1,12 +1,11 @@
|
|||||||
from cpl_core.logging import LoggerABC
|
from bot_core.logging.database_logger import DatabaseLogger
|
||||||
|
|
||||||
from bot_data.abc.migration_abc import MigrationABC
|
from bot_data.abc.migration_abc import MigrationABC
|
||||||
from bot_data.db_context import DBContext
|
from bot_data.db_context import DBContext
|
||||||
|
|
||||||
|
|
||||||
class InitialMigration(MigrationABC):
|
class InitialMigration(MigrationABC):
|
||||||
|
|
||||||
def __init__(self, logger: LoggerABC, db: DBContext):
|
def __init__(self, logger: DatabaseLogger, db: DBContext):
|
||||||
self._logger = logger
|
self._logger = logger
|
||||||
self._db = db
|
self._db = db
|
||||||
self._cursor = db.cursor
|
self._cursor = db.cursor
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
from typing import Optional
|
from typing import Optional
|
||||||
|
|
||||||
from cpl_core.database.context import DatabaseContextABC
|
from cpl_core.database.context import DatabaseContextABC
|
||||||
from cpl_core.logging import LoggerABC
|
|
||||||
from cpl_query.extension import List
|
from cpl_query.extension import List
|
||||||
|
|
||||||
|
from bot_core.logging.database_logger import DatabaseLogger
|
||||||
from bot_data.abc.client_repository_abc import ClientRepositoryABC
|
from bot_data.abc.client_repository_abc import ClientRepositoryABC
|
||||||
from bot_data.abc.server_repository_abc import ServerRepositoryABC
|
from bot_data.abc.server_repository_abc import ServerRepositoryABC
|
||||||
from bot_data.model.client import Client
|
from bot_data.model.client import Client
|
||||||
@ -10,7 +11,7 @@ from bot_data.model.client import Client
|
|||||||
|
|
||||||
class ClientRepositoryService(ClientRepositoryABC):
|
class ClientRepositoryService(ClientRepositoryABC):
|
||||||
|
|
||||||
def __init__(self, logger: LoggerABC, db_context: DatabaseContextABC, servers: ServerRepositoryABC):
|
def __init__(self, logger: DatabaseLogger, db_context: DatabaseContextABC, servers: ServerRepositoryABC):
|
||||||
self._logger = logger
|
self._logger = logger
|
||||||
self._context = db_context
|
self._context = db_context
|
||||||
|
|
||||||
|
@ -1,16 +1,17 @@
|
|||||||
from typing import Optional
|
from typing import Optional
|
||||||
from cpl_core.database.context import DatabaseContextABC
|
|
||||||
from cpl_core.logging import LoggerABC
|
|
||||||
from cpl_query.extension import List
|
|
||||||
from bot_data.abc.known_user_repository_abc import KnownUserRepositoryABC
|
|
||||||
|
|
||||||
|
from cpl_core.database.context import DatabaseContextABC
|
||||||
|
from cpl_query.extension import List
|
||||||
|
|
||||||
|
from bot_core.logging.database_logger import DatabaseLogger
|
||||||
|
from bot_data.abc.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.model.known_user import KnownUser
|
from bot_data.model.known_user import KnownUser
|
||||||
|
|
||||||
|
|
||||||
class KnownUserRepositoryService(KnownUserRepositoryABC):
|
class KnownUserRepositoryService(KnownUserRepositoryABC):
|
||||||
|
|
||||||
def __init__(self, logger: LoggerABC, db_context: DatabaseContextABC, servers: ServerRepositoryABC):
|
def __init__(self, logger: DatabaseLogger, db_context: DatabaseContextABC, servers: ServerRepositoryABC):
|
||||||
self._logger = logger
|
self._logger = logger
|
||||||
self._context = db_context
|
self._context = db_context
|
||||||
|
|
||||||
|
@ -2,15 +2,15 @@ from typing import Type
|
|||||||
|
|
||||||
from cpl_core.database.context import DatabaseContextABC
|
from cpl_core.database.context import DatabaseContextABC
|
||||||
from cpl_core.dependency_injection import ServiceProviderABC
|
from cpl_core.dependency_injection import ServiceProviderABC
|
||||||
from cpl_core.logging import LoggerABC
|
|
||||||
|
|
||||||
|
from bot_core.logging.database_logger import DatabaseLogger
|
||||||
from bot_data.abc.migration_abc import MigrationABC
|
from bot_data.abc.migration_abc import MigrationABC
|
||||||
from bot_data.model.migration_history import MigrationHistory
|
from bot_data.model.migration_history import MigrationHistory
|
||||||
|
|
||||||
|
|
||||||
class MigrationService:
|
class MigrationService:
|
||||||
|
|
||||||
def __init__(self, logger: LoggerABC, services: ServiceProviderABC, db: DatabaseContextABC):
|
def __init__(self, logger: DatabaseLogger, services: ServiceProviderABC, db: DatabaseContextABC):
|
||||||
self._logger = logger
|
self._logger = logger
|
||||||
self._services = services
|
self._services = services
|
||||||
|
|
||||||
@ -31,11 +31,10 @@ class MigrationService:
|
|||||||
# there is a table named "tableName"
|
# there is a table named "tableName"
|
||||||
self._logger.trace(__name__, f"Running SQL Command: {MigrationHistory.get_select_by_id_string(migration_id)}")
|
self._logger.trace(__name__, f"Running SQL Command: {MigrationHistory.get_select_by_id_string(migration_id)}")
|
||||||
migration_from_db = self._db.select(MigrationHistory.get_select_by_id_string(migration_id))
|
migration_from_db = self._db.select(MigrationHistory.get_select_by_id_string(migration_id))
|
||||||
self._logger.trace(__name__, str(migration_from_db))
|
|
||||||
if migration_from_db is not None and len(migration_from_db) > 0:
|
if migration_from_db is not None and len(migration_from_db) > 0:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
self._logger.debug(__name__, f"Running Migration {migration}")
|
self._logger.debug(__name__, f"Running Migration {migration_id}")
|
||||||
migration_as_service: MigrationABC = self._services.get_service(migration)
|
migration_as_service: MigrationABC = self._services.get_service(migration)
|
||||||
migration_as_service.upgrade()
|
migration_as_service.upgrade()
|
||||||
self._cursor.execute(MigrationHistory(migration_id).insert_string)
|
self._cursor.execute(MigrationHistory(migration_id).insert_string)
|
||||||
|
@ -1,15 +1,16 @@
|
|||||||
from typing import Optional
|
from typing import Optional
|
||||||
|
|
||||||
from cpl_core.database.context import DatabaseContextABC
|
from cpl_core.database.context import DatabaseContextABC
|
||||||
from cpl_core.logging import LoggerABC
|
|
||||||
from cpl_query.extension import List
|
from cpl_query.extension import List
|
||||||
|
|
||||||
|
from bot_core.logging.database_logger import DatabaseLogger
|
||||||
from bot_data.abc.server_repository_abc import ServerRepositoryABC
|
from bot_data.abc.server_repository_abc import ServerRepositoryABC
|
||||||
from bot_data.model.server import Server
|
from bot_data.model.server import Server
|
||||||
|
|
||||||
|
|
||||||
class ServerRepositoryService(ServerRepositoryABC):
|
class ServerRepositoryService(ServerRepositoryABC):
|
||||||
|
|
||||||
def __init__(self, logger: LoggerABC, db_context: DatabaseContextABC):
|
def __init__(self, logger: DatabaseLogger, db_context: DatabaseContextABC):
|
||||||
self._logger = logger
|
self._logger = logger
|
||||||
self._context = db_context
|
self._context = db_context
|
||||||
|
|
||||||
|
@ -1,18 +1,18 @@
|
|||||||
from typing import Optional
|
from typing import Optional
|
||||||
|
|
||||||
from cpl_core.database.context import DatabaseContextABC
|
from cpl_core.database.context import DatabaseContextABC
|
||||||
from cpl_core.logging import LoggerABC
|
|
||||||
from cpl_query.extension import List
|
from cpl_query.extension import List
|
||||||
|
|
||||||
|
from bot_core.logging.database_logger import DatabaseLogger
|
||||||
from bot_data.abc.user_joined_server_repository_abc import \
|
from bot_data.abc.user_joined_server_repository_abc import \
|
||||||
UserJoinedServerRepositoryABC
|
UserJoinedServerRepositoryABC
|
||||||
from bot_data.abc.user_repository_abc import UserRepositoryABC
|
from bot_data.abc.user_repository_abc import UserRepositoryABC
|
||||||
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
|
||||||
|
|
||||||
|
|
||||||
class UserJoinedServerRepositoryService(UserJoinedServerRepositoryABC):
|
class UserJoinedServerRepositoryService(UserJoinedServerRepositoryABC):
|
||||||
|
|
||||||
def __init__(self, logger: LoggerABC, db_context: DatabaseContextABC, users: UserRepositoryABC):
|
def __init__(self, logger: DatabaseLogger, db_context: DatabaseContextABC, users: UserRepositoryABC):
|
||||||
self._logger = logger
|
self._logger = logger
|
||||||
self._context = db_context
|
self._context = db_context
|
||||||
|
|
||||||
|
@ -1,17 +1,17 @@
|
|||||||
from typing import Optional
|
from typing import Optional
|
||||||
|
|
||||||
from cpl_core.database.context import DatabaseContextABC
|
from cpl_core.database.context import DatabaseContextABC
|
||||||
from cpl_core.logging import LoggerABC
|
|
||||||
from cpl_query.extension import List
|
from cpl_query.extension import List
|
||||||
|
|
||||||
|
from bot_core.logging.database_logger import DatabaseLogger
|
||||||
|
from bot_data.abc.user_joined_voice_channel_abc import UserJoinedVoiceChannelRepositoryABC
|
||||||
from bot_data.abc.user_repository_abc import UserRepositoryABC
|
from bot_data.abc.user_repository_abc import UserRepositoryABC
|
||||||
from bot_data.model.user_joined_voice_channel import UserJoinedVoiceChannel
|
from bot_data.model.user_joined_voice_channel import UserJoinedVoiceChannel
|
||||||
|
|
||||||
from bot_data.abc.user_joined_voice_channel_abc import UserJoinedVoiceChannelRepositoryABC
|
|
||||||
|
|
||||||
|
|
||||||
class UserJoinedVoiceChannelRepositoryService(UserJoinedVoiceChannelRepositoryABC):
|
class UserJoinedVoiceChannelRepositoryService(UserJoinedVoiceChannelRepositoryABC):
|
||||||
|
|
||||||
def __init__(self, logger: LoggerABC, db_context: DatabaseContextABC, users: UserRepositoryABC):
|
def __init__(self, logger: DatabaseLogger, db_context: DatabaseContextABC, users: UserRepositoryABC):
|
||||||
self._logger = logger
|
self._logger = logger
|
||||||
self._context = db_context
|
self._context = db_context
|
||||||
|
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
from typing import Optional
|
from typing import Optional
|
||||||
|
|
||||||
from cpl_core.database.context import DatabaseContextABC
|
from cpl_core.database.context import DatabaseContextABC
|
||||||
from cpl_core.logging import LoggerABC
|
|
||||||
from cpl_query.extension import List
|
from cpl_query.extension import List
|
||||||
|
|
||||||
|
from bot_core.logging.database_logger import DatabaseLogger
|
||||||
from bot_data.abc.server_repository_abc import ServerRepositoryABC
|
from bot_data.abc.server_repository_abc import ServerRepositoryABC
|
||||||
from bot_data.abc.user_repository_abc import UserRepositoryABC
|
from bot_data.abc.user_repository_abc import UserRepositoryABC
|
||||||
from bot_data.model.user import User
|
from bot_data.model.user import User
|
||||||
@ -10,7 +11,7 @@ from bot_data.model.user import User
|
|||||||
|
|
||||||
class UserRepositoryService(UserRepositoryABC):
|
class UserRepositoryService(UserRepositoryABC):
|
||||||
|
|
||||||
def __init__(self, logger: LoggerABC, db_context: DatabaseContextABC, servers: ServerRepositoryABC):
|
def __init__(self, logger: DatabaseLogger, db_context: DatabaseContextABC, servers: ServerRepositoryABC):
|
||||||
self._logger = logger
|
self._logger = logger
|
||||||
self._context = db_context
|
self._context = db_context
|
||||||
|
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
from cpl_core.configuration import ConfigurationABC
|
from cpl_core.configuration import ConfigurationABC
|
||||||
from cpl_core.logging import LoggerABC
|
|
||||||
from cpl_discord.command import DiscordCommandABC
|
from cpl_discord.command import DiscordCommandABC
|
||||||
from cpl_discord.service import DiscordBotServiceABC
|
from cpl_discord.service import DiscordBotServiceABC
|
||||||
from cpl_translation import TranslatePipe
|
from cpl_translation import TranslatePipe
|
||||||
@ -8,6 +7,7 @@ from discord.ext.commands import Context
|
|||||||
|
|
||||||
from bot_core.abc.client_utils_service_abc import ClientUtilsServiceABC
|
from bot_core.abc.client_utils_service_abc import ClientUtilsServiceABC
|
||||||
from bot_core.abc.message_service_abc import MessageServiceABC
|
from bot_core.abc.message_service_abc import MessageServiceABC
|
||||||
|
from bot_core.logging.command_logger import CommandLogger
|
||||||
from modules.permission.abc.permission_service_abc import PermissionServiceABC
|
from modules.permission.abc.permission_service_abc import PermissionServiceABC
|
||||||
|
|
||||||
|
|
||||||
@ -15,7 +15,7 @@ class RestartCommand(DiscordCommandABC):
|
|||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
logger: LoggerABC,
|
logger: CommandLogger,
|
||||||
config: ConfigurationABC,
|
config: ConfigurationABC,
|
||||||
message_service: MessageServiceABC,
|
message_service: MessageServiceABC,
|
||||||
bot: DiscordBotServiceABC,
|
bot: DiscordBotServiceABC,
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
from cpl_core.configuration import ConfigurationABC
|
from cpl_core.configuration import ConfigurationABC
|
||||||
from cpl_core.logging import LoggerABC
|
|
||||||
from cpl_discord.command import DiscordCommandABC
|
from cpl_discord.command import DiscordCommandABC
|
||||||
from cpl_discord.service import DiscordBotServiceABC
|
from cpl_discord.service import DiscordBotServiceABC
|
||||||
from cpl_translation import TranslatePipe
|
from cpl_translation import TranslatePipe
|
||||||
@ -8,6 +7,7 @@ from discord.ext.commands import Context
|
|||||||
|
|
||||||
from bot_core.abc.client_utils_service_abc import ClientUtilsServiceABC
|
from bot_core.abc.client_utils_service_abc import ClientUtilsServiceABC
|
||||||
from bot_core.abc.message_service_abc import MessageServiceABC
|
from bot_core.abc.message_service_abc import MessageServiceABC
|
||||||
|
from bot_core.logging.command_logger import CommandLogger
|
||||||
from modules.permission.abc.permission_service_abc import PermissionServiceABC
|
from modules.permission.abc.permission_service_abc import PermissionServiceABC
|
||||||
|
|
||||||
|
|
||||||
@ -15,7 +15,7 @@ class ShutdownCommand(DiscordCommandABC):
|
|||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
logger: LoggerABC,
|
logger: CommandLogger,
|
||||||
config: ConfigurationABC,
|
config: ConfigurationABC,
|
||||||
message_service: MessageServiceABC,
|
message_service: MessageServiceABC,
|
||||||
bot: DiscordBotServiceABC,
|
bot: DiscordBotServiceABC,
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
from cpl_core.configuration import ConfigurationABC
|
from cpl_core.configuration import ConfigurationABC
|
||||||
from cpl_core.logging import LoggerABC
|
|
||||||
from cpl_discord.command import DiscordCommandABC
|
from cpl_discord.command import DiscordCommandABC
|
||||||
from cpl_discord.service import DiscordBotServiceABC
|
from cpl_discord.service import DiscordBotServiceABC
|
||||||
from cpl_translation import TranslatePipe
|
from cpl_translation import TranslatePipe
|
||||||
@ -9,6 +8,7 @@ from discord.ext.commands import Context
|
|||||||
|
|
||||||
from bot_core.abc.client_utils_service_abc import ClientUtilsServiceABC
|
from bot_core.abc.client_utils_service_abc import ClientUtilsServiceABC
|
||||||
from bot_core.abc.message_service_abc import MessageServiceABC
|
from bot_core.abc.message_service_abc import MessageServiceABC
|
||||||
|
from bot_core.logging.command_logger import CommandLogger
|
||||||
from modules.base.configuration.base_server_settings import BaseServerSettings
|
from modules.base.configuration.base_server_settings import BaseServerSettings
|
||||||
|
|
||||||
|
|
||||||
@ -16,7 +16,7 @@ class AFKCommand(DiscordCommandABC):
|
|||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
logger: LoggerABC,
|
logger: CommandLogger,
|
||||||
config: ConfigurationABC,
|
config: ConfigurationABC,
|
||||||
message_service: MessageServiceABC,
|
message_service: MessageServiceABC,
|
||||||
bot: DiscordBotServiceABC,
|
bot: DiscordBotServiceABC,
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
from cpl_core.configuration import ConfigurationABC
|
from cpl_core.configuration import ConfigurationABC
|
||||||
from cpl_core.logging import LoggerABC
|
|
||||||
from cpl_discord.command import DiscordCommandABC
|
from cpl_discord.command import DiscordCommandABC
|
||||||
from cpl_discord.service import DiscordBotServiceABC
|
from cpl_discord.service import DiscordBotServiceABC
|
||||||
from discord.ext import commands
|
from discord.ext import commands
|
||||||
@ -7,6 +6,7 @@ from discord.ext.commands import Context
|
|||||||
|
|
||||||
from bot_core.abc.client_utils_service_abc import ClientUtilsServiceABC
|
from bot_core.abc.client_utils_service_abc import ClientUtilsServiceABC
|
||||||
from bot_core.abc.message_service_abc import MessageServiceABC
|
from bot_core.abc.message_service_abc import MessageServiceABC
|
||||||
|
from bot_core.logging.command_logger import CommandLogger
|
||||||
from modules.base.configuration.base_server_settings import BaseServerSettings
|
from modules.base.configuration.base_server_settings import BaseServerSettings
|
||||||
|
|
||||||
|
|
||||||
@ -15,7 +15,7 @@ class HelpCommand(DiscordCommandABC):
|
|||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
config: ConfigurationABC,
|
config: ConfigurationABC,
|
||||||
logger: LoggerABC,
|
logger: CommandLogger,
|
||||||
message_service: MessageServiceABC,
|
message_service: MessageServiceABC,
|
||||||
bot: DiscordBotServiceABC,
|
bot: DiscordBotServiceABC,
|
||||||
client_utils: ClientUtilsServiceABC
|
client_utils: ClientUtilsServiceABC
|
||||||
|
@ -2,7 +2,6 @@ from datetime import datetime
|
|||||||
|
|
||||||
import discord
|
import discord
|
||||||
from cpl_core.configuration import ConfigurationABC
|
from cpl_core.configuration import ConfigurationABC
|
||||||
from cpl_core.logging import LoggerABC
|
|
||||||
from cpl_discord.command import DiscordCommandABC
|
from cpl_discord.command import DiscordCommandABC
|
||||||
from cpl_discord.service import DiscordBotServiceABC
|
from cpl_discord.service import DiscordBotServiceABC
|
||||||
from cpl_translation import TranslatePipe
|
from cpl_translation import TranslatePipe
|
||||||
@ -12,6 +11,7 @@ from discord.ext.commands import Context
|
|||||||
import bot
|
import bot
|
||||||
from bot_core.abc.client_utils_service_abc import ClientUtilsServiceABC
|
from bot_core.abc.client_utils_service_abc import ClientUtilsServiceABC
|
||||||
from bot_core.abc.message_service_abc import MessageServiceABC
|
from bot_core.abc.message_service_abc import MessageServiceABC
|
||||||
|
from bot_core.logging.command_logger import CommandLogger
|
||||||
|
|
||||||
|
|
||||||
class InfoCommand(DiscordCommandABC):
|
class InfoCommand(DiscordCommandABC):
|
||||||
@ -19,7 +19,7 @@ class InfoCommand(DiscordCommandABC):
|
|||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
config: ConfigurationABC,
|
config: ConfigurationABC,
|
||||||
logger: LoggerABC,
|
logger: CommandLogger,
|
||||||
message_service: MessageServiceABC,
|
message_service: MessageServiceABC,
|
||||||
bot: DiscordBotServiceABC,
|
bot: DiscordBotServiceABC,
|
||||||
client_utils: ClientUtilsServiceABC,
|
client_utils: ClientUtilsServiceABC,
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
from cpl_core.logging import LoggerABC
|
|
||||||
from cpl_discord.command import DiscordCommandABC
|
from cpl_discord.command import DiscordCommandABC
|
||||||
from cpl_discord.service import DiscordBotServiceABC
|
from cpl_discord.service import DiscordBotServiceABC
|
||||||
from cpl_translation import TranslatePipe
|
from cpl_translation import TranslatePipe
|
||||||
@ -7,13 +6,14 @@ from discord.ext.commands import Context
|
|||||||
|
|
||||||
from bot_core.abc.client_utils_service_abc import ClientUtilsServiceABC
|
from bot_core.abc.client_utils_service_abc import ClientUtilsServiceABC
|
||||||
from bot_core.abc.message_service_abc import MessageServiceABC
|
from bot_core.abc.message_service_abc import MessageServiceABC
|
||||||
|
from bot_core.logging.command_logger import CommandLogger
|
||||||
|
|
||||||
|
|
||||||
class PingCommand(DiscordCommandABC):
|
class PingCommand(DiscordCommandABC):
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
logger: LoggerABC,
|
logger: CommandLogger,
|
||||||
message_service: MessageServiceABC,
|
message_service: MessageServiceABC,
|
||||||
bot: DiscordBotServiceABC,
|
bot: DiscordBotServiceABC,
|
||||||
client_utils: ClientUtilsServiceABC,
|
client_utils: ClientUtilsServiceABC,
|
||||||
|
@ -2,7 +2,6 @@ from typing import Optional
|
|||||||
|
|
||||||
import discord
|
import discord
|
||||||
from cpl_core.configuration import ConfigurationABC
|
from cpl_core.configuration import ConfigurationABC
|
||||||
from cpl_core.logging import LoggerABC
|
|
||||||
from cpl_discord.command import DiscordCommandABC
|
from cpl_discord.command import DiscordCommandABC
|
||||||
from cpl_discord.service import DiscordBotServiceABC
|
from cpl_discord.service import DiscordBotServiceABC
|
||||||
from cpl_translation import TranslatePipe
|
from cpl_translation import TranslatePipe
|
||||||
@ -11,6 +10,7 @@ from discord.ext.commands import Context
|
|||||||
|
|
||||||
from bot_core.abc.client_utils_service_abc import ClientUtilsServiceABC
|
from bot_core.abc.client_utils_service_abc import ClientUtilsServiceABC
|
||||||
from bot_core.abc.message_service_abc import MessageServiceABC
|
from bot_core.abc.message_service_abc import MessageServiceABC
|
||||||
|
from bot_core.logging.command_logger import CommandLogger
|
||||||
from bot_core.pipes.date_time_offset_pipe import DateTimeOffsetPipe
|
from bot_core.pipes.date_time_offset_pipe import DateTimeOffsetPipe
|
||||||
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
|
||||||
@ -23,7 +23,7 @@ class UserInfoCommand(DiscordCommandABC):
|
|||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
config: ConfigurationABC,
|
config: ConfigurationABC,
|
||||||
logger: LoggerABC,
|
logger: CommandLogger,
|
||||||
message_service: MessageServiceABC,
|
message_service: MessageServiceABC,
|
||||||
bot: DiscordBotServiceABC,
|
bot: DiscordBotServiceABC,
|
||||||
client_utils: ClientUtilsServiceABC,
|
client_utils: ClientUtilsServiceABC,
|
||||||
|
@ -2,6 +2,7 @@ import traceback
|
|||||||
|
|
||||||
from cpl_core.configuration.configuration_model_abc import ConfigurationModelABC
|
from cpl_core.configuration.configuration_model_abc import ConfigurationModelABC
|
||||||
from cpl_core.console import Console
|
from cpl_core.console import Console
|
||||||
|
from cpl_query.extension import List
|
||||||
|
|
||||||
|
|
||||||
class BaseServerSettings(ConfigurationModelABC):
|
class BaseServerSettings(ConfigurationModelABC):
|
||||||
@ -13,7 +14,9 @@ class BaseServerSettings(ConfigurationModelABC):
|
|||||||
self._max_voice_state_hours: int = 0
|
self._max_voice_state_hours: int = 0
|
||||||
self._xp_per_message: int = 0
|
self._xp_per_message: int = 0
|
||||||
self._xp_per_ontime_hour: int = 0
|
self._xp_per_ontime_hour: int = 0
|
||||||
self._afk_channel_ids: list[int] = []
|
self._afk_channel_ids: List[int] = List(int)
|
||||||
|
self._afk_command_channel_id: int = 0
|
||||||
|
self._help_command_reference_url: str = ''
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def id(self) -> int:
|
def id(self) -> int:
|
||||||
@ -32,7 +35,7 @@ class BaseServerSettings(ConfigurationModelABC):
|
|||||||
return self._xp_per_ontime_hour
|
return self._xp_per_ontime_hour
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def afk_channel_ids(self) -> list[int]:
|
def afk_channel_ids(self) -> List[int]:
|
||||||
return self._afk_channel_ids
|
return self._afk_channel_ids
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
90
src/modules/base/events/base_on_command_event.py
Normal file
90
src/modules/base/events/base_on_command_event.py
Normal file
@ -0,0 +1,90 @@
|
|||||||
|
from typing import Optional
|
||||||
|
|
||||||
|
import discord
|
||||||
|
from cpl_core.database.context import DatabaseContextABC
|
||||||
|
from cpl_core.time import TimeFormatSettings
|
||||||
|
from cpl_discord.events import OnCommandABC
|
||||||
|
from cpl_discord.service import DiscordBotServiceABC
|
||||||
|
from cpl_translation import TranslatePipe
|
||||||
|
from discord.ext.commands import Context
|
||||||
|
|
||||||
|
from bot_core.abc.message_service_abc import MessageServiceABC
|
||||||
|
from bot_core.configuration.bot_settings import BotSettings
|
||||||
|
from bot_core.logging.command_logger import CommandLogger
|
||||||
|
from bot_data.abc.client_repository_abc import ClientRepositoryABC
|
||||||
|
from bot_data.abc.server_repository_abc import ServerRepositoryABC
|
||||||
|
from bot_data.abc.user_repository_abc import UserRepositoryABC
|
||||||
|
from bot_data.model.user import User
|
||||||
|
from modules.base.abc.base_helper_abc import BaseHelperABC
|
||||||
|
from modules.base.configuration.base_server_settings import BaseServerSettings
|
||||||
|
|
||||||
|
|
||||||
|
class BaseOnCommandEvent(OnCommandABC):
|
||||||
|
|
||||||
|
def __init__(
|
||||||
|
self,
|
||||||
|
logger: CommandLogger,
|
||||||
|
bot: DiscordBotServiceABC,
|
||||||
|
messenger: MessageServiceABC,
|
||||||
|
bot_settings: BotSettings,
|
||||||
|
time_format_settings: TimeFormatSettings,
|
||||||
|
translate: TranslatePipe,
|
||||||
|
bhs: BaseHelperABC,
|
||||||
|
db: DatabaseContextABC,
|
||||||
|
users: UserRepositoryABC,
|
||||||
|
clients: ClientRepositoryABC,
|
||||||
|
servers: ServerRepositoryABC,
|
||||||
|
):
|
||||||
|
OnCommandABC.__init__(self)
|
||||||
|
self._logger = logger
|
||||||
|
self._bot = bot
|
||||||
|
self._messenger = messenger
|
||||||
|
self._bot_settings = bot_settings
|
||||||
|
self._time_format_settings = time_format_settings
|
||||||
|
self._t = translate
|
||||||
|
self._base_helper = bhs
|
||||||
|
self._db = db
|
||||||
|
self._users = users
|
||||||
|
self._clients = clients
|
||||||
|
self._servers = servers
|
||||||
|
|
||||||
|
def _append_received_message_count(self, g_id: int):
|
||||||
|
try:
|
||||||
|
self._clients.append_received_message_count(self._bot.user.id, g_id, 1)
|
||||||
|
self._db.save_changes()
|
||||||
|
except Exception as e:
|
||||||
|
self._logger.error(__name__, f'Cannot edit client {self._bot.user.id}@{g_id}', e)
|
||||||
|
|
||||||
|
def _handle_message_for_xp(self, message: discord.Message):
|
||||||
|
dc_user_id = message.author.id
|
||||||
|
try:
|
||||||
|
server = self._servers.get_server_by_discord_id(message.guild.id)
|
||||||
|
except Exception as e:
|
||||||
|
self._logger.error(__name__, f'Cannot get server {message.guild.id}', e)
|
||||||
|
return
|
||||||
|
|
||||||
|
user: Optional[User] = None
|
||||||
|
try:
|
||||||
|
user = self._users.get_user_by_discord_id_and_server_id(dc_user_id, server.server_id)
|
||||||
|
except Exception as e:
|
||||||
|
self._logger.error(__name__, f'Cannot get user {dc_user_id}', e)
|
||||||
|
return
|
||||||
|
|
||||||
|
if user is None:
|
||||||
|
self._logger.error(__name__, f'User not found {dc_user_id}')
|
||||||
|
return
|
||||||
|
|
||||||
|
settings: BaseServerSettings = self._base_helper.get_config(message.guild.id)
|
||||||
|
old_xp = user.xp
|
||||||
|
user.xp += settings.xp_per_message
|
||||||
|
self._users.update_user(user)
|
||||||
|
self._db.save_changes()
|
||||||
|
|
||||||
|
self._logger.debug(__name__, f'User {user} sent message. xp: from {old_xp} to {user.xp}')
|
||||||
|
|
||||||
|
async def on_command(self, ctx: Context):
|
||||||
|
self._logger.debug(__name__, f'Module {type(self)} started')
|
||||||
|
self._logger.info(__name__, f'Received command: {ctx.command} from {ctx.channel}')
|
||||||
|
if ctx is None or ctx.guild is None:
|
||||||
|
return
|
||||||
|
self._append_received_message_count(ctx.guild.id)
|
@ -2,10 +2,11 @@ from typing import Optional
|
|||||||
|
|
||||||
import discord
|
import discord
|
||||||
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 OnMessageABC
|
from cpl_discord.events import OnMessageABC
|
||||||
from cpl_discord.service import DiscordBotServiceABC
|
from cpl_discord.service import DiscordBotServiceABC
|
||||||
|
|
||||||
|
from bot_core.helper.log_message_helper import LogMessageHelper
|
||||||
|
from bot_core.logging.message_logger import MessageLogger
|
||||||
from bot_data.abc.client_repository_abc import ClientRepositoryABC
|
from bot_data.abc.client_repository_abc import ClientRepositoryABC
|
||||||
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
|
||||||
@ -18,7 +19,7 @@ class BaseOnMessageEvent(OnMessageABC):
|
|||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
logger: LoggerABC,
|
logger: MessageLogger,
|
||||||
bhs: BaseHelperABC,
|
bhs: BaseHelperABC,
|
||||||
db: DatabaseContextABC,
|
db: DatabaseContextABC,
|
||||||
bot: DiscordBotServiceABC,
|
bot: DiscordBotServiceABC,
|
||||||
@ -71,6 +72,7 @@ class BaseOnMessageEvent(OnMessageABC):
|
|||||||
|
|
||||||
async def on_message(self, message: discord.Message):
|
async def on_message(self, message: discord.Message):
|
||||||
self._logger.debug(__name__, f'Module {type(self)} started')
|
self._logger.debug(__name__, f'Module {type(self)} started')
|
||||||
|
self._logger.info(__name__, f'Received message: {LogMessageHelper.get_log_string(message)}')
|
||||||
if message is None or message.guild is None:
|
if message is None or message.guild is None:
|
||||||
return
|
return
|
||||||
self._append_received_message_count(message.guild.id)
|
self._append_received_message_count(message.guild.id)
|
||||||
|
@ -5,6 +5,8 @@ from cpl_core.configuration import ConfigurationABC
|
|||||||
from cpl_core.dependency_injection import ServiceProviderABC
|
from cpl_core.dependency_injection import ServiceProviderABC
|
||||||
from cpl_core.logging import LoggerABC
|
from cpl_core.logging import LoggerABC
|
||||||
|
|
||||||
|
from bot_core.configuration.feature_flags_settings import FeatureFlagsSettings
|
||||||
|
|
||||||
|
|
||||||
class BootLogExtension(ApplicationExtensionABC):
|
class BootLogExtension(ApplicationExtensionABC):
|
||||||
|
|
||||||
@ -12,6 +14,9 @@ class BootLogExtension(ApplicationExtensionABC):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
async def run(self, config: ConfigurationABC, services: ServiceProviderABC):
|
async def run(self, config: ConfigurationABC, services: ServiceProviderABC):
|
||||||
|
feature_flags: FeatureFlagsSettings = config.get_configuration(FeatureFlagsSettings)
|
||||||
|
if not feature_flags.boot_log_module:
|
||||||
|
return
|
||||||
logger: LoggerABC = services.get_service(LoggerABC)
|
logger: LoggerABC = services.get_service(LoggerABC)
|
||||||
logger.debug(__name__, 'BootLog extension started')
|
logger.debug(__name__, 'BootLog extension started')
|
||||||
config.add_configuration('Bot_StartTime', str(datetime.now()))
|
config.add_configuration('Bot_StartTime', str(datetime.now()))
|
||||||
|
@ -42,12 +42,12 @@ class BootLogOnReadyEvent(OnReadyABC):
|
|||||||
# print warning if initialisation took too long
|
# print warning if initialisation took too long
|
||||||
if init_time >= 30:
|
if init_time >= 30:
|
||||||
self._logger.warn(
|
self._logger.warn(
|
||||||
__name__, 'It takes long time to start the bot!')
|
__name__, 'It takes too long to start the bot!')
|
||||||
|
|
||||||
# print error if initialisation took way too long
|
# print error if initialisation took way too long
|
||||||
elif init_time >= 90:
|
elif init_time >= 90:
|
||||||
self._logger.error(
|
self._logger.error(
|
||||||
__name__, 'It takes very long time to start the bot!!!')
|
__name__, 'It takes far too long to start the bot!!!')
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
self._logger.error(__name__, 'Init time calculation failed', e)
|
self._logger.error(__name__, 'Init time calculation failed', e)
|
||||||
return
|
return
|
||||||
|
@ -5,6 +5,8 @@ from cpl_core.configuration import ConfigurationABC
|
|||||||
from cpl_core.dependency_injection import ServiceProviderABC
|
from cpl_core.dependency_injection import ServiceProviderABC
|
||||||
from cpl_core.logging import LoggerABC
|
from cpl_core.logging import LoggerABC
|
||||||
|
|
||||||
|
from bot_core.configuration.feature_flags_settings import FeatureFlagsSettings
|
||||||
|
from bot_core.logging.database_logger import DatabaseLogger
|
||||||
from bot_data.service.migration_service import MigrationService
|
from bot_data.service.migration_service import MigrationService
|
||||||
|
|
||||||
|
|
||||||
@ -14,7 +16,10 @@ class DatabaseExtension(ApplicationExtensionABC):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
async def run(self, config: ConfigurationABC, services: ServiceProviderABC):
|
async def run(self, config: ConfigurationABC, services: ServiceProviderABC):
|
||||||
logger: LoggerABC = services.get_service(LoggerABC)
|
feature_flags: FeatureFlagsSettings = config.get_configuration(FeatureFlagsSettings)
|
||||||
|
if not feature_flags.database_module:
|
||||||
|
return
|
||||||
|
logger: LoggerABC = services.get_service(DatabaseLogger)
|
||||||
logger.debug(__name__, 'Database extension started')
|
logger.debug(__name__, 'Database extension started')
|
||||||
config.add_configuration('Database_StartTime', str(datetime.now()))
|
config.add_configuration('Database_StartTime', str(datetime.now()))
|
||||||
migrations: MigrationService = services.get_service(MigrationService)
|
migrations: MigrationService = services.get_service(MigrationService)
|
||||||
|
@ -4,10 +4,10 @@ from datetime import datetime, timedelta
|
|||||||
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 OnReadyABC
|
from cpl_discord.events import OnReadyABC
|
||||||
from cpl_discord.service import DiscordBotServiceABC
|
from cpl_discord.service import DiscordBotServiceABC
|
||||||
|
|
||||||
|
from bot_core.logging.database_logger import DatabaseLogger
|
||||||
from bot_core.pipes.date_time_offset_pipe import DateTimeOffsetPipe
|
from bot_core.pipes.date_time_offset_pipe import DateTimeOffsetPipe
|
||||||
from bot_data.abc.client_repository_abc import ClientRepositoryABC
|
from bot_data.abc.client_repository_abc import ClientRepositoryABC
|
||||||
from bot_data.abc.known_user_repository_abc import KnownUserRepositoryABC
|
from bot_data.abc.known_user_repository_abc import KnownUserRepositoryABC
|
||||||
@ -29,7 +29,7 @@ class DatabaseOnReadyEvent(OnReadyABC):
|
|||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
config: ConfigurationABC,
|
config: ConfigurationABC,
|
||||||
logger: LoggerABC,
|
logger: DatabaseLogger,
|
||||||
bot: DiscordBotServiceABC,
|
bot: DiscordBotServiceABC,
|
||||||
db_context: DatabaseContextABC,
|
db_context: DatabaseContextABC,
|
||||||
server_repo: ServerRepositoryABC,
|
server_repo: ServerRepositoryABC,
|
||||||
@ -65,12 +65,12 @@ class DatabaseOnReadyEvent(OnReadyABC):
|
|||||||
# print warning if initialisation took too long
|
# print warning if initialisation took too long
|
||||||
if init_time >= 30:
|
if init_time >= 30:
|
||||||
self._logger.warn(
|
self._logger.warn(
|
||||||
__name__, 'It takes long time to start the bot!')
|
__name__, 'It takes too long to prepare the database!')
|
||||||
|
|
||||||
# print error if initialisation took way too long
|
# print error if initialisation took way too long
|
||||||
elif init_time >= 90:
|
elif init_time >= 90:
|
||||||
self._logger.error(
|
self._logger.error(
|
||||||
__name__, 'It takes very long time to start the bot!!!')
|
__name__, 'It takes far too long to prepare the database!!!')
|
||||||
except Exception as e: #
|
except Exception as e: #
|
||||||
self._logger.error(__name__, 'Database init time calculation failed', e)
|
self._logger.error(__name__, 'Database init time calculation failed', e)
|
||||||
return
|
return
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
import asyncio
|
import asyncio
|
||||||
|
|
||||||
from cpl_core.configuration import ConfigurationABC
|
from cpl_core.configuration import ConfigurationABC
|
||||||
from cpl_core.logging import LoggerABC
|
|
||||||
from cpl_discord.command import DiscordCommandABC
|
from cpl_discord.command import DiscordCommandABC
|
||||||
from cpl_translation import TranslatePipe
|
from cpl_translation import TranslatePipe
|
||||||
from discord.ext import commands
|
from discord.ext import commands
|
||||||
@ -10,6 +9,7 @@ from discord.ext.commands import Context
|
|||||||
from bot_core.abc.client_utils_service_abc import ClientUtilsServiceABC
|
from bot_core.abc.client_utils_service_abc import ClientUtilsServiceABC
|
||||||
from bot_core.abc.message_service_abc import MessageServiceABC
|
from bot_core.abc.message_service_abc import MessageServiceABC
|
||||||
from bot_core.configuration.server_settings import ServerSettings
|
from bot_core.configuration.server_settings import ServerSettings
|
||||||
|
from bot_core.logging.command_logger import CommandLogger
|
||||||
from modules.permission.abc.permission_service_abc import PermissionServiceABC
|
from modules.permission.abc.permission_service_abc import PermissionServiceABC
|
||||||
|
|
||||||
|
|
||||||
@ -17,7 +17,7 @@ class PurgeCommand(DiscordCommandABC):
|
|||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
logger: LoggerABC,
|
logger: CommandLogger,
|
||||||
config: ConfigurationABC,
|
config: ConfigurationABC,
|
||||||
message_service: MessageServiceABC,
|
message_service: MessageServiceABC,
|
||||||
permissions: PermissionServiceABC,
|
permissions: PermissionServiceABC,
|
||||||
|
Loading…
Reference in New Issue
Block a user