Added support for dynamic loaded modules
This commit is contained in:
@@ -4,19 +4,27 @@ 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, discord_settings: DiscordSettings, bot_settings: BotSettings):
|
||||
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 self
|
||||
|
||||
# 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:
|
||||
@@ -24,3 +32,5 @@ class BotService(BotServiceABC, commands.Bot):
|
||||
# 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