cpp-mirai-client  v2.6.1
cpp client for mirai-api-http
NudgeTarget.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_TYPES_NUDGE_TARGET_HPP_
17#define MIRAI_TYPES_NUDGE_TARGET_HPP_
18
19#include <array>
20#include <string>
21
23
24namespace Mirai
25{
26
27/**
28 * @brief QQ移动端头像戳一戳动作的对象
29 *
30 * Member Variable | Default Value
31 * --------------- | -------------
32 * `NudgeTarget::kind_` | `NudgeType::ENUM_END`
33 * `NudgeTarget::target_` | `0_qq`
34 * `NudgeTarget::subject_` | `0`
35 */
37{
38protected:
41 int64_t subject_ = 0;
42
43public:
44 /**
45 * @brief 构造函数
46 *
47 */
48 NudgeTarget() = default;
49
50 /**
51 * @brief 构造函数
52 *
53 * @param kind 戳一戳的类型
54 * @param target 戳一戳的对象
55 * @param subject 戳一戳的发送主体,群聊消息时为群号,私聊时为对方QQ号码
56 */
57 NudgeTarget(NudgeType kind, QQ_t target, UID_t subject) : kind_(kind), target_(target), subject_((int64_t)subject)
58 {
59 }
60
61 /**
62 * @brief 返回戳一戳类型
63 *
64 * @return 戳一戳类型 `enum`
65 */
66 NudgeType GetNudgeType() const { return this->kind_; }
67
68 /**
69 * @brief 返回戳一戳的对象
70 *
71 * @return 戳一戳对象的QQ号
72 */
73 QQ_t GetTarget() const { return this->target_; }
74
75 /**
76 * @brief 返回戳一戳所在的群聊
77 *
78 * 仅在类型为 `NudgeType::GROUP` 时有效,否则返回 `0`
79 * @return 戳一戳的群号
80 */
81 GID_t GetGroup() const { return (this->kind_ == NudgeType::GROUP) ? (GID_t)this->subject_ : (GID_t)0; }
82
83 /**
84 * @brief 设置戳一戳类型
85 *
86 * @param kind 戳一戳类型 `enum`
87 * @return Reference to *this
88 */
90 {
91 this->kind_ = kind;
92 return *this;
93 }
94
95 /**
96 * @brief 设置戳一戳对象
97 *
98 * @param target 戳一戳对象QQ
99 * @return Reference to *this
100 */
102 {
103 this->target_ = target;
104 return *this;
105 }
106
107 /**
108 * @brief 设置戳一戳的发送主体
109 *
110 * 不推荐,考虑使用 `NudgeFriend()`, `NudgeGroupMember()` 与 `NudgeStranger()`
111 * @param subject 戳一戳的发送主体
112 * @return Reference to *this
113 */
114 NudgeTarget& SetSubject(int64_t subject)
115 {
116 this->subject_ = subject;
117 return *this;
118 }
119
120
121 /**
122 * @brief 设置为好友戳一戳消息
123 *
124 * @param target 好友QQ
125 * @return Reference to *this
126 */
128 {
129 this->kind_ = NudgeType::FRIEND;
130 this->target_ = target;
131 return *this;
132 }
133
134 /**
135 * @brief 设置为群聊戳一戳消息
136 *
137 * @param target 群友QQ
138 * @param group 群聊号码
139 * @return Reference to *this
140 */
142 {
143 this->kind_ = NudgeType::GROUP;
144 this->target_ = target;
145 this->subject_ = (int64_t)group;
146 return *this;
147 }
148
149 /**
150 * @brief 设置为单向好友戳一戳消息
151 *
152 * @param target 陌生人QQ
153 * @return Reference to *this
154 */
156 {
157 this->kind_ = NudgeType::STRANGER;
158 this->target_ = target;
159 return *this;
160 }
161};
162
163} // namespace Mirai
164
165#endif
群聊号码类型
Definition: BasicTypes.hpp:88
QQ移动端头像戳一戳动作的对象
Definition: NudgeTarget.hpp:37
QQ_t GetTarget() const
返回戳一戳的对象
Definition: NudgeTarget.hpp:73
NudgeTarget & SetTarget(QQ_t target)
设置戳一戳对象
NudgeTarget(NudgeType kind, QQ_t target, UID_t subject)
构造函数
Definition: NudgeTarget.hpp:57
GID_t GetGroup() const
返回戳一戳所在的群聊
Definition: NudgeTarget.hpp:81
NudgeTarget()=default
构造函数
NudgeType GetNudgeType() const
返回戳一戳类型
Definition: NudgeTarget.hpp:66
NudgeTarget & NudgeStranger(QQ_t target)
设置为单向好友戳一戳消息
NudgeTarget & NudgeFriend(QQ_t target)
设置为好友戳一戳消息
NudgeTarget & NudgeGroupMember(QQ_t target, GID_t group)
设置为群聊戳一戳消息
NudgeTarget & SetSubject(int64_t subject)
设置戳一戳的发送主体
NudgeTarget & SetNudgeType(NudgeType kind)
设置戳一戳类型
Definition: NudgeTarget.hpp:89
QQ号码类型
Definition: BasicTypes.hpp:71
Base class for QQ_t and GID_t
Definition: BasicTypes.hpp:43
所有mirai相关的对象的命名空间
NudgeType
头像戳一戳消息的发送环境
Definition: BasicTypes.hpp:205