List of usage examples for twitter4j UserMentionEntity getScreenName
String getScreenName();
From source file:com.michaelfitzmaurice.clocktwerk.TweetResponder.java
License:Apache License
private String replyBody(String myScreenName, Status mention, String messageBody) { String replyMessage = "@" + mention.getUser().getScreenName() + " "; for (UserMentionEntity userMentionEntity : mention.getUserMentionEntities()) { String mentionScreenName = userMentionEntity.getScreenName(); if (mentionScreenName.equalsIgnoreCase(myScreenName) == false) { replyMessage += "@" + mentionScreenName + " "; }//from ww w. ja v a 2 s. com } replyMessage += messageBody; return replyMessage; }
From source file:com.mothsoft.alexis.engine.retrieval.TwitterRetrievalTaskImpl.java
License:Apache License
private List<TweetMention> readMentions(Status status) { final List<TweetMention> mentions = new ArrayList<TweetMention>(); if (status.getUserMentionEntities() != null) { for (final UserMentionEntity entity : status.getUserMentionEntities()) { final Long userId = entity.getId(); final String name = entity.getName(); final String screenName = entity.getScreenName(); final TweetMention mention = new TweetMention((short) entity.getStart(), (short) entity.getEnd(), userId, name, screenName); mentions.add(mention);/* w w w.j av a 2 s.c o m*/ } } return mentions; }
From source file:com.raythos.sentilexo.twitter.utils.StatusArraysHelper.java
public static Map<String, Long> getUserMentionMap(Status status) { @SuppressWarnings("MismatchedQueryAndUpdateOfCollection") Map<String, Long> result = new HashMap<>(); for (UserMentionEntity um : status.getUserMentionEntities()) { result.put(um.getScreenName(), um.getId()); }/*w ww . j ava2s . c om*/ return result; }
From source file:com.rhymestore.twitter.stream.GetMentionsListener.java
License:Open Source License
@Override public void onStatus(final Status status) { UserMentionEntity[] mentions = status.getUserMentionEntities(); if (mentions != null) { for (UserMentionEntity mention : mentions) { try { // Check if there is any mention to us if (isCurrentUser(twitter, mention.getScreenName())) { // Only reply if it is a valid mention if (isValidMention(status) && !isCurrentUser(twitter, status.getUser().getScreenName())) { LOGGER.debug("Processing tweet {} from {}", status.getId(), status.getUser().getScreenName()); ReplyCommand reply = new ReplyCommand(twitter, wordParser, rhymeStore, status); reply.execute(); } else { LOGGER.debug("Ignoring mention: {}", status.getText()); }//from w w w .j a v a 2s .c o m // Do not process the same tweet more than once break; } } catch (TwitterException ex) { LOGGER.error("Could not process status: {}", status.getText()); } } } }
From source file:crawltweets2mongo.MonoThread.java
private String[] pickMentions(UserMentionEntity[] mentioned) { LinkedList<String> friends = new LinkedList<String>(); for (UserMentionEntity x : mentioned) { //String y=x.getName();// Long.toString(x.getId()); friends.add(x.getScreenName()); }/* w w w .ja va 2s . co m*/ String a[] = {}; return friends.toArray(a); }
From source file:DataCollections.UserHelper.java
public User_dbo convertMentionedUserToUser_dbo(UserMentionEntity user) { User_dbo u = new User_dbo(); u.values[User_dbo.map.get("user_id")].setValue(String.valueOf(user.getId())); u.values[User_dbo.map.get("name")].setValue(removeEscapeCharacters(user.getName())); u.values[User_dbo.map.get("screename")].setValue(removeEscapeCharacters(user.getScreenName())); return u;//from ww w. j av a2 s .c o m }
From source file:de.vanita5.twittnuker.model.ParcelableUserMention.java
License:Open Source License
public ParcelableUserMention(final UserMentionEntity entity) { id = entity.getId(); name = entity.getName(); screen_name = entity.getScreenName(); }
From source file:Logic.mongoC.java
public void IngresarUsuario(String name) { String[] buscarUs = new String[1]; buscarUs[0] = name;/* w w w . j a va 2 s. c o m*/ try { ResponseList<twitter4j.User> use = twitter.lookupUsers(buscarUs); twitter4j.User u = use.get(0); System.out.println(u.getStatus()); usuario nuevoS = new usuario(); nuevoS.setId(Long.toString(u.getId())); nuevoS.setNombre(u.getName()); nuevoS.setLocation(u.getLocation()); nuevoS.setNumFol(u.getFollowersCount()); nuevoS.setNumeroDeT(u.getStatusesCount()); List<Status> twitts = twitter.getUserTimeline(u.getId(), new Paging(1, 200)); ArrayList<twitt> timeL = new ArrayList(); for (Status s : twitts) { twitt tw = new twitt(); tw.setTexto(s.getText()); tw.setRetwett(s.getRetweetCount()); //tw.setFecha((java.util.Date) s.getCreatedAt()); tw.setFav(s.getFavoriteCount()); tw.setCreador(s.getUser().getScreenName()); UserMentionEntity[] userMentionEntities = s.getUserMentionEntities(); ArrayList<String> inter = new ArrayList(); for (UserMentionEntity uh : userMentionEntities) { inter.add(uh.getScreenName()); } tw.setPersonas(inter); timeL.add(tw); } nuevoS.setTimeline(timeL); final String fIns = gson.toJson(nuevoS); Document dt; dt = new Document("ScreenName", u.getScreenName()); dt.append("todo", fIns); conect(); coll.insertOne(dt); JOptionPane.showMessageDialog(null, "Usuario Ingresado"); } catch (TwitterException ex) { System.out.println("No se pudo conectar el usuario deseado"); } }
From source file:net.lacolaco.smileessence.twitter.util.TwitterUtils.java
License:Open Source License
/** * Get array of screenName in own text//from w w w . j a v a 2s .co m * * @param status status * @param excludeScreenName * @return */ public static Collection<String> getScreenNames(Status status, String excludeScreenName) { ArrayList<String> names = new ArrayList<>(); names.add(status.getUser().getScreenName()); if (status.getUserMentionEntities() != null) { for (UserMentionEntity entity : status.getUserMentionEntities()) { if (names.contains(entity.getScreenName())) { continue; } names.add(entity.getScreenName()); } } if (excludeScreenName != null) { names.remove(excludeScreenName); } return names; }
From source file:net.lacolaco.smileessence.twitter.util.TwitterUtils.java
License:Open Source License
public static Collection<String> getScreenNames(DirectMessage message, String excludeScreenName) { ArrayList<String> names = new ArrayList<>(); names.add(message.getSenderScreenName()); if (!message.getRecipientScreenName().equals(message.getSenderScreenName())) { names.add(message.getRecipientScreenName()); }//from ww w.j av a2s .c o m if (message.getUserMentionEntities() != null) { for (UserMentionEntity entity : message.getUserMentionEntities()) { if (names.contains(entity.getScreenName())) { continue; } names.add(entity.getScreenName()); } } if (excludeScreenName != null) { names.remove(excludeScreenName); } return names; }