From 0e6355329f241a3e3c8b38cb4146fda4470e6ed0 Mon Sep 17 00:00:00 2001 From: Kelly Rauchenberger Date: Mon, 26 Mar 2018 15:33:06 -0400 Subject: Whitespace changes --- cadence.cpp | 54 +++++++++++++++++++++++++++--------------------------- 1 file changed, 27 insertions(+), 27 deletions(-) (limited to 'cadence.cpp') diff --git a/cadence.cpp b/cadence.cpp index c91ca4a..80e4a05 100644 --- a/cadence.cpp +++ b/cadence.cpp @@ -24,16 +24,16 @@ int main(int argc, char** argv) std::string configfile(argv[1]); YAML::Node config = YAML::LoadFile(configfile); - + // Set up the Twitter client. 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); - + // Read in the forms file. std::map> groups; std::ifstream datafile(config["forms"].as()); @@ -42,7 +42,7 @@ int main(int argc, char** argv) std::cout << "Could not find forms file." << std::endl; return 1; } - + bool newgroup = true; std::string line; std::string curgroup; @@ -52,7 +52,7 @@ int main(int argc, char** argv) { line.pop_back(); } - + if (newgroup) { curgroup = line; @@ -70,10 +70,10 @@ int main(int argc, char** argv) // Initialize the random number generator. std::random_device random_device; std::mt19937 random_engine{random_device()}; - + // Connect to the AcousticBrainz data file. sqlite3* ppdb = nullptr; - + if (sqlite3_open_v2(config["acoustic_datafile"].as().c_str(), &ppdb, SQLITE_OPEN_READONLY, NULL) != SQLITE_OK) { // We still have to free the resources allocated. In the event that @@ -82,19 +82,19 @@ int main(int argc, char** argv) sqlite3_close_v2(ppdb); std::cout << "Could not open acoustic datafile." << std::endl; - + return 1; } for (;;) { std::cout << "Generating tweet..." << std::endl; - + std::string mood = moods[std::uniform_int_distribution(0, moods.size()-1)(random_engine)]; - + std::string songTitle; std::string songArtist; - + sqlite3_stmt* ppstmt; std::string query = "SELECT title, artist FROM songs WHERE category = ? ORDER BY RANDOM() LIMIT 1"; @@ -102,12 +102,12 @@ int main(int argc, char** argv) { std::cout << "Error reading from acoustic datafile:" << std::endl; std::cout << sqlite3_errmsg(ppdb) << std::endl; - + return 1; } - + sqlite3_bind_text(ppstmt, 1, mood.c_str(), mood.length(), SQLITE_TRANSIENT); - + if (sqlite3_step(ppstmt) == SQLITE_ROW) { songTitle = reinterpret_cast(sqlite3_column_blob(ppstmt, 0)); @@ -115,10 +115,10 @@ int main(int argc, char** argv) } else { std::cout << "Error reading from acoustic datafile:" << std::endl; std::cout << sqlite3_errmsg(ppdb) << std::endl; - + return 1; } - + sqlite3_finalize(ppstmt); std::string action = "{" + cadence::uppercase(mood) + "}"; @@ -133,12 +133,12 @@ int main(int argc, char** argv) modifier = token.substr(modloc+1); token = token.substr(0, modloc); } - + std::string canontkn; std::transform(std::begin(token), std::end(token), std::back_inserter(canontkn), [] (char ch) { return std::toupper(ch); }); - + std::string result; if (canontkn == "\\N") { @@ -157,10 +157,10 @@ int main(int argc, char** argv) } else { std::cout << "Badly formatted forms file:" << std::endl; std::cout << "No such form as " + canontkn << std::endl; - + return 1; } - + if (modifier == "indefinite") { if ((result.length() > 1) && (isupper(result[0])) && (isupper(result[1]))) @@ -173,7 +173,7 @@ int main(int argc, char** argv) result = "a " + result; } } - + std::string finalresult; if (islower(token[0])) { @@ -187,21 +187,21 @@ int main(int argc, char** argv) { word[0] = std::toupper(word[0]); } - + finalresult = cadence::implode(std::begin(words), std::end(words), " "); } else { finalresult = result; } - + action.replace(tknloc, action.find("}")-tknloc+1, finalresult); } - + if (action.size() <= 140) { try { client.updateStatus(action); - + std::cout << action << std::endl; } catch (const twitter::twitter_error& e) { @@ -209,9 +209,9 @@ int main(int argc, char** argv) } std::cout << "Waiting..." << std::endl; - + std::this_thread::sleep_for(std::chrono::hours(1)); - + std::cout << std::endl; } else { std::cout << "Tweet was too long, regenerating." << std::endl; -- cgit 1.4.1