diff --git a/build/CMakeFiles/gbp-bot.dir/src/main.cpp.o b/build/CMakeFiles/gbp-bot.dir/src/main.cpp.o index f26c474..e377722 100644 Binary files a/build/CMakeFiles/gbp-bot.dir/src/main.cpp.o and b/build/CMakeFiles/gbp-bot.dir/src/main.cpp.o differ diff --git a/src/commands.cpp b/src/commands.cpp index 99e2907..cd2ed1a 100644 --- a/src/commands.cpp +++ b/src/commands.cpp @@ -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 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!"; } @@ -77,10 +84,20 @@ std::string printFullGBPList(bool update) std::string findNum(int pos) { std::map> gbp = readGBPIntoList(); - std::string out = "#" + std::to_string(pos) + ": " + gbp[pos].second + " (" + std::to_string(gbp[pos].first) + "GBP)\n"; + std::string out = "#" + std::to_string(pos) + ": " + gbp[pos].second + " (" + std::to_string(gbp[pos].first) + " GBP)\n"; return out; } +std::string findName(std::string user) +{ + std::map> gbp = readGBPIntoList(); + for (std::map>::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 *