@@ -38,68 +38,60 @@ namespace Cyan
3838 return bot_->SendMessage (Sender.Group .GID , mc, GetMessageId ());
3939 }
4040
41- bool GroupMessage::Recall ()
41+ bool GroupMessage::Recall () const
4242 {
4343 return bot_->Recall (GetMessageId ());
4444 }
4545
46- bool GroupMessage::AtMe ()
46+ bool GroupMessage::AtMe () const
4747 {
4848 auto at = MessageChain.GetAt ();
4949 auto it = std::find (at.begin (), at.end (), bot_->GetBotQQ ());
5050 if (it != at.end ()) return true ;
5151 else return false ;
5252 }
5353
54- bool NewFriendRequestEvent::Respose (int operate, const string& message)
54+ bool NewFriendRequestEvent::Response (int operate, const string& message)
5555 {
5656 json data =
5757 {
5858 { " sessionKey" , bot_->GetSessionKey () },
5959 { " eventId" , this ->EventId },
60- { " fromId" , ( int64_t ) this ->FromId },
61- { " groupId" , ( int64_t ) this ->GroupId },
60+ { " fromId" , int64_t ( this ->FromId ) },
61+ { " groupId" , int64_t ( this ->GroupId ) },
6262 { " operate" , operate},
6363 { " message" , message},
6464 };
6565
6666 httplib::Client& http_client = *(bot_->GetHttpClient ());
6767 auto res = http_client.Post (" /resp/newFriendRequestEvent" , data.dump (), " application/json;charset=UTF-8" );
68- if (res)
69- {
70- if (res->status != 200 )
71- throw std::runtime_error (" [mirai-api-http error]: " + res->body );
72- return true ;
73- }
74- else
68+ if (!res)
7569 throw std::runtime_error (" 网络错误" );
76-
70+ if (res->status != 200 )
71+ throw std::runtime_error (" [mirai-api-http error]: " + res->body );
72+ return true ;
7773 }
7874
79- bool MemberJoinRequestEvent::Respose (int operate, const string& message)
75+ bool MemberJoinRequestEvent::Response (int operate, const string& message)
8076 {
8177
8278 json data =
8379 {
8480 { " sessionKey" , bot_->GetSessionKey () },
8581 { " eventId" , this ->EventId },
86- { " fromId" , ( int64_t ) this ->FromId },
87- { " groupId" , ( int64_t ) this ->GroupId },
82+ { " fromId" , int64_t ( this ->FromId ) },
83+ { " groupId" , int64_t ( this ->GroupId ) },
8884 { " operate" , operate},
8985 { " message" , message},
9086 };
9187
9288 httplib::Client& http_client = *(bot_->GetHttpClient ());
9389 auto res = http_client.Post (" /resp/memberJoinRequestEvent" , data.dump (), " application/json;charset=UTF-8" );
94- if (res)
95- {
96- if (res->status != 200 )
97- throw std::runtime_error (" [mirai-api-http error]: " + res->body );
98- return true ;
99- }
100- else
90+ if (!res)
10191 throw std::runtime_error (" 网络错误" );
102-
92+ if (res->status != 200 )
93+ throw std::runtime_error (" [mirai-api-http error]: " + res->body );
94+ return true ;
10395 }
10496
10597}
0 commit comments