From d4c7cc7bf69b81c63c4229d4a7ae505a1180dc90 Mon Sep 17 00:00:00 2001 From: Kelly Rauchenberger Date: Tue, 31 May 2016 09:59:57 -0400 Subject: Added caption to tweets --- CMakeLists.txt | 7 +++---- infinite.cpp | 16 +++++++++++++--- vendor/libtwittercpp | 2 +- vendor/verbly | 2 +- 4 files changed, 18 insertions(+), 9 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 900f8d4..1c72ef4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,12 +8,11 @@ add_subdirectory(vendor/verbly) add_subdirectory(vendor/yaml-cpp EXCLUDE_FROM_ALL) find_package(PkgConfig) -pkg_check_modules(sqlite3 sqlite3>=3.8.3 REQUIRED) pkg_check_modules(GraphicsMagick GraphicsMagick++ REQUIRED) -include_directories(${GraphicsMagick_INCLUDE_DIRS} ${sqlite3_INCLUDE_DIR} vendor/verbly/lib vendor/libtwittercpp/src vendor/yaml-cpp/include vendor/libtwittercpp/vendor/json/src vendor/libtwittercpp/vendor/curlcpp/include) -link_directories(${sqlite3_LIBRARY_DIRS} ${GraphicsMagick_LIBRARY_DIRS}) +include_directories(${GraphicsMagick_INCLUDE_DIRS} vendor/verbly/lib vendor/libtwittercpp/src vendor/yaml-cpp/include) +link_directories(${GraphicsMagick_LIBRARY_DIRS}) add_executable(infinite infinite.cpp color.cpp fractal.cpp matrix3x3.cpp vector3d.cpp tinyxml2.cpp triangle.cpp) set_property(TARGET infinite PROPERTY CXX_STANDARD 11) set_property(TARGET infinite PROPERTY CXX_STANDARD_REQUIRED ON) -target_link_libraries(infinite ${GraphicsMagick_LIBRARIES} verbly ${sqlite3_LIBRARIES} yaml-cpp twitter++ curlcpp) +target_link_libraries(infinite ${GraphicsMagick_LIBRARIES} verbly yaml-cpp twitter++) diff --git a/infinite.cpp b/infinite.cpp index 0016178..1086169 100644 --- a/infinite.cpp +++ b/infinite.cpp @@ -733,10 +733,11 @@ int main(int argc, char** argv) closedir(fontdir); + std::string subaction = action; std::string font = fonts[rand() % fonts.size()]; if (font == "Le_Super_Type_SemiBold.ttf") { - std::transform(std::begin(action), std::end(action), std::begin(action), [] (char ch) { + std::transform(std::begin(subaction), std::end(subaction), std::begin(subaction), [] (char ch) { return std::toupper(ch); }); } @@ -747,7 +748,7 @@ int main(int argc, char** argv) textimage.fontPointsize(72.0); textimage.font("fonts/" + font); - auto words = verbly::split>(action, " "); + auto words = verbly::split>(subaction, " "); std::string towrite = ""; std::string curline = ""; Magick::TypeMetric metric; @@ -788,8 +789,17 @@ int main(int argc, char** argv) continue; } + std::string tweetText; + size_t tweetLim = 140 - client.getConfiguration().getCharactersReservedPerMedia() - 2; + if (action.length() > tweetLim) + { + tweetText = "\"" + action.substr(0, tweetLim - 1) + "…\""; + } else { + tweetText = "\"" + action + "\""; + } + twitter::tweet tw; - resp = client.updateStatus("", tw, {media_id}); + resp = client.updateStatus(tweetText, tw, twitter::tweet(), {media_id}); if (resp != twitter::response::ok) { std::cout << "Twitter error while tweeting: " << resp << std::endl; diff --git a/vendor/libtwittercpp b/vendor/libtwittercpp index f465dce..aceb3cc 160000 --- a/vendor/libtwittercpp +++ b/vendor/libtwittercpp @@ -1 +1 @@ -Subproject commit f465dce27cf0f07039e29d8975ad98939f0df3a9 +Subproject commit aceb3cc33ee78cce1077252aff8a8808a3195ff1 diff --git a/vendor/verbly b/vendor/verbly index e7299f7..6c2aca0 160000 --- a/vendor/verbly +++ b/vendor/verbly @@ -1 +1 @@ -Subproject commit e7299f7bf66df7e62bf36ef42ab7810086d088c5 +Subproject commit 6c2aca03c89b37e136ab4c7ea58b485dadc85bcd -- cgit 1.4.1