cpp-mirai-client  v2.6.1
cpp client for mirai-api-http
FriendEvents.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_FRIEND_EVENTS_HPP_
17#define MIRAI_FRIEND_EVENTS_HPP_
18
19#include <string>
20
23
24#include "IEvent.hpp"
25
26namespace Mirai
27{
28
29/**
30 * @brief 好友输入状态改变事件
31 *
32 * Member Variable | Default Value
33 * --------------- | -------------
34 * `FriendInputStatusChangedEvent::friend_` | `User{}`
35 * `FriendInputStatusChangedEvent::inputting_` | `false`
36 */
37class FriendInputStatusChangedEvent final : public IEvent<FriendInputStatusChangedEvent>
38{
40
41private:
42 User friend_;
43 bool inputting_ = false;
44
45 static constexpr EventTypes TYPE_ = EventTypes::FriendInputStatusChanged;
46
47public:
48 /// 获取好友信息
49 User GetFriend() const { return this->friend_; }
50 /// 是否正在输入
51 bool isInputting() const { return this->inputting_; }
52
53 struct Serializable;
54};
55
56
57
58/**
59 * @brief 好友消息事件
60 *
61 * Member Variable | Default Value
62 * --------------- | -------------
63 * `FriendMessageEvent::sender_` | `User{}`
64 * `FriendMessageEvent::message_` | `MessageChain{}`
65 */
66class FriendMessageEvent final : public IEvent<FriendMessageEvent>
67{
69
70private:
71 User sender_;
72 MessageChain message_;
73
74 static constexpr EventTypes TYPE_ = EventTypes::FriendMessage;
75
76public:
77 /// 获取发送者资料
78 User GetSender() const { return this->sender_; }
79 /// 获取消息内容
80 MessageChain GetMessage() const { return this->message_; }
81
82 // TODO: add helper methods for quick reply
83
84 struct Serializable;
85};
86
87
88
89/**
90 * @brief 好友昵称改变事件
91 *
92 * Member Variable | Default Value
93 * --------------- | -------------
94 * `FriendNickChangedEvent::friend_` | `User{}`
95 * `FriendNickChangedEvent::from_` | `""`
96 * `FriendNickChangedEvent::to_` | `""`
97 */
98class FriendNickChangedEvent final : public IEvent<FriendNickChangedEvent>
99{
101private:
102 User friend_;
103 std::string from_;
104 std::string to_;
105
106 static constexpr EventTypes TYPE_ = EventTypes::FriendNickChanged;
107
108public:
109 /// 获取好友信息
110 User GetFriend() const { return this->friend_; }
111 /// 获取更改前的昵称
112 std::string GetOriginalNickname() const { return this->from_; }
113 /// 获取当前昵称
114 std::string GetNewNickname() const { return this->to_; }
115
116 struct Serializable;
117};
118
119
120
121/**
122 * @brief 好友消息撤回事件
123 *
124 * Member Variable | Default Value
125 * --------------- | -------------
126 * `FriendRecallEvent::AuthorId_` | `0_qq`
127 * `FriendRecallEvent::MessageId_` | `0`
128 * `FriendRecallEvent::time_` | `0`
129 * `FriendRecallEvent::operator_` | `0_qq`
130 */
131class FriendRecallEvent final : public IEvent<FriendRecallEvent>
132{
134private:
135 QQ_t AuthorId_;
136 MessageId_t MessageId_ = 0;
137 std::time_t time_ = 0;
138 QQ_t operator_;
139
140 static constexpr EventTypes TYPE_ = EventTypes::FriendRecall;
141
142public:
143 /// 获取被撤回消息的发送者QQ
144 QQ_t GetSender() const { return this->AuthorId_; }
145 /// 获取被撤回消息的消息id
146 MessageId_t GetMessageId() const { return this->MessageId_; }
147 /// 获取被撤回消息的发送时间
148 std::time_t GetSendTime() const { return this->time_; }
149 /// 获取操作员QQ
150 QQ_t GetOperator() const { return this->operator_; }
151
152 struct Serializable;
153};
154
155
156
157/**
158 * @brief 好友消息同步事件
159 *
160 * Member Variable | Default Value
161 * --------------- | -------------
162 * `FriendSyncMessageEvent::subject_` | `User{}`
163 * `FriendSyncMessageEvent::message_` | `MessageChain{}`
164 */
165class FriendSyncMessageEvent final : public IEvent<FriendSyncMessageEvent>
166{
168private:
169 User subject_;
170 MessageChain message_;
171
172 static constexpr EventTypes TYPE_ = EventTypes::FriendSyncMessage;
173
174public:
175 /// 获取目标好友信息
176 User GetFriend() const { return this->subject_; }
177 /// 获取消息内容
178 MessageChain GetMessage() const { return this->message_; }
179
180 struct Serializable;
181};
182
183
184
185#define DECLARE_TYPE_ENUM(event_type) \
186 template<> struct GetEventType<event_type::GetType()> \
187 { \
188 using type = event_type; \
189 }
190
196
197#undef DECLARE_TYPE_ENUM
198
199} // namespace Mirai
200
201
202#endif
好友输入状态改变事件
bool isInputting() const
是否正在输入
User GetFriend() const
获取好友信息
好友消息事件
User GetSender() const
获取发送者资料
MessageChain GetMessage() const
获取消息内容
好友昵称改变事件
std::string GetNewNickname() const
获取当前昵称
User GetFriend() const
获取好友信息
std::string GetOriginalNickname() const
获取更改前的昵称
好友消息撤回事件
std::time_t GetSendTime() const
获取被撤回消息的发送时间
MessageId_t GetMessageId() const
获取被撤回消息的消息id
QQ_t GetSender() const
获取被撤回消息的发送者QQ
QQ_t GetOperator() const
获取操作员QQ
好友消息同步事件
User GetFriend() const
获取目标好友信息
MessageChain GetMessage() const
获取消息内容
Common interface for all event types
Definition: IEvent.hpp:34
消息链对象,由一系列消息元素组成
QQ号码类型
Definition: BasicTypes.hpp:71
所有mirai相关的对象的命名空间
int64_t MessageId_t
消息id类型,用于撤回消息和引用消息
Definition: BasicTypes.hpp:35
DECLARE_TYPE_ENUM(BotOfflineEventActive)
QQ用户
Definition: BasicTypes.hpp:305