# ALEX BRIE - April 2007 # TwitterYM # http://www.alexbrie.net # Simple Ruby app that updates your yahoo messenger status (Windows only) with your Twitter status # runs in console mode for now # uses the twitter gem and the win api one # to make it work: # 1. install ruby on your machine; # 2. install the gems specified here http://addictedtonew.com/archives/187/ruby-twitter-gem/ # gem install hpricot --source http://code.whytheluckystiff.net -v 0.4.86 # gem install twitter # 3. change the line s = Twitter::Base.new('my_email', 'my_password').timeline(:user)[0] # by entering your login credentials for the twitter account # 4. start yahoo messenger # 5. run the script require 'Win32API' require 'Win32\registry' findWindow=Win32API.new("user32", "FindWindow",['p','i'],'L') postMessage=Win32API.new("user32", "PostMessage",['L'] * 4, 'L') sendMessage=Win32API.new("user32", "SendMessage",['L'] * 4, 'L') getWindowText=Win32API.new("user32", "GetWindowText",['L','P','i'] , 'L') windowMove=Win32API.new("user32", "MoveWindow",['P','L','L','L','L'] , 'L') userid=""; newstatus=""; size=46 theText=" "*size; defaultStatus="" oldStatus="toto" newStatus="" #postMessage.call(findWindow.call("YahooBuddyMain",0),273,392,0) theText=defaultStatus if theText.nil? print theText print "\ngata\n" require 'rubygems' require 'twitter' while true Win32::Registry::HKEY_CURRENT_USER.open('Software\Yahoo\Pager') do |reg| userid = reg['Yahoo! User ID'] # read a value print userid+"\n" end s = Twitter::Base.new('my_email', 'my_password').timeline(:user)[0] newStatus = "Twitter: "+s.text #newStatus=defaultStatus if oldStatus!=newStatus #~ # Reg write new status print newStatus Win32::Registry::HKEY_CURRENT_USER.open("Software\\Yahoo\\pager\\profiles\\"+userid+"\\Custom Msgs",Win32::Registry::KEY_ALL_ACCESS) do |reg| print reg.inspect+"\n" #print reg['5'] reg.write('5', Win32::Registry::REG_SZ, 'bar') reg['5']=newStatus print "\n"+newStatus+"\n" end #~ # Beep the YahooWindow postMessage.call(findWindow.call("YahooBuddyMain",0),273,392,0) oldStatus=newStatus end sleep 40 end