1. May 5th, 2008

    Distributed Twitter Client in 20 lines of code

    There you go.

    require 'rubygems'
    require 'xmpp4r'
    require 'xmpp4r/roster'
    
    puts 'Connecting ...'
    client = Jabber::Client.new(ARGV[0]).connect('talk.google.com')
    client.auth(ARGV[1])
    puts 'Receiving'
    roster = Jabber::Roster::Helper.new(client)
    roster.add_presence_callback do |roster_item, old_presence, new_presence|
      if new_presence
        from = roster_item.iname || "#{new_presence.from.node}@#{new_presence.from.domain}"
        if new_presence.status
          puts "#{from}: #{new_presence.status}"
        end
      end
    end
    client.send(Jabber::Presence.new)
    Thread.stop
    client.close

    Run from the command line:

    $ ruby distwit.rb <jabber_id> <password>
    Connecting ...
    Receiving
    Andre Lewis: Away
    Matthieu Riou: Enjoying a JavaOne couch
    Matthieu Riou: Entertaining Assaf
    Alexis Midon: hacking in a couch @community-one 

    Now just wait for your friends to status away using their IM client.

    And don’t forget, please yo-yo the rrm.

    1. May 6th, 2008

      Joe Cascio

      Very interesting and ties right into this post I just made about Distributed Twiiter. Would be interested in your take on it.
      http://tinyurl.com/6j7×79

    2. May 7th, 2008

      Erik Kastner

      Here’s something:
      http://pastie.textmate.org/pastes/178297
      One line twitter bot

    3. May 7th, 2008

      Marcus Breese

      Similar thing in Python:
      http://snippets.dzone.com/posts/show/5474

      This type of distributed system makes a lot of sense… But the largest problem that I see is that people already have a GUI IM client that they can use. So, what would the client for this really be? Another GUI IM(-lite) client? Would it be a web-based tracker (with the server tracking each person’s roster)?

      I think it doesn’t quite live up to the ease of using Twitter, namely the lack of anything to install.

      Now, I could see a web app that you gave your IM credentials to, and it tracked the people that you follow. You could then update your status there as well. But what you don’t necessarily want to (or expect to) receive IMs from everyone that you are tracking.

    4. May 7th, 2008

      Assaf

      I would implement something like this as a Web-based tracker. Then you can use it from a browser, feed reader, write all sorts of fancy clients around it, e-mail notifications, SMS in/out, filtering, etc. It’s just replacing one piece of infrastructure with another that’s decentralized. You could be using your service, I would be using mine, and we’ll both be able to see each other’s statuses.

      This example is intentionally simplified to show that XMPP already solved that problem, and something you can run from the command line to see what the timeline looks like (and no, you won’t be receiving any IMs, only status updates).

      A real implementation would look different, for one you’ll want to run an XMPP server not multiple client threads polling for each user, but the concepts are all the same: use XMPP to decentralize and exchange statuses.

    5. May 9th, 2008

      links for 2008-05-09 « Breyten’s Dev Blog

      [...] Labnotes " Distributed Twitter Client in 20 lines of code (tags: jabber presence ruby status twitter xmpp) [...]

    6. May 26th, 2008

      Bre Pettis – A Dream – Open Source Distributed Microblogging at I Make Things

      [...] your personal info off of proprietary networks. – Link Distributed Twitter in 20 Lines of code. – Link APML – Link XXMP – Link « Getting Started in Video: [...]