cpp-mirai-client  v2.6.1
cpp client for mirai-api-http
AppMessage.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_APP_MESSAGE_HPP_
17#define MIRAI_APP_MESSAGE_HPP_
18
19#include <string>
20#include <utility>
21
22#include "IMessage.hpp"
23
24namespace Mirai
25{
26
27/**
28 * @brief 小程序消息
29 *
30 * Member Variable | Default Value
31 * --------------- | -------------
32 * `AppMessage::content_` | `""`
33 */
34class AppMessage final : public IMessageImpl<AppMessage>
35{
37
38private:
39 std::string content_{};
40
41 bool isValid_() const final { return !this->content_.empty(); }
42
43 static constexpr MessageTypes TYPE_ = MessageTypes::APP;
44 static constexpr bool SUPPORT_SEND_ = true;
45
46public:
47 AppMessage() = default;
48 AppMessage(std::string content) : content_(std::move(content)) {};
49
50 bool operator==(const AppMessage& rhs) { return this->content_ == rhs.content_; }
51
52 bool operator!=(const AppMessage& rhs) { return !(*this == rhs); }
53
54 /// 获取App消息内容
55 std::string GetContent() const { return this->content_; }
56
57 /// 设置App消息内容
58 AppMessage& SetContent(std::string content)
59 {
60 this->content_ = std::move(content);
61 return *this;
62 }
63
64 struct Serializable;
65};
66
67template<> struct GetType<AppMessage::GetType()>
68{
70};
71
72} // namespace Mirai
73
74
75#endif
小程序消息
Definition: AppMessage.hpp:35
std::string GetContent() const
获取App消息内容
Definition: AppMessage.hpp:55
AppMessage(std::string content)
Definition: AppMessage.hpp:48
bool operator!=(const AppMessage &rhs)
Definition: AppMessage.hpp:52
bool operator==(const AppMessage &rhs)
Definition: AppMessage.hpp:50
AppMessage()=default
AppMessage & SetContent(std::string content)
设置App消息内容
Definition: AppMessage.hpp:58
CRTP helper layer
Definition: IMessage.hpp:78
所有mirai相关的对象的命名空间
STL namespace
用于类型之间转换的辅助模板