Created
August 22, 2008 02:05
-
-
Save pope/6717 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'twitter' | |
require 'ruby-growl' | |
require 'simple-daemon' | |
require 'tempfile' | |
require 'net/http' | |
class Growitter < SimpleDaemon::Base | |
SimpleDaemon::WORKING_DIRECTORY = "/Users/dir/Desktop" | |
@@twit = Twitter::Base.new('username', 'password') | |
@@options = {} | |
@@profile_image_cache = {} | |
def self.start | |
puts "Starting growitter" | |
loop do | |
timeline = @@twit.timeline(:friends, @@options) | |
if timeline | |
timeline.reverse.each do |s| | |
unless @@profile_image_cache.has_key?(s.user.profile_image_url) | |
f = Tempfile.new("growitter") | |
f << Net::HTTP.get(URI.parse(s.user.profile_image_url)) | |
f.close | |
@@profile_image_cache[s.user.profile_image_url] = f.path | |
end | |
system "growlnotify -n growitter --image #{@@profile_image_cache[s.user.profile_image_url]} -t #{s.user.name.inspect} -m #{s.text.inspect}" | |
@@options[:since_id] = s.id | |
end | |
end | |
sleep 60 | |
end | |
end | |
def self.stop | |
puts "Stopping growitter" | |
end | |
end | |
Growitter.daemonize |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment