cpp-mirai-client  v2.6.1
cpp client for mirai-api-http
NewFriendRequestEvent.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_NEW_FRIEND_REQUEST_EVENT_HPP_
17#define MIRAI_NEW_FRIEND_REQUEST_EVENT_HPP_
18
19#include <string>
20
22
23#include "IEvent.hpp"
24
25namespace Mirai
26{
27
28/**
29 * @brief 用户申请添加Bot好友事件
30 *
31 * Member Variable | Default Value
32 * --------------- | -------------
33 * `NewFriendRequestEvent::EventId_` | `0`
34 * `NewFriendRequestEvent::FromId_` | `0_qq`
35 * `NewFriendRequestEvent::GroupId_` | `0_gid`
36 * `NewFriendRequestEvent::nickname_` | `""`
37 * `NewFriendRequestEvent::message_` | `""`
38 */
39class NewFriendRequestEvent final : public IEvent<NewFriendRequestEvent>
40{
42private:
43 int64_t EventId_ = 0;
44 QQ_t FromId_;
45 GID_t GroupId_;
46 std::string nickname_;
47 std::string message_;
48
49 static constexpr EventTypes TYPE_ = EventTypes::NewFriendRequest;
50
51public:
52 /// 获取事件id,唯一标识符
53 int64_t GetEventId() const { return this->EventId_; }
54 /// 获取申请人QQ
55 QQ_t GetUserId() const { return this->FromId_; }
56 /// 获取申请人昵称
57 std::string GetNickname() const { return this->nickname_; }
58 /// 获取申请人来自的群聊,若无则返回 `0_gid`
59 GID_t GetGroupId() const { return this->GroupId_; }
60 /// 申请人是否通过群聊找到Bot
61 bool isFromGroup() const { return this->GroupId_ != (GID_t)0; }
62 /// 获取申请信息
63 std::string GetMessage() const { return this->message_; }
64
65 // TODO: add helper methods for quick response
66
67 struct Serializable;
68};
69
70template<>
72{
74};
75
76} // namespace Mirai
77
78
79#endif
群聊号码类型
Definition: BasicTypes.hpp:88
Common interface for all event types
Definition: IEvent.hpp:34
用户申请添加Bot好友事件
GID_t GetGroupId() const
获取申请人来自的群聊,若无则返回 0_gid
std::string GetMessage() const
获取申请信息
QQ_t GetUserId() const
获取申请人QQ
std::string GetNickname() const
获取申请人昵称
int64_t GetEventId() const
获取事件id,唯一标识符
bool isFromGroup() const
申请人是否通过群聊找到Bot
QQ号码类型
Definition: BasicTypes.hpp:71
所有mirai相关的对象的命名空间
用于类型之间转换的辅助模板
Definition: EventTypes.hpp:107
用于类型之间转换的辅助模板