« The Daily WTF Submit Automator Service | Main | Air Drum Machine - "DrumAnimal" »
Saturday
Dec052009

TwitterBot Construction Kit

I pulled the Zork Twitter bot apart and rebuilt it using more sensible means.   HTMLUnit for scraping the actual WebZork game and Apache Commons Config for configuration reading.  The code was also restructured to support Twiiter Bot plugins. 

It is a failry simple interface constisting of 4 callbacks that are invoked on interesting Twitter events.
The methods are passed a Twitter client object that allows the bot to send tweets. 

The default example that simple echos any tweet sent to it is:

package com.glulogic.twitter.bot

public class DefaultTweetHandler {

// Each method called is passed a 'context' hashmap
// containing the following keys:
//
// from - the shortname (login) of the user who sent the Tweet
// body - the contents of the Tweet (@... removed)
// twitter - an object that can send tweets to Twitter users

// called when someone sends an metion (e.g. '@...')
def mention(context) {
context.twitter.mention('to': context.from, 'message': "You said ${context.body}")
}

// called when someone sends a direct message (e.g. 'd ...')
def direct(context) {
context.twitter.direct('to': context.from, 'message': "You said ${context.body}")
}

// called when a user begins following
def follow(context) {
}

// called when a user stops following
def unfollow(context) {
}
}

Reader Comments (2)

This site started off pretty well only to be sold later by the owner. The new management which took over the site reset all the balances of the users. Although the new owners who go by the love bracelet cartier replica James and Ultra tried their best to clear earlier dues and make payments on time, the site just couldn't pay up. Shortly, the forum was also closed.

visit replica richard mille.cheaper and well.

Enjoy $15 savings at xclones.net with this coupon code S7D15U

Rules of the Code:

1. The coupon code is only applicable for $100+ full-price item(s) .
2. This coupon code is not applicable for promotional items or discount products.

November 5, 2011 | Unregistered Commenterreplica richard mille

PostPost a New Comment

Enter your information below to add a new comment.

My response is on my own website »
Author Email (optional):
Author URL (optional):
Post:
 
Some HTML allowed: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>