about summary refs log tree commit diff stats
path: root/main.cpp
blob: e1cdb8baca0096eae608f0f9fffb07149501476f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#include "fanmail.h"
#include <iostream>

int main(int argc, char** argv)
{
  Magick::InitializeMagick(nullptr);

  std::random_device randomDevice;
  std::mt19937 rng(randomDevice());

  // We also have to seed the C-style RNG because librawr uses it.
  srand(time(NULL));
  rand(); rand(); rand(); rand();

  if (argc != 2)
  {
    std::cout << "usage: fanmail [configfile]" << std::endl;
    return -1;
  }

  std::string configfile(argv[1]);

  try
  {
    fanmail bot(configfile, rng);

    try
    {
      bot.run();
    } catch (const std::exception& ex)
    {
      std::cout << "Error running bot: " << ex.what() << std::endl;
    }
  } catch (const std::exception& ex)
  {
    std::cout << "Error initializing bot: " << ex.what() << std::endl;
  }
}