diff --git a/build/CMakeFiles/gbp-bot.dir/CXX.includecache b/build/CMakeFiles/gbp-bot.dir/CXX.includecache index 0cb730d..c15b37a 100644 --- a/build/CMakeFiles/gbp-bot.dir/CXX.includecache +++ b/build/CMakeFiles/gbp-bot.dir/CXX.includecache @@ -1121,8 +1121,12 @@ gbp.cpp /home/seth/documents/programming/discord-bots/gbp/src/gbp.cpp string - +unordered_map +- vector - +algorithm +- /home/seth/documents/programming/discord-bots/gbp/src/gbp.cpp string diff --git a/build/CMakeFiles/gbp-bot.dir/src/main.cpp.o b/build/CMakeFiles/gbp-bot.dir/src/main.cpp.o index 60f8858..f26c474 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 4e03ea9..99e2907 100644 --- a/src/commands.cpp +++ b/src/commands.cpp @@ -1,11 +1,16 @@ #include "gbp.cpp" #include +#include #include +#include #define FILE_WARNING "/FILE/" +#define EMBED_WARNING "/EMBED/" std::string printFullGBPList(bool = false); std::string genericResponse(); +std::string helpMessage(); +std::string findNum(int pos); /** * ##commandParse @@ -17,12 +22,24 @@ std::string genericResponse(); */ std::string commandParse(std::vector args) { - if (args[0] == "gbplist") - return printFullGBPList(args[1] == "update" ? true : false); - else if (args[0] == "hi") + if (args[0] == "gbplist") { + if (args.size() >= 2) + return printFullGBPList(args[1] == "update" ? true : false); + else + return printFullGBPList(); + } else if (args[0] == "hi") { return genericResponse(); - else + } else if (args[0] == "help") { + return helpMessage(); + } else if (args[0] == "findpos" ) { + if (args.size() >= 2) + return findNum(std::stoi(args[1])); + else + return "Invalid command!"; + + } else { return "Invalid command!"; + } } #define FILE_NAME "temp-GBP" @@ -57,6 +74,13 @@ std::string printFullGBPList(bool update) } #undef FILE_NAME +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"; + return out; +} + /** * ##genericResponse * @@ -66,3 +90,20 @@ std::string genericResponse() { return "Fuck you"; } + +/** + * ##helpMessage + * + * Return the list of commands. + */ + +std::string helpMessage() +{ + std::string out; + out += "```\n"; + out += "Available Commands: \n"; + out += "gbplist (update):\n"; + out += "----> Print out the current GBP leaderboard. Add update to fetch the latest page.\n"; + out += "```\n"; + return out; +} diff --git a/src/gbp.cpp b/src/gbp.cpp index 140b907..962daa6 100644 --- a/src/gbp.cpp +++ b/src/gbp.cpp @@ -13,8 +13,8 @@ void fetchLatestGBP() FILE* fp; Py_Initialize(); - fp = _Py_fopen("gbp-leaderboard.py", "r"); - PyRun_SimpleFile(fp, "gbp-leaderboard.py"); + fp = _Py_fopen("../src/gbp-leaderboard.py", "r"); + PyRun_SimpleFile(fp, "../src/gbp-leaderboard.py"); Py_Finalize(); } diff --git a/src/main.cpp b/src/main.cpp index 41a0340..34a2458 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -78,7 +78,6 @@ void onMessage(dpp::cluster &bot, dpp::message msg) std::vector messageArgs = separateArgs(msgContent); dpp::message toSend; if (messageArgs[0] == std::string(FILE_WARNING)) { - std::cout << "Handling file!\n"; toSend = dpp::message(msg.channel_id, ""); toSend.add_file("gbp-list.txt", dpp::utility::read_file(messageArgs[1])); } else {