diff --git a/backends/twitter/main.cpp b/backends/twitter/main.cpp index 9f5c12a83c48cd3f64303d43f505501224bf633f..aa9a9d91494969311e83f8b08344748ab68d2b8c 100644 --- a/backends/twitter/main.cpp +++ b/backends/twitter/main.cpp @@ -203,6 +203,30 @@ class TwitterPlugin : public NetworkPlugin { LOG4CXX_INFO(logger, "Sent PIN " << data << " and obtained access token"); } + if(cmd == "#help") { + std::string helpMsg = "\nHELP\n\ +status: - Update your status\n\ +#timeline - Retrieve your timeline\n\ +@: - Send a directed message to the user \n\ +#help - print this help message\n"; + + handleMessage(user, "twitter-account", helpMsg); + } + + if(cmd[0] == '@') { + std::string username = cmd.substr(1); + if(sessions[user]->directMessageSend(username, data, false) == false) { + LOG4CXX_ERROR(logger, "Error while sending directed message to user " << username ); + return; + } + + LOG4CXX_INFO(logger, "Sending " << data << " to " << username) + + std::string replyMsg; + sessions[user]->getLastWebResponse( replyMsg ); + LOG4CXX_INFO(logger, replyMsg); + } + if(cmd == "status") { if(connectionState[user] != CONNECTED) { LOG4CXX_ERROR(logger, "Trying to update status for " << user << " when not connected!"); @@ -238,9 +262,11 @@ class TwitterPlugin : public NetworkPlugin { LOG4CXX_INFO(logger, "twitCurl::timeline web response: " << replyMsg ); std::vector tweets = getTimeline(replyMsg); + std::string timeline = "\n"; for(int i=0 ; igetLastCurlError( replyMsg ); LOG4CXX_INFO(logger, "twitCurl::timeline error: " << replyMsg );