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

Commit

Permalink
正确实现 VoiceMessage.ToJson();
Browse files Browse the repository at this point in the history
  • Loading branch information
cyanray committed Feb 28, 2022
1 parent 85eb9cd commit c8f668d
Showing 1 changed file with 18 additions and 5 deletions.
23 changes: 18 additions & 5 deletions include/mirai/messages/VoiceMessage.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,15 +84,28 @@ namespace Cyan
}
virtual json ToJson() const override
{
return
json result =
{
{ "type", type_ },
{ "voiceId", voiceId_.empty()? nullptr : voiceId_ },
{ "url", url_.empty()? nullptr : url_ },
{ "path", path_.empty()? nullptr : path_ },
{ "base64", base64_.empty()? nullptr : base64_ },
{ "length", length_ }
};

voiceId_.empty()
? result["voiceId"] = json(nullptr)
: result["voiceId"] = voiceId_;

url_.empty()
? result["url"] = json(nullptr)
: result["url"] = url_;

path_.empty()
? result["path"] = json(nullptr)
: result["path"] = path_;

base64_.empty()
? result["base64"] = json(nullptr)
: result["base64"] = base64_;
return result;
}
virtual ~VoiceMessage() {}

Expand Down

0 comments on commit c8f668d

Please sign in to comment.