diff --git a/src/modules_core/abc/module_abc.py b/src/modules_core/abc/module_abc.py index a970850..d860319 100644 --- a/src/modules_core/abc/module_abc.py +++ b/src/modules_core/abc/module_abc.py @@ -1,14 +1,21 @@ from abc import ABC, abstractmethod -import discord class ModuleABC(ABC): @abstractmethod def __init__(self): self._priorities = {} + self._success = True def get_priority(self, t: type) -> int: if t not in self._priorities: raise Exception(f'Priority for {t} not found!') return self._priorities[t] + + def stop_propagation(self): + self._success = False + + @property + def success(self) -> bool: + return self._success diff --git a/src/modules_core/service/module_service.py b/src/modules_core/service/module_service.py index 9760cf3..ddcbf56 100644 --- a/src/modules_core/service/module_service.py +++ b/src/modules_core/service/module_service.py @@ -84,15 +84,18 @@ class ModuleService(ModuleServiceABC, commands.Cog, metaclass=_MetaCogABC): modules = self._get_modules(event) if modules.count() < 1: - self._logger.debug(__name__, f'Stopped {event} modules') + self._logger.debug(__name__, f'Stopped {event} modules') return func_name = String.convert_to_snake_case(event.__name__.split('ABC')[0]) for module in modules: func = getattr(module, func_name) await func(*args) + if not module.success: + self._logger.debug(__name__, f'Stopped progation for {event} from {type(module)}') + break - self._logger.debug(__name__, f'Stopped {event} modules') + self._logger.debug(__name__, f'Stopped {event} modules') @commands.Cog.listener() async def on_connect(self):