@@ -130,7 +130,6 @@ namespace twobot {
130130 });
131131
132132 // 仅仅为了特化onEvent模板
133- // TODO: 在这里伪装调用一下,特化一下模板
134133 instance->onEvent <Event::GroupMsg>([](const auto &) {});
135134 instance->onEvent <Event::PrivateMsg>([](const auto &) {});
136135 instance->onEvent <Event::EnableEvent>([](const auto &) {});
@@ -140,10 +139,14 @@ namespace twobot {
140139 instance->onEvent <Event::GroupAdminNotice>([](const auto &) {});
141140 instance->onEvent <Event::GroupDecreaseNotice>([](const auto &) {});
142141 instance->onEvent <Event::GroupInceaseNotice>([](const auto &) {});
142+ instance->onEvent <Event::GroupBanNotice>([](const auto &) {});
143+ instance->onEvent <Event::FriendAddNotice>([](const auto &) {});
144+ instance->onEvent <Event::GroupRecallNotice>([](const auto &) {});
145+ instance->onEvent <Event::FriendRecallNotice>([](const auto &) {});
146+ instance->onEvent <Event::GroupNotifyNotice>([](const auto &) {});
143147 }
144148
145149 std::unique_ptr<Event::EventBase> Event::EventBase::construct (const EventType& event) {
146- // TODO: 这里要根据event的类型来创建对应的Event对象
147150 if (event.post_type == " message" ) {
148151 if (event.sub_type == " group" ) {
149152 return std::unique_ptr<Event::EventBase>(new Event::GroupMsg ());
@@ -167,12 +170,21 @@ namespace twobot {
167170 return std::unique_ptr<Event::EventBase>(new Event::GroupDecreaseNotice ());
168171 } else if (event.sub_type == " group_increase" ){
169172 return std::unique_ptr<Event::EventBase>(new Event::GroupInceaseNotice ());
173+ } else if (event.sub_type == " group_ban" ){
174+ return std::unique_ptr<Event::EventBase>( new Event::GroupBanNotice ());
175+ } else if (event.sub_type == " friend_add" ){
176+ return std::unique_ptr<Event::EventBase>(new Event::FriendAddNotice ());
177+ } else if (event.sub_type == " group_recall" ){
178+ return std::unique_ptr<Event::EventBase>(new Event::GroupRecallNotice ());
179+ } else if (event.sub_type == " friend_recall" ){
180+ return std::unique_ptr<Event::EventBase>(new Event::FriendRecallNotice ());
181+ } else if (event.sub_type == " group_notify" ){
182+ return std::unique_ptr<Event::EventBase>(new Event::GroupNotifyNotice ());
170183 }
171184 }
172185 return nullptr ;
173186 }
174187
175- // TODO: parse要这边写
176188 void Event::GroupMsg::parse () {
177189 this ->time = this ->raw_msg [" time" ];
178190 this ->user_id = raw_msg[" user_id" ];
@@ -262,4 +274,57 @@ namespace twobot {
262274 this ->sub_type = INVITE;
263275 }
264276
277+ void Event::GroupBanNotice::parse (){
278+ this ->time = this ->raw_msg [" time" ];
279+ this ->self_id = raw_msg[" self_id" ];
280+ this ->group_id = raw_msg[" group_id" ];
281+ this ->user_id = raw_msg[" user_id" ];
282+ this ->operator_id = raw_msg[" operator_id" ];
283+ this ->duration = raw_msg[" duration" ];
284+ this ->sub_type = ( raw_msg[" sub_type" ] == " ban" ) ? BAN : LIFT_BAN;
285+ }
286+
287+ void Event::FriendAddNotice::parse (){
288+ this ->time = this ->raw_msg [" time" ];
289+ this ->self_id = raw_msg[" self_id" ];
290+ this ->user_id = raw_msg[" user_id" ];
291+ }
292+
293+ void Event::FriendRecallNotice::parse (){
294+ this ->time = this ->raw_msg [" time" ];
295+ this ->self_id = raw_msg[" self_id" ];
296+ this ->user_id = raw_msg[" user_id" ];
297+ this ->message_id = raw_msg[" message_id" ];
298+ }
299+
300+ void Event::GroupRecallNotice::parse (){
301+ this ->time = this ->raw_msg [" time" ];
302+ this ->self_id = raw_msg[" self_id" ];
303+ this ->group_id = raw_msg[" group_id" ];
304+ this ->message_id = raw_msg[" message_id" ];
305+ this ->operator_id = raw_msg[" operator_id" ];
306+ this ->user_id = raw_msg[" user_id" ];
307+ }
308+
309+ void Event::GroupNotifyNotice::parse (){
310+ this ->time = this ->raw_msg [" time" ];
311+ this ->self_id = raw_msg[" self_id" ];
312+ this ->user_id = raw_msg[" user_id" ];
313+ this ->group_id = raw_msg[" group_id" ];
314+ if (raw_msg[" sub_type" ] == " poke" ){
315+ this ->sub_type = POKE;
316+ this ->target_id = raw_msg[" target_id" ];
317+ } else if (raw_msg[" sub_type" ] == " lucky_king" ){
318+ this ->sub_type = LUCKY_KING;
319+ this ->target_id = raw_msg[" target_id" ];
320+ } else {
321+ this ->sub_type = HONOR;
322+ if (raw_msg[" honor_type" ] == " talkative" )
323+ this ->honor_type = TALKATIVE;
324+ else if (raw_msg[" honor_type" ] == " performer" )
325+ this ->honor_type = PERFORMER;
326+ else if (raw_msg[" honor_type" ] == " emotion" )
327+ this ->honor_type = EMOTION;
328+ }
329+ }
265330};
0 commit comments