TwitterBrite
Feb 22, 2008 @ 11:27 pmI signed up my BetaBrite for a twitter account. Now I’m getting twitter messages in my living room. Yay! Leave a comment, or follow me on twitter so I can get your messages on my sign. I think next I will try to wire up a webcam to automagically take pictures.
Anyway, here is the code:
twitter = Twitter::Base.new('betabrite', '%%%%%%%%')
seen = {}
DATA.each_line { |l| seen[l.chomp] = true }
twit = nil
twitter.timeline(:friends).each do |tweet|
next if seen[tweet.id]
twit = tweet
end
if twit
File.open(__FILE__, 'a') { |db| db.puts(twit.id) }
puts "#{twit.text} (#{twit.user.name})"
bb = BetaBrite::USB.new { |sign|
sign.stringfile('0') do
print string("#{twit.text}")
end
sign.stringfile('1') do
print string("(#{twit.user.name})").red
end
}.write!
end
__END__
My favorite part is that I use the script for its own database. It keeps appending twitter ids it has seen to the end of the file.