/ Published in: Ruby
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
#!/usr/bin/env ruby # # Update iChat/Adium status from Twitter # # Michael Tyson # http://michael.tyson.id.au # Set Twitter username here Username = 'yourUsername' require 'net/http' require 'rexml/document' # Download timeline XML and extract latest entry url = "http://ws.audioscrobbler.com/1.0/user/" + Username + "/recenttracks.rss" xml_data = Net::HTTP.get_response(URI.parse(url)).body doc = REXML::Document.new(xml_data) latest = doc.root.elements['channel/item/title'] message = '♫ ' + latest.text.gsub(/^[^:]+:\s*/, '') exit if ! message # Apply to status script = 'set message to "' + message.gsub(/"/, '\\"') + "\"\n" + 'tell application "System Events"' + "\n" + 'if exists process "iChat" then tell application "iChat" to set the status message to message' + "\n" + 'if exists process "Adium" then tell application "Adium" to set status message of every account to message' + "\n" + 'end tell' + "\n" IO.popen("osascript", "w") { |f| f.puts(script) }
URL: http://trepmal.com/scripts/lastfm-ichat-status/