cpp-mirai-client  v2.6.1
cpp client for mirai-api-http
AtMessage.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_AT_MESSAGE_HPP_
17#define MIRAI_AT_MESSAGE_HPP_
18
19#include <string>
20
22
23#include "IMessage.hpp"
24
25namespace Mirai
26{
27
28/**
29 * @brief At用户消息
30 *
31 * Member Variable | Default Value
32 * --------------- | -------------
33 * `AtMessage::target_` | `0_qq`
34 * `AtMessage::display_` | `""`
35 */
36class AtMessage final : public IMessageImpl<AtMessage>
37{
38 friend class IMessageImpl<AtMessage>;
39
40private:
41 QQ_t target_{};
42 std::string display_{};
43
44 bool isValid_() const final { return this->target_ != QQ_t(); }
45
46 static constexpr MessageTypes TYPE_ = MessageTypes::AT;
47 static constexpr bool SUPPORT_SEND_ = true;
48
49public:
50 AtMessage() = default;
51 AtMessage(QQ_t target) : target_(target) {}
52
53 bool operator==(const AtMessage& rhs) { return this->target_ == rhs.target_; }
54
55 bool operator!=(const AtMessage& rhs) { return !(*this == rhs); }
56
57 /// 获取At对象QQ
58 QQ_t GetTarget() const { return this->target_; }
59
60 /// 获取At时显示的文字,发送时无法设置
61 std::string GetDisplayName() { return this->display_; }
62
63 /// 设置At对象QQ
65 {
66 this->target_ = target;
67 return *this;
68 }
69
70 struct Serializable;
71};
72
73template<> struct GetType<AtMessage::GetType()>
74{
75 using type = AtMessage;
76};
77
78} // namespace Mirai
79
80#endif
At用户消息
Definition: AtMessage.hpp:37
std::string GetDisplayName()
获取At时显示的文字,发送时无法设置
Definition: AtMessage.hpp:61
bool operator!=(const AtMessage &rhs)
Definition: AtMessage.hpp:55
AtMessage & SetTarget(QQ_t target)
设置At对象QQ
Definition: AtMessage.hpp:64
bool operator==(const AtMessage &rhs)
Definition: AtMessage.hpp:53
AtMessage()=default
QQ_t GetTarget() const
获取At对象QQ
Definition: AtMessage.hpp:58
AtMessage(QQ_t target)
Definition: AtMessage.hpp:51
CRTP helper layer
Definition: IMessage.hpp:78
QQ号码类型
Definition: BasicTypes.hpp:71
所有mirai相关的对象的命名空间
用于类型之间转换的辅助模板