aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
author苏向夜 <fu050409@163.com>2023-12-16 20:05:11 +0800
committer苏向夜 <fu050409@163.com>2023-12-16 20:05:11 +0800
commit0680f2f8de507236966ed9ac3ae692f009f2de8f (patch)
treeace5f343c4d98836c779c34b3c945521873eac56
parent0ed002af9a90cbdaadb2fdf554f656fe7a0aecd2 (diff)
downloadinfini-0680f2f8de507236966ed9ac3ae692f009f2de8f.tar.gz
infini-0680f2f8de507236966ed9ac3ae692f009f2de8f.zip
:sparkles: 更新事件基类声明
-rw-r--r--src/infini/event.py28
1 files changed, 22 insertions, 6 deletions
diff --git a/src/infini/event.py b/src/infini/event.py
index a83c4042..659ae73e 100644
--- a/src/infini/event.py
+++ b/src/infini/event.py
@@ -1,4 +1,3 @@
-from abc import ABCMeta
from .typing import Dict
from .exceptions import UnknownMessageEvent
@@ -7,6 +6,12 @@ import re
__all__ = ["MessageEvent", "events"]
+class InfiniEvent:
+ """Inifni 事件基类"""
+
+ name: str
+
+
class Events:
"""事件集合"""
@@ -30,20 +35,31 @@ class Events:
return string
-class MessageEvent(metaclass=ABCMeta):
- """消息事件基类"""
+class MessageEvent(InfiniEvent):
+ """Message 事件"""
name: str
output: str
- def __init_subclass__(cls) -> None:
- events.regist(cls.name, cls.output)
+ def __repr__(self) -> str:
+ return f"<MessageEvent [{self.name}]>"
+
+
+class WorkflowEvent(InfiniEvent):
+ """Workflow 事件"""
+
+ name: str
+ kwargs: dict
+
+ def __repr__(self) -> str:
+ return f"<WorkflowEvent [{self.name}]>"
-class MatcherEvent:
+class MatcherEvent(InfiniEvent):
"""Matcher 事件"""
name: str
+ prefix: str
string: str
kwargs: dict