diff options
| -rw-r--r-- | manifesto.cpp | 18 |
1 files changed, 9 insertions, 9 deletions
| diff --git a/manifesto.cpp b/manifesto.cpp index b81c66a..3c440c3 100644 --- a/manifesto.cpp +++ b/manifesto.cpp | |||
| @@ -15,26 +15,26 @@ int main(int argc, char** argv) | |||
| 15 | 15 | ||
| 16 | std::string configfile(argv[1]); | 16 | std::string configfile(argv[1]); |
| 17 | YAML::Node config = YAML::LoadFile(configfile); | 17 | YAML::Node config = YAML::LoadFile(configfile); |
| 18 | 18 | ||
| 19 | twitter::auth auth; | 19 | twitter::auth auth; |
| 20 | auth.setConsumerKey(config["consumer_key"].as<std::string>()); | 20 | auth.setConsumerKey(config["consumer_key"].as<std::string>()); |
| 21 | auth.setConsumerSecret(config["consumer_secret"].as<std::string>()); | 21 | auth.setConsumerSecret(config["consumer_secret"].as<std::string>()); |
| 22 | auth.setAccessKey(config["access_key"].as<std::string>()); | 22 | auth.setAccessKey(config["access_key"].as<std::string>()); |
| 23 | auth.setAccessSecret(config["access_secret"].as<std::string>()); | 23 | auth.setAccessSecret(config["access_secret"].as<std::string>()); |
| 24 | 24 | ||
| 25 | twitter::client client(auth); | 25 | twitter::client client(auth); |
| 26 | 26 | ||
| 27 | long loc = 0; | 27 | long loc = 0; |
| 28 | if (config["current_location"]) | 28 | if (config["current_location"]) |
| 29 | { | 29 | { |
| 30 | loc = config["current_location"].as<long>(); | 30 | loc = config["current_location"].as<long>(); |
| 31 | } | 31 | } |
| 32 | 32 | ||
| 33 | std::list<std::string> tweets; | 33 | std::list<std::string> tweets; |
| 34 | { | 34 | { |
| 35 | std::ifstream corpus(config["corpus"].as<std::string>()); | 35 | std::ifstream corpus(config["corpus"].as<std::string>()); |
| 36 | corpus.ignore(loc); | 36 | corpus.ignore(loc); |
| 37 | 37 | ||
| 38 | char buffer[140]; | 38 | char buffer[140]; |
| 39 | while (corpus) | 39 | while (corpus) |
| 40 | { | 40 | { |
| @@ -42,14 +42,14 @@ int main(int argc, char** argv) | |||
| 42 | tweets.push_back(std::string(buffer, 140)); | 42 | tweets.push_back(std::string(buffer, 140)); |
| 43 | } | 43 | } |
| 44 | } | 44 | } |
| 45 | 45 | ||
| 46 | while (!tweets.empty()) | 46 | while (!tweets.empty()) |
| 47 | { | 47 | { |
| 48 | try | 48 | try |
| 49 | { | 49 | { |
| 50 | std::string nextTweet = tweets.front(); | 50 | std::string nextTweet = tweets.front(); |
| 51 | client.updateStatus(nextTweet); | 51 | client.updateStatus(nextTweet); |
| 52 | 52 | ||
| 53 | std::cout << "Tweeted!" << std::endl; | 53 | std::cout << "Tweeted!" << std::endl; |
| 54 | 54 | ||
| 55 | loc += 140; | 55 | loc += 140; |
| @@ -64,9 +64,9 @@ int main(int argc, char** argv) | |||
| 64 | { | 64 | { |
| 65 | std::cout << "Twitter error: " << e.what() << std::endl; | 65 | std::cout << "Twitter error: " << e.what() << std::endl; |
| 66 | } | 66 | } |
| 67 | 67 | ||
| 68 | std::cout << "Waiting..." << std::endl; | 68 | std::cout << "Waiting..." << std::endl; |
| 69 | 69 | ||
| 70 | std::this_thread::sleep_for(std::chrono::hours(6)); | 70 | std::this_thread::sleep_for(std::chrono::hours(6)); |
| 71 | } | 71 | } |
| 72 | } | 72 | } |
