diff --git a/backends/twitter/TwitterPlugin.cpp b/backends/twitter/TwitterPlugin.cpp index 75fd083426f1198305f271e3e0f1fc46dd7b60bc..d8a1af28d224aeca338b3ef3bb9e575fb5ca8c8a 100644 --- a/backends/twitter/TwitterPlugin.cpp +++ b/backends/twitter/TwitterPlugin.cpp @@ -191,7 +191,7 @@ void TwitterPlugin::handleMessageSendRequest(const std::string &user, const std: else if(cmd[0] == '@') { std::string username = cmd.substr(1); tp->runAsThread(new DirectMessageRequest(sessions[user], user, username, data, - boost::bind(&TwitterPlugin::directMessageResponse, this, _1, _2, _3))); + boost::bind(&TwitterPlugin::directMessageResponse, this, _1, _2, _3, _4))); } else if(cmd == "#status") tp->runAsThread(new StatusUpdateRequest(sessions[user], user, data, boost::bind(&TwitterPlugin::statusUpdateResponse, this, _1, _2))); @@ -207,13 +207,14 @@ void TwitterPlugin::handleMessageSendRequest(const std::string &user, const std: boost::bind(&TwitterPlugin::RetweetResponse, this, _1, _2))); else if(twitterMode == CHATROOM) { std::string buddy = message.substr(0, message.find(":")); - if(buddy == "") { - handleMessage(user, adminLegacyName, "Unknown command! Type #help for a list of available commands.", adminNickName); - return; + if(chatroomBuddies[user].count(buddy) == 0) { + tp->runAsThread(new StatusUpdateRequest(sessions[user], user, message, + boost::bind(&TwitterPlugin::statusUpdateResponse, this, _1, _2))); + } else { + data = message.substr(message.find(":")+1); + tp->runAsThread(new DirectMessageRequest(sessions[user], user, buddy, data, + boost::bind(&TwitterPlugin::directMessageResponse, this, _1, _2, _3, _4))); } - data = message.substr(message.find(":")+1); - tp->runAsThread(new DirectMessageRequest(sessions[user], user, buddy, data, - boost::bind(&TwitterPlugin::directMessageResponse, this, _1, _2, _3))); } else handleMessage(user, adminLegacyName, "Unknown command! Type #help for a list of available commands.", adminNickName); } @@ -223,7 +224,7 @@ void TwitterPlugin::handleMessageSendRequest(const std::string &user, const std: if(twitterMode == CHATROOM) buddy = legacyName.substr(legacyName.find("/") + 1); if(legacyName != "twitter") { tp->runAsThread(new DirectMessageRequest(sessions[user], user, buddy, message, - boost::bind(&TwitterPlugin::directMessageResponse, this, _1, _2, _3))); + boost::bind(&TwitterPlugin::directMessageResponse, this, _1, _2, _3, _4))); } } } @@ -271,7 +272,7 @@ void TwitterPlugin::pollForDirectMessages() while(it != onlineUsers.end()) { std::string user = *it; tp->runAsThread(new DirectMessageRequest(sessions[user], user, "", mostRecentDirectMessageID[user], - boost::bind(&TwitterPlugin::directMessageResponse, this, _1, _2, _3))); + boost::bind(&TwitterPlugin::directMessageResponse, this, _1, _2, _3, _4))); it++; } message_timer->start(); @@ -423,8 +424,10 @@ void TwitterPlugin::populateRoster(std::string &user, std::vector &friends for(int i=0 ; i(), pbnetwork::STATUS_ONLINE); - else + else { handleParticipantChanged(user, friends[i].getScreenName(), adminLegacyName, 0, pbnetwork::STATUS_ONLINE); + chatroomBuddies[user].insert(friends[i].getScreenName()); + } } } else handleMessage(user, adminLegacyName, std::string("Error populating roster - ") + errMsg, adminNickName); @@ -451,25 +454,34 @@ void TwitterPlugin::displayTweets(std::string &user, std::string &userRequested, std::string timeline = ""; for(int i=0 ; i &messages, std::string &errMsg) +void TwitterPlugin::directMessageResponse(std::string &user, std::string &username, std::vector &messages, std::string &errMsg) { if(errMsg.length()) { handleMessage(user, adminLegacyName, std::string("Error while sending direct message! - ") + errMsg, adminNickName); return; } + + if(username != "") { + handleMessage(user, adminLegacyName, "Message delivered!", adminNickName); + return; + } if(!messages.size()) return; @@ -489,14 +501,17 @@ void TwitterPlugin::directMessageResponse(std::string &user, std::vector(), pbnetwork::STATUS_ONLINE); + } else if(twitterMode == CHATROOM) { + handleParticipantChanged(user, frnd, adminLegacyName, 0, pbnetwork::STATUS_ONLINE); + chatroomBuddies[user].insert(frnd); } } @@ -526,11 +542,14 @@ void TwitterPlugin::deleteFriendResponse(std::string &user, std::string &frnd, s if(errMsg.length()) { handleMessage(user, adminLegacyName, errMsg, adminNickName); return; - } if(twitterMode == SINGLECONTACT) { - handleMessage(user, adminLegacyName, std::string("You are not following ") + frnd + " anymore", adminNickName); - } else if(twitterMode == MULTIPLECONTACT) { - handleMessage(user, adminLegacyName, std::string("You are not following ") + frnd + " anymore", adminNickName); + } + + handleMessage(user, adminLegacyName, std::string("You are not following ") + frnd + " anymore", adminNickName); + if(twitterMode == MULTIPLECONTACT) { handleBuddyRemoved(user, frnd); + } else if (twitterMode == CHATROOM) { + handleParticipantChanged(user, frnd, adminLegacyName, 0, pbnetwork::STATUS_NONE); + chatroomBuddies[user].erase(frnd); } }