; ; Twitter support for mIRC ; by Ben XO http://www.ben-xo.com/twitter.mrc ; ; version 0.4 ; ; This script will poll Twitter every 3 minutes and then /ame ; your status to all channels, but only if it has changed. ; It will also set your /away to that status. ; ; You must set a variable for your Twitter username. You can do ; this by typing /twitter.id your_twitter_username ; ; Twitter.mrc Requires Ruby4Mirc from http://kthx.net/clb/ruby4mirc ; which in turn requires Ruby from http://rubyinstaller.rubyforge.org/ ; ; This is Free software licensed under the GPL. ; See http://www.gnu.org/licenses/gpl.html for more info and a copy ; of the License text. ; ; START timer and boot-strap for ruby on *:START: { if $($has_ruby,2) { id = mirc[:twitterid] id.empty? and puts "You must set %twitterid with /twitter.id " require 'rss/1.0' require 'rss/2.0' require 'open-uri' } timertwit 0 180 twitter.update } ; Set your Twitter ID alias twitter.id { set %twitterid $1- echo Twitter ID set to $1- } ; Update from your Twitter RSS feed and save the status into %tweettitle ; If it's changed, call /tweet alias twitter.update { var twitter_update_message var dotweet if $($has_ruby,2) { id = mirc[:twitterid] mirc[:twitter_update_message] = "Fetched #{id}'s #{mirc[:tweettitle].empty? ? "first" : "latest"} tweet... " source = "http://twitter.com/statuses/user_timeline/#{id}.rss?count=1" content = "" mirc[:dotweet] = false begin # { open(source) do |s| content = s.read end latest_entry = RSS::Parser.parse(content, false).items[0] tweettitle = latest_entry.title tweettitle.slice!(0..."#{id}: ".length) entities = { "amp" => "&", "lt" => "<", "gt" => ">" } tweettitle.gsub!(/&(amp|lt|gt);/) { |m| entities[$1] } if(mirc[:tweettitle] != tweettitle) # { mirc[:tweettitle] = tweettitle mirc[:tweetdate] = latest_entry.date.to_s mirc[:dotweet] = true end # } # } rescue Exception => e # { mirc[:twitter_update_message] = "Failed to fetch tweet: " + e.to_s end # } } echo -st %twitter_update_message if (%dotweet) { tweet } } ; /away and /ame on all servers alias tweet { var %i = $scon(0) while (%i > 0) { scon %i if (!$server) { echo -st Not announcing tweet: not connected to server } else { away %tweettitle (from Twitter on %tweetdate ) ame %tweettitle } dec %i } }