Skip to content
This repository was archived by the owner on Aug 16, 2024. It is now read-only.

Commit c8f668d

Browse files
committed
正确实现 VoiceMessage.ToJson();
1 parent 85eb9cd commit c8f668d

File tree

1 file changed

+18
-5
lines changed

1 file changed

+18
-5
lines changed

include/mirai/messages/VoiceMessage.hpp

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -84,15 +84,28 @@ namespace Cyan
8484
}
8585
virtual json ToJson() const override
8686
{
87-
return
87+
json result =
8888
{
8989
{ "type", type_ },
90-
{ "voiceId", voiceId_.empty()? nullptr : voiceId_ },
91-
{ "url", url_.empty()? nullptr : url_ },
92-
{ "path", path_.empty()? nullptr : path_ },
93-
{ "base64", base64_.empty()? nullptr : base64_ },
9490
{ "length", length_ }
9591
};
92+
93+
voiceId_.empty()
94+
? result["voiceId"] = json(nullptr)
95+
: result["voiceId"] = voiceId_;
96+
97+
url_.empty()
98+
? result["url"] = json(nullptr)
99+
: result["url"] = url_;
100+
101+
path_.empty()
102+
? result["path"] = json(nullptr)
103+
: result["path"] = path_;
104+
105+
base64_.empty()
106+
? result["base64"] = json(nullptr)
107+
: result["base64"] = base64_;
108+
return result;
96109
}
97110
virtual ~VoiceMessage() {}
98111

0 commit comments

Comments
 (0)