improved find name
This commit is contained in:
parent
8bf125ce6e
commit
2c726b556e
Binary file not shown.
@ -42,6 +42,9 @@ std::string commandParse(std::vector<std::string> args)
|
||||
} else if (args[0] == "findgbp") {
|
||||
if (args.size() >= 2)
|
||||
return findGBP(std::stoi(args[1]));
|
||||
} else if (args[0] == "fetchgbp") {
|
||||
fetchLatestGBP();
|
||||
return "Fetched latest GBP!";
|
||||
}
|
||||
return "Invalid command!";
|
||||
}
|
||||
@ -103,13 +106,18 @@ std::string findNum(int pos)
|
||||
*/
|
||||
std::string findName(std::string user)
|
||||
{
|
||||
std::string out = "```";
|
||||
std::map<unsigned short int, std::pair<int, std::string>> gbp = readGBPIntoList();
|
||||
for (std::map<unsigned short int, std::pair<int, std::string>>::iterator it = gbp.begin(); it != gbp.end(); it++) {
|
||||
if (it->second.second.find(user) != -1) {
|
||||
return "```#" + std::to_string(it->first) + ": " + it->second.second + " (" + std::to_string(it->second.first) + " GBP)```\n";
|
||||
out += "#" + std::to_string(it->first) + ": " + it->second.second + " (" + std::to_string(it->second.first) + " GBP)\n";
|
||||
}
|
||||
}
|
||||
out += "```";
|
||||
|
||||
if (out == "``````")
|
||||
return "User not found!";
|
||||
return out;
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user