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