List of usage examples for twitter4j Status getText
String getText();
From source file:module.ihm.MainFrameInitializer.java
public void initJList() { JList jList = (JList) application.getMainFrameJComponent("jListTweet"); DefaultListModel model = new DefaultListModel(); jList.setCellRenderer(new ListCellRenderer() { @Override/*www. j a v a 2 s . c o m*/ public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { JLabel renderer = (JLabel) new DefaultListCellRenderer().getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); if (value instanceof Status) { Status s = (Status) value; renderer.setForeground(new Color(0, 51, 102)); try { renderer.setIcon(new ImageIcon(new URL(s.getUser().getProfileImageURL().toString()))); } catch (MalformedURLException ex) { Logger.getLogger(MainFrameInitializer.class.getName()).log(Level.SEVERE, null, ex); } SimpleDateFormat dateformat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); renderer.setText("<html><b>" + s.getUser().getName() + " @" + s.getUser().getScreenName() + "</b><br>" + s.getText() + "<br>" + "Ecrit le " + dateformat.format(s.getCreatedAt()) + "<br><br> </html>"); } if (value instanceof twitter4j.User) { twitter4j.User u = (twitter4j.User) value; try { renderer.setIcon(new ImageIcon(new URL(u.getProfileImageURL().toString()))); } catch (MalformedURLException ex) { Logger.getLogger(MainFrameInitializer.class.getName()).log(Level.SEVERE, null, ex); } renderer.setText(u.getName() + " @" + u.getScreenName()); } return renderer; } }); jList.addMouseListener(new MouseListener() { @Override public void mouseClicked(MouseEvent e) { JList jList = (JList) application.getMainFrameJComponent("jListTweet"); if (jList.getSelectedValue() instanceof Status) { Status s = (Status) jList.getSelectedValue(); // System.out.println(s); PandaProdButton button = (PandaProdButton) hsJcomponent.get("pandaProdButtonRetweet"); button.setVisible(true); } else if (jList.getSelectedValue() instanceof twitter4j.User) { twitter4j.User s = (twitter4j.User) jList.getSelectedValue(); // System.out.println(s); } } @Override public void mousePressed(MouseEvent e) { } @Override public void mouseReleased(MouseEvent e) { } @Override public void mouseEntered(MouseEvent e) { } @Override public void mouseExited(MouseEvent e) { } }); for (Status s : user.getListOfTweet()) { model.addElement(s); } jList.setModel(model); }
From source file:monitoring.tools.TwitterAPI.java
License:Apache License
private void generateData(String searchTimeStamp) { List<MonitoringData> data = new ArrayList<>(); for (Status s : tweetInfo) { String id = String.valueOf(s.getId()); String timeStamp = String.valueOf(s.getCreatedAt()); String message = s.getText(); String author = "@" + s.getUser().getScreenName(); String link = "https://twitter.com/" + s.getUser().getName().replace(" ", "") + "/status/" + s.getId(); MonitoringData dataObj = new MonitoringData(id, timeStamp, message, author, link); data.add(dataObj);/*from ww w .j a v a 2 s.c om*/ } tweetInfo = new ArrayList<>(); //kafka.generateResponseKafka(data, searchTimeStamp, id, configurationId, this.confParams.getKafkaTopic); kafka.generateResponseIF(data, searchTimeStamp, id, configurationId, this.confParams.getKafkaTopic()); logger.debug("Data successfully sent to Kafka endpoint"); ++id; }
From source file:my.twittergui.TwitterUI.java
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed String text;/*from w w w .j av a 2 s . com*/ text = jTextField1.getText(); //jTextArea1.append(text+"\n"); jTextArea1.append("Searching for: "); String[] strarray = text.split(" "); for (int i = 0; i < strarray.length; i++) { jTextArea1.append(strarray[i] + "\n"); } File filed = null; filed = new File("C:\\Results"); if (!filed.exists()) { filed.mkdir(); } ConfigurationBuilder cb = new ConfigurationBuilder(); cb.setDebugEnabled(true).setOAuthConsumerKey("").setOAuthConsumerSecret("").setOAuthAccessToken("") .setOAuthAccessTokenSecret(""); StatusListener listener = new StatusListener() { public void onStatus(Status status) { try { int fileno = 0; String strI = Integer.toString(fileno); String fname = "C:\\results\\DataCol" + strI + ".csv"; File file = new File(fname); FileWriter bw = new FileWriter(file, true); if (file.length() == 0) { bw.write("\"Screen Name\", text, \"created at\", geolocation, Retweet? \r\n"); bw.flush(); } while (file.length() > 10485760) { fileno += 1; strI = Integer.toString(fileno); fname = "DataCol" + strI + ".txt"; file = new File(fname); bw = new FileWriter(file, true); bw.write("\"Screen Name\", \"text\", \"created_at\", \"geolocation\" \r\n"); bw.flush(); } // if(!status.isRetweet()){ bw.write("\r\n"); bw.write("\"" + status.getUser().getScreenName() + "\","); String tweettxt = status.getText(); tweettxt = tweettxt.replace("\n", ""); tweettxt = tweettxt.replace(",", ""); tweettxt = tweettxt.replace("\"", ""); bw.write("\"" + tweettxt + "\","); bw.write("\"" + status.getCreatedAt() + "\","); if (status.getGeoLocation() != null) { bw.write("\"" + status.getGeoLocation() + "\""); } else bw.write("N/A,"); if (status.isRetweet()) bw.write("Yes"); else bw.write("No"); bw.flush(); bw.close(); //System.out.print("\n"); String str = "@" + status.getUser().getScreenName() + " " + status.getText() + " " + status.getCreatedAt() + " "; if (status.getGeoLocation() != null) str += status.getGeoLocation(); //System.out.print(str); jTextArea1.append(str + "\n"); // } bw.close(); } catch (IOException e) { //System.out.print("EXCEPTION"); e.printStackTrace(); } } public void onDeletionNotice(StatusDeletionNotice statusDeletionNotice) { } public void onTrackLimitationNotice(int numberOfLimitedStatuses) { } public void onStallWarning(StallWarning stall) { } public void onScrubGeo(long a, long b) { } public void onException(Exception ex) { ex.printStackTrace(); } }; TwitterStreamFactory tf = new TwitterStreamFactory(cb.build()); TwitterStream twitterStream = tf.getInstance(); twitterStream.addListener(listener); // Filter FilterQuery filtre = new FilterQuery(); Scanner in = new Scanner(System.in); filtre.track(strarray); twitterStream.filter(filtre); }
From source file:net.craftrepo.CraftBird.TwitterUpdates.java
License:Open Source License
public void run() { while (true) { if (CraftBird.twitter.getAuthorization().isEnabled()) { net.craftrepo.CraftBird.CraftBird.config.load(); String[] users = ((String[]) net.craftrepo.CraftBird.CraftBird.config.getProperty("users")); if (users == null) { CraftBird.log.warning("[Twitter] No users defined in the config! Turning updates off."); CraftBird.updates = false; CraftBird.scheduler.cancelAllTasks(); return; }//ww w.j av a 2s . c om for (String s : users) { try { List<Status> statuses; statuses = CraftBird.twitter.getFriendsTimeline(); if (lastStatuses == null || !statuses.containsAll(lastStatuses)) { for (Status status : statuses) { if (status.getUser().getName().contains(s)) { CraftBird.log.info( "[Twitter] " + status.getUser().getName() + ":" + status.getText()); CraftBird.notifyPlayers( "[Twitter] " + status.getUser().getName() + ":" + status.getText()); } } lastStatuses = statuses; } } catch (TwitterException e) { e.printStackTrace(); } } } } }
From source file:net.jeremybrooks.suprsetr.twitter.TwitterHelper.java
License:Open Source License
/** * Update the user status./*from ww w. j a v a 2 s. c om*/ * <p/> * <p>The user must be authenticated.</p> * * @param tweet the status. * @throws Exception if there are any errors. */ public static void updateStatus(String tweet) throws Exception { if (TwitterHelper.isAuthorized()) { Status status = twitter.updateStatus(tweet); logger.info("Updated status to [" + status.getText() + "]"); } }
From source file:net.lacolaco.smileessence.command.status.StatusCommandMakeAnonymous.java
License:Open Source License
public static String build(Activity activity, Status status, Account account) { String str = status.getText(); String header = ""; if (str.startsWith(".")) { str = str.replaceFirst(".", ""); }/*www .ja v a 2 s . c o m*/ if (str.startsWith(String.format("@%s", account.screenName))) { str = str.replaceFirst(String.format("@%s", account.screenName), "").trim(); } str = activity.getString(R.string.format_status_command_make_anonymous, str).trim(); return str; }
From source file:net.lacolaco.smileessence.command.status.StatusCommandNanigaja.java
License:Open Source License
public String build() { Status status = getOriginalStatus(); String str = status.getText(); String header = ""; if (str.startsWith(".")) { str = str.replaceFirst(".", ""); }//from w ww. j a va2s .c o m if (str.startsWith(String.format("@%s", account.screenName))) { str = str.replaceFirst(String.format("@%s", account.screenName), "").trim(); header = "@" + status.getUser().getScreenName(); } str = String.format("%s %s", header, String.format(getFormatString(getActivity()), str)).trim(); return str; }
From source file:net.lacolaco.smileessence.twitter.TweetBuilder.java
License:Open Source License
public TweetBuilder setQuotation(Status status) { return setText(String.format(" RT @%s: %s", status.getUser().getScreenName(), status.getText())); }
From source file:net.lacolaco.smileessence.twitter.TweetBuilder.java
License:Open Source License
public TweetBuilder setQuotation(Status status, String text) { return setText(String.format("%s RT @%s: %s", text, status.getUser().getScreenName(), status.getText())); }
From source file:net.lacolaco.smileessence.twitter.util.TwitterUtils.java
License:Open Source License
/** * Get "@screen_name: text" format text/*from w ww . j av a 2 s .c o m*/ * * @param status status * @return summary string */ public static String getStatusSummary(Status status) { return String.format("@%s: %s", status.getUser().getScreenName(), status.getText()); }