/** Retrieve the 10 most recent tweet ids in the user's news feed. Each item in the news feed must be posted by users who the user followed or by the user herself. Tweets must be ordered from most recent to least recent. */ vector<int> getNewsFeed(int userId) { vector<int> newsFeed; priority_queue<tweet> recentTweets; if(!users[userId].tweets.empty()) { recentTweets.push(tweet(users[userId].tweets[(int)users[userId].tweets.size() - 1].first, userId, (int)users[userId].tweets.size() - 1, users[userId].tweets[(int)users[userId].tweets.size() - 1].second)); } for(auto it = users[userId].followeeIds.begin(); it != users[userId].followeeIds.end(); ++it) { if(!users[*it].tweets.empty()) { recentTweets.push(tweet(users[*it].tweets[(int)users[*it].tweets.size() - 1].first, *it, (int)users[*it].tweets.size() - 1, users[*it].tweets[(int)users[*it].tweets.size() - 1].second)); } } while((int)newsFeed.size() < 10 and !recentTweets.empty()) { newsFeed.push_back(recentTweets.top().tweetId); int id = recentTweets.top().userId; int indx = recentTweets.top().indx; recentTweets.pop(); if(indx > 0) { recentTweets.push(tweet(users[id].tweets[indx - 1].first, id, indx - 1, users[id].tweets[indx - 1].second)); } } return newsFeed; }
int TwitterProto::OnChatOutgoing(WPARAM, LPARAM lParam) { GCHOOK *hook = reinterpret_cast<GCHOOK*>(lParam); if (mir_strcmp(hook->pDest->pszModule, m_szModuleName)) return 0; switch (hook->pDest->iType) { case GC_USER_MESSAGE: debugLog(_T("**Chat - Outgoing message: %s"), hook->ptszText); { T2Utf text(hook->ptszText); std::string tweet(text); replaceAll(tweet, "%%", "%"); // the chat plugin will turn "%" into "%%", so we have to change it back :/ char *varTweet = mir_strdup(tweet.c_str()); ForkThread(&TwitterProto::SendTweetWorker, varTweet); } break; case GC_USER_PRIVMESS: { ptrA text(mir_t2a(hook->ptszUID)); CallService(MS_MSG_SENDMESSAGE, WPARAM(UsernameToHContact(text)), 0); } break; } return 0; }
void TwitterShieldClass::tweet(String data) { int dataLength = data.length(); char cTypeData[dataLength+1]; for (int i = 0; i <dataLength; i++) { cTypeData[i]=data[i]; } cTypeData[dataLength]='\0'; tweet(cTypeData); }
void execCommand(char* command) { // Interpret the user command if(isCommand("boot\0", command)) { interrupt(33, 11, 0, 0, 0); } else if(isCommand("cls\0", command)) { interrupt(33, 12, 4, 11, 0); } else if(isCommand("dir\0", command)) { printDir(); } else if(isCommand("copy\0", command)) { copy(command + 5); } else if(isCommand("del\0", command)) { delete(command + 4); } else if(isCommand("echo\0", command)) { echo(command + 5); } else if(isCommand("type\0", command)) { type(command + 5); } else if(isCommand("run\0", command)) { run(command + 4); } else if(isCommand("tweet\0", command)) { tweet(command + 6); } else if(isCommand("help\0", command)) { help(); } else { commandNotRecognized(); } }
void TwitterShieldClass::tweet(String data) { const char * cTypeData = data.c_str(); tweet(cTypeData); }
//-------------------------------------------------------------- void testApp::draw() { if(face.found > 0) { // draw a face ofPushMatrix(); ofTranslate(face.posePosition); ofScale(face.poseScale, face.poseScale); ofSetColor(0); ofNoFill(); ofEllipse(-20, face.eyeLeft * -9, 20, 7); ofEllipse(20, face.eyeRight * -9, 20, 7); ofEllipse(0, 20, face.mouthWidth * 3, face.mouthHeight * 3); ofEllipse(-5, face.nostrils * -1, 7, 3); ofEllipse(5, face.nostrils * -1, 7, 3); ofSetRectMode(OF_RECTMODE_CENTER); ofFill(); ofRect(-20, face.eyebrowLeft * -5, 25, 5); ofRect(20, face.eyebrowRight * -5, 25, 5); ofSetRectMode(OF_RECTMODE_CORNER); ofPopMatrix(); // catch emotion if(face.mouthHeight > 5){ // Tweet if(!mouth_open) { tweet(); mouth_open = true; ofDrawBitmapString(requestStr,20,20); ofDrawBitmapString(responseStr,20,60); } // fetch Twitter Trend if(parsed) { ofSetHexColor(0x000000); int n=0; ofxJSONElement trends = json[n]["trends"]; for(int i=0; i<trends.size(); i++) { string message = trends[i]["query"].asString(); message = ofxJSONElement::decodeURL( message ); //cout << message << endl; font.drawString(message, 10, 40*i+40); //franklinBook.drawString(message, 10, 40*i+40); } } }else{ mouth_open = false; } } }
void CocosEventHandler::onTweetPress(QString s, QString t) { emit tweet(s, t); }
void main() { char x[512]; char buffer[512]; int size; while(1) { interrupt(33,0,"cxxxx][===blackdos===> \0",0,0); /* Takes command line input */ SCANS(x); PRINTS("\r\n\0"); if(strcmp(x,"boot\0") == 1) { BOOT; } else if(strcmp(x,"cls\0") == 1) { clr(); } else if(strcmp(x,"help\0") == 1) { help(); } else if(strcmp(x,"echo\0") == 1) { echo(x+5); } else if(strcmp(x,"type\0") == 1) { loadF(x+5,buffer,size); } else if(strcmp(x,"run\0") == 1) { runF(x+4); } else if(strcmp(x,"del\0") == 1) { delF(x+4); } else if(strcmp(x,"dir\0") == 1) { dir(); } else if(strcmp(x,"tweet\0") == 1) { tweet(x+6); } else if(strcmp(x,"cp\0") == 1) { copy(x+3); } else { interrupt(33,0,"\r\nBad command or filename\r\n\0",0,0); } interrupt(33,0,"\r\n\0",0,0); } END; }