cpp-mirai-client  v2.6.1
cpp client for mirai-api-http
OtherClientEvents.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_OTHER_CLIENT_EVENTS_HPP_
17#define MIRAI_OTHER_CLIENT_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 * `OtherClientMessageEvent::sender_` | `ClientDevice{}`
35 * `OtherClientMessageEvent::message_` | `MessageChain{}`
36 */
37class OtherClientMessageEvent final : public IEvent<OtherClientMessageEvent>
38{
40private:
41 ClientDevice sender_;
42 MessageChain message_;
43
44 static constexpr EventTypes TYPE_ = EventTypes::OtherClientMessage;
45
46public:
47 /// 获取发送客户端信息
48 ClientDevice GetSender() const { return this->sender_; }
49 /// 获取消息内容
50 MessageChain GetMessage() const { return this->message_; }
51
52 struct Serializable;
53};
54
55
56
57/**
58 * @brief 其它客户端下线事件
59 *
60 * Member Variable | Default Value
61 * --------------- | -------------
62 * `OtherClientOfflineEvent::client_` | `ClientDevice{}`
63 */
64class OtherClientOfflineEvent final : public IEvent<OtherClientOfflineEvent>
65{
67
68private:
69 ClientDevice client_;
70
71 static constexpr EventTypes TYPE_ = EventTypes::OtherClientOffline;
72
73public:
74 /// 获取设备信息
75 ClientDevice GetClient() const { return this->client_; }
76
77 struct Serializable;
78};
79
80
81
82/**
83 * @brief 其它客户端上线事件
84 *
85 * Member Variable | Default Value
86 * --------------- | -------------
87 * `OtherClientOnlineEvent::client_` | `ClientDevice{}`
88 * `OtherClientOnlineEvent::kind_` | `std::nullopt`
89 */
90class OtherClientOnlineEvent final : public IEvent<OtherClientOnlineEvent>
91{
93
94private:
95 ClientDevice client_;
96 std::optional<int64_t> kind_ = std::nullopt;
97
98 static constexpr EventTypes TYPE_ = EventTypes::OtherClientOnline;
99
100public:
101 /// 获取设备信息
102 ClientDevice GetClient() const { return this->client_; }
103 /// 获取详细设备类型,无则返回 `std::nullopt`
104 std::optional<int64_t> GetKind() const { return this->kind_; }
105
106 // TODO: replace kind with enum, see https://github.com/mamoe/mirai/blob/dev/mirai-core-api/src/commonMain/kotlin/contact/OtherClient.kt#L113
107
108 struct Serializable;
109};
110
111
112
113#define DECLARE_TYPE_ENUM(event_type) \
114 template<> struct GetEventType<event_type::GetType()> \
115 { \
116 using type = event_type; \
117 }
118
122
123#undef DECLARE_TYPE_ENUM
124
125} // namespace Mirai
126
127
128#endif
Common interface for all event types
Definition: IEvent.hpp:34
消息链对象,由一系列消息元素组成
其它客户端消息事件
ClientDevice GetSender() const
获取发送客户端信息
MessageChain GetMessage() const
获取消息内容
其它客户端下线事件
ClientDevice GetClient() const
获取设备信息
其它客户端上线事件
ClientDevice GetClient() const
获取设备信息
std::optional< int64_t > GetKind() const
获取详细设备类型,无则返回 std::nullopt
所有mirai相关的对象的命名空间
DECLARE_TYPE_ENUM(BotOfflineEventActive)