diff --git a/cpl-workspace.json b/cpl-workspace.json index b0db2c0..891044f 100644 --- a/cpl-workspace.json +++ b/cpl-workspace.json @@ -10,7 +10,8 @@ "boot-log": "src/modules/boot_log/boot-log.json", "level-generator": "tools/level_generator/level-generator.json", "ontime-calculator": "tools/ontime_calculator/ontime-calculator.json", - "database": "src/modules/database/database.json" + "database": "src/modules/database/database.json", + "base": "src/modules/base/base.json" }, "Scripts": { "build-start": "cd src/gismo_cli; echo 'gismo-cli:'; cpl build; cd ../gismo; echo 'gismo:'; cpl build; cd ../../dist/gismo/build/gismo; bash gismo", diff --git a/src/gismo/startup.py b/src/gismo/startup.py index f359a18..3d2d05f 100644 --- a/src/gismo/startup.py +++ b/src/gismo/startup.py @@ -18,6 +18,7 @@ from gismo_data.abc.user_repository_abc import UserRepositoryABC from gismo_data.db_context import DBContext from gismo_data.service.server_repository_service import ServerRepositoryService from gismo_data.service.user_repository_service import UserRepositoryService +from modules.base.base import Base from modules.boot_log.boot_log import BootLog from modules.database.database import Database from modules_core.abc.module_abc import ModuleABC @@ -59,6 +60,7 @@ class Startup(StartupABC): services.add_transient(UserRepositoryABC, UserRepositoryService) services.add_transient(ModuleABC, Database) + services.add_transient(ModuleABC, Base) services.add_transient(ModuleABC, BootLog) provider: ServiceProviderABC = services.build_service_provider() diff --git a/src/modules/base/__init__.py b/src/modules/base/__init__.py new file mode 100644 index 0000000..ad5eca3 --- /dev/null +++ b/src/modules/base/__init__.py @@ -0,0 +1 @@ +# imports: diff --git a/src/modules/base/base.json b/src/modules/base/base.json new file mode 100644 index 0000000..7c5150a --- /dev/null +++ b/src/modules/base/base.json @@ -0,0 +1,43 @@ +{ + "ProjectSettings": { + "Name": "modules/base", + "Version": { + "Major": "0", + "Minor": "0", + "Micro": "0" + }, + "Author": "", + "AuthorEmail": "", + "Description": "", + "LongDescription": "", + "URL": "", + "CopyrightDate": "", + "CopyrightName": "", + "LicenseName": "", + "LicenseDescription": "", + "Dependencies": [ + "sh_cpl-core>=2021.11.0.post1" + ], + "PythonVersion": ">=3.9.2", + "PythonPath": { + "linux": "" + }, + "Classifiers": [] + }, + "BuildSettings": { + "ProjectType": "library", + "SourcePath": "", + "OutputPath": "../../dist", + "Main": "modules/base.main", + "EntryPoint": "modules/base", + "IncludePackageData": false, + "Included": [], + "Excluded": [ + "*/__pycache__", + "*/logs", + "*/tests" + ], + "PackageData": {}, + "ProjectReferences": [] + } +} \ No newline at end of file diff --git a/src/modules/base/base.py b/src/modules/base/base.py new file mode 100644 index 0000000..530b3cd --- /dev/null +++ b/src/modules/base/base.py @@ -0,0 +1,29 @@ +import discord +from cpl_core.logging.logger_abc import LoggerABC + +from modules_core.abc.events.on_member_join_abc import OnMemberJoinABC +from modules_core.abc.events.on_message_abc import OnMessageABC +from modules_core.abc.events.on_voice_state_update_abc import OnVoiceStateUpdateABC +from modules_core.abc.module_abc import ModuleABC + + +class Base(ModuleABC, OnMemberJoinABC, OnMessageABC, OnVoiceStateUpdateABC): + + def __init__(self, logger: LoggerABC): + + self._logger = logger + + ModuleABC.__init__(self) + self._priorities[OnMemberJoinABC] = 1 + self._priorities[OnMessageABC] = 30 + self._priorities[OnVoiceStateUpdateABC] = 10 + self._logger.trace(__name__, f'Module {type(self)} loaded') + + async def on_member_join(self, member: discord.Member): + self._logger.debug(__name__, f'Module {type(self)} started') + + async def on_message(self, message: discord.Message): + self._logger.debug(__name__, f'Module {type(self)} started') + + async def on_voice_state_update(self, member: discord.Member, before: discord.VoiceState, after: discord.VoiceState): + self._logger.debug(__name__, f'Module {type(self)} started')