From 95cd6e298cf6b80476fdcec08c5249ff4530bb16 Mon Sep 17 00:00:00 2001 From: Kelly Rauchenberger Date: Mon, 30 May 2016 11:35:32 -0400 Subject: Initial commit --- .gitmodules | 9 +++++++++ CMakeLists.txt | 12 ++++++++++++ composite.cpp | 39 +++++++++++++++++++++++++++++++++++++++ vendor/libtwittercpp | 1 + vendor/verbly | 1 + vendor/yaml-cpp | 1 + 6 files changed, 63 insertions(+) create mode 100644 .gitmodules create mode 100644 CMakeLists.txt create mode 100644 composite.cpp create mode 160000 vendor/libtwittercpp create mode 160000 vendor/verbly create mode 160000 vendor/yaml-cpp diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..3ac2123 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,9 @@ +[submodule "vendor/libtwittercpp"] + path = vendor/libtwittercpp + url = https://github.com/hatkirby/libtwittercpp +[submodule "vendor/verbly"] + path = vendor/verbly + url = https://github.com/hatkirby/verbly +[submodule "vendor/yaml-cpp"] + path = vendor/yaml-cpp + url = https://github.com/jbeder/yaml-cpp diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..a90ea6e --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,12 @@ +cmake_minimum_required (VERSION 3.1) +project (composite) + +add_subdirectory(vendor/libtwittercpp) +add_subdirectory(vendor/verbly) +add_subdirectory(vendor/yaml-cpp EXCLUDE_FROM_ALL) + +include_directories(vendor/libtwittercpp/src vendor/verbly/lib vendor/yaml-cpp/include) +add_executable(composite composite.cpp) +set_property(TARGET composite PROPERTY CXX_STANDARD 11) +set_property(TARGET composite PROPERTY CXX_STANDARD_REQUIRED ON) +target_link_libraries(composite verbly twitter++ yaml-cpp) diff --git a/composite.cpp b/composite.cpp new file mode 100644 index 0000000..891f179 --- /dev/null +++ b/composite.cpp @@ -0,0 +1,39 @@ +#include +#include +#include +#include +#include +#include +#include + +int main(int argc, char** argv) +{ + YAML::Node config = YAML::LoadFile("config.yml"); + + twitter::auth auth; + auth.setConsumerKey(config["consumer_key"].as()); + auth.setConsumerSecret(config["consumer_secret"].as()); + auth.setAccessKey(config["access_key"].as()); + auth.setAccessSecret(config["access_secret"].as()); + + twitter::client client(auth); + verbly::data database("data.sqlite3"); + + for (;;) + { + std::cout << "Generating..." << std::endl; + auto nq = database.nouns().with_stress({{true, false, false}}).random().limit(1).run().front(); + std::string output = "full metal " + nq.singular_form(); + std::cout << output << std::endl; + + twitter::tweet sent; + twitter::response resp = client.updateStatus(output, sent); + if (resp != twitter::response::ok) + { + std::cout << "Twitter error: " << resp << std::endl; + } + + std::cout << "Waiting..." << std::endl; + std::this_thread::sleep_for(std::chrono::hours(1)); + } +} \ No newline at end of file diff --git a/vendor/libtwittercpp b/vendor/libtwittercpp new file mode 160000 index 0000000..5018801 --- /dev/null +++ b/vendor/libtwittercpp @@ -0,0 +1 @@ +Subproject commit 501880160ac69f90143bc38add541731a9242ab0 diff --git a/vendor/verbly b/vendor/verbly new file mode 160000 index 0000000..6c2aca0 --- /dev/null +++ b/vendor/verbly @@ -0,0 +1 @@ +Subproject commit 6c2aca03c89b37e136ab4c7ea58b485dadc85bcd diff --git a/vendor/yaml-cpp b/vendor/yaml-cpp new file mode 160000 index 0000000..728e26e --- /dev/null +++ b/vendor/yaml-cpp @@ -0,0 +1 @@ +Subproject commit 728e26e42645d4d70ca65522990f915f47b47a50 -- cgit 1.4.1