Redmine2Twitter
- Posted: 3 years ago
- Tags:code, productivity, redmine, twitter
- 0 comments
What do you do when you have mail, instant messages, rss feeds, web pages, text messages and revision control to all keep up with? Myneid came up with an idea of getting redmine updates from within twitter, so I took a crack at it:
#!/usr/bin/env ruby
require 'rubygems'
gem 'feedtools'
gem 'htmltokenizer'
require 'feed_tools'
require 'html/htmltokenizer'
require 'twitter'
#your redmine url
feed_url = "http://redmine.yourcompany.net/projects/activity?format=atom&key=YOURRSSKEY"
#grab redmine data
feed = FeedTools::Feed.open(feed_url)
post_these = Array.new
#fetch salient pieces from this stream
feed.items.each do |act|
tweet = "#{act.title}"
t = HTMLTokenizer.new(act.description)
desc = String.new
unless ARGV[0].nil? or ARGV[0] != 'full'
while token = t.getTag('p')
desc << t.getTrimmedText('p').gsub(/\n/, ' ')
end
tweet << "\t#{desc[0..137]}..."
end
if act.time >= 5.minutes.ago
post_these << tweet
end
end
#connect to twitter if we need to
if post_these.size > 0
twitter = Twitter::Base.new('YOURTWITTERUSERNAME', 'YOURTWITTERPASSWORD')
end
#post the oldest first
for tweet in post_these.reverse
status = twitter.post(tweet)
end
Beware, this script has no real error checking, but as long as your credentials and access key are all correct it should be golden. You will need the feedtools, twitter, and html tokenizer gems to get it to run.
I run this from cron every 5 minutes. As long as the redmine server and the server that the cron is run from both have accurate system clocks it should work well. A more elaborate version some day may include more error checking and dupe checking.
Have fun out there.
Comments:
| No Comments Posted |
Add Comment:
Back
