about summary refs log tree commit diff stats
path: root/lunatic.cpp
diff options
context:
space:
mode:
authorKelly Rauchenberger <fefferburbia@gmail.com>2018-03-02 20:13:06 -0500
committerKelly Rauchenberger <fefferburbia@gmail.com>2018-03-02 20:13:06 -0500
commit161973846f76a15f0d7c9fba3d85c1b389ab5c84 (patch)
tree740a7300dba343717986112659563baefbf97561 /lunatic.cpp
parent5b7bf82edb672d5d5dbd8b1de64532aeec695661 (diff)
downloadlunatic-161973846f76a15f0d7c9fba3d85c1b389ab5c84.tar.gz
lunatic-161973846f76a15f0d7c9fba3d85c1b389ab5c84.tar.bz2
lunatic-161973846f76a15f0d7c9fba3d85c1b389ab5c84.zip
Added blacklist back
Diffstat (limited to 'lunatic.cpp')
-rw-r--r--lunatic.cpp28
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