some file handling stuff

This commit is contained in:
SuperNovaa41 2022-03-04 09:25:27 -05:00
parent ddec57e4b3
commit 2df93a60cc
3 changed files with 20 additions and 6 deletions

View File

@ -1,6 +1,9 @@
#include "gbp.cpp" #include "gbp.cpp"
#include <string> #include <string>
#define FILE_WARNING "/FILE/"
#define FILE_NAME "temp-GBP"
std::string printFullGBPList(bool update = false) std::string printFullGBPList(bool update = false)
{ {
std::map<int, std::pair<int, std::string>> gbp; std::map<int, std::pair<int, std::string>> gbp;
@ -9,11 +12,21 @@ std::string printFullGBPList(bool update = false)
else else
gbp = readGBPIntoList(); gbp = readGBPIntoList();
std::string msg = ""; std::ofstream file;
file.open("temp-GBP");
std::string line;
for (std::map<int, std::pair<int, std::string>>::iterator it = gbp.begin(); it != gbp.end(); it++) { for (std::map<int, std::pair<int, std::string>>::iterator it = gbp.begin(); it != gbp.end(); it++) {
msg += std::to_string(it->first) + ": " + it->second.second + "(" + std::to_string(it->second.first) + " GBP)\n"; line = std::to_string(it->first) + ": " + it->second.second + " (" + std::to_string(it->second.first) + " GBP)\n";
file << line;
} }
return msg; file.close();
}
std::string out;
out.append(FILE_WARNING);
out.append(" ");
out.append(FILE_NAME);
return out;
}
#undef FILE_NAME

View File

@ -49,8 +49,9 @@ void onMessage(dpp::cluster &bot, dpp::message msg)
std::string argument = msg.content.substr(argIdx, msg.content.length() - argIdx); std::string argument = msg.content.substr(argIdx, msg.content.length() - argIdx);
std::string msgContent = ""; std::string msgContent = "";
if (argument == "gbp")
msgContent = printFullGBPList();
dpp::message toSend = dpp::message(msg.channel_id, msgContent); dpp::message toSend = dpp::message(msg.channel_id, msgContent);