Skip to content

Instantly share code, notes, and snippets.

@threedaymonk
Forked from madebymany/unfollowold.rb
Created November 14, 2009 21:09
Show Gist options
  • Save threedaymonk/234783 to your computer and use it in GitHub Desktop.
Save threedaymonk/234783 to your computer and use it in GitHub Desktop.
require 'rubygems'
require 'optiflag'
require 'twitter'
Infinity = 1.0/0.0 unless defined? Infinity
module DBChecker extend OptiFlagSet
flag "password"
flag "user"
flag "days"
and_process!
end
username = ARGV.flags.user
password = ARGV.flags.password
days = ARGV.flags.days
#clear ARGV for gets to work
ARGV.clear
cutoff_date = DateTime.now - days.to_i
httpauth = Twitter::HTTPAuth.new(username, password)
twitter = Twitter::Base.new(httpauth)
1.upto(Infinity) do |page|
friends = twitter.friends(:page => page)
break if friends.empty?
friends.each do |friend|
last_status_update = friend.status && DateTime.parse(friend.status.created_at)
if (last_status_update.nil? or last_status_update <= cutoff_date)
puts "Unfollow #{friend.screen_name} (#{friend.name})?"
STDOUT.flush
if gets.chomp.match(/^y(?:es)?$/i)
twitter.friendship_destroy(friend.id)
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment