Skip to content

Commit

Permalink
✨ Feature: 为 MessageSegment 添加 add 操作类型推导支持 (#64)
Browse files Browse the repository at this point in the history
  • Loading branch information
mobyw authored Oct 16, 2023
1 parent 1287d9e commit b90265e
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions nonebot/adapters/qq/message.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,22 @@ def reference(
},
)

@override
def __add__(
self, other: Union[str, "MessageSegment", Iterable["MessageSegment"]]
) -> "Message":
return Message(self) + (
MessageSegment.text(other) if isinstance(other, str) else other
)

@override
def __radd__(
self, other: Union[str, "MessageSegment", Iterable["MessageSegment"]]
) -> "Message":
return (
MessageSegment.text(other) if isinstance(other, str) else Message(other)
) + self

@override
def is_text(self) -> bool:
return self.type == "text"
Expand Down

0 comments on commit b90265e

Please sign in to comment.