<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>black_list.yml.sample</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -2,12 +2,19 @@ A ruby script that will automatically follow all your followers.
 
 Gem dependencies:
 * twitter &gt;= 0.2.6
+* hpricot
 
 Usage:
 follower = AutoFollower.new('admin@example.com', 'password')
 follower.start
+follower.stalk('cincinnati')
 
-NB: 
+Another option if you only want to follow your followers is
+running it off command line like auto_follow.rb admin@example.com password
+
+You can black list people from been added to your friend by adding them to the yaml file called black_list.yml.
+
+NB:
 Twitter has limit on how many people you can follow in an hour.
 But if you schedule this script to run hourly it will eventually catchup.
 </diff>
      <filename>README</filename>
    </modified>
    <modified>
      <diff>@@ -1,6 +1,8 @@
 #!/usr/bin/env ruby
 
 require 'rubygems'
+require &quot;logger&quot;
+require &quot;yaml&quot;
 gem &quot;twitter&quot;, '&gt;=0.2.6'
 require 'twitter'
 require 'hpricot'
@@ -11,23 +13,41 @@ require 'hpricot'
 # follower.start
 # follower.stalk('cincinnati')
 # 
+# Another option if you only want to follow your followers is
+# running it off command line like auto_follow.rb admin@example.com password
+# 
 class AutoFollower
   
+  FOLLOW_INTERVAL = 10
   TWITTER_PAGE_SIZE = 100
+  BLACK_LIST = 'black_list.yml'
+  
+  attr_accessor :black_list
   
-  def initialize(email, password)
+  def initialize(email, password, output = STDOUT, level = Logger::INFO)
     @twitter = Twitter::Base.new(email, password)
+    
+    output = eval(output) if output.is_a?(String)
+    level = eval(level) if level.is_a?(String)
+    
+    @log = Logger.new(output)
+    @log.sev_threshold = level
+    
+    @black_list = File.exist?(BLACK_LIST) ? YAML.load_file(BLACK_LIST) : []
   end
   
   def start
-    (followers - friends).each { |name| follow(name) }
+    peeps = (followers - friends).find_all { |n| !black_listed?(n) }
+    
+    @log.info &quot;Need to follow #{peeps.size} people&quot;
+    peeps.each { |name| follow(name) }
   end
 
   def stalk(query, page = 1)
     doc = Hpricot(open(&quot;http://twitter.com/search/users?q=#{query}&amp;page=#{page}&quot;))
     names = doc.search(&quot;.screen_name span&quot;).collect { |d| d.innerHTML }
     return if names.empty?
-    (names - friends).each { |name| follow(name) }
+    (names - friends).find_all { |n| !black_listed?(n) }.each { |name| follow(name) }
     page = page + 1
     stalk(query, page)
   end
@@ -42,19 +62,31 @@ class AutoFollower
 
   private
   
-    def follow(name)
+    def black_listed?(name)
+      black_list.include?(name)
+    end
+  
+    def follow(name, delay = FOLLOW_INTERVAL)
+      @log.info &quot;Following: #{name}&quot;
       @twitter.create_friendship(name)
+      sleep delay
     end
     
     def find_followers(page = 1)
+      @log.debug &quot;followers page: #{page}&quot;
       f = @twitter.followers(:lite =&gt; true, :page =&gt; page).collect { |f| f.screen_name }
       return f if f.empty? || f.size &lt; TWITTER_PAGE_SIZE
       f + find_followers(page + 1)
     end
     
     def find_friends(page = 1)
+      @log.debug &quot;friends page: #{page}&quot;
       f = @twitter.friends(:lite =&gt; true, :page =&gt; page).collect { |f| f.screen_name }
       return f if f.empty? || f.size &lt; TWITTER_PAGE_SIZE
       f + find_friends(page + 1)
     end
 end
+
+if $0 == __FILE__
+  AutoFollower.new(*ARGV).start
+end
\ No newline at end of file</diff>
      <filename>auto_follow.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>0e91c65ac28e0efdc46058d9420d18fda0fff27d</id>
    </parent>
  </parents>
  <author>
    <name>Andy Shen</name>
    <email>andy@shenie.info</email>
  </author>
  <url>http://github.com/shenie/auto_follow/commit/45d0ffa3563616991febfca54952d69297bd303e</url>
  <id>45d0ffa3563616991febfca54952d69297bd303e</id>
  <committed-date>2008-07-30T05:07:16-07:00</committed-date>
  <authored-date>2008-07-30T05:07:16-07:00</authored-date>
  <message>added ability to black list people, added delay between each successive follow request, use logger and allow this file to be run as a script</message>
  <tree>0430a73da50f6231f361b217830a56e39e22d609</tree>
  <committer>
    <name>Andy Shen</name>
    <email>andy@shenie.info</email>
  </committer>
</commit>
