find names
This commit is contained in:
parent
c4f555bc6e
commit
2245e48a66
Binary file not shown.
@ -11,6 +11,7 @@ std::string printFullGBPList(bool = false);
|
||||
std::string genericResponse();
|
||||
std::string helpMessage();
|
||||
std::string findNum(int pos);
|
||||
std::string findName(std::string user);
|
||||
|
||||
/**
|
||||
* ##commandParse
|
||||
@ -37,6 +38,12 @@ std::string commandParse(std::vector<std::string> args)
|
||||
else
|
||||
return "Invalid command!";
|
||||
|
||||
} else if (args[0] == "findname") {
|
||||
if (args.size() >= 2)
|
||||
return findName(args[1]);
|
||||
else
|
||||
return "Invalid command!";
|
||||
|
||||
} else {
|
||||
return "Invalid command!";
|
||||
}
|
||||
@ -81,6 +88,16 @@ std::string findNum(int pos)
|
||||
return out;
|
||||
}
|
||||
|
||||
std::string findName(std::string user)
|
||||
{
|
||||
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 == user)
|
||||
return "#" + std::to_string(it->first) + ": " + it->second.second + " (" + std::to_string(it->second.first) + " GBP)\n";
|
||||
}
|
||||
return "User not found!";
|
||||
}
|
||||
|
||||
/**
|
||||
* ##genericResponse
|
||||
*
|
||||
|
Loading…
x
Reference in New Issue
Block a user