Added support for dynamic loaded modules
This commit is contained in:
1
src/gismo_core/service/__init__.py
Normal file
1
src/gismo_core/service/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
# imports
|
36
src/gismo_core/service/bot_service.py
Normal file
36
src/gismo_core/service/bot_service.py
Normal file
@@ -0,0 +1,36 @@
|
||||
from cpl_core.logging import LoggerABC
|
||||
from discord.ext import commands
|
||||
|
||||
from gismo_core.abc.bot_service_abc import BotServiceABC
|
||||
from gismo_core.configuration.bot_settings import BotSettings
|
||||
from gismo_core.configuration.discord_settings import DiscordSettings
|
||||
from modules_core.abc.module_service_abc import ModuleServiceABC
|
||||
|
||||
|
||||
class BotService(BotServiceABC, commands.Bot):
|
||||
|
||||
def __init__(self, logger: LoggerABC, modules: ModuleServiceABC, discord_settings: DiscordSettings, bot_settings: BotSettings):
|
||||
# services
|
||||
self._logger = logger
|
||||
self._modules = modules
|
||||
|
||||
# settings
|
||||
self._discord_settings = discord_settings
|
||||
self._bot_settings: BotSettings = bot_settings
|
||||
|
||||
# setup super
|
||||
commands.Bot.__init__(self, command_prefix=bot_settings.prefix, help_command=None)
|
||||
|
||||
async def start_async(self):
|
||||
self._modules.start_modules()
|
||||
self.run(self._discord_settings.token)
|
||||
# continue at on_ready
|
||||
|
||||
async def stop_async(self):
|
||||
try:
|
||||
pass
|
||||
# save data
|
||||
except Exception as e:
|
||||
self._logger.error(__name__, 'Stop failed', e)
|
||||
|
||||
async def on_ready(self): pass
|
Reference in New Issue
Block a user