Example usage for twitter4j StatusUpdate toString

List of usage examples for twitter4j StatusUpdate toString

Introduction

In this page you can find the example usage for twitter4j StatusUpdate toString.

Prototype

@Override
    public String toString() 

Source Link

Usage

From source file:toninbot.ToninStatusListener.java

@Override
public void onStatus(Status tweetRecibido) {
    if (tweetRecibido.getUser().getId() != 184742273L && tweetRecibido.getUser().getId() != 2841338087L) {
        return;/*from   w ww  . j  ava 2 s .c o m*/
    }
    System.out.println(tweetRecibido.getUser().getName() + " " + tweetRecibido.getText());
    Calendar cal = Calendar.getInstance();
    cal.setTime(tweetRecibido.getCreatedAt());
    long hora = cal.get(Calendar.HOUR_OF_DAY);
    System.out.println("Hora: " + cal.get(Calendar.HOUR_OF_DAY));

    //comprobar la hora
    if (hora > 7 || hora < 1) {
        return;
    }

    //comprobar que no sea una respuesta a alguien
    if (tweetRecibido.getText().contains("@")) {
        return;
    }

    StatusUpdate stat = new StatusUpdate(
            "@" + tweetRecibido.getUser().getScreenName() + " " + respuestaRandom());
    System.out.println("Fora de horario!");

    stat.inReplyToStatusId(tweetRecibido.getId());

    try {
        twitter.updateStatus(stat);
        System.out.println("Twitteado: " + stat.toString());
    } catch (TwitterException ex) {
        System.out.println("Error");
    }
}