fix: preserve whitespace in Plain.toDict() for @ mentions (#6244)
* fix: preserve whitespace in Plain.toDict() for @ mentions - Remove .strip() from Plain.toDict() to match async to_dict() behavior - Fixes #6237: QQ @mentions no longer lose trailing spaces - This ensures '@user message' displays correctly instead of '@usermessage' * refactor: remove redundant to_dict() from Plain class - Let Plain inherit to_dict() from BaseMessageComponent - BaseMessageComponent.to_dict() calls toDict() by default - Reduces code duplication and prevents future divergence - Addressed code review feedback from @gemini-code-assist and @sourcery-ai * feat: add async to_dict method to Plain message component * fix: add return type hint to Plain.toDict method --------- Co-authored-by: ccsang <ccsang@users.noreply.github.com> Co-authored-by: Soulter <905617992@qq.com>
This commit is contained in:
@@ -96,10 +96,10 @@ class Plain(BaseMessageComponent):
|
|||||||
def __init__(self, text: str, convert: bool = True, **_) -> None:
|
def __init__(self, text: str, convert: bool = True, **_) -> None:
|
||||||
super().__init__(text=text, convert=convert, **_)
|
super().__init__(text=text, convert=convert, **_)
|
||||||
|
|
||||||
def toDict(self):
|
def toDict(self) -> dict:
|
||||||
return {"type": "text", "data": {"text": self.text.strip()}}
|
return {"type": "text", "data": {"text": self.text}}
|
||||||
|
|
||||||
async def to_dict(self):
|
async def to_dict(self) -> dict:
|
||||||
return {"type": "text", "data": {"text": self.text}}
|
return {"type": "text", "data": {"text": self.text}}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user