Close #3 Добавил фильтр к нейтральным

This commit is contained in:
Vladimir N. Korotenko
2025-11-22 17:35:19 +03:00
parent 5ee67e1006
commit d8a1e13a5e
2 changed files with 48 additions and 47 deletions

View File

@@ -12,10 +12,11 @@
"args": [ "--address", "args": [ "--address",
"https://testnet-dm2.bitdeals.org", "https://testnet-dm2.bitdeals.org",
"--debug", "--debug",
"deal", "account",
"status", "status",
"--is-paid", "-f",
"2NDkN9PWdvf8T3AFe57vDsQX9qeJG5Y5iJW" "n",
"mraXx7JrmAmuKypdJ1vseQBXySsdRZE5AC"
], ],
"stopAtEntry": false, "stopAtEntry": false,
"cwd": "${workspaceFolder}", "cwd": "${workspaceFolder}",

View File

@@ -27,13 +27,14 @@ void AccountHelp(bool isRussian)
/// @param address адресс АПИ /// @param address адресс АПИ
/// @param bkaddress номер кошелька /// @param bkaddress номер кошелька
/// @param isDebug флаг отладки /// @param isDebug флаг отладки
int AccountStatus(const std::string address, const char* bkaddress, bool isDebug) int AccountStatus(const std::string address, const char *bkaddress, bool isDebug)
{ {
// curl "https://testnet-dm.bitdeals.org/api/v1/account/status?address=mnumHs9HQMrw2Q1iKLNnx9NzExS7nMLmyp" // curl "https://testnet-dm.bitdeals.org/api/v1/account/status?address=mnumHs9HQMrw2Q1iKLNnx9NzExS7nMLmyp"
string url("curl -s "); string url("curl -s ");
url += address + "/api/v1/account/status?address=" + bkaddress ; url += address + "/api/v1/account/status?address=" + bkaddress;
string result = ExecCommand(url.c_str()); string result = ExecCommand(url.c_str());
if (result.length() == 0) return NoResponse(""); if (result.length() == 0)
return NoResponse("");
nlohmann::json jsonData = nlohmann::json::parse(result); nlohmann::json jsonData = nlohmann::json::parse(result);
string payload(""); string payload("");
@@ -43,16 +44,20 @@ int AccountStatus(const std::string address, const char* bkaddress, bool isDebug
string decoded = base64_decode(payload); string decoded = base64_decode(payload);
string cleaned = cleanup_html(decoded); string cleaned = cleanup_html(decoded);
cout << cleaned << endl; cout << cleaned << endl;
if (isDebug) ShowDebug(url, result, success, decoded); if (isDebug)
if (success) return 0; else return 1; ShowDebug(url, result, success, decoded);
if (success)
return 0;
else
return 1;
} }
/// @brief Получение информации аккаунта /// @brief Получение информации аккаунта
/// @param address адресс АПИ /// @param address адресс АПИ
/// @param bkaddress номер кошелька /// @param bkaddress номер кошелька
/// @param isDebug флаг отладки /// @param isDebug флаг отладки
int AccountInfo(const std::string address, const char* bkaddress, bool isDebug) { int AccountInfo(const std::string address, const char *bkaddress, bool isDebug)
{
// curl -H "Content-Type: application/json" -d "{ \"code\": \"mnumHs9HQMrw2Q1iKLNnx9NzExS7nMLmyp\"}" https://testnet-dm2.bitdeals.org/api/v1/user/profile // curl -H "Content-Type: application/json" -d "{ \"code\": \"mnumHs9HQMrw2Q1iKLNnx9NzExS7nMLmyp\"}" https://testnet-dm2.bitdeals.org/api/v1/user/profile
string url("curl -s "); string url("curl -s ");
@@ -64,10 +69,10 @@ int AccountInfo(const std::string address, const char* bkaddress, bool isDebug)
url.append("/api/v1/user/profile"); url.append("/api/v1/user/profile");
string result = ExecCommand(url.c_str()); string result = ExecCommand(url.c_str());
if (result.length() == 0) return NoResponse(""); if (result.length() == 0)
return NoResponse("");
nlohmann::json jsonData = nlohmann::json::parse(result); nlohmann::json jsonData = nlohmann::json::parse(result);
string bitcoin(""); string bitcoin("");
string btckey(""); string btckey("");
string bitmessage(""); string bitmessage("");
@@ -78,9 +83,6 @@ int AccountInfo(const std::string address, const char* bkaddress, bool isDebug)
bitmessage = jsonData["bitmessages"][0]; bitmessage = jsonData["bitmessages"][0];
pgpkey = jsonData["pgpkey"]; pgpkey = jsonData["pgpkey"];
string decoded(""); string decoded("");
decoded.append("bitcoin: "); decoded.append("bitcoin: ");
decoded.append(bitcoin); decoded.append(bitcoin);
@@ -90,20 +92,18 @@ int AccountInfo(const std::string address, const char* bkaddress, bool isDebug)
decoded.append(btckey); decoded.append(btckey);
decoded.append("\n"); decoded.append("\n");
decoded.append("bitmessage: "); decoded.append("bitmessage: ");
decoded.append(bitmessage); decoded.append(bitmessage);
decoded.append("\n"); decoded.append("\n");
decoded.append("pgpkey: "); decoded.append("pgpkey: ");
decoded.append(pgpkey); decoded.append(pgpkey);
decoded.append("\n"); decoded.append("\n");
cout << decoded << endl; cout << decoded << endl;
if (isDebug) ShowDebug(url, result, 1, decoded); if (isDebug)
ShowDebug(url, result, 1, decoded);
return 0; return 0;
} }
@@ -112,7 +112,8 @@ int AccountInfo(const std::string address, const char* bkaddress, bool isDebug)
/// @param address адресс АПИ /// @param address адресс АПИ
/// @param bkaddress номер кошелька /// @param bkaddress номер кошелька
/// @param isDebug флаг отладки /// @param isDebug флаг отладки
int AccountRaiting(const std::string address, const char* bkaddress, bool isDebug) { int AccountRaiting(const std::string address, const char *bkaddress, bool isDebug)
{
// curl -H "Content-Type: application/json" -d "{ \"code\": \"mnumHs9HQMrw2Q1iKLNnx9NzExS7nMLmyp\"}" https://testnet-dm2.bitdeals.org/api/v1/user/profile // curl -H "Content-Type: application/json" -d "{ \"code\": \"mnumHs9HQMrw2Q1iKLNnx9NzExS7nMLmyp\"}" https://testnet-dm2.bitdeals.org/api/v1/user/profile
string url("curl -s "); string url("curl -s ");
url.append("-H \"Content-Type: application/json\" "); url.append("-H \"Content-Type: application/json\" ");
@@ -123,12 +124,10 @@ int AccountRaiting(const std::string address, const char* bkaddress, bool isDebu
url.append("/api/v1/user/profile"); url.append("/api/v1/user/profile");
string result = ExecCommand(url.c_str()); string result = ExecCommand(url.c_str());
if (result.length() == 0) return NoResponse(""); if (result.length() == 0)
return NoResponse("");
nlohmann::json jsonData = nlohmann::json::parse(result); nlohmann::json jsonData = nlohmann::json::parse(result);
std::ostringstream stream; std::ostringstream stream;
stream << "created: " << jsonData["created"] << endl; stream << "created: " << jsonData["created"] << endl;
@@ -136,7 +135,6 @@ int AccountRaiting(const std::string address, const char* bkaddress, bool isDebu
stream << " count: " << jsonData["seller"]["count"] << endl; stream << " count: " << jsonData["seller"]["count"] << endl;
stream << " positive: " << jsonData["seller"]["positive"] << endl; stream << " positive: " << jsonData["seller"]["positive"] << endl;
stream << "customer: " << endl; stream << "customer: " << endl;
stream << " count: " << jsonData["customer"]["count"] << endl; stream << " count: " << jsonData["customer"]["count"] << endl;
stream << " positive: " << jsonData["customer"]["positive"] << endl; stream << " positive: " << jsonData["customer"]["positive"] << endl;
@@ -144,19 +142,19 @@ int AccountRaiting(const std::string address, const char* bkaddress, bool isDebu
string decoded = stream.str(); string decoded = stream.str();
cout << decoded << endl; cout << decoded << endl;
if (isDebug) ShowDebug(url, result, 1, decoded); if (isDebug)
ShowDebug(url, result, 1, decoded);
return 0; return 0;
} }
/// @brief Получение Рейтинга аккаунта /// @brief Получение Рейтинга аккаунта
/// @param address адресс АПИ /// @param address адресс АПИ
/// @param bkaddress номер кошелька /// @param bkaddress номер кошелька
/// @param isDebug флаг отладки /// @param isDebug флаг отладки
/// @param fb - тип фидбэка 0- все p - 1(positive) n-2 (negative) /// @param fb - тип фидбэка 0- все p - 1(positive) n-2 (negative)
int AccountFeedbacks(const std::string address, const char* bkaddress, bool isDebug, int fb) { int AccountFeedbacks(const std::string address, const char *bkaddress, bool isDebug, int fb)
{
/* /*
curl -X POST "https://testnet-dm2.bitdeals.org/api/v1/deal/feedback/list" \ curl -X POST "https://testnet-dm2.bitdeals.org/api/v1/deal/feedback/list" \
@@ -172,12 +170,12 @@ int AccountFeedbacks(const std::string address, const char* bkaddress, bool isDe
url.append(bkaddress); url.append(bkaddress);
url.append("\\\"}],\\\"orderby\\\":[\\\" date DESC\\\"],\\\"reclimit\\\":100,\\\"recoffset\\\":0} \" "); url.append("\\\"}],\\\"orderby\\\":[\\\" date DESC\\\"],\\\"reclimit\\\":100,\\\"recoffset\\\":0} \" ");
url.append(address); url.append(address);
url.append("/api/v1/deal/feedback/list"); url.append("/api/v1/deal/feedback/list");
string result = ExecCommand(url.c_str()); string result = ExecCommand(url.c_str());
if (result.length() == 0) return NoResponse(""); if (result.length() == 0)
return NoResponse("");
nlohmann::json jsonData = nlohmann::json::parse(result); nlohmann::json jsonData = nlohmann::json::parse(result);
std::ostringstream stream; std::ostringstream stream;
@@ -185,7 +183,8 @@ int AccountFeedbacks(const std::string address, const char* bkaddress, bool isDe
int positivefb = 0; int positivefb = 0;
int negativefb = 0; int negativefb = 0;
for (size_t i = 0;i < size;++i) { for (size_t i = 0; i < size; ++i)
{
// "positive" // "positive"
// "negative" // "negative"
// 0 - все p - 1(positive)n - 2 (negative) // 0 - все p - 1(positive)n - 2 (negative)
@@ -193,33 +192,35 @@ int AccountFeedbacks(const std::string address, const char* bkaddress, bool isDe
auto val = jsonData[i]; auto val = jsonData[i];
string statustext = val["statustext"]; string statustext = val["statustext"];
if (statustext.compare("positive") == 0) positivefb++; if (statustext.compare("positive") == 0)
if (statustext.compare("negative") == 0) negativefb++; positivefb++;
if (statustext.compare("negative") == 0)
negativefb++;
if (fb == 0)
if (fb == 0) { {
stream << "- deal: " << val["deal"] << endl; stream << "- deal: " << val["deal"] << endl;
stream << " date: " << val["date"] << endl; stream << " date: " << val["date"] << endl;
stream << " statustext: " << val["statustext"] << endl; stream << " statustext: " << val["statustext"] << endl;
stream << " comments: " << val["comments"] << endl; stream << " comments: " << val["comments"] << endl;
} }
else { else
if (fb == 1 && statustext.compare("positive") == 0) { {
if (fb == 1 && statustext.compare("positive") == 0)
{
stream << "- deal: " << val["deal"] << endl; stream << "- deal: " << val["deal"] << endl;
stream << " date: " << val["date"] << endl; stream << " date: " << val["date"] << endl;
stream << " statustext: " << val["statustext"] << endl; stream << " statustext: " << val["statustext"] << endl;
stream << " comments: " << val["comments"] << endl; stream << " comments: " << val["comments"] << endl;
} }
else if (fb == 2 && statustext.compare("negative") == 0) { else if (fb == 2 && statustext.compare("negative") == 0 || fb == 2 && statustext.compare("neutral") == 0)
{
stream << "- deal: " << val["deal"] << endl; stream << "- deal: " << val["deal"] << endl;
stream << " date: " << val["date"] << endl; stream << " date: " << val["date"] << endl;
stream << " statustext: " << val["statustext"] << endl; stream << " statustext: " << val["statustext"] << endl;
stream << " comments: " << val["comments"] << endl; stream << " comments: " << val["comments"] << endl;
} }
} }
} }
stream << "------------Summary--------------" << endl; stream << "------------Summary--------------" << endl;
stream << "total: " << size << endl; stream << "total: " << size << endl;
@@ -229,11 +230,10 @@ int AccountFeedbacks(const std::string address, const char* bkaddress, bool isDe
string decoded = stream.str(); string decoded = stream.str();
cout << decoded << endl; cout << decoded << endl;
if (isDebug) ShowDebug(url, result, 1, decoded); if (isDebug)
ShowDebug(url, result, 1, decoded);
return 0; return 0;
return 0; return 0;
} }