mirror of
https://github.com/nonebot/nonebot2.git
synced 2025-01-19 17:58:26 +08:00
🐛 tweak
This commit is contained in:
parent
b1c5013088
commit
2908cb3ce2
@ -218,11 +218,11 @@ class MessageDeserializer:
|
||||
|
||||
def deserialize(self) -> Message:
|
||||
dict_mention = {}
|
||||
if self.type == "post":
|
||||
if self.mentions:
|
||||
for mention in self.mentions:
|
||||
dict_mention[mention["key"]] = mention
|
||||
|
||||
if self.type == "post":
|
||||
msg = Message()
|
||||
if self.data["title"] != "":
|
||||
msg += MessageSegment("text", {'text': self.data["title"]})
|
||||
@ -237,6 +237,12 @@ class MessageDeserializer:
|
||||
msg += MessageSegment(tag if tag != "img" else "image", seg)
|
||||
|
||||
return msg._merge()
|
||||
elif self.type == "text":
|
||||
for key, mention in dict_mention.items():
|
||||
self.data["text"] = self.data["text"].replace(key, f"@{mention['name']}")
|
||||
self.data["mentions"] = dict_mention
|
||||
|
||||
return Message(MessageSegment(self.type, self.data))
|
||||
|
||||
else:
|
||||
return Message(MessageSegment(self.type, self.data))
|
||||
|
Loading…
Reference in New Issue
Block a user