mirror of
https://github.com/MaaAssistantArknights/MaaAssistantArknights.git
synced 2026-07-16 17:57:01 +08:00
feat: 确实上传企鹅和一图流的回调结果正确
fix https://github.com/MaaAssistantArknights/MaaAssistantArknights/issues/1681
This commit is contained in:
@@ -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": {
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user