1+ #pragma once
2+ #ifndef mirai_cpp_events_member_join_event_hpp_H_
3+ #define mirai_cpp_events_member_join_event_hpp_H_
4+
5+ #include < nlohmann/json.hpp>
6+ #include " CURLWrapper.h"
7+ #include " defs/qq_types.hpp"
8+ #include " defs/serializable.hpp"
9+ #include " defs/message_chain.hpp"
10+ #include " defs/friend.hpp"
11+
12+ namespace Cyan
13+ {
14+ // 新成员入群请求
15+ class MemberJoinRequestEvent : public Serializable
16+ {
17+ public:
18+ int64_t EventId;
19+ QQ_t FromId;
20+ GID_t GroupId;
21+ string GroupName;
22+ string Nick;
23+ string Message;
24+
25+ MemberJoinRequestEvent () = default ;
26+ MemberJoinRequestEvent (const MemberJoinRequestEvent& gm)
27+ {
28+ EventId = gm.EventId ;
29+ FromId = gm.FromId ;
30+ GroupId = gm.GroupId ;
31+ Nick = gm.Nick ;
32+ GroupName = gm.GroupName ;
33+ Message = gm.Message ;
34+ bot_ = gm.bot_ ;
35+ }
36+ MemberJoinRequestEvent& operator =(const MemberJoinRequestEvent& t)
37+ {
38+ MemberJoinRequestEvent tmp (t);
39+ std::swap (this ->EventId , tmp.EventId );
40+ std::swap (this ->FromId , tmp.FromId );
41+ std::swap (this ->GroupId , tmp.GroupId );
42+ std::swap (this ->GroupName , tmp.GroupName );
43+ std::swap (this ->Nick , tmp.Nick );
44+ std::swap (this ->Message , tmp.Message );
45+ std::swap (this ->bot_ , tmp.bot_ );
46+ return *this ;
47+ }
48+
49+ void SetMiraiBot (MiraiBot* bot)
50+ {
51+ this ->bot_ = bot;
52+ }
53+
54+ bool Accept ()
55+ {
56+ return Respose (0 , " " );
57+ }
58+
59+ bool Reject (const string& message = " " )
60+ {
61+ return Respose (1 , message);
62+ }
63+
64+ bool Ignore (const string& message = " " )
65+ {
66+ return Respose (2 , message);
67+ }
68+
69+ bool RejectAndBlock (const string& message = " " )
70+ {
71+ return Respose (3 , message);
72+ }
73+
74+ bool IgnoreAndBlock (const string& message = " " )
75+ {
76+ return Respose (4 , message);
77+ }
78+
79+
80+ virtual ~MemberJoinRequestEvent () = default ;
81+ virtual bool Set (const json& j) override
82+ {
83+ this ->EventId = j[" eventId" ].get <int64_t >();
84+ this ->FromId = (QQ_t)j[" fromId" ].get <int64_t >();
85+ this ->GroupName = (GID_t)j[" groupName" ].get <int64_t >();
86+ this ->GroupId = (GID_t)j[" groupId" ].get <int64_t >();
87+ this ->Nick = j[" nick" ].get <string>();
88+ this ->Message = j[" message" ].get <string>();
89+ return true ;
90+ }
91+ virtual json ToJson () const override
92+ {
93+ json j = json::object ();
94+ j[" type" ] = " MemberJoinRequestEvent" ;
95+ j[" eventId" ] = this ->EventId ;
96+ j[" fromId" ] = (int64_t )this ->FromId ;
97+ j[" groupId" ] = (int64_t )this ->GroupId ;
98+ j[" groupName" ] = this ->GroupName ;
99+ j[" nick" ] = this ->Nick ;
100+ j[" message" ] = this ->Message ;
101+ return j;
102+ }
103+
104+ private:
105+ MiraiBot* bot_;
106+ bool Respose (int operate, const string& message);
107+ };
108+
109+ }
110+
111+ #endif // !mirai_cpp_events_member_join_event_hpp_H_
0 commit comments