From 23ab264ebe52bd050e02c5c6a009645a252a5ea0 Mon Sep 17 00:00:00 2001 From: 简律纯 Date: Sat, 29 Jun 2024 16:23:44 +0800 Subject: refactor(rule): change self.state with self.core.rule_state logic --- hrc/rule/__init__.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/hrc/rule/__init__.py b/hrc/rule/__init__.py index f04dbba..a41c81d 100644 --- a/hrc/rule/__init__.py +++ b/hrc/rule/__init__.py @@ -105,7 +105,7 @@ class Rule(ABC, Generic[EventT, StateT, ConfigT]): @property def core(self) -> "Core": """core object.""" - return self.event.bot # pylint: disable=no-member + return self.event.core # pylint: disable=no-member @final @property @@ -133,19 +133,19 @@ class Rule(ABC, Generic[EventT, StateT, ConfigT]): @property def state(self) -> StateT: - """plugin status.""" - return self.bot.plugin_state[self.name] + """rule status.""" + return self.core.rule_state[self.name] @state.setter @final def state(self, value: StateT) -> None: - self.bot.plugin_state[self.name] = value + self.core.rule_state[self.name] = value @abstractmethod async def handle(self) -> None: """Method to handle events. iamai will call this method when the ``rule()`` method returns ``True``. Each plugin must implement this method.""" raise NotImplementedError - + @abstractmethod async def rule(self) -> bool: """Method to match the event. When the event is processed, this method will be called in sequence according to the priority of the plugin. When this method returns ``True``, the event will be handed over to this plugin for processing. Each plugin must implement this method. -- cgit v1.2.3-70-g09d2