🔒 ensure cqhttp str radd escaped

This commit is contained in:
yanyongyu 2021-03-30 16:21:56 +08:00
parent 5db819738e
commit 4e7592de98

View File

@ -38,7 +38,8 @@ class MessageSegment(BaseMessageSegment):
@overrides(BaseMessageSegment)
def __radd__(self, other) -> "Message":
return Message(other) + self
return (MessageSegment.text(other)
if isinstance(other, str) else Message(other)) + self
@overrides(BaseMessageSegment)
def is_text(self) -> bool:
@ -211,6 +212,11 @@ class Message(BaseMessage):
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
@overrides(BaseMessage)
def _construct(