summary refs log tree commit diff stats
path: root/infinite.cpp
diff options
context:
space:
mode:
authorKelly Rauchenberger <fefferburbia@gmail.com>2016-05-31 09:59:57 -0400
committerKelly Rauchenberger <fefferburbia@gmail.com>2016-05-31 09:59:57 -0400
commitd4c7cc7bf69b81c63c4229d4a7ae505a1180dc90 (patch)
tree3c46d8db66427a41ddff51e57c505d12ff2bc96c /infinite.cpp
parent09cb5b468d20820219e9e341ee25ae17c2a5e089 (diff)
downloadinfinite-d4c7cc7bf69b81c63c4229d4a7ae505a1180dc90.tar.gz
infinite-d4c7cc7bf69b81c63c4229d4a7ae505a1180dc90.tar.bz2
infinite-d4c7cc7bf69b81c63c4229d4a7ae505a1180dc90.zip
Added caption to tweets
Diffstat (limited to 'infinite.cpp')
-rw-r--r--infinite.cpp16
1 files changed, 13 insertions, 3 deletions
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)
733 733
734 closedir(fontdir); 734 closedir(fontdir);
735 735
736 std::string subaction = action;
736 std::string font = fonts[rand() % fonts.size()]; 737 std::string font = fonts[rand() % fonts.size()];
737 if (font == "Le_Super_Type_SemiBold.ttf") 738 if (font == "Le_Super_Type_SemiBold.ttf")
738 { 739 {
739 std::transform(std::begin(action), std::end(action), std::begin(action), [] (char ch) { 740 std::transform(std::begin(subaction), std::end(subaction), std::begin(subaction), [] (char ch) {
740 return std::toupper(ch); 741 return std::toupper(ch);
741 }); 742 });
742 } 743 }
@@ -747,7 +748,7 @@ int main(int argc, char** argv)
747 textimage.fontPointsize(72.0); 748 textimage.fontPointsize(72.0);
748 textimage.font("fonts/" + font); 749 textimage.font("fonts/" + font);
749 750
750 auto words = verbly::split<std::list<std::string>>(action, " "); 751 auto words = verbly::split<std::list<std::string>>(subaction, " ");
751 std::string towrite = ""; 752 std::string towrite = "";
752 std::string curline = ""; 753 std::string curline = "";
753 Magick::TypeMetric metric; 754 Magick::TypeMetric metric;
@@ -788,8 +789,17 @@ int main(int argc, char** argv)
788 continue; 789 continue;
789 } 790 }
790 791
792 std::string tweetText;
793 size_t tweetLim = 140 - client.getConfiguration().getCharactersReservedPerMedia() - 2;
794 if (action.length() > tweetLim)
795 {
796 tweetText = "\"" + action.substr(0, tweetLim - 1) + "…\"";
797 } else {
798 tweetText = "\"" + action + "\"";
799 }
800
791 twitter::tweet tw; 801 twitter::tweet tw;
792 resp = client.updateStatus("", tw, {media_id}); 802 resp = client.updateStatus(tweetText, tw, twitter::tweet(), {media_id});
793 if (resp != twitter::response::ok) 803 if (resp != twitter::response::ok)
794 { 804 {
795 std::cout << "Twitter error while tweeting: " << resp << std::endl; 805 std::cout << "Twitter error while tweeting: " << resp << std::endl;