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",
"https://testnet-dm2.bitdeals.org",
"--debug",
"deal",
"account",
"status",
"--is-paid",
"2NDkN9PWdvf8T3AFe57vDsQX9qeJG5Y5iJW"
"-f",
"n",
"mraXx7JrmAmuKypdJ1vseQBXySsdRZE5AC"
],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",

View File

@@ -27,13 +27,14 @@ void AccountHelp(bool isRussian)
/// @param address адресс АПИ
/// @param bkaddress номер кошелька
/// @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"
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());
if (result.length() == 0) return NoResponse("");
if (result.length() == 0)
return NoResponse("");
nlohmann::json jsonData = nlohmann::json::parse(result);
string payload("");
@@ -43,31 +44,35 @@ int AccountStatus(const std::string address, const char* bkaddress, bool isDebug
string decoded = base64_decode(payload);
string cleaned = cleanup_html(decoded);
cout << cleaned << endl;
if (isDebug) ShowDebug(url, result, success, decoded);
if (success) return 0; else return 1;
if (isDebug)
ShowDebug(url, result, success, decoded);
if (success)
return 0;
else
return 1;
}
/// @brief Получение информации аккаунта
/// @param address адресс АПИ
/// @param bkaddress номер кошелька
/// @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
string url("curl -s ");
url.append("-H \"Content-Type: application/json\" ");
url.append("-d \"{ \\\"code\\\": \\\"");
url.append(bkaddress);
url.append("\\\"} \" ");
url.append("\\\"} \" ");
url.append(address);
url.append("/api/v1/user/profile");
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);
string bitcoin("");
string btckey("");
string bitmessage("");
@@ -78,9 +83,6 @@ int AccountInfo(const std::string address, const char* bkaddress, bool isDebug)
bitmessage = jsonData["bitmessages"][0];
pgpkey = jsonData["pgpkey"];
string decoded("");
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("\n");
decoded.append("bitmessage: ");
decoded.append(bitmessage);
decoded.append("\n");
decoded.append("pgpkey: ");
decoded.append(pgpkey);
decoded.append("\n");
cout << decoded << endl;
if (isDebug) ShowDebug(url, result, 1, decoded);
if (isDebug)
ShowDebug(url, result, 1, decoded);
return 0;
}
@@ -112,23 +112,22 @@ int AccountInfo(const std::string address, const char* bkaddress, bool isDebug)
/// @param address адресс АПИ
/// @param bkaddress номер кошелька
/// @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
string url("curl -s ");
url.append("-H \"Content-Type: application/json\" ");
url.append("-d \"{ \\\"code\\\": \\\"");
url.append(bkaddress);
url.append("\\\"} \" ");
url.append("\\\"} \" ");
url.append(address);
url.append("/api/v1/user/profile");
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);
std::ostringstream stream;
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 << " positive: " << jsonData["seller"]["positive"] << endl;
stream << "customer: " << endl;
stream << " count: " << jsonData["customer"]["count"] << 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();
cout << decoded << endl;
if (isDebug) ShowDebug(url, result, 1, decoded);
if (isDebug)
ShowDebug(url, result, 1, decoded);
return 0;
}
/// @brief Получение Рейтинга аккаунта
/// @param address адресс АПИ
/// @param bkaddress номер кошелька
/// @param isDebug флаг отладки
/// @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" \
@@ -172,12 +170,12 @@ int AccountFeedbacks(const std::string address, const char* bkaddress, bool isDe
url.append(bkaddress);
url.append("\\\"}],\\\"orderby\\\":[\\\" date DESC\\\"],\\\"reclimit\\\":100,\\\"recoffset\\\":0} \" ");
url.append(address);
url.append("/api/v1/deal/feedback/list");
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);
std::ostringstream stream;
@@ -185,7 +183,8 @@ int AccountFeedbacks(const std::string address, const char* bkaddress, bool isDe
int positivefb = 0;
int negativefb = 0;
for (size_t i = 0;i < size;++i) {
for (size_t i = 0; i < size; ++i)
{
// "positive"
// "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];
string statustext = val["statustext"];
if (statustext.compare("positive") == 0) positivefb++;
if (statustext.compare("negative") == 0) negativefb++;
if (statustext.compare("positive") == 0)
positivefb++;
if (statustext.compare("negative") == 0)
negativefb++;
if (fb == 0) {
if (fb == 0)
{
stream << "- deal: " << val["deal"] << endl;
stream << " date: " << val["date"] << endl;
stream << " statustext: " << val["statustext"] << endl;
stream << " comments: " << val["comments"] << endl;
}
else {
if (fb == 1 && statustext.compare("positive") == 0) {
else
{
if (fb == 1 && statustext.compare("positive") == 0)
{
stream << "- deal: " << val["deal"] << endl;
stream << " date: " << val["date"] << endl;
stream << " statustext: " << val["statustext"] << 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 << " date: " << val["date"] << endl;
stream << " statustext: " << val["statustext"] << endl;
stream << " comments: " << val["comments"] << endl;
}
}
}
stream << "------------Summary--------------" << endl;
stream << "total: " << size << endl;
@@ -229,11 +230,10 @@ int AccountFeedbacks(const std::string address, const char* bkaddress, bool isDe
string decoded = stream.str();
cout << decoded << endl;
if (isDebug) ShowDebug(url, result, 1, decoded);
if (isDebug)
ShowDebug(url, result, 1, decoded);
return 0;
return 0;
}