Skip to content
This repository was archived by the owner on Aug 16, 2024. It is now read-only.

Commit 4a70b3e

Browse files
committed
重构 event_func.cpp
1 parent ae19822 commit 4a70b3e

File tree

1 file changed

+8
-16
lines changed

1 file changed

+8
-16
lines changed

src/event_func.cpp

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -65,15 +65,11 @@ namespace Cyan
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

7975
bool MemberJoinRequestEvent::Respose(int operate, const string& message)
@@ -91,15 +87,11 @@ namespace Cyan
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

Comments
 (0)