diff options
Diffstat (limited to 'main.cpp')
-rw-r--r-- | main.cpp | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/main.cpp b/main.cpp new file mode 100644 index 0000000..e1cdb8b --- /dev/null +++ b/main.cpp | |||
@@ -0,0 +1,38 @@ | |||
1 | #include "fanmail.h" | ||
2 | #include <iostream> | ||
3 | |||
4 | int main(int argc, char** argv) | ||
5 | { | ||
6 | Magick::InitializeMagick(nullptr); | ||
7 | |||
8 | std::random_device randomDevice; | ||
9 | std::mt19937 rng(randomDevice()); | ||
10 | |||
11 | // We also have to seed the C-style RNG because librawr uses it. | ||
12 | srand(time(NULL)); | ||
13 | rand(); rand(); rand(); rand(); | ||
14 | |||
15 | if (argc != 2) | ||
16 | { | ||
17 | std::cout << "usage: fanmail [configfile]" << std::endl; | ||
18 | return -1; | ||
19 | } | ||
20 | |||
21 | std::string configfile(argv[1]); | ||
22 | |||
23 | try | ||
24 | { | ||
25 | fanmail bot(configfile, rng); | ||
26 | |||
27 | try | ||
28 | { | ||
29 | bot.run(); | ||
30 | } catch (const std::exception& ex) | ||
31 | { | ||
32 | std::cout << "Error running bot: " << ex.what() << std::endl; | ||
33 | } | ||
34 | } catch (const std::exception& ex) | ||
35 | { | ||
36 | std::cout << "Error initializing bot: " << ex.what() << std::endl; | ||
37 | } | ||
38 | } | ||