0.3.1 #187
@ -44,7 +44,8 @@ class Application(DiscordBotApplicationABC):
|
||||
try:
|
||||
self._logger.debug(__name__, f'Starting...')
|
||||
|
||||
if self._feature_flags.get_flag(FeatureFlagsEnum.api_module) and self._feature_flags.get_flag(FeatureFlagsEnum.api_only) and self._environment.environment_name == 'development':
|
||||
if self._feature_flags.get_flag(FeatureFlagsEnum.api_module) and self._feature_flags.get_flag(
|
||||
FeatureFlagsEnum.api_only) and self._environment.environment_name == 'development':
|
||||
self._api.start()
|
||||
self._api.join()
|
||||
return
|
||||
|
@ -16,10 +16,10 @@
|
||||
"LicenseName": "MIT",
|
||||
"LicenseDescription": "MIT, see LICENSE for more details.",
|
||||
"Dependencies": [
|
||||
"cpl-core==2022.12.0",
|
||||
"cpl-translation==2022.10.0.post2",
|
||||
"cpl-query==2022.12.2",
|
||||
"cpl-discord==2022.12.0",
|
||||
"cpl-core==2022.12.1.post2",
|
||||
"cpl-translation==2022.12.1",
|
||||
"cpl-query==2022.12.2.post1",
|
||||
"cpl-discord==2022.12.1.post1",
|
||||
"Flask==2.2.2",
|
||||
"Flask-Classful==0.14.2",
|
||||
"Flask-Cors==3.0.10",
|
||||
@ -31,7 +31,7 @@
|
||||
"icmplib==3.0.3"
|
||||
],
|
||||
"DevDependencies": [
|
||||
"cpl-cli==2022.12.0"
|
||||
"cpl-cli==2022.12.1.post2"
|
||||
],
|
||||
"PythonVersion": ">=3.10.4",
|
||||
"PythonPath": {},
|
||||
|
0
kdb-bot/src/bot/extension/__init__.py
Normal file
0
kdb-bot/src/bot/extension/__init__.py
Normal file
20
kdb-bot/src/bot/extension/init_bot_extension.py
Normal file
20
kdb-bot/src/bot/extension/init_bot_extension.py
Normal file
@ -0,0 +1,20 @@
|
||||
from cpl_core.application import ApplicationExtensionABC
|
||||
from cpl_core.configuration import ConfigurationABC
|
||||
from cpl_core.dependency_injection import ServiceProviderABC
|
||||
from cpl_discord.service import DiscordBotServiceABC
|
||||
|
||||
from bot_core.configuration.bot_settings import BotSettings
|
||||
|
||||
|
||||
class InitBotExtension(ApplicationExtensionABC):
|
||||
|
||||
def __init__(self):
|
||||
ApplicationExtensionABC.__init__(self)
|
||||
|
||||
async def run(self, config: ConfigurationABC, services: ServiceProviderABC):
|
||||
settings = config.get_configuration(BotSettings)
|
||||
|
||||
bot: DiscordBotServiceABC = services.get_service(
|
||||
DiscordBotServiceABC,
|
||||
max_messages=settings.cache_max_messages
|
||||
)
|
@ -6,6 +6,7 @@ from cpl_core.application import ApplicationBuilder
|
||||
from cpl_core.console import Console
|
||||
|
||||
from bot.application import Application
|
||||
from bot.extension.init_bot_extension import InitBotExtension
|
||||
from bot.startup import Startup
|
||||
from bot.startup_discord_extension import StartupDiscordExtension
|
||||
from bot.startup_migration_extension import StartupMigrationExtension
|
||||
@ -29,6 +30,7 @@ class Program:
|
||||
.use_extension(StartupDiscordExtension) \
|
||||
.use_extension(StartupModuleExtension) \
|
||||
.use_extension(StartupMigrationExtension) \
|
||||
.use_extension(InitBotExtension) \
|
||||
.use_extension(BootLogExtension) \
|
||||
.use_extension(DatabaseExtension) \
|
||||
.use_extension(AppApiExtension) \
|
||||
|
@ -16,6 +16,7 @@ class BotSettings(ConfigurationModelABC):
|
||||
self._technicians: List[int] = List(int)
|
||||
self._wait_for_restart = 2
|
||||
self._wait_for_shutdown = 2
|
||||
self._cache_max_messages = 1000
|
||||
|
||||
@property
|
||||
def servers(self) -> List[ServerSettings]:
|
||||
@ -33,6 +34,10 @@ class BotSettings(ConfigurationModelABC):
|
||||
def wait_for_shutdown(self) -> int:
|
||||
return self._wait_for_shutdown
|
||||
|
||||
@property
|
||||
def cache_max_messages(self) -> int:
|
||||
return self._cache_max_messages
|
||||
|
||||
def from_dict(self, settings: dict):
|
||||
try:
|
||||
self._technicians = settings["Technicians"]
|
||||
@ -41,6 +46,11 @@ class BotSettings(ConfigurationModelABC):
|
||||
settings.pop("Technicians")
|
||||
settings.pop("WaitForRestart")
|
||||
settings.pop("WaitForShutdown")
|
||||
|
||||
if 'CacheMaxMessages' in settings:
|
||||
self._cache_max_messages = settings["CacheMaxMessages"]
|
||||
settings.pop("CacheMaxMessages")
|
||||
|
||||
servers = List(ServerSettings)
|
||||
for s in settings:
|
||||
st = ServerSettings()
|
||||
|
Loading…
Reference in New Issue
Block a user