cpp-mirai-client  v2.6.1
cpp client for mirai-api-http
MusicShareMessage.hpp
浏览该文件的文档.
1// Copyright (C) 2022 Numendacil and contributors
2//
3// This program is free software: you can redistribute it and/or modify
4// it under the terms of the GNU Affero General Public License as
5// published by the Free Software Foundation, either version 3 of the
6// License, or (at your option) any later version.
7//
8// This program is distributed in the hope that it will be useful,
9// but WITHOUT ANY WARRANTY; without even the implied warranty of
10// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11// GNU Affero General Public License for more details.
12//
13// You should have received a copy of the GNU Affero General Public License
14// along with this program. If not, see <http://www.gnu.org/licenses/>.
15
16#ifndef MIRAI_MUSIC_SHARE_MESSAGE_HPP_
17#define MIRAI_MUSIC_SHARE_MESSAGE_HPP_
18
19#include <array>
20#include <string>
21#include <utility>
22
24
25#include "IMessage.hpp"
26
27namespace Mirai
28{
29
30/**
31 * @brief 音乐分享卡片消息
32 *
33 * Member Variable | Default Value
34 * --------------- | -------------
35 * `MusicShareMessage::kind_` | `MusicShareType::ENUM_END`
36 * `MusicShareMessage::title_` | `""`
37 * `MusicShareMessage::summary_` | `""`
38 * `MusicShareMessage::JumpUrl_` | `""`
39 * `MusicShareMessage::PictureUrl_` | `""`
40 * `MusicShareMessage::MusicUrl_` | `""`
41 * `MusicShareMessage::brief_` | `""`
42 */
43class MusicShareMessage final : public IMessageImpl<MusicShareMessage>
44{
46
47protected:
49 std::string title_{};
50 std::string summary_{};
51 std::string JumpUrl_{};
52 std::string PictureUrl_{};
53 std::string MusicUrl_{};
54 std::string brief_{};
55
57 static constexpr bool SUPPORT_SEND_ = true;
58
59 bool isValid_() const final
60 {
61 return !(this->kind_ == MusicShareType::ENUM_END || this->title_.empty() || this->summary_.empty()
62 || this->JumpUrl_.empty() || this->PictureUrl_.empty() || this->MusicUrl_.empty()
63 || this->brief_.empty());
64 }
65
66public:
67 MusicShareMessage() = default;
68
69 MusicShareMessage(MusicShareType kind, std::string title, std::string summary, std::string JumpUrl,
70 std::string PictureUrl, std::string MusicUrl, std::string brief)
71 : kind_(kind)
72 , title_(std::move(title))
73 , summary_(std::move(summary))
74 , JumpUrl_(std::move(JumpUrl))
75 , PictureUrl_(std::move(PictureUrl))
76 , MusicUrl_(std::move(MusicUrl))
77 , brief_(std::move(brief))
78 {
79 }
80
81 /// 获取分享种类
82 MusicShareType GetKind() const { return this->kind_; }
83 /// 获取标题
84 std::string GetTitle() const { return this->title_; }
85 /// 获取介绍
86 std::string GetSummary() const { return this->summary_; }
87 /// 获取转跳链接
88 std::string GetJumpUrl() const { return this->JumpUrl_; }
89 /// 获取封面图片连接
90 std::string GetPictureUrl() const { return this->PictureUrl_; }
91 /// 获取音乐链接
92 std::string GetMusicUrl() const { return this->MusicUrl_; }
93 /**
94 * @brief 获取简介
95 *
96 * 简介为未打开会话窗口时显示的简要文字消息
97 */
98 std::string GetBrief() const { return this->brief_; }
99
100 /// 设置分享种类
102 {
103 this->kind_ = kind;
104 return *this;
105 }
106 /// 设置标题
107 MusicShareMessage& SetTitle(std::string title)
108 {
109 this->title_ = std::move(title);
110 return *this;
111 }
112 /// 设置介绍
113 MusicShareMessage& SetSummary(std::string summary)
114 {
115 this->summary_ = std::move(summary);
116 return *this;
117 }
118 /// 设置转跳链接
119 MusicShareMessage& SetJumpUrl(std::string JumpUrl)
120 {
121 this->JumpUrl_ = std::move(JumpUrl);
122 return *this;
123 }
124 /// 设置封面图片连接
125 MusicShareMessage& SetPictureUrl(std::string PictureUrl)
126 {
127 this->PictureUrl_ = std::move(PictureUrl);
128 return *this;
129 }
130 /// 设置音乐链接
131 MusicShareMessage& SetMusicUrl(std::string MusicUrl)
132 {
133 this->MusicUrl_ = std::move(MusicUrl);
134 return *this;
135 }
136 /// 设置简介
137 MusicShareMessage& SetBrief(std::string brief)
138 {
139 this->brief_ = std::move(brief);
140 return *this;
141 }
142
143 struct Serializable;
144};
145
146template<> struct GetType<MusicShareMessage::GetType()>
147{
149};
150
151
152} // namespace Mirai
153
154
155#endif
CRTP helper layer
Definition: IMessage.hpp:78
音乐分享卡片消息
static constexpr bool SUPPORT_SEND_
std::string GetMusicUrl() const
获取音乐链接
MusicShareMessage(MusicShareType kind, std::string title, std::string summary, std::string JumpUrl, std::string PictureUrl, std::string MusicUrl, std::string brief)
std::string GetBrief() const
获取简介
MusicShareMessage & SetMusicUrl(std::string MusicUrl)
设置音乐链接
MusicShareMessage & SetPictureUrl(std::string PictureUrl)
设置封面图片连接
MusicShareMessage & SetJumpUrl(std::string JumpUrl)
设置转跳链接
MusicShareMessage & SetBrief(std::string brief)
设置简介
std::string GetTitle() const
获取标题
MusicShareMessage & SetKind(MusicShareType kind)
设置分享种类
static constexpr MessageTypes TYPE_
MusicShareType GetKind() const
获取分享种类
MusicShareMessage & SetSummary(std::string summary)
设置介绍
bool isValid_() const final
std::string GetJumpUrl() const
获取转跳链接
std::string GetPictureUrl() const
获取封面图片连接
std::string GetSummary() const
获取介绍
MusicShareMessage & SetTitle(std::string title)
设置标题
所有mirai相关的对象的命名空间
MusicShareType
音乐卡片类型
Definition: BasicTypes.hpp:220
STL namespace
用于类型之间转换的辅助模板