Findpos command
This commit is contained in:
parent
8e29c3dfa6
commit
c4f555bc6e
@ -1121,8 +1121,12 @@ gbp.cpp
|
|||||||
/home/seth/documents/programming/discord-bots/gbp/src/gbp.cpp
|
/home/seth/documents/programming/discord-bots/gbp/src/gbp.cpp
|
||||||
string
|
string
|
||||||
-
|
-
|
||||||
|
unordered_map
|
||||||
|
-
|
||||||
vector
|
vector
|
||||||
-
|
-
|
||||||
|
algorithm
|
||||||
|
-
|
||||||
|
|
||||||
/home/seth/documents/programming/discord-bots/gbp/src/gbp.cpp
|
/home/seth/documents/programming/discord-bots/gbp/src/gbp.cpp
|
||||||
string
|
string
|
||||||
|
Binary file not shown.
@ -1,11 +1,16 @@
|
|||||||
#include "gbp.cpp"
|
#include "gbp.cpp"
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <unordered_map>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
#define FILE_WARNING "/FILE/"
|
#define FILE_WARNING "/FILE/"
|
||||||
|
#define EMBED_WARNING "/EMBED/"
|
||||||
|
|
||||||
std::string printFullGBPList(bool = false);
|
std::string printFullGBPList(bool = false);
|
||||||
std::string genericResponse();
|
std::string genericResponse();
|
||||||
|
std::string helpMessage();
|
||||||
|
std::string findNum(int pos);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ##commandParse
|
* ##commandParse
|
||||||
@ -17,12 +22,24 @@ std::string genericResponse();
|
|||||||
*/
|
*/
|
||||||
std::string commandParse(std::vector<std::string> args)
|
std::string commandParse(std::vector<std::string> args)
|
||||||
{
|
{
|
||||||
if (args[0] == "gbplist")
|
if (args[0] == "gbplist") {
|
||||||
return printFullGBPList(args[1] == "update" ? true : false);
|
if (args.size() >= 2)
|
||||||
else if (args[0] == "hi")
|
return printFullGBPList(args[1] == "update" ? true : false);
|
||||||
|
else
|
||||||
|
return printFullGBPList();
|
||||||
|
} else if (args[0] == "hi") {
|
||||||
return genericResponse();
|
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!";
|
return "Invalid command!";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#define FILE_NAME "temp-GBP"
|
#define FILE_NAME "temp-GBP"
|
||||||
@ -57,6 +74,13 @@ std::string printFullGBPList(bool update)
|
|||||||
}
|
}
|
||||||
#undef FILE_NAME
|
#undef FILE_NAME
|
||||||
|
|
||||||
|
std::string findNum(int pos)
|
||||||
|
{
|
||||||
|
std::map<unsigned short int, std::pair<int, std::string>> gbp = readGBPIntoList();
|
||||||
|
std::string out = "#" + std::to_string(pos) + ": " + gbp[pos].second + " (" + std::to_string(gbp[pos].first) + "GBP)\n";
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ##genericResponse
|
* ##genericResponse
|
||||||
*
|
*
|
||||||
@ -66,3 +90,20 @@ std::string genericResponse()
|
|||||||
{
|
{
|
||||||
return "Fuck you";
|
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;
|
||||||
|
}
|
||||||
|
@ -13,8 +13,8 @@ void fetchLatestGBP()
|
|||||||
FILE* fp;
|
FILE* fp;
|
||||||
|
|
||||||
Py_Initialize();
|
Py_Initialize();
|
||||||
fp = _Py_fopen("gbp-leaderboard.py", "r");
|
fp = _Py_fopen("../src/gbp-leaderboard.py", "r");
|
||||||
PyRun_SimpleFile(fp, "gbp-leaderboard.py");
|
PyRun_SimpleFile(fp, "../src/gbp-leaderboard.py");
|
||||||
Py_Finalize();
|
Py_Finalize();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -78,7 +78,6 @@ void onMessage(dpp::cluster &bot, dpp::message msg)
|
|||||||
std::vector<std::string> messageArgs = separateArgs(msgContent);
|
std::vector<std::string> messageArgs = separateArgs(msgContent);
|
||||||
dpp::message toSend;
|
dpp::message toSend;
|
||||||
if (messageArgs[0] == std::string(FILE_WARNING)) {
|
if (messageArgs[0] == std::string(FILE_WARNING)) {
|
||||||
std::cout << "Handling file!\n";
|
|
||||||
toSend = dpp::message(msg.channel_id, "");
|
toSend = dpp::message(msg.channel_id, "");
|
||||||
toSend.add_file("gbp-list.txt", dpp::utility::read_file(messageArgs[1]));
|
toSend.add_file("gbp-list.txt", dpp::utility::read_file(messageArgs[1]));
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user