How I made a twitterbot for fun and profit! part 2

Back to the bot. The twitter-bot. The Lars Ulrich twitter-bot. The Lars Ulrich swearing twitter-bot. He’s up and running, spreading obscenities all over the internets. Check him out at http://twitter.com/i_am_larsulrich

The engine I was planning on using didn’t do what I  wanted it to do (search) so I went with twitter4j and processing (processing to the rescue).

There are a lot of other bot’s you could build for example a “silent bob” bot, that twitters silent comments beavis or butthead bot’s that search for bad words and replies to those twitters in a “huh huh huh you say *”

I’ve included the source of the bot down after the jump for you to build further on if you want to, the whole shebang is also available here for you to download: i_am_larsulrich.zip

Twitter twitter;
int friendCount;
User[] friends;
java.util.List statuses = null;
Query query = new Query("fuck");

void setup()
{
  twitter = new Twitter("i_am_larsulrich","SEKRETS");
  size( 400, 400 );
} 

void searchAndDestroy()
{
  try
  {
    QueryResult result = twitter.search( query );

    java.util.List  tweets = result.getTweets();

    //  System.out.println("hits:" + tweets.size());

    for( int i=0; i<7)
      {
        System.out.println(tweet.getId() +"  " +  tweet.getFromUser() + ":" + tweet.getText() + " " + tweet.getText().length() );
        twitter.retweetStatus(tweet.getId());  

        switch((int)random(10))
        {
        case 0:
          twitter.updateStatus("@"+tweet.getFromUser() +" fukc",tweet.getId());
          break;
        case 1:
          twitter.updateStatus("@"+tweet.getFromUser() +" fuck",tweet.getId());
          break;
        case 2:
          twitter.updateStatus("@"+tweet.getFromUser() +" FUCK",tweet.getId());
          break;
        case 3:
          twitter.updateStatus("@"+tweet.getFromUser() +" FACK",tweet.getId());
          break;
        case 4:
          twitter.updateStatus("@"+tweet.getFromUser() +" fock",tweet.getId());
          break;
        case 5:
          twitter.updateStatus("@"+tweet.getFromUser() +" FOCK",tweet.getId());
          break;
        case 6:
          twitter.updateStatus("@"+tweet.getFromUser() +" FUUUUCK",tweet.getId());
          break;
        case 7:
          twitter.updateStatus("@"+tweet.getFromUser() +" f*ck",tweet.getId());
          break;
        case 8:
          twitter.updateStatus("@"+tweet.getFromUser() +" Fuck!",tweet.getId());
          break;
        case 9:
          twitter.updateStatus("@"+tweet.getFromUser() +" fuck!!!!!!!11!!one!1!1!!!1!",tweet.getId());
          break;
        }    

        // twitter.enableNotification(tweet.getFromUser()); //doesent work? why?
        query.setSinceId(tweet.getId());

      }
    }
  }
  catch (TwitterException te)
  {
    System.out.println("Failed wit reason: " + te.getMessage());
  }

}

void updateMyStatus()
{
  try
  {
    Status status1;
    switch((int)random(10))
    {
    case 0:
      status1 = twitter.update("fukc");
      break;
    case 1:
      status1 = twitter.update("fuck");
      break;
    case 2:
      status1 = twitter.update("FUCK");
      break;
    case 3:
      status1 = twitter.update("FACK");
      break;
    case 4:
      status1 = twitter.update("fock");
      break;
    case 5:
      status1 = twitter.update("FOCK");
      break;
    case 6:
      status1 = twitter.update("FUUUUCK");
      break;
    case 7:
      status1 = twitter.update("f*ck");
      break;
    case 8:
      status1 = twitter.update("Fuck!");
      break;
    case 9:
      status1 = twitter.update("fuck");
      break;
    }
  }
  catch( TwitterException e)
  {
    println(e.getStatusCode());
  }
}

void draw()
{
  searchAndDestroy();
  if(random(1000)==1)
  {
    updateMyStatus();
    println("changing status");
  }
  println(hour()+":"+minute() + ":" + second() );
  delay(60*1000);
}

2 thoughts on “How I made a twitterbot for fun and profit! part 2

Leave a Reply