diff --git a/resource/config.json b/resource/config.json index 2d7ce0af2f..32b4957a7f 100644 --- a/resource/config.json +++ b/resource/config.json @@ -14,12 +14,12 @@ "adbExtraSwipeDuration_Doc": "额外的滑动持续时间:adb有bug,同样的参数,偶尔会划得非常远。额外做一个短程滑动,把之前的停下来。若小于0,则关闭额外滑动功能", "penguinReport": { "Doc": "企鹅物流汇报: https://penguin-stats.cn/", - "cmdFormat": "curl -H \"Content-Type: application/json\" -s -S -m 20 -i -d \"[body]\" \"https://penguin-stats.cn/PenguinStats/api/v2/report\" [extra]", + "cmdFormat": "curl -H \"Content-Type: application/json\" -s -S -m 5 -i -d \"[body]\" \"https://penguin-stats.cn/PenguinStats/api/v2/report\" [extra]", "cmdFormat_Doc": "命令格式,想打印详细信息可以尝试添加 -v -i" }, "yituliuReport": { "Doc": "一图流汇报:https://yituliu.site/maarecruitdata", - "cmdFormat": "curl -H \"Content-Type: application/json\" -s -S -m 20 -i -d \"[body]\" \"https://houduan.yituliu.site/tool/recruitUpload\" [extra]", + "cmdFormat": "curl -H \"Content-Type: application/json\" -s -S -m 5 -i -d \"[body]\" \"https://houduan.yituliu.site/tool/recruitUpload\" [extra]", "cmdFormat_Doc": "命令格式,想打印详细信息可以尝试添加 -v -i" }, "depotExportTemplate": { diff --git a/src/MeoAssistant/AutoRecruitTask.cpp b/src/MeoAssistant/AutoRecruitTask.cpp index 5c1e354808..e85f625ba1 100644 --- a/src/MeoAssistant/AutoRecruitTask.cpp +++ b/src/MeoAssistant/AutoRecruitTask.cpp @@ -710,10 +710,21 @@ void asst::AutoRecruitTask::upload_to_penguin(const json::value& details) std::string cmd_line = utils::string_replace_all_batch(opt.penguin_report.cmd_format, { { "[body]", body_escapes }, { "[extra]", extra_param } }); - Log.trace("request_penguin |", cmd_line); - + Log.info("request_penguin |", cmd_line); std::string response = utils::callcmd(cmd_line); + Log.info("response:\n", response); + cb_info["details"]["response"] = response; + + static const std::regex http_ok_regex(R"(HTTP/.+ 200 OK)"); + if (std::regex_search(response, http_ok_regex)) { + callback(AsstMsg::SubTaskCompleted, cb_info); + } + else { + cb_info["why"] = "上报失败"; + callback(AsstMsg::SubTaskError, cb_info); + } + static const std::regex penguinid_regex(R"(X-Penguin-Set-Penguinid: (\d+))"); std::smatch penguinid_sm; if (std::regex_search(response, penguinid_sm, penguinid_regex)) { @@ -722,10 +733,6 @@ void asst::AutoRecruitTask::upload_to_penguin(const json::value& details) id_info["details"]["id"] = m_penguin_id; callback(AsstMsg::SubTaskExtraInfo, id_info); } - - Log.trace("request_penguin | response:\n", response); - - callback(AsstMsg::SubTaskCompleted, cb_info); } void asst::AutoRecruitTask::upload_to_yituliu(const json::value& details) @@ -754,12 +761,19 @@ void asst::AutoRecruitTask::upload_to_yituliu(const json::value& details) std::string cmd_line = utils::string_replace_all_batch(opt.yituliu_report.cmd_format, { { "[body]", body_escapes }, { "[extra]", "" } }); - Log.trace("request_yituliu |", cmd_line); std::string response = utils::callcmd(cmd_line); - Log.trace("request_yituliu | response:\n", response); - callback(AsstMsg::SubTaskCompleted, cb_info); + cb_info["details"]["response"] = response; + + static const std::regex http_ok_regex(R"(HTTP/.+ 200 OK)"); + if (std::regex_search(response, http_ok_regex)) { + callback(AsstMsg::SubTaskCompleted, cb_info); + } + else { + cb_info["why"] = "上报失败"; + callback(AsstMsg::SubTaskError, cb_info); + } } diff --git a/src/MeoAssistant/StageDropsTaskPlugin.cpp b/src/MeoAssistant/StageDropsTaskPlugin.cpp index bb63321844..32ffa44263 100644 --- a/src/MeoAssistant/StageDropsTaskPlugin.cpp +++ b/src/MeoAssistant/StageDropsTaskPlugin.cpp @@ -207,20 +207,20 @@ void asst::StageDropsTaskPlugin::upload_to_penguin() auto& opt = Resrc.cfg().get_options(); - json::value info = basic_info(); - info["subtask"] = "ReportToPenguinStats"; - callback(AsstMsg::SubTaskStart, info); + json::value cb_info = basic_info(); + cb_info["subtask"] = "ReportToPenguinStats"; + callback(AsstMsg::SubTaskStart, cb_info); // Doc: https://developer.penguin-stats_vec.io/public-api/api-v2-instruction/report-api std::string stage_id = m_cur_info_json.get("stage", "stageId", std::string()); if (stage_id.empty()) { - info["why"] = "未知关卡"; - callback(AsstMsg::SubTaskError, info); + cb_info["why"] = "未知关卡"; + callback(AsstMsg::SubTaskError, cb_info); return; } if (m_stars != 3) { - info["why"] = "非三星作战"; - callback(AsstMsg::SubTaskError, info); + cb_info["why"] = "非三星作战"; + callback(AsstMsg::SubTaskError, cb_info); return; } json::value body; @@ -234,8 +234,8 @@ void asst::StageDropsTaskPlugin::upload_to_penguin() continue; } if (drop.at("itemId").as_string().empty()) { - info["why"] = "存在未知掉落"; - callback(AsstMsg::SubTaskError, info); + cb_info["why"] = "存在未知掉落"; + callback(AsstMsg::SubTaskError, cb_info); return; } json::value format_drop = drop; @@ -253,11 +253,22 @@ void asst::StageDropsTaskPlugin::upload_to_penguin() extra_param = "-H \"authorization: PenguinID " + m_penguin_id + "\""; } cmd_line = utils::string_replace_all(cmd_line, "[extra]", extra_param); - - Log.trace("request_penguin |", cmd_line); + Log.info("request_penguin |", cmd_line); std::string response = utils::callcmd(cmd_line); + Log.info("response:\n", response); + cb_info["details"]["response"] = response; + + static const std::regex http_ok_regex(R"(HTTP/.+ 200 OK)"); + if (std::regex_search(response, http_ok_regex)) { + callback(AsstMsg::SubTaskCompleted, cb_info); + } + else { + cb_info["why"] = "上报失败"; + callback(AsstMsg::SubTaskError, cb_info); + } + static const std::regex penguinid_regex(R"(X-Penguin-Set-Penguinid: (\d+))"); std::smatch penguinid_sm; if (std::regex_search(response, penguinid_sm, penguinid_regex)) { @@ -266,10 +277,6 @@ void asst::StageDropsTaskPlugin::upload_to_penguin() id_info["details"]["id"] = m_penguin_id; callback(AsstMsg::SubTaskExtraInfo, id_info); } - - Log.trace("response:\n", response); - - callback(AsstMsg::SubTaskCompleted, info); } bool asst::StageDropsTaskPlugin::check_stage_valid()