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

Commit 1ba073b

Browse files
authored
Merge pull request #8 from cyanray/dev/cyanray
修复mirai重启导致异常崩溃的问题
2 parents bf6b65c + 43fa78c commit 1ba073b

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/mirai_bot.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -798,15 +798,21 @@ namespace Cyan
798798
if (!event_json_str.empty())
799799
{
800800
json j = json::parse(event_json_str);
801-
if (j.find("code") != j.end() && j["code"].get<int>() == 3)
801+
// code 不存在,说明没错误,处理事件/消息
802+
if (j.find("code") == j.end())
803+
{
804+
ProcessEvents(j);
805+
event_json_str.resize(0);
806+
continue;
807+
}
808+
// code 存在,按照 code 进行错误处理
809+
if (j["code"].get<int>() == 3 || j["code"].get<int>() == 4)
802810
{
803811
Release();
804812
Auth(authKey_, qq_);
805813
SessionConfigure(cacheSize_, ws_enabled_);
806814
throw std::runtime_error("失去与mirai的连接,尝试重新验证...");
807815
}
808-
ProcessEvents(j);
809-
event_json_str.resize(0);
810816
}
811817
}
812818
}

0 commit comments

Comments
 (0)