#!/usr/bin/env ruby

print "Content-type: text/plain;\n\n"

require 'steam-condenser'

for friend in SteamId.new('bungmonkey').friends do
  Thread.new(friend) do | localfriend |
    begin
      localfriend.fetch
      printf("%s %-25s %s\n", localfriend, localfriend.instance_variable_get(:@nickname), localfriend.instance_variable_get(:@state_message).gsub(/<.+?>/,' '))
    rescue Exception => e
      print localfriend, " FAILED: ", e, "\n"
      next # sometimes a profile doesn't exist
    end
  end
  sleep(0.05)
end
