List of usage examples for twitter4j DirectMessage getText
String getText();
From source file:com.marpies.ane.twitter.functions.SendDirectMessageFunction.java
License:Apache License
@Override public void sentDirectMessage(DirectMessage message) { AIR.log("Success sending DM '" + message.getText() + "'"); try {//from w w w. j a va2s. c o m JSONObject dmJSON = DirectMessageUtils.getJSON(message); dmJSON.put("listenerID", mCallbackID); dmJSON.put("success", "true"); AIR.dispatchEvent(AIRTwitterEvent.DIRECT_MESSAGE_QUERY_SUCCESS, dmJSON.toString()); } catch (JSONException e) { e.printStackTrace(); AIR.dispatchEvent(AIRTwitterEvent.DIRECT_MESSAGE_QUERY_SUCCESS, StringUtils.getEventErrorJSON(mCallbackID, e.getMessage())); } }
From source file:com.marpies.ane.twitter.utils.DirectMessageUtils.java
License:Apache License
public static JSONObject getJSON(DirectMessage message) throws JSONException { JSONObject dmJSON = new twitter4j.JSONObject(); dmJSON.put("id", message.getId()); dmJSON.put("idStr", String.valueOf(message.getId())); dmJSON.put("text", message.getText()); dmJSON.put("createdAt", message.getCreatedAt()); dmJSON.put("recipient", UserUtils.getJSON(message.getRecipient())); dmJSON.put("sender", UserUtils.getJSON(message.getSender())); return dmJSON; }
From source file:com.narvis.frontend.twitter.input.Input.java
License:Open Source License
@Override public void onDirectMessage(DirectMessage directMessage) { NarvisLogger.logInfo("Received directmessage from user : " + directMessage.getSenderId() + " with content : " + directMessage.getText()); }
From source file:com.test.GetDirectMessages.java
License:Apache License
/** * Usage: java twitter4j.examples.directmessage.GetDirectMessages * * @param args String[]/*from w w w . java 2s. c o m*/ */ public static void main(String[] args) { // Twitter twitter = new TwitterFactory().getInstance(); Twitter twitter = AccountTwitterFactory.getWiseManTwitter(); try { Paging paging = new Paging(1); List<DirectMessage> messages; do { messages = twitter.getDirectMessages(paging); for (DirectMessage message : messages) { System.out.println("From: @" + message.getSenderScreenName() + " id:" + message.getId() + " - " + message.getText()); } paging.setPage(paging.getPage() + 1); } while (messages.size() > 0 && paging.getPage() < 10); System.out.println("done."); System.exit(0); } catch (TwitterException te) { te.printStackTrace(); System.out.println("Failed to get messages: " + te.getMessage()); System.exit(-1); } }
From source file:com.tuncaysenturk.jira.plugins.jtp.twitter.JiraTwitterUserStreamListener.java
public void onDirectMessage(DirectMessage directMessage) { logger.info("just logging, onDirectMessage text:" + directMessage.getText()); }
From source file:com.tweetmyhome.TweetMyHome.java
/** * Si me llegan mensajes significa que lo estoy siguiendo... * @param directMessage //from w w w. j a va 2 s . c o m */ @Override public void onDirectMessage(DirectMessage directMessage) { String text = directMessage.getText(); debug("onDirectMessage text: @" + directMessage.getSender().getScreenName() + " : " + text); if (TwitterUserUtil.equals(directMessage.getSender().getScreenName(), p.getValueByKey(Key.twitterSuperUser))) { debug("Own tweet detected..."); return; } User user = directMessage.getSender(); TweetStringAnalizer tsa; try { tsa = new TweetStringAnalizer(text, tweetDictionary); if (!tsa.isErrorFounded()) { db.add(new SimpleDirectMessage(this, directMessage.getId(), directMessage.getSenderId(), null, text, Calendar.getInstance().getTimeInMillis())); analyzeAndRespond(user, tsa, true); } else { // pasa si no reconose el mensaje error(tsa.getErrorString().toString()); } } catch (TweetStringException | TwitterException | TweetMyHomeException ex) { error(ex.toString(), ex); } }
From source file:de.vanita5.twittnuker.model.ParcelableDirectMessage.java
License:Open Source License
public ParcelableDirectMessage(final DirectMessage message, final long account_id, final boolean is_outgoing) { this.account_id = account_id; this.is_outgoing = is_outgoing; final User sender = message.getSender(), recipient = message.getRecipient(); final String sender_profile_image_url_string = sender != null ? ParseUtils.parseString(sender.getProfileImageUrlHttps()) : null;//from w w w .j av a2 s . c o m final String recipient_profile_image_url_string = recipient != null ? ParseUtils.parseString(recipient.getProfileImageUrlHttps()) : null; id = message.getId(); timestamp = getTime(message.getCreatedAt()); sender_id = sender != null ? sender.getId() : -1; recipient_id = recipient != null ? recipient.getId() : -1; text_html = formatDirectMessageText(message); text_plain = message.getText(); sender_name = sender != null ? sender.getName() : null; recipient_name = recipient != null ? recipient.getName() : null; sender_screen_name = sender != null ? sender.getScreenName() : null; recipient_screen_name = recipient != null ? recipient.getScreenName() : null; sender_profile_image_url = sender_profile_image_url_string; recipient_profile_image_url = recipient_profile_image_url_string; text_unescaped = toPlainText(text_html); medias = ParcelableMedia.fromEntities(message); first_media = medias != null && medias.length > 0 ? medias[0].url : null; }
From source file:de.vanita5.twittnuker.util.ContentValuesCreator.java
License:Open Source License
public static ContentValues makeDirectMessageContentValues(final DirectMessage message, final long account_id, final boolean is_outgoing, final boolean large_profile_image) { if (message == null || message.getId() <= 0) return null; final ContentValues values = new ContentValues(); final User sender = message.getSender(), recipient = message.getRecipient(); if (sender == null || recipient == null) return null; final String sender_profile_image_url = ParseUtils.parseString(sender.getProfileImageUrlHttps()); final String recipient_profile_image_url = ParseUtils.parseString(recipient.getProfileImageUrlHttps()); values.put(DirectMessages.ACCOUNT_ID, account_id); values.put(DirectMessages.MESSAGE_ID, message.getId()); values.put(DirectMessages.MESSAGE_TIMESTAMP, message.getCreatedAt().getTime()); values.put(DirectMessages.SENDER_ID, sender.getId()); values.put(DirectMessages.RECIPIENT_ID, recipient.getId()); final String text_html = Utils.formatDirectMessageText(message); values.put(DirectMessages.TEXT_HTML, text_html); values.put(DirectMessages.TEXT_PLAIN, message.getText()); values.put(DirectMessages.TEXT_UNESCAPED, toPlainText(text_html)); values.put(DirectMessages.IS_OUTGOING, is_outgoing); values.put(DirectMessages.SENDER_NAME, sender.getName()); values.put(DirectMessages.SENDER_SCREEN_NAME, sender.getScreenName()); values.put(DirectMessages.RECIPIENT_NAME, recipient.getName()); values.put(DirectMessages.RECIPIENT_SCREEN_NAME, recipient.getScreenName()); values.put(DirectMessages.SENDER_PROFILE_IMAGE_URL, large_profile_image ? getBiggerTwitterProfileImage(sender_profile_image_url) : sender_profile_image_url); values.put(DirectMessages.RECIPIENT_PROFILE_IMAGE_URL, large_profile_image ? getBiggerTwitterProfileImage(recipient_profile_image_url) : recipient_profile_image_url); final ParcelableMedia[] mediaArray = ParcelableMedia.fromEntities(message); if (mediaArray != null) { values.put(DirectMessages.MEDIA, JSONSerializer.toJSONArrayString(mediaArray)); values.put(DirectMessages.FIRST_MEDIA, mediaArray[0].url); }//w w w . j a v a 2s. c o m return values; }
From source file:main.TwitterController.java
License:Open Source License
public void listDirectMessages() throws TwitterException { List<DirectMessage> statusList = null; int counter = 0; BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); statusList = twitter.getDirectMessages(); Iterator<DirectMessage> iterator = statusList.iterator(); while (iterator.hasNext()) { DirectMessage s = iterator.next(); System.out.println(++counter + " [" + s.getCreatedAt().toString() + "] " + printUser(s.getSender()) + " to " + printUser(s.getRecipient()) + ": " + s.getText()); if (counter % 10 == 0) { System.out.print("Hit [Enter] to continue, or type q to break: "); String str = null;// w w w. jav a 2 s . c om try { str = in.readLine(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } if (str.length() > 0 && (str.charAt(0) == 'Q' || str.charAt(0) == 'q')) return; } } }
From source file:net.lacolaco.smileessence.twitter.util.TwitterUtils.java
License:Open Source License
public static String getMessageSummary(DirectMessage message) { return String.format("@%s: %s", message.getSender().getScreenName(), message.getText()); }