mirror of
https://github.com/nonebot/nonebot2.git
synced 2024-11-28 03:05:25 +08:00
🔒 ensure cqhttp str radd escaped
This commit is contained in:
parent
5db819738e
commit
4e7592de98
@ -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(
|
||||
|
Loading…
Reference in New Issue
Block a user