mirror of
https://github.com/MaaAssistantArknights/MaaAssistantArknights.git
synced 2026-07-18 18:20:39 +08:00
52 lines
1.4 KiB
C++
52 lines
1.4 KiB
C++
#pragma once
|
|
|
|
#include "AbstractTask.h"
|
|
#include "Utils/AsstHttp.hpp"
|
|
#include "Utils/AsstUtils.hpp"
|
|
|
|
#include <cctype>
|
|
#include <future>
|
|
#include <unordered_set>
|
|
|
|
namespace asst
|
|
{
|
|
enum class ReportType
|
|
{
|
|
Invaild,
|
|
PenguinStats,
|
|
YituliuBigData,
|
|
};
|
|
|
|
class ReportDataTask : public AbstractTask
|
|
{
|
|
public:
|
|
using AbstractTask::AbstractTask;
|
|
virtual ~ReportDataTask() override;
|
|
|
|
ReportDataTask& set_report_type(ReportType type);
|
|
|
|
ReportDataTask& set_body(std::string body);
|
|
ReportDataTask& set_extra_param(std::string extra_param);
|
|
|
|
protected:
|
|
using HttpResponsePred = std::function<bool(const http::Response&)>;
|
|
|
|
virtual bool _run() override;
|
|
|
|
void report_to_penguin();
|
|
void report_to_yituliu();
|
|
http::Response escape_and_request(const std::string& format);
|
|
http::Response report(
|
|
const std::string& subtask, const std::string& format,
|
|
HttpResponsePred success_cond = [](const http::Response& response) -> bool { return response.success(); },
|
|
HttpResponsePred retry_cond = [](const http::Response& response) -> bool {
|
|
return !response.status_code() || response.status_5xx();
|
|
});
|
|
|
|
ReportType m_report_type = ReportType::Invaild;
|
|
std::string m_body;
|
|
std::string m_extra_param;
|
|
std::vector<std::future<void>> m_upload_pending;
|
|
};
|
|
} // namespace asst
|