diff options
Diffstat (limited to 'lunatic.cpp')
-rw-r--r-- | lunatic.cpp | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/lunatic.cpp b/lunatic.cpp index 58a0854..5dd198c 100644 --- a/lunatic.cpp +++ b/lunatic.cpp | |||
@@ -8,6 +8,7 @@ | |||
8 | #include <Magick++.h> | 8 | #include <Magick++.h> |
9 | #include <list> | 9 | #include <list> |
10 | #include <string> | 10 | #include <string> |
11 | #include <set> | ||
11 | #include <sstream> | 12 | #include <sstream> |
12 | #include "database.h" | 13 | #include "database.h" |
13 | 14 | ||
@@ -60,12 +61,39 @@ int main(int argc, char** argv) | |||
60 | std::random_device randomDevice; | 61 | std::random_device randomDevice; |
61 | std::mt19937 rng(randomDevice()); | 62 | std::mt19937 rng(randomDevice()); |
62 | 63 | ||
64 | std::set<std::string> blacklist; | ||
65 | if (config["blacklist"].IsScalar()) | ||
66 | { | ||
67 | std::ifstream blfile(config["blacklist"].as<std::string>()); | ||
68 | |||
69 | if (!blfile.is_open()) | ||
70 | { | ||
71 | throw std::invalid_argument("Could not find blacklist"); | ||
72 | } | ||
73 | |||
74 | std::string line; | ||
75 | while (getline(blfile, line)) | ||
76 | { | ||
77 | if (line.back() == '\r') | ||
78 | { | ||
79 | line.pop_back(); | ||
80 | } | ||
81 | |||
82 | blacklist.insert(line); | ||
83 | } | ||
84 | } | ||
85 | |||
63 | for (;;) | 86 | for (;;) |
64 | { | 87 | { |
65 | std::cout << "Generating tweet" << std::endl; | 88 | std::cout << "Generating tweet" << std::endl; |
66 | 89 | ||
67 | achievement ach = db.getRandomAchievement(); | 90 | achievement ach = db.getRandomAchievement(); |
68 | 91 | ||
92 | if (blacklist.count(ach.title)) | ||
93 | { | ||
94 | continue; | ||
95 | } | ||
96 | |||
69 | Magick::Image moonColor; | 97 | Magick::Image moonColor; |
70 | moonColor.read("res/" + ach.color + ".png"); | 98 | moonColor.read("res/" + ach.color + ".png"); |
71 | 99 | ||