From 161973846f76a15f0d7c9fba3d85c1b389ab5c84 Mon Sep 17 00:00:00 2001 From: Kelly Rauchenberger Date: Fri, 2 Mar 2018 20:13:06 -0500 Subject: Added blacklist back --- lunatic.cpp | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'lunatic.cpp') diff --git a/lunatic.cpp b/lunatic.cpp index 58a0854..5dd198c 100644 --- a/lunatic.cpp +++ b/lunatic.cpp @@ -8,6 +8,7 @@ #include #include #include +#include #include #include "database.h" @@ -60,12 +61,39 @@ int main(int argc, char** argv) std::random_device randomDevice; std::mt19937 rng(randomDevice()); + std::set blacklist; + if (config["blacklist"].IsScalar()) + { + std::ifstream blfile(config["blacklist"].as()); + + if (!blfile.is_open()) + { + throw std::invalid_argument("Could not find blacklist"); + } + + std::string line; + while (getline(blfile, line)) + { + if (line.back() == '\r') + { + line.pop_back(); + } + + blacklist.insert(line); + } + } + for (;;) { std::cout << "Generating tweet" << std::endl; achievement ach = db.getRandomAchievement(); + if (blacklist.count(ach.title)) + { + continue; + } + Magick::Image moonColor; moonColor.read("res/" + ach.color + ".png"); -- cgit 1.4.1