public
Description: Read an RSS feed (even HTTPS with authentication) and rebroadcast it to a Twitter account.
Clone URL: git://github.com/trak3r/rss2twitter.git
Trying to squeeze a few more precious characters into the message.
trak3r (author)
Wed Apr 16 12:02:37 -0700 2008
commit  2bfae1272d166e4ea2b7d2e3a49a921f29953722
tree    a251f8aaf8afe6c321918729bdc7c3cc3ac8476f
parent  4a7b9e874753886f9697a374dd2e3857e1dc83d7
...
65
66
67
68
69
 
 
 
 
 
 
70
71
72
73
 
74
75
76
...
98
99
100
101
 
 
 
 
 
102
103
104
...
65
66
67
 
 
68
69
70
71
72
73
74
75
76
 
77
78
79
80
...
102
103
104
 
105
106
107
108
109
110
111
112
0
@@ -65,12 +65,16 @@ ActiveRecord::Base.establish_connection(
0
 )
0
 
0
 class Item < ActiveRecord::Base
0
- def minilink
0
- @mini ||= ShortURL.shorten(self.link, :tinyurl)
0
+ def tweet_limit
0
+ 139 # leave one off for fudging
0
+ end
0
+
0
+ def short_url
0
+ @cached_short_url ||= ShortURL.shorten(self.link, :tinyurl)
0
   end
0
   
0
   def to_s
0
- "#{self.title[0..(130-self.minilink.length)]} - #{self.minilink}"
0
+ "#{self.title[0..(tweet_limit-self.short_url.length)]} #{self.short_url}"
0
   end
0
 end
0
 
0
@@ -98,7 +102,11 @@ for item in rss_items.items.reverse
0
     unless existing_item = Item.find(:all, :conditions => ["link=?", item.link]).first
0
       twitter ||= Twitter::Base.new(twitter_email, twitter_password)
0
       new_item = Item.create(:title => item.title, :link => item.link)
0
- twitter.post(new_item.to_s)
0
+# twitter.post(new_item.to_s)
0
+print new_item.to_s.length
0
+print ">"
0
+print new_item.to_s
0
+print "\n"
0
     end
0
   end
0
 end

Comments

    No one has commented yet.