Blog

Keeping iChat and Adium status in sync with Twitter

I’ve been using Twitter for a while now, and I’ve just started doing ‘global’ status updates across Twitter, Facebook, and my instant messenger account statuses for iChat and Adium. Usually I use MoodBlast, a really nice application which lets me use a global keyboard shortcut to quickly enter a tweet and hit enter to update everything simultaneously.

However, if I want to update from, say, Twinkle on my iPhone (side-note: Wow, Tapulous need to do some serious SEO – their Twitter site isn’t even on the first page of Google hits. I’m on the first page of Google hits for it, ferchrissake) the sync won’t happen. This Ruby script will do the trick.

Download: Sync Status With Twitter

To use it:

  1. Extract the .rb file to ~/Library/Scripts
  2. Open it in, say, TextEdit and edit ‘Username’ at the top of the file to match your username
  3. Open Terminal (in Applications, Utilities)
  4. Make the script executable: chmod +x ~/Library/Scripts/sync-status-with-twitter.rb
  5. Open your crontab: crontab -e
  6. Add a line to crontab to run the script regularly:
    • Press ‘o’ to insert a new line
    • Paste the following line:
      */30 * * * * ~/Library/Scripts/sync-status-with-twitter.rb
      The ‘30’ here means run every 30 minutes. Change it if you want. Some alternatives are:
      */10 * * * *… – Every 10 minutes 0 * * * *… – Hourly, on the hour 0 */2 * * *… – Every second hour, on the hour
    • Press escape to stop editing
    • Hold down shift and press ZZ (Z key twice) to save and quit
  7. You’re done. Wait a little bit and it’ll update, or if you like, run it immediately from Terminal (~/Library/Scripts/sync-status-with-twitter.rb).

If you want to update Facebook too, you have two options: Either use the excellent Facebook plugin for Adium (comes with the latest version), and it’ll happen all by default [Edit: Looks like I’m wrong; Adium won’t update Facebook] , or add the Twitter application to Facebook itself.

This script was inspired by a similar script by John Nunemaker over at RailsTips.org. Thanks, John.

Update: Bed has made some changes which will ignore @reply messages.

Update: I’ve also added an implementation to ignore @reply messages

Update: I’ve added a provision to only update the status if you’re not set as away – if you’re away, the status message will remain unchanged.

, , , . Bookmark the permalink. Both comments and trackbacks are currently closed.

18 Comments

  1. Posted February 3, 2009 at 11:43 am | Permalink

    Thanks for the script – very useful! FYI I’ve done a small mod to ignore @reply tweets, see http://abednarz.net/wp/twitter-adium-status-syncing-ignoring-replies/.

    • Posted February 3, 2009 at 11:47 am | Permalink

      Great idea, Bed; I might integrate your changes, if you’re okay with that!

      • Posted February 3, 2009 at 11:49 am | Permalink

        Of course! There may be a more ruby-elegant way to do it, this was my first experience with it.

  2. Posted February 15, 2009 at 3:25 am | Permalink

    Thanks, works perfect! And what’s the procedure to stop the syncing? Just in case…

  3. Posted February 15, 2009 at 3:26 am | Permalink

    so i mean, how do you stop the crontab-thingie? Thanks!

    • Posted February 15, 2009 at 9:43 am | Permalink

      You open Terminal again, type crontab -e to edit the crontab, delete the line you entered with this tip (you can press ‘dd’ to delete the current line, for example), then save and quit (‘zz’).

  4. Posted February 16, 2009 at 3:38 am | Permalink

    Thanks! It still works flawlessly!

  5. Posted February 28, 2009 at 9:32 am | Permalink

    I get the following error when I try to run the script: /Users/marn/Library/Scripts/sync-status-with-twitter.rb:39: undefined method `text' for nil:NilClass (NoMethodError) Any ideas?

    • Posted February 28, 2009 at 10:04 am | Permalink

      There's no error checking in the script (mostly because I'm a bit lazy sometimes), so unfortunately it doesn't give very helpful feedback if there's a problem – that error suggests to me that either it has an invalid twitter name, or a network problem – In this case, it's trying to get 'text' (the content) from an element in the Twitter timeline RSS, but it couldn't find that element (which is why it's "nil:NilClass"). Make sure you're using the right twitter name and that your network connection's solid.

  6. Kegan
    Posted September 22, 2009 at 7:26 am | Permalink

    Script works wonderfully except for a stray “” on the end of each tweet.

    I.E. “just got home from school.”

    Any idea on how to correct this? Using Adium 1.4b9, OSX 10.6.1.

  7. Kegan
    Posted September 22, 2009 at 7:28 am | Permalink

    Sorry, I meant /content, except with brackets around it. Doesn’t display correctly in this comment system.

    I.E. “just got home from school./content”

  8. Kegan
    Posted September 27, 2009 at 5:26 am | Permalink

    Nevermind, fixed it myself by parsing it out. Nothing like a crash course in Ruby!

  9. Neelix
    Posted October 6, 2009 at 10:56 am | Permalink

    Hi Kegan,

    I’ve the same problem. Can you post your fix please? :) Thanks!

    • Kegan
      Posted October 8, 2009 at 6:29 am | Permalink

      Okay, so you’re going to insert this line of code:

      message = message[0,message.length-10]

      after this line in the program:

      exit if ! message

      It’s a pretty remedial fix, given that I don’t know Ruby. I’m sure there’s a more sensible fix.

      • Neelix
        Posted October 8, 2009 at 8:16 am | Permalink

        Thanks a lot, Kegan! :)

  10. Posted July 27, 2010 at 1:00 am | Permalink

    Thanks!

    I tweaked the script to let me use my most recent last.fm track – posted here: http://trepmal.com/scripts/lastfm-ichat-status/

  11. Sascha
    Posted September 27, 2010 at 10:50 pm | Permalink

    Thank you for this script! Unfortunately, I don’t get it work. I only get an error message when I try to launch it: $ ~/Library/Scripts/sync-status-with-twitter.rb 287:291: syntax error: Expected “then”, etc. but found identifier. (-2741) Maybe you have an idea how to fix it.

  12. Posted October 8, 2010 at 2:26 am | Permalink

    This causing my computer to restart after letting the cron job run while the computer is asleep for several hours. Some applications will block restart with a modal dialog message, but this behavior isn’t consistent.

    I did run into a few problems getting the script up and running including an issue with “Adobe Unit Types”. See the details of the error message and how I fixed it here: http://jpgrace.com/blog/2010/10/automatically-syncing-twitter-status-with-ichatadium/

    Frankly, I’m just blindly digging through console logs searching for things I think it might be and coming up with nothing.

    Does anyone have any ideas as to why this may be happening? Pointing me in the right direction would be greatly appreciated.

    Thanks!