mirror of
https://github.com/nonebot/nonebot2.git
synced 2025-09-12 06:56:41 +00:00
⚗️ rewrite echo and say builtin plugin
This commit is contained in:
@ -265,7 +265,7 @@ class BaseMessageSegment(abc.ABC):
|
||||
- 类型: ``str``
|
||||
- 说明: 消息段类型
|
||||
"""
|
||||
data: Dict[str, Union[str, list]] = field(default_factory=lambda: {})
|
||||
data: Dict[str, Any] = field(default_factory=lambda: {})
|
||||
"""
|
||||
- 类型: ``Dict[str, Union[str, list]]``
|
||||
- 说明: 消息段数据
|
||||
@ -279,6 +279,11 @@ class BaseMessageSegment(abc.ABC):
|
||||
def __add__(self, other):
|
||||
raise NotImplementedError
|
||||
|
||||
@classmethod
|
||||
@abc.abstractmethod
|
||||
def text(cls, text: str) -> "BaseMessageSegment":
|
||||
return cls("text", {"text": text})
|
||||
|
||||
|
||||
class BaseMessage(list, abc.ABC):
|
||||
"""消息数组"""
|
||||
|
@ -637,9 +637,9 @@ class Event(BaseEvent):
|
||||
class MessageSegment(BaseMessageSegment):
|
||||
|
||||
@overrides(BaseMessageSegment)
|
||||
def __init__(self, type: str, data: Dict[str, Union[str, list]]) -> None:
|
||||
def __init__(self, type: str, data: Dict[str, Any]) -> None:
|
||||
if type == "text":
|
||||
data["text"] = unescape(data["text"]) # type: ignore
|
||||
data["text"] = unescape(data["text"])
|
||||
super().__init__(type=type, data=data)
|
||||
|
||||
@overrides(BaseMessageSegment)
|
||||
|
@ -858,7 +858,7 @@ class Event:
|
||||
|
||||
class MessageSegment:
|
||||
|
||||
def __init__(self, type: str, data: Dict[str, Union[str, list]]) -> None:
|
||||
def __init__(self, type: str, data: Dict[str, Any]) -> None:
|
||||
...
|
||||
|
||||
def __str__(self):
|
||||
|
Reference in New Issue
Block a user