aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/infini/handler.py12
-rw-r--r--src/infini/matcher.py4
2 files changed, 6 insertions, 10 deletions
diff --git a/src/infini/handler.py b/src/infini/handler.py
index 1edef9fa..8f50fc8c 100644
--- a/src/infini/handler.py
+++ b/src/infini/handler.py
@@ -10,18 +10,12 @@ class Result(metaclass=ABCMeta):
event: str
status: bool
- exception: HydroError | None = None
+ kwargs: dict = {}
- def __init__(
- self, event: str, status: bool, exception: HydroError | None = None
- ) -> None:
+ def __init__(self, event: str, status: bool, **kwargs) -> None:
self.event = event
self.status = status
- self.exception = exception
-
- def ok(self):
- """规则执行期间是否产生异常"""
- return isinstance(self.exception, HydroError)
+ self.kwargs = kwargs
class Handler:
diff --git a/src/infini/matcher.py b/src/infini/matcher.py
index 1a6bfe45..d7cfa336 100644
--- a/src/infini/matcher.py
+++ b/src/infini/matcher.py
@@ -37,7 +37,9 @@ class Matcher:
def run(self, event: MatcherEvent) -> str:
result = self.match(event.name).process(**event.kwargs)
- return self.events.process(result.event, **event.kwargs)
+ return self.events.process(
+ result.event, **result.kwargs if result.kwargs else event.kwargs
+ )
matcher = Matcher()