Twitter フォロー拡散スクリプト

package jp.noragrammer.comiccafe;

import java.io.Serializable;
import java.util.List;
import java.util.Random;

import javax.jdo.PersistenceManager;
import javax.jdo.Query;
import javax.jdo.annotations.IdGeneratorStrategy;
import javax.jdo.annotations.IdentityType;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;

import twitter4j.IDs;
import twitter4j.Twitter;
import twitter4j.TwitterException;

@PersistenceCapable(identityType = IdentityType.APPLICATION)
public class TwFollowing implements Serializable {
	private static final long serialVersionUID = -1883389214702384667L;
	@PrimaryKey
	@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)    
	private Long id;
	@Persistent
	Integer twitterId;
	public void setId(Long id) {
		this.id = id;
	}
	public Long getId() {
		return id;
	}
	public Integer getTwitterId(){
		return twitterId;
	}
	public void setTwitterId(Integer twId){
		twitterId = twId;
	}
	@SuppressWarnings("unchecked")
	public static void createFollow() {
		Twitter twitter = new Twitter("user","password");
		PersistenceManager pm = PMF.getPersistenceManager();
		try {
			Query q = pm.newQuery(TwFollowing.class);
			List <TwFollowing> list = (List<TwFollowing>) q.execute();
			IDs ids;
			ids = twitter.getFollowersIDs();
			int id[] = ids.getIDs();
			if ( id == null || id.length == 0 )
				return;
			int oneLink = id[getRandom(id.length)];
			ids = twitter.getFollowersIDs(oneLink);
			id = ids.getIDs();
			if ( id == null || id.length == 0 )
				return;
			int fid = id[getRandom(id.length)];
			q = pm.newQuery(TwFollowing.class);
			q.setFilter("twitterId == idParam");
			q.declareParameters("Integer idParam");
			list = (List<TwFollowing>)q.execute(fid);
			if ( list.size() >= 1 ) {
				return;
			}
			TwFollowing ntf = new TwFollowing();
			ntf.setTwitterId(fid);
			pm.makePersistent(ntf);
			twitter.createFriendship(String.valueOf(fid));
		} catch (TwitterException e) {
			e.printStackTrace();
		} finally {
			pm.close();
		}
	}
	private static int getRandom(int n){
		Random r = new Random(System.currentTimeMillis());
		return r.nextInt(n);
	}
}

フォロー相手を逐次乱数でタゲッて、少しずつ増やすスクリプト
このBotの存在を広告するために作ってみたけど、これってスパム行為になるのかな?はずすの入れなきゃいけないかもだけど、さてどうするかw。
アルゴリズムは、直接のFollowerのFollowerにFollowをかけるという感じ。Follow返ししてくれると、そのFollowerにまたFollowかけていくので拡散する。外人さんはFollow返ししないから、そこで増加にリミットがかかるハズ。

という予定だったのだけど、外人さん、気にせずFollowしてくれちゃうんでw、外人さんのリストがどんどん追加されていってます。
イミネーwww。