All pastes #255009 Raw Edit

Untitled

public text v1 · immutable
#255009 ·published 2006-11-22 15:33 UTC
rendered paste body
require 'rinda/ring'
require 'rinda/tuplespace'
require 'timeout'


def bot_say msg
  DRb.start_service
  ring_server = Rinda::RingFinger.primary
  if ring_server 
    begin
    Timeout.timeout(5){
      bot = ring_server.read([:name, :BCMBot,nil,nil])[2]
      bot.say(msg) if bot
    }
    rescue Timeout::Error
      puts "no response from server"
    end
  end
end


if __FILE__ == $0
  msg = ARGV[0] || 'hello world'
  bot_say msg
end