mirror of
https://github.com/nonebot/nonebot2.git
synced 2025-09-12 06:56:41 +00:00
🔒 ensure cqhttp str radd escaped
This commit is contained in:
@ -38,7 +38,8 @@ class MessageSegment(BaseMessageSegment):
|
|||||||
|
|
||||||
@overrides(BaseMessageSegment)
|
@overrides(BaseMessageSegment)
|
||||||
def __radd__(self, other) -> "Message":
|
def __radd__(self, other) -> "Message":
|
||||||
return Message(other) + self
|
return (MessageSegment.text(other)
|
||||||
|
if isinstance(other, str) else Message(other)) + self
|
||||||
|
|
||||||
@overrides(BaseMessageSegment)
|
@overrides(BaseMessageSegment)
|
||||||
def is_text(self) -> bool:
|
def is_text(self) -> bool:
|
||||||
@ -211,6 +212,11 @@ class Message(BaseMessage):
|
|||||||
CQHTTP 协议 Message 适配。
|
CQHTTP 协议 Message 适配。
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
def __radd__(self, other: Union[str, MessageSegment,
|
||||||
|
"Message"]) -> "Message":
|
||||||
|
result = MessageSegment.text(other) if isinstance(other, str) else other
|
||||||
|
return super(Message, self).__radd__(result)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@overrides(BaseMessage)
|
@overrides(BaseMessage)
|
||||||
def _construct(
|
def _construct(
|
||||||
|
Reference in New Issue
Block a user